0
\$\begingroup\$

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.

Assumptions:

  • 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.

The methods:

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.

variable gain op-amp using analog switches


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.)

multiple dividers, series resistors for protection


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.

multiple dividers, analog switch and comparators for selection

\$\endgroup\$
  • 1
    \$\begingroup\$ You need to diode clamp those dividers or they will fry. \$\endgroup\$ – DKNguyen Jun 8 at 14:17
  • \$\begingroup\$ @DKNguyen you mean the internal GPIO protection diodes are not enough ? \$\endgroup\$ – Tirdad Sadri Nejad Jun 8 at 14:19
  • \$\begingroup\$ Oh, I guess. I don't like to rely. on those. \$\endgroup\$ – DKNguyen Jun 8 at 14:19
  • \$\begingroup\$ @DKNguyen so the B method with added clamps. do the series resistors affect the readings? (I can calibrate the readings linearly with software) \$\endgroup\$ – Tirdad Sadri Nejad Jun 8 at 14:23
  • \$\begingroup\$ They will affect how fast you can sample unless buffered. Thevnin resistance and ADC sampling cap make RC time constant. \$\endgroup\$ – DKNguyen Jun 8 at 14:25
1
\$\begingroup\$

I'm trying to design a relatively \$\color{blue}{\text{accurate}}\$ variable power supply with 2~24v output voltage controlled from an MCU using \$\color{red}{\text{off-the-shelf parts}}\$.

ADC

Just use a decent external ADC with a single potential divider using resistors of high \$\color{blue}{\text{accuracy}}\$ (maybe 0.1% and 15 ppm/degC). A 16 bit ADC has a resolution of 1 in 65536 so 24 volts divided by 65536 gives about 0.3662 mV resolution. You can get off-the-shelf ADCs that have DNL and INLs of a couple of bits and gain and offset errors about the same. Don't mess around with a load of external switching of gain stages, get a decent 16 bit ADC (serial output). There are plenty to choose from.

My personal preference given that I've literally used hundreds is this: -

enter image description here

It just delivers the goods. Worst case error is 4.15 LSb plus a zero offset error of 0.5 mV - that's well within what you need (about a 2 mV error).

Resistor potential divider

Of course you have to have decent resistors and 0.1% types will generate a worst case full scale error of 48 mV but, this is can be calibrated out or, use 0.01% resistors to give a worst case full scale error of 4.8 mV. They'll cost a bit of course but, if you want decent \$\color{blue}{\text{accuracy}}\$ then you have to pay.

Voltage reference

You need to use a decent voltage reference too. Look out for initial accuracy percentage and drift factors with temperature. I tend to use really good ones such as the LTC6655B - it has an initial \$\color{blue}{\text{accuracy}}\$ of 0.025% and a drift of 2 ppm/degC but the C version is cheaper.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ unfurtunately the I have access to very tiny portion of electronic parts due to heavy sanctions on the country. I searched for AD7988 in local markets and didn't find nothing. there are a few models which are pricey. the STM32 MCUs have 12bit ADCs so I might switch to them in this case. they are available and cost less. there is a loadcell adc chip available also with 24bit(16bits effective) available. \$\endgroup\$ – Tirdad Sadri Nejad Jun 8 at 14:32
  • 2
    \$\begingroup\$ @TirdadSadriNejad You said using "off the shelf" parts. You should have told us from the very beginning which parts you had on your particular shelf. \$\endgroup\$ – Elliot Alderson Jun 8 at 14:40
  • \$\begingroup\$ @TirdadSadriNejad the AD7988 is my choice - you can choose any 16 bit ADC you want and compare numbers with what I use and make a decision based on what you can get vs accuracy and resolution. I can't give country specific answers and you did ask for "off-the-shelf" parts and that statement usually implies there are shelves that have a variety of parts and not that your country has import sanctions. \$\endgroup\$ – Andy aka Jun 8 at 16:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.