This is only a preview of the December 1992 issue of Silicon Chip. You can view 54 of the 104 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Articles in this series:
Articles in this series:
Articles in this series:
Items relevant to "A 2kW 24VDC To 240VAC Sinewave Inverter; Pt.3":
|
Build the
NUMBER CRUNCHER
What can you do with 10 ICs, three
LEDs, two displays and a power
supply? You can build the Number
Cruncher! It chooses a 2-digit
number between O and 99, and you
have to guess what it is.
By GREIG SHERIDAN & DARREN YATES
Think of a number between 0 and 99, double it, add 10, take away
the number you first though of, divide it by 10 and what do you get?
Well, this project isn't quite that clever but it does automatically
select a 2-digit number between 1 and 99, stores it away, and then
lets you try to guess what it is. Each time you make a guess, it tells
you whether your guess is too high or too low. You then make
repeated attempts, all the time zeroing in until you finally guess
the correct number.
So what's the purpose behind it? Well, to be strictly honest,
there is no purpose except to teach and entertain! By building
the Number Cruncher, you'll learn a good deal about digital
electronics and how logic circuits work. And, when you've
finished, you'll have a useful game that will entertain the
family for hours.
There are just three pushbutton switch controls on the
Number Cruncher and these are arranged in a row along the bottom of the PC
board. The first (bottom left) increments the TENS digit of a 2-digit LED display,
while the second increments the UNITS digit. The third pushbutton switch (on the right)
is designated MOVE and has a number of functions.
When you first apply power, the display is blank and the game defaults to the reset
mode. During this time, two "hidden number" counters are clocked by a lOkHz oscillator.
These counters form a random number generator which rapidly cycles between 0 and 99.
The game progresses to the running mode when you press the MOVE switch. This
latches in a random number and illuminates the 7-segment displays with an initial value
of 00. You now try to guess the number by incrementing the display using the TENS and
UNITS buttons, and then entering the chosen number by pressing the MOVE button again.
To the left of the 2-digit display are three LED indicators. These are the result LEDs. If
the number you entered is too low, the bottom red LED glows, Similarly, if it is too high,
the top red LED glows. You then enter a new number and press the MOVE button again.
When you guess the correct number, the centre green LED glows and the game can be restarted by pressing the MOVE button once more.
Block diagram
Fig.1 shows the block diagram of the Number Cruncher. The clock (IClOa) provides a
square-wave with a frequency of about l0kHz. This is used to clock two decade counters
(IC5a & IC5b) to provide the random 2-digit number. The counters are stopped when the
44
SILICON CHIP
MOVE button is pressed.
Two other BCD (binary coded decimal) counters (IC2a & IC2b) are then
clocked by the UNITS and TENS
switches. Pressing each switch once
increments its associated counter.
The outputs from these two
counters, along with the outputs from
the random number counters, are fed
into two 4-bit BCD comparators (IC6
& IC7). These two ICs are really the
main stars of the project. They compare the values in the two sets of
counters and generate an appropriate
output, depending on which is higher
and which is lower, or whether they
are equal.
For example, IC6 compares the values from units counters IC2a and IC5a.
Similarly, IC7 compares the values
from IC2b and IC5b. The outputs from
the comparators are then fed into latch
IC8 which is clocked whenever the
MOVE switch is pressed. The outputs
from this latch then feed the LED drivers to indicate "too high", "too low"
and "equal".
To show you the number you've
pressed, the outputs of IC2a and IC2b
are fed into two BCD to 7-segment
display drivers (IC3 & IC4). These in
turn drive two 7-segment displays.
Circuit diagram
Let's now take a look at the full
circuit diagram - see Fig.2.
When power is initially applied, an
RC network on pin 9 of IClb sets the
flipflop so that its Q output (pin 15) is
high. This means that the K input
(pin 11) will also be high, while Q-bar
(pin 14) will initially be low. This
blanks the two 7-segment displays by
pulling pin 4 of the two 7-segment
display drivers (IC3 & IC4) low.
The initial high on IClb's Q output
does several things. First, it resets the
two guess counters, IC2a & IC2b, so
that they don't come on with some
random number. Second, it resets
quad latch stage IC8 and this in turn
ensures that LEDs 1-3 are initially
extinguished. And third, it enables
the two cascaded random number
counters which immediately begin
counting clock pulses from IClOa.
IClOa is part of a 4093 quad NAND
Schmitt trigger IC and is configured
here as a square-wave oscillator. It
oscillates at a frequency of about
l0kHz, as set by the .0lµF capacitor
and the 8.2kQ feedback resistor.
Its output (pin 11) clocks IC5 which
INCREMENT
UNITS
S1
T
UNITS
I
~
l7
DISPLAY
DRIVER
IC3
RANDOM
COUNTER
TOO HIGH
UNITS
COMPARATOR
IC&
ICSa
CLOCK
l 1
LED
EQUALS
LED
LATCH
IC8
IC10a
RANDOM
COUNTER
IC5b
TENS
COMPARATOR
IC7
TOO LOW
LED
INCREMENT
TENS
S2
TENS
T
I
~
COUNTER I -_ _.....,__ ___,_
IC2b
w:rvtt:
IC4
l7
l 1
Fig.1: block diagram of the Number Cruncher. When the MOVE button is
pressed, the two random number counters are stopped. The user then tries to
guess the hidden number by incrementing counters IC2a & IC2b until the
desired number appears on the 7-segment LED displays. The entered number is
then compared with the hidden number using IC7 & IC8.
is one-half of a 4518 dual BCD UP
counter. Thl:l Q4 output from IC5a in
turn clocks IC5b, thereby producing a
2-digit UP counter which continuously cycles from 0 to 99.
The outputs of counters IC5a & IC5b
are fed into the "B" inputs ofIC6 and
IC7. These two ICs are CMOS 4585 4bit comparators and it's these devices
that tell us whether the input number
is too high, too low, or "just right".
Debounce switches
ICla is one half of a 4027 dual JK
flipflop and is used to debounce the
MOVE switch (S3). Each time S3 is
pressed, it releases the reset on pin 4
and pulls the set input (pin 7) high.
PARTS LIST
1 PC board, code SC08110921,
195 x 97mm
4 10mm rubber feet
3 PC-mount piano key switches
1 metre tinned copper wire (for
links)
3 BC547 NPN transistors (01 -03)
1 1N4004 silicon diode (D1)
3 1N914 signal diodes (02-04)
2 5mm red LEDs (LED1 ,LED3)
1 5mm green LED (LED2)
2 LTS543 or equivalent commoncathode ?-segment displays
Semiconductors
2 4027 dual JK flipflops (IC1 ,IC9)
2 4518 dual 4-bit up counters
(IC2,IC5)
2 4511 ?-segment decoders
(IC3,IC4)
2 4585 4-bit magnitude
comparators (IC6,IC7)
1 40175 quad D latch (IC8)
1 4093 quad Schmitt trigger 2-input
NANO gate (IC10)
Capacitors
1 100µF 16VW electrolytic
1 0.1 µF 63VW MKT polyester
1 .01 µF 63VW MKT polyester
Resistors (0.25W, 1%)
8100kQ
310kn
1 8.2kQ
171kQ
DECEMBER
1992
45
01
1N4004
INCREMENT
UNITS
S1
I
~
100k
5
3 J IC9b 0
r
~
-
116
10
112 . 11&
T
I
I
EN
Q
~
lo
Q3
R
04
LT
7
l
12
Q2
IC21
4518
1a
3
11
01
CK
u
~K477
13
i
(
2
14
I
I
6
6
11
4
d 10
2
C
4511
,
9
•I 1,.
-!!
•
14
~
~
P,~k
l
+V
IC10:_l
4093
14
13
'-)1
:ill s
9
_r
K
11
01 11
Q2 12
IC51
.~
RANDOM
NUMBER
CLOCK
.8·
d
10
BI
-!!
41!
,_
14
04 14
EN
7
10
i1!..
A4 A3 A2 Al
INL
9 82
1
03 13
4518
2
1
IC&
.
8-
>L
4515
OUT
3
D
-!-5
I~
< IN 8
OUT
~2
~
+V
1~:14~
--
-
~
16
R
--
0.1
11 81
9 82
035
1 83
•
1A
.
IC7
4515
OUT
.
• 01
-
OUT
12
12
1
:i
...
~
r'
s
1
s
iiJ
D3 I ~ '
1N914
R
~
...] R
17
12
EN
cm
Q 1
£HK!~
100k
B
~
•
'-:!I
100k
E~C
VIEWED FROM
BELOW
_J!
1
01
3
Q2 4
Q3 5
I
1a
I
i
.
.
I
I
1 B
.
I
2 C
Q4 6
CK
'
I
7
A
+V
4 13
BI
a 13
4511
DEBOUNCE
..I!
.!§
711k
7
b 12
6
11
4
C
IC4
8 D
~
NUMBER CRUNCHER
SILICON CHIP
2
C:
14
~
E
~
04
I I
100k
CLK
9
-:I
'-,,Cl
B
O 15
13
CK IC1b
11
K
.r8
6
10k
K(:.\A
I
DEBOUNCE
--
1~.
C
re
J
R
INCREMENT
TENS
-!'
LED3
TOO LOW
IC1®~1
~
17
100k
E
~
3
~
~01
Q3 10 ..,.
CLR
rf:\A
01
41175
03
A1 A2 A3 A4
10 7 2 15
K
'-C,,I'
C
A
mLr-
I
14 16
R
11111
Q3
BC547
t-,fMffE
100k
1k
Q2
BC547
,
ICI
I■100k
POWER UP
RESET
LED2
EQUAL
E
84
-!!
-1:
+V
01 3
024
04
'-.!:l7
B
~
I
IC5ll
EN
10K
Q4 15
13 D4
K /'F\A
C
OUT
~>
N
1
CLK
........1
IN > 13
IN
1k
Q1
BC547
18
5
<
6
LED1
TOO HIGH
f,
+V
46
UNITS
+V
~5
16
1T
.01I
i
100
1&VW!
IIIIPIAY1
D
••
LfJ
7
12
'
IC3
711k
13
I
1
DEBDUNCE
100k
Cl
17:\ _
.1 \!:I - +9-1 2V
+V
d 1•
2
• 9
1
I 15
9
I 14
18
DISPIAY2
Tall
.8
d
-!!
~K
The result is a clean positive-going
Now the really tricky
9V
pulse on ICla's Q output (pin 1).
work is done inside these
Thus, when S3 is pressed to start two ICs. Let's see how it all
the game, ICla's Q output goes high works.
Since we want to guess a
and clocks flipflop IClb. This resets
IClb which now switches its Q-bar number between 0 and 99,
output high and this enables the dis- we ne~d eight bits·to hold
play drivers, so that the displays now that number; ie, four bits
show "00". At the same time, IClb's Q {or the "units" and four bits
output switches low and this releases for the "tens" .
the resets on the guess counters, IC2a
IC6 compares the lower
& IC2b. The enable inputs of IC5a &
four bits from IC2a with
IC5b are also pulled low and so these those from IC5a (ie, the
counters are latched, thus locking in units). The outputs at pins
2, 12 & 13 then indicate the
the random number.
IC9 is a 4027 dual JK flipflop and results of this comparison.
this is used to debounce switches Sl If the units number entered
and S2. The resulting pulses from IC9a in (ie, the number on the
and IC9b form the clock signals for "A" inputs) is higher than
IC2a and IC2b. These counters corre- the random number on the
spond to those shown in Fig.1 and are "B" inputs, pin 13 goes
used to hold the entered number. Each high.
Conversely, if "A" is less
press of the appropriate switch applies a single clock pulse to either pin than "B", then pin 12 goes
1 or to pin 9 to increment either the high. And if they are equal,
pin 3 goes high. Note that
tens or units digits.
The 4-bit (Ql-Q4) outputs from each only one of these three outcounter are fed to 4511 7-segment de- puts can be high at any
coder/ driver ICs (IC3 & IC4). These time.
then drive two 7-segment displays to
The latter two outputs
indicate the number that's being en- (pins 3 & 12) are coupled to
tered. At the same time, the positive- the cascading inputs of the
going pulse that results each time an "tens" comparator, IC7, but
increment switch is pressed is ap- note that pin 13 of IC6 is
plied to diode OR gate D3 & D4. The left disconnected. By dooutput of this OR gate is inverted by • ing this, IC7 is able to disIClOb and resets latch IC8 to extin- tinguish between numbers
INCREMENT
MOVE
guish any result LED (LEDl - LED3)
of the same decade.
UNITS
that may be on from a previous guess.
IC7 is also used to compare the outputs of IC2b
Fig.3: install the parts on the PC board exactly
8-bit comparator
as shown here & note that all the ICs face in the
and IC5b. Its three outputs
same direction.
As well as driving the 7-segment at pins 3, 12 & 13 then give
decoders, the outputs ofIC2a and IC2b the result of the overall
are also fed into the "A" inputs ofIC6 comparison between the two num- age to set and reset them and do not
and IC7 respectively. These two de- bers. Pin 12 goes high if the guess is respond when the switch wipers are
vices are 4585 4-bit comparators and too low; pin 13 goes high if the guess held low.
The high on pin 2 of IC8 is also fed
have been cascaded to form an 8-bit is too high; and pin 3 goes high if the
to the J input (pin 10) of IClb. Thus ,
BCD comparator by tying the cascad- guess is correct.
These outputs are fed into IC8, a IClb now has a "high" on its J input
ing inputs (pins 4, 5 & 6) appropri40175 quad D latch which is clocked and a "low" on its K input. When the
ately high or low.
each time the MOVE switch (S3) is MOVE switch is again depressed, the
pressed. If the number entered is too
resulting clock pulse from IC la causes
high, pin 15 of IC8 goes high and IClb to set, sending its Q output (pin
turns on LED 1 via transistor Ql. If 15) high and its Q-bar output (pin 14)
the number is too low, pin 10 goes low. This causes the displays to blank
Fig.2 (left): the two 4-bit magnitude
high and lights LED 3 via Q3.
again and the game can now be recomparators, IC7 & ICB, form the
If the number entered is correct,
started by pressing the MOVE button
heart of the circuit. These compare
pin 2 of IC8 (Ql) goes high and lights once more.
the number entered into IC2a & IC2b
LED 2. At the same time, Ql-bar (pin
with the hidden number in counters
3) goes low and this disables the twq Construction
IC5a & IC5b and generate an
INCREMENT
switches. This occurs beAll of the components for the
appropriate output to ·drive quad D
cause the switch debounce flipflops
Number Cruncher are mounted on a
latch ICB. IC8 then drives the
(IC9a & IC9b) require a positive volt- PC board coded SC08110921 and
indicator LEDs via transistors Qt-Q3.
DECEMBER
1992
47
Tt
SC08110921
ol
codes check the values with your
DMM. Note that Dl must be a 1N4004
while D2-D4 are all 1N914s.
The two capacitors can be soldered
in next, followed by the 't ransistors
and the ICs. Be sure to install the
correct IC at each location and note
that they are all oriented in the same
direction. A clean, fine-tipped soldering iron is essential for this job, since
many of the tracks run quite close to
the IC pins.
Don't use a soldering iron that's too
big for this job. If you do, you risk
damage to the tracks and you will
probably wind up with lots of short
circuits.
Finally, install the LEDs, 7-segment
displays and the three switches. Note
that the green LED is LED 2 (centre)
and check that all the LEDs are correctly oriented (the anode lead is the
longer of the two). The 7-segment displays must be installed with their decimal points at bottom right.
Switching on
lV)o
o-fiTI=o;.=~~
a
a
~
Fig.4: check your PC board for defects by comparing it to this full-size pattern
before installing any of the parts.
measuring 195 x 98mm. Fig.3 shows
the assembly details.
Before actually installing any of the
parts, it's a good idea to check the
board carefully for etching defects.
Repair any defects that you do find,
then start the assembly by installing
the wire links.
It's important to keep these wire
48
SILICON CHIP
links as straight as possible, to avoid
shorts. If necessary, you can straighten
the link wire by clamping one end in
a vyce and then stretching it slightly
by pulling the other end with a pair or
pliers.
Once all the links are in, you can
install the resistors and the diodes. If
you don't know the resistor colour
Now for the smoke test but first
check your completed board carefully
against Fig.3 to ensure that all parts
are correct. Everything OK? If so, connect your DMM (set to the mA range)
in series with a 9V plugpack supply
and apply power to the board. Note:
do not use a 12V plugpack supply, as
its output may be well in excess of the
maximum 15V supply voltage for the
CMOS ICs.
Initially, none of the displays or
LEDs should be on and the current
should be less than 5mA (typically
about ZmA) . If the current exceeds
5mA, switch off immediately and
check for wiring errors. An IC might
have been mounted the wrong way
around or there could be a short on
the copper side of the PC board.
If everything checks out so far, press
the MOVE button (S3) and check that
the display now shows "00". At the
same time, the current reading should
jump to about 100mA. Now press the
INCREMENT buttons (S1 & S2) until
the nµmber you want to enter is dis. played and then press the MOVE button (S3).
Finally, check that one of the three
indicator LEDs lights to indicate
whether you're too high, too low or
bang on.
Do you know anyone who claims to
have ESP? You can now put them to
the test.
SC
|