Electronics Intermediate: Power, Transistors, Op-Amps and Logic
Digital Logic and the 555 Timer
In this lesson you will
- Read truth tables for AND, OR and NOT gates
- Use pull-up and pull-down resistors with switches
- Calculate the output of a 555 timer in astable and monostable modes
Introduction
Analogue circuits deal with smoothly varying voltages. Digital circuits use just two levels: low (0) and high (1). This makes them robust against noise, and lets us build computers. This lesson covers the basics, and a classic chip for making timing signals.
Binary and logic levels
A digital signal is high (close to the supply voltage, such as 5 V or 3.3 V) or low (close to 0 V). We call them 1 and 0. Binary numbers use only 0 and 1: counting goes 0, 1, 10, 11, 100... Four bits can represent 16 values, and eight bits 256.
Different chip families use different voltages, and the logic levels must match. Connecting a 5 V output to a 3.3 V input can damage it, so check the datasheet and use level shifting when needed.
Logic gates
A gate combines inputs to produce an output according to a truth table.
The three basic gates. AND needs both inputs high, OR needs either, NOT flips the input.
- AND: output is 1 only if both inputs are 1.
- OR: output is 1 if either input is 1.
- NOT (inverter): output is the opposite of the input.
Others are combinations: NAND is AND followed by NOT, NOR is OR followed by NOT, and XOR (exclusive OR) outputs 1 when the inputs are different. NAND gates alone can build any logic function, which is why they are called universal.
Quick quiz
For a two-input OR gate, which input combination gives an output of 0?
Gates combine to make adders, memories, counters and processors.
Handling inputs: pull-ups and pull-downs
An input connected to nothing floats and picks up noise, giving random results. For a push button, use a pull-up or pull-down resistor, typically around 10 kΩ:
- Pull-down: the resistor holds the input at 0 V, and pressing the button connects it to the supply, making it 1.
- Pull-up: the resistor holds the input at the supply (1), and the button connects it to ground, making it 0.
Mechanical switches also bounce, making several quick on-off changes in a few milliseconds. Handle it with a small capacitor, a debounce circuit or software delays.
The 555 timer
The 555 is a cheap, classic chip that makes timing pulses with just a few resistors and capacitors. It is still widely used. Two main modes:
Astable: a free-running oscillator
It produces a continuous square wave, for flashing LEDs or tones. With resistors R1 and R2 and capacitor C:
Frequency f = 1.44 ÷ ((R1 + 2 × R2) × C)
Duty cycle = (R1 + R2) ÷ (R1 + 2 × R2)Example: R1 = 1 kΩ, R2 = 10 kΩ, C = 10 µF.
R1 + 2×R2 = 21 kΩ
f = 1.44 ÷ (21,000 × 0.00001) = 1.44 ÷ 0.21 ≈ 6.9 Hz
Duty = 11 ÷ 21 ≈ 52 percentSo an LED on the output blinks about seven times a second.
Monostable: a one-shot timer
A trigger makes the output go high for a set time, then return low:
Pulse length T = 1.1 × R × CWith R = 100 kΩ and C = 10 µF, T = 1.1 × 100,000 × 0.00001 = 1.1 seconds. Uses: a timed light, debounce or a delay.
Practical tips: put a 100 nF capacitor across the supply close to the chip, follow the pinout in the datasheet, and note that the real timing depends on component tolerances, so capacitors with poor tolerance (such as many electrolytics) make it less precise.
From here
Digital designs now usually use microcontrollers, small computers on a chip, which you will meet in the advanced course. The ideas of logic levels, pull-ups, debouncing and timing still apply.
Try it yourself
Design a 555 astable flasher that blinks about once per second. One option: R1 = 1 kΩ, R2 = 68 kΩ and C = 10 µF gives about 1.0 Hz. Check the calculation, and draw the circuit from the datasheet.
Summary
- Digital signals are high or low, and gates such as AND, OR and NOT combine them according to truth tables.
- Use pull-up or pull-down resistors for inputs, and handle switch bounce.
- A 555 timer makes oscillators (f = 1.44 ÷ ((R1 + 2R2)C)) and one-shot pulses (T = 1.1RC).
Lesson complete
+20 XP
Nice work. Keep going while it is fresh.
Sources and further reading