Author Topic: Confusion about using a comparator to generate a square wave  (Read 4556 times)

0 Members and 1 Guest are viewing this topic.

Offline PeepsTopic starter

  • Contributor
  • Posts: 48


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?
 

Online oPossum

  • Super Contributor
  • ***
  • Posts: 1416
  • Country: us
  • Very dangerous - may attack at any time
Re: Confusion about using a comparator to generate a square wave
« Reply #1 on: July 14, 2018, 04:56:17 am »
Comparators are usually open collector or open drain. They will sink current, but not source current.
 
The following users thanked this post: Peeps

Offline JS

  • Frequent Contributor
  • **
  • Posts: 947
  • Country: ar
Re: Confusion about using a comparator to generate a square wave
« Reply #2 on: July 14, 2018, 05:22:29 am »
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

If I don't know how it works, I prefer not to turn it on.
 
The following users thanked this post: Peeps

Offline PeepsTopic starter

  • Contributor
  • Posts: 48
Re: Confusion about using a comparator to generate a square wave
« Reply #3 on: July 14, 2018, 07:35:41 am »
 |O 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.
 

Offline JS

  • Frequent Contributor
  • **
  • Posts: 947
  • Country: ar
Re: Confusion about using a comparator to generate a square wave
« Reply #4 on: July 14, 2018, 02:53:14 pm »
|O 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
« Last Edit: July 14, 2018, 08:42:42 pm by JS »
If I don't know how it works, I prefer not to turn it on.
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3240
  • Country: gb
Re: Confusion about using a comparator to generate a square wave
« Reply #5 on: July 14, 2018, 05:46:57 pm »
|O 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.
 

Offline JS

  • Frequent Contributor
  • **
  • Posts: 947
  • Country: ar
Re: Confusion about using a comparator to generate a square wave
« Reply #6 on: July 14, 2018, 08:44:22 pm »


It has positive feedback, in order to provide hysteresis.

Yes, it does, thanks.

JS

If I don't know how it works, I prefer not to turn it on.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19520
  • Country: gb
  • 0999
Re: Confusion about using a comparator to generate a square wave
« Reply #7 on: July 14, 2018, 10:27:23 pm »
Another option is to use a comparator with a push-pull output, such as the LMC6762 or TSX3702.
http://www.ti.com/lit/ds/symlink/lmc7211-n.pdf
https://www.st.com/resource/en/datasheet/tsx3702.pdf
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf