Comparator Circuit Behavior Questions

Started by Ohioisonfire, July 04, 2022, 01:06:06 PM

Previous topic - Next topic

Ohioisonfire

Hello,

I have been working with comparator circuits for a square wave effect.  I have done a lot of breadboaring and am pleased with the results.  While working on expanding the circuits in LTSpice I noticed some behavior I didn't expect.  In the snips below you will see a very basic slimmed down circuit that works and demonstrates what I have noticed.

Output of the Op-Amp based comparator:


Output of the circuit after a 1uF capacitor and a voltage divider:


Output of the circuit after a 10uF capacitor and a voltage divider:


On to the questions:

1. Why does the square wave center at ground eventually?  I would have expected going between ground and whatever the "high" state is.

2. Why does the signal transistion from going between ground and whatever the "high" state is, to switching betwen high and low centered on ground?  The speed of this changes with the RC filter that is created.

3. Is there a better way to attenuate the comparator output voltage?  I do not want to clip anything downstream.

I'm sure I am missing something basic here, but the goal is to learn from the more knowledgeable in this forum.

duck_arse

short answer would be C5. the opamp sits at 1/2 supply at its output, but you then bung in the cap, and pull one end of it to 0V with resistors. then the AC comes along, and is more than and less than 0V. I think.
" I will say no more "

PRR

#2
> Why does the square wave center at ground eventually?

A capacitor-resistor coupling network will settle so the *average* value of the output is zero.

IOW: DC won't go through a capacitor.

If you need DC on the output, lose the capacitor.
  • SUPPORTER

antonis

IMHO, a Smitt Trigger configuration should be more effective..
(provided the input signal amplitude higher than the hysteresis limits..)
"I'm getting older while being taught all the time" Solon the Athenian..
"I don't mind  being taught all the time but I do mind a lot getting old" Antonis the Thessalonian..

Ohioisonfire

Quote from: PRR on July 04, 2022, 04:13:41 PM
A capacitor-resistor coupling network will settle so the *average* value of the output is zero.

IOW: DC won't go through a capacitor.

If you need DC on the output, lose the capacitor.

Thank you for the reply, that helps me to understand it better.  I am always trying to learn, and sometimes it just takes someone explaining it differently for things to make more sense.

Quote from: antonis on July 04, 2022, 04:44:07 PM
IMHO, a Smitt Trigger configuration should be more effective..
(provided the input signal amplitude higher than the hysteresis limits..)

Great suggestion!  The final design will likely be of a schmitt trigger configuration.  I wanted to trim down the circuit as much as possible to keep this thread simple.

Rob Strand

#5
You need to think about what you expect from the simulation and what you expect from the circuit in the real world application.

In your simulation the whole circuit is starting up from nothing.   Spice always starts with the caps charged to their DC values, often that will be 0V.  So with this mind set the charging of the caps to their average DC values is an artifact of the simulation.   If you simply don't want to see these artifacts in the simulation, you can set the caps to specific voltages (using "initial conditions") to make the simulations cleaner.

However, the behaviour isn't always an artifact/annoyance.   The transient behaviour you are seeing near time=0 can occur in the actual circuit at any time.

For example if the input signal came from a guitar instead of an oscillator then there will be periods where there is no signal followed by the application of the guitar signal.  In this case the transient behaviour is going to be there in the normal operation of the circuit and you don't want to be forcing the cap voltages.

For your actual circuit: when there is no input signal you have the option to idle the output of the comparator at 0V and or Vcc depending of whether VB > VA or VB < VA.    You might need to consider that as part of your design.

If you are going to inject the square-wave into the audio then there's no point removing the DC/transisient.  You are going to have to couple the square-wave into the audio path at some point.   If you are using the square-wave for some additional processing (eg feed it into a divider) then the DC needs to be sorted out.

FWIW, the Schmitt-trigger is outside of all of the above.  The Schmitt-trigger will remove fizzing when the signal passes through 0V AC.   You can think of it as removing noise.   Often filtering the signal before the Schmitt-trigger can also clean-up the signal detection.
Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.