Go Down

Topic: How to find fundamental frequency? (Read 2480 times)previous topic - next topic

RicardoLATech

Nov 22, 2010, 10:57 pm
Hello,

I'm new to the Arduino and programming and am looking for some help.  I'm currently using the Arduino uno and need to find the fundamental frequency of a sine wave between around 80-340 Hz.  I plan to bias the sine wave to oscillate between .5-4.5V or so and input it into the analog input of the Arduino.  I was thinking of using zero crossings to find the fundamental frequency but am not sure how to go about doing this.  Any help or example code would be greatly appreciated.

Thanks,

retrolefty

#1
Nov 22, 2010, 11:37 pmLast Edit: Nov 22, 2010, 11:41 pm by retrolefty Reason: 1
Well a true sine wave has a positive and negative voltage values over time and an Arduino analog input pin can only safely measure positive voltages, usually from 0-5vdc, however one can change the maximum value to utilize a lower upper limit thus increasing resolution for lower level signals. So you are correct to understand the need to bias the signal before wiring to the Arduino.

One method would be to feed the sine wave into a simple comparator op-amp and use the PulseIn() statement to measure the low or high time period of the then square wave and then compute the frequency from that value.

http://arduino.cc/en/Reference/PulseIn

Lefty

RicardoLATech

#2
Nov 23, 2010, 02:28 am
i was thinking of trying this, a few questions though.   If instead of a sine wave, i use a guitar signal which will contain harmonics etc,  will this pulse technique still work?  Basically im looking to measure the fundamental frequency of each guitar string, and its the harmonics that are throwing me off.       Thanks,

retrolefty

#3
Nov 23, 2010, 04:57 pm
That is a problem and trying to extract a fundamental from a complex AC signal is most likely way beyond what an Arduino can accomplish. FFT is the common algorithm method to obtain such signal information and is pretty complex mathematics.

Lefty

robtillaart

#4
Nov 23, 2010, 10:39 pmLast Edit: Nov 23, 2010, 10:39 pm by robtillaart Reason: 1
@Ricardo

in this thread http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1286718155 an FFT library is discussed, it might help
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

wwbrown

#5
Nov 25, 2010, 03:52 am
Using fft's to analyze the data to find the frequency content is probably the best way to go.  I was thinking that way but did not know someone had implemented an fft library for Arduino, until I read the previous post.  Now that I know there is an fft library it allows me to do some of the tasks I am doing with ffts.

Go Up

Please enter a valid email to subscribe