Pages: [1]   Go Down
Author Topic: AC (guitar) signal to Analog Input  (Read 731 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

Can anyone tell me how could I input an AC (guitar) signal into Arduino Analog Input so when strumming the guitar I would see stable data from 0 to 1024 depending on how hard I strum the strings.

Thank you.

PS. I tried to use an Opamp circuit to amplify the signal but I still get an 'AC' data kind of input. Maybe what I need is to write a program that would somehow smooth the data. Does anyone have any ideas or information I could read?

« Last Edit: February 09, 2008, 10:50:31 pm by miro2424 » Logged

Brisbane, Australia
Offline Offline
God Member
*****
Karma: 1
Posts: 593
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

So you want a value between 0 and 1023 depending what note your playing?

Very difficult. You need to convert the waveform to something usable.
I dont know how you would do it.
Logged

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

 No, I just want a value between 0 and 1023 depending on how hard I strum the strings.
Logged

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

Well, if you sample the signal from the guitar fast enough you should come up with the wave form. I don't know what the frequency of the guitar is but I think human hearing range is up to about 22 kHz. In that case you need to sample at least 44 kHz fast which is possible with the 16 MHz ATmega168 chip. So what you could do is save the last sample. Then get the current sample and subtract the last sample from the current sample to find the delta. Err, also save the last delta. If you notice the "delta" change signs then you know that the sinusoidal wave has just passed a peak or trough? If that's the case then you can take the sample there as the amplitude of the wave. However, this assumes a sinusoidal wave which I'm guessing might not be the case. See if you can just log the data and plot it to see what the wave looks like. If you're crazy enough you could run a discrete FFT... just an idea. Or if anything you could just keep a running max or min of the samples in the past 100 samples or something and use that as your amplitude. Bah, I just realized that the Arduino can't really pick up the negative voltages since the ADC goes from 0V to 5V. Well, you could still do a similar analysis I think.
Logged

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

You would need to rectify that AC signal into a DC signal that the ADC will be able to work with. Then the DC signal will vary in amplitude according to how loudly you strum the guitar.
Logged

Copenhagen / Denmark
Offline Offline
Edison Member
*
Karma: 5
Posts: 2360
Do it !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Try to just pass the signal through a polarized (electrolytic) capacitor on the input pin.

Thats what many sound cards in PC's do.

Logged

Huntsville, AL, USA
Offline Offline
Newbie
*
Karma: 0
Posts: 30
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You might also want to check out these threads - they are all doing something very similar (trying to read volume/sound intensity via the analog pins):

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1202371284

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1201637097

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1202056662

It sounds like once we get some solid solutions, this should go in a FAQ or in the Playground...
« Last Edit: February 11, 2008, 04:41:56 pm by cmpalmer » Logged

Pages: [1]   Go Up
Jump to: