SAADC(two channel) Differencial Sampling by External 62.5KHz Clock Interrupt.

I am developing a product using the nRF52840.
I am currently running into a difficult problem. I inquired about it 2 years ago, but it has not been resolved.

I need to process Two Channel (Diffrencial) type saadc by using an external 62.5Khz interrupt.
However, the nRF52840 doesn't seem to be able to handle this speed.
The SAADC handler comes out too late.
I use s140_nrf52_7.2.0_softdevice.hex for soft device.

Please give me an answer on how to implement saadec two channel diffrencial type sampling at 62.5Khz rate.

Parents
  • Hi,

    I implemented SAADC on a custom board using a BSP only example without using SoftDevice and BLE.
    Chipset: nRF52840CIAA

    This product uses an external ADA2200 (Lock-In-Amp) to generate a 62.5KHz clock (Logic Channel 7).
    This clock is input to the nRF52840 as an interrupt (Logic Channel 5).
    This interrupt does SAADC sampling through ppi (Logic Channel 3).

    According to the nRF52840 datasheet, the maximum sampling rate is 200KHz.
    I'm trying to do ADC sampling synchronized to a 62.5KHz clock. (Channel 7)
    However, as shown in the figure, 19 clocks per 100 INTs were dropped (Channel 5)
    But even worse, ADC Sampling only got 19 (Channel 3)

    This is a very serious problem. The most important function of my product is to perform ADC sampling in synchronization with the 62.5KHz clock.
    However, there are too many DROPs as shown in the picture below.

    Looking at the second picture,
    When ADC sampling is acquired, the next interrupt is dropped. 19 interrupts dropped, 19 ADC samplings acquired.

    The interval time of 62.5KHz is 16uSec. ADC sampling takes more than 16uSec.

    I have to solve this.

    I share the source code I made. https://drive.google.com/file/d/1tBp8IeFoq03mxUm5P3QUvkJj_13QjYGn/view?usp=sharing
    Please check this source code. How can I solve this problem?
    And are there no mistakes in my source code? SAADC, PPI, INT.

    Please help and thank you.

    SunBae Yim.

  • Hello,

    Even though you are sampling this at 62.5kHz, you should not need to execute an MCU interrupt at this interval. Much of the point of having PPI and EasyDMA is to offload the MCU for the real-time requirements, and instead the MCU only need to actively handle "lump" of data, not on a byte level, but on an array of data. So my suggestion here is that you change SIM_SAMPLES_IN_BUFFER from 1 to 10. Then the MCU will be interrupted every 6.25kHz to process 10samples, instead of 1 sample every 62.5kHz.

    Best regards,
    Kenneth

  • Hello,

    I implemented ADC sampling with a differential like the source code above, and converted it into a voltage value using the formula.
    However, the voltage value is only half of the actual measured value.

    Does the differential read half the voltage? Or do I have to change the formula?

    In differential sampling, half the voltage is output, how can I solve it?

    Best Regards,

    SunBae Yim.

  • Hi,

    ParanBada said:
    Does the differential read half the voltage?

    No, it should not. I suggest for test that you try with a different source (for instance with less impedance), and possible try to increase the acquisition time, ref:
    https://infocenter.nordicsemi.com/topic/ps_nrf52840/saadc.html

    Best regards,
    Kenneth

  • Hi,

    Differential ADC sampling:
    Find the difference by reading the P and N channels. Is that right? (VALUE = P - N)

    The same formula is used as follows.

    #define SIMPLE_REF_VOLTAGE_IN_MILLIVOLTS   		600.0f                                     /**< Reference voltage (in milli volts) used by ADC while doing conversion. */
    #define SIMPLE_PRE_SCALING_COMPENSATION    		6.0f                                       /**< The ADC is configured to use VDD with 1/3 prescaling as input. And hence the result of conversion is to be multiplied by 3 to get the actual value of the battery voltage.*/
    #define SIMPLE_ADC_RES_10BITS             		1024.0f                                    /**< Maximum digital value for 10-bit ADC conversion. */
    
    /**@brief Macro to convert the result of ADC conversion in millivolts.
     *
     * @param[in]  ADC_VALUE   ADC result.
     *
     * @retval     Result converted to millivolts.
     */
    #define SIMPLE_VOUT_IN_MILLI_VOLTS(ADC_VALUE)\
    				((((ADC_VALUE) * SIMPLE_REF_VOLTAGE_IN_MILLIVOLTS) / SIMPLE_ADC_RES_10BITS) * SIMPLE_PRE_SCALING_COMPENSATION)
    

    Please check if this formula can also be used for DIFFRENTIAL.

    Best Regards,

    SunBae Yim.

  • Hi,
    I inquired about the voltage calculation formula for differential sampling above.
    I look forward to your reply.

    Best Regards,

    SunBae Yim.

Reply Children
No Data
Related