next up previous contents index

[ENGN3213 Home]

Example - Pedestrian Crossing Controller

Figure 78 shows a single lane road with a pedestrian crossing. Road traffic and pedestrians are controlled by light signals. Pedestrians may request to cross the road by pressing a walk button W.


  
Figure 78: Pedestrian crossing.
\begin{figure}
\begin{center}
\epsfig{file=images/seqdesimg11.eps}\end{center}\end{figure}

The traffic lights are controlled by a synchronous state machine, with state diagram as shown in Figure 79.


  
Figure 79: Pedestrian crossing traffic light controller.
\begin{figure}
\begin{center}
\epsfig{file=images/seqdesimg12.eps}\end{center}\end{figure}

This is very much idealised. The system should go to the state corresponding to R, HALT on RESET or power up.

The next state/output table for the pedx controller is as follows:

Present state next state output
s0 s0 if $\overline{W}$, G, HALT
  else s1 if W  
s1 s2 Y, HALT
s2 s3 R, WALK
s3 s0 R, HALT

Let's do something different and use two falling edge triggered JK flip flops with active low preset and preclear as memory elements. Use AB as a pair of state variables to label the flip flops, with natural binary as our coding (in this example this turns out not to be the best choice, as we will see). We need to work out the next state and output logic, making use of the state transition table for the JK flip flop.

The binary version of the next state/output table is as follows:

Present state next state G Y R WALK HALT
00 00 if W=0, 1 0 0 0 1
  else 01 if W=1          
01 10 0 1 0 0 1
10 11 0 0 1 1 0
11 00 0 0 1 0 1

The k-maps for the Boolean functions JA, KA, JB, KB are shown in Figure 80.


  
Figure 80: Next state k-maps for pedx controller.
\begin{figure}
\begin{center}
\epsfig{file=images/seqdesimg13.eps}\end{center}\end{figure}

This gives:

\begin{displaymath}\begin{array}{rl}
J_A & = B \\
K_A & = B \\
J_B & = A + W \\
K_B & = 1
\end{array}\end{displaymath}

The k-maps for the output signals are shown in Figure 81.


  
Figure 81: Output k-maps for pedx controller.
\begin{figure}
\begin{center}
\epsfig{file=images/seqdesimg14.eps}\end{center}\end{figure}

This gives:

\begin{displaymath}\begin{array}{rl}
R & = A \\
Y & = \overline{A}. B \\
G & =...
... + B = \overline{WALK} \\
WALK & = A. \overline{B}
\end{array}\end{displaymath}

A circuit diagram of the pedx controller is given in Figure 82.


  
Figure 82: Circuit diagram for the pedx controller.
\begin{figure}
\begin{center}
\epsfig{file=images/seqdesimg15.eps}\end{center}\end{figure}

Some practical issues. Output race glitches may occur in the output signals, e.g. HALT. Consider the transition

\begin{displaymath}AB=11 \to AB=00
\end{displaymath}

which involves two flip flops changing state simultaneously, a race condition. See Figure 83.


  
Figure 83: K-map for HALT illustrating race condition.
\begin{figure}
\begin{center}
\epsfig{file=images/seqdesimg16.eps}\end{center}\end{figure}

   

Since we can't predict which path the machine will take, we may or may not get a glitch as the figure shows.

Exercise. Examine other outputs for possible glitches (either due to races, or hazards in the output logic).

Question? Will glitches cause problems?

This depends on what the signals are used for.

  How to avoid problems with glitches (if necessary).


next up previous contents index

[ENGN3213 Home]

ANU Engineering - ENGN3213