PhysicsElectronics › Digital signal processing

Digital signal processing

Send a voltage a hundred miles and noise ruins it on the way. Send the same information as ones and zeros and a repeater partway along can rebuild it at its original levels. Logic gates then combine to add or compare binary inputs, and flip-flops store one bit so a circuit can count.

Builds on Operational amplifiers and Summing and difference amplifiers.

IN THIS TOPIC

  • Explain why digital signals resist noise, and what regeneration does that amplification cannot.
  • Write the truth table of each of the six gates without hesitation.
  • Turn a Boolean expression, or a specification in words, into a gate circuit, the half-adder included.
  • Describe the D-type flip-flop as a one-bit memory, and use counters that halve the frequency at every stage.
  • Reset a chain early to count modulo n, and tell BCD, up/down and Johnson counters apart.
  • Read the pulse width, frequency, mark-to-space ratio and duty cycle off an astable's output.

COMMON MISCONCEPTION

Digital signals survive long distances because they are transmitted at higher power.

Why two levels resist noise

An analogue signal carries its information in its exact shape, and that is its weakness. Every metre of cable adds a little random noise, and once noise is mixed in no circuit can tell it from signal. Amplifying a tired analogue signal amplifies the noise with it, so each leg of a long link leaves the signal permanently worse.

A digital signal gives up the shape entirely. Only two levels mean anything, logic 0 near 0 V and logic 1 near the supply voltage, and the receiver makes one crude test, above the threshold or below it? Noise that would wreck an analogue waveform leaves a 1 still recognisably a 1. There is a genuine margin for error, and small noise sits inside it.

Regeneration: a noisy, sagging digital signal is read against a threshold and reissued at full height, so the original bits survive and the noise is discardedsent10110100receivedthreshold: above it read 1, below it read 0regenerated10110100the same eight bits come out
FIG. 1A clean digital signal, the same signal noisy and sagging after a long cable, and the regenerated result. Every noisy sample still falls on the correct side of the threshold, so the rebuilt signal is identical to the original, and the accumulated noise is simply thrown away.

Better still, a digital signal can be regenerated. A repeater partway along the route reads each incoming pulse as 0 or 1, then issues a brand-new, full-height pulse at the nominal levels. It does not amplify the old signal, it replaces it, and the noise collected so far is discarded. While every sample still falls on the correct side of the threshold the message crosses a continent unchanged; let noise or timing error reach the decision margin first and bits get misread, which is why repeaters are spaced to stay well inside it. Transmitted power is beside the point, and digital links usually use less of it.

The six gates

The circuits that act on logic levels are gates. A gate's output depends only on its present inputs, so the whole behaviour fits in a truth table, one row per input combination. The simplest is NOT, one input, one output, always the opposite: input 0 gives 1, input 1 gives 0. The remaining five take two inputs, so their tables have four rows:

ABANDORNANDNOREOR
0000110
0101101
1001101
1111000

Three of these are worth learning as sentences. AND outputs 1 only when both inputs are 1. OR outputs 1 when at least one input is 1. EOR, exclusive-OR, outputs 1 when the inputs differ, and that last row is the one that separates it from OR. NAND and NOR are simply AND and OR with the answer inverted, drawn with a small circle on the output, and each of them alone can be wired up to build every other gate.

Combinational design is reading Boolean sentences in both directions. A specification in words becomes an expression, the expression becomes gates. The habit worth building is to write the full truth table, every input combination in binary counting order, because it brings out the cases you did not think about.

WORKED EXAMPLE

Reading a Boolean sentence

A machine may run (Q = 1) only when the guard is closed (G = 1) and either the two-hand switch is pressed (T = 1) or a supervisor override is on (S = 1). Write the expression, name the gates, and evaluate Q for G = 1, T = 0, S = 1.

The sentence translates directly: Q = G AND (T OR S). One OR gate feeds one AND gate.

With T = 0 and S = 1 the OR gives 1; with G = 1 the AND gives Q = 1, and the machine may run.

Check the effect of the guard input in the table. Whenever G = 0 the AND cannot output 1, whatever the other switches are set to. The expression enforces the safety rule structurally.

The half-adder

Binary arithmetic in one column is small enough to build by inspection. Adding bits A and B gives 0 + 0 = 0, 0 + 1 = 1, 1 + 0 = 1, and 1 + 1 = 10, which is the number two, written as sum 0 carry 1. Now stare at the two output columns. The sum is 1 exactly when the inputs differ, and the carry is 1 exactly when both inputs are 1. Those are tables you already know.

The half-adder: an EOR gate gives the sum bit and an AND gate gives the carry bit from the same two inputsABEORANDSCABSC0000011010101101sum = A EOR Bcarry = A AND B1 + 1 = 10: sum 0, carry 1
FIG. 2The half-adder. Inputs A and B fan out to two gates in parallel, an EOR producing the sum bit and an AND producing the carry bit, and together the outputs spell the two-bit answer to A plus B.

So a half-adder is one EOR gate for the sum and one AND gate for the carry, wired to the same pair of inputs. It is the standard exam example of combinational design, a truth table recognised as a pair of known gates. Chain half-adders with provision for an incoming carry and you have the adder at the heart of every processor.

GUIDED PRACTICE

One plus one, in gates

Trace the half-adder for A = 1, B = 1, then for A = 1, B = 0, and read each result as a binary number.

Show the working

A = 1, B = 1: the inputs match, so EOR gives S = 0; both are 1, so AND gives C = 1. Read carry then sum, the answer is 10, the number two.

A = 1, B = 0: the inputs differ, so S = 1; AND gives C = 0. The answer is 01, the number one.

Both agree with ordinary arithmetic. The gate pair performs binary addition in one column, rather than imitating it.

Memory, and counting by halving

Gates have no memory; release a switch and the output reverts immediately. Sequential circuits add the missing ingredient with the D-type flip-flop, a one-bit memory. It has a data input D, a clock input, and an output Q. On each rising clock edge it copies whatever is on D to Q, then holds Q frozen until the next edge, ignoring D completely in between. Registers and other small fast storage are rows of these, one per bit; bulk memory uses denser cells instead, a capacitor per bit in DRAM and charge-trapping transistors in flash.

One wiring trick turns storage into rhythm. Connect the flip-flop's inverted output back to its own D input and every clock edge loads the opposite of what Q held, so Q toggles at each edge. Two clock cycles pass before Q completes one full cycle of its own, so Q runs at half the clock frequency, a clean square wave. Feed that stage's inverted output onward as the clock of a second stage and the halving repeats. For n stages,

fout=fin2nf_{out} = \frac{f_{in}}{2^{n}}NOT ON THE AQA DATA SHEET: LEARN IT
Two toggling flip-flop stages: each output completes one cycle for every two of its clock, so the frequency is halved and halved again÷ 2÷ 24096 Hz2048 Hz1024 Hzstage 1stage 2clockQ₁Q₂ff/2f/4two stages: 4096 Hz becomes 1024 Hz, that is f divided by 2²
FIG. 3A clock and two toggling flip-flop stages. The first output changes state at every clock cycle's end, completing one cycle for every two of the clock; the second halves the frequency again, to a quarter of the original.

Read all the Q outputs at once, last stage first, and the same chain is a binary counter. The outputs step through 00, 01, 10, 11 and onward, one count per clock pulse, rolling over after 2n2^{n} states. Counting and frequency division are the same circuit described two ways.

WORKED EXAMPLE

The watch that counts out one second

A quartz watch crystal oscillates at 32 768 Hz. How many toggling stages does the watch need to derive its once-per-second tick?

32 768 is 2152^{15}, so each of 15 halvings takes the frequency down one power of two, ending at exactly 1 Hz.

That number is designed backwards. Crystal makers chose 32 768 Hz precisely because a whole number of halvings lands on one second.

INDEPENDENT PRACTICE

Designing the divider

A timing circuit is clocked at 4096 Hz and must drive a display at 16 Hz. How many flip-flop stages are needed, and how many distinct states does that chain pass through as a counter?

Show the working

The division needed is 4096/16 = 256 = 282^{8}, so 8 stages.

An 8-stage counter runs through 282^{8} = 256 states, 0 to 255, before repeating.

Keep the two answers apart. Frequency out is f/2nf/2^{n}, states counted is 2n2^{n}. Swapping them is the standard slip.

Counters that stop where you want them to

A plain chain always runs to 2n2^{n} and rolls over, and that is rarely the number anybody wants. Wire the outputs that are high at the unwanted count into a NAND gate, and take its output to the reset input of every stage. The instant that count appears the gate clears the whole chain, so the count never persists there and the chain starts again from zero instead. Detect ten, 1010, and the chain counts 0000 up to 1001 and resets: a modulo-10, or decade, counter. Any modulus is available by choosing which outputs feed the gate.

The decade is the useful one, because a decimal digit has exactly ten states. Four bits holding 0000 to 1001 and nothing above is binary-coded decimal, and a BCD counter is a decade counter read as one decimal digit. Cascade them, the last output of each decade clocking the next, and the units decade rolls over once per ten pulses while the tens decade rolls over once per hundred, so four of them drive a display reading 0 to 9999 with no arithmetic in between. A frequency meter is that row of BCD counters behind a gate that lets pulses through for exactly one second.

Counting backwards needs one extra connection per stage. Each flip-flop copies D on a rising edge, so a stage clocked from the previous stage's inverted output steps the count up, and the same stage clocked from Q instead steps it down. An up/down counter brings both routes to a pair of gates in every stage and lets a single direction input choose between them, which is what a lift controller requires when it has to track how many floors are left in either direction.

A Johnson counter gives up the ripple altogether. Put n flip-flops in a row, all clocked together, each output feeding the next one's D input so that a pattern shifts one place along the row per pulse, and then bring the last stage's inverted output back to the first stage's D. From 0000 the row fills with ones from the left, 1000, 1100, 1110, 1111, and the inverted feedback then fills it with zeros the same way, 0111, 0011, 0001, 0000. Four stages therefore cycle through eight states rather than sixteen, and n stages through 2n.

Two of those states are worth the waste. Only one output changes at each step, so the outputs never pass through a wrong combination on their way to the right one as a ripple chain does, and any single state can be recognised by a two-input gate rather than an n-input one. Where a ripple counter is asked only for a number, a Johnson counter is asked for clean, glitch-free timing signals in a fixed order.

GUIDED PRACTICE

Choosing the chain

A circuit must count from 0 to 11 and repeat. How many flip-flops does it need, and which count must the reset gate detect? Then state how many states a 5-stage Johnson counter passes through.

Show the working

Twelve states need at least twelve, and 232^{3} = 8 is too few, so 4 flip-flops, which offer sixteen.

The chain must be cleared as soon as it reaches twelve, so the gate detects 1100, watching the 8s and 4s outputs. The counter then shows 0000 to 1011, which is 0 to 11.

A Johnson counter gives 2n states, so five stages give 10 states, not 252^{5} = 32.

Count the states, not the top number. A modulo-12 counter reaches 11, and reading the reset count as the highest count displayed is the standard slip.

The astable, which supplies the clock

Every counter above waits on a clock, and something has to make one. A comparator will, once it is given a memory of its own. Feed a fraction of the output back to the non-inverting input, which is positive feedback, and the circuit holds whichever rail it has reached until the other input is dragged past the threshold that fraction sets. Now charge a capacitor towards the output through a resistor and take the inverting input from it. The capacitor climbs, crosses the upper threshold, and the output flips; it then falls towards the other rail, crosses the lower threshold, and the output flips back. Neither state is stable, so it never stops. That is an astable.

All the timing lives in the charging. Each interval lasts a fixed multiple of the RC of whichever path is charging the capacitor during it, the multiple set by where the thresholds sit, so doubling that resistance doubles that interval and touches nothing else. Give the two directions separate paths, a pair of resistors each with a diode that lets current through one way only, and the high time and the low time become independent of each other.

Three numbers describe the output, and questions ask for them by name. The pulse width is the length of the high part on its own, t1t_{1}. The period is t1+t2t_{1} + t_{2} and the frequency is its reciprocal. The mark-to-space ratio is the high time divided by the low time, t1/t2t_{1}/t_{2}, quoted as a ratio. The duty cycle is the high time as a fraction of the whole period, t1/(t1+t2)t_{1}/(t_{1} + t_{2}), quoted as a percentage. Equal intervals give a square wave, mark-to-space 1:1 at a duty cycle of 50%.

WORKED EXAMPLE

Reading an astable's output

An astable's output is high for 1.5 ms and low for 0.50 ms. Give the pulse width, the frequency, the mark-to-space ratio and the duty cycle. The resistance in the path that sets the low time is then doubled: give the new duty cycle and frequency.

The pulse width is the high time alone, 1.5 ms. The period is 1.5 + 0.50 = 2.0 ms, so f = 1/(2.0 × 10−3) = 500 Hz.

Mark-to-space = 1.5/0.50 = 3.0, written 3:1. Duty cycle = 1.5/2.0 = 0.75, or 75%.

Doubling that resistance doubles the low time to 1.0 ms, so the period becomes 2.5 ms. Duty cycle = 1.5/2.5 = 60% and f = 1/(2.5 × 10−3) = 400 Hz.

Changing one interval changes the frequency as well as the ratio. Only altering both paths together keeps the frequency where it was.

A counter responds to any of those settings, since it acts on an edge, provided the pulse stays wide enough and its edges sharp enough to meet the counter's own timing requirements; make a pulse too narrow or too slow-edged and even an edge-triggered input misses it.

For a load switched by a MOSFET the duty cycle is what matters. The duty cycle is the fraction of the time the channel is open, so it fixes the average power the load receives: modelling the lamp as a constant resistance, one fed at 20% duty from a 12 V supply is being given a fifth of the power it would take at 100% (a real filament's resistance shifts with temperature, so the proportion belongs to the model), while the switch itself stays cool because it is either fully on or fully off.

ASSESSMENT FOCUS

  • The regeneration argument is a contrast, so give both halves. An amplifier boosts signal and accumulated noise together; a regenerator reads each pulse as 0 or 1 and issues a new clean pulse, discarding the noise.
  • Write truth tables with the inputs counting in binary order, 00, 01, 10, 11. Examiners look for the complete table, and a missing row forfeits the mark.
  • EOR's definition is worth one crisp sentence, output 1 when the inputs differ. The row that catches people is 1, 1, where OR gives 1 and EOR gives 0.
  • Half-adder answers must name both gates and both outputs. Sum from EOR, carry from AND, one pair of shared inputs.
  • The D-type in one line: on the clock's rising edge it copies D to Q, and holds Q between edges. The qualitative description is what the mark scheme credits.
  • Counter arithmetic: frequency divides by 2n2^{n}, the number of states is 2n2^{n}. Decide which the question wants before reaching for the calculator.
  • A modulo-n counter is a chain plus a gate that spots n and resets it, so it displays 0 to n − 1. A decade counter is the modulo-10 case and one BCD digit. A Johnson counter of n stages has 2n states, not 2n2^{n}.
  • Astable numbers are three separate quantities. Pulse width is the high time by itself, mark-to-space is high over low, duty cycle is high over the period as a percentage. Write which one you are giving.

CHECK YOURSELF

A 3-stage binary counter is clocked at 96 Hz. Find the frequency at the final output, state how many distinct states the counter passes through, and give the EOR output for inputs 1 and 1. The astable supplying the clock is high for 3.0 ms and low for 7.4 ms: give its pulse width, mark-to-space ratio and duty cycle.

Show a hint

Each stage halves the frequency once. EOR asks whether the inputs differ. Keep the astable's three numbers apart.

Show the answer

Three halvings divide by 232^{3} = 8, so the final output runs at 96/8 = 12 Hz.

The counter passes through 232^{3} = 8 states, 000 up to 111, then rolls over.

The inputs match, so EOR outputs 0. That is the row that separates it from OR.

The pulse width is the high time alone, 3.0 ms, and the mark-to-space ratio is 3.0/7.4 = 0.41, or about 1:2.5.

The period is 3.0 + 7.4 = 10.4 ms, which checks against the 96 Hz clock, and the duty cycle is 3.0/10.4 = 29%.

A gate's output depends only on its present inputs; a flip-flop remembers one bit until the next clock edge.

EOR answers 1 when the inputs differ, and EOR with AND is the half-adder; NAND and NOR are AND and OR with the answer flipped.

Every toggling stage halves the frequency, so n stages divide by 2 to the n, and a gate that resets the chain early counts modulo n.

An astable's mark-to-space ratio is its high time over its low time; its duty cycle is its high time over the whole period.

WORKBOOK

Printable practice for this topic: original exam-style questions with room to work, and a fully worked answer book. Free to use; please do not redistribute or sell.

17 questions on this topicAnswer them one at a time and mark yourself against the mark scheme.Practise this topic

Or read them with their mark schemes on the digital signal processing questions page.

6 flashcards on this topicDefinitions, off-sheet equations and a spot-the-error card, scheduled by spaced repetition in your browser.Revise with flashcards

CHECK YOUR PROGRESS

Rate how confident you feel with each objective for this lesson. Ratings are saved in this browser, on this device, unless you sign in.

  • Explain why digital signals resist noise, and what regeneration does that amplification cannot.
  • Write the truth table of each of the six gates without hesitation.
  • Turn a Boolean expression, or a specification in words, into a gate circuit, the half-adder included.
  • Describe the D-type flip-flop as a one-bit memory, and use counters that halve the frequency at every stage.
  • Reset a chain early to count modulo n, and tell BCD, up/down and Johnson counters apart.
  • Read the pulse width, frequency, mark-to-space ratio and duty cycle off an astable's output.

Open the full revision checklist to track your progress across the whole unit.