I've got a microcontroller taling to a DAC MAX520ACPE over i2c. This DAC gives me 0V to 5V with 8bit presision. I neev to control 0Vto 8V. I think I can use a LM317 to regulate the output voltage but I don't know how to connect the output of the MAX520ACPE to the LM317.


enter image description here


enter image description here

  • \$\begingroup\$ How much current must the 0-8V output supply, and what will the programmable voltages be used for? \$\endgroup\$ Dec 31, 2016 at 19:21
  • \$\begingroup\$ The 0V-8V power will run some small Z scale trains. Each output would need no more than 400mA. I'll add a picture for what I think my power input is. \$\endgroup\$
    – Justin808
    Dec 31, 2016 at 19:25
  • 2
    \$\begingroup\$ This is typically done with an H-bridge IC and pulse width modulation, not a DAC and linear (analog) power amplifier. For tiny motors in a Z scale train you probably want a PWM frequency in the KHz range (you can always filter it, too). Overall, it's a case where looking at what people in your field of use are already doing (include N gauge and even HO solution in your search) will likely be more productive than trying to invent something from first principles. \$\endgroup\$ Dec 31, 2016 at 19:30
  • \$\begingroup\$ The LM317 requires about 3 volts "headroom" for operation - that is, the input voltage must be about 3 volts above the desired output voltage. \$\endgroup\$ Dec 31, 2016 at 19:32
  • \$\begingroup\$ "Z scale trains" - that explains the 'railx' outputs! \$\endgroup\$ Dec 31, 2016 at 20:29

1 Answer 1


To get 0-8V from 0-5V you must amplify the DAC output voltage by a factor of 8/5 = 1.6. However the LM317 regulates its output voltage to 1.25V above the ADJ pin, so you will also have to bias it with -1.25V. The circuit below should do the job:-


simulate this circuit – Schematic created using CircuitLab

R3 and R4 set the non-inverting voltage gain of OA1 to (R4+R3)/R3 = 1.6. R1 and R2 provide a bias voltage of 2.083V to the inverting input. The formula for Inverting gain is -(R4/R3), so the bias voltage output is 2.083*-(60k/100k) = -1.25V. V3 provides the negative supply voltage that the op amp needs to pull its output below ground.

The LM324 has 4 op amps in it so you only need one IC to do 4 channels. The negative supply voltage is not critical (just has to be at least -2.2V) and only a few milliamps is required, so you could generate it from the +5V supply using eg. an ICL7660 or LM555.


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.