0-12v square wave to +/- square wave

Thread Starter

JW_Bryncelynnog

Joined Mar 25, 2020
12
I have a signal which is a square wave at about 25000Hz. The high is 12V, the low is 0V or ground. I have a dual rail supply. I want to change the signal so it swings between +12v to -12v.

I use an LM358 op amp as a comparitor, powered from the + and - rails. I put 2V relative to ground on the inverting input. I was expecting the output to swing either way (as on my schematic), but it doesn't - it is constant at -12V. I have tried putting the potential divider between the +/ground and using different resistors between + and -, so that it is just a few volts above ground, but the output is not moving.

Relatively new to this, have I done anything wrong?

Any help most appreciated!

John20200415_191059.jpg
 

BobTPH

Joined Jun 5, 2013
8,967
Unless the op amp is rail to rail, it will not produce ±12V.

A better circuit would have a gain of 2 and offset of 6V.

Bob
 

crutschow

Joined Mar 14, 2008
34,452
have I done anything wrong?
Sort of. You didn't look at the frequency response/slew rate of the opamp or its output characteristics.
The first thing any good designer does is carefully look at the data sheet of the devices he is using.

An LM358 opamp is way too slow to be used as a comparator for a 25kHz square-wave.
You need to use a comparator, which is much faster since it doesn't have the internal frequency compensation of an opamp needed for stable closed-loop operation.
Also the LM358 won't output the full ±12V as it's not a rail-rail type.

Below is the LTspice simulation of such a circuit using an LM339 comparator:

1586978536336.png
 
Last edited:

Thread Starter

JW_Bryncelynnog

Joined Mar 25, 2020
12
Thanks for your reply.

first thing any good designer does
I tend to learn by my mistakes - I am a trial and error ist! I will get some on order. Thanks.

Just one further question - Why does it give me a negative voltage - if it cant slew quick enough, why does it not dither about 0V?
Just wondering!

Regards

John
 

crutschow

Joined Mar 14, 2008
34,452
Why does it give me a negative voltage - if it cant slew quick enough, why does it not dither about 0V?
Just wondering!
Because it's not biased at 0V.
You have a positive DC reference voltage into the (-) input which biases the opamp output at its most negative voltage, and the op amp is too slow to go much above that when the (+) input is high.

Below is the what the simulation shows:
If you are a "trial and error" type then you should learn to use a simulator such as the free LTspice from Analog Devices.
If will show you most of your errors before you do the real trial.

1586979036757.png
 

wayneh

Joined Sep 9, 2010
17,498
Thanks for your reply.


I tend to learn by my mistakes - I am a trial and error ist! I will get some on order. Thanks.

Just one further question - Why does it give me a negative voltage - if it cant slew quick enough, why does it not dither about 0V?
Just wondering!

Regards

John
Play with it in DC mode. Use your voltmeter. You'll discover where the bad assumptions are in short order. It could be a bad amp, too, by the way. Does your signal share the same ground as your op-amp?
 
Top