Microbit Programable Logic Gates
Introduction: Microbit Programable Logic Gates
When you think of logic gates what comes to mind, small packages containing combinational or sequential logic elements, building blocks with which to build more complex circuits.
However, there construction is not limited to integrated circuits but could be made from any number of different elements; relays, optical or pneumatic.
But regardless of the construction the basic logic functions can be implemented and used to enable more complex functions and circuits.
In this case rather than using any of the options previously mentioned the logic gates will be created using a microcontroller.
The versatility of the microcontroller allows it to be used to create any of the logic functions not just virtually but physically and even replacing a gate in a circuit as a temporary solution.
All of the basic logic functions (NOT, AND, OR, XOR, NAND, NOR and XNOR)*, will be realised in a single Microbit with real time input and output status monitoring.
*Each function will be described individually.
Enabling the selection of a single logic function that the Microbit will emulate.
Connecting multiple Microbit's configured as different logic functions will enable more complex logic circuits to be created..
Consideration has to be given to identifying the different logic functions selected so that it clear to the user.
However, the 5x5 LED display is limited in the detail that can be presented and as such has dictated that displaying logic symbols be as simple as possible.
Electronic logic symbols were rejected in favour of Boolean algebra symbols which require less detail.
Boolean algebra is concerned with the expression binary decisions where the states are either 0 (false) or 1(true).
In addition the input and output states will also be displayed in real time.
Supplies
Microbit V1 & V2
Step 1: Digital Logic
By digital logic we are referring to an electrical system that makes use of two distinct voltage levels to encode information.
In this case a binary system of 0's and 1's were 0 is a low voltage and 1 is a high voltage.
The 0's and 1's can be represented by switches which are either ON (1) or OFF (0) but beyond these simple actions these switches are combined to create more complex building blocks.
These building blocks are NOT, AND, OR, XOR
The NOT (negating/inverter), function when added to the output of the AND, OR & XOR creates the NAND, NOR & XNOR.
These logic functions are unidirectional meaning that changes at the input only affect the output.
All these basic functions only have one output.
The NOT gate only has one input whilst the other gates have a minimum of 2.
The NOT output from a digital logic perspective is in the opposite state to the input.
If the input is ON the output is OFF and if the input is OFF the output is ON.
Each function will be represented by symbols
Function Symbol
NOT -
AND ^
OR v
NAND ⊼
NOR ⊽
XOR ⊻
XNOR ⊙
{Multiple symbols exist for the same logic function the availability subject to fonts and whether graphics or text. This is particularly evident with the XOR/XNOR functions.}
For the other gates, combinations of the two inputs produce an output subject to the truth table
The truth table lists the input combinations and the corresponding output state.
Step 2: Logic Levels
In this context we are referring to two distinct voltage states which represent the binary states of 0 and 1.
The 0 (Low = L), would be represented by a low voltage and the 1 (High = H), by a high voltage.
The voltage for the logic levels varies depending on the type of logic family.
In this case as we are using a Microbit with a supply voltage of 3.3V.
However, the inputs have logic thresholds which minimise the effect of variation in the voltage level due to finite variation in voltage accuracy and noise.
The logic input high level (VIH), is recognised as such if the input voltage is > ~1.8V*. (maximum 3.3V)
The logic input low level (VIL), is recognised as such if the input voltage is < ~1.4V*. (minimum 0V)
*Voltage levels as measured on an actual Microbit using a potentiometer to vary the input voltage.
If you are dealing with logic from the same family, logic thresholds will be compatible and can simply be reference as 0 = Low or 1 = High.
But if interfacing to different logic families the voltages become important and voltage level shifting ensures that the logic levels between the different logic families maintains correct function.
As we will be dealing purely with the Microbit no other logic families will be involved and therefore there will be no need for voltage level shifting. 134