i want to ask a question about PWM.Now if we have a sine wave with say peak to peak amplitude 5V and a triangle wave with peak to peak amplitude say 7V and we pass it into a comparator like the LM393 and i remember audioguru saying that the amplitudes of both waves dont need to be that high since the comparator has a very high voltage gain about say 200 times or something like that.
1)Well if all circuits are it from a 12V source and passed into the comparator would the resulting PWM output go from 0V to as high as near the supply voltage even if the amplitude of the two waves being compared are not that high since the voltage gain of the comaprator is very high?
2)if we were to filter this PWM wave to get back the sine wave would the sine wave gotten back have peak to peak amplitude 5V since that is the oroginal wave used in the actual comparing?
Hello again,
I think this is a very good question. The best answer i think shows the difference between how we perceive comparators and how a real life comparator really works.
In theory, if we have a non inverting (+) input of 10 volts and an inverting (-) input of 5 volts, the output will be go high immediately. In practice with a real comparator IC, the same thing happens except there is a delay while the output STARTS to ramp high, then another delay while the output actually ramps high. The first delay is caused by the internal gain and input signal, and the second delay is caused by the slew rate. The second delay is 'usually' the most important, but we can not totally forget about the first delay in all applications.
There we looked at signals that are quite different, 10v and 5v, but what about signals that are much closer?
It just so happens that many comparator applications have signals that are much closer to each other because one or both signals do not change very fast themselves. For example, with 5v on the inverting terminal and a charging capacitor that charges slowly on the non inverting terminal, the voltage on the cap starts at 0v and rises slowly past 5v, so just how long does it take for the comparator to respond when the voltage gets 'near' 5v.
It just so happens that it takes a little bit longer because when the voltage of the cap reaches 5.000000 volts with a reference of 5.000000 volts on the other input the comparator gain of 100000 still does not produce any output change because the difference in input voltages is zero, and zero times any gain is still zero.
So lets say the cap voltage rises to 5.000001 volts next. That means the difference is 1uv, and with an internal gain of 100000 that means the output should rise to 0.1 volts, with a small delay. But since the input is changing so slow (large cap and resistor) it could have taking 60 seconds for that change to occur.
So we have a delay that is based partly on the rate of change of the two inputs as well as other built in factors, and this is why we often see tests of comparators done with voltage steps. The step is usually around 0.1 volt as a min i think, but you could check your data sheets to see what they use for their test for that particular device.
What this means is that the input amplitudes do have an effect on the output of the comparator, in that the amplitudes tend to delay the point in time where the comparator starts to switch states. The delay after that depends mostly on the output slew rate.
So for two signals one a sine and one a triangle, we see two inputs changing at different rates most of the time. That means the initial response delay for the slowest change points in time will be double for signals that are half as high in amplitude. The slew rate however will still be the same for any amplitude, but it could appear to be much longer if the two inputs dwell near the same amplitude level for long periods of time.
For example, for very slow sine and triangle waves, the sine rises fastest near 0 degrees and 180 degrees, so those times will produce the fastest output change. Neat the peaks however, the triangle rate will dominate and that's usually fast enough to produce a good output providing the initial delay is much faster than the slew rate.
So the short answer is, the voltage levels do affect the output delay, but if the initial delay is much faster than the slew rate it should not matter too much. If the voltages are very low the initial delay can be long though.
What will not be affected however is the amplitude after all of the delays have been considered. Using a +12v supply with a pullup resistor for the comparator, the output will rise eventually near to +12v, and will fall down very close to 0v. One thing to note however is that because the comparator depends on a pullup resistor, any load resistor from the output to ground could greatly reduce the output voltage for a logic high level. With a 10k pullup and a 10k load resistor, that would mean that with a +12v supply we would only see +6v output across the 10k load resistor.
It will however pull all the way to ground, except for the small internal transistor drop would could be anywhere from near 0 to around 0.5 volts and depends on the value of the pullup resistor and if there is any load resistor from the output to the +12v line.
Finally, for most comparator apps there is usually a small amount of hysteresis added to the comparator in the form of an extra resistor or two. One thing this does is it improves that initial delay time to help keep it short. That way even with slowly changing input signals we can see fast output rise times.