When I last looked at my musical instrument tuner, I was having difficulty with real-world waveforms from the instrument : all the harmonics meant that zero-crossing analysis wasn't accurate for capturing the fundamental frequency.
This post describes my approach to solving that problem in the analogue domain - so that I don't need to worry about fast A to D conversion (although that would be an interesting problem in itself).
The standard approach is to implement a low-pass filter, with the stop frequency tuned around the desired fundamental, to get rid of those troublesome harmonics. A passive filter would only achieve 6dB/octave roll-off, which is unlikely to be enough. And you can't sensibly cascade passive filters to improve that. Time to roll out the op-amps, and implement active filters, which are easily cascadable, and in the simplest form, are usually 2nd order so 12dB/octave. Cascading two of those together should give 24dB/octave, which should be plenty of attenuation.
So far, so good - but the tricky part is the need to support tuning different strings of the instrument, each of which has a different fundamental frequency. So the filter needs to be tunable, ideally under the control of software.
That's where my experiments with digital potentiometers come in. I chose to use a Sallen Key filter topology, which is 2nd order, and tunable by resistor values alone. Unfortunately, it uses two resistors, which must normally be equal in value, so I needed to use two digital potentiometers per filter, with the same value loaded into each.
Here's the circuit I used:
I tuned the capacitor values via this handy website, so that using resistor values of around 5KΩ (half the maximum of the digital potentiometers that I have) gives a cutoff frequency of 440 Hz - which is about the middle of the range that I need. According to this site, the Q factor should be 1 / √2 with these capacitor values, which is generally considered to be about ideal.
Running against a sample of a real ukulele string tuned to approx 400Hz gives the waveform correction shown in the picture at the top of the article, which I think looks pretty decent. The difference between the two dotted vertical white lines is 2.5ms (see ΔT figure on the right), indicating that this is pretty close to a 400Hz sine wave.
The next step will be to string everything together onto a real circuit board - the current mess of interconnected breadboards is getting a bit unmanageable.