Opamp max output voltage

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.

edit:

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.

I started with the same textbook 10 gain inverting amp I used successfully twice before in the circuit; R1=100k and R2=10K.

As you can see from this link, your circuit is NOT an inverting amp. It is a NON-inverting amp.

second. I do not see a 1 uF coupling capacitor on the input of the amp , nor do I see a voltage divider to bias the signal at 2.5V

What's up ?

chantling:
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.

I think that 'wiring it up wrong' also includes breadboard not making 'good contact'.

When using breadboard, it's necessary to ensure that the wires etc are getting good electrical connections between points. For example, plugging the wires into the holes properly. And re-plugging if there's any doubt that a wire didn't go in properly.

Sometimes....to trace a problem, multimeter testing may need to be used to ensure points are indeed connected together properly.

Also, if decoupling capacitors for chips aren't used, then they should be used. Without actual high resolution photos of your actual system, or an "accurate" schematic of the system, it's hard to know what could truly be happening.

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

Is it supposed to be 400mV peak to peak for the input? Looks like 100 mV per division. And output is 3.5 Volt peak to peak.

The nice thing is, your system is now functioning in the way you want it. So good effort in getting it to work.

FYI, in the future, try using a meter to do continuity checks and measure resistance. This will indicate open connections or wrong resistor value.

When non-inverting, you can drive from ground up.
When inverting, you need to offset the input because
the opamp can't output less than ground.
Both setups will most likely clip near ground.
Dwight

When non-inverting, you can drive from ground up.
When inverting, you need to offset the input because
the opamp can't output less than ground.
Both setups will most likely clip near ground.

I'm working on a circuit to detect a specific audio frequency and output a proportional signal for the Arduino's analog input.

There is no information provided about the "audio signal", specifically where it is coming from.
There is no information given for the frequency, smoothing circuit, or detection circuit mentioned in the OP. The only information given is for the amplifier. The OP describes an AUDIO frequency and the simulation shows a SQUAREWAVE. There is not enough information given to determine what was going on with this circuit.
That being said, any (audio) input to an op amp or an arduino , should be biased midpoint (2.5V) unless the op amp is running on a split rail supply in which case the output is swinging negative and needs to be coupled to the arduino with a 1 uF cap and biased midpoint to make the signal within the 0 to 5V range of the arduino ADC. Without the cap the negative half of the signal will exceed the input limits of the arduino and be clipped in the process, which is clearly shown in the scope screen shots. The negative phase of the audio is clipped. (the input is the small signal in violet). A properly designed audio amplifier would look the same after amplification , only with a larger amplitude. Clearly , that is not the case here, for the reasons cited. The circuit outputs 4.3 V because the gain is enough to develop that with only the positive phase.

If you are detecting a specific frequency you would surely have a sinusoidal signal to detect, and
if you want to measure it you must not clip?

If you want to detect a particular frequency look at the LM567 detector - they work well

regards

Allan