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

NRF51822 ADC measure and accuracy

Hello

I have a problem with ADC measure and accuracy.

 

I want to read a voltage (U_BAT+) between 2.5 – 4.5V with an accuracy of < +/- 50mV

 

I have two scenarios.

  1. No load
  2. With 1A load

 

Schematic

 

 

 

 

ADC Configuration

 

Souce code snippets:

// ADC configuration
static nrf_drv_adc_channel_t     ADC_I_discharge         = NRF_DRV_ADC_DEFAULT_CHANNEL(ADC_I_discharge_PIN);         // Channel instance. Default configuration used
static nrf_drv_adc_channel_t     ADC_U_HE                = NRF_DRV_ADC_DEFAULT_CHANNEL(ADC_U_HE_PIN);                // Channel instance. Default configuration used
static nrf_drv_adc_channel_t     ADC_U_BAT               = NRF_DRV_ADC_DEFAULT_CHANNEL(ADC_U_BAT_PIN);               // Channel instance. Default configuration used
static nrf_drv_adc_channel_t     ADC_I_BAT               = NRF_DRV_ADC_DEFAULT_CHANNEL(ADC_I_BAT_PIN);               // Channel instance. Default configuration used
static nrf_drv_adc_channel_t     ADC_U_charger           = NRF_DRV_ADC_DEFAULT_CHANNEL(ADC_U_charger_PIN);           // Channel instance. Default configuration used

//***************************************************************************
//*  ADC Init
//***************************************************************************
void Init_ADC(void)
{
   nrf_drv_adc_config_t adc_config = NRF_DRV_ADC_DEFAULT_CONFIG;
   
err_code = nrf_drv_adc_init(&adc_config, NULL);
   APP_ERROR_CHECK(err_code);
}   


//***************************************************************************
//*  Get Battery Voltage
//***************************************************************************
void get_battery_voltage(uint8_t mode)
{
   uint32_t messung;
   uint8_t cycles = 5;
   
   messung = 0;
   write_SW(SW_U_bat_mess,ON);
   
   for(uint8_t i = 0; i<cycles; i++)
  {     
      nrf_delay_ms(1);
DEBUG_LED_ON;     
      nrf_drv_adc_sample_convert(&ADC_U_BAT, &adc_buffer[2]);  // get Battery voltage
DEBUG_LED_OFF;     
      messung = messung + adc_buffer[2];      
  }
   
   ADC_Bat_U = messung / cycles;
   write_SW(SW_U_bat_mess,OFF);
   
}

 

Timing

 

Blue        U_BAT_mess

Red         Debug LED (ADC is sampling)

 

 

 

Measurements

No load

 

Measured

calculated

U_BAT+

4.312V

 

U_BAT_mess

0.925V

0.917V

ADC

781 (ADC_Bat_U)

781.5

 

 

Measured

calculated

U_BAT+

3.0V

 

U_BAT_mess

0.645V

0.638V

ADC

546 (ADC_Bat_U)

543.7

 

With 1A load

 

Measured

calculated

U_BAT+

3.986V

 

U_BAT_mess

0.853V

0.847V

ADC

717 (ADC_Bat_U)

722.4

 

 

Measured

calculated

U_BAT+

3.18V

 

U_BAT_mess

0.675V

0.676V

ADC

572 (ADC_Bat_U)

576.3

 

The measured ADC (output on display) does not change if I connect the probe to U_BAT_mess.

Questions

  • Why is the measured and the calculated U_BAT_mess not the same ?

(The ADC impedance of 130k || to 270R should not make a difference)

  • Why does the measured ADC value not match to the measured U_BAT_mess ?

(1.2V ref / 1023 * ADC is not equal to U_BAT_mess)

  • Why is there a difference if I measure with and without load ?
Parents Reply Children
No Data
Related