Many electronic systems require a timing mechanism. This is most often done via a clock signal, which is a square wave of a specific frequency. For many applications, the clock signal is generated within the system via a square wave oscillator. However, this square wave signal can also be an input to the system.

Since many analog and digital circuits can be employed as square wave oscillators, we’ll aim to cover both types; however, in this article, we will discuss the design of analog oscillators, cover their theory of operation, and review their advantages and disadvantages.

### Op-amp Square Wave Generator Using an Astable Multivibrator

The first circuit we will study is a single op-amp circuit known as the astable multivibrator, as shown in Figure 1.

**Figure 1. **Single op-amp astable multivibrator oscillator for generating a square wave.

**Figure 1.**Single op-amp astable multivibrator oscillator for generating a square wave.

If you momentarily ignore the RC feedback from the output, V_{OUT}, to the negative input, V_{c}, you might recognize the rest of this circuit as a Schmitt trigger with hysteresis. The Schmitt trigger has positive feedback and only two stable operating points (V_{OUT} = V_{DD} or V_{OUT} = V_{SS}). As we will explain, the astable multivibrator configuration relies on this positive feedback and hysteresis.

Upon startup of the circuit, we have a capacitor (C) completely discharged to the ground. Since there is an internal offset between the inputs of any amplifier, the positive feedback will ensure the output is driven to one of the two stable states (depending on whether the internal offset is positive or negative).

Now, let’s assume that V_{OUT} is driven to the positive rail (V_{DD}) at the start. At this point, V_{c} will begin to charge through the resistor, R_{3}, and the voltage at V_{p} can be calculated using the resistor voltage divider equation:

$$ V_{p1} = V_{OUT}frac{R_1}{R_1+R_2}= V_{DD}frac{R_1}{R_1+R_2}$$

From here, V_{c} will continue to charge until it becomes slightly larger than the threshold voltage at V_{p}. At this point, V_{OUT} will pull down to the negative rail (V_{SS}), and V_{c} will begin to discharge.

With the new value for V_{OUT} equal to V_{SS}, we also have a new threshold voltage:

$$ V_{p2} = V_{OUT}frac{R_1}{R_1+R_2}= V_{SS}frac{R_1}{R_1+R_2}$$

Next, V_{c} will continue to discharge until it becomes lower than the voltage at V_{p}. Then, the output will be driven back to the positive supply rail, V_{DD}. This process will continue periodically, resulting in a square wave at the output of the op-amp.

#### Op-amp Square Wave Simulation: Voltage Waveform and Frequencies

For the circuit of Figure 1, let’s plug in some component values and simulation performance:

- R
_{1}= R_{2}= 10 kΩ - R
_{3}= 1 kΩ - C = 1 uF
- V
_{DD}= +5 V - V
_{SS}= -5 V

In Figure 2, we have plotted the voltage waveforms of V_{c}, V_{OUT}, and V_{p}.

**Figure 2. **Op-amp astable multivibrator square wave oscillator simulation. *Top: V*_{OUT} (green). Bottom: V_{c} (blue) and V_{p} (red)

**Figure 2.**Op-amp astable multivibrator square wave oscillator simulation.

_{OUT}(green). Bottom: V

_{c}(blue) and V

_{p}(red)

As we can see, V_{c} charges and discharges to the trip points defined earlier by the resistor voltage divider between R_{1} and R_{2} and the supply voltages. The trip points, V_{high} and V_{low}, are defined as:

$$ V_{high} = V_{p1}= 5(frac{10 text{ k}}{10 text{ k} + 10 text{ k}}) = 2.5 text{ V}$$

$$ V_{low} = V_{p2}= -5(frac{10 text{ k}}{10 text{ k} + 10 text{ k}}) = -2.5 text{ V}$$

The frequency of the waveform in Figure 2 is 451 Hz. It is defined by the RC time constant of R_{3} and C in Figure 1 required to charge and discharge the capacitor between V_{high} and V_{low}.

To accurately calculate the frequency of the circuit in terms of the components, we must utilize the charging/discharging equation of an RC circuit. The general form of the charging equation is:

$$V(t)=V_{max}+(V_{initial} -V_{max})e^{frac{-t}{tau}}$$

Solving for t in this equation, we obtain:

$$t=-tau cdot ln(frac{V_{max}-V(t)}{V_{max}-V_{initial}})$$

Now, if we assume the time to charge from V_{low }to V_{high}, with V_{max }= V_{DD}, and we double the time to account for charge and discharge, we obtain the output period:

$$T = 2t = -2 tau cdot ln(frac{V_{DD}-V_{up}}{V_{DD}-V_{low}}) = – 2RC cdot ln(frac{V_{DD}(1-frac{R_1}{R_1 + R_2})}{V_{DD}-V_{SS} frac{R_1}{R_1+R_2}})$$

This equation shows that the RC time constant dominates, while the values of R_{1} and R_{2} have a weak relationship to the period because they change the trip points to which the capacitor must charge and discharge.

If we plug in the values of R_{1}, R_{2}, R_{3}, and C, we get a period of 455 Hz, which matches nearly our frequency of 451 Hz from the simulation.

This circuit is simple, effective, and supports both low and high frequencies, limited by the op-amp’s slew rate driving the output during the switching events. The downside is that the output swing cannot be made smaller, thereby setting a hard limit on the frequency as the output must swing from rail to rail.

To build this circuit with a single supply op-amp that swings from the ground (0 V) to V_{DD}, the ground nodes connected to the capacitor and resistor R_{1} must be changed to a mid-range voltage—typically $$frac{V_{DD}}{2}$$.

### Transistor-based Square Wave Oscillator Using a BJT

An astable multivibrator can also be made with discrete transistors instead of the op-amp. An example using bipolar junction transistors (BJTs) is illustrated in Figure 3.

**Figure 3. **BJT-based astable multivibrator for square wave generation.

**Figure 3.**BJT-based astable multivibrator for square wave generation.

Upon startup of this circuit, one transistor, let’s assume Q2, will go into the “cut-off” region, where it conducts no current. This will cause the collector node (top of Q2) to charge up to V_{DD}.

Meanwhile, Q1 will be saturated and thus conducting current. This will cause the node of C_{1} connected to the base of Q2 to charge up through R_{3} until Q2 is pushed into saturation. Upon being pushed to saturation, the sharp voltage drop on the right side of C_{2} causes a heavy negative response at the base of Q1, pushing it into cut-off.

This kind of push-pull behavior happens continuously, creating output voltage waveforms on both collectors of Q1 and Q2. The outputs are square waves of the same frequency but opposite phases. Since the bases of Q1 and Q2 charge/discharge via RC circuits of R_{3} with C_{1} and R_{2} with C_{2}, respectively, we can define the output period of the generator as:

$$T=t_1+t_2$$

$$t_1=0.69R_3C_1$$

$$t_2=0.69R_2C_2$$

In the transient waveforms, t_{1} is the pulse width of the output at collector Q1, while t_{2} is the pulse width at collector Q2. As one can see in the equations, t_{1} need not be equal to t_{2}, and thus we can create rectangular waveforms of variable duty cycle.

This behavior is demonstrated in the simulation results of Figure 4. For this simulation, we have designed the circuit to have a 50% duty cycle with t_{1} = t_{2}.

**Figure 4. **Bipolar transistor astable multivibrator output with symmetric outputs.

**Figure 4.**Bipolar transistor astable multivibrator output with symmetric outputs.

The components values for this simulation are:

- R
_{1}= R_{4}= 1 kΩ - R
_{2}= R_{3}= 100 kΩ - C
_{1}= C_{2}= 10 nF

The BJTs are standard 2N2222 NPNs. Therefore our expected time constants from our basic equation are:

$$t_1 = t_2 = 0.69RC = 0.69(100 text{ k}Omega)(10 text{ nF}) = 690 text{ } mu s $$

The measured result from our simulation is 681 μs which is close to our design value of 690 μs.

We can also change this design to have nonsymmetric performance. If we halve the resistance of R_{2} to 50 kΩ, we can change the period of t_{2} to 345 us. The simulation result for this circuit after the change is shown in Figure 5.

**Figure 5. **Bipolar transistor astable multivibrator output with nonsymmetric outputs.

**Figure 5.**Bipolar transistor astable multivibrator output with nonsymmetric outputs.

From Figure 5, we see the ability to create nonsymmetric output rectangular waves with easily adjustable duty cycles. The simulation results are t_{1} = 681 μs and t_{2} = 335 μs which is again close to those predicted by our design equations.

Overall, the BJT-based astable multivibrator has much more flexibility when compared to the op-amp oscillator. While slightly more complex in structure, it does not require a negative power supply and produces both the output and its complement. It also gives the ability to form generic rectangular waves of variable frequency and duty cycle instead of pure square waves of variable frequency.

### Review of Analog Square Wave Generator Circuits

Analog implementations of square wave oscillators rely on feedback mechanisms via RC charging/discharging that define the square wave frequency. While not limited to pure square waves, as seen in the BJT version of the astable multivibrator, both of these circuits allow for highly configurable square waveforms to be generated via a simple circuit with no reference signal required.

For lighting, electrical, signage, and technology solutions that allow you to do more call Sverige Energy today at +4(670) 4122522.