# Logic gates

It might be useful to have an electronic circuit that would:

Switch on a water pump on a hot sunny day
Sound an alarm if the pilot light of a boiler went off
Sound an alarm if a burglar stepped on a pressure pad or shone his torch
Switch a light on if it was a cloudy day
Add two simple binary numbers together
Switch on a fan if a darkroom door was shut and it was warm inside

All these things and indeed many more can be done with ELECTRONIC LOGIC CIRCUITS.
These circuits are ones that can make decisions. Different decisions need different circuits.

Think about just two of the examples:

The hot sunny day.
To switch on the pump it must be hot AND sunny. This needs an AND circuit.

The burglar alarm.
To sound the alarm the burglar has to step on the pressure pad OR switch on his torch. This needs an OR circuit.

A summary of how each circuit behaves is called a TRUTH TABLE and the circuits themselves are usually called LOGIC GATES.
The truth tables and symbols for the most common logic gates are shown below.

## Summary of the use of the NAND gate

One of the most useful circuits in school electronics is the NAND gate and so we will think about what it does in a little more detail.
(a) it has two inputs - if either (or both) these are 0 then the output is 1 (high) , but if both are 1 the output is 0 (low)
(b) a flying lead (unconnected input) is high (1)
(c) the output current from the NAND gate will only be a few milliamps. It will therefore operate a buzzer with difficulty but will NOT operate a motor (the motor will need hundreds of milliamps)
(d) you will need a driver relay module (see later) to operate the motor from a NAND gate.

## Making other logic gates from NAND gates

The circuits below show you how to make a NOT, OR, NOR and AND gate using NAND gates.

We will consider one in detail, the NOT gate or INVERTER. This is a circuit that gives a high output (1) for a low input (0) and a low output (0) for a high input (1). With the two inputs of the NAND gate connected together this is just what will happen.

STUDENT INVESTIGATIONS
Design and construct circuits using NAND gates that will do the following things:
(a) switch a light on when it gets dark
(b) switch a light on when it gets light
(c) detect when an object is longer than a certain length
(d) switch on a warning light when either of the two front doors of a car are open
(e) sound a buzzer if there is a person sitting on the front seat of a car and the ignition key is turned
(f) sound a buzzer when all three coconuts on a coconut shie have been knocked off
(g) switch a light on if a safe door has been closed but not locked
(h) switch on a buzzer when the temperature of a room falls below a certain value

STUDENT INVESTIGATION
How low does the input voltage of a NAND gate
have to be before the output becomes high.
Use the circuit shown in the diagram to test this.

## Applications of the NAND gate

(a) Burglar alarm
When the switch is closed one input of the NAND gate is LOW. When the LDR is in the light the other input is LOW. This means that if either of these things happen, i.e. the switch is closed or the light is on one of the inputs is LOW, the output is HIGH and the buzzer sounds.

(b) Freezer warning buzzer
When the thermistor is COLD its resistance is LARGE and the input to the NAND gate is high.
Since the NAND gate is connected as an INVERTER the Output is LOW.
As the thermistor warms up its resistance decreases, the voltage across it falls and the input to the NAND gate falls.
When it becomes low enough the output becomes HIGH and the buzzer sounds.

How would you adjust the temperature at which the buzzer came on?

## The driver-relay module

You will find that the output from the NAND gate is not sufficient to run a motor, it may not even be enough to operate a buzzer if the batteries are at all flat. (The NAND gate output current is a few milliamps while the motor requires many hundreds of milliamps to run it)

You can overcome this problem with the DRIVER RELAY module. This allows a small current to operate a switch that will allow a much larger current to flow in another circuit.
The applications of the driver include:
(a) running an electric motor
(b) reversing an electric motor
(c) switching on a 12V 1.2W lamp for automatic light with a NAND gate

A VERSION IN WORD IS AVAILABLE ON THE SCHOOLPHYSICS CD

© Keith Gibbs 2020