In my last few posts I’ve been writing about using an Arduino to generate waveforms. Part 3 of that series is still in the works (I’ve not forgotten, honestly!) – but this time I want to write about an alternative way to make a simple waveform: using good old analogue electronics, without the need for a microcontroller.
To do this we’ll use the ubiquitous NE555 timer chip (or just a 555 for short). The 555 is almost certainly the first IC you’ll play with if you’re learning analogue electronics at school or college – and for good reason, you can do all kinds of things with 555 timers – and whole books have been written on the subject. I’m not going to compete with any of those (Google, Amazon and Wikipedia will be your friends if you want to find out more). Or have a look at the datasheet…
Using a 555 to produce a square wave is a really nice easy circuit to have a go at if you’re new to electronics: as it’s not too complicated to build – and it’s pretty easy to understand what’s going on.
There are a handful of different basic ways to use a 555 – known as monostable, bistable, and astable. In a monostable configuration, the 555 will generate a single pulse (or a length determined by the configuration of the rest of the circuit), so it can be used, for example, as the basis of a simple electronic timer (such a circuit was my first ever electronics project – about twenty years ago!). In a bistable circuit, the 555 can be used as a latched flip-flop – turning on or off an output, depending on the state of two pulse inputs.
We’re interested in the astable configuration though – as that will let us generate a series of pulses in the form of our square wave.
Let’s start by looking at the circuit.
As you can see it’s a pretty simple circuit – with just the 555 IC, two resistors, and two capacitors. Additionally if we want to be able to vary the frequency, we can add a potentiometer (variable resistor) in series with R2, and to drive larger loads we can use a transistor switched by the output from pin 3 (as I’ve done here)…
So how does it work?
First of we need to understand an RC (resistor – capacitor) network. A capacitor charges and discharges at a rate proportional to the value of the resistance. This means that there’s an exponential relationship between the capacitor voltage and time… Specifically:
When the voltage on the timing capacitor (C1) reaches 2/3 of the supply voltage (Vcc) the 555 triggers the flip-flop (via pin 2) and the capacitor starts to discharge, when it drops to 1/3 Vcc, the flip-flop flips again, and starts the capacitor charging again. When C1 is charging the RC is dependant on both R1 and R2; when it’s discharging only R2 comes into play because of the connection to pin 7 between the two resistors.
Don’t worry if you don’t understand exactly how the 555 flip-flop works (it’s slightly out of the scope of this post – but maybe I’ll write something about that if people are interested): the important thing is the that the time taken to perform these charge / discharge cycles is what determines the frequency of the square wave generated.
Specifically the frequency is the reciprocal of the time taken for the circuit to go high + the time taken to go low…
So in our case the frequency should be:
And, sure enough – here’s what the oscilloscope gives us…