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

SAADC false reading on RIgado BMD300eval kit

Hi,

I am using BMD300 to develop my projects. I am working on SAADC sample example in SDK12.0.0. I am sampling the SAADC at a rate og 1000 sps. following is the saadc_ini() function:

    void saadc_init(void)
{
    ret_code_t err_code;
    
   //###########################################ANI0
    nrf_saadc_channel_config_t channel_0_config;
    channel_0_config.resistor_p = NRF_SAADC_RESISTOR_DISABLED;
    channel_0_config.resistor_n = NRF_SAADC_RESISTOR_DISABLED;
    channel_0_config.gain       = NRF_SAADC_GAIN1_6;
    channel_0_config.reference  = NRF_SAADC_REFERENCE_VDD4;
    channel_0_config.acq_time   = NRF_SAADC_ACQTIME_10US;
    channel_0_config.mode       = NRF_SAADC_MODE_SINGLE_ENDED;
    channel_0_config.pin_p      = NRF_SAADC_INPUT_AIN0;
    channel_0_config.pin_n      = NRF_SAADC_INPUT_DISABLED;

    nrf_drv_saadc_config_t saadc_config;
                
    //Configure SAADC
    saadc_config.resolution = NRF_SAADC_RESOLUTION_12BIT;                                 //Set SAADC resolution to 12-bit. This will make the SAADC output values from 0 (when input voltage is 0V) to 2^12=2048 (when input voltage is 3.6V for channel gain setting of 1/6).
    saadc_config.oversample = NRF_SAADC_OVERSAMPLE_DISABLED;                              //Set oversample to 4x. This will make the SAADC output a single averaged value when the SAMPLE task is triggered 4 times.
    saadc_config.interrupt_priority = APP_IRQ_PRIORITY_LOW;   
    
    
    err_code = nrf_drv_saadc_init(&saadc_config, saadc_callback);
    APP_ERROR_CHECK(err_code);

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

    err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[0], SAMPLES_IN_BUFFER);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[1], SAMPLES_IN_BUFFER);
    APP_ERROR_CHECK(err_code);

}

When I am giving variable analog input voltage , I am not getting the expected Digital output. Following table shows the analog inputs and corresponding digital values:

image description

Following are my concerns:

  1. Is it displaying 2's compliment values? and if yes for 12 bit resolution values should lie between -2048 to 2047. So if I am not wrong maximum output should be equal to 2047 and which is equal to reference of SAADC. So why the values are not in the range?

  2. If it is not 2's complement values should lie in range 0 to 4095. But SAADC values seems to decrease after I apply voltage more than 3.4 volts. Why is it so?

  3. what is the reference. Is it VDD or VDD/4(mentioned in the documentation)?

  4. does the calibration required as it consumes more time.(which may affect my operation)

I know it is somewhat lengthy question or someone might have asked previously. But I couldn't find the proper solution. So If someone had worked over it previously please make understand these things..

Thanks in advance!!

Parents Reply Children
  • Hi Jørgen,

    Thanks for your reply. It helped to re-evaluate the things related to ADC.I was wondering about why I am not getting maximum value of 12 bit resolution as 4095(I was getting around 3000), even when I am applying maximum input.

    So from the formula if I want to get 4095 as digital output, with VDD=3.3 volts, I have to apply input as 3.3 volts and gain of ADC should be 1/4 (instead of 1/6). Setting gain as 1/6 means I am increasing the dynamic range of the input to SAADC(maximum input to be applied to ADC), but here VDD should also be increased(I was not doing this).

    Now I am getting maximum digital output as 4095 for input of 3.3 volts with gain 1/4 and 12bit resolution.

    Can you suggest one more thing. My input signal is a bio potential signal with some fixed gain of analog front end. So if signal strength increases suddenly then again it will distort the ADC output. So what is the remedy to avoid this. Can I put one voltage divider for the incoming signal. Does it will increase the noise coming at input to ADC?

    Thanks once again!!

  • I'm not sure I understand what you mean. Can you try to describe in some more detail and give an example? How is the output of the SAADC distorted? Is the SAADC input higher than the supply voltage?

  • Hi Jørgen,

    Actually, Gain of the front End is fixed to which I am applying bio potential signal, which is 1100. Hence if input signal amplitude if increases it goes beyond the range that I can apply to ADC. Hence I am getting clipped output. I tried giving proper 3.3 volt so I got 4095 as digital output.

    So from this I can summarize following things,

    1. input to the ADC should lie in the range of 0 to VDD (in my case 3.3 volt)
    2. Selection of ADC Gain should be proper to set range for the input voltage.

    Thanks for timely support..

Related