I would like to output whole number voltages 0V,1V,2V,3V and 4V from two digital pins on an arduino/5V source. A simple r2r ladder doesn't seem like it would work because it would split its definition across the whole 0-5V range. Is there a way to lower the 5V output to 4V and then feed it into a 2 bit r2r ladder?
Asked
Active
Viewed 638 times
2
-
2Filtered PWM would be the simplest, if you can suppress - or live with - any ripple. – Dampmaskin Jul 31 '17 at 23:45
-
What current out? – Tony Stewart EE75 Aug 01 '17 at 00:44
-
A silicone and a germanium diode in series should be about 0.7V + 0.3V = 1V drop. – Passerby Aug 01 '17 at 01:14
-
I can't really live with any ripple as this will be controlling the pitch of an instrument. The diode idea is interesting thank you! – Garrett Dreyfus Aug 01 '17 at 01:19
-
There will always be ripple as well as some DC error. Do you need it to be very precise and accurate? Like 4.000V? Or does it just need to be close to 4V (and 1 and 2 and 3V, etc)? – user57037 Aug 01 '17 at 03:54
-
use an external DAC and a series pass supply. – dandavis Aug 01 '17 at 17:00
-
The arduino already has a external dac which is connected to a 4 channel multiplexer. I was hoping to take some of the load off the dac with a simpler circuit that could be controlled with just two digital pins. – Garrett Dreyfus Aug 01 '17 at 17:36
1 Answers
-1
simulate this circuit – Schematic created using CircuitLab
As the gentleman in your comment mention, you can use a pwm output the voltage you want. Let's say you let it switch at 1kHz and you want 4V.
In that 1ms, on 0.8ms and off 0.2ms. You would get close to 4V.

Jason Han
- 1,720
- 9
- 22
-
1In other words, when he use analogWrite to a pin (which effectively sends a PWM on that pin) he should limit himself to multiples of \$\frac{255}{5}=51\$. So analogWrite(51) => 1V, analogWrite(102) = 2V. -- On another note, can you explain why C1 is enormous and why R1 is in the circuit? Wouldn't it be more wise to set R2 to 100kΩ and C1 to 1µF and remove R1? – Harry Svensson Aug 01 '17 at 01:33
-
Well, it depends on application. The R2 and C1 will form a low pass filter and will reduce the ripple in the voltage much better. Pumping an AC voltage into a cap directly is actually shorting the MCU pin, so need to take note on that. If the output side can tolerate higher ripple, then C1 can be further reduce. I saw other design changing R1 into a diode but writing the program will be more complex and it needs to factor in the forward voltage of 0.7V. – Jason Han Aug 01 '17 at 02:35
-
1
-
To the OP, please give consideration to @HarrySvensson 's excellent comment. – user57037 Aug 01 '17 at 03:50
-
The problem with PWM + capacitor is that I can tolerate very little "ripple" as the output voltage will control the pitch of an instrument. – Garrett Dreyfus Aug 01 '17 at 14:23
-
@GarrettDreyfus The situation is as you describe, but why is it a problem? Is it because changing from 4V to 3V would necessarily be an elision? A semitone is circa 8% frequency change, and 1 kHz PWM with the given RC values about 1% 'ripple' or vibrato. – Whit3rd Aug 02 '17 at 08:28