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

SAADC Configuration

Hi All,

I am developing one project and there we are using ADC (i.e., SAADC in nRF). I have designed the hardware where I am using Capacitor ( C14, 2.2µF) which is connected to Analog pin and my requirement is I have to read the voltage level.

Here I am attaching details and image,

The voltage level of the input capacitor C14, 2.2µF / 400V to the Step-Down controller must be monitored. A voltage divider is used across the capacitor from R2, 3M3, and R3, 24k. The tapped voltage is measured at pin port P0.04 / AIN2 of the nRF52840. The expected voltage at the input of the controller is between 2.35V and 0V. The voltage at the capacitor must not fall below the value of 100V.

This is my requirement can anyone help how to configure SAADC with respect to my requirement.

Thanks in advance

Rohit R

Parents Reply Children
  • Hi Istvan,

    Thank you for the quick response

    I have referred those documents and even SDK examples.

    The 0.6 V internal reference is used by default, which you can tweak by changing the GAIN factor.

    - I did not understand it clearly. Can you please explain more regarding the Gain factor.

    For the tested purpose, I have configured as below,

    1) saadc_config.resolution = NRF_SAADC_RESOLUTION_12BIT;   //12 bit resolution

    2) NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN2);

    3) channel_config.gain = NRF_SAADC_GAIN1;

    4) err_code = nrf_drv_saadc_sample(); // Check error

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

    6) void saadc_callback(nrf_drv_saadc_evt_t const * p_event)
    {
        if (p_event->type == NRF_DRV_SAADC_EVT_DONE)
        {
            ret_code_t err_code;

            err_code = nrf_drv_saadc_buffer_convert(p_event->data.done.p_buffer, SAMPLES_IN_BUFFER);
            APP_ERROR_CHECK(err_code);

            
            int i;
            NRF_LOG_INFO("ADC event number: %d", (int)m_adc_evt_counter);

            for (i = 0; i < SAMPLES_IN_BUFFER; i++)
            {
                NRF_LOG_INFO("%d", p_event->data.done.p_buffer[i]);
            }
            m_adc_evt_counter++;
        }
    }

    7) Buffer size is 1

    And I have shorted P0_4 to VCC and GND Dev-kit on putty it shows me,

    a) when short to VCC - 1023

    b) when short to GND - -6, -4, -3

    I am not understanding with these values whether it is correct or wrong. Basically not understood SAADC config and it's result.

    Thanks and Regards

    Rohit R

Related