# How to control 8V over I2C from a microcontroller

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.

Output:

Power:

• How much current must the 0-8V output supply, and what will the programmable voltages be used for? – Bruce Abbott Dec 31 '16 at 19:21
• 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. – Justin808 Dec 31 '16 at 19:25
• 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. – Chris Stratton Dec 31 '16 at 19:30
• The LM317 requires about 3 volts "headroom" for operation - that is, the input voltage must be about 3 volts above the desired output voltage. – Peter Bennett Dec 31 '16 at 19:32
• "Z scale trains" - that explains the 'railx' outputs! – Bruce Abbott Dec 31 '16 at 20:29