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

AC (240V) current measurement using a CT with NRF52832

I need to measure current of loads attached to NRF52832 using  current transformer(CT).

I can use SAADC library to read ADC value. But to measure current I have to know the pick values of samples of AC current waveform to measure its rms value.

How I can acheive this using saadc. In Arduino it takes sample every 500 us for and records it. for one cycle we got peak to peak value of it.

So How in SAADC, I take sample every 500us for cycle and then get peak to peak value to measure it.

Which mode is suitable for it like single shot, or continuous mode?

Is pulling method is suitable or interrupt method can be used, I think interrupt is best but measuring at 500us generates lots of interrupt may disturb ble operation.

Thank You

Bivay

Parents
  • Which mode is suitable for it like single shot, or continuous mode?

    Continuous mode is best if you need accurate measurements(in time) and the easiest, but it has a bit more current consumption than single-shot. 

    Single shot on the other hand is at the mercy of the BLE stack who's got higher interrupt priority. One way to get around the interrupt priority is to use the Radio Timeslot API of the SoftDevice's Multiprotocol support to request a time slot where you have complete control of the MCU. For a 50Hz signal that requires 20ms of sampling + minor processing of the data. 

    To find the maximum and minimum value of an array you can use the ARM CMSIS DSP library's arm_max_f32 and arm_min_f32, or:

    // Set min/max values for 10-bit precision
    int16_t max_val = -1023;
    int16_t min_val = 1023;
    
    for(uint16_t i=0; i < SAMPLE_SIZE; i++)
    {
        if(my_samples[i] > max_val)
        {
            max_val = my_samples[i];
        }
        else if(my_samples[i] < min_val)
        {
            min_val = my_samples[i];
        }
    }

Reply
  • Which mode is suitable for it like single shot, or continuous mode?

    Continuous mode is best if you need accurate measurements(in time) and the easiest, but it has a bit more current consumption than single-shot. 

    Single shot on the other hand is at the mercy of the BLE stack who's got higher interrupt priority. One way to get around the interrupt priority is to use the Radio Timeslot API of the SoftDevice's Multiprotocol support to request a time slot where you have complete control of the MCU. For a 50Hz signal that requires 20ms of sampling + minor processing of the data. 

    To find the maximum and minimum value of an array you can use the ARM CMSIS DSP library's arm_max_f32 and arm_min_f32, or:

    // Set min/max values for 10-bit precision
    int16_t max_val = -1023;
    int16_t min_val = 1023;
    
    for(uint16_t i=0; i < SAMPLE_SIZE; i++)
    {
        if(my_samples[i] > max_val)
        {
            max_val = my_samples[i];
        }
        else if(my_samples[i] < min_val)
        {
            min_val = my_samples[i];
        }
    }

Children
Related