News:

SMF for DIYStompboxes.com!

Main Menu

Guitar Tuner.

Started by Galego, November 10, 2010, 06:32:41 PM

Previous topic - Next topic

Galego

Hey guys.

I've been working on a Guitar Tuner. I'm using a PIC 16F684.
The analog part of the circuit was lifted from this site: http://www.schickt.de/index.php?entry=entry080606-004307 which in turn was lifted from another site...

Thing is, i don't have an oscilloscope, so i don't know exactly how the waveform looks like when it reaches the PIC. There are some note stability issues that i think are related to harmonics being generated mostly on the thicker strings.

Does anyone have any experience with anything like this?

This is what i've got so far:
http://www.youtube.com/watch?v=keURkUKPppU

The note recognition is lightning fast, i'm measuring the period and calculating the frequency from that. I'm thinking about doing some simple analysis of the data prior to using it for the calculations but still, i don't really know if the most frequent period is the correct one.

Lets say that i have an analysis phase where from a sample of 20 periods. Just keep the most significant byte, for memory saving purposes and because the slack it gives me will compensate for slight variations that are perfectly acceptable. See what is the most common value and for the data collection phase, basically an average of the values, i would only consider the values that have the most significant byte equal to the most frequent one.

Does this make any sense? Any other suggestions i should consider?

The tuner is usable as is, but because it's for me. Anyone else would be very annoyed that they have to pluck the E string very gently to get a good reading. :)

I would already have tried this idea if i wasn't so tired, so instead of messing up my code, today i'm just going to ask for fresh ideas. :)

jasperoosthoek

I have to read a bit more to know exactly how it works. Right now I'm finishing my beer and am about to go to bed ;D.

That looks like an interesting project. I've looked at guitar signals occasionally on a scope. You can get soundcard scopes. Basically it's a freeware program that turns your soundcard into an oscilloscope. That could be very useful. Getting a real oscilloscope is always a good investment. Even a 30 year old 20MHz is suitable for most if not all of your debugging.

Did you try using the neck humbucker? That usually works best and was even recommended in the manual of my pedal tuner.
[DIYStompbox user name]@hotmail.com

jman 31

I built that project a while back and noticed the same thing. I never put it in an enclosure because it was not very reliable in my opinion. I would really have liked it if it would have worked with a bass, but as was stated, even a guitar had trouble with the fatter strings. Sorry to not help, but I agree with your assessment.

armstrom

sounds like you need an FFT algorithm so you can discard the harmonics. After processing your samples you will end up with a function that evaluates the amplitude of each discrete frequency contained in the combined waveform. All of the harmonics will have a lower amplitude than your fundamental frequency.
Here's a FFT implementation for a PIC17C756. I'm not sure what would be required to port this to your PIC but it should give you some ideas.
http://www.piclist.com/techref/microchip/fft/picspect.htm?key=fft&from=


Galego

Quote from: armstrom on November 11, 2010, 07:37:45 PM
sounds like you need an FFT algorithm so you can discard the harmonics. After processing your samples you will end up with a function that evaluates the amplitude of each discrete frequency contained in the combined waveform. All of the harmonics will have a lower amplitude than your fundamental frequency.
Here's a FFT implementation for a PIC17C756. I'm not sure what would be required to port this to your PIC but it should give you some ideas.
http://www.piclist.com/techref/microchip/fft/picspect.htm?key=fft&from=



I thought about that, but to go that route i think i'd need to have a different input. The LM393 already turns the signal into a square wave, probably ruining the conditions needed to properly analyze the signal...

jasperoosthoek

A friend asked me five minutes ago how to make an 'as many bands as possible' spectrum analyzer for his bass guitar. He wants to put it in a 19" rack and use it on stage. The ideal situation would be that the rack is (almost) fully covered with LEDs. Just for show of course but fully functional. Wouldn't such an FFT analysis be perfect for his purpose?
[DIYStompbox user name]@hotmail.com

armstrom

yes, a spectrum analyzer is basically just a graphical representation of the results of a FFT.. Well, you don't HAVE to use FFT to get the spectrum plot, but it's pretty much the de-facto way of doing it. Most FFT algorithms produce a data structure that is an array amplitudes at several discrete frequencies. Of course that's a gross simplification of how you REALLY work with the results of an FFT calculation. FFT involves the use of complex numbers so there is additional work required to analyze the result.

jasperoosthoek

Could you advise on the micro controller to use? Arduino is the best documented platform around nowadays. But I'm afraid that the Arduino is too slow. The guy doesn't have any experience with programming but as a chemistry student he shouldn't be bothered by complex numbers. So the Arduino saves him the hassle of having to build or buy an additional programmer.

When I searched the web for him I found this chip: http://www.bliptronics.com/item.aspx?ItemID=111 It has only 7 bands. I couldn't find a chip with more bands which would do the job.
[DIYStompbox user name]@hotmail.com

armstrom

well, if you use something like that then you can use pretty much any micro controller you want. The  chip is doing the heavy lifting for you and simply producing a voltage that is proportional to the signal level for seven discrete frequencies (63Hz, 160Hz, 400Hz, 1kHz, 2.5kHz, 6.25kHz and 16kHz). The usage is pretty simple. You feed that chip your input audio signal and it produces a single DC voltage on its output that is proportional to one of the seven bands. It looks like it applies a gain of about 22dB to the signal to arrive at the DC value for that frequency.  The reference values given in the datasheet indicate that a .3V P-P signal on the input (at 1kHz) will produce an output value of around 3.5-4V DC.

The choice of which micro controller to use is really wide open at that point since the use of that chip has removed the main calculation burden from the controller.

Galego

Quote from: jasperoosthoek on November 12, 2010, 09:57:25 AM
Could you advise on the micro controller to use? Arduino is the best documented platform around nowadays. But I'm afraid that the Arduino is too slow. The guy doesn't have any experience with programming but as a chemistry student he shouldn't be bothered by complex numbers. So the Arduino saves him the hassle of having to build or buy an additional programmer.

When I searched the web for him I found this chip: http://www.bliptronics.com/item.aspx?ItemID=111 It has only 7 bands. I couldn't find a chip with more bands which would do the job.

I have one of those. From a broken stereo system. But is that useful for your friend? Wouldn't the Bass output just sit in the lower 2 bands all the time?

armstrom

Yeah, for bass it would probably not provide enough resolution. Even if you could shift the frequency bands by changing the clock frequency of the chip it would still cover too much bandwidth.

jasperoosthoek

He prefers more than seven outputs. And indeed the 7 band spectrum analyzer chip probably won't have enough resolution.

So I think the micro controller has to do the analysis and output it to shift registers controlling a LED matrix. So the question would be which micro controller could do the job.
[DIYStompbox user name]@hotmail.com

ExpAnonColin

Last I checked, most 8-bit microcontrollers were not at all fast enough to do any kind of serious FFT.  It's "fast" - for a computer, not a puny microcontroller.  That being said, I do know it has been done, and a really good example is here: http://elm-chan.org/works/akilcd/report_e.html which you could easily adapt to an LED matrix. 

Newer ARM microcontrollers can probably do some serious FFT in real-time, and DSPs can do it in their sleep (well, not really).  The 7-band chip you're linking too probably has an internal filterbank - similar to an FFT, but different in purpose.

-Colin

jasperoosthoek

Colin, that's perfect! I'll forward it to him and see what he thinks of it.
[DIYStompbox user name]@hotmail.com