In entry 4, we designed an SR latch using two NOR gates on an 74LS02 chip. This latch is also called an RS latch, S-R latch, or a NOR latch.
Building a NOR latch using ACEL
This is the NOR latch from entry 4:
It has the following function table:
where NC means "no change". Letting S = R = 1 is not used (it is said to cause a "race" condition).
I want my Arduino to become two NOR latches with connections as in the figure above. Then I connect buttons to Set and Reset and an LED to Q:
This is the code to build a NOR latch. Pin 2 is connected to R, pin 3 to S and pin 4 to Q (I am not outputting Q-bar).
This will turn your Arduino into a NOR latch. Connect pin 2 to a button (reset), pin 3 to a button (set) and pin 4 to an LED and we have the same setup as in entry 4, but where Arduino replaces the 74LS02.
You can also check this out on Wokwi.
ACEL has a print function which allows you to see the state of all chips and pins on your screen. You hook up a "print" button to one pin of the Arduino, say pin 13. You then add the following three line to the setup():
In order for the printout to be more clear, you can name your gates :
If you click the print button when Q = 0 and S is pressed, you see
This makes sense.
- X2 on lower NOR (Set) is 1.
- This will make Lower Y = 0.
- This will make Upper X2 = 0
- This will make Upper Y = 1
- This will make Lower X1 = 1
You can play around with this on at Wokwi project "NOR latch (SR latch)".
The NOR latch
The two nor gates, with connections, is combined into one ACEL component called the NorLatch. The NorLatch has
- Input pin: Set
- Input pin: Reset
- Output pin: Q
- Output pin Q_Bar
See also the ACEL page. The Wokwi project "NOR latch (SR latch)" also has the NorLatch so that we can see that it does the same as the one constructed from two NOR gates. This is the symbol often used for a NOR latch:
The NAND latch
The NAND latch is similar to the NOR latch. This is the schematics of a NAND latch:
The design is the same as the NOR latch, but with two NAND gates instead of two NOR gates. Remember the function table of the NAND gate:
It is not hard to see that the NAND latch has the following function table:
Set and Reset works the same as in a NOR latch, setting or resetting Q. However, now the R = 0, S= 0 is unused while R= 1, S= 1 means "no change". Here is a commonly used symbol for the NAND latch, or the SR latch designed from NAND gates:
I have not made a Wokwi project for the NAND latch. You can do it yourself starting from the project "NOR latch (SR latch)", replacing NorGates with NandGates. Acel has a NAND latch, called NandLatch. The pins are the same as for the NorLatch.