Go Down

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



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.



Nov 22, 2010, 11:37 pm Last 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.




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,


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.



Nov 23, 2010, 10:39 pm Last Edit: Nov 23, 2010, 10:39 pm by robtillaart Reason: 1

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)


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