Erlen Primer · all experiments

Electrical · Digital · Investigate

A traffic light with a state nobody drew

Its designer drew six states. What does this controller do in the two codes nobody drew, and what puts it right?

A traffic light with a state nobody drew: the bench

The bench

A traffic light controller on a breadboard, wired to a model junction: a red, a yellow and a green each way, north–south and east–west. Its designer drew six states: north–south green, yellow, all red, east–west green, yellow, all red, and round again. U1 and U2, two 74HC74s, hold the state in three D flip-flops, so eight codes are possible and six are used; the designer's sheet on the bench gives each state its code. Each next state and each lamp was minimised on a K-map, the two codes the sheet does not use left as don't-cares. U4, a 74HC161, counts the clock from a function generator, 1 to 10 Hz, and tells the flip-flops when the time is up: 8 ticks in a green, 2 in a yellow or an all red. A logic analyser watches the flip-flops and the timer from each switch-on, or from a code jammed in through the flip-flops' preset and clear pins. The supply is 5 V.

What you do

Controls

  • Supply output: Off or On
  • Timer clock: 0 to 3
  • Code to jam: 0 to 7

Buttons

  • Jam the code in
  • Record the capture
  • Sign it off for the street

Stockroom

  • Power-on reset: None, as built · 1 µF and 100 kΩ into a 74HC14, to every clear
  • The two codes nobody drew: Don't-cares, as built · Drawn in: red both ways, then an all red

Unknown

  • Controller: what it does in the codes nobody drew

Predictions

  • Three flip-flops hold eight codes and the sheet uses six. Switched on with nothing to reset them, they come up…
  • In a code the sheet never drew, the junction will show…

To work out

  • At the timer clock you have set, how long does the controller take to go once round its six drawn states? In seconds, three significant figures. (s)

To conclude

  • Switched on in a code nobody drew, this controller…
  • The lower of the two codes nobody drew goes next to…
  • The higher of the two codes nobody drew goes next to…

Results kept

  • The state table, as captured: Board, Clock, Code, Got there, North–south, East–west, Time in it (s), Next

What you find

  • Switched on, the flip-flops came up in a code the sheet never drew: nothing sets them anywhere, and three flip-flops hold eight codes whatever a design uses.
  • Every one of the eight codes now has a next state in your rows: the whole state diagram, the two codes nobody drew as well.

What is simplified

Switched on, each flip-flop of the state register and the timer comes up 0 or 1 at even odds, by seed: real ones lean one way or the other, part by part, and TI says only that the state before a clock edge is not defined. The logic is taken at each clock edge, with nothing in between: at 1 to 10 Hz the gates' nanoseconds of delay do not show. The power-on reset works at every switch-on, as if the supply had been off long enough for C1 to lose its charge; switched off and on quickly, a real one may not reset. A jammed code is set at once, and the generator's clock is perfect.

Topics

digital logic, finite state machine, state machine, traffic light controller, moore machine, state diagram, state table, state assignment, state encoding, gray code, johnson counter, karnaugh map, k-map, don't care, logic minimisation, unused states, self-starting, lock-up, power-on reset, flip-flop, d flip-flop, preset and clear, timer, counter, 74hc74, 74hc161, logic analyser, breadboard, troubleshooting, safety