Author Topic: Old topic. Beating a horse. LDR in place of Potentiometer.  (Read 9106 times)

william

Old topic. Beating a horse. LDR in place of Potentiometer.
« on: April 12, 2015, 11:13:59 PM »
I've been thinking about ways to use a LDR in place of a pot and would like a critique of my current idea.

My thought is using two LDRs.  One is to act as the variable resistor, the other is to provide feedback to the MCU as to what the current resistance is.  The resistance is set by a pot of the correct value connected to an analog input of the MCU.  The MCU reads the voltage between a resistor and the Tone pot.  It then adjusts a digital pot until the feedback LDR achieves the same voltage. 

Because the variable resistor LDR and feedback LDR are connected to the same digital pot they should be close to the same value.  I don't believe the two LDRs will be too far from each others value after adjustment but it shouldn't matter as you should be able to achieve the same value each time. 

R2 and R3 are used to tune the LDRs to be close to the same value and close to the maximum target resistance.

The problems I can see now is if it is the tone pot is a logarithmic pot the digital pot will have less resolution at low values. The LDRs might drift apart over time.  And the MCU will need software control to ensure the value of the LDRs do not bounce back and forth trying to get close to the value of the tone pot.

Here is kind of what I have in mind.  Thoughts?


Digital Larry

Re: Old topic. Beating a horse. LDR in place of Potentiometer.
« Reply #1 on: April 12, 2015, 11:46:22 PM »
I made an analog servo gain with an op-amp feeding the LED shining on a center-tap LDR.  Half was in the servo loop and the other half was the controlled resistor.

The controlled resistance was grounded (it was like the mid control on a Fender notch type circuit) The target voltage/resistance was set by an R/2R DAC being driven by an 8031.  So you don't really even need to do it with the microcontroller although it would save an op amp.  It sounds do able though you may encounter some real world obstacles such as you mentioned.  Interested to hear what happens.
« Last Edit: April 13, 2015, 09:02:37 AM by Digital Larry »
Digital Larry
DSP tinkerer and former transistor twister

william

Re: Old topic. Beating a horse. LDR in place of Potentiometer.
« Reply #2 on: April 12, 2015, 11:53:02 PM »
It sounds like you used a similar method that the Triaxis uses.  I have thought of that but the R/2R ladder seemed somewhat limited.  To get any decent number of steps you end up using a lot of resistors with no benifit.  I'm thinking with a digital pot with a high enough resolution (256 steps) you can have more accuracy.

Digital Larry

Re: Old topic. Beating a horse. LDR in place of Potentiometer.
« Reply #3 on: April 13, 2015, 09:05:52 AM »
I wasn't really recommending the use of an R/2R ladder compared to anything else.  Mostly I was just confirming that you could use a pair of LDRs in a servo arrangement - one for linearizing feedback and one to do what you wanted to do in the audio circuit.  I don't know about matching and drift over time, but at least they'd probably be close to the same temperature and you could check them for matching ahead of time.
Digital Larry
DSP tinkerer and former transistor twister

MetalGuy

Re: Old topic. Beating a horse. LDR in place of Potentiometer.
« Reply #4 on: April 13, 2015, 04:15:45 PM »
No need to reinvent the wheel. Below are the two most informative threads on the subject of LDR pots and relay pots that I know of and it's not only theory and small talk:

http://music-electronics-forum.com/t1015/

http://music-electronics-forum.com/t27058/


william

Re: Old topic. Beating a horse. LDR in place of Potentiometer.
« Reply #5 on: April 13, 2015, 11:42:02 PM »
I have read the first thread you posted.  They talk about a servo setup like Digital Larry was talking about.  I wanted to avoid something like that because you either setup a R/2R ladder as mentioned earlier with the taper you want, as is was done on the triaxis.  Or you can use a digital pot as in the thread.  I wanted to avoid a R/2R ladder because my experience is that it limits the resolution and creates a noticeable step between settings.  And a Digital pot will need to have the correct taper, so if you need a special taper or mixed Log and Linear tapers you have to use multiple digital pots.

The second thread I haven't seen but I always hear people talk about using relays attached to a R/2R network.  I wanted something compact and simpler than that.

The taper of the Tone pot will be reflected in the voltage at AIN1.  The taper of the digital pot doesn't really matter.  It just needs to match the voltage of AIN2 with AIN1. 

It seems like you save on parts.  No switching components, fewer resistors, no op-amps and no dedicated op-amp power supply.  Also the value of the tone pot can be easily changed.  With R/2R ladders you have to change the resistors, and with digital pots you have to desolder a bunch of leads.

I'm thinking of building a GCB-95f wah and trying a LDR pot for control.  The topic has been viewed 150 times with only two comments so I guess that is a good sign either no one actually cares to talk theory or they don't see anything wrong that I haven't anticipated.  Or don't care, anyways the next step will be to get the two LDRs from my local dealer.

free electron

Re: Old topic. Beating a horse. LDR in place of Potentiometer.
« Reply #6 on: April 14, 2015, 04:43:38 AM »
One factor you need to take into account is the max current you are allowed to pass through the digital pot terminals, usually in range of few mA (check the datasheet). Is it enough to fully drive the led? Which brings another question: why not use a DAC or PWM or lowpass filtered PWM to drive the leds? Many modern MCUs are equipped with 12bit DACs or even higher bit depth PWM drivers, you can create any taper you imagine using simple lookup tables and interpolation.
Btw, using an MCU you could do some kind of automated LDR matching/response compensation, too.

snarblinge

Re: Old topic. Beating a horse. LDR in place of Potentiometer.
« Reply #7 on: April 14, 2015, 06:19:47 AM »
I have a Wah on the bench, that I have been planning to marry to a digital pot controlled by arduino...for years.

One day I'll get it completed and test if it works,

I have a standard 100k pot for control. Arduino reads and outputs to the digipot a sweep. Have pot for speed and one for freq. range.

My subsequent easing, and I can't remember where. Suggested the digipot is noisy. My plan b is optocouplers controlled by pwm.

But need to get plan a sorted first. Mostly posting here to show solidarity and follow.
b.

snarblinge.tumblr.com

g_u_e_s_t

Re: Old topic. Beating a horse. LDR in place of Potentiometer.
« Reply #8 on: April 14, 2015, 10:51:46 AM »
just a few thoughts:

1. i am assuming youre adding digital in the loop so you can save/recall settings.
2. matching LDRs may be a problem, but as long a the 2 stay consistent with each other, youll mostly be setting your input pot by ear, so the exact mapping isnt critical.
3. your resolution will be limited by your ADC.  a lot of microcontrollers have 10b input, which is ok, but will probaby be lacking for a log taper pot.
4. if 10b is good enough for you, why not just use a 10b digital pot instead of an LDR?  swapping out an IC isnt that bad.  there is a limit to values/tapers for these, but it would be easier and fewer parts.
5. instead of using an ADC and a digipot, i think an opamp and DAC would give better results.  it would be higher resolution and faster response.  you could even go cheap and use a dual PWM DAC, which is just 2 resistors and a capacitor for 16b resolution (14b accuracy).  the basic idea here is that rather than doing the comparison/adjustment between the input pot and output reference with a micrcontroller (2 ADC inputs with low frequency response and low bit resolution), you use an opamp or comparator to compare the 2, and then send that signal to the microcontroller to servo the DAC to bring them closer.  using just a comparator would essentially be making a sigma-delta converter, and could be quite fast (limited by update time on interrupt -> DAC), and using an opamp/ADC gives you higher resolution as your only sampling the difference, not the whole signal, so youre basically zooming in.  the frequency response is also better, as youre only sampling 1 thing.

Digital Larry

Re: Old topic. Beating a horse. LDR in place of Potentiometer.
« Reply #9 on: April 14, 2015, 01:02:52 PM »
Just to chime in on the response speed.  When I did my design, I noticed that turn off time for LDRs is slower than turn on time (I think).  It caused a few problems where I was attempting to turn one thing up at the same time as turning another down - got a bit of a volume "bump" that I don't think we ever fully got under control. 
Digital Larry
DSP tinkerer and former transistor twister

digi2t

Re: Old topic. Beating a horse. LDR in place of Potentiometer.
« Reply #10 on: April 14, 2015, 02:21:37 PM »
Pardon me if I'm out of place here....

Has anyone considered replicating the method used in the Sonuus Wahoo? It uses some form of proximity sensor in the base, with a metallic (maybe magnetic?) target under the treadle.

Personally, I find this to be the cat's ass. I have one, and I find it just wonderful. Always accurate, and with a PC GUI, I can retune the sweep to whatever suits me. Not quite sure how it works on the digital side of things, but would it be that hard to replicate?

Alright... back to regular programming.... ;D
Dead End FX
http://www.deadendfx.com/

Asian Icemen rise again...
http://www.soundclick.com/bands/default.cfm?bandID=903467

"gigantically smaller."  - pinkjimiphoton

william

Re: Old topic. Beating a horse. LDR in place of Potentiometer.
« Reply #11 on: April 14, 2015, 02:58:09 PM »
Pardon me if I'm out of place here....

Has anyone considered replicating the method used in the Sonuus Wahoo? It uses some form of proximity sensor in the base, with a metallic (maybe magnetic?) target under the treadle.

Personally, I find this to be the cat's ass. I have one, and I find it just wonderful. Always accurate, and with a PC GUI, I can retune the sweep to whatever suits me. Not quite sure how it works on the digital side of things, but would it be that hard to replicate?

Alright... back to regular programming.... ;D

It is using some sort of RF proximity sensor.  My guess is it is using a voltage controlled filter of some sort.  A hall effect sensor could be used to get the same control.  I know the Rock Band drum set uses a hall effect sensor for the kick drum.  Similar idea I think.

I'm going with LDR's not simply for the wah.  If the wah works I'll try implementing it into a Slo 100 OD preamp I designed as the gain control.  The tone controls would then be from my G-Major.  But that is in the future.

anotherjim

Re: Old topic. Beating a horse. LDR in place of Potentiometer.
« Reply #12 on: April 15, 2015, 05:52:43 AM »
You can increase the resolution of a 10bit ADC by oversampling - run it faster and simply add consecutive readings. Each addition increases the word length by 1 lsb. This also tends to average out noise induced errors in the ADC, which is useful if pin usage on a small MCU means you can't have an external filtered ADC reference voltage and have to use an internal reference without filtering.


"The passage of my life is measured out in shirts" - Eno

I've only done it once, so now I'm an expert.

g_u_e_s_t

Re: Old topic. Beating a horse. LDR in place of Potentiometer.
« Reply #13 on: April 15, 2015, 11:32:18 AM »
You can increase the resolution of a 10bit ADC by oversampling

this is true, but there are some limitations.

1. the amount of bits increase linearly as you described, but the noise also increases (but not as fast), so the SNR and usable bit depth increases with the square root of the number of extra samples.  so if you take 4 samples, you get a factor of 2 improvement, which is one extra bit.  if you take 64 samples, you get a factor of 8 improvment, which is 3 extra bits.

2. you can only sample so fast before youre no longer getting 10b on your ADC.  and you can only average so many samples before there is lag/stutter in your input response.  so for a typical 8b microcontroller, its only reasonable to expect to get 2 to 4 extra bits, depending upon the response rate you need.

3. it only works on getting rid of uncorrelated noise (generally speaking - white noise), and things like distortion and some pick-up noise will still be at the same level.

william

Re: Old topic. Beating a horse. LDR in place of Potentiometer.
« Reply #14 on: June 07, 2015, 01:21:31 AM »
It doesn't work.  I can't get the Photocell not to turn completely off.  I've tried a couple things and it always goes from <10M to about 600ohm.

slacker

Re: Old topic. Beating a horse. LDR in place of Potentiometer.
« Reply #15 on: June 07, 2015, 05:31:32 AM »
You'll always have that problem with LDRs, they will all have a minimum resistance some might go lower than others but none will go to 0 Ohms. Most of the time you can adjust the other components in the circuit the LDR is part of to account for the minimum resistance and make it not matter.
« Last Edit: June 07, 2015, 05:47:39 AM by slacker »

anotherjim

Re: Old topic. Beating a horse. LDR in place of Potentiometer.
« Reply #16 on: June 08, 2015, 07:58:04 AM »
A trick is to scale the LDR resistance by careful choice of series and/or parallel fixed resistors and also scale the LED brightness range with its series resistance. Depends on the function of the control the LDR is replacing. Not many stompbox controls need to go to exactly zero ohms and some examples of control pots don't either. Check the circuit, some pots will have a fixed resistance in series to limit the current - your LDR already has 600ohms so you can reduce that fixed resistance accordingly.

For a tone/gain pot that's working as a variable resistance and the original manual pot range is 0 to 5k, you can put some fixed resistor in parallel with the LDR - perhaps even as low as 5k but not lower, but perhaps more like 10k. If the PWM or DAC controlling the LED can range 0-5v, you want a series LED resistor that causes the LDR control to sweep 0 to 5k over the full control voltage range.
You won't achieve 0 ohms of the LDR, but the lower the parallel resistance can be, the closer to 0 it can get.
The parallel resistor will cause a logarithmic response, which could be right for the job.
"The passage of my life is measured out in shirts" - Eno

I've only done it once, so now I'm an expert.

Tightpants

Re: Old topic. Beating a horse. LDR in place of Potentiometer.
« Reply #17 on: June 08, 2015, 01:41:34 PM »
Have a look at this Silonex application note: http://www.cresttech.com.au/pdf/Silonex/levelcontrol.pdf
It explains how to use two optocouplers in series/shunt mode to better approximate a potentiometer. I think it helps if the optos are matched. The arrangement in Figure 10 approximates a 5K pot and can be controlled direct from a single pwm signal (I tried it and it works well). You will get some slight drift from light memory effects and some variation with temperature but it's really not too bad.

william

Re: Old topic. Beating a horse. LDR in place of Potentiometer.
« Reply #18 on: June 09, 2015, 10:14:22 AM »
Yea, I should have mentioned I was aware that no LDR goes fully to zero.  It was more the off value that I was concerned about getting correct.  I can't get the LDR to stop at 10k or 250k or 1M close to it.  It always ends up going completely off and thus greater than 10M of resistance..

MetalGuy

Re: Old topic. Beating a horse. LDR in place of Potentiometer.
« Reply #19 on: June 09, 2015, 04:20:32 PM »
My advice is go with the 4 pin (refers to the number of photocells' pins) photo cell design the Mesa Triaxis style. Since the original Hamamatsu part# P873-13 is not readily available what you need is:
1/ Carefully choose the photocells you need in order to get minimum resistance and at least couple of MOhms dark resistance. For example check NSL6112 and VT935G-A. I used them for 1Mohm LDR 4 pin pots and they work. If you're using a shunt regulator or a Presence type of LDR pot you can use a single 3 pin VTL5 type.
2/ Put together a 4 pin LDR
3/ Use the circuit from the thread above.