Microcontroller based power supplies

Discussion in 'The Projects Forum' started by Sparky49, Sep 8, 2012.

  1. Sparky49

    Thread Starter Active Member

    Jul 16, 2011
    834
    417
    Hi everyone.

    I'm quite interested in looking into building a microcontroller based power supply.

    I know how the basic variable linear power supply works, however I'd like to make something a little 'beefier' and preciser.

    I figured it might be cool to make a power supply which allows me to enter the voltage I want via a keypad (for example), and which is then monitored and warnings given for any over-voltage or excessive current, etc, etc.

    However, one thing I'm not too sure about is how the microcontroller would change the voltage?

    My (little) experience with adjustable linear power supplies is that one controls the output voltage via a potentiometer connected to the output and reference pins on the ic. Whatever voltage goes to the reference pin, comes out of the output, which is followed by smoothing caps and other bits and pieces.

    However, if I wanted 25V output, clearly my microcontroller couldn't handle that directly - how would it control such desired voltages? Perhaps a digital potentiometer, or how about a fixed voltage ic and the output is determined by op amps? I've tried googling, but there doesn't seem to be any clear explanation of the subject.

    Eitherway, if you guys could suggest means of doing this, I would be very grateful.

    Sparky
     
  2. John P

    AAC Fanatic!

    Oct 14, 2008
    1,634
    224
    It is possible to operate an LM317 in a closed-loop mode where the adjustment terminal is connected to Gnd via a transistor instead of a resistor. Would that be of any interest?
     
    Sparky49 likes this.
  3. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    A power supply is in basic a P-regulator. From the top of head. I would have used a two way approach. First I would have used a cheap 10/12 bit DAC for the reference. Combined with some simple digitally controlled switches for gain control. After that maybe rewarded my self with a fishing trip:D
    What kind of voltage span do you need? Perhaps the cheap LM723 can be used as base. I would not have worried so much of voltage error. You may typical see lower output voltage then the current limiter kicks in. So put your time in making a over-current detector first
     
    Sparky49 and absf like this.
  4. upand_at_them

    Active Member

    May 15, 2010
    246
    29
    Sparky, You might want to check out Dave's power supply project at the EEVblog. It's microcontroller-based.

    Typically what you want is a microcontroller generating a voltage via PWM, which is then fed to an op-amp. When an op-amp is wired with feedback it tries to make both inputs the same. This technique is used to generate the desired output voltage. The op-amp would then drive an output transistor.

    EDIT: Or as t06afre pointed out, the uC could drive a DAC. This would then be used with an op-amp and an output transistor.
     
    Sparky49 likes this.
  5. #12

    Expert

    Nov 30, 2010
    16,314
    6,818
    Look at my blog #4, "LM723 inspired" to see how to regulate down to zero volts and how the ratio of feedback resistors will allow a 5 volt input to cause a 25 volt output.
     
    Last edited: Sep 8, 2012
    Sparky49 and absf like this.
  6. takao21203

    Distinguished Member

    Apr 28, 2012
    3,577
    463
    A good microcontroller PSU is not a trivial task.

    Normally it should be based on a SMPS circuit.

    You have to sample the voltage very fast, and then generate a (fake) feedback voltage. The internal ADC can be used but you also need DAC. Some PICs have DAC but only the high-end one's. Otherwise good DACs are relatively expensive (for fast speed). If you leave out the consideration of messing around with resistor networks.

    At first you need a SMPS circuit in working condition for the power level you want. Then you need a microcontroller preferably with displays, I mean you need to have sufficient experience and control over it.

    Then you need to choose suitable ADC/ DAC chips, most likely using I2C or SPI.

    For the setting you can use potentiometers, reading them out via A/D, rotary encoders, a keypad, or serial interface.

    You can also control SMPS directly using a microcontroller. In this case you do not neccessarily need the DAC. Obtaining good results (at Amperes level) also is not trivial. Microchip has some documents about this topic.
     
    Sparky49 likes this.
  7. upand_at_them

    Active Member

    May 15, 2010
    246
    29
    If this is going to be a lab power supply make it linear, not switch mode. Switch modes are too noisy.
     
    Sparky49 likes this.
  8. WTP Pepper

    New Member

    Aug 1, 2012
    21
    6
    I made just the thing. Using a C8051F321 from Si Labs. The PWM timers produced the duty cycle for the switching power supply and the 10bit ADC provided feedback in a tight interrupt driven control loop. It involved a few inductors and mosfets and a few lines of C code on the micro.

    Line and load regulation was superb. High speed transient load regulation took a few capacitors and a bit of maths to sort out.

    It was about 85% efficient over 3-12 volts output at ~1A. It was used as a multiple cell Li-ion charger.
     
    Sparky49 likes this.
  9. crutschow

    Expert

    Mar 14, 2008
    13,023
    3,236
    For a simple micro controlled, 1.5A linear power supply, I would use a DAC (either standard or PWM) to generate an output voltage from the micro and use that to drive a non-inverting op amp circuit with gain to give the desired output voltage. Buffer the op amp output with an LM317 to supply the output current as well as giving current and temperature overload protection. Drive the LM317 control pin with the op amp output and use the LM317 output (at the power supply output connector for best regulation) as the feedback point to the op amp feedback resistor.

    The minimum output of the LM317 is about 1.2V (unless you have a negative voltage available for the op amp) but that's usually low enough for most lab applications.

    For current indication you can use a small shunt resistor (say 0.1Ω) in series with the negative return line of the supply and monitor the voltage across it with another op amp.
     
    Sparky49 and absf like this.
  10. Sparky49

    Thread Starter Active Member

    Jul 16, 2011
    834
    417
    Thanks, I will draw up a few flow diagrams to help me plan the circuit. :)
     
Loading...