Tag Archives: square wave using 555 timer IC

Symmetric Square Wave using 555

This 22nd article in the series of “Do It Yourself: Electronics”, finally generates a 50% duty cycle waveform using IC 555.

<< Previous Article

After failing to achieve 50% duty cycle square wave, or so called symmetric square wave, using his trivial circuitry, Pugs further explored. One clear observation was that the output pin 3 is the only pin which goes both high and low, correspondingly during the charging and discharging cycle. So, not using pin 3 means that there has to be two separate paths for charging and discharging the capacitor C, meaning two separate resistors R1 & R2 similar to the initial design as in the first 555 article.

So, Pugs restarted with the same initial design, where R2 was in discharging path and R1 + R2 in the charging path. Clearly, the problem is that R2 is also in the charging path, making it non-symmetrical. The thought of “Can R2 be removed just from the charging path?”, treaded Pugs into the short circuit and open circuit properties of diodes correspondingly in their forward and reverse biases. “Yes! Why not put a diode D1 in parallel with R2, such that D1 is short (aka forward bias) in charging cycle, and it is open (aka reverse bias) in discharging cycle?”, exclaimed Pugs. Thus, R2 would be by-passed in the charging cycle and used in the discharging cycle, exactly as desired. Here’s the modified circuit, which has just clicked:

Approximate Symmetric Square Wave using 555 (Schematic)

Approximate Symmetric Square Wave using 555 (Schematic)

Now the charging path has the resistor R1 & capacitor C, and the discharging path has the resistor R2 & capacitor C. So, we would get,
t_{on} = R1 * C * ln(2) … (4)
t_{off} = R2 * C * ln(2) … (5)

And if we put R1 = R2, we get a 50% duty cycle.

Live Demo

What do you think would Pugs wait for? Here’s his breadboard layout with two 4.7KΩ resistors (both of which closely measured 4.3KΩ on the multimeter), and a 1μF capacitor:

Approximate Symmetric Square Wave using 555 (Breadboard)

Approximate Symmetric Square Wave using 555 (Breadboard)

The audio jack is being used for observing the waveforms on the home-made PC oscilloscope, as created in his previous PC Oscilloscope article.

Below is the waveform observed by Pugs, for the values of R1 = R2 = 4.3KΩ (measured), and C = 1μF:

R1 = 4.3K, R2 = 4.3K, C = 1u, D1

R1 = 4.3K, R2 = 4.3K, C = 1u, D1

From the above waveform, we approximately have t_on = 3.2ms and t_off = 3.0ms. Close enough to our expected value of 2.98ms (as per equation 4 or 5), but not really satisfactory as t_on and t_off are still not exactly same, even though R1 and R2 are closely equal.

In fact, t_on is slightly more, meaning the resistance in the charging path is more than just R1. O Yes! Our diode D1 is not an ideal diode, it would have some resistance in the forward bias as well, and that is what is getting added up in the charging path, causing this deviation. But how to avoid this? How about adding an equivalent diode D2 in the discharging path? That’s a cool idea, which looks like as shown below:

Symmetric Square Wave using 555 (Schematic)

Symmetric Square Wave using 555 (Schematic)

Pugs’ breadboard connections for the same are as follows:

Symmetric Square Wave using 555 (Breadboard)

Symmetric Square Wave using 555 (Breadboard)

Captured waveform as follows:

R1 = 4.3K, R2 = 4.3K, C = 1u, D1, D2

R1 = 4.3K, R2 = 4.3K, C = 1u, D1, D2

And, now we see that t_on and t_off both are approximately equal to 3.2ms.

To be more exact, one may use a pot in place of R2 & D2, and then adjust it to match it with resistance of R1 & D1 – more precisely by matching the off cycle to the on cycle.

Next Article >>

   Send article as PDF   

Trivial Square Wave using 555

This 21st article in the series of “Do It Yourself: Electronics”, tries generating a 50% duty cycle waveform using a non-conventional trivial circuit using IC 555.

<< Previous Article

On further observation, of the IC 555 behaviour, Pugs got a trivial idea of generating 50% duty cycle square wave using just one resistor and one capacitor as shown in figure below:

Trivial Square Wave using 555 (Schematic)

Trivial Square Wave using 555 (Schematic)

Note that, both the charging & discharging paths would have the same resistor R & capacitor C. So, putting in the equations (1) & (2) derived in the previous article, we would get,
t_{on} = t_{off} = R * C * ln(2) … (3),
thus giving a 50% duty cycle.

Live Demo

Excited by his idea, Pugs couldn’t wait but try out the same. So, he set the above circuitry on a breadboard as shown in the figure below:

WARNING: Do NOT put the pot to a value of zero, as that will overload the circuit. A safety workaround could be to put a fixed 1K resistor in series with the pot.

Trivial Square Wave using 555 (Breadboard)

Trivial Square Wave using 555 (Breadboard)

The audio jack is being used for observing the waveforms on the home-made PC oscilloscope, as created in his previous PC Oscilloscope article.

Then, for C as a 1μF capacitor, he adjusted R to different values to get different frequencies with 50% duty cycle. But, what’s this, none of them have a 50% duty cycle.

Below are some of the waveforms being observed by Pugs, for the values of R being adjusted to 1.5KΩ, 5KΩ, 10KΩ:

R = 1.5K

R = 1.5K

R = 5K

R = 5K

R = 7K

R = 7K

From the above waveforms, we approximately have the following t_on & t_off:
R = 1.5KΩ => t_on = 2.8ms, t_off = 1.1ms
R = 5KΩ => t_on = 8.9ms, t_off = 3.4ms
R = 7KΩ => t_on = 12.5ms, t_off = 4.8ms

Now, as per equation (3), for C = 1μF, and the above three R values, we should have got the following:
R = 1.5KΩ => t_on = t_off = 1.0ms
R = 5KΩ => t_on = t_off = 3.5ms
R = 7KΩ => t_on = t_off = 4.9ms

t_offs are pretty exact, but t_ons are really high. After quite a bit of analysis, Pugs realized that the peak Vo is not actually reaching Vcc. Debugging trick he used, was to replace the 1μF capacitor by a 100μF capacitor, thus reducing the frequency in Hz (eye observable), and then measuring the Vo using a multimeter. Aha! if the Vo doesn’t reach Vcc, then in the above circuit, we are not charging the capacitor using Vcc but this measured peak value of Vo. Mathematically, this changes our derivation for equation (1) in the previous article, though equation (2) remains the same. And hence, getting a correct t_off but incorrect t_on. Even conceptually, we can see that as Vo is less than Vcc, the capacitor would take more time to charge, and thus increasing the time (t_on), as observed in all the readings above.

On this realization, Pugs approximated the measured value of maximum Vo to 3.65V, i.e. 3.65/5 of Vcc instead of Vcc in deriving the equation (1) of the previous article, getting the following relation:
2/3 * V_{cc} = 3.65/5 * V_{cc} * (1 - e^{\frac{-t_{on}}{R*C}}) + 1/3 * V_{cc} * e^{\frac{-t_{on}}{R*C}},
which on simplifying gives:
t_{on} = R * C * ln(6.2632) = R * C * 1.8347

Putting in the values, gave t_on values amazingly close to the observed values, thus again verifying the theory.

Summary

Also from the 555 IC datasheet, Pugs found that there is always some expected drop on the peak Vo from the supply voltage Vcc, and the peak Vo in most cases would be less than Vcc – thus rendering all our standard calculations of t_on futile. In fact, if we put the actual value of peak Vo in our calculations, we would get the results as observed. But getting the actual value of Vo is non-trivial and non-standard. Moreover, even if we do that somehow, we are not going to get our desired 50% duty cycle.

Thus, moral of the story is that, in general, Vo should not be used to generate the trigger voltages, as practically it may not be reaching Vcc, as in the case above. And, Pugs would have to find out some other way to achieve 50% duty cycle.

Next Article >>

   Send article as PDF   

Square Wave using 555

This 20th article in the series of “Do It Yourself: Electronics”, explains the basic working of IC 555 and generating a square wave using it.

<< Previous Article

Playing with raw electronics (without any microcontroller), further boosted the confidence of Pugs to dive into non-microcontroller electronics. This time he decided to explore the ever popular IC 555, loosely also known as the timer IC.

555 Functionality

555 is basically an 8-pin IC, with pin 1 for GND, pin 8 for Vcc, and pin 3 for Vo – the output voltage, which goes either high (Vcc) or low (GND), based on the other pins.

Vo goes high if the trigger pin 2 senses voltage less than 1/3 of Vcc. Vo goes low if the threshold pin 6 senses voltage greater than 2/3 of Vcc.

Pin 5 can be used as a control voltage always fixed to 2/3 of Vcc. Putting reset pin 4 low any time makes Vo go immediately low. So, if not in use it is recommended to be tied to Vcc.

Discharge pin 7 becomes GND when pin 6 senses voltage greater than 2/3 of Vcc and becomes tristate (open) when pin 2 senses voltage less than 1/3 of Vcc. In other words, discharge pin 7 becomes GND when Vo goes low and becomes open when Vo goes high.

Generating a Square Wave

Given this background, one of the common uses of the 555 IC is to generate a square wave of any particular frequency and duty cycle (on pin 3), by varying some analog voltage between GND and Vcc (on pins 2 and 6), more precisely between 1/3 Vcc and 2/3 Vcc, both inclusive. And this analog voltage is typically achieved by charging / discharging a capacitor through one or more resistors. Thus, the time constants given by τ = RC, R being the resistance, and C being the capacitance in the corresponding charging & discharging paths, controlling the corresponding on & off cycle of the square wave.

Let’s consider the following circuit with R1 as a variable resistance (pot) between 0-10KΩ, and R2 as fixed resistance of 4.7KΩ, and C as a 1μF capacitor.

Square Wave using 555 (Schematic)

Square Wave using 555 (Schematic)

In the on cycle (when Vo (pin 3) is high), pin 7 would be open. Pins 2 & 6 can be assumed tristate. Hence, then C is getting charged towards Vcc through R = R1 + R2.

In the off cycle (when Vo (pin 3) is low), pin 7 would be GND. Pins 2 & 6 can be assumed tristate. Hence, then C is getting discharged towards GND (pin 7) through R = R2.

Moreover, note that in the on cycle as soon as capacitor voltage reaches 2/3 Vcc, Vo (pin 3) becomes low, and pin 7 becomes GND, i.e. off cycle starts.

And, in the off cycle as soon as capacitor voltage drops to 1/3 Vcc, Vo (pin 3) becomes high, and pin 7 becomes tristate, i.e. on cycle starts.

And the above sequence keeps on repeating, thus giving a square wave on Vo (pin 3), with on time t_on controlled by charging through R1 + R2 and off time t_off controlled by discharging through R2.

From RC circuit analysis, we have that voltage Vc across a capacitor C, getting charged through resistance R, at time t is given by:
V_c = V_s * (1 - e^{\frac{-t}{R*C}}) + V_i * e^{\frac{-t}{R*C}},
where Vs is supply voltage (Vcc in our case), Vi is the initial voltage on the capacitor.

So, t_on could be obtained from the fact that it starts with inital voltage Vi = 1/3 Vcc, and ends when Vc = 2/3 Vcc, being charged by Vs = Vcc through R = R1 + R2. That is,
2/3 * V_{cc} = V_{cc} * (1 - e^{\frac{-t_{on}}{R*C}}) + 1/3 * V_{cc} * e^{\frac{-t_{on}}{R*C}},
which on simplifying gives:
t_{on} = R * C * ln(2) = (R1 + R2) * C * 0.6931 … (1)

Similarly, from RC circuit analysis, we have that voltage Vc across a capacitor C, getting discharged through resistance R, at time t is given by:
V_c = V_i * e^{\frac{-t}{R*C}},
where Vi is the initial voltage on the capacitor.

So, t_off could be obtained from the fact that it starts with initial voltage Vi = 2/3 Vcc, and ends when Vc = 1/3 Vcc, being discharged through R = R2. That is,
1/3 * V_{cc} = 2/3 * V_{cc} * e^{\frac{-t_{off}}{R*C}},
which on simplifying gives:
t_{off} = R * C * ln(2) = R2 * C * 0.6931 … (2)

Live Demo

Pugs doesn’t get a punch unless he sees the theory working in practice. That’s where, he sets up the above circuitry on a breadboard as shown in the figure below:

WARNING: Do NOT put the pot to a value of zero, as that will short Vcc & GND, and may blow off the circuit. A safety workaround could be to put a fixed 1K resistor in series with the pot.

Square Wave using 555 (Breadboard)

Square Wave using 555 (Breadboard)

The audio jack is being used for observing the waveforms on the home-made PC oscilloscope, as created in his previous PC Oscilloscope article.

Below are the three waveforms Pugs observed for the values of R1 being adjusted to 1.28KΩ, 4.2KΩ, 8.6KΩ:

R1 = 1.28K, R2 = 4.3K

R1 = 1.28K, R2 = 4.3K

R1 = 4.15K, R2 = 4.3K

R1 = 4.15K, R2 = 4.3K

R1 = 8.60K, R2 = 4.3K

R1 = 8.60K, R2 = 4.3K

From the waveforms, Pugs approximately have the following t_on & t_off:
R1 = 1.28KΩ => t_on = 3.8ms, t_off = 3.0ms
R1 = 4.15KΩ => t_on = 6.0ms, t_off = 3.0ms
R1 = 8.60KΩ => t_on = 9.0ms, t_off = 3.0ms

Now, as per equations (1) & (2), for C = 1μF, R2 = 4.7K, and the above three R1 values, we should have got the following:
R1 = 1.28KΩ => t_on = 4.1ms, t_off = 3.3ms
R1 = 4.15KΩ => t_on = 6.1ms, t_off = 3.3ms
R1 = 8.60KΩ => t_on = 9.2ms, t_off = 3.3ms

Pretty close, but the t_off not really satisfactory. That triggered Pugs to take out his multimeter and check the resistance of the fixed resistor R2, he used. Ow! that actually measured 4.3K. Recomputing using R2 = 4.3K, gave values amazingly close to the observed values.

Summary

Thus by appropriately choosing the R1, R2, and C values one should be able to get a square wave of a desired frequency given by 1 / (t_on + t_off) and duty cycle given by t_on / (t_on + t_off). Obviously, the frequency would have a practical upper limit dictated by the 555 IC, though it is typically in MHz. What about duty cycle? Note that as per relations (1) & (2), t_on will be always greater than t_off. Thus, duty cycle would be always greater than 0.5.

So, what if we need duty cycle less than 0.5, or at least equal to 0.5, where t_on = t_off. This is what Pugs is working out on. Watch out for the next article.

Next Article >>

   Send article as PDF