Here was the first version of the circuit;
Testing With Spice
Spice is an analog circuit simulator that allows you to build and test your circuit on the computer before the breadboard. Since this was my first Op Amp circuit, I used it to test used CircuitLogix to build the circuit and test it - here's what I got;
Looks pretty good, right? The left box shows our amplified source, a nicely shaped sine wave, and the right box shows gain across the audible frequencies.
The Real World
I built the circuit on a breadboard and hooked it up to my home stereo. The result was good, although there was a little clipping, which was cured by turning down the MP3 player a notch. Total current draw was <10mA @ 5V, good considering we’re using a voltage divider.
I conducted an extended listening test and was very satisfied, so I put together a prototype;
Then, I took it out to the car and everything fell apart.
Spice is a liar!
What worked well on the bench was a noisy mess in the real world! I modeled a perfect power source in Spice, which was close enough with a battery pack, but far from true in the car. After scoping it out, I saw the problems: Interference from the Power Supply (the USB car charger) and the car’s electronics, and the Op Amp would become unstable and seriously distort the audio.
Scoping out noiseCrappy power supply
The 99 cent USB car charger provided a pretty unstable power supply. Works fine when charging your phone, but not as good for an analog circuit.
To solve that problem, I added more bypass caps that help smooth out the input power. This made a huge improvement. The two caps that tie +5V and +2.5V (my virtual ground) actually didn't help keep 2.5V stable, but just increased noise, so I removed them from the circuit.Amp Stability
I suspected there was enough load capacitance to destabilize the Op Amp, so I increased the gain (from 5x to 10x) and it eliminated the instability problems. Testing in Spice didn't show any difference from the original circuit, but you can see from scoping out a square wave, we get a pretty solid reproduction;
Here’s the final schematic, less bypass caps;
Testing is done. Now, let’s build it!