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

ADC error

Hi,

I am experiencing an error of up to 8% on SAADC readings on the NRF52832. We have performed a sweep of the full range of the ADC and produced the following graph which shows the phenomenon:

The SAADC is set up in single ended mode using the VDD/4 reference and a gain of 1/4 to give full range readings over 0-3.3v. The set up code is given below:

ret_code_t err_code;

nrf_saadc_channel_config_t channel_config =
    NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN1);
channel_config.gain = NRF_SAADC_GAIN1_4;
channel_config.reference = NRF_SAADC_REFERENCE_VDD4;
    
static nrfx_saadc_config_t default_config = NRFX_SAADC_DEFAULT_CONFIG;
nrfx_saadc_config_t * p_config = &default_config;
p_config->resolution = NRF_SAADC_RESOLUTION_12BIT;

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

err_code = nrf_drv_saadc_channel_init(0, &channel_config);
APP_ERROR_CHECK(err_code);

Is there any way to mitigate the error we are seeing or is this just inherent to the nature of the NRF52832 SAADC?

Thanks in advance,

Rob

  • Hi,

     

    Q1: Is the external HFCLK running when doing the SAADC conversion? This is important, as the SAADC will inherit the tolerance from the clock source.

    You can start the HFCLK like this (prior to initializing the softdevice):

    NRF_CLOCK->TASKS_HFCLKSTART = 1;

    while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0);

     

    Q2: Have you calibrated the offset via "TASKS_CALIBRATEOFFSET" ?

     

    Q3: Since you are using VDD/4 as the reference; are you 100 % certain that the input voltage is what you think it is? There's usually a bit of a difference between setting 3.3V on a power source, and the measured voltage at the input of the nRF.

    Kind regards,

    Håkon

  • Hi Håkon,

    Thanks for your reply. I've now implemented points 1 and 2 of your suggestions and they have had minimal effect. I also found some redundant initialisation code which was re-initialising the channel incorrectly, removing this has had more of an effect, but the readings are still not what I would expect to see. For example, at an input of 3.3v the ADC count is around 985 (where it should be around 1023).

    I am running the ADC calibration once every 5 seconds. What is the recommended frequency for running this task?

    With regard to point three, we have measured our supply voltage at 3.295V which would not account for the magnitude of the error we are seeing.

    Do you have any further ideas?

    Kind Regards,

    Rob

  • Hi Rob,

     

    robertco said:
    I am running the ADC calibration once every 5 seconds. What is the recommended frequency for running this task?

     That interval can be adjusted even higher (depending on how often the temperature changes in your environment). You normally want to calibrate once on boot, then if something changes (temperature or any other environmental variable).

    robertco said:
    the readings are still not what I would expect to see. For example, at an input of 3.3v the ADC count is around 985 (where it should be around 1023).

    Your results show that this get's worse on higher voltage, it implies that this is due to gain error. You will have some gain error (up to +/- 3%), and smaller ripples (radio powering up, CPU waking up etc) in the power supply may also have an impact on the reference.

    Have you tried using the internal 0.6V reference (set in REFSEL register) to see if this improves the scenario? Remember to adjust the gain to match the maximum input voltage as well.

     

    Kind regards,

    Håkon

  • Hi Håkon,

    Thanks for the further info. I'll adjust the calibration interval to be longer. We don't have temperature sensing on the device, so I can't use that to trigger calibration.

    We've since repeated our testing and it seems that our initial tests after implementing the calibration were incorrect. Now, with calibration enabled it looks like we are getting within the 3% error margins you stated above.

    Thanks for your help.

    Kind Regards,

    Rob

Related