• Forums
• Posts
Latest Posts
Active Posts
Recently Visited
Search Results
• Page Extras
• Forum Themes
• AVR Freaks

### Voltage Regulator Control with DAC

Author
simong123
Lab Member No. 003
• Total Posts : 1391
• Reward points : 0
• Joined: 2012/02/07 18:21:03
• Location: Future Gadget Lab (UK Branch)
• Status: offline
0

# Voltage Regulator Control with DAC

Over time I have noticed a few people asking how to control, for example, a Buck regulator with a DAC over I2C or SPI for use in, for exmple, a PIC controlled Bench PSU or efficiently driving a Peltier cooler. (The Microchip MCP4725 is Ideal for this).
I have seen various methods proposed, including Digital Pot's, Op-Amps in the feedback loop, etc. However I have found that the simplest way is the best :)
The following circuit requires only 1 extra component (not including the DAC of course) - a simple Resistor.

How it works:-
It is best explained by considering the current into/out of the resistors where they attach to the regulator feedback pin.
The regulator will always drive the output such that the voltage at the feedback pin is at a fixed value (see datasheet for your regulator). In the case of the LM2670 pictured, it is 1.21V.
This being the case, the current through R1 (IR1) will be constant, and equal to the sum of the currents through R2 and Rb (Kirchoffs Law!)( note the current into the feedback pin will generate a small error, though as it is so low, it can usually be ignored ).
The current through Rb (IRb) is simply Rb x (DAC Output - 1.21V).
The current through R2 (IR2) equals IR1 - IRb

The voltage drop accross R2 (VR2) is then R2 x Ir2, which gives the Regulated Output Voltage as VR2 + 1.21V

A worked example:-
R1=1k33
R2=2k87
Rb=2k87
DAC Max Output = Vdd = 5.0V

For DAC input code = 0

IR1 = 1.21 / 1330 = 0.909mA
IRb = (0 - 1.21) / 2870 =  - 0.4216mA
IR2 = 0.909 - (-0.4216) = 1.3313mA
VR2 = 1.3313mA x 2870 = 3.82V
Regulated Output = 3.82+1.21 = 5.03V

For DAC input code = 4095

IR1 = 1.21 / 1330 = 0.909mA
IRb = (5.0 - 1.21) / 2870 =  1.3206mA
IR2 = 0.909 -1.3206 = -0.4108mA
VR2 = -0.4108mA x 2870 = -1.1790V
Regulated Output = -1.1790+1.21 = 0.03V

The output is linear for DAC values between these two.
The output of an actual test circuit (with the above resistor values) is displayed in the next image. Note that 0V at the output is not actually achieveable in real life, bottoming out at ~0.11V.

Pretty much any voltage range can be achieved, by adjusting the resistor values.
For example:-
R1=1k3
R2=2k0
Rb=6k8
gives an output voltage range of 1.96V - 3.43V.

R1=1k
R2=5k36
Rb=2k67
gives an output range of 0.08V - 10.12V

Note:- the above circuit is for illustration only. It does not contain any filtering or protection circuits. It is recommended that the DAC output is filtered as a minimum.  Care would have to be taken on inductor selection.
Legal stuff:- USE THE ABOVE CIRCUIT AT YOUR OWN RISK.
post edited by simong123 - 2012/11/17 08:13:16

DarioG
Allmächtig.
• Total Posts : 54081
• Reward points : 0
• Joined: 2006/02/25 08:58:22
• Location: Oesterreich
• Status: offline
Re:Voltage Regulator Control with DAC 2012/11/17 10:42:57 (permalink)
4 (1)
Interesting, thanks!

I made a fully-linear (old-style) USB-controlled power supply some years ago... with a PIC and a DAC. It's on this forum too.

GENOVA :D :D ! GODO
BrimarBob
New Member
• Total Posts : 3
• Reward points : 0
• Joined: 2016/11/03 17:44:11
• Location: 0
• Status: offline
Re: Voltage Regulator Control with DAC 2017/04/13 05:53:00 (permalink)
0
Hi, This is a great article and I thought I had the answer to my problem but I am not so sure now.  I want to make a variable voltage supply from 0-400V.  The LR8 from MicroChip is a super device and I can use the output to drive a FET and get more power.  The LR8 Adj pin creates a ref voltage relative to the output and not ground so at the worst case, the voltage on that pin would be 400V.  I ruled out Digital pots for the same reason.  Any thoughts on how I can get my PIC to control the voltage of this supply?
Thanks - Bob
CinziaG
die fucking humans
• Total Posts : 3145
• Reward points : 0
• Joined: 2016/12/07 14:20:36
• Location: Wien
• Status: offline
Re: Voltage Regulator Control with DAC 2017/04/13 10:33:19 (permalink)
0
Maybe an optoisolator driven via PWM?

in 2018 you signed for your annihilation. in 2019 it will come ;) I promise
my most wonderful creations here
PStechPaul
Super Member
• Total Posts : 2910
• Reward points : 0
• Joined: 2006/06/27 16:11:32
• Location: Cockeysville, MD, USA
• Status: offline
Re: Voltage Regulator Control with DAC 2017/04/13 12:45:29 (permalink)
3 (1)
It's helpful to include links to special devices such as the LR8:

http://www.microchip.com/wwwproducts/en/LR8

It might be possible to use a high voltage MOSFET from ADJ to GND with perhaps a 1.2 k resistor from output to ADJ. Put something like a 420k resistor across the source and drain to limit maximum output to 420V. Then you may be able to adjust the gate voltage using PWM or a DAC to get Rds of 1k for 2.2 volts or 100k for 101.2 volts. But the linear range is rather sensitive.

Better, perhaps, would be a BJT with a fairly stable hfe of perhaps 100. Adjust the base current via PWM or DAC through a resistor, and the output voltage should be adjustable, like this:

BrimarBob
New Member
• Total Posts : 3
• Reward points : 0
• Joined: 2016/11/03 17:44:11
• Location: 0
• Status: offline
Re: Voltage Regulator Control with DAC 2017/04/13 14:14:57 (permalink)
3 (1)
That's a very interesting suggestion to resolve my problem. I will investigate further and let you know how I get on. Linear performance is important as i dont want to have to monitor the input or to have to model the reponse. Thanks for your assistance.
PStechPaul
Super Member
• Total Posts : 2910
• Reward points : 0
• Joined: 2006/06/27 16:11:32
• Location: Cockeysville, MD, USA
• Status: offline
Re: Voltage Regulator Control with DAC 2017/04/13 22:32:08 (permalink)
0
It won't be very linear, and probably will drift with temperature and time, so output monitoring would be needed. You can make the response quite linear by adding an op-amp as follows:

PStechPaul
Super Member
• Total Posts : 2910
• Reward points : 0
• Joined: 2006/06/27 16:11:32
• Location: Cockeysville, MD, USA
• Status: offline
Re: Voltage Regulator Control with DAC 2017/04/13 23:05:30 (permalink)
3 (1)
Here is an implementation using an N channel MOSFET:

BrimarBob
New Member
• Total Posts : 3
• Reward points : 0
• Joined: 2016/11/03 17:44:11
• Location: 0
• Status: offline
Re: Voltage Regulator Control with DAC 2017/05/22 01:58:28 (permalink)
0
Thanks for your help.  I also had a chat with Microchip engineers and after some discussion and concerns over heat and power dissipation in some of the other components, I have decided to go for a hybrid circuit that uses the LR8 to produce a stable reference voltage at 425V and then an NPN transistor driven from the op-amp DAC/feedback comparator to vary the voltage drive to the FET output regulator.  It simulates will in LTspice and while not a great response time for voltage changes, it is manageable and the ripple is low enough to not cause measurement issues. I can't upload the image of the circuit as the forum wont let me :(  Happy to supply it on request. Of to build a prototype now ...
PStechPaul
Super Member
• Total Posts : 2910
• Reward points : 0
• Joined: 2006/06/27 16:11:32
• Location: Cockeysville, MD, USA
• Status: offline
Re: Voltage Regulator Control with DAC 2017/05/22 11:58:08 (permalink)
3 (1)
It would be helpful to have an image or the actual schematic. You should be able to upload to the Microchip server if the file size and type guidelines are followed. I usually upload images and files to my own web server and use links to those locations. If you like you can send files to me (PM or email) and I can post them. I'm interested in what you and the FAE came up with.