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

nRF52832 with Thermistor Sensor - ADC

Hi,

I need a bit of help to fully understand how ADC works on nRF52832.

I am using a Thermistor sensor like the following to measure temperature: Epoxy Thermistor - 3950 NTC

I have followed this setup to connect Thermistor sensor to AIN0(GPIO2) of nRF52-DK: sensor connection

So, I have connected one leg of Thermistor sensor to GND and the other leg to AIN0(GPIO2) of nRF52-DK, with a 10K(0.1% accuracy) pull-up resistor connected to VSHLD(VDD).

Questions:

  1. When I was calibrating my Thermistor sensor I noticed the VDD on nRF52-DK is 2.85V rather than 3.3V! is that normal?

  2. Does that mean my usable ADC resolution is the following, considering .gain = NRF_SAADC_GAIN1_6?

  • ADC value at 2.85 V – 10 bit setup: 2.85V * (1/6) / 0.6 V * 1023 = 810
  • ADC value at 0 V - 10 bit setup: 0V* (1/6) / 0.6 V * 1023 = 0
  • Usable ADC resolution - 10 bit setup: 810 - 0 = 810
  1. Can I increase my usable ADC resolution by making .gain = NRF_SAADC_GAIN1?

I started with saadc_pca10040 example and after a bit of modification to the example code I managed to measure temperature.

  1. How can I change the example code to create a 12 bit setup?

The example code seems a bit complicated for a simple ADC project.

  1. Do I really need PPI and timer_handler() function to perform ADC or I can get rid of them? If it is OK to remove them, how can I do it without breaking the code?

  2. Also, Can I use the internal pull-up resistor on the nRF52-DK instead of an external 10K resistor? If yes, what's the disadvantage of using the internal pull-up resistor over an external one?

  3. To apply such change, do I need to change the NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(PIN_P) in nrf_drv_saadc.h file?

from:

#define NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(PIN_P) 
{                                                      
    .resistor_p = NRF_SAADC_RESISTOR_DISABLED,         
    .resistor_n = NRF_SAADC_RESISTOR_DISABLED,         
    .gain       = NRF_SAADC_GAIN1_6,                   
    .reference  = NRF_SAADC_REFERENCE_INTERNAL,        
    .acq_time   = NRF_SAADC_ACQTIME_10US,              
    .mode       = NRF_SAADC_MODE_SINGLE_ENDED,         
    .pin_p      = (nrf_saadc_input_t)(PIN_P),          
    .pin_n      = NRF_SAADC_INPUT_DISABLED             
}

to:

#define NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(PIN_P) 
{                                                      
    .resistor_p = NRF_SAADC_RESISTOR_PULLUP,         
    .resistor_n = NRF_SAADC_RESISTOR_DISABLED,         
    .gain       = NRF_SAADC_GAIN1_6,                   
    .reference  = NRF_SAADC_REFERENCE_INTERNAL,        
    .acq_time   = NRF_SAADC_ACQTIME_10US,              
    .mode       = NRF_SAADC_MODE_SINGLE_ENDED,         
    .pin_p      = (nrf_saadc_input_t)(PIN_P),          
    .pin_n      = NRF_SAADC_INPUT_DISABLED             
}
  1. What other changes do you recommend to NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(PIN_P) profile for better and faster ADC? like can I make .acq_time = NRF_SAADC_ACQTIME_3US?

Thanks in advance

Parents
  • Hi,

    1. Between 3.3V regulator and Vdd there is a diode, see here. So a voltage around 3V is normal.

    2. If you use 1/6 gain and 10 bit resolution the usable range will be 810. You can also use 1/5 gain to increase the range (saturating voltage will be 3V) and higher resolution (12-bit or even 14-bit with oversampling). You can change the resolution by changing SAADC_CONFIG_RESOLUTION in nrf_drv_config.h to e.g. SAADC_RESOLUTION_VAL_12bit.

    3. You don’t need to use PPI, you can trigger a sample in code with nrf_drv_saadc_sample().

    4. I am a bit unsure if using internal pull-up resistor on the GPIO would work, but in your case I would not do it anyhow because the accuracy of the internal pull-up resistor is bad (11k-16k), see here. The ladder resistor in SAADC (which is configured with the .resistor_p = NRF_SAADC_RESISTOR_PULLUP) is about 160kohm, see here. Not sure what the accuracy is on this resistor.

    5. You can set down the acquisition time to 3 us, which is just within what we recommend with source resistance of 10kohm, see here. Do that with:

      nrf_saadc_channel_config_t channel_config =
          NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN0);
      channel_config.acq_time = SAADC_CH_CONFIG_TACQ_3us;
      
Reply Children
No Data
Related