I'm getting unexpected results with a simple opamp voltage amplifier and was hoping somebody could point out what I'm missing. I'm working on a circuit to detect a specific audio frequency and output a proportional signal for the Arduino's analog input. I've got the preamp, filter, and smoothing circuit working; the problem arises when I try to amplify the output.
The output of the smoothing circuit is a (rather poorly formed) square wave with peak ranging from ~50-3500mv, no DC offset. I'd like to amplify the signal to be closer to the 5V input level of the Arduino. I realize that with such a huge potential input range I'll need to be able to adjust the gain and plan to make R2 of my output amp a potentiometer. I don't mind some clipping; in fact a small amount of clipping is desirable because the peak of the square wave has spikes up to 20% of the total wave height. I was taking many measurements and averaging to counteract this, but it left little time for the program to do other things. Clipping the noisy peak would allow me to simply take one measurement instead of many. I don't want to increase the discharge time of the smoothing circuit to further reduce the peaks because the signal is beginning to distort fairly heavily on the falling edge as it is.
I want to just use the same 5V supply I power the Arduino with. Started with the LM324. Designed the circuit and simulated it; everything worked great. Breadboarded it and got no output. Had no access to a scope at the time to see what was actually happening, and was unable to get the physical circuit working despite several hours of diddling and several holes in the wall.
Redesigned using the MC33174, which is also specified to be usable with a single supply. This circuit worked when breadboarded. I now have access to a scope, and can actually see what's happening with the signal. The output of this circuit is the aforementioned pseudo-square wave ranging from 50-3500mV. No problem; I've got two spare circuits on my second opamp. I'll just use one to amplify the output to as close to 5V as the opamp can get me.
I started with the same textbook 10 gain inverting amp I used successfully twice before in the circuit; R1=100k and R2=10K. The output of this amp is locked to ~400mV before clipping. Low inputs are amplified correctly; not quite a gain of 10 but significant. But 400mV is my max output. In the MC33174.jpg, Ch 2 is my input square wave; I've got it cranked up to the max in this shot and it's about 3.5V here. Ch 1 is my amp output, clipped at 400mV. Tried a non-inverting setup and got the same thing.
Simulation.jpg shows the (now non-inverting amp) schematic with the simulation showing what you'd expect. Square wave input of 350mV peak to peak, output of just under 4V.
If I use an LM324, the output goes to 4V. I swapped the channels inadvertently for LM324.jpg, and in this particular shot the input is lower. Ch 1 here is my input, lowered to about 230mV, and Ch 2 is 4V. Note that while the output appears similar between the two shots, the divisions are set to 100mV in MC33174.jpg and 1V in LM324.jpg, so there's a 10x difference.
It's not the end of the world to use an LM324 for this last stage if necessary, although I'd certainly rather use the spare circuits on the MC33174, but I would like to know why the huge difference between the two for future reference. Neither amp is rail-to-rail, but still...400mV? I've been scouring the MC33174 datasheet, trying to find the difference from the LM324 that would explain it, but I don't know enough about opamps to know what the crucial piece is. Any explanation would be very much appreciated.
So I replaced the MC33174s with LM324s to see if they would work, as the initial filter that didn't work with the LM324s was different from this one. The output square wave of this filter with the LM324s was about 5 times weaker and had dramatically more slope than the MC33174s. Put the MC33174s back in and tried setting up the final output amp for the 4th time. All this time I've been using the same two 10K and 100K resistors, just moving them around the breadboard. I've checked numerous times that I've got the right pins and that the resistors aren't swapped. And yet...and yet this time I get the expected output. Around 4.2V. I don't know if they weren't making good contact inside the breadboard or if somehow I managed to wire it up wrong after all. I doubt the latter, because I kept taking them out, switching from inverting to non-inverting configuration, etc. and always got the same result until this last time.
Regardless, problem is solved. Too bad there's no "delete post" option.