This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

ADC measurement is not good.

Hi,

I am using nrf52832_AA, SDK 15.0.0,  s132.

I am using an ADC and it does not seem to be measured correctly.
The value is shaken.

The AIN2 pin is used, and when the voltage is measured by the multimeter, a constant voltage of 3.5 V is input.

However, the value of ADC is not constant.

void saadc_init(void)
{
    ret_code_t err_code;
    
    /* Battery ADC */
    nrf_saadc_channel_config_t channel_config =
        NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN2);

    err_code = nrf_drv_saadc_init(NULL, NULL);
    APP_ERROR_CHECK(err_code);

    /* Battery ADC */
    err_code = nrf_drv_saadc_channel_init(0, &channel_config);
    APP_ERROR_CHECK(err_code);
}

In main, nrf_drv_saadc_sample_convert (0, & adc_value); It is used by calling a function.
I could see that the value was shaking when reading the adc_value value.

What did I do wrong?

Thank you.

Parents
  • shaking when reading the adc_value value

    It would be helpful to understand what you mean by "shaking", since at the LSB level there is typically always some sort of noise unless you have an ideal input and VDD. The closest you may get to an ideal source can be to connect 1x AAA batteries for input, and 2x AAA batteries for VDD. So I suggest to try that to narrow down the source of the noise you see.

    Best regards,
    Kenneth

Reply
  • shaking when reading the adc_value value

    It would be helpful to understand what you mean by "shaking", since at the LSB level there is typically always some sort of noise unless you have an ideal input and VDD. The closest you may get to an ideal source can be to connect 1x AAA batteries for input, and 2x AAA batteries for VDD. So I suggest to try that to narrow down the source of the noise you see.

    Best regards,
    Kenneth

Children
  • Thank you for answer.

    Is the code okay?
    I am using a 3.7V lithium polymer battery with a zener diode.
    Let's test it with a power supply instead of a battery.

    ->

    Can I increase the resolution of the ADC?
    Where can I change to 8/10/12-bit?

    Also, when the direct power supply was connected to the pin, voltages above 3.5V were not measured accurately.
    Is the maximum input voltage 3.5V correct?

    Thank you.

    Have a nice day.

  • Please use batteries (not a steady power supply) as I suggest for both analog input and VDD when possible. A starting example may be: \nRF5_SDK_15.3.0_59ac345\examples\peripheral\saadc

    The maximum analog input depends on VDD, it can not be above VDD. You may also need to adjust the gain setting when measuring the analog input, to ensure that it is below the reference voltage (which internally is 0.6V). So a gain setting of 1/6 ensure that the analog input signal is divided by 6 and is less than the reference voltage.

    It's possible to change the resolution yes, please look at the SAADC chapter in the nRF52832 Product Specifications and the parameters when calling nrfx_saadc_init() in the above example (e.g. see NRFX_SAADC_CONFIG_RESOLUTION in the sdk_config.h).

  • I set NRFX_SAADC_CONFIG_RESOLUTION  1 //(10bit)

    And converts the values ​​obtained by the ADC.

    nrf_drv_saadc_sample_convert(0, &adc_value);

    adc_value = adc_value*360/1023;

    This ensures that the ADC value is a three-digit integer.

    Hundred digits, decimal digits are good.
    However, the value of the first digit constant changes.

    [For example]

    adc_value = adc_value*36/1023;

    3.35V input ->  33 (good)

    adc_value = adc_value*360/1023;

    3.35V input -> 334~336 (bad)

    I want to get the correct value.
    Is it impossible?

Related