Help with computing correct SAADC output value

I am using an Nrf52840 and sdk V14.2.0.

My question is how to compute the battery voltage based on my hardware.

The hardware uses AIN0 to measure.

The hardware has a resistor divider: GPIO output pin >---806K---X---->2M------>GND.

AIN0 is connected at point X above. The GPIO pin is configured as an output and set to a logic 1.

How would I scale the reading taken this way to represent a supply voltage of 3V?

With 3V as VDD AIN0 would see 2V I believe.

I use default config so gain is 1/6.

Battery has no protection diode in series.

Thanks.

Parents
  • Thanks.

    We are using a 3V and saadc provides 10-bit conversions. 

    with 10-bit readings and 3V then (2.14V/3V) = .713. -- .713 * 1024 = 730.

    730 represents the value when VDD is 3V if I understand correctly.

    To display 3V to the user as the measured value how would I scale 730 to result in a 3V value?

  • davidb said:
    with 10-bit readings and 3V then (2.14V/3V) = .713. -- .713 * 1024 = 730.

    No, this is not correct if you are using internal 0.6V reference and 1/6 Gain, then the input range will be 3.6V and your input will be related to this, not the supply voltage of 3V.

    Correct calculation will be:

    (2.14V/3.6V)*1023 = 0.59*1023 = 609.

    davidb said:
    To display 3V to the user as the measured value how would I scale 730 to result in a 3V value?

    Not sure I understand what you ask about here. With your current voltage divider and SAADC configurations, a digital output of 609 will correspond to the 3V supply voltage.

Reply
  • davidb said:
    with 10-bit readings and 3V then (2.14V/3V) = .713. -- .713 * 1024 = 730.

    No, this is not correct if you are using internal 0.6V reference and 1/6 Gain, then the input range will be 3.6V and your input will be related to this, not the supply voltage of 3V.

    Correct calculation will be:

    (2.14V/3.6V)*1023 = 0.59*1023 = 609.

    davidb said:
    To display 3V to the user as the measured value how would I scale 730 to result in a 3V value?

    Not sure I understand what you ask about here. With your current voltage divider and SAADC configurations, a digital output of 609 will correspond to the 3V supply voltage.

Children
Related