So here's what I'm trying to do:
Given a square wave provided by my arduino, use a nth order active low pass filter to modify the square wave into a sine wave by filtering out upper harmonics. This is in the audio range of frequencies, of course.
I've spent a good deal of time trying to do this and I'm pretty close to giving up and buying a function signal generator ic like XR-2206. I don't have any dough for fancy equipment, and may I stress that it's partly a learning exercise.
Maybe part of the problem being is I don't have an oscilloscope, and can't afford one, so oscilloscope is out. It would definitely help to have one, sometimes wishing I could see the signal I'm creating, but here's my thinking: If I can create an audio sine wave that I can hear, then I can change my RC values to work for higher frequencies. Right? (Or wrong?)
But I can never seem to get what sounds to me like a sine wave. I play back a youtube 1000Hz sine wave (or pick your frequency) and compare that to the output of my active RC filter and they just don't sound alike. When I listen to the 1000Hz triangle wave, then that sounds exactly like what I'm hearing from the output of my active RC low-pass filter. But why?
I've read over and over, all over the net and back, that by filtering out the upper harmonics of a square wave produces a sine wave (because of the details of Fourier Transform having an infinite sum of continually doubling frequencies with phase shifts and yada-yada) but the idea just doesn't seem to work. If I filtered out all the other sine waves and am left with the fundamental sine wave, then why doesn't it sound like one? Triangle waves!!!
I'm using n many resistors, n many capacitors, and n+1 many LM358 op-amps. I need the last one to amplify the output signal. I have read that many higher capacity capacitors (like electrolytic) are just too inaccurate for a proper low-pass filter in the audio range, so I'm using 100pF caps with very large value resistors. For example, if I used a 100pF capacitor with 1.62M ohm resistor, then the cut-off frequency is 1/(2*pi*100pF*1.62Mohm) = ~982 Ohms. By using multiple RC filters, you can create a steeper "roll-off" on the upper frequencies, and because the resistance values are so high, the signal needs to be amplified, which is why I'm using LM358 op-amps. The output of one active filter feeds into another, and is filtered again in the next active filter. I'm powering everything with 0 to 5V.
And I know the filter works!! I've modified my filter so that I can hear a crisp 400Hz (triangle??) wave, but by just increasing to 450Hz, the frequency is completely inaudible. Therefore, it's definitely filtering, and pretty damn well! Yet I can still not get a clean sine wave sound. Why? What am I doing wrong? Maybe I'll just torment myself further by trying to make a crystal ladder. Pretty sure I won't do that.
I am not expecting perfection. But I know what I'm hearing and it just ain't sine. Not even close. Any suggestions?
Thanks stack community.