This circuit which I found in an industrial electronic device uses an LM339 comparator to compare the offset sine wave to a reference voltage of 5V and creates an inverted square wave as a result. From what I've read, R2 exists to feed back some of the output to change the reference slightly to create a hysteresis effect although in simulation the reference voltage hardly changes.
What I don't understand and haven't quite been able to figure out is why the output square wave never goes above 5V. Regardless of the supply voltage, the square wave maxes out at 5V. I feel like it should go as high as Vcc but this is not the case. Can someone help this fool understand why?
Comparators are usually open collector or open drain. They will sink current, but not source current.
The voltage change would be only 1/121, since the ratio of the resistors is such. The reference won't change, but effectively it does by shifting the input signal by that ammount on the non inverting pin. There you will see a small jump when the voltage crosses the threshold. That's there as you said to generate hysteresis, so the noise while crossing the line doesn't make the output to jump back and forth before settling, or if the voltage crossing is too slow, the output could act as a linear amplifier making strange things, for this circuits you usually want some ammount of hysteresis.
JS
thank you, I knew I was missing something obvious and that was it. I kept thinking about it in terms of a traditional op-amp and not a comparator.
thank you, I knew I was missing something obvious and that was it. I kept thinking about it in terms of a traditional op-amp and not a comparator.
More like the opposite, it has POSITIVE feedback so it doesn't want to be stable, one state one the other, wich makes it stable (against the rails) and once it's there id doesn't want to go to the other state, it preferes to stay, till the change is big enough.
JS
thank you, I knew I was missing something obvious and that was it. I kept thinking about it in terms of a traditional op-amp and not a comparator.
More like the opposite, it has negative feedback so it doesn't want to be stable,
It has
positive feedback, in order to provide hysteresis.