The first circuit design for the VC-1 was a bit unstable and very dependant on the quality of the control signal. Since the goal here is to control the resistance with a PWM signal from the micro-controller, the control signal is going to be a fixed frequency square wave with a variable duty cycle (variable power-on period). I had tried an RC filter with no success. I ended up using a transistor and a programming trick to push the PWM frequency out of the audio range. The PWM programming became tricky, as a wrong value would load the response curve, to the point where distortion became a problem. In effect, some values would push the circuit into a nice “receiver” mode and I could hear radio talk on the amplifier!
Also, the circuit was using two PWM pins from the micro-controller, each with its own code to modify the response curve and additional code to balance the responses of the two opto-couplers used.
Here’s the new circuit (adapted from the Silonex web site):
How it works
As before, the INPUT signal goes into the first opto-coupler, while the second opto-coupler is connected to ground. This is known as a “series/shunt” volume control circuit. The audio signal goes through the first LDR. That’s the “series” part. The output audio signal is tied to ground (analog ground) through LDR number 2. This is the “shunt” part. The OUTPUT connection is equivalent to the wiper connection on a standard potentiometer.
The changes were made on the control side (left). The control voltage (PWM1) is expected to vary from 0 to 5 volts. When using a potentiometer, the circuit sees a nice regular voltage variation. When using a digital signal, like a PWM signal, the circuit is fed a rapidly switching 0-to-5 volt series of pulses. Because the light from the LEDs inside the opto-couplers will vary rapidly in sync with the control signal, some audio artifact might “bleed” through the analog signal on the LDR side. The solution is to use an RC filter to produce a varying voltage from the switching peeks of the PWM signal. Click here for a good explanation of RC circuits. According to the RC rules(and this site), using a 1.2K resistor with a 22uF capacitor will remove most of the ripple from the signal and still respond quickly to a change in PWM duty cycle, and produce a smooth volume curve with minimum induced distortion on the audio side.
Feeding the LEDs, the 5 volt source voltage is going through 2 diodes in series which lower it to 3.6 V (5 -0.7 -0.7). The idea here is that the resistance of the opto-coupler varies nicely for part of its range, but varies more rapidly near the end. Having a voltage limiter solves part of the problem. The 470 Ohms resistors limit the current through the LEDs. The LEDs inside the opto-couplers have a voltage drop of 2.5 V. All the resistor is doing is controling the current through the LED. If we have 3.6 – 2.5 = 1.1 V max through the resistor, V/R = I, 1.1/470 = 2 mA MAX going through that LED when the PWM duty cycle is zero. The response curve for the opto-coupler shows that the resistance for the LDR varies a lot when current through the LED goes from 0 to 1 mA, effectively going from >25 MegOhms to a few hundred Ohms. Letting more current through (up to 20-25 mA will lower the resistance from a few hundred to around 60 Ohms. I measured a maximum current of 1.6 mA through that LED when zero volt is present on the control input. As the voltage on the control input rises, the LED – connection is becoming “less negative” with respect to the LED + side. At some point, the LED shuts off and goes dark. The LDR’s resistance goes quickly to >20 MOhms. At the same time, as the control voltage goes up, the + side of the second LED becomes more positive than its – side. Eventually, the LED turns ON and shines a little light on the LDR. This will smoothly reduce its resistance and shunt the signal to ground to lower the output volume, while balancing the impedance seen on the output side of the circuit.
Ideally, both opto-couplers should have the same response curve. Silonex recommends using their NSL32SR3S series of matched LDRs. I only had unmatched units to build the circuit but the results were just fine. I suspect that matched components would provide a more balanced impedance, but because I use a good line buffer, the very low impedance going into this circuit is not affected too much by the irregular impedance curve.
I am now ready to build a few PCBs and field-test the device. The PCB will allow some circuit modification to account for variable specs of some of the components. One or both 470 Ohms resistor could be replaced by 500 Ohms potentiometers.
This circuit is (strongly) inspired by the sample circuits provided by Silonex. Take a look at this Silonex sample circuits for level contro PDF file.
How’s the VC-1 coming along?
Hey, looking forward to seeing the finished product 🙂
wow! good job!
what is the frequency of the pwm that you are using?
After I modified the design for this circuit, I used the standard Arduino/AVR PWM frequencies for those pins. I think that it is 32K Hz. The modified circuit acts as a reasonable high and low-pass filter.
great! thanks! I’ll test it
Very intersting this application of LDR!
Just a question, Can you use this type of circuit to substitute
a volume potentiometer of a tube amplifier?
It should work. Basically, the circuit emulates a 5K pot. It could be modified to emulate other pots. Impedance control is the key when designing pot circuits.
was looking to adapt this to use for contrast control on glcd , the glcd has a inbuilt 15v neg output with a 10k pot to 5v with the wiper to contrast control , would it work ?
It should work. You might have to add a resistor if the range of the circuit is too narrow. Either between P$4 and Ground or P$3 and Output. The circuit emulates a 5K pot, so it might need some help to emulate the 2K that you have. Easy enough to try.
I was wondering, why did you use two 1N4148 for the first LDR, while only one 1N4148 for the lower LDR?
Why did you use two diodes for the first LDR, then one diode for the second one?
Two diodes in series provide twice the voltage drop. I just use the diodes to make sure the voltage is controlled. Each of these diodes, from its datasheet, has a voltage drop of 0.7 Volt. The second LDR uses only one diode to provide a better response curve to imitate a regular potentiometer. Look at the new file link that I added to the post in the notes at the bottom for sample circuits.
Question: why not control the two LDRs independently from the arduino? Arduino output resolution is 8bit (256 steps), but if you vary the output of the +LED and the -LED independently, you could get 9bit resolution. As I read your circuit now (please correct me if I’m wrong), you are increasing the voltage to one LED and decreasing it to the other at the same time, just like a pot.
I have found that 128 steps is plenty for the typical use of this volume control. It is generally used to quickly lower or raise the volume and not much for “finessing”. For that, I would use the guitar volume pot.
I am increasing the voltage on one LDR while decreasing the voltage on the other to balance impedance in the circuit. A single standard pot does that by itself but my circuit needs two devices (the LDR only has two pins…). I had a test version that used two Arduino pins for finer balance, and using a programming trick I could modify the impedance curves. It was fun to try, but not really useful, although it could be necessary if the two LDR had very different curves. I have a stock of them and pair them (testing with a voltmeter) for impedance.