Digital Logic SystemsDavid N. Warren-Smith, MSc. South Australia |
The five relay problem
The first step in the solution is to draw up a table showing all possible states of the five relays as shown in Figure 2. Since there are 5 relays there are 25 or 32 possible states. The usual notation of representing an on state by a '1' and an off state by a '0' is used and the entries are arranged according to a Gray code. The relays are represented by letters of the alphabet and these are the state variables for this circuit. The second column of the table is actually a separate column for each relay. The entries for the second column are constructed from the logic equations for each relay. The convention is that the relay contacts are shown in their normally unenergised condition so that a logic true contact is shown with an open circuit and visa versa for a logic false contact (the logic true contact is closed when the variable is energised). For example, the equation for the 'A' relay is: A = E', (the prime after the letter for the variable ( ' ) represents the inverse of the variable or normally closed contact).
If you now consider what this table represents you will see that each entry on the right represents the excitation conditions for each of the relays given the instantaneous condition of the relays on the left hand side of the table. In other words the entries on the right are the next states of the relays from the states given by the entries on the left. Hence the table is called a State Table for the relay circuit since it shows all the states and next states for the circuit. This problem is an example of an unstable asynchronous sequential system or state machine. Starting with any entry in the table, the next state of the relays can be written down by simply reading off the entry in the right hand column adjacent to it. By going to that entry in the left hand column, one can then read off the next state after that and so on. On doing this one finds that there are sequences of states that form loops. The relays will execute the successive states in one or other of the loops. The more general situation is that a state table will have a number of stable states and some unstable states. A flip flop would have two stable states but circuits can be devised that have numerous stable states.
Summary
Simulation of the 5 relay puzzleIf you have access to a PLD design system such as the Altera MaxPlus II system you can demonstrate the behaviour of the relays with the simulator that is part of the system. I will show you the results (click on the underlined text for Figures 8 to 11 to see the results). Figure 7 is the circuit that has been used for the simulation. The multiplexer circuits are used to switch in the initial conditions for each loop. The simulator will of course allocate fixed delay values from its timing model so that the simulator will show continuous oscillations in each loop. Compare the successive values of the relays in Figures 8 to 11 with the values derived in Figures 3 to 6. A circuit constructed with real electromechanical relays will behave as described but I was interested to see how a circuit constructed with gate circuits would behave. So I programmed Figure 7 into my printed circuit board. I made provision for repetitive initialisation and followed the action on an oscilloscope. I had to provide additional buffering on output signals to prevent the oscilloscope leads from interfering with the experiment. I found that if the circuit was initialised in loops B or C the circuit quickly reverted to loop D. What I could see was that the asymmetry in the mark to space ratio in the waveforms produced in loops B or C resulted in a progressive shift in the phase of the waveforms until the circuit jumped into loop D. The waveforms in loop D are square waves. When I started the circuit in loop A, the circuit continued to run in this loop, without any sign of changing to another loop, throughout the time that I allowed before re-initialisation. The waveforms in this loop are also square waves but at a much higher frequency. This suggests to me that the delays in the interconnections in the EPM7128SLC device used in the printed circuit board have been very carefully equalised in the manufacturing process. The experiment made quite an impressive demonstration of this fact. Return to Intelligent logic OR Navigation menu at the top of the page OR continue with Exclusive-OR Logic:
(Copyright) David N. Warren-Smith, CPENG Digital Logic Systems, South Australia 21 September, 1998 |