Pages: [1]   Go Down
Author Topic: How to find fundamental frequency?  (Read 1783 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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,

Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17294
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: November 22, 2010, 05:41:00 pm by retrolefty » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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,
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17294
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 217
Posts: 13705
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@Ricardo

in this thread http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1286718155 an FFT library is discussed, it might help
« Last Edit: November 23, 2010, 04:39:51 pm by robtillaart » Logged

Rob Tillaart

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

0
Offline Offline
Full Member
***
Karma: 5
Posts: 238
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

wade
Logged

Pages: [1]   Go Up
Jump to: