Pages: [1]   Go Down
 Author Topic: How to find fundamental frequency?  (Read 1812 times) 0 Members and 1 Guest are viewing this topic.
0
Offline
Newbie
Karma: 0
Posts: 3
Arduino rocks
 « on: November 22, 2010, 04:57:38 pm » Bigger Smaller 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
Brattain Member
Karma: 361
Posts: 17301
Measurement changes behavior
 « Reply #1 on: November 22, 2010, 05:37:53 pm » Bigger Smaller 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
Newbie
Karma: 0
Posts: 3
Arduino rocks
 « Reply #2 on: November 22, 2010, 08:28:49 pm » Bigger Smaller 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
Brattain Member
Karma: 361
Posts: 17301
Measurement changes behavior
 « Reply #3 on: November 23, 2010, 10:57:47 am » Bigger Smaller 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
Shannon Member
Karma: 223
Posts: 13870
In theory there is no difference between theory and practice, however in practice there are many...
 « Reply #4 on: November 23, 2010, 04:39:38 pm » Bigger Smaller 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
Full Member
Karma: 5
Posts: 241
Arduino rocks
 « Reply #5 on: November 24, 2010, 09:52:00 pm » Bigger Smaller 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: