0
$\begingroup$

This questions seems to be a little strange but bear with me.

I have an application that needs a digital filter to be implemented in a microcontroller.

What I want to do

I want to use the DMA to get the data from the ADC every 300us (approximately). and store it in a buffer and I'm using FreeRTOS. I want to have a task check the DMA for half transfer completion and whenever it does reach that point, then the microcontroller would execute the LP filter on half the array, while the DMA keeps on filling the rest of the buffer. Due to my microcontroller's specs I'm sure I can run this filter in those points way before it has filled the other end of the buffer.

After this it would go to a waiting mode until it finishes the later half and when it's done it will execute the filter on the second half.

Does this make sense?

What I have done in the past

Program an interruption , when the interruption occurs put the data in a FIFO and keep filling the buffer until you reach its limit while doijg the calculations

Question

Is "what I want to do" ? Of course it can be done, but will it actually be a proper filter? It sounds strange in my head when I think about it, but it somehow makes sense (ever get that feeling?). Or do I have to do it the way I've done it in the past?

Another option would be to do it in a mixture kind of way? Fill the buffer with DMA and execute FreeRTOS every milissecond and do the filter the same way I used to do it (fill FIFO, do calculations, etc)?

EDIT:

Thank you @Ben for your response. I'm adding the same info I put as a comment here in the edit so it can be better visualized.

Desired filter - IIR filter initially

Sampling rate- 10kHz. An ADC acquisition every 100us (waaay above the Nyquist frequency, but it's necessary for what I want .. a power meter)

Tap - between 2 and 10, it doesn't need to be a high order filter

Acceptable latency- Well I'd need to use the output to do al the calculations related to power and then store it and send it to storage somewhere, so the latency can be high

$\endgroup$
1
$\begingroup$

Basically you want to implement a filter with batch processing, right?

Is this an FIR filter or an IIR filter?

What is the sampling rate? Number of taps? Acceptable latency between output and input as batch processing adds some processing latency.

$\endgroup$
  • $\begingroup$ I'll add it here as a comment but I'll add it to an edit to my question. First of all Batch processing .. thanks for the keywords, english is not my first language. Desired filter- IIR filter initially Sampling rate- 10kHz. An ADC acquisition every 100us (waaay above the Nyquist frequency, but it1s necessary for what I want .. a power meter) Tap - between 2 and 10, it doesn't need to be a high order filter Acceptable latency- Well I'd need to use the output to do al the calculations related to power and then store it and send it to storage somewher, so the latency can be high $\endgroup$ – morcillo Jul 13 '17 at 18:10
  • $\begingroup$ The comment sucks for formatting. I's already been added to an edit to my question. Please ignore the above comment $\endgroup$ – morcillo Jul 13 '17 at 18:14
  • $\begingroup$ If you can live with some latency, maybe you could process it on a computer and simply use the CPU for data acquisition and transfer. If you want to do power-related calculations, averaging and RMS-ing might be more relevant than using an IIR filter. My 2 cents $\endgroup$ – Ben Jul 13 '17 at 19:37
  • $\begingroup$ I'd rather do it in the embedded board and just use an SD card for storage ... or send it to "the cloud". I've been reading on regulations for power monitors and they are very specific on a few things ... like the minimum sampling rate, calibration, refresh rate on the display, storage rate .. etc ... it even talks about data encryption for the stored data. I used to work for a company that makes power meters and power analyzers, but I didn't get to work neither in the firmware nor the hardware, so, for study reasons I decided to make my own power monitor for my home $\endgroup$ – morcillo Jul 13 '17 at 21:56
  • $\begingroup$ and follow the regulations as close as possible. Also, The hardware I have now for acquiring the data to the ADC is pretty bad and inserts noise that shouldn't be there, also apparently they need low pass filters on power meters to remove any problems not related to the power line .. at least that's what I've been told .. gonna read more about it ... but still ... my next project will be to build my own spectrum analyzer and I'd like to do as much as possible digitally since new hardware is very expensive here $\endgroup$ – morcillo Jul 13 '17 at 21:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.