I'm setting up this ADC triggered each ms with a timer interrupt, or 1 kHz sampling frequency to read a 50/60 Hz AC signal and calculate its RMS with 1% accuracy. Also I'm using DMA. The AC signal will swing around 1.65V or Vcc/2 to avoid the negative cycle enter the ADC. I have another ADC channel to track another variable. I have the following questions for the AC signal sampling:
- I need to find the RMS in a single cycle of the AC signal (20 ms or 16.67 ms). Is 1 kHz enough? This mean that for 50Hz I will take 20 samples per cycle and for 60 Hz 16 samples. So I need to fill the DMA buffer with these few samples.
- How do I choose the sampling time? I could choose between 1.5 and 160.5 cycles. I chose 160.5 as the signal is slow but I'm not sure.
A little pseudo code would be:
- Fill DMA Buffer with the samples
- Subtract DC offset from each sample or pass the filter through a high pass filter
- Take the filtered buffer and calculate RMS