Convert Sine Wave To 5 Volt Square Wave

Thread Starter

820L

Joined May 14, 2025
30
I would like to know if this circuit will work in the real world. The purpose of the circuit is
to convert a sine wave or square wave of any voltage of up to say 20 volts into a 5 volt
square wave. Not sure how high of a frequency can this circuit handle?

thanks
 

Attachments

Ian0

Joined Aug 7, 2020
13,118
Yes, that will work.
I would suggest that you move D1 so that it is directly across the base-emitter junction, and make it a 1N4148. There is no need to protect Q1 base from positive voltages, but you must not let it go below -6V.

You will get a better response at high frequencies if you put a Baker (anti-saturation) clamp across Q2. That is a small schottky diode between base and collector with the cathode connected to the collector.

You could get a squarer squarewave by making R4 a short circuit. Increase R3 to 22k. Join Q1 and Q2 emitters and put 100Ω between them and ground. Then you've made a Schmitt trigger.
 

schmitt trigger

Joined Jul 12, 2010
2,056
I also vote to make it a schmitt trigger. If any noise enters the circuit, you may have multiple transitions during the zero crossing.
Since those will be high frequencies, unless you significantly decrease the timebase you won’t see them on the scope, but the logic circuits definitely will react to them!
 

Ian0

Joined Aug 7, 2020
13,118
Try a bias resistor from Q1 base to the positive supply.
Calculate it so that the current through the bias resistor would put 0.6V across your input resistor.
 

AnalogKid

Joined Aug 1, 2013
12,093
she works with a 0.7 volt to 5 volts square wave rather than 0 to 5 volts. Any way to make it 0 to 5?
For that you need a circuit whose input signal operating range includes GND. Concept level: 1/2 of an M358 or LM393.

It's actually a bit more complex than that, but if you can AC-couple the signal into the comparator then you don't need a device with the exceptional input common mode voltage range. But the main point is that you cannot get there with just one transistor and no negative voltage rail.

ak
 

panic mode

Joined Oct 10, 2011
4,947
Yep, I had D1 upside down. Fixed the diode and she works with a 0.7 volt to 5 volts square wave
rather than 0 to 5 volts. Any way to make it 0 to 5?
diode works as intended, so leave it at that. it is your circuit output that you should be focused on. and there voltage is from 0.03V - 5V. is't that what you wanted?

1747747347862.png
 

Ian0

Joined Aug 7, 2020
13,118
I thought he wanted it to work with a smaller amplitude sinewave, so 200k between Q1 base and 5V supply should bias it so that it switches around zero.
 

panic mode

Joined Oct 10, 2011
4,947
my interpretation is that input can be any wave (singe, square) up some max limit... say 20V
using large input resistor will work well for higher voltage but may pose a problem is input voltages are low.
using biasing resistor can make circuit switch near specific point. not sure what that point is. or what frequency range this is supposed to work with.. so probably AC coupled input would meet TS's expectations.

The purpose of the circuit is to convert a sine wave or square wave of any voltage of up to say 20 volts into a 5 volt
square wave. Not sure how high of a frequency can this circuit handle?
 

panic mode

Joined Oct 10, 2011
4,947
yup, it would be nice to know what the purpose is as well as working constraints. it seem to be intended to derive clock from mains... but using circuit that switches near zero would be sensitive to noise. and why TS asked about max frequency? isn' t he supposed to come up with some requirements, and then suitable circuits and budget can be worked out.
 
Top