Jan 6, 2020

Debugging a 555 Circuit

While building a 555 astable timer circuit, I noticed that the value of a seemingly unrelated resistor was actually of crucial importance to the overall functionality. Using simple circuit analysis and simulation, I got to the bottom of why exactly this resistor matters: it controls the asymptotic behavior of a timing capacitor.

Table of Contents

The Setup

I bought some 555 timers and figured I would make an LED blink. I decided a frequency of $2\text{ Hz}$ was a good target. I wanted a duty cycle of $50\%$ because to me that’s most visually appealing.

According to this tutorial, all I needed to do was build this circuit:

555 50% duty cycle oscillator circuit

Reference: Electronics Tutorials

To get any particular frequency $f$, I simply needed to utilize the formula

$$ f=\frac{1}{0.693(2R_2)C_1}\,\text{ Hz} $$

Using my impeccable algebra skills, I figured out that to get a $2 \text{ Hz}$ wave I needed

$$ R_2C_1 \approx 0.360$$

I looked through my electronics parts to see what values capacitors and resistors I had:

available resistor values
available capacitor values

Can you spot the manufacturer’s typo in the capacitor values?

Just from eyeballing it, a $330\text{ nF}$ capacitor and a $1\text{ MΩ}$ resistor would do the trick. In fact, if we plug in those values, we get $f \approx 2.186\text{ Hz}$. Good enough!

For $C_2$, I didn’t have a $0.01\text{ µF}$ capacitor, but I did have a $0.1\text{ µF}$ capacitor. Since $C_2$ is just there to stabilize the voltage on the CONTROL pin, that was also good enough.

The question now was what to do about $R_1$. How big or small should it be? The tutorial doesn’t say much:

Note that resistor R1 needs to be sufficiently high enough to ensure it does not interfere with the charging of the capacitor to produce the required 50% duty cycle

Is $100\text{ kΩ}$ “sufficiently high enough?” It seemed pretty big to me, and I mean that’s what the picture used anyways. I went ahead built the circuit to test it out:

555 astable circuit using 100 kilo ohms for R1

I powered it up, but whenever I turned the circuit on, the LED would flash briefly and then never turn on again. This would happen every time I connected the circuit to power:

Demonstration of 555 astable circuit using 100 kilo ohms for R1

I mean, I guess I could create a $2\text{ Hz}$ wave by just plugging and unplugging the power manually

I double- and triple-checked the wiring, but couldn’t find anything wrong :(

I figured just mindlessly quadruple-checking was gonna be useless. It was time for some good ol' circuit analysis!

Background Reading

In case you’re unfamiliar with the astable oscillator configuration of the 555, this is a pretty good video to watch. The relevant part starts at 6:54. The circuit the person goes through is slightly different than the one I’m using, but it’s close enough to get the point of how the 555 works.

Debugging the Circuit

Unfortunately, I didn’t have an oscilloscope lying around (on account of them being expensive), so I settled for simulation using LTSpice (which is free).

In LTSpice I created the schematic for my circuit:

Schematic of 555 astable circuit using 100 kilo ohms for R1

I then simulated it and got the following results. The blue line is the voltage at the OUT pin and the green line is the voltage across the capacitor, i.e. the voltage at the THRESHOLD pin.

Simulation of 555 astable circuit using 100 kilo ohms for R1

The OUT pin goes high for just a bit then turns off, never to turn on again

After close inspection, I was curious as to why the capacitor topped out at $4.5\text{ V}$. After all, it’s connected to the $5\text{ V}$ supply, so it should asymptotically approach $5\text{ V}$ right?

The trick was to think of the circuit like this:

Circuit redrawn to put focus on C1

I like to hand draw my circuit diagrams ‘cause I think it adds a certain charm

If there’s one thing my undergrad degree taught me, it’s recognizing voltage dividers, and boy howdy, $R_1$ and $R_2$ sure look like one! From there it was fairly straightforward to see what the issue was:

1$C_1$ starts out discharged and so the THRESHOLD pin is low. This causes OUT to start out high.

2$C_1$ charges up through both resistors.

C1 charging up through R1 and R2

3$C_1$ evenutally brings THRESHOLD up to ${2}/{3}\,V_{CC}$, and so the OUT pin goes low.

4OUT now acts as a ground, so $R_1$ and $R_2$ form a voltage divider. Since $C_1$ is connected to the output of the voltage divider, it will charge up to the value of the divider.

R1 and R2 forming a voltage divider that determines what voltage C1 charges to

We can easily calculate what the steady-state voltage of $C_1$ will be:

$$ \left(\frac{R_2}{R_1+R_2}\right) V_{CC}$$ $$ = \left(\frac{10^6Ω}{10^3Ω+10^6Ω}\right)\left(5\text{ V}\right)$$ $$\approx 4.545 \text{ V}$$

That explains why $C_1$ stabilizes at roughly $4.5\text{ V}$

5Now nothing will change. In order for the OUT pin to toggle, the THRESHOLD pin needs to reach ${1}/{3}\,V_{CC}$. Unfortunately, the voltage divider keeps $C_1$ at $4.5\text{ V}$.

A First Attempt at a Fix

Ok, so we just need to pick a value of $R_1$ such that $C_1$ stabilizes at a voltage below ${1}/{3}\,V_{CC}$. Mathematically, this means we need

$$ \left(\frac{R_2}{R_1+R_2}\right) V_{CC} < \frac{1}{3}\,V_{CC} $$

A little bit of algebra gives us our constraint: in order for the circuit to oscillate, we need $R_1>2\,R_2 $

Since in our circuit $R_2=1\text{ MΩ}$, a nice choice for $R_1$ would be $3\text{ MΩ}$. I used this new value of $R_1$ in my circuit and tested it out:

Demonstration of 555 astable circuit using 3 mega ohms for R1

The duty cycle doesn’t seem quite right…

Eh… I mean it’s a $2\text{-ish Hz}$ wave (I checked by timing it with a stopwatch), but the pulsing doesn’t look symmetric…

To confirm my suspicion, I simulated the circuit with $R_1=3\text{ MΩ}$ and got the following graph:

Simulation of 555 astable circuit using 3 mega ohms for R1

Simulation shows the capacitor waveform (green) is asymmetric

Well, that most certainly is not a $50\%$ duty cycle! It seems that $C_1$ spends more time discharging than it does charging…

Why Is Charging Quicker Than Discharging?

By the laws of physics, a capacitor charges/discharges up to its target voltage asymptotically. So not only will the capacitor voltage never quite reach the target voltage, but it will actually charge/discharge slower the closer it gets.

Thus if the asymptote is just past the cutoff voltage, the capacitor will start to slow down its charging/discharging as it approaches the cutoff. Of course, since the cutoff is before the asymptote, it is guaranteed to reach the cutoff; it just will take a relatively longer time.

On the other hand, if the asymptote were way past the cutoff, the capacitor would reach the cutoff pretty quickly. This is because as the capacitor voltage approaches the cutoff, it’s still quite far from the asymptote, so it slows down negligibly.

Let’s see this visually! We’ll take a capacitor that is charging from $1\text{ V}\rightarrow 6\text{ V}$ but is cut off at $2\text{ V}$, meaning there is a gap of a whopping $4\text{ V}$. We’ll also take a separate capacitor that is discharging from $2\text{ V}\rightarrow 0.97\text{ V}$ but is cut off at $1\text{ V}$, meaning there is a gap of merely $0.03\text{ V}$. We’ll start both capacitors at $t=0$.

I’ve put time on the x-axis and voltage on the y-axis. The green curve represents the charging while the blue curve represents the discharging. The orange dotted lines indicate the asymptotes while the black lines indicate the cutoffs. The little X’s show where the capacitors hit their cutoffs.

Graph showing the asymmetry between the charging and discharging phases

A visual example of how target voltage placement can affect the duration of charging/discharging.
You can play with it yourself here (hopefully that link doesn’t break…)

From the graph it’s pretty easy to see why green “wins”. The asymptote is so far from the cutoff that the charging basically plows straight through the cutoff. On the other hand, the asymptote for blue is right under the cutoff, so it heavily slows down as it approaches the cutoff, making discharging take its sweet time.


IMPORTANT NOTE: If you’re going to look at the gaps between the cutoffs and the asymptotes to see who wins, it’s important that the gaps between the starting voltages and the cutoffs be the same!

In the case of the previous graph, the gaps between the starting voltages and the cutoffs were both $1\text{ V}$, so we’re good there.


Let’s crunch some numbers to get a sense of how our circuit fares.

First up, how big is the gap between the charging asymptote and the high cutoff voltage? The high cutoff voltage is ${2}/{3}\,V_{CC}$, and the capacitor is trying to charge up to $V_{CC}$. So the gap is ${1}/{3}\,V_{CC}\approx 1.67\text{ V}$

Up next, how big is the gap between the discharging asymptote and the low cutoff voltage? The low cutoff voltage is ${1}/{3}\,V_{CC}$. The voltage that the capacitor is trying to discharge down to is given by

$$ \left(\frac{R_2}{R_1+R_2}\right) V_{CC} $$ $$ = \left(\frac{1\text{ MΩ}}{3\text{ MΩ}+1\text{ MΩ}}\right) V_{CC} $$ $$ = \frac{1}{4}\,V_{CC} $$

Thus, the gap is ${1}/{12}\,V_{CC}\approx 0.42\text{ V}$

Since the gap between charging asymptote and the high cutoff voltage is bigger than the gap between the discharging asymptote and the low cutoff voltage, charging is faster.

Note that the gaps between the starting voltages and the cutoffs are both ${1}/{3}\,V_{CC}$, so this comparison/conclusion is valid.

The Fix

The obvious solution is to move the discharge asymptote to be as close to $0\text{ V}$ as we can. That way the gap between the low cutoff voltage and the discharge asymptote will also be ${1}/{3}\,V_{CC}$.

The discharge asymptote is given by the voltage divider mentioned just a bit ago. To make the formula go to $0\text{ V}$, we can have $R_1$ go to $\infty\text{ Ω}$.

Of course, $\infty\text{ Ω}$ is not a resistor value that I have in my box. But all that means is that we just take $R_1$ out of the circuit!

Here’s a simulation of what would happen if we did such a dastardly thing!

Simulation of circuit with R1 removed

Simulation of circuit with $R_1$ removed

What a nice waveform! ❤️

Conclusion

The Electronics Tutorial article gave this advice for choosing $R_1$:

Note that resistor R1 needs to be sufficiently high enough to ensure it does not interfere with the charging of the capacitor to produce the required 50% duty cycle

Now we know what “sufficiently high enough” means: so big it’s basically not there! :)