cancel
Showing results for 
Search instead for 
Did you mean: 

FFT and ZCD algorithm implementation

CDesh
Associate III

Hello,

I am using STM32L072xx, Core: Arm® 32-bit Cortex®-M0+ with MPU

– From 32 kHz up to 32 MHz max.

– 0.95 DMIPS/MHz

I have the following question

Can I implement FFT algorithms to read ADC values?

How can I implement ZCD(zero crossing detection) algorithm ?

Can someone help me identify right document or path for example codes?

3 REPLIES 3
KiptonM
Lead

There is FFT Source code on the Internet in C. The Hard part is knowing how to use it. Fortunately it is well known and there is a lot of write ups and youtube videos on the subject.

If you are trying to detect a zero crossing in a AC line you have to have external hardware to keep the AC blowing out the pin on your microcontroller.

Probably the easiest is a 3 or 3.3V zener diode and a high value resistor. (Do not do it with powerline AC because of no isolation, you will kill yourself. Or at least get shocked and maybe blow up your computer.)

What you will see is a square wave. And a dead time. The Square wave will be less time than the dead time because the square wave will appear high when the voltage is +something like on the rising side 2.7V until it is less than something like 0.8V on the falling side. from those two references and the on time and the off time (or frequency) you can calculate the zero crossing points.

Another way to do it is with a comparator at the zero crossing point. This is best if the signal is all above 0. (Has a bias voltage).

Ozone
Lead II

The CMSIS DSP package contains implementations for float (f32), short int (q15) and integer (q31).

The latter implementations definitely run on a M0/M0+ with acceptable performance.

Without realtime requirements, you could use f32, which would pull in floating point emulation code.

The DSP code is part of the Cube package, AFAIK.

Ons KOOLI
Senior III

Hi CDesh,

Sorry that I we do not provide a document or example for your specific case. But I found this link. Hope it is helpful.

Best Regards,

Ons.