I'm trying to design a relatively accurate variable power supply with 2~24V output voltage controlled from an MCU using off-the-shelf parts.
For the MCU to be able to read the whole range of voltage, the simplest approach was to use a voltage divider to map the scale of 0~24V into 0~3.3V for the ADC unit. Considering noise and ADC precision, for desired voltage resolution of 10mV, the accuracy is low, so I came up with 3 remedies.
I'm a bit lost to find out which gives a more stable reading. The approach itself is my concern. The values provided (e.g. input voltage) are not that critical.
- The input, unregulated voltage is 25V.
- The output voltage is variable from 2~24V.
- Desired voltage resolution is about 10mV. (e.g. a reading of 7.24V. It's not strict if it's not reachable.)
- Digital parts and op-amps have a linearly regulated supply of 5V.
- The main adjustable regulator which the output is concerned is a LM2596 with datasheet designed circuit.
- ADC is 10bits with a 3.3V reference from an STM8S MCU.
- The analog mux can be either CD4051 or 74HC4051 based on the switch voltage range.
- Software calibrations are applicable.
A: Variable gain op-amp using analog switches.
In this design, the input voltage is divided so the whole range of input is scaled to ADC input., but for accuracy, a simple op-amp is placed with a MCU controlled analog MUX to select various resistors for selective gain. Corrections and calibrations are possible using software. The MCU starts with the lowest gain, adds up gain until a good value is reached.
B: Multiple dividers, series resistors for protection
In this design, I just used various dividers for analog zooming (is that correct ?) I used series resistors for the case the input voltage is high so the divided voltage (which maybe still bigger than the input tolerance of MCU) goes through internal protection diodes and doesn't damage the MCU. This method needs 3 ADC inputs (also an analog switch is applicable.)
C: Multiple dividers, analog switch and comparators for divider selection.
I this one, in case the B method is not applicable, I added voltage comparators and an analog switch to select the divider based on the input voltage range. It doesn't need the input resistors or 3 ADC inputs used in B.