Vous êtes sur la page 1sur 6

Constructional Project

Back to Basics CMOS


Logic Devices
Bart Trepak
Part 8 Noughts and Crosses Enigma and Weather Vane
Illustrates how useful circuits can be designed simply
using CMOS logic devices as the active components

MALL electronic games have


always been popular constructional
projects and no series featuring
CMOS i.c.s would be complete without
one! Whilst this Noughts & Crosses
Enigma game is simple enough to construct, it requires a good deal of logical
thinking as well as a good memory to win.
It is based on the familiar game of
Noughts and Crosses (a.k.a. Tic-Tac-Toe)
which is played on a 9-cell grid, but the
similarity ends here hence Enigma in
the name. Instead of taking turns to place
a O or X in each cell to form a winning
pattern, in this version the game is already
won, so to speak, and the players take
turns to try to guess what the winning
pattern was.
This makes paper and pencils unnecessary and greatly simplifies the electronics
as well as making the game much more
interesting. In its simple form, it is more
akin to a detective game, while in the
more complex version it has some of the
attributes of the wartime Enigma machine
which the German forces used to encode
secret messages, although it does not
require a computer, which the Allies
developed to decode Enigma!

Game Play
To start a game, a switch is pressed,
which selects at random one of the winning patterns (see Fig.8.1) although this
of course remains hidden from the players. The players now take turns to press
one of the nine switches (S1 to S9) and if
the switch pressed forms part of the hidden pattern, the relevant l.e.d. in the display will light. If it does not form part of
the pattern the l.e.d. will remain off. From
this information, a logically-thinking
player can deduce the hidden pattern. The
first player to guess this correctly is the
winner.
A simple-minded way of finding the
hidden pattern would be to press each button in turn and see which ones cause the
l.e.d.s to light and thus deduce the stored
pattern. A good player, however, can be
much cleverer than that.
There are only eight winning patterns and
these are labelled P1 through P8 in Fig.8.1.

Advanced Call

Fig.8.1. The eight winning patterns

To make the game more interesting,


a switch selects between standard play
and a more advanced version in which
the pattern changes cyclically, just as the
Enigma machine encoded each letter of
the alphabet into a different one each
time the letter was used in a message.
Here, each time a correct guess is made
and an l.e.d. lights, the circuit selects the
next pattern when the switch is released,
giving each player even more to
remember.
Thus, in the above example, if the l.e.d.
lights when S2 is pressed revealing that
the current hidden pattern is P3 or P6,
when the switch is released the hidden
pattern will become P4 or P7. The players must therefore also take this into
account when considering their next
move.

Thus pressing switch S2, for example, and


noting the result provides far more information than simply that this switch/l.e.d. is or
is not part of the hidden pattern. If the l.e.d.
lights, then the hidden pattern must be either
Row 1 or Column 2 (i.e. pattern P3 or P6)
Basic Operation
and all of the other patterns and their
The block diagram in Fig.8.2 shows
switches can be discounted.
what is involved in the design.
Similarly, if the l.e.d. lights when switch
A counter is used to store the randomS9 is pressed, patterns P2, P3, P5, P6 and
ly selected hidden pattern, which is genP7 can be ignored, while if it remains off,
erated by an oscillator that is switched on
then one of these
must be the hidden
pattern. In this way,
the player with the
most logical thought
process and best
memory (together
with a bit of luck)
can beat the opponent player.
When
players
think they have
guessed the pattern, they press the
three
switches
s i m u l t a n e o u s l y,
which should result
in the three l.e.d.s
lighting,
thus
revealing the pattern as correct. If
the guess is wrong,
the opponent gets
an extra turn. This
is the simple game!
Fig.8.2. Noughts and Crosses block diagram

Everyday Practical Electronics, November 2005

785

when the Play button is pressed. The


count reached when the oscillator is
switched off is decoded into one of eight
states, corresponding to the eight winning
patterns. These outputs are encoded to
drive nine l.e.d.s arranged in the familiar
grid pattern.
Each l.e.d. has a corresponding pushswitch associated with it (again arranged in
the grid pattern) so that pressing the switch
will light the l.e.d., provided that the l.e.d.
is one of those selected by the encoder.
In the advanced setting of the game a
simple switch debouncing circuit is activated, to prevent the pattern change being
triggered unexpectedly.

Completed Noughts
and Crosses Enigma board

Circuit Diagram
The simplicity of the block diagram is
matched by that of the Noughts and
Crosses Enigma circuit diagram in
Fig.8.3, except that it contains rather a lot
of diodes. IC1a forms a familiar gated
oscillator which is activated when Play
switch S10 is pressed, producing a series
of pulses which are fed to the clock input
of decade counter IC2, connected as a
divide-by-eight counter.

Depending on the instant when S10 is


released, one of the outputs of IC2 will
be high, defining one of the eight winning patterns. The high speed of the
oscillator, set by capacitor C1 and resistor R2, and the variable time for which
S10 is pressed ensure that the final state

of IC2 is essentially random and


unknown to the players.
The outputs are encoded by diodes D10
to D33 to produce nine outputs driving nine
l.e.d.s and switches arranged in a grid pattern. For example, l.e.d. D1 only lights
when winning pattern P1, P2 or P6 has been
selected by the counter, so diodes are connected to D1 from outputs Q0, Q1 and Q5.

COMPONENTS
Noughts and Crosses
Resistors
See
R1
100k
SHOP
R2
10k
TALK
R3
1M
page
R4
390
All 025W 5% carbon film
Capacitors
C1
10n ceramic
disc, 5mm pitch
C2
1 radial elect.
16V
Semiconductors
D1 to D9
red l.e.d. (9 off)
D10 to D33
1N4148 signal
diode (24 off)
TR1
2N3904 npn
transistor
IC1
4093 quad
Schmitt NAND
gate
IC2
4017 decade
counter
Miscellaneous
S1 to S10
min. push-tomake switch,
p.c.b. mounting
(10 off)
S11
min. s.p.s.t. toggle
switch (see text)
Printed circuit board, available
from the EPE PCB Service, code
538; 14-pin d.i.l. socket; 16-pin d.i.l.
socket; 9V PP3 battery and connector; connecting wire; solder, etc.

Approx.
Cost

16
excl case and batt

Fig.8.3. Completed circuit diagram for the Noughts and Crosses Enigma

786

Everyday Practical Electronics, November 2005

Each l.e.d. is also connected to a


switch so that an l.e.d. can light only if it
is selected by the encoder and the associated switch is pressed, thus enabling the
players to determine if a particular l.e.d.
is part of the hidden pattern.
Resistor R4 serves to limit the l.e.d.
current and is either connected to the 0V
supply via switch S11, or, in the
advanced version of the game, to the
base of transistor TR1. In this latter
case, if a switch is pressed and an l.e.d.
is lit, the transistor will switch on and its
collector voltage will fall, discharging
capacitor C2.
Consequently, any switch bounce will
not appear at this point because the relatively long time constant of C2/R3 will
prevent the collector voltage from rising
appreciably until the base current is
switched off when the switch is released.
The collector voltage is inverted by
IC1b which causes IC2s Enable input
to go high when TR1 is switched on,
and low again when it is switched off.
Since this input causes the counter to
advance when it goes low, the next
counter state is selected only when the
switch is released.
As with the other projects in this
series, this circuit is powered by a 9V battery. As the current consumption is very
low (except when a switch that results in
a l.e.d. switching on is pressed), no on/off
switch is included.

NOUGHTS & CROSSES ENIGMA CIRCUIT BOARD

Construction
Printed circuit board component and
track layout details are shown in Fig.8.4.
This board is available from the EPE
PCB Service, code 538.
Switches S1 to S9 and the l.e.d.s are
mounted in a 3 3 matrix pattern. Except
for the battery, all components are
mounted on the board. Ensure that polarity-sensitive components such as l.e.d.s,
diodes, i.c.s and electrolytic capacitor C2
are inserted correctly. The i.c.s are static
sensitive and the usual precautions
should be observed. Do not fit them in
their sockets until the board has been
fully checked.
As mentioned, the game can be played
in two versions. You can allow for both to
be played by using switch S11.
Alternatively, you could replace the
switch by a link wire (advanced version)
or omitting the connection (standard
version).

Testing
No adjustment or setting up is necessary and provided the circuit has been
correctly assembled, it will be ready
to play as soon as a battery has been
connected.
A simple way to determine if all of the
diodes have been correctly fitted and that
there are no faults is to set the unit for the
Advanced game and then press each
switch in turn until one l.e.d. is found to
light. Keeping this switch pressed, determine which winning pattern is active by
pressing two other switches until all three
l.e.d.s selected light. When these switches
have been released, the next pattern will be
selected and this may be confirmed by
pressing the relevant switches. In this way
all eight patterns can be checked.

Fig.8.4. Printed circuit board component layout and copper foil trackside master for
the Noughts and Crosses Enigma

Everyday Practical Electronics, November 2005

787

ELECTRONIC WEATHER VANE


I

T is always good to know which way


the wind is blowing, both in the figurative and the literal sense! While this
device can be of little help with the former, it will be of much more use with the
latter.
Weather vanes or wind direction indicators are traditionally ornate pieces of ironmongery, shaped as cockerels or other
livestock, placed on rooftops together with
arrows showing the four main points of
the compass (NESW).
Unfortunately, the roof and hence the
vane cannot normally be seen from within
the house so unless your neighbour is
thoughtful enough to place one on his roof
for your benefit, determining the wind
direction will normally involve going outside, whatever the weather.

Viewpoint
To get around this, some form of indicator mounted in a convenient place
indoors is useful. The simplest scheme for
such a device would consist of an 8-way
switch, to which the vane is attached,
feeding eight l.e.d.s which display the
position of the switch. A typical arrangement is shown in Fig.8.5.
To achieve this, a switch capable of
rotating through 360 degrees is required
and, although such switches are not generally available, it is a relatively simple matter to modify a standard 12-way rotary
switch to perform this function.
A bigger problem is the fact that a 9way cable is required to connect the
switch to the display and since the length
of this is likely to be considerable, the cost
of such a system would be quite high with
the cable costing more than the indicator.
This circuit allows a relatively inexpensive 2-way cable to be used instead and
could also be useful in many other signalling applications.

Basic Operation
The weather vane presented here consists of two units; an indoor Display and
a Wind Vane mounted on the roof. These
are shown in the block diagram in

Fig.8.6. The system basically consists of


two counters which are fed with clock
pulses via a common line. One counter,
together with the clock pulse generator
and display, is mounted indoors while
the other counter with an 8-way switch
attached to the weather vane is mounted
on the roof.
Both counters are initially reset and
since they are advanced by the same clock
signal, both counters keep in step. When
the output of the roof-mounted counter, to
which the weather vane switch is pointing,
goes high, a monostable is triggered, forcing the clock line low, inhibiting further
counting. The count reached at that
moment by the counter mounted indoors
is displayed by l.e.d.s, indicating the relative direction in which the weather vane is
pointing.

Time Out
When the monostable times out, the
counters clock terminal goes high again.
As long as no more clock pulses are
received, the Vane counter is reset, ensuring that it always starts with output Q0
high. The Display counter is reset independently at the beginning of each count
cycle (controlled by a separate oscillator)

so that it too starts with its Q0 output high,


thus ensuring that both counters remain in
step.
The low power requirements of CMOS
are exploited here to allow power for the
roof-mounted Vane to be supplied through
the same wire as the clock signal, allowing
a simple two-wire connection between the
two units. The positive supply for the Vane
is derived from the Display unit when the
clock line goes high. This is made possible
by ensuring that the clock terminal is
taken low for a very short time compared
to the time it spends in the high state.
This also means that the counting period is very much shorter than the display
period (when the clock line is high) so
that although some or even all of the
l.e.d.s in the Display unit may light in
turn, only the final one will be lit for long
enough to be visible. To save battery
power, the l.e.d. display is only enabled
when a switch is pressed.

Circuit Diagram
The circuit diagram for the Electronic
Weather Vane is shown in Fig.8.7. The
operation is best considered by assuming
that a transmission has just ended and
transistor TR1 has switched off. One of

Fig.8.6. Block diagram for the Electronic Weather Vane Repeater


Fig.8.5. Conventional weather vane repeater set-up

788

Everyday Practical Electronics, November 2005

the outputs of decade counter IC2 will be


high causing the corresponding l.e.d. (D1
to D8) to light if the Display switch S1 is
closed.
With TR1 off, capacitor C7 can charge
via resistor R6 and diode D11, thus providing the d.c. voltage to power the Vane
circuit. Capacitor C5 will also charge via
R7, thus resetting counter IC3, but this
will have no effect on IC2 or the l.e.d.
which is lit.

Master Oscillator
The master oscillator in the Display
circuit is built around IC1a and produces
a short positive pulse (about 10ms) every
few seconds or so defined by the time
constants set by the relationship between
capacitor C2, resistors R3 and R4, and
diode D9. When the output of IC1a goes
high, counter IC2 is reset via C1, and the
oscillator formed around IC1b is
enabled, providing clock signals to both
counters. Resistor R5 and capacitor C3
set the clocking rate.
The Enable input of counter IC2 is also
taken high via inverter IC1c so that counting can proceed. Diode D10 ensures that
the output of IC1b can only pull the clock
line low, while R6 pulls it high when the
output goes high.
As soon as the clock line goes low, C5
will discharged via D12, removing the
reset on counter IC3. The values of R7
and C5 are chosen to ensure that the
reset input of IC3 remains low during
the short positive periods of each clock
pulse, so that the i.c. is not reset and can
continue to count. Since the counters are
initially reset and they receive the same
clock pulses, both counters will advance
on the positive clock transition and will
therefore remain in step.
When the output of IC3, to which the
rotor or pole of switch S2 is connected,
goes high, transistor TR1 will be switched
on by the resulting pulse across C6,
grounding further clock pulses so that
counting stops even though IC1b will still
be oscillating.
When the output of IC1a goes low
again, clock oscillator IC1b switches off

Approx. Cost

COMPONENTS

14

excl cases and batts

Electronic Weather Vane


See
SHOP
TALK
Resistors
page
R1
56k
R2
1k
R3, R5
10k (2 off)
R4
1M
R6
1k8
R7
560k
R8
56k
All 025W 5% carbon film
Capacitors
C1
47p ceramic disc,
5mm pitch
C2
22 radial
elect. 16V
C3
10n ceramic disc,
5mm pitch
C4, C6, C7 47 radial
elect. 16V (3 off)
C5
100 ceramic disc,
5mm pitch

Semiconductors
D1 to D8
red l.e.d. (8 off)
D9 to D13
1N4148 signal
diode (5 off)
TR1
2N3904 npn
transistor
IC1
4093 quad NAND
gate
IC2, IC3
4017 CMOS
decade counter
(2off)
Miscellaneous
S1
min. push-to-make
switch, p.c.b.
mounting
S2
1-pole 12-way
rotary switch,
p.c.b. mounting
Printed circuit board, available from
the EPE PCB Service, code 539;
cases to suit (see text); 14-pin d.i.l.
socket; 16-pin d.i.l. socket (2 off);
9V PP3 battery and connector;
connecting wire; solder, etc.

and IC2s Enable input (pin13) goes


high, preventing any further advancement of the counter, which will therefore
continue to display the position of the
Vane switch S2.
Capacitor C6 will eventually charge
up, causing TR1 to switch off and allow
the clock line to go high. Since both
counters respond to the positive going
transition of the clock signal, this would
essentially form another clock pulse but
the count reached by IC2 will not
change as the Enable pin is now high.
The count of IC3 advances by one but
this does not matter as the counter will
be reset as soon as capacitor C5 charges
via resistor R7.
With TR1 off and IC3 reset, capacitor
C6 discharges via one of the outputs of

IC3 making the circuit ready for another


run. Meanwhile, IC2 will remain in its
final state, turning on the appropriate
l.e.d. when Display switch S1 is pressed,
until the output of IC1a again goes high
and the process is repeated.

Construction
Printed circuit board component and
track layout details are shown in Fig.8.8.
This board is available from the EPE PCB
Service. code 539. Cut the board into its
two sections as indicated.
All of the components including both
switches are mounted on the board
although S1 (Display switch) may need
to be mounted on the front panel of the
enclosure if one is used. In this case a
suitable panel mounted push switch

Fig.8.7. Complete circuit diagram for the Electronic Weather Vane

Everyday Practical Electronics, November 2005

789

Fig.8.8. Printed circuit board (p.c.b.) component layout, wiring details and full-size copper track master for the
Electronic Weather Vane. The p.c.b. is cut into two sections making up the Display and Vane boards see
below
connected to the
board on flying
leads would be more
appropriate.
The rest of the
electronics
construction should not
pose any problems
provided the normal
precautions
with device orientation and CMOS
handling
are
observed.

Display board

Vane Unit
As the Vane board will be mounted on
the roof and thus exposed to the elements,
some thought must be given to the box in
which it is to be mounted. This can range
from proprietary mast mounting boxes
specifically designed for such applications, to homemade equivalents such as an
empty tin.
Whatever is chosen it should obviously be weather resistant and waterproof
and, as an added precaution, the circuit
board can be given a few coats of varnish
or conformal spray (after it has been tested). Care should be taken to ensure that
the freedom of Vane switch S2 to rotate
is not impaired. Metal boxes should be
painted with suitable oil based paint.
Since no battery is required in the roof
mounted unit, the box may be permanently sealed leaving only the cable emerging.
Another alternative is to pot the entire circuit, or at least the areas where water may

790

penetrate, in mastic such as is used for


sealing around baths and sinks.

Vane Switch
The author was unable to source 8-way
360-degree rotary switches and so
instead an easily available 12-way unit
was used. These normally have an
adjustable end stop so that rotation can
be limited to the number of ways
required and this should be removed. The
permanent end stop at position 12, consisting of a protrusion in the moulded
plastic switch body, must be removed to
enable full 360 degree rotation.
Rotary switches also often have a
click action imposed by two ball bearings. These must also be removed to
enable the switch shaft to rotate freely.
Gently prize back the four retaining
lugs, taking care not to break them,
removing the spring, ball bearings and

Vane board
end stop, and snap the switch back
together again.
A suitable vane needs to be attached to
the shaft and this could be made from an
aluminium or plastic sheet but the details
of this are left to the taste and artistic
capabilities of the reader.
The two units should be interconnected
using a suitable length of twin cable.
Once the system is working there are no
adjustments to be made other than
mounting
switch
S2
and
the
l.e.d.s with
the same orientation so
that when the
vane points
north,
the
l.e.d. marked
N is lit.

Everyday Practical Electronics, November 2005

Vous aimerez peut-être aussi