Max Source Resistance value of SAADC in nRF52840

Hello,

In my project i am currently creating a sub-module to read the battery voltage and convert that into percentage based on the ADC value read. I have refereed the guide from Nordic to measure the battery voltage.

In the guide as well as the in the docs of SAADC peripheral of nRF52840, its mentioned that max source resistance that we can use is 800K for 40us data acquisition. But in my case i have to use high value of source resistance to reduce the leakage current. Source resistance around 10 M Ohm and R2 around 2.2 Ohm reduces the leakage current for me. 


My question is can i use the source resistor value as mentioned above which are higher than 800K ? Would it damage anything ? Will my SAADC give proper readings / work properly ?

We have used high value of resistor to decrease the leakage current.

Here is my calculation using R1 and R2 value used by me ? Are this values to high for SAADC peripheral ?

Calculation based on the Reference Guide:  

R1 = 10 M Ohm
R2 = 2.2 M Ohm


Maximum voltage: 4.2 V * (2.2 M/(2.2 M + 10 M)) = 0.757377049 V
Minimum voltage: 2.7 V * (2.2 M/(2.2 M + 10 M)) = 0.540983607 V

ADC value at 4.2 V – 12 bit setup: 0.757377049 V * (1/5) / 0.6 V * 4095 = 1033.819671885

ADC value at 2.7 V - 12 bit setup: 0.540983607 V * (1/5) / 0.6 V * 4095 = 739

So voltage measured across pins will be in range of .75V to .54V.

So if the above resistor values are deemed appropriated can you please check my low power code for SAADC Init function which will be called every 5 minutes on app timer timeout. 

Here is code implementation for the SAADC peripheral, for the same configuration. I am using 12bit resolution with TACQ value of 40us. I am using oversampling with burst enabled and my sample buffer size is of 1.   

/**
* @brief  Function for initializing the ADC module in Single Shot mode
          for Battery Voltage Monitoring. 
* @param  void  
* @retval BSP Status
*/
uint32_t Battery_Voltage_Monitior_Init(void)
{
  ret_code_t err_code; 
  nrf_drv_saadc_config_t saadc_config;
  nrf_saadc_channel_config_t channel_config0;

  /* Configure SAADC: Set resolution to 12-bit and oversample to 8x. 
  This will make the SAADC output a single averaged value when the 
  SAMPLE task is triggered 8 times. */
  saadc_config.resolution = NRF_SAADC_RESOLUTION_12BIT;                                
  saadc_config.oversample = SAADC_OVERSAMPLE;               
  saadc_config.interrupt_priority = APP_IRQ_PRIORITY_LOW; 
  saadc_config.low_power_mode = true;

 /* Initialize SAADC */
  err_code = nrf_drv_saadc_init(&saadc_config, battery_voltlage_callback_handler);  
  APP_ERROR_CHECK(err_code);
		
 /* Struct to hold the configurations ADC channel. */
  nrf_saadc_channel_config_t channel_config = NRFX_SAADC_DEFAULT_CHANNEL_CONFIG_SE(BATTERY_VOLTAGE_MONITOR_PIN);
  channel_config.gain = SAADC_CH_CONFIG_GAIN_Gain1_5;  
  channel_config.acq_time = NRF_SAADC_ACQTIME_40US;

  /* Initialize the ADC Channel with ADC channel configuration */  
  err_code = nrfx_saadc_channel_init(0, &channel_config);
  APP_ERROR_CHECK(err_code);

  /* Configure burst mode for channel 0. Burst is useful together 
  with oversampling. When triggering the SAMPLE task in burst mode, 
  the SAADC will sample "Oversample" number of times as fast as it 
  can and then output a single averaged value to the RAM buffer. */
  if(SAADC_BURST_MODE)
  {
    NRF_SAADC->CH[0].CONFIG |= 0x01000000;                                            
  }

/* Allocate buffer to store sample data using EASYDMA */
  err_code = nrfx_saadc_buffer_convert(m_buffer_pool[0], SAADC_SAMPLES_IN_BUFFER);
  APP_ERROR_CHECK(err_code);

/* Allocate second buffer where the values will be stored if overwritten on first before reading*/
  err_code = nrfx_saadc_buffer_convert(m_buffer_pool[1], SAADC_SAMPLES_IN_BUFFER);
  APP_ERROR_CHECK(err_code);

//  nrf_gpio_cfg_output(BATTERY_MONITOR_TRIG_PIN);

 /* Disable the Battery monitor section */
//  Trigger_Device_State(DEV_BATTERY_MONITOR,STATE_ON);
  nrf_delay_us(100);
 

  return  err_code;
}
  

Waiting for some help as soon as possible. 

Parents
  • Hello,

    Which guide / reference document are you referring to here - Is it the How to measure lithium ion battery's guide?
    In general, when working with a very high resistance you should add a capacitor to ensure correct readings. This is also explained in the linked guide, along with an explanation of the calculations involved with determining the correct resistor and capacitor values.

    Best regards,
    Karl

  • Hello, 

    I have referred the link which you have mentioned. And also the nRF52840 SAADC peripheral doc, says the max source resistance that I can have is 800K ohms for acquisition time of 40us. 

    Okay this means if I don't use capacitor, and just use high resistance values directly for R1 and R2 the values read by ADC might not be correct. 

  • Brian (Geek) said:
    Okay this means if I don't use capacitor, and just use high resistance values directly for R1 and R2 the values read by ADC might not be correct. 

    Yes, this is correct - because the SAADC's internal capacitor will not fill fast enough if the source resistance is too high, meaning that the SAADC readings will come out too low. Adding a capacitor to the voltage divider negates this issue through always making enough charge available (given that the SAADC sampling frequency is not too high for the new capacitor to reach its steady state) for the SAADC to sample accurately.

    Best regards,
    Karl

  • Hello thanks for clarification.

    So i will be using the resistor and capacitor values same as the values given in the example section of

    https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/measuring-lithium-battery-voltage-with-nrf52

    Based on these calculations we can for example use these values: R1 = 4MOhm, R2 = 10MOhm, Cext = 10nF. Then the leakage current will maximum be:
    
    4.2V / (10MOhm + 4MOhm) = 300nA

    Also software side, I will be using acquisition time of around 10us and will be triggering SAADC read every 2-3 minutes. After successful conversion of SAADC samples i will be un-initializing the SAADC peripheral and cut-off voltage monitoring section using a trigger pin to save power. 

    While designing our board we took reference from Thingy 52 board, where the R1 value is 1.5 M Ohms and R2 is around 180K Ohms without use of any external capacitor. So how is it possible to get proper reading in Thingy 52 board just by the use of high source resistance (1.5 M Ohm) ? Can you please explain that. 

    Thank you.  

  • Thank you for your patience with this.

    Brian (Geek) said:
    thanks for clarification.

    No problem at all, I am happy to help!

    Brian (Geek) said:
    Also software side, I will be using acquisition time of around 10us and will be triggering SAADC read every 2-3 minutes. After successful conversion of SAADC samples i will be un-initializing the SAADC peripheral and cut-off voltage monitoring section using a trigger pin to save power. 

    This is good - then you should only see the leakage current of the measurement pin adding into your overall current consumption.

    Brian (Geek) said:
    While designing our board we took reference from Thingy 52 board, where the R1 value is 1.5 M Ohms and R2 is around 180K Ohms without use of any external capacitor. So how is it possible to get proper reading in Thingy 52 board just by the use of high source resistance (1.5 M Ohm) ? Can you please explain that. 

    I reached out to the Thingy52 developers about this, but they did not have any particular comment about this. Based on the calculations I would expect this level of source resistance to cause inaccurate readings of the battery level - but at the same time I have not heard about this being reported as an issue by Thingy52 users, so it is hard to say how big the potential effect of this is.

    Either way, I would recommend that you go with the capacitor approach since this both theoretically and practically will cause the most accurate readings with the least possible leakage current.

    Best regards,
    Karl

Reply
  • Thank you for your patience with this.

    Brian (Geek) said:
    thanks for clarification.

    No problem at all, I am happy to help!

    Brian (Geek) said:
    Also software side, I will be using acquisition time of around 10us and will be triggering SAADC read every 2-3 minutes. After successful conversion of SAADC samples i will be un-initializing the SAADC peripheral and cut-off voltage monitoring section using a trigger pin to save power. 

    This is good - then you should only see the leakage current of the measurement pin adding into your overall current consumption.

    Brian (Geek) said:
    While designing our board we took reference from Thingy 52 board, where the R1 value is 1.5 M Ohms and R2 is around 180K Ohms without use of any external capacitor. So how is it possible to get proper reading in Thingy 52 board just by the use of high source resistance (1.5 M Ohm) ? Can you please explain that. 

    I reached out to the Thingy52 developers about this, but they did not have any particular comment about this. Based on the calculations I would expect this level of source resistance to cause inaccurate readings of the battery level - but at the same time I have not heard about this being reported as an issue by Thingy52 users, so it is hard to say how big the potential effect of this is.

    Either way, I would recommend that you go with the capacitor approach since this both theoretically and practically will cause the most accurate readings with the least possible leakage current.

    Best regards,
    Karl

Children
No Data
Related