Using 2 ADC's to Measure Output Voltage

Discussion in 'Programmer's Corner' started by R!f@@, Jul 25, 2016.

  1. R!f@@

    Thread Starter AAC Fanatic!

    Apr 2, 2009
    Umm ! I could not decide a better title :oops:.


    The Picture shows a part of PSU I designed. It's a CC, CV one. 0-35V @ 10mA to 2A continues. 3 Amps peak.
    I do not have a problem with the circuit. Just a basic question about the ADC part.
    As you can see I am using Low side sensing for the current limiter and measuring the current from high side was not accomplished since I cannot get the component I wanted.

    The output GND is not the same as the Main GND, due to low side CS resistor. And the PIC ADC negative reference is the main GND.

    The V, I sensing is buffered by the BB OPAMPS.
    The Current buffer IC5 is used with gain as the CS voltage drop is lower. I needed 5V output at 3A. That part is done.

    Now since the -Vref is at GND, ADC (v+), which measures the output Voltage, varies as load current varies even thought the Main Output remains stable. The Variation is in mV which is the result of current sense resistor drop. So I decide to measure the difference between Vout and CS voltage drop. When simulated the voltage is constant.
    I decide not use a differential amp ( to minimize components and board space, which is limited), instead use 2 ADC to measure the difference. Which resulted in ADC (V+) and ADC (V-).

    I believe this will work with extra coding.

    My Question is,
    When to convert the ADC values to voltage ?
    Should I first Subtract raw ADC(V+) from ADC(V-) and convert them to Voltage to be displayed or Convert the 2 ADC values to Voltage and do the subtraction and send to LCD?

    Never done this before so I am asking around which method is better.
  2. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    What I do:

    Continuously convert, as fast as possible, both channels (interleaved) in an interrupt routine. Usually, I'll sum the results of each channel into their own accumulator. I accumulate n conversions for each channel such that the accumulator just saturates for full scale values. I.e, with a 10 bit converter, I'll accumulate 64 conversions to result in a sum of 0xFFCO for full scale*. When the conversion counter is exhausted, I signal the main program that a final conversion is ready.

    The main program can then take its own sweet time processing the two accumulations in any way it wants.

    *Why? Because then I only have to multiply the 16 bit fixed point fraction by the reference voltage to determine the input voltage. No scaling necessary.
  3. R!f@@

    Thread Starter AAC Fanatic!

    Apr 2, 2009
  4. JohnInTX


    Jun 26, 2012
    I also do it like Joey. Some additional thoughts,

    If you accumulate a number of conversions that is an even power of 2, you can do the division by simple shifting or byte extraction.
    Since both readings have the same number of samples, you can take the difference of the two sums and then do one divide to get the actual difference. Dividing takes some time (especially non-powers of 2) so once is better than twice.

    When you want a human-friendly number (volts for example) you have to do the arithmetic and do the average. But if you have an application where the ADC value is compared to a fixed point - an overtemp limit, for example - consider expressing the setpoint as a value multiplied by the average factor. Then you don't have to do the division to compare the ADC reading to the setpoint. Better to do one multiplication when setting the setpoint than a division each time you get an averaged point from the ADC.

    My basic rule is to defer calculations until you need them. There's no sense in doing a bunch of arithmetic if you don't use the result before another point comes along.

    In your circuit, if you know the amps, you can calculate the low volts by ohm's law across the shunt, yes?

    In my charger designs, I did use a differential stage across the shunt. That's because there is full charging current in that leg to ground and you'll likely see some voltage offset in the wiring between the bottom of the shunt and the battery terminal. With a 50mV shunt, it made a difference. I used a single op-amp subtracting circuit to subtract the voltage on the high side of the shunt from that on the low side with some gain. Choose an op amp with low offset and especially drift and any errors will come out when you calibrate. Hint: examine the amp's output just before turning the charger on (Amps = 0). Save that value and use it as your zero offset when you scale your readings to true amps. Nice.

    Have fun.
  5. R!f@@

    Thread Starter AAC Fanatic!

    Apr 2, 2009
    Hmmm !
    Not sure what you guys are still saying but I did ask for a better approach.

    One issue. I cannot change the PCB now.
    So I have to do what I have to with in the code.
    I will start the coding and post when I run into a dead end.

    By the way, this is not a charger. But a Bench PSU I will be using.