Reading in frequency of a modulated sine wave using A/D

Hi,

I need to calculate the frequency of a sine wave of varying frequency and amplitude to maximum of 50Hz. The signal will vary from its max to DC. I am using an 8 bit AVR with 10bit sampling. So far I have considered three approaches: -FFT (I'm not sure if this will be fast enough I would like to have a usable frequency reading every 100 A/D samples or so.) -zero crossing and time between each odd one -calculating the max slope and max amplitude and using their relationship to calculate frequency.

Does anyone have experience they would like to share as to the best approach?

Scott

Reply to
Scott Ronald
Loading thread data ...

I have experience in this particular case. This is what i do:

I use a cross zero detector. A LM393 with 1Mohm resistor positive feedback, this is because when the sine wave cross zero have some crazy peaks and you have to create a little hysteresis of 10 mV above zero. If you dont do this you will see a pulse train and then your square signal. After you have a clean and perfect square signal from the comparator you just have to insert it to the microcontroller and calculate the time of the pulse, this gives you the frecuency (1/T).

This works great and for 50 Hz the micro is going easy. Forget FFT, dont kill a fly with a magnum.

If you need more help let me know.

Reply to
steven.cano

if you do not have a complex signal and it's rather clean then use a zero crossing method. It's the cheapest on CPU time. Keep a running average on the Peak amplitude, You'll want to generate a Sin/Cos table for speed in the rom image to convert the PCM readings from the base line to obtain the fraction in a linear state.

The only math you may need to do that maybe CPU taxing on an AVR is the scaling of the input signal to match the coefficients in the table.

other than that, it's simple..

If your signal is complex, then FFT is required and that can be taxing on the CPU. Some where around here, I have a simple PASCAL file that you can use to break down a FFT for 8 bit operations for the AVR if you need it.

--
"I\'m never wrong, once i thought i was, but was mistaken"
Real Programmers Do things like this.
http://webpages.charter.net/jamie_5
Reply to
Jamie

good idea, I never thought of using a simple comparator which would make life easier on the coding side :) I use that years ago in the DOS days when for Slow scan tv via the serial port.

--
"I\'m never wrong, once i thought i was, but was mistaken"
Real Programmers Do things like this.
http://webpages.charter.net/jamie_5
Reply to
Jamie

Interesting problem. What sample rate will you use? Is it constant? How accurate do you need the result to be? How fast can the input amplitude and frequency change? What might the input waveforms look like?

We're working on a similar problem, but we'll do the math in an FPGA. We're considering phase-locking a DDS synthesizer to the incoming sine wave, among other things. That could be done in software, too.

John

Reply to
John Larkin

Why exactly can't you use the simple comparator and a period/frequency counter? For the ultimate convenience, the AVR does have the comparator on the chip, and this comparator is already connected to the timer input capture.

It depends.

Vladimir Vassilevsky DSP and Mixed Signal Consultant

formatting link

Reply to
Vladimir Vassilevsky

I've done somthing similar (just not down to DC). I like to amplify the crap out of the signal to straighten up those rising and falling edges, and then feed that to a comparator.

Reply to
Anthony Fremont

Another use for a phase-locked loop? If you lock a 4046 type PLL chip to the signal, you can read the loop filter voltage through the follower, and get about 1% linearity on the frequency. It only takes one ADC sample to get the frequency (average).

Reply to
whit3rd

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.