How would I go about making a simple Guitar tuner using BS2?
K2K
Posts: 1
I am a·musician and I thought it would be fun, and educational,·to make a simple Guitar tuner using the BS2. Doesn't have to be anything speacial, but I do want it to be as accurate as possible. If anyone could give me any information on how to do this, it would be much appreciated. Thank You.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
When you state 'conditioning the signal', can you describe what that means? Or rather, how would one go about conditioning the incoming audio signal?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Guitar signal are full of harmonics and overtones.· Look for an amplifier that gracefully recovers from hitting the rails- lots of overdrive circuits contain op-amps that are good at this.· Typically they are duals, where you would probably want single ended.
· The high E-string fundamental will create a "1 ms" pulse, and the BS2 has 2us resolution, so you should be in good shape there.· In fact, I'd recommend damping the fundamental and playing the 1st harmonic (lightly touching the string at the twelfth fret).· This is a dramatically cleaner signal than a plucked fundamental (fewer surviving overtones).
····· E6····· 82.41
····· A5···· 110.00
····· D4···· 146.83
····· G3···· 196.00
····· B2···· 246.94
····· E1···· 329.63
·
Chris: Thanks for the data. I'll see how it works out for me tonight.
Regards!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
rotflmao!
I thought it was a good guise! [noparse]:)[/noparse]
Knight.
If your intonation is set properly then YES, the note on the open string and at the same strings 12th fret should be the same....however, going from different environments (temperatures and humidity) the wood bends and twists so that this isn't always the same.
I've a new guitar that I had in a non A/C'd apartment and had real trouble with humidity....was readjusting it so much, that I accidentally tightened the truss rod too much and pressed in to the wood (shoulda loosened)...anyhow, the moral is, if you don't know how to do it...pay $20 and have the gee-tar restringed and adjusted by a shop!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·
Steve
"Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
Just to see what would happen, I wired a microphone to an LM324 OpAmp, and then into pin 0 of a BS2 to see if I could get any data into the stamp via the count command.· But no luck.· Have you ever done this type of circuit before?· Any advice?· I understand this will not be an accurate pitch detection method, but I'd just like to get started with some type of feedback and work up from there.
Also: I'd be interested to know if you've ever used an IC to do Freq. to voltage and interfaced this to a BS2?· I have an application where I'd like to monitor the pitch from 4 different sources.· I have coded PC based pitch detection, but I've never done DSP programming and I'm hoping to be able to use a BS2 for·this project.
Thanks!
I am no musician and don't know anything about the normal guitar tuning procedure, but may I suggest a different approach to the problem based on a few things I do know something about.
A music teacher uses a "pitch pipe" to establish a singers pitch. A piano tuner uses a tuning fork as a frequency standard and tunes for an audible beat note between the key (really a string) and the tuning fork. A HAM radio operator uses the same idea of "zero beating" one signal against another to precisely match the frequency. In that case, one can often visually "zero beat" by watching the S-meter make slow undulations until the needle holds still when the frequencies match. Anyway, it would seem one could use the "freqout" command on a BS2 or BS2E to generate the desired reference frequencies (one at a time) and using the 2 stage RC low pass filter (shown in the freqout help description) feeding either a speaker, or preferrably, an audio amplifier with speaker, a audible beat could be heard as the string was tuned. In other words, the stamp generates an audible reference frequency which the human ear compares with the sound of the simultaneously plucked string. The only problem I see with this is the minimum frequency increment appears to be 1 Hz steps and some of the earlier exampes indicate frequencies in between which would mean errors of up to .5 Hz on some notes, and that does not include error due to time base accuracy. Of course, who knows what the spec'd accuracy of that 25 year old tuning fork is that has been kicking around for most of a career?
Back to my cave,
Horace
If I understood you right: Sure, you could use a BS2 to produce audio tones at a certain Hertz and then tune by ear.· Actually, you could just use a 555 timer (no BS2 needed) for that approach.·
However, what I'm really interested is pitch detection methods... that's my interest in this topic.· The most sophisticated pitch detection we all have access to is our ears, but what could be done with a Basic Stamp? Any thoughts?
·
Horace,
I think you are on the right track. If I were constructing this circuit, I would probably create 6 independent band-pass filters for the 6 notes indicated.
This is to reject any unwanted frequencies that we are not focusing on. Each filter would then have an active region of about +/-10% or so (however
accurate you want your instrument). From here, the output of the band-pass filters would be relatively easy to condition (convert to a square wave)
for the Stamp to interpret. You could use either an RC filter or LC filter to accomplish your band-pass, although unless you are into winding your own
coils, the RC approach might work out better for you.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
The problem is that a guitar string has harmonics, so the E6 string has mostly 82.41 Hz, but also has some higher frequencies mixed in. Using harmonics (lightly touching the string at a certain place when it is plucked) will give you a purer signal (less other frequencies) that's why they sound like a "bell".
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
"SX-Video OSD module" Now available from Parallax for only·$49.95
http://www.parallax.com/detail.asp?product_id=30015
Product web site: www.sxvm.com
Those that would give up freedom for security will have neither.
·
Bean is right, to square off the signal you just amplify the signal to the point where
you have "clipping" of both the top and bottom halves of the wave.
Now, as far as picking off the frequency range so you don't have a lot of garbage when
you amplify the signal, you need either a LC filter (better) or an RC filter (good).
Think of the LC filter like tuning in a radio channel, only instead of MHz or kHz we are dealing
with a few hertz (Hz). The goal is to create a LC circuit that resonates at the frequency we
are looking for.
Here is a good reference on-line calculator:
www.deephaven.co.uk/lc.html
What? afraid of coils? Here is an RC approach....
Good reference material.... Note (Fig 1 is all you need)
www.qrp.pops.net/filter1.htm
Here with an RC approach, the goal is to create a "notch"
filter by combining a High Pass filter with a Low Pass filter.
The BIG difference here is that with a LC filter we are really
not filtering, we are "tuning" and when we hit on the resonate
frequency of the LC circuit, the output can increase dramatically!!!
Where as with an RC filter the signal level is attenuated by the
input frequency, and is never as "sharp" of a response than a LC
filter.
If you really want to play with coils, here is an Excel file that I put together.
(Note: change the extension from .TXT to .XLS)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 11/9/2005 9:14:23 PM GMT
At least that's the case on my tuner. I can be a little off on an open string and yet when I hit the intonation at the 12th fret my tuner will show that I'm dead on....of course, does that mean my intonation is off? lol maybe!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·
Steve
"Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
Thanks for the data. Great stuff!! I'd like to try this out... What would the circuit look like to interface a mic element to P0 of my BS2? Bean (above) said to use an opamp to square off the signal. I understand the filtering, but a little stuck with the mic->BS2 circuit. I am currently not seeing data coming in from the mic element (using LM324 opamp) and I am hoping one of you kind BS2 gurus would post a description of the circuit (exluding the filtering, as that can be applied later) to get the BS2 to read the mic input via the pulsin or count commands.
Regards!!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Since I usually play open chords I set my intonation so that it is "right-on" when the string is held at the third fret.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
"SX-Video OSD module" Now available from Parallax for only·$49.95
http://www.parallax.com/detail.asp?product_id=30015
Product web site: www.sxvm.com
Those that would give up freedom for security will have neither.
·
Looking through my November 2005 issue of "Nuts and Volts" on page 56 there is an article
going over "...analog filters built with discrete components..."
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Heres a page that discusses it: http://www.epanorama.net/circuits/microphone_powering.html
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10
Regards!!
But ya, the action on my electric is way different than on my acoustic....high/low action. I've also got a bit of a twist on my electrics neck, so the bottom isn't the same as the top!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·
Steve
"Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
After rereading you posts, you mention to call pulsin twice. I am not clear what you meant by this. Last night I mucked about with using pulsin to detect the frequency of a few sine waves, and although I got data back that seemed to correlate with the pitch of the sine wave, I didn't see Freq=1/Time and perhaps I am not using pulsin as you prescribed? Or perhaps my signal is not 'conditioned' as it should be?
Thanks for any direction you can give.
I am getting back to this project, and am stuck on the OpAmp -> BS2 interface circuit.· From what Jon posted earlier, I think that if do something like:
I can use var1+var2 to determine the frequency of tones being picked up from a mic.· I have tried a few circuits to interface the mic to an opamp, and then to a pin on a BS2.· But I have not had very good luck doing this at all.·(I get either noise or 0's). ·Has anyone else actually done this type of circuit before?· Would you be willing to post a schematic?· A BS2 should be able to 'hear' 440Hz pulses?
See attached snips of a circuit I have been trying this weekend.· The OmpAmp is OPA2340PA. I am not sure of the source of the original (googled), or I'd post the source site/author.
The OPA2340 is a good choice, rail to rail i/o and plenty of bandwidth. I don't like the circuit though. for the "gain block" in particular. The rest of it looks okay. I would suggest tying the top of R5 to VG (virtual ground) instead of Vcc. Also leave out the capacitor C6 and tie the left end of R6 directly to VG. Actually, you can leave C6. The most important change is R5 to VG.
It should work okay so long as the fundemental amplitude is greater than the summed amplitude of the harmonics and other ambient noise.
If you have access to an oscilloscope, that can show yoou so much of what is going on.
Another fun kind of circuit for this would be a PLL tone decoder. It is in the class of tuned or filter circuits that Beau mentioned, that would reject the harmonics and ambient noise. Devices like the LM567 are no harder to use than an op amp. You would feed your audio in, and the LO (local oscillator) output is a clean square wave that tracks the input frequency over a +/- 10% range. That you would feed into the Stamp for COUNT or PULSIN. The tone decoder also gives you a flag to show you that the tone is strong enough for a lock. There are tricks you can play with the stamp pins to set the PLL for different tones, by switching in different LO capacitors.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com