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

Does anyone has a code snippet showing how to run saadc to get 100000 samples at 10 usec interval and store them into memory?

I need to digitize one input every 10 usec and store results into memory. After say 100000 samples the ADC should stop.

Thanks

Parents
  • Thank you for the code. It works.

    I found that if one connects A0 input to VDD on the board the values in the first buffer is much lower than in the subsequent buffers.

    It does not happened if I connect ADC input to VDD internally, i.e. replace NRF_SAADC_INPUT_AIN0 with NRF_SAADC_INPUT_VDD.

    Here is my modifications:

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

    and here is prinout when usnig NRF_SAADC_INPUT_AIN0 :

    <info> app: SAADC HAL simple example started.
    <info> app: ADC event number: 0
    <info> app: 35
    <info> app: 39
    <info> app: ADC event number: 1
    <info> app: 169
    <info> app: 169
    <info> app: ADC event number: 2
    <info> app: 171
    <info> app: 167
    <info> app: ADC event number: 3

    Can you explain this?

    Thanks,

    Mike

Reply
  • Thank you for the code. It works.

    I found that if one connects A0 input to VDD on the board the values in the first buffer is much lower than in the subsequent buffers.

    It does not happened if I connect ADC input to VDD internally, i.e. replace NRF_SAADC_INPUT_AIN0 with NRF_SAADC_INPUT_VDD.

    Here is my modifications:

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

    and here is prinout when usnig NRF_SAADC_INPUT_AIN0 :

    <info> app: SAADC HAL simple example started.
    <info> app: ADC event number: 0
    <info> app: 35
    <info> app: 39
    <info> app: ADC event number: 1
    <info> app: 169
    <info> app: 169
    <info> app: ADC event number: 2
    <info> app: 171
    <info> app: 167
    <info> app: ADC event number: 3

    Can you explain this?

    Thanks,

    Mike

Children
  • I'm not sure exactly what is causing this, but it could be related to charging of the internal capacitor when the input is floating. When the pin has not been sampled for a while, it may take longer for the capacitor to be changed than it does for the subsequent samplings that are performed almost back-to-back. Note that this is purely speculations, there could be other reasons for this as well. As long as you are not planning to sample floating inputs, and the first sample does not show this behavior when the inputs are connected, I do not see this as an issue.

Related