Search This Blog

Thursday, July 26, 2018

Adjustable Linear Bench Supply in 1k

Projects / PSU  Original post date: 12/22/2016

This is a linear power supply that is controlled by a microcontroller with LCD readout. I am implementing a crude delta-sigma DAC for controlling the output voltage and high side current sense with using common parts.

This is part of a contest, so there are some constraints that do not make sense in real life.








The output voltage of this power supply is controlled by a crude form of single bit Delta Sigma D/A. It is a very simple, low cost and less noisy alternative to the usual PWM, I2C Trimpot or DAC design.
  • The output voltage can go down to 0V by biasing the Adjust pin below 0V.
  • Output voltage resolution is only limited by the ADC resolution.
  • High side current sensing
  • Low microcontroller resources requirement: 1 GPIO for output voltage control and 2 ADC channels for reading output voltage and current.
  • Multiple supplies can be controlled by the same microcontroller in a loop.
  • LCD readout of voltage/current with rotary encoder for controlling set point.

This is a simplified schematic to show the connectivity of the power circuits to the microcontroller.


Circuit Description

U2 (+ R7,C5) is an integrator. It is controlled by a GPIO pin on the microcontroller which is simulated by the MOSFET M2 and M3. The reference point is offset to half way point of the I/O rail by voltage divider R5/R6. The integrator level shifts the Adjust pin of the linear regulator to control the output voltage. The output voltage is monitored by the ADC and a PID control loop in firmware to drive the integrator. The LM317 linear regulator provides the current gain, regulation, transient responses, integrated over-temperature and over-current protection.
The output voltage can be increased or decreased by the amount of time that integrator input is high/low.
The integrator is biased at half I/O rail of the microcontroller so can be used without level translations. The output decreases when M2 turns on (red trace) and increase when M3 turns on. It maintains the output when the GPIO is tristated. This does not requires a continuous pulses like PWM. This reduces the amount of noise ripples introduces on the output. The update rate only need to be fast enough to compensate for drifts.

The RC time constant can be adjusted to accommodate the timer resolution for the micrcontroller. The voltage step is 1/(10K* 0.1uF) * 1.65V = 1650V/s. Using a software timing loop _delay_loop_2( ) with 4 cycles resolution at 8MHz, the voltage steps is 0.000825V. This corresponds to 13.5-bit DAC for a 10V range (and 14.5-bit for 20V range). The resolution can be increased by simply increasing the RC constants and/or a higher clock speed. This is much higher resolution than what is possible using PWM and I2C trimpot and a lower cost and simpler alternative to an external DAC.

The microcontroller feedback loop corrects for the non-linearity and output drifts of the integrator and regulator due to temperature offsets, leakages, parasitics etc. The ADC, voltage reference and the feedback divider determines the accuracy of the output.


The output of the integrator controls the Adjust pin on the LM317 (or similar regulators). The LM317 maintains an output that is Vref = 1.25V (typ) higher than its Adjust pin. The LM317 requires a minimum output load of 5mA. This is satisfied by the current 1.25V/220R = 5.68mA flowing through R1. R1 can be adjusted for regulators with a different minimum load.

The LM317 acts a constant current source for the integrator and isolating it from the load variations. The opamp negative rail is from a -2.5V supply to account for the opamp voltage drop and the Vref. This is generated by a switched capacitor charge pump.

This power supply uses a high side current sense design. Basically U4, R3 and M1 is wired as a constant current source which is controlled by the voltage drop across R2. This current is level shifted to ground and converted by R4 into a voltage output. The ratio of R4 to R3 determines the gain of the current sense circuit. The DC input offset of the opamp imposes a lower limit on the current that can be measured. The LM317 has a minimum constant current load which gets around this limits. This current can be subtracted by the microcontroller firmware.

The positive rail is 2V above the supply to extend the input common mode range (Vcc-1.5V) of the cheap opamp.


Reference:
Linear Tech: AN105 Current Sense Circuit Collection

Implementation Consideration

R4 should be connected to the analog ground of the ADC. This can minimized the effects of DC offset introduced by I*R drop at the ground offset between the microcontroller and the power circuit. Similarly, voltage divider ground connections should be made to the receiver's ground.

Also see project log section for the microcontroller decoupling, low pass filter cap placement as the ADC performance can affect the accuracy of this supply. External voltage reference source can be used to improve on the temperature and long term drift.

Power up/down and Safety

A mechanism is needed to shutdown the regulator with an enable pin. See log: Power up glitch fixed

There is a power on glitch around 0ms as the integrator cap is likely powered up discharged. This can be prevented by using a power on reset to disable the regulator until the integrator is a a know state. A watchdog timer can be used as a reset source to detect a lockup. It can be connected to bidirectional Reset pin on better microontrollers (e.g. ARM) to shutdown the regulator. Alternatively, a strong pulldown resistor can be used on a GPIO line for initialization and firmware controlled. Most microcontrollers GPIO lines tristates or weak pullup/pull down upon reset. After the firmware initialized the integrator, the enable pin can then be driven to logic high.

Heatsink

The regulator should be mounted on a heatsink as it is a linear power supply after all.

e.g. 10V drop at 1A means 10W of heat needs to be dissipated. A 5C/W heatsink (or lower values) is the bare minimum. So that puts the case temperature at 50C above ambient temperature and the junction another 20-30C higher.

Regulator headroom

The LM317 needs about 2.5V headroom for heavy loads, so it'll need at least a 12.5V supply for the 10V output. Some of the older heavy transformer adapters and the new cheap non-regulated "Electronic Transformer" have a very high ripple output at high loads, so it might fall out of regulation at high output voltages.

Project logs:

The analog circuit has been simulated and wired up. It seems to be working. Right now the microcontroller can read voltage and current. I haven't connected the wires for the power control.

The white breadboard contains the microcontroller, LCD, rotatory encoder, 3.3V regulator, switched capacitor power supply while the green one house the power circuits.
The project is a proof of concept. ATMega is actually not my preferred choice as it only has a 10-bit ADC which limits the output voltage resolution (and indirectly output range).

 The new code is very simple, but it is good enough for the job. The IRQ service routine has been reduced 68 bytes. In term of code size, that's pretty comparable to using buttons.

It is a bit of a pain to not have some kind of velocity sensing instead of the slow 10mV steps. That's something to think about when I don't have a code size constraints.

I have added in a PID control loop. I have to use 32-bit integer math for the intermediate PID calculation due to overflow. The code size is still within the 1kB. I'll need to fine tune the PID values.

Found some noise issues. I have build a module for the AVR so that I can have a cleaner layout for decoupling and low pass filter caps for the ADC channels. The rest are pretty much straight forward breakout.


The root cause turns out to be coming from power supplies I used for testing. The old transformer one has lots of (full wave) 120Hz ripples when running at full load. The switch mode wall warts on the other hand has a lot of digital noise and high frequency leakage current.

The output of the power supply is relatively clean as the firmware trims the integrator when it drifts or when the set point has been changed. This is a lot better than PWM controlled designs.

The following shows the no load output AC ripple at 5V output (BWL = Bandwidth Limited). Notice the slight staircase steps around horizontal division 2.5 and 9 when the PID loop trims the integrator. The update rate is about 30.5Hz which works out to be around (9-2.5) x 5ms.

I can probably reduce the step size by increasing the integrator time constant and use better layout and components to reduce the drifts.

Calibration Procedure

  • Set output to100mV. Figure out the ADC DC offset required to put it into my C code.
  • Set output to 10.00V, adjust trim pot for voltage scaling so that the multimter. reading agrees with the output voltage.
  • Adjust the Current offset (the LM317 regulator load) and put that into the C code.
  • Adjust the trim pot for current so that the current reading agrees with the multimeter.\

Know issues

There are some minor issue with the lower end voltage setting as the ADC can't measure output voltage correctly. The minimal voltage for proper regulation is about 0.1V. Below 60mV, there isn't a lot of head room for the ADC DC offset and the control loop, there are some minor output ripples.

There is a spike on the output during power on as I have mentioned earlier. I'll probably have to add some parts to disable the regulator until the microcontroller has a chance to set the integrator output. I have to figure if I want to add a some MOSFET switch or a LDO regulator with enable pin which helps with noisy power.

References:

"Design How-To Power Tip #6: Accurately Measuring Power Supply Ripple"

Power up glitch fixed

There is a power up glitch that I have been trying to solve. It is due to the fact that the integrator is in an uninitialized state at power on. Yikes!


Top trace is the Enable signal that the microcontroller during initialization. Bottom trace is the output voltage with the mod disabled so that I can get a before/after comparison.

The LM317 doesn't have an enable pin, so it is kind of tricky to solve this.

  • I have added a MOSFET switch to control the power to the LM317, This gets turn on after the Enable signal is asserted.
  • The integrator is still connected to the load via the 220R resistor. So I have added a series Schottky diode to block current sourcing from the integrator to the output.
  • I have added a 1K load to the output.
There is still a glitch, but the level is now at -0.25V. Not a perfect fix, but should be good enough for now.

Note: The bottom trace scale has been changed to 0.5V/div.

Idea - Switch Mode +Post Regulation

Linear regulators aren't exactly efficient, but they are relatively quiet and easy to work with. Quite often a linear regulator is used as a post regulation to remove noise. Here is my project log showing the noise of post regulation in case you worry about noise.

I have previously designed a discrete buck converter here. The comparator U2 compares the output voltage again a reference voltage V2 to control a MOSFET. The circuit is relative simple, has a very fast transient response, good efficiency and is stable. The circuit already has a simulation model. :)

The beauty of this is that the reference can be easily change without affecting the transient response of the feedback loop.


If I drive the reference source directly with my integrator output, I can made an adjustable switch mode supply. There are no short circuit protection.

What if I used a 4V refer/ence that is sitting on top of the LM317 Adjust pin? The output of the supply will be 4V-1.25V = 2.75V above the LM317 output rail. This would limit the power dissipation to the LM317 and improve on the overall efficiency.

This is just an idea on paper for improving the design. It is a bit beyond what I would want to build for the contest.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.