# square wave oscillator using transistors

#### Dut Chen

Joined May 19, 2017
27
I created a thread about this a while ago and back then i did manage to get a working circuit. Looking back at it now I'm still not very happy with it so i decided to give it another shot, and because you're reading this i obviously failed.

The idea is to create a square wave oscillator where the frequency is adjustable using a potentiometer.
Some things I took into consideration:
1. I could use a 555, op-amp, Schmitt trigger, or whatever IC to create this circuit, but these come with a lot of extra fluff that isn't required for a working oscillator and because the rest of the project is built from scratch, without ICs, I also want to build the timing circuit from scratch.
2. The circuit must have actual outputs. High is V+ (5v) and low is V- (0v), not some internal state change where the circuitry to read the output affects the oscillation frequency or duty cycle.
3. The output load must never affect the frequency or duty cycle.
These might be harsh requirements, but I'm still amazed that with all the circuits on the internet i couldn't find a single one that fits all three requirements.
I have, of course, been spending lots and lots of time trying to get a working circuit myself, these are some of my attempts:
1. The standard astable multivibrator circuit:
The basic astable multivibrator has two issues: It's more of a saw-tooth wave than a square wave, and it has two frequency determining networks so a potentiometer can't be used to adjust the frequency.
There are many different variations on the basic circuit which solve some of these issues but I still couldn't find any that fit all requirements.
2. The Schmitt trigger relaxation oscillator:
My last post was about this circuit, using a Schmitt trigger IC this oscillator is perfect for my needs, but the transistor Schmitt trigger shown above is nowhere near perfect and suffers from these issues: There's tons of calculations online about determining the low and high threshold of the transistor Schmitt trigger, some different than others, which are correct? I don't know, none of them matched the behavior i got after building the circuit, and the output low isn't actually 0 volts but the result of the resistor voltage divider Rc2 and Re, the output load also affects the frequency.
3. My own attempts:
I suck at designing circuits, no wonder none of them worked.
Though i did learn a lot in the process.
Naturally after all else fails I find a forum and hope to get some help there.
Thanks for taking the time to read my post.

#### dl324

Joined Mar 30, 2015
16,923
You're requirements are unreasonable.

The output can't swing from 0-5V regardless of loading. Real circuits don't behave that way.

You can buffer the outputs of the two transistor astable multivibrator circuit you posted to get more ideal behavior.

EDIT: Missed the part where you wanted the frequency to be adjustable. Buffering would address requirements 2 and 3, but not a single component to adjust frequency.

Last edited:

#### Dut Chen

Joined May 19, 2017
27
Of course a high enough load will pull down (or up) the output voltage, but this must not affect the oscillation frequency.

#### BobTPH

Joined Jun 5, 2013
8,971
Perhaps you have discovered why the ICs ypu are rejecting have all that “extra fluff.”

Bob

#### Dut Chen

Joined May 19, 2017
27
Hi Bob,

I was specifically talking about the 555 timer IC, I'm fine with building a much less complex Schmitt trigger out of transistors and using that but as you can see i didn't have any luck with that either.

#### dl324

Joined Mar 30, 2015
16,923
Of course a high enough load will pull down (or up) the output voltage, but this must not affect the oscillation frequency.
Loading the two transistor astable outputs should have minimal affect on frequency. If you buffer the outputs with a CMOS inverter, the problem essentially goes away.

#### BobTPH

Joined Jun 5, 2013
8,971
So was I, it was designed to do exactly what you want. It has a essentially a very precise schmitt trigger with thresholds if 1/3 and 2/3 V+ and a buffered push pull output circuit. The CMOS version has output from rail to rail.

It is basically what it takes to meet your requirements and not much more.

Bob

#### iimagine

Joined Dec 20, 2010
511
I designed this circuit awhile ago, maybe you'd be interested:

output needs buffer but that can be just another bjt

#### iimagine

Joined Dec 20, 2010
511
Or you can use diodes:

#### AnalogKid

Joined Aug 1, 2013
11,048
A few things about post #1. I'm no huge 555 fan, but it was built from the ground up to do one thing well and this is it.

There is no extra "fluff" in any of the three circuits you mention, unless you count the unused gates in a quad or hex Schmitt trigger chip. A 555 needs 2 Rs and 2 Cs - hard to get less fluffy than that.

Also, the 555 output stage is not connected to the oscillator section, so there is your output isolation.

Also, the 555 output frequency has an almost zero voltage coefficient; that is the effect a varying power supply voltage has on the output frequency.

You don't state the frequency or freq range of operation.

You don't state whether or not you need a 50% duty cycle, and, if so, a tolerance on it.

You don't state the output requirements: Voltage range, high and low output currents, risetime, etc.

An all-transistor Schmitt trigger circuit can be tricky to calculate correctly, and there is the problem of Vbe varying from part to part and with temperature. However, a dual opamp circuit is relatively easy to calculate, stable, repeatable, and has a single timing resistor. The first opamp is the oscillator, the second opamp is an output buffer.

ak

#### Dut Chen

Joined May 19, 2017
27
Hi ak,

I quickly mocked up some specifications, though in reality the circuit will probably function fine if these are exceeded.
The circuit will operate at ~1Hz to ~100Hz.
Duty cycle should be between 1/3 and 2/3.
The circuit will operate at 5V.
The output voltage must not dip below 4.9V when sourcing below 20mA, it will never sink current.

Again, my reluctance to use ICs is because the rest of the project also doesn't use ICs.
I've had a lot of fun designing transistor logic circuits but when a circuit requires feedback my brain just can't handle it.

#### Dut Chen

Joined May 19, 2017
27
stealing some ideas from iimagine I created this circuit

Now i could use some help understanding what i just built.

You'll see a RC network to the left, a Schmitt trigger in the center, and to the right the output circuit and a 330 ohm resistor representing the load.
Let's start with the Schmitt trigger. The upper threshold is 3.3V, makes sense as the 4.7K and 10K form a voltage divider that leaves 2/3s of V+ at the emitter of the input transistor. However the lower threshold is 1.66V which i got after tweaking the 33K resistor, this doesn't make sense to me, shouldn't the lower threshold be 10k/(10k+33k) = 23% of V+ = 1.16V? or taking into account the voltage drop across a transistor 23%+0.7 of V+ = 1.86? To be honest I'm surprised this even oscillates at all, to me the math doesn't line up.
Next up the power consumption. The 1k resistor to the left consumes about 4mA while the capacitor is charging, the resistor itself is required for the capacitor to discharge properly but it just wastes power while charging, is there a way to reduce the consumption without adding too much extra complexity?
The output voltage also drops a little below 4.9V with a 20mA load but if that becomes an issue i can just add another output transistor.

Aside from still not understanding the Schmitt trigger thresholds I'm pretty happy with the circuit, way happier than the previous one at least.
Special thanks to iimagine for the inspiration for this circuit, maybe the rest of you will be able to convince me to use an IC some other time.

EDIT: Also please let me know what you think of the circuit and how it could possibly be improved, I'm very much interested in sharpening my circuit-design skills.

Last edited:

#### dl324

Joined Mar 30, 2015
16,923
My last post was about this circuit, using a Schmitt trigger IC this oscillator is perfect for my needs, but the transistor Schmitt trigger shown above is nowhere near perfect and suffers from these issues: There's tons of calculations online about determining the low and high threshold of the transistor Schmitt trigger, some different than others, which are correct?
Here's a Schmitt trigger inverter that doesn't require any calculations:

I breadboarded the circuit using the 6 MOSFETs in a CD4007. It's oscillating at around 20 30 Hz with a 1M resistor and 0.1uF cap. I doubled the cap and the frequency dropped to about 10 7 Hz.
EDIT: scope timebase was in the uncal position...

Have fun finding discrete MOSFETs that will work...

Last edited:

#### iimagine

Joined Dec 20, 2010
511
taking into account the voltage drop across a transistor 23%+0.7 of V+ = 1.86?
Correct, 1.86V is your lower threshold
I'm surprised this even oscillates at all
Why? You have defined an upper threshold of 3.3V and a lower at 1.16V (at emitter), why wouldnt it oscillates?
Next up the power consumption. The 1k resistor to the left consumes about 4mA while the capacitor is charging, the resistor itself is required for the capacitor to discharge properly
That resistor is not needed if you omit the 100k base resistor and allow the cap to discharge thru the transistor. I think I put it there to allow me to control the pulse width, it has been awhile. Anyway, here is an update of my circuit:

#### Dut Chen

Joined May 19, 2017
27
That resistor is not needed if you omit the 100k base resistor and allow the cap to discharge thru the transistor. I think I put it there to allow me to control the pulse width, it has been awhile. Anyway, here is an update of my circuit:
I dislike discharging through the transistor because it gives you less control over the duty cycle.

So i built the circuit from my previous post with only one modification: having the 4.7k resistor on the collector instead of the emitter.
However the square wave doesn't look quite as clean in real life

There's some noise on the falling edge, any ideas on how i could smooth this out?

#### iimagine

Joined Dec 20, 2010
511
I dislike discharging through the transistor because it gives you less control over the duty cycle.
You can control duty cycle by adjusting the upper threshold resistor, in this case, the 4.7k. As for the noise, I have no idea at this point.

What is the purpose of the second diode?

#### Dut Chen

Joined May 19, 2017
27
What is the purpose of the second diode?
Nothing really, I wanted to see if it would even out the duty cycle since it would be charging and also discharging through a diode, but of course it still discharges through an extra 1K resistor so i ended up removing it.

#### iimagine

Joined Dec 20, 2010
511
Since you are using a base resistor, you can just omit the diode and the 1k, the load resistor can take care of the discharging.

#### Dut Chen

Joined May 19, 2017
27
The load resistor is just to test, in practice the load will not be constant and therefor can't be used to discharge the capacitor.

#### MrAl

Joined Jun 17, 2014
11,487
Hi,

Do you really need a 50 percent duty cycle wave?

If so, run the oscillator at twice the frequency and use a flip flop to divide by 2. The output of the flip flop will be 50 percent duty cycle at the required frequency.
You can use almost any oscillator for this even if not 50 percent duty cycle.