School Science Lessons
Physics - Electronics 2, Experiments from "UNESCO Electronics
Teacher's Guide"
Updated: 2008-08-06
Please send comments to: J.Elfick@uq.edu.au
See also:
Table of contents
All the experimental work below uses a 6 V supply from batteries but
they will also work from a 4.5 V supply.
39.1.0 Electronic Components
39.2.0 Switches
39.3.0 Logic circuits
39.4.0 Logic gates
39.5.0 Bistable circuits
39.6.0 Drivers
39.7.0 Coding
39.8.0 Pulser (pulse generator), the
astable and the clocked
bistable
39.9.0 Counting circuits
39.1.0 Electronic Components
39.1.1 Resistor and light-emitting diode (LED)
39.1.2 Brightness and current
39.1.3 LEDs in parallel
39.1.4 Current direction indicator
39.1.5 Light dependent resistor (LDR)
39.1.6 Simple burglar alarm using LDR
39.2.0 Switches
39.2.1 Manual control of a LED
39.2.2 Reed switch and magnet
39.2.3 Reed switch and coil - the reed relay
39.2.4 Reed relay controls a motor
39.2.5 Reed relay with a coil and contacts in
parallel, using a single power supply
39.2.6 Automatic washing line
39.2.7 Reversing an electric motor
39.3.0 Logic circuits
39.3.1 Simple AND circuit
39.3.2 Simple OR circuit
39.3.3 Relay as a NAND circuit
39.3.4 Simple burglar alarm
39.3.5 NAND circuit as an inverter
39.3.6 Make an AND circuit with two NAND circuits
39.3.7 Excess length detector
39.3.8 Two NAND circuits as a bistable
(Flip-flop)
39.3.9 Latched burglar alarm
39.3.10 Use a bistable to control an electric
motor
39.4.0 Logic gates
39.4.01 Logic symbols
39.4.1.0 LED indicators
39.4.2.0 NAND gate truth table
39.4.2.1 NAND gate as an inverter (NOT circuit)
using joined inputs
39.4.2.2 NAND gate as an inverter (NOT circuit)
using separate inputs
39.4.2.3 Astable using two NAND gates connected
as an AND gate
39.4.2.4 AND gate from two NAND gates
39.4.2.5 OR gate using three NAND gates
39.4.2.6 NOR gate using four NAND gates
39.4.3.0 Applications using NAND gates
39.4.3.1 Burglar alarm (NAND application)
39.4.3.2 Length detector (AND application)
39.4.3.3 Automatic night light using two NAND
gates as inverters
39.4.3.4 Fire alarm using NAND gate as
inverter, and a thermistor
39.4.3.5 Safety circuit for a safe using three
input AND gate
39.4.3.6 Skittle alley winner indicator with
3-input NAND gate
39.4.3.7 Car doors warning light using 2-input
NAND gate
39.4.3.8 Light at the top of the stairs circuit
using OR gate
39.5.0 Bistable circuits
39.5.1.0 Bistable using two NAND gates
39.5.1.1 Two NAND gates as inverters
39.5.1.2 Two NAND gates with reversed
conditions
39.5.1.3 Two NAN gates with positive feedback
link - bistable
39.5.1.4 Bistable with complimentary outputs, Q
and Q'
39.5.1.5 Bistable building block
39.5.1.6 Bistables and logic gates
39.5.2.0 Bistable applications using NAND
gates
39.5.2.1 Latched burglar alarm
39.5.2.2 Latched fire alarm using a bistable
39.5.2.3 Simple stop-go traffic lights
39.5.2.4 Traffic lights operated by an SPST
switch
39.5.2.5 Quiz master
39.6.0 Drivers
39.6.1.0 Loading an output
39.6.2.0 Using a NAND gate to switch an
electric motor on or off
39.6.2.1 Inverting driver amplifier
39.6.2.2 Driver amplifier with relay omitted
39.6.3.0 Applications involving the driver
amplifier and reed relay
39.6.3.1 Reversing an electric motor
39.6.3.2 Reversing an electric motor with a
bistable circuit
39.6.3.3 Automatic light
39.6.3.4 Motor vehicle moving backwards and
forwards between two light beams
39.7.0 Coding
39.7.1d Sending messages using a 4 bit binary
code
39.7.2 Seven segment LED display
39.7.3 Seven segment display with a decoder
39.7.4 Two-line to four-line decoder from NAND
gates
39.8.0 Pulser, the astable and the
clocked bistable
39.8.1.0 Voltage outputs from the pulser /
astable module
39.8.2.0 Clocked bistable
39.8.3.1 Four 4 bit binary counters from
clocked bistables, binary up-counter
39.8.3.2 Four 4 bit binary counters from
clocked bistables, binary down-counter
39.9.0 Counting circuits
39.9.1.0 Four bit binary counter integrated
circuit
39.9.1.1 Linking the counter to a decoder and
seven segment display
39.9.2.0 Counters of different moduli
39.9.3.0 Switch contact bounce
39.9.3.1 Bistable circuit to eliminate contact
bounce
39.9.4.0 One bit memory from NAND gates and an
RS bistable
39.9.5.0 Linking two single digit counters to
make a dual decade counter
39.9.6.0 Applications using counting
circuits
39.9.6.1 Divide-by-N counting
39.9.6.2 Down-counting 1.
39.9.6.3 Down-counting 2.
39.9.6.4 Counting the swings of a pendulum
39.9.6.5 Controlling a motor 1.
39.9.6.6 Controlling a motor 2.
39.9.6.7 Reversing a motor at regular intervals
39.9.6.8 Flashing a lamp six times - six pips
39.9.6.9 Automatic light buoy
39.9.6.10 Electronic die
39.9.6.11 Traffic lights
39.9.6.12 Batch counting
39.9.6.13 Reaction time
Other topic headings
Timers
Position and Velocity Detectors
Sources of Sound
Sound Detectors
Circuits/Components/Instruments
Function Generators
Oscilloscopes
Advanced Instruments
Power Supplies
Light Sources
Light Paths Made Visible
Lasers
Microwave Apparatus
Computer Interface
Appendix A Bibliography
Appendix B Technical
See also:
See also: Interesting websites
See also: Chapter 38
Electronics 1 Experiments
See also:
Electronics appendix
39.1.0 Electronic Components
39.1.1 Resistor and light-emitting diode (LED)
See diagram 39.1.1
Use a LED, a battery and a resistor.
The passage of current causes the emission of light. The
intensity of light depends on the size of the current. The direction in
which current will flow is the same as that of the arrowhead in the
symbol. (2) Reverse the connections so that the diode is the other way
round. A LED will allow current to pass in only one direction. (3) If
you connect directly across the battery you will destroy the LED, so
insert a series resistor to limit the current, e.g. 10
milliamperes.
39.1.2 Brightness and current
See diagram 39.1.2
Connect the circuit shown, using a LED module, a resistor and a
battery.
Use a low value resistor and note how brightly the LED glows.
Replace the resistor first by the one of medium value, then by one of
large value, e.g. 27 k ohms, 2.7 k ohms and 270 ohms. Note what happens
to the brightness of the LED and how does the brightness of the LED
depend on the current passing through it.
39.1.3 LEDs in parallel
See diagram 39.1.3
Use one red LED, one green LED and a battery.
Both LEDs glow because Two LEDs of the same colour and resistance
connected in parallel will glow with the same brightness because the
currents through each are equal. A LED of different colour with the
same value of series resistor may not glow with the same brightness.
Use a milliammeter to show that the currents through red and green LEDs
with equal series resistors are almost the same. Variations in apparent
brightness are due to differences in the materials and to variations in
the sensitivity of the eye to different colours.
39.1.4 Current direction indicator
See diagram 39.1.4
If you connect a battery one way round to the indicator, one LEDs
should glow. If you reverse the battery connections, the other LED will
glow.
39.1.5 Light-dependent resistor (LDR)
See diagram 39.1.5
Use a light dependent resistor in series with a LED and a battery. If
you cover or uncover the LED, the current will flow in either direction
as with an ordinary resistor. The resistance of a LDR is very large in
the dark, e.g. a million ohms or more, but falls to a small value, e.g.
two hundred ohms, in bright light. Cadmium sulfide is commonly used for
LDRs. A LDR is not a photocell.
39.1.6 Simple burglar alarm using LDR
See diagram 39.1.6 Use and LDR, a buzzer and
a battery to construct a circuit that will sound an alarm when a light
comes on. The buzzer probably has a definite polarity.
39.2.0 Switches
The next 3 experiments show the progression from direct manual control
to magnetic control, and then to electromagnetic control.
39.2.1 Manual control of a LED
See diagram 39.2.1
Connect a battery, and LED and a push-button switch together in a
series circuit. The LED lights only when the push-button switch is
pressed.
39.2.2 Reed switch and magnet
See diagram 39.2.2
Use a magnifying glass to see the two metal contacts inside the glass
envelope of the reed switch. These contacts are normally open. Connect
the switch in series with a buzzer and a battery. Bring a small bar
magnet close to the reed switch to see the contacts close. A reed
switch has two metal contacts, "reeds", inside a glass envelope filled
with an inert gas to prevent corrosion. The contacts consist of a
ferrous metal so a magnet can magnetize them. If you bring the magnet
close to the switch, the metal strips become magnetized and attract
each other. When the contacts close, a current flows through the
buzzer. The magnet produces a force that closes the switch contacts.
The reed switch contacts are either open or closed so you call the reed
switch a single-pole single-throw, SPST, switch.
39.2.3 Reed switch and coil - the reed relay
See diagram 39.2.3
Using a reed relay with two separate battery supplies. Do not use
either of the diode connections to the coil of the relay. In this
experiment switching is controlled by the magnetic effect of a
current-carrying coil that has a magnetic effect - an electromagnetic
relay. When the switch is closed, the relay uses a change-over reed
switch, a single-pole double-throw, SPDT, switch. The reed C and
contact A consist of a magnetic metal. Contact B is a nonmagnetic
metal. Contact C is normally in contact with B. However, when a
magnetic field magnetizes A and C, they are attracted together so that
contact with B is broken and C contacts A instead. When you remove the
field, C springs back to its original position. Change the switch
connections at the relay so that the LED is on until the push-button
switch is pressed. If current flows through the coil, the reed switch
changes over and the LED lights. Note that the flow of an electric
current now determines the switching, and although the two circuits are
separate, what happens in one circuit is controlled by what happens in
the other circuit. The current through the coil, needed to operate the
switch, is usually smaller than the current allowed through the switch
contacts. So if the LED and resistor were replaced by an electric motor
that needed a large current to make it rotate, the electric motor could
be operated by a much smaller current through the coil circuit.
39.2.4 Reed relay controls a motor
See diagram 39.2.4
Use a reed switch, a motor and two batteries. When the LDR is covered,
its resistance is great, and not enough current flows through the relay
coil to operate the reed switch and switch on the motor. When the LDR
is well illuminated with a torch, its resistance decreases and the
relay operates. Insert ammeters in series with the coil and the motor
to show that the current through the motor, e.g. 0.2 A, is more than
the current through the coil. So the flow of a small current is used to
control the flow of a much larger current. If the reed relay is not
used, the change in the resistance of the LDR is not enough to allow
the motor to operate.
39.2.5 Reed relay with a coil and contacts in
parallel, using a single power supply
See diagram 39.2.5
In 39.2.4 and 39.2.6, a small current in one circuit controlled a much
larger current in another circuit that was completely separate with its
own power supply. In this experiment, a current through one branch of a
parallel circuit, the coil branch, controls a much larger current
through another branch, the motor branch, using only one battery. Note
what happens to the motor when the switch is closed. In this circuit
the relay coil and the relay contacts are connected in parallel. Trace
the closed current paths from the battery, through each branch of the
circuit and back to the battery again. This circuit uses the idea of
positive and negative supply rails.
39.2.6 Automatic washing line
See diagram 39.2.6
Use two batteries, reed relay, electric motor and the rain sensor to
make a circuit that switches on an electric motor when rain fails. Make
a rain sensor from a small piece of strip board on which are six copper
strips are connected. If a conducting solution bridges any of the
strips, the two leads are short circuited allowing current to flow
through the relay coil. If the experiment does not work with tap water
add salt to the water. Rain water may conduct electricity, but not
sufficiently to operate the reed relay in the circuit. The experiment
will work with rain if the copper strips are covered by dry absorbent
paper soaked in a salt solution.
39.2.7 Reversing an electric motor
See diagram 39.2.7 Use a push-button switch,
the reed relay and three batteries to make a circuit so that the
direction of rotation of the motor is reversed when the switch is
pressed. With a 3 volt motor only one battery may be used.
39.3.0 Logic circuits
39.3.1 Simple AND circuit
See diagram 39.3.1
Connect two push-button switch modules in series with a LED and a
battery.
| S1 |
S2 |
LED |
| Not pressed |
Not pressed |
OFF |
| Pressed |
Not pressed |
OFF |
| Not pressed |
Pressed |
OFF |
| Pressed |
Pressed |
ON |
The table tells us that the LED is on when S1 AND S2 are pressed, so
the circuit is called an AND circuit. An AND circuit may be used in a
motor car if the ignition light shows that the car can be started only
when the driver has engaged his safety belt AND closed his door.
39.3.2 Simple OR circuit
See diagram 39.3.2
| S1 |
S2 |
LED |
| Not pressed |
Not pressed |
OFF |
| Pressed |
Not pressed |
ON |
| Not pressed |
Pressed |
ON |
| Pressed |
Pressed |
ON |
The truth table for an OR circuit tells us that the LED is on when
either S1 OR S2, or both, are pressed. In a burglar alarm pressure pads
are open SPST switches. A pad is placed under a carpet so that the
pressure of the burglar's foot closes the switch. The circuit could be
used with two such switches. An alarm sounds, if the buzzer replaces
the LED, if entry were through door 1 OR door 2.
39.3.3 Relay as a NAND circuit
See diagram 39.3.3
A logic circuit is a switching circuit in which the state of the output
at any instant depends on the present state of all the inputs. The
output is HIGH only for some input combinations. NAND is a contraction
of "negative AND". NAND circuits are commonly used in electronics.
Construct the NAND relay circuit with its coil and contacts in parallel
with the supply, and its inputs and outputs are either HIGH or LOW.
| INPUT B |
INPUT A |
OUTPUT |
| LOW |
LOW |
HIGH |
| LOW |
HIGH |
HIGH |
| HIGH |
LOW |
HIGH |
| HIGH |
HIGH |
LOW |
Using a reed relay, a LED and a battery, connect leads to the diode
input terminals of the relay, A and B. When you connect the other end
of one of these leads to the positive supply rail, the input is HIGH.
If you connect the lead to the negative supply rail, the input is LOW.
The output is HIGH if the LED is on and LOW if the LED is off. The
output is HIGH when one or both of the inputs are LOW.
In an AND circuit, its output is HIGH when input A and input B are HIGH
- see the AND circuit truth table below. In a NAND circuit, the output
is LOW when input A and input B are HIGH, see the NAND relay circuit
truth table below. The contacts at the output form an SPDT switch. You
normally connect the pole of this switch to the negative supply rail,
i.e. the output is LOW. This is the position at the output when no
current flows through the relay coil. When either or both inputs are
taken LOW, current flows through the coil and the output contact
changes over. The output goes HIGH and the LED module is connected
directly to the positive supply rail. No current can flow through an
input if it is HIGH nor if the input is unconnected. So an unconnected
input behaves as though it were HIGH. You include diodes at the inputs
because without diodes and one input were taken HIGH and the other
taken LOW, a short circuit across the battery may occur.
AND circuits.
| INPUT B |
INPUT A |
OUTPUT |
| LOW |
LOW |
LOW |
| LOW |
HIGH |
LOW |
| HIGH |
LOW |
LOW |
| HIGH |
HIGH |
HIGH |
NAND relay circuit LOW
| INPUT B |
INPUT A |
OUTPUT |
| LOW HIGH |
LOW |
HIGH |
| LOW |
HIGH |
HIGH |
| HIGH |
LOW |
HIGH |
| HIGH |
HIGH |
LOW |
39.3.4 Simple burglar alarm
See diagram 39.3.4
Note what happens when switch A or switch B is pressed, or both are
pressed together. How would you modify this circuit so that the alarm
sounds either when a switch was closed or when a light shines on a LDR.
This circuit is more realistic if you use pressure pads instead of the
switch modules, as in 39.3.2. A light beam can trigger the alarm by
replacing one switch module by a LDR module. If you cover the LDR or
the room is dark the LED will have a very HIGH resistance and so little
current flows through the relay coil. When light fails on the LDR its
resistance rapidly decreases and current can flow through the coil, so
the LDR operates the relay. The input is now LOW.
39.3.5 NAND circuit as an inverter
See diagram 39.3.5
Connect a LED to the output and a flying lead to one input of the NAND
circuit. Use the flying lead to take the input HIGH and LOW. When you
use one input of a NAND circuit, or you join the two inputs of a NAND
circuit as a single input, the NAND circuit behaves as an inverter.
| INPUT |
OUTPUT |
| HIGH |
LOW |
| LOW |
HIGH |
39.3.6 Making an AND circuit with two NAND
circuits
See diagram 39.3.6
Using two NAND circuits (one as an inverter), a LED and a battery. The
inverter inverts the output of the NAND circuit. Compare the truth
table below with 39.3.3. Connect a flying lead to each input terminal
of the first NAND circuit. Remove the flying lead from input B and
connect a push-button switch between input B and the negative supply
rail. Connect the flying lead from input A to the positive supply rail,
i.e. HIGH, then operate the switch several times. Connect the flying
lead from input A to the negative supply rail, i.e. LOW, and operate
the switch. When you connect the lead from input A to the positive
supply rail, HIGH, operating the switch connected to input B causes the
LED to go on or off. So the output follows the changes at input B. When
input A is LOW, the LED is off and operating the switch does not affect
it. The action of the circuit is like a gate and you call it a "gate".
With input A HIGH, the gate is opened and the signals pass through it.
With input A LOW, the gate is closed and the output is not affected by
changes at input B.
| INPUT B |
INPUT A |
OUTPUT |
| LOW |
LOW |
LOW |
| LOW |
HIGH |
LOW |
| HIGH |
LOW |
LOW |
| HIGH |
HIGH |
HIGH |
39.3.7 Excess length detector
See diagram 39.3.7
Use two NAND circuits (one connected as an inverter), two LDR modules
and a buzzer. Illuminate each LDR with a light beam. If light shines on
an LDR, its resistance is LOW. The inputs of the first NAND circuit are
therefore LOW, so its output must be HIGH. The buzzer sounds only when
both the LDRs are shaded. The second NAND circuit is an inverter, so
its output is LOW and the buzzer does not sound. If one LDR is covered,
but not the other, one input is still LOW, a current still flows in the
coil, the output of the first NAND circuit is still HIGH, the output of
the inverter is LOW, and nothing happens. However, if both LDRs are
covered, the output from the first NAND is LOW, so the output from the
second is HIGH and the buzzer sounds. If objects of greater length than
the distance between the LDRs pass in front of them, the buzzer sounds.
The two relay modules, a NAND circuit followed by an inverter, are
together acting as an AND circuit. So, the output is HIGH, the buzzer
sounds, only when input 1 AND input 2 are HIGH.
39.3.8 Two NAND circuits as a bistable
(Bistable multibrator, Flip-flop)
See diagram 39.3.8
To show the circuit, press the RESET switch. The green LED is on and
the red LED is off. Press the SET switch. The red LED is on and the
green LED is off. Press the SET switch repeatedly. The red LED is still
on and the green LED is still off. Press the RESET switch again. The
green LED is on and the red LED is off. Press the RESET switch
repeatedly. The green LED is still on and the red LED is still off.
When the RESET switch is pressed, the output of NAND circuit 2 is HIGH
and the output of NAND circuit 1 is LOW. When the SET switch is
pressed, the output of circuit 1 is HIGH and the output of circuit 2 is
LOW. The bistable circuit has two stable states. The first stable state
occurs when the output of NAND circuit 2 is HIGH and the output of NAND
circuit 1 is LOW - the RESET state. The second stable state occurs when
the output of NAND circuit 1 is HIGH and the output of NAND circuit 2
is LOW - the SET state.
In a bistable circuit, after the SET switch has been pressed, repeated
depressions of this switch have no effect. Also, after the RESET switch
has been pressed, repeated pressing of this switch have no effect. The
SET and RESET inputs are normally unconnected, i.e. they "float HIGH".
To change from one stable state to the other the appropriate input must
be taken LOW. Follow the path of the current flow through the coils and
the connections between the two NAND circuits.
Note how the two NAND circuits are joined and share the same power
rails. The output C of the first circuit is connected to the input D of
the second circuit. Similarly the output F of the second circuit is
connected to the input A of the first circuit. A red LED is connected
between C and M. If C is HIGH, the red LED will light. If C is LOW, the
red LED will not light. A green LED is connected between F and N. If F
is HIGH, the green LED will light. If F is LOW, the green LED will not
light. A bistable circuit has two stable states. For the first stable
state, if C is HIGH, the red LED will light, D will be HIGH, F will be
LOW so the green LED will not light. As F is low, A is LOW, so C
remains HIGH. For the second stable state, if C is LOW, the red LED
will not light, D will be LOW, F will then be HIGH so the green LED
will light. As F is high, A is HIGH, so C remains LOW. This is the
second stable state - and so you use the name "bistable" as it has two
stable states. Note that the output of the 1st module is connected to
the input of the 2nd module and the output of the 2nd module
is connected to the input of the 1st module.
1. To set the bistable in one stable state or the other, push-button
switches are connected between input B and the negative rail at P and
between input E and the negative rail at Q.
2. To set the first stable state, press the push-button switch at P,
current flows through the relay coil, C becomes HIGH and the red LED
will light.
3. To set the second stable state, press the second push button at
Q, current flows through the relay coil F becomes HIGH, the green LED
will light. The circuit could be used to control of simple traffic
lights so that the red light and the green light cannot be turned on
together.
39.3.9 Latched burglar alarm
Replace the red LED in the circuit of 39.3.8 with a buzzer. Remove the
green LED. If the buzzer sounds, press the RESET switch to silence it.
The SET switch is now the trip switch of the alarm. If it is pressed,
the alarm sounds and it cannot be turned off by releasing the trip
switch or pressing it again. You say the output is locked or latched
because the bistable is locked in its second stable state. The alarm
can only be turned off by pressing the RESET switch. This latched alarm
is an improvement on the alarm constructed in 39.3.4.
39.3.10 Use a bistable to control an electric
motor
Remove the buzzer from the circuit of 39.3.9, or both LEDs from the
circuit of 39.3.8, and connect the motor between the outputs of the two
NAND circuits C and F in diagram 39.3.8. Pressing the SET and RESET
switches alternately changes the direction of rotation of the electric
motor. The bistable circuit here is used simply to reverse the polarity
of the motor supply.
39.4.0 Electronic logic circuits - logic gates
See 39.4.0 Modules
Draw a circuit before connecting the parts. If their circuit does not
behave as expected, try to explain why this happens before making any
changes to the circuit. CMOS integrated circuits operate over the wide
voltage range of 3 V to 18 V and require little supply current unless
driving external devices, e.g. LEDs and 7-segment displays. Use dry
cells that can drive the LEDs and the 7-segment displays because the
current required will rarely exceed 0.2 A. However, performance of CMOS
integrated circuits can vary with the supply voltage chosen. A supply
voltage of 5 V or 6 V is recommended. Integrated circuits can be
damaged if supply polarity is reversed so connect a diode, e.g. IN5401,
between the power rails of each circuit so the diode conducts if the
supply connections are inadvertently crossed. The reverse voltage is
about 1 V. and current about 3 A. When connecting prepared circuits,
link the corresponding power rails of the circuits before connecting
the circuits to the supply.
39.4.01 Truth tables for logic gates
See diagram 39.4.01: Logic symbols
AND gate: Circuit has two or more inputs, and one output that is high
if all inputs are high.
NAND gate: Circuit has two or more inputs, and one output that is high
if one or more of the inputs are low, and low if all the inputs are
high.
OR gate: Circuit has two or more inputs, and one output that is high if
one or more of the inputs are high.
NOR gate: Circuit has two or more inputs, and one output that is high
only if all inputs are low.
INVERTER (NOT gate): Circuit has one input, and one output that is high
if the input is low and low if the input is high.
| AND |
. |
. |
. |
NAND |
. |
. |
| B |
A |
OUTPUT |
. |
B |
A |
OUTPUT |
| LOW |
LOW |
LOW |
. |
LOW |
LOW |
HIGH |
| LOW |
HIGH |
LOW |
. |
LOW |
HIGH |
HIGH |
| HIGH |
LOW |
LOW |
. |
HIGH |
LOW |
HIGH |
| HIGH |
HIGH |
HIGH |
. |
HIGH |
HIGH |
LOW |
| . |
. |
. |
. |
. |
. |
. |
| . |
. |
. |
. |
. |
. |
. |
| OR |
. |
. |
. |
NOR |
. |
. |
| LOW |
LOW |
LOW |
. |
LOW |
LOW |
HIGH |
| LOW |
HIGH |
HIGH |
. |
LOW |
HIGH |
LOW |
| HIGH |
LOW |
HIGH |
. |
HIGH |
LOW |
LOW |
| HIGH |
HIGH |
HIGH |
. |
HIGH |
HIGH |
LOW |
| INVERTER (NOT gate) |
. |
| INPUT |
OUTPUT |
| HIGH |
LOW |
| LOW |
HIGH |
39.4.1.0 LED indicators
See diagram 39.4.1.0
Use a LED indicator module or different LEDs and power supply,
connected correctly. Plug a lead into the top input socket of the
indicator module or the first LED. Connect the other end of this flying
lead to the positive power supply rail or to the negative power supply
rail. If the flying lead connects to the positive rail, the input is
said to be HIGH. If the flying lead connects to the negative rail, the
input is said to be LOW.
39.4.1.1 Indicator in a circuit diagram
See diagram 39.4.1.1
Note how an indicator is represented in the circuit diagram. The power
supply need not be drawn. Only the parts of a module in use need be
shown, so diagram 39.4.1.1 is the equivalent of diagram 39.4.1.0. The +
and - signs near the power rails show that a power supply is connected
between them.
39.4.1.2 Control function in an AND gate
See diagram 39.4.1.2
The term gate refers to the switching circuit in which the state of the
output at any instant depends on the state of the inputs at that
instant, i.e. a logic circuit. In an AND gate one of its inputs
performs a control function when a succession of high and low pulses
arriving at the other input. If the control input is held low, the
output will be held low if the state of the other input is high or low,
so the gate is closed. If the control input is held high, the output
state follows the state of the other input, so the gate is open. A NAND
gate is open when its control input is high as with an AND gate, but
the pulses arriving at the other input are inverted when they arrive at
the output. The OR gate and NOR gates are both open when their control
inputs are low. However, the output pulses are inverted with the NOR
gate.
39.4.2.0 NAND gate truth table
See diagram 39.4.2.0
Use a NAND gate, LED indicator and power supply. Each input A and B can
be connected to the positive power supply rail (high) or to the
negative power supply rail (low) using a flying lead. Note how the
different LEDs light when the input is connected high or low. The
output is high if the LED is lit and low if the LED is unlit. Connect
the inputs high and low, complete the truth table for a NAND gate. Note
whether an unconnected input behaves as if it is high or low.
39.4.2.1 NAND gate as an inverter (NOT
circuit) using joined inputs
See diagram 39.4.2.1
Note the inversion circle at the output of a gate with an inverting
function. The symbol for AND with an inversion circle becomes symbol
for NAND ("not and"). The symbol for OR with inversion circle becomes
the symbol for NOR ("not or"). The NAND gates can be used to make NOT
circuits, AND, OR and NOR gates. The NAND gate used in these
experiments has inputs that are high when unconnected. Connect the two
inputs of a NAND gate together as shown in the diagram. The two joined
inputs can now be thought of as a single input. This single input can
be taken high or low using the flying lead. By taking the input high
and then low, complete the truth table for the inverter. The inverter
is also called a NOT circuit.
39.4.2.2 NAND gate as an inverter (NOT
circuit) using separate inputs
See diagram 39.4.2.2 (a) 39.4.2.2 (b)
Instead of using a two input NAND gate as an inverter as in 39.4.2.1 by
joining the two inputs of the NAND gate, use one input of a NAND gate
by joining a flying lead to it and connect the other to the positive
rail so it is permanently high, or leave it leave it unconnected, i.e.
"floating", as in diagram 39.4.2.2 (a). Note how the circuit behaves if
the input is taken high and low. Note what happens if one input is tied
permanently low. However, for these experiments show an inverter as in
diagram 39.4.2.2 (b).
39.4.2.3 An astable using two NAND gates
connected as an AND gate
See diagram 39.4.2.3
Use two NAND gates connected as an AND gate. When the control input is
high, pulses will pass through the AND gate and the two LEDs will flash
on and off together. If the control input is taken low, the LED at the
output will be permanently low. If a single NAND gate is used and the
control input is high, the output LED will flash on and off. However,
it will be on when the LED at the input is off, and vice versa. When
the control input is low, the output LED will be permanently on.
39.4.2.4 AND gate from two NAND gates
See diagram 39.4.2.4
Connect the circuit using two NAND gates. The second NAND gate is
connected as an inverter, i.e. a NOT circuit. Check that the circuit
behaves as an AND gate by taking the inputs high and low. Complete the
truth table.
39.4.2.4.1 Power connections for AND gate
from two NAND gates
See diagram 39.4.2.4.1
By common convention draw the symbol without power supply connections
as in 39.4.2. (b4). However, the diagram shows how to include the
supply lines in the circuit diagrams to show the power supply
connections to the electronic devices inside the NAND gate.
39.4.2.5 OR gate using three NAND gates
See diagram 39.4.2.5
Note the truth table for an OR gate. Compare this with the truth table
for a NAND gate. If every high input to the NAND gate becomes a low and
every low input becomes a high, you have an OR gate. Design an OR gate
using three NAND gates. Build the circuit and check that it produces
the correct truth table.
39.4.2.6 NOR gate using four NAND gates
See diagram 39.4.2.6
Note the truth table for a NOR gate. Use four NAND gates to convert
your OR gate to a NOR gate. Check that your circuit produces the
correct truth the truth tables for a NOR gate.
39.4.3.0 Applications using NAND gates
Electronic circuits can do useful tasks and control devices, e.g. LEDs,
buzzers and motors. In these experiments integrated circuit NAND gates
are used instead of NAND circuit relays. However, the circuits are
identical whether relay or integrated circuit (IC) NAND gates are used.
These applications use illuminated LDRs to keep inputs low. So an LDR
can act as a switch that is open in the dark and closed when
illuminated. Connect input devices such as LDRs between gate inputs and
the negative supply rail. Because an unconnected input floats high, an
LDR connected to the positive supply rail will not change the logic
level at the input when the illumination changes. When connected to the
negative supply rail, an LDR will cause a low level input when brightly
illuminated, low resistance, and a high level input when dark, high
resistance. A suitable LDR is the ORP 12. Buzzers are used because they
are low current devices that can operate over a voltage range of 3 V to
15 V and emit a constant frequency audible tone.
39.4.3.1 Burglar alarm (NAND application)
See diagram 39.4.3.1 Use a single NAND gate,
an LDR, a push-button switch and a buzzer to make a simple burglar
alarm. The alarm should sound when the LDR is illuminated by the
burglar's torch or the switch is closed by the burglar's foot.
39.4.3.2 Length detector (AND application)
See diagram 39.4.3.2
Use two NAND gates (one gate connected as an inverter) with two LDRs
and a buzzer to construct a system that will sound an alarm when an
object is longer than a specified maximum length. Such a circuit might
be used to reject overlong objects passing along a conveyor belt in a
factory.
The LDRs are positioned a distance x apart (where x is the specified
maximum length of the object) and illuminated by "pencil" torches. The
alarm sounds when both beams are interrupted.
39.4.3.3 Automatic night light using two
NAND gates as inverters
See diagram 39.4.3.3
Use two NAND gates (both connected as inverters), an LDR and a LED
indicator to make a circuit in which a light (the LED) will come on
automatically in the dark. This circuit could be used to turn on a
light when it gets dark. This application uses two NAND gate inverters
to drive a LED indicator. The circuit on the left is not very sensitive
to changes of light intensity. This is because the LDR and the internal
circuitry of the NAND gate module effectively form a potential divider
between the supply rails (see right). As R has a high resistance, it
needs a large change in the resistance of the LDR to change the voltage
level at the NAND gate input appreciably. The second circuit allows the
sensitivity to be changed. The variable resistor should be set so that
the LED is on the verge of switching on. Then any darkening of the LDR
will cause the LED to light. The value of the variable resistance to
use depends on ambient light conditions, but 10 k ohm should suit most
circumstances.
39.4.3.4 Fire alarm using NAND gate as
inverter, and a thermistor
See diagram 39.4.4
Use a NAND gate connected as an inverter, a thermistor, a variable
resistor and a buzzer to make a simple fire alarm. The alarm should
sound when the thermistor is heated. How would you adjust the circuit
so that the alarm sounded when the temperature reached a higher value?
It is important that students should have previously met the potential
divider and the thermistor if they are to solve this problem.
(2) An inexpensive TH3 thermistor can be used for this fourth
application. Its resistance at room temperature is about 400 ohm, and
decreases to about 20 ohm at 100oC. At room temperature, the
5 k ohm variable resistor, i.e. a 5 k ohm potentiometer connected as a
variable resistor, should be set so that the buzzer is just turned off.
Warming the thermistor with the hand will then cause the buzzer to
sound. To increase the temperature at which the alarm responds,
decrease the value of the variable resistance. Note that a 2.5 k ohm
variable resistor provides greater sensitivity.
39.4.3.5 Safety circuit for a safe using three
input AND gate
See diagram 39.4.5
A safety circuit for a large safe sounds an alarm only if the door is
closed but not locked. Closing the door opens a switch, while locking
the door closes another switch. What sort of logic gate is required to
do this? Set up the circuit and test it. Now adapt your circuit for a
safe that has two locks.
This project introduces the 3 input AND gate that will be used in
several projects later in the course. Note that 9 NAND gate 4 is
omitted, the circuit i a 3 input NAND gate.
39.4.3.6 Skittle alley winner indicator with
3-input NAND gate
See diagram 39.4.3.6
In a fairground skittle alley, customers try to overturn three
skittles. Each skittle stands on a small switch that it keeps closed
until it is overturned. Design a circuit that lights a lamp only when a
customer is successful. The problem is similar to 39.4.3 (e) but it
uses a 3 input AND gate. If gate 4 is omitted, the circuit is a 3 input
NAND gate.
39.4.3.7 Car doors warning light using 2-input
NAND gate
See diagram 39.4.7
Design a circuit that will cause a warning lamp on the dashboard of a
two door car to light if either of the doors is not closed. Closing a
door closes
a switch.
39.4.3.8 Light at the top of the stairs
circuit using OR gate
See diagram 39.4.3.8
In the truth table, "0" stands for LOW, and "1" stands for HIGH.
Complete the truth table to show the voltage level at each of the
lettered points for each of the level combinations at A and B. Set up
the circuit and check your predictions for the output F. If you have
made an error, use a flying lead from another LED indicator to check
your predictions for the level at each point Q, D and E. Do this by
touching the free end of the flying lead on to each of those points in
turn. The circuit is an exclusive OR gate. Note that F is high when A
or B is high, excluding the case when both are high. It is a light at
the top of the stairs circuit.
39.5.0 The bistable circuit
39.5.1.0 Bistable using two NAND gates
Use two NAND gates. Press RESET switch and note which LED is on and
which LED is off. Press and release the switch marked SET and note what
happens.
Press and release the SET switch several times and note what happens.
Press and release RESET and note what happens.
In the circuit diagram the LED indicator connected to the output of
NAND gate 1 is not drawn beneath the LED indicator of gate 2, although
that is where it is placed on the indicator module. Circuit diagrams
are easier to understand if the parts are drawn in convenient places
rather than as they are placed on the modules. The positive power rail
is drawn in the above diagram although no leads are shown connected to
it. Such a power rail may be omitted from circuit diagrams but are
included in these experiments. In this experiment when the RESET switch
is pressed, the output of NAND gate 2 goes high and the output of NAND
gate 1 is low. When the SET switch is pressed, the output of NAND gate
1 goes high and the output of NAND gate 2 goes low. The bistable
circuit has two stable states. The first stable state exists when the
output of 2 is high and the output of 1 is low (the RESET state). The
second stable state exists when the output of 1 is high and the output
of 2 is low (the SET state). After the SET switch has been pressed,
more depressions of this switch have no effect. The same is true of the
RESET switch. The SET and RESET inputs are normally high. To change
from one stable state to the other, the appropriate input must be taken
briefly low.
39.5.1.1 Two NAND gates as inverters
See diagram 39.5.1.1
Connect two NAND gates so that the output of one is joined to the input
of the other. If the second input of each gate is not used, both gates
act as inverters. If the input of the first gate is made high, its
output will be low. The input of the second gate is therefore low and
its output high. Connect the output of the second gate to the input of
the first gate, see broken line. The original high input to the first
gate provided by the flying lead is removed and the system is stable.
The high output of the second gate maintains the high input to the
first gate.
39.5.1.2 Two NAND gates with reversed
conditions
See diagram 39.5.1.2
A different situation arises if the flying lead to the first gate is
originally tied low. Since the input of the first gate is now low, the
output of the second gate is also low. Connect the output of the second
gate to the input of the first gate. Remove the original flying lead.
The system is now stable. However, the output conditions at the two
gates are reversed compared with 39.5.1.2. The system consisting of two
inverters can be connected to form two stable states.
39.5.1.3 Two NAN gates with positive
feedback link - bistable
See diagram 39.5.1.3
The second, and so far unused, input of each NAND gate can be used to
switch between the two states. The diagram shows the initial stable
state. The inputs of the first NAND gate are both high, and its output
is low. However, if the SET switch is pressed, one input of the first
NAND gate is taken low, its output goes high. The output of the second
gate therefore goes low and this low state is fed back to the other
input of the first gate. If the SET switch is now released, the system
is in the second completely stable state. Note that pressing the SET
switch a second time has no effect. The system can only be switched
back to its original state by pressing the RESET switch. The line shown
dotted in the earlier diagrams provides a positive feedback link. In
other words, the output of the system is fed back to provide an input
of the same polarity.
39.5.1.4 Bistable with complimentary
outputs, Q and Q'
See diagram 39.5.1.4
In electronics literature, the above bistable would usually be drawn as
in the diagram. The connections are identical, but the gates are shown
one beneath the other. The output of the top gate, with the SET input,
is usually labelled Q. The output of the other gate, with the RESET
input, is labelled
Q'. The two inputs and called complementary outputs because each is the
inverse of the other.
39.5.1.5 Bistable building block
See diagram 39.5.1.5
Diagram 39.5.1.5 is too complicated to use in circuit diagrams so this
symbol is in common use. The circles on the S and R input lines show
that they are active low. The S and R inputs are normally high and must
be taken momentarily low to have an effect. This bistable building
block, called an RS bistable or as an RS flip-flop has the following
properties: 1. There are two stable states: SET state (0 high, b low)
and RESET state (0 low, U high). 2. Normally the system will be in one
of its stable states. In both states the S and R inputs will be high.
3. To change from the SET state to the RESET state the R input must be
taken briefly low, If R is taken low again, nothing happens. 4. To
change from the RESET state to the SET state the S input must be taken
briefly low. If S is taken low again, nothing happens. This behaviour
can be summarized in a truth table:
| S |
R |
Q |
Q' |
| HIGH |
HIGH |
same |
same |
| LOW |
HIGH |
HIGH |
LOW |
| HIGH |
LOW |
LOW |
HIGH |
| LOW |
LOW |
avoid |
avoid |
Note that the state with both S and R low is avoided or disallowed,
since both Q and Q' are then forced to go high simultaneously and the
system will be in neither of its stable states.
39.5.1.6 Bistables and logic gates
See diagram 39.5.1.6
Difference between a bistable and a logic gate. A logic gate requires
retention of its input signals to remain in a given state. The bistable
remains in a stable state when the inputs are removed (the particular
state will depend upon which input was last taken low).
39.5.2.0 Bistable applications using NAND
gates
39.5.2.1 Latched burglar alarm
See diagram 39.5.2.1
A. Use two NAND gates, two push-button switches and a buzzer to make a
latched burglar alarm. One switch should correspond to the "trip"
switch. If this is closed (by the burglar's foot, perhaps) the alarm
should sound and stay on even when the switch is released or pressed
again. The second switch should correspond to the "reset" switch, and
would be hidden away in a place known only to the householder. Only
when this switch is pressed should the alarm be silenced.
Once you have built this circuit, convert it to an alarm that will come
on and stay on when a light, e.g. the burglar's torch, shines on an
LDR. Replace the trip switch by an LDR to make a light-activated
latched alarm. A variable resistor connected between the LDR and the
positive supply rail to form a potential divider, will allow the
sensitivity to be adjusted, 39.4.3.3. With CMOS modules, the
output of NAND gate 1 may be unable to drive both the buzzer and the
input to NAND gate 2. If this is the case, possible courses of action
are as follows:
Use a LED indicator rather than a buzzer.
B. Try to "buffer" the
buzzer by connecting it to the output of another NAND gate whose inputs
go to the output of NAND 2 in the circuit above. When the "trip" switch
is pressed, the alarm sounds and cannot be turned off by releasing the
switch or by depressing it again. You say that the output is latched.
The bistable is now locked in its second stable state (the state with
the output of the NAND gate connected to the buzzer high, and the
output of the other NAND gate low). The alarm can only be turned off by
pressing the "reset" switch. In a practical system the trip switch
might be contained in a pressure pad of the type designed especially
for home security systems. Such a pad (effectively a normally open
push-button switch) is placed under a carpet near a door so that the
switch is closed by the pressure of the intruder's foot. Pressure pads
of this kind are available.
39.5.2.2 Latched fire alarm using a bistable
See diagram 39.5.2.2
Build a fire alarm which, once triggered, will continue to sound until
it is reset. See 39.4.3.4 for information about a thermistor, and
39.5.2.1 for information about driving the buzzer.
39.5.2.3 Simple stop-go traffic lights
See diagram 39.5.2.3
Traffic in a one way street has to cross a bridge that can only have
one car on it at a time. The bridge is to be controlled by a set of
stop-go lights, activated by switches in the road, so that the lights
go red when a car enters the bridge and then green as the car leaves
ft. Design a circuit to do this job.
39.5.2.4 Traffic lights operated by an SPST
switch
See diagram 39.5.2.4
A simple set of stop-go traffic lights is to be operated by an SPST
switch so that either the red light is on or the green light is on, but
not both together. When SET is high, RESET is low and the green LED is
on. Since both inputs to NAND gate 1 are high, the red LED is off. When
SET is low, the red LED is on, and since both inputs to gate 2 are now
high, the green LED goes off.
39.5.2.5 Quiz master
See diagram 39.5.2.5
A quiz master circuit is used to identify the first contestant to push
the answer button in a quiz game. Each contestant has a push-button and
a LED indicator light. The light of the first person to answer should
come on and stay on. Simultaneously all other lights should be
prevented from coming on. Use four NAND gates two connected as a
bistable, a push-button switch and a LED indicator. Complete the wiring
of the four gates for one contestant then wire for another contestant
separately. Finally connect the two sets. If the B inputs of the two
quiz stations are taken low, the bistable circuit formed by the two
right hand gates will be reset. So the 5 outputs at the stations are
high and the LEDs are off. At the station of one contestant, the A
input will initially be high because it is connected to the output of
the other station, which has just been reset. The A input effectively
"opens" the NAND gate to which it is connected, so if this contestant
is the first to press his or her switch, the bistable is set by a low
pulse and the LED indicator comes on. At the same time 0 goes low, and
since this output is connected to the A input of the other station, the
NAND gate controlled by this A input is closed. This means that a low
going pulse from the other contestant's push-button can pass to his or
her bistable. The bistable therefore remains in the reset state with
the indicator light off. You can build a simpler quiz master station
using fewer NAND gates but they may not have the required properties of
simultaneously latching the victor's indicator LED and permanently
disabling the switches of all other contestants.
39.6.0 Drivers
Drivers are essential to drive heavy current devices such as motors so
an operational approach to drivers follows.
39.6.1.0 Loading an output
See diagram 39.6.1
Set up the first circuit. Note what happens when you press the
push-button. When the switch is closed, note whether the output of the
NAND gate high or low. Replace the LED with an electric motor module as
shown in the second circuit. Note what happens when you press the
push-button. To investigate why the motor did not operate in (3),
connect a LED in parallel with the motor as shown in the third circuit.
Note when you press the push-button. Note whether the output of the
NAND gate is still high as in or is it now low. The experiment
shows that a logic gate operates satisfactorily only when small
currents of a few milliamperes are used because a larger current for
the motor may change the logic level of the output. The next experiment
shows that this difficulty is overcome using a driver. Use a LED in
series with a 33 M resistor.
39.6.2.0 Using a NAND gate to switch an
electric motor on or off
See diagram 39.6.2
Use the Driver Amplifier module and the reed relay. Note what happens
when the switch is pressed. When the switch is pressed, note whether
the output of the NAND gate is high or low. The driver amplifier is a
special kind of inverter. When the switch is pressed, note whether its
output is high or low. The relay is connected between the positive
supply line and the output of the driver. The motor operates when a
current flows through the relay coil. When this happens note whether
the output of the driver is high or low. Replace the switch by an LDR.
Note what happens to the motor when the LDR is covered or
uncovered.
39.6.2.1 Inverting driver amplifier
See diagram 39.6.2.1
The function of a driver is to provide an interface between a device
such as an integrated circuit that can control only a small current,
and a device, such as a relay or an electric motor, which usually
requires a large current for its operation. The simplest and cheapest
inverting driver amplifier consists of a single transistor and one
resistor. A relay and its protective diode, essential when switching
inductive loads, would then be connected between the positive supply
line and the transistor collector in the way shown. When the transistor
input goes high, the collector current flows through the relay coil
into the transistor. Use two transistors connected as a Darlington
pair. The current gain of such a system is far higher than that of a
single transistor, and the base current needed to switch the collector
current on is then easily supplied by the high output of any integrated
circuit.
Note that the circuit diagram shows the motor being driven by a
separate power supply. If separate supplies are not available, the
motor may be driven by the supply used for the modules, provided, of
course, that this supply can deliver the necessary current. It is a
wise precaution to connect a 1000 muF capacitor between the power lines
in those circumstances.
39.6.2.2 Driver amplifier with relay omitted
See diagram 39.6.2.2 (a) and (b)
The driver amplifier operates a relay that controls the motor. The same
job, of course, could be done in other ways. In diagram 39.6.2.3 the
relay is omitted entirely when the motor current does not exceed the
maximum current allowed by the driver. However if the motor and the
logic circuitry share the same power supply this would disadvantage
CMOS integrated circuits where only a small battery is needed for the
ICs. A motor would soon run this flat, or might not operate at all. In
diagram 39.6.2.4 the driver is omitted. Reed relays are available which
will operate satisfactorily off a low voltage supply with a coil
current of only a few milliamperes, and these can be operated directly
using the logic gate output. However, a disadvantage of this type of
relay is that the contact ratings are often small, and could possibly
overheat when used with a motor requiring a large current.
The current need of the device to be operated by the relay lies within
the current rating of the relay contacts.
39.6.3.0 Applications involving the driver
amplifier and reed relay
39.6.3.1 Reversing an electric motor
See diagram 39.6.3.1
Using a push-button switch, a NAND gate and the driver amplifier and
reed relay, set up a circuit so that the direction of rotation of a
motor is reversed when the switch is pressed. Three batteries will be
needed, one for the modules and two for the motor (see 39.2.7). The
NAND gate is not necessary if the switch is connected between the
driver input and the positive supply rail (see 39.6.3 (b)).
39.6.3.2 Reversing an electric motor with a
bistable circuit
See diagram 39.6.3.2
Using two push-button switches, two NAND gates, a reed relay and the
driver module, set up a circuit that reverses the direction of rotation
of a motor when one switch is pressed and released. Three batteries
will be needed, one for the modules and two for the motor (see 39.2.7).
Use a low value resistor connected in series with the motor supply to
prevent a shot circuit of the motor supply. The resistor value must be
low enough not to interfere with the operation of the motor.
The two NAND gates form an RS bistable, The contact of the relay switch
will be in the lower position when 0 is low, and the motor will rotate
in a certain direction. When the bistable is switched to its other
state, 0 goes high, the relay operates and the switch goes to the
higher position. This reverses the polarity of the supply to the motor
that now rotates in the opposite sense. So a reversal occurs every time
the bistable is switched.
39.6.3.3 Automatic light
See diagram 39.6.3.3
Use a driver module, a reed relay, an LDR and any necessary gates, to
make a circuit in which a filament lamp will come on automatically in
the dark.
Use a very bright lamp, e.g. 12 V 3 W lamp or 12 V 0.1 A MES bulb to
show that this circuit is controlling a much larger power than the
circuit of 39.4.3 (c). If a variable resistor is used to adjust the
sensitivity so that the lamp is just on, and the lamp is moved to
illuminate the LDR, the circuit becomes astable because light from the
lamp reduces the LDR's resistance. This switches the lamp off. The fall
in light intensity then causes the circuit to switch the lamp on
again.
39.6.3.4 Motor vehicle moving backwards and
forwards between two light beams
See diagram 39.6.3.4
Use the circuit of 39.6.3.2 with two inverters and two LDRs to make the
motor reverse every time a light beam is interrupted. The point about
this application is that, when illuminated, the resistance of the LDRs
will be low. So they cannot be connected directly to the SET/ RESET
inputs of the bistable, since these must both be high. The answer is to
use inverters between the LDRs and the SET/RESET inputs. The
application has greatest impact if a motor with wheels is available.
Two long leads are attached to the motor and connected to the
appropriate points in the circuit. If the LDRs are set up in the way
shown above and illuminated by pencil torches, the vehicle should
oscillate happily backwards and forwards between the light beams. A 4.5
V LEGO motor from technical set 107 can be fitted with wheels and works
well. A length of LEGO railway track along which the vehicle will run
is also useful.
39.7.0 Coding
39.7.1 Sending messages using a 4 bit binary code
See diagram 39.7.1d | See 38.7.03.4: ASCII code
Connect a flying lead to each of the four inputs of the LED Indicator
module. The LEDs are turned on or off by taking the flying leads at the
inputs high or low. When an input is high and the corresponding LED is
on, you will let it represent the binary digit 1. When an input is low
and the corresponding LED is off, you will let it represent the binary
digit 0. Note that the term binary digit is usually shortened to bit.
The four LEDs can therefore represent a 4 bit binary pattern. The
experiment shows that a 4 bit binary pattern can represent
non-numerical information if an agreed code is used, e.g. the 7 bit
ASCII code (American Standard Code for Information Exchange). Invent a
4 bit binary code for sending messages. Write your code in a table. A
few words have been added to start off. How many words can you
represent with a 4 bit pattern? Give a copy of your code to another
group, and then send them a message using the LED indicators. Send the
message, word by word, by lighting the agreed 4 bit binary pattern for
each word. Apart from a copy of your code, what other information did
you have to give the other group before they were able to decode your
message? When using any binary code, numerical or non-numerical, you
should know which is the LSB (least significant bit) and which is the
MSB (most significant bit). In these experiments the LSB is shown on
the right when binary patterns are written horizontally according to
the normal conventions for numbers, i.e. represents the number 13 in
the scale of 10 (decimal) notation.
| MSB |
- |
- |
LSB |
| 23 |
22 |
21 |
20 |
| 1 |
1 |
0 |
1 |
The binary digit 1 represents a high logic level, and the binary digit
0 represents a low logic level. Encoding means that information is put
into a binary pattern. For numerical information, encoding usually
means changing from a scale of ten, decimal, to a binary notation. In
decoding the information is extracted from the binary pattern. With
numerical information, this means changing from a binary to a scale of
ten, decimal, representation.
39.7.2 Seven-segment LED display
See diagram 39.7.2
Use the seven-segment LED display on the Seven Segment Display module
for this experiment. The display has seven segments, labelled a to g in
the diagram. A single segment behaves like an ordinary LED, and lights
when current flows from positive (anode) to negative (cathode).
Inside this common cathode display, all the cathodes are connected and
to a single lead, the common cathode lead, which is connected to the
negative supply line.
Connect a flying lead to the point marked TEST and touch the other end
on to the pins marked a to g, one at a time. Note what happens. Copy
the tables below and complete them to show how you would display the
digits 0 to 9. Use the Display/Decoder module with a flying lead.
Insert a safety resistor between the test point and the supply line to
limit the current and prevent any damage to the display in case of
direct contact between the flying lead and wires on the display side of
the other resistors. For extra safety feature locate the terminal pins
on the decoder side of these resistors to prevent damage to the display
if any direct contact between a terminal pin and the positive rail
which would damage the module. To check answers to the questions
connect the terminal pins directly to the appropriate power supply rail
because the current flowing through each segment also flows through the
resistor in series with the test socket. Eventually the voltage drop
across this resistor is too large to allow sufficient current to flow
to light the segments clearly. However do not make direct connection of
the decoder/driver outputs, the terminal pins, to the power rail.
39.7.3 Seven-segment display with a decoder
See diagram 39.7.3
Use the Seven Segment Display module and the four decoder inputs to
light the display. Use flying leads to take the decoder inputs (A, B, C
and D) high or low. Let a high input represent the binary digit 1, and
let a low input represent binary digit 0. Use the flying leads to
complete the tables. When the digit 1 is displayed, segments b and c of
the display are In. Which outputs of the decoder must then be low, and
which outputs are high?
As there are four inputs (A, B, C and D) to the decoder, 24
or 16 separate messages can be transferred. When the binary number 0000
is received, the decoder gives the message that a, b, c, d, e, f should
light and the number 0 is displayed. When the input 0001 is received
the message goes out that b and c should light and hence the number 1
displayed. With a common cathode module, the inputs b and c are high,
and all the others low. The integrated circuit used in this experiment
is called a BCD to seven segment decoder/driver. (BCD stands for
"Binary Coded Decimal"). The input is a decimal digit in the binary
code (i.e. 0000 to 1001) and the decoder decodes the input to drive a
seven segment display.
In practice, a BCD to seven segment display decoder may or may not
respond to the numbers beyond 1001 (that is, from 1010 to 1111)
depending on the particular integrated circuit used. For the
recommended CMOS decoder/driver, the display will be blank beyond 1001.
In digital electronics an N bit binary code is said to be completely
decoded if 2N distinct output signals are produced from N
input signals. In each case every possible binary pattern present on
the input lines activates a distinct output line. With two inputs there
are four possible binary patterns (00, 01, 10 and 11) and so four
output lines are required. With three inputs, eight output lines are
required. With four inputs 16 output lines are required. So N inputs
require 2N outputs for complete decoding. In some computers
with 16 lines from the microprocessor to the computer memory each
memory location is identified by a different binary pattern present on
these lines. Also, a separate and unique signal must be generated for
each location when it is selected for the storage or retrieval of
information. If you completely decode the 16 memory input lines, you
can generate 216 = 65536 distinct signals to select memory locations.
So some microcomputers have a memory size of 64 K where 1 K = 1024. So
64 K means that there are 64 x 1024 = 65536 memory locations. The BCD
to seven segment display decoder used earlier is not a complete decoder
since R has 4 inputs, but only 7, not 16, outputs so it is a partial
decoder.
39.7.4 Two-line to four-line decoder from NAND
gates
See diagram 39.7.4
In diagram 39.7.4.1 two inputs labelled X and Y which are inverted by
NAND gates 1 and 2 to produce x' and y'. In 39.7.4.2 an AND gate is
formed from NAND gates 3 and 4, with two inputs A and B.
If X = 0 and Y = 0, how do you connect A and B to light the LED? How do
you connect A and B to light the LED K X = 0 and Y = 1? How do you do
it if X = 1 and Y = 0? How do you do it if X = 1 and Y = 1? Build the
circuits and check your predictions. Use your results from above to
draw a circuit diagram of a 2 line to 4 line decoder. Build the decoder
with NAND gates. NAND gates with 3 inputs are also available in
integrated circuit form (the output is low only when all 3 inputs are
high). Draw a circuit diagram showing how a 3 line to 8 line decoder
could be built from 2 input and 3 input NAND gates. A 3 line to 8 line
decoder can be built using 2 input NAND gates only. How many of these
gates would be required? Gate 4 provides the high output to light
the LED and is not essential to the decoding function. Integrated
circuit decoders are often available with high or with low outputs and
the choice between these depends on the task the decoder is to perform.
This 2 line to 4 line decoder uses ten NAND gates. To build the decoder
with low outputs only six NAND gates are required. Use voltmeters to
detect the logic levels. A 3 line to 8 line decoder would require three
NAND gates to invert the three inputs X1, Y1 and Z1 to produce X2, Y2
and Z2. Eight 3-input NAND gates would then be required to produce a
distinct low output for each of the eight possible combinations of X, Y
and Z at the decoder inputs. If high outputs are preferred to light
indicators, a further eight NAND gates connected as inverters would be
needed. Since three 2-input NAND gates are required to produce one
3-input NAND gate, a total of [3 + (8 x 3) + 8] = 35 two input NAND
gates would be required to produce a 3 line to 8 line decoder with high
outputs. Such decoders are available as single integrated
circuits.