2
\$\begingroup\$

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?

\$\endgroup\$
7
  • 2
    \$\begingroup\$ Filtered PWM would be the simplest, if you can suppress - or live with - any ripple. \$\endgroup\$
    – Dampmaskin
    Commented Jul 31, 2017 at 23:45
  • \$\begingroup\$ What current out? \$\endgroup\$
    – D.A.S.
    Commented Aug 1, 2017 at 0:44
  • \$\begingroup\$ A silicone and a germanium diode in series should be about 0.7V + 0.3V = 1V drop. \$\endgroup\$
    – Passerby
    Commented Aug 1, 2017 at 1:14
  • \$\begingroup\$ 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! \$\endgroup\$ Commented Aug 1, 2017 at 1:19
  • \$\begingroup\$ 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)? \$\endgroup\$
    – user57037
    Commented Aug 1, 2017 at 3:54

1 Answer 1

-1
\$\begingroup\$

schematic

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.

\$\endgroup\$
6
  • 1
    \$\begingroup\$ In 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? \$\endgroup\$ Commented Aug 1, 2017 at 1:33
  • \$\begingroup\$ 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. \$\endgroup\$
    – Jason Han
    Commented Aug 1, 2017 at 2:35
  • 1
    \$\begingroup\$ Uhm. Yeah. Okay. Good talk. \$\endgroup\$ Commented Aug 1, 2017 at 3:00
  • \$\begingroup\$ To the OP, please give consideration to @HarrySvensson 's excellent comment. \$\endgroup\$
    – user57037
    Commented Aug 1, 2017 at 3:50
  • \$\begingroup\$ The problem with PWM + capacitor is that I can tolerate very little "ripple" as the output voltage will control the pitch of an instrument. \$\endgroup\$ Commented Aug 1, 2017 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.