> Well, my youngest just bought himself a bass guitar. Anyway, along with > the amp we're building I thought I'd toss in a tuning indicator. Found a > nice example of one done with an Atmel part, code in C, so I'm most of the > way there. The only gotcha seems to be the PIC listening to the bass > pickups. Input is via a series .02uF cap to the base of a 2N2222a, 330K > resistor to Vcc, 56K resistor to ground, PIC input is from the collector > with a 4.7K pullup, emitter to ground. It does what it's supposed to > (amplify). I get a nice pulse to ground at the primary frequency of the > string... but I'm also getting what looks like some harmonics (or maybe > just noise) that are apparently getting amped enough to trigger the PIC > input (Schmitt trigger, A0 on a 12CE674). Result is that the PIC almost > always says the string freq. is too high, even when it's ridiculously low. > Tried a few different resistor values on the base of the transistor, but > no improvement. It would help to look at the pickup output on a scope before designing the circuit to receive it. I'm not familiar with guitar pickups so I have no idea what level this signal is. I always assumed it was a low level signal like a microphone, but that wouldn't get thru the circuit you described. Apparently a full signal is a volt or two peak to peak, probably from an amplifier built into the guitar somewhere. In any case, you want to find the fundamemtal frequency of an audio signal. This signal can be up to a volt or two in amplitude and may contain significant harmonics. You do not just want to detect zero crossings, because the harmonics can create extra zero crossings causing exactly the symptom you describe. What is the frequency range of the fundamental signals you want to measure? The first thing to do is to put one or two poles of low pass filtering starting at the highest fundamental frequency you want to measure. That should sufficiently attenuate the higher harmonics. Such a low pass filter can be made from two resistors and two capacitors. If the desired frequency range is large, then the low harmonics of the lowest tones will still be within the pass range. I would start by putting one more low pass filter pole (one more R and C) with a rolloff a bit below the lowest frequency of interest. That guarantees that another 6dB attenuation of all first harmonics with respect to their fundamentals. That may be enough to detect the fudamental by using a bit of hysterisis (like a schmitt trigger, but I would use an opamp to get more control of the exact levels). The limiting factor will be the amplitude of the highest frequency of interest coming out of the filter. Adjust the hysterisis levels for 1/4 and 3/4 of the peak to peak of this signal and hope that the harmonics don't get thru for the low tones. This is a simple approach that has a chance of being good enough. There are more fancy ways of doing this that are more robust, but I would start with this and see what it gets you. ***************************************************************** Embed Inc, embedded system specialists in Littleton Massachusetts (978) 742-9014, http://www.embedinc.com -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body