Close
0%
0%

Microbit Programmable logic Gates

Using a Microbit to realise the basic 2 input logic functions

Similar projects worth following
0 followers
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.

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.

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.

Connections

he physical connections to the Microbit for the logic function use Analog inputs P0 and P1 and Digital output P2.

Enabling one or two input logic functions all with a single output.

Layout

The Microbit display is divided up into input, output and symbol area.

Button A - Selects a logic function and shows the symbol on the display.
Button B - Shows the truth table for the logic function selected with Button A

Button A+B - Enabled or disables the output at P2 whilst retaining live update at LED 4,4

Column 1 shows the inputs to the logic function with LED's at co-ordinates 0,1 (input a) & 0, 3 (input b)

Column 5 shows the status of the logic function output with LED at 4,2 (output).

When an input or output LED is lit it indicates a logic 1 (High) and when extinguished logic 0 (Low).

Columns 2 to 4 show the symbol for the selected logic function.

AND gate example:

This shows the input LED's with a logic 1 (High) at both inputs.

This shows the output LED with a logic 1 (High).

The symbol display area of 3x5 LED's shows the AND function.

Gates

NOT (Inverter)

Press button B for the truth table of the gate currently selected....

Read more »

microbit-logic.hex

Microsoft block code

hex - 1.41 MB - 10/01/2021 at 20:34

Download

  • 1 × Microcontroller Microbit V1 or V2

  • 1
    Operation and Usage

    Power up the Microbit and load the Hex file.

    Press button A to select the required gate and its Boolean symbol will be displayed.

    An input left unconnected or connected to 0V(GND), represents a logic 0.

    An input connected to ~3V represents a logic 1.

    The input and output states will be displayed in real time.

    The logic truth table for the selected function can be displayed at any time by pressing Button B, this will remain visible for 2 seconds than revert back to the live display.

    Pressing buttons A+B enables or disables live changes to the output at P2 and is indicated by the LED at 4,4 lit when disabled and unlit when enabled.

    The display will reflect the logic status whether the output at P2 is enabled or not.

    A different gate can be selected by pressing button A.

    With a single Microbit you can evaluate the basic functions in isolation.

    The example shows a NOT gate with a low input and corresponding high output

    If you wish to experiment with more complex functions you will need to use multiple Microbits.

View all instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates