Arduino based LDR volume and source selection controller

With the consent of Vincent I am posting my modified source. Tested with genuine Apple silver remote and encoder PEC11R-4220F-S0024 using ide 1.6.5 (may also work with our builds).
Changes :
1. Added newPulseIn and changes to getIrKey to improve repeat behaviour and immunity to other IR remotes like squeezebox touch.
2. Added mute functionality to setInput to mute input when changing source.
3. Changed encoder ISR functionality to reject encoder bounce especially at high rotation rates.

https://dl.dropboxusercontent.com/u/17920263/firmware_LDR_v1.0.ino
 
With the consent of Vincent I am posting my modified source. Tested with genuine Apple silver remote and encoder PEC11R-4220F-S0024 using ide 1.6.5 (may also work with our builds).
Changes :
1. Added newPulseIn and changes to getIrKey to improve repeat behaviour and immunity to other IR remotes like squeezebox touch.
2. Added mute functionality to setInput to mute input when changing source.
3. Changed encoder ISR functionality to reject encoder bounce especially at high rotation rates.

https://dl.dropboxusercontent.com/u/17920263/firmware_LDR_v1.0.ino

Thank you Wineds for your contribution!!
 
Argh. Spent 30 minutes typing a reply only to get an expired token and lose it all, so this is a condensed retype!

Presumably those of you who've built the I/O side have it working OK? My relay isn't latching properly and I'm getting some strange voltages across it - it will go one way but the reverse voltage is never enough (around -2.5V) for it to unlatch...

Maybe this is linked to what I wonder may be strange voltage levels coming out of the ULN2003? I get around 11.4V when logic high (maybe 0.6V is dropped from the diodes inside the IC), but around 0.5V for a logic low. Does this look right? MCP23008 logic levels are OK.
 
Argh. Spent 30 minutes typing a reply only to get an expired token and lose it all, so this is a condensed retype!

Presumably those of you who've built the I/O side have it working OK? My relay isn't latching properly and I'm getting some strange voltages across it - it will go one way but the reverse voltage is never enough (around -2.5V) for it to unlatch...

Maybe this is linked to what I wonder may be strange voltage levels coming out of the ULN2003? I get around 11.4V when logic high (maybe 0.6V is dropped from the diodes inside the IC), but around 0.5V for a logic low. Does this look right? MCP23008 logic levels are OK.

Probably not that helpful to you but I did mange to get the 3 input board working with latching relays. What sort of IO are you trying to setup? Did you define this correctly in the code :

#define TIME_RELAYLATCH 250 // Time in millisec for latching I/O relay driver to stabilize (0 if not using latching relays)

I think your ULN2003 output levels look OK.
 
Last edited:
Hi Wineds,

Thanks. I do have the 250ms set up in the code.

I redrew the board (and IO) and had a set of PCBs made up - but electrically, it's the same stuff.

BTW, I did try your version of the code and it behaved in quite an unstable manner - the encoder often didn't register, and it looked like the arduino crashed, but then responded with a few seconds delay. I haven't looked into that. I will once I get my head around what should be a trivial relay driving problem :)
 
Yes, I'm using 1.6.5.

In fact, I'm still using the original code on 1.6.5 which as we've said, has issues, but I thought this was only for the IR bit. Maybe I'll double check with Vincent's recommended version in case that has an effect... Your version compiled and uploaded without any problem. It works, it just seems unreliable with my particular setup. But I far more basic problems to sort out first - I'm sure your version works great :)
 
Relay problems sorted. Well, kind of, except, I have manged to read the datasheet the wrong way round. Not a big problem, I guess I can change the code so it's the other way around.

Still have some strange stability problems though with the rotary encoder. Often, there's a delay between a rotation / push and the arduino acknowledging it / showing on the LCD screen. The delay can be a few seconds. If I touch the Atmel uc, it seems to work far better / be more responsive. Need to get my head around that now!
 
Maybe this is linked to what I wonder may be strange voltage levels coming out of the ULN2003? I get around 11.4V when logic high (maybe 0.6V is dropped from the diodes inside the IC), but around 0.5V for a logic low. Does this look right? MCP23008 logic levels are OK.

You lose some voltage to the ULN2003. In my designs usually around 1.1V. I think this is called saturation voltage and is detailed in the datasheet.
 
Dear Vincent,

I had problem sourcing 5LN01SP on Farnell. Do you recommend other parts instead? What characteristic should I look into with MOSFET in this position?

Thanks,

Ken

Hello Ken,

The resistors around the mosfet are calculated for this model, so using another type may result in lower precision.
The characteristics we want here is a low Vgs(th).

5LN01SP are available at Mouser, who can ship globally.

Cheers,
Vincent
 
Hello Ken,

The resistors around the mosfet are calculated for this model, so using another type may result in lower precision.
The characteristics we want here is a low Vgs(th).

5LN01SP are available at Mouser, who can ship globally.

Cheers,
Vincent

Hi, Vincent

A comment to that is that it's convenient to order all components from the same supplier to save shipping costs. And Farnell seems to have most of the components at a reasonable price, (at least in Norway) with the exception of the 5LN01SP and the Rotary Encoder.
Do you know of any replacement for this components?

Thanks & regards
 
Hi Vincent
Is anybody with limited electronic knowledge (limited to use of soldering iron) can achive success in this project? Or can you provide and sell ready to solder pcb and parts as a kit? I want to make an LDR passive preamp and your project seems very promising for me with adjustable input and output impedance. It will be very good to have this project as a kit with a simple guide that can be implemented by the people like me with very little knowledge :)

GT-I9500 cihazımdan Tapatalk kullanılarak gönderildi
 
Hi Vincent
Is anybody with limited electronic knowledge (limited to use of soldering iron) can achive success in this project? Or can you provide and sell ready to solder pcb and parts as a kit? I want to make an LDR passive preamp and your project seems very promising for me with adjustable input and output impedance. It will be very good to have this project as a kit with a simple guide that can be implemented by the people like me with very little knowledge :)

GT-I9500 cihazımdan Tapatalk kullanılarak gönderildi

The simple answer is Yes, if you have the PCBs made, this is relatively easy project to take up and complete.

Without PCBs, point to point soldering of these components could be challenging, otherwise this is a nice simple project where failure chances are less.

The zip file in Post#1 has everything needed to construct the project including how to prepare arduino nano unit as part of measurement and calibration of LDRs.

The key is PCB and availability of parts in your region. I got all my parts sourced from Mouser through a friend returning from US and I could construct the boards in couple of days. Am using this as a volume control alone at the moment and have not used other features of I/O boards. So one input and output in my setup.

Am not a hardcore electronic engineer but only an enthusiast with knowledge on identifying components, read data sheets, how to solder and know what am doing when am dealing with mains voltage.

Hope this helps.
 
I ordered the majority of components from Mouser. Being based in the UK, the order had to be around 50GBP to get free delivery, but as delivery was something like GBP15, then as soon as you get near 35, you might as well add a few more bits as they'll be offset with the shipping.

I ordered enough to make around 4-5 preamps, and thought it would be useful in case I blow anything up! Delivery from Mouser was very good for me - around 3 days coming from the US to the UK :) For the other bits, I ordered from Farnell or RS (things like the relays).

In the end, I re-did the PCB following the schematic as I wanted to lay things out a little differently and take on a good PCB Kicad exercise at the same time. I had a bunch of PCBs made by shenzhen2u.

I've put one together and it's working fine from bench measurements (although I'm yet to listen to it - must do that soon!). The only issues I came across were self-inflicted :) Follow the great guide Vincent put together and you'll be fine. A great project that doesn't involve fiddly / tricky / precision SMDs.
 
The simple answer is Yes, if you have the PCBs made, this is relatively easy project to take up and complete.

Without PCBs, point to point soldering of these components could be challenging, otherwise this is a nice simple project where failure chances are less.

The zip file in Post#1 has everything needed to construct the project including how to prepare arduino nano unit as part of measurement and calibration of LDRs.

The key is PCB and availability of parts in your region. I got all my parts sourced from Mouser through a friend returning from US and I could construct the boards in couple of days. Am using this as a volume control alone at the moment and have not used other features of I/O boards. So one input and output in my setup.

Am not a hardcore electronic engineer but only an enthusiast with knowledge on identifying components, read data sheets, how to solder and know what am doing when am dealing with mains voltage.

Hope this helps.
Hey man thank you for the answer. Here in Turkey it is much easier to work with mouser electronics. For PCBs i will first try to work with local dealers. Now i am ready to order parts. Thank you for the help.

GT-I9500 cihazımdan Tapatalk kullanılarak gönderildi