Now Reading
Technoblogy – Logic Lab

Technoblogy – Logic Lab

2023-08-24 07:10:41

Logic Lab

18th Might 2023

The Logic Lab offers a collection of 12 logic gates that you may interconnect with patch cables to make quite a lot of completely different logic circuits, for experimenting with and studying about logic:

LogicLabCables.jpg

The Logic Lab permits you to experiment with logic gates by interconnecting them with patch cables.

You’ll be able to enter inputs utilizing switches, and show the outputs on 5 colored LEDs. The entire Logic Lab is applied utilizing a single AVR128DA48 (or ATmega4809) microprocessor and some LEDs and different passive parts, with a complete elements price of underneath £20 or $25.

I’ve included 9 logic issues that you may attempt fixing with the assistance of the Logic Lab.

Introduction

I initially determined to construct this for a buddy’s son who was thinking about studying about logic gates, and I believed he would get pleasure from having one thing that he might use for sensible experiments. I had a design in thoughts, and searched to see if something comparable already existed; the closest I discovered was a package developed by the College of Southampton within the UK [1], however it wasn’t commercially accessible.

My first thought was to make use of 74LVC sequence logic gates, that are particular person logic gates in small surface-mount packages. The great factor about that is that every drawing of a logic gate on the PCB can be applied by a single gate.

Nonetheless, I then thought of utilizing the Configurable Customized Logic (CCL) within the AVR DA-series microcontrollers, which lets you configure three-input gates that work independently of the processor. The benefit can be that you may reconfigure the collection of gates in software program, with no need to resolder the board. Nonetheless, even the most important 64-pin units solely present six logic gates, and within the 48-pin packages plainly solely 5 of those are literally accessible on I/O pins.

My remaining design used an ATmega4809 or AVR128DA48 microcontroller, however simulating the gates by polling the inputs, and setting the outputs accordingly, utilizing reality tables saved in this system. With a 48-pin package deal it will be doable to emulate at the least 12 gates of various varieties, which might be ample for the design I had in thoughts. This method would can help you change the collection of gates accessible by importing a brand new model of the software program, after which making stickers to point out the brand new gate symbols.

Regardless that the logic gates are simulated utilizing a microcontroller, the one detectable distinction is the propagation delay. You’ll be able to even create an oscillator by connecting the output of one of many inverters again to its enter.

Description

The Logic Lab has the next options:

  • 12 logic gates: two AND, two NAND, two OR, two NOR, two XOR, and two inverters.
  • 4 slider switches, S1 to S4, with LEDs to point out the standing, that may present logic inputs to the gates.
  • 5 colored LEDs, L1 to L5, that may show the state of the output from a logic circuit. The highest three are pink, orange, and inexperienced, permitting simulation of site visitors lights.
  • Two busses, J1 and J2, that can be utilized to hyperlink patch cables collectively.
  • It’s powered by two AAA batteries, with an on/off swap and energy indicator LED.
  • The inputs and outputs are linked to header pins, so you possibly can interconnect them with a set of patch cables terminated in header sockets.

LogicLabFront.jpg

The entrance panel of the Logic Lab.

Logic issues

Listed here are 9 pattern logic issues that you may attempt fixing with the Logic Lab. These can every be solved utilizing the twelve gates within the Logic Lab. I’ve given an approximate issue ranking out of 100 for every drawback.

For the solutions to the issues see Logic Lab Problem Answers.

Visitors lights (20%)

Visitors lights (within the UK) undergo the next sequence:

S1 S2 Lights
0 0 Crimson
0 1 Crimson and Orange
1 0 Inexperienced
1 1 Orange

Design a logic circuit that lights the pink, orange, and inexperienced LEDs based on that sequence of switches.

Unique-OR (30%)

Two of the gates within the logic lab are exclusive-OR, or XOR, gates; their output is ‘1’ if both of the inputs is ‘1’, however not each.

Design an exclusive-OR gate with out utilizing the XOR gates, by utilizing a mixture of the opposite gates within the Logic Lab.

Security swap (40%)

A faculty has a hearth warning mild that lights up in each classroom. To keep away from it being unintentionally switched on it has 4 switches, all of which must be turned on earlier than the warning will mild up.

Design a logic circuit that implements this: the pink LED, representing the warning, ought to solely activate if all switches are set to ‘1’.

Palindrome checker (40%)

Design a circuit that lights the inexperienced LED if the 4 switches are set to a binary quantity that is a palindrome, akin to ‘1001’, and the pink LED if it is not a palindrome, like ‘1011’.

Resort mild switches (60%)

In a resort 4 rooms are on the identical hall, and there is one mild in the course of the hall. There is a swap exterior every room that can be utilized to regulate the sunshine.

Design a circuit that enables every of the 4 switches S1 to S4 to show the sunshine L5 on or off.

Binary decoder (70%)

Design a circuit that lights up simply one of many 4 LEDs L1 to L4 for every of the completely different doable settings of switches S1 and S2:

S1 S2 Lights
0 0 Crimson
0 1 Orange
1 0 Inexperienced
1 1 Blue

Majority vote (80%)

When the key spy membership must vote on a problem, the three members every have a button that they press to register their vote. If there’s a majority vote, the difficulty is handed.

Use three switches to signify the votes, and design a circuit that may mild the inexperienced LED if the bulk vote ‘1’, or the pink LED if they do not.

Mixture swap (90%)

You could have a drawer with an digital lock, and it could possibly solely be opened in the event you set the right password on 4 switches. Design a logic circuit that permits you to select any of the 16 doable passwords, akin to ‘1011’, by altering the place of 4 patch leads. The circuit ought to then solely mild up the inexperienced LED in the event you set the right password on the switches.

Binary adder (100%)

Design a circuit that may add collectively two 2-digit binary numbers, and put the reply in binary on the three LEDs L3 to L5.

The primary quantity must be on S1 (excessive bit) and S2 (low bit), and the second quantity must be on S3 (excessive bit) and S4 (low bit). The reply must be on L3 (excessive bit), L4 (center bit), and L5 (low bit).

The circuit

Here is the complete circuit of the Logic Lab:

LogicLab.gif

Circuit of the Logic Lab, primarily based on an AVR128DA48 or ATmega4809 processor.
Click on to open a bigger model in a brand new window.

There’s fairly a large alternative of pin-compatible microcontrollers you need to use for this mission, which ought to assist whereas most of the hottest elements are nonetheless out of inventory at time of writing. I constructed two prototypes, one with an AVR128DA48, and one with the older ATmega4809 which is pin appropriate, and their efficiency was indistinguishable. This system solely makes use of about 1500 bytes, so an ATmega809, ATmega1609, or ATmega3209 must be superb. Likewise, an AVR32DA48 or AVR64DA48 must be superb, or the equal AVR32DB elements.

I used 0.1″ pitch header pins for the inputs and outputs, and patch leads terminated in header sockets. The benefit of that is that you may purchase the header pins in lengthy strips, after which lower them right down to the lengths you want; the header sockets are harder to divide up.

The 5 output LEDs are 5mm subtle through-hole LEDs in 5 completely different colors. In my first prototype, proven within the pictures, I used a white LED, however discovered that as a result of white has the next ahead voltage than the opposite colors, in the event you join each white and one of many different LEDs to the identical output the white is way dimmer. I due to this fact changed white with yellow to keep away from the issue.

The opposite LEDs and resistors are 0805 measurement SMD varieties.

The circuit is powered by two 1.5V AAA batteries in sequence, mounted in through-hole battery clips on the again of the board. Alternatively you may use two PCB-mount AAA battery holders [2] which slot in the identical mounting holes.

Brief-circuit safety

The board contains 100Ω present limiting resistors on each output, so if the consumer inadvertently connects collectively two outputs at completely different logic ranges, the present will probably be 3/(100 + 100) or 15mA, which is nicely throughout the 50mA per output most given on the information sheet.

Unconnected inputs

Unconnected inputs are handled as being at logic-level ‘0’. That is applied by a 10kΩ pull-down resistor on each enter.

For those who choose to have unconnected inputs at logic stage ‘1’ (like TTL) you possibly can omit these resistors, and activate the interior pullup resistors by configuring the inputs as INPUT_PULLUP in setup().

Patch cables

To make use of the Logic Lab you may want a set of at the least 20 jumper wires terminated in header sockets. I like to recommend 150mm lengthy cables; both ribbon cables that you may separate to create a set of jumper wires [3], or barely costlier separate cables [4].

► Parts list

Building

I designed a PCB in Eagle and ordered boards from Elecrow [5]. The board is 100 x 140mm, utilizing a double-sided PCB. I additionally created a design for a again panel and ordered this in 2mm thick clear acrylic [6]. I give hyperlinks on the finish of the article so you possibly can order your personal boards.

The one commonplace I might discover for drawing the logic symbols was a USA Division of Protection doc from 1962, which describes how to attract them from arcs of circles [7].

For my first try at designing the PCB I assigned the logic gate inputs to the microcontroller ports in a scientific approach, with all of the AND and NAND gate inputs on one port, all of the OR and NOR gate inputs to a different port, and so forth. Nonetheless, the format was a nightmare, and I wanted a variety of vias to make it work. I made a decision to have a second try merely selecting the closest I/O pin to every gate enter or output, with the concept I might type out in software program, and I managed to put it out way more neatly with no vias.

Here is a information to the project of I/O pins to the gate inputs and outputs:

LogicGatePins.gif

My beneficial sequence for assembling the board is as follows:

  • Solder the microcontroller on the again of the board utilizing a scorching air gun.
  • Solder the SMD resistors and capacitors to the again of the board, and the SMD LEDs to the entrance of the board, utilizing the new air gun.
  • Match the the header pins to the entrance of the board with a traditional soldering iron.
  • Mount the switches and 5mm LEDs with a soldering iron.
  • Match the three-pin header socket on the again of the board with a soldering iron.
  • Lastly, match the battery holders with a soldering iron, utilizing a beneficiant quantity of solder to carry them firmly in place.

For the SMD parts I used a Youyue 858D+ scorching air gun set to 300°C.

When becoming the header pins I did them a column at a time, and located it useful to push them into one thing like a 1×36 header socket [8], to maintain them appropriately aligned and vertical.

When mounting the battery clips I discovered I needed to enlarge the mounting holes with a 2mm drill to get the clips to suit. You will not want to do that in the event you use the PCB-mount AAA battery holders [9].

LogicLabBack.jpg

The again of the Logic Lab PCB, exhibiting the ATmega4809 processor and battery holders.

See Also

I mounted the clear acrylic again panel with 15mm nylon pillars [10] and M3 6mm nylon screws [11].

This system

For every gate this system merely reads the inputs, and units the output based on the reality desk for the logic gate.

I thought of utilizing interrupts, however I made a decision to go along with the easier method of repeatedly stepping by the gates, processing them in sequence. This system would not have anything to do, so there is no want for interrupts.

Fact tables

The reality desk for every of the completely different gate varieties is outlined by an enum:

enum truthtable_t: uint8_t { AND = 0b1000, NAND = 0b0111,  OR = 0b1110, 
                             NOR = 0b0001,  XOR = 0b0110, NOT = 0b0011 };

Logic gate definitions

The definition of every gate is a struct, gate_t:

typedef struct {
  int inputa;
  int inputb;
  int output;
  truthtable_t truthtable;
} gate_t;

This defines the pin numbers used for the 2 inputs and the output, the worth to be output, and the kind of logic gate.

Listed here are the definitions of the 12 gates within the Logic Lab:

gate_t gates[12] = {
  { PIN_PC1, PIN_PC0, PIN_PC5, AND },
  { PIN_PB5, PIN_PB4, PIN_PC4, AND },
  { PIN_PB1, PIN_PB0, PIN_PA3, NAND },
  { PIN_PA6, PIN_PA7, PIN_PA2, NAND },
  { PIN_PC7, PIN_PC6, PIN_PD2, OR },
  { PIN_PC3, PIN_PC2, PIN_PD3, OR },
  { PIN_PA5, PIN_PA4, PIN_PF2, NOR },
  { PIN_PA1, PIN_PA0, PIN_PF3, NOR },
  { PIN_PD4, PIN_PD5, PIN_PE0, XOR },
  { PIN_PD6, PIN_PD7, PIN_PE1, XOR },
  { PIN_PF0, PIN_PF0, PIN_PE2, NOT },
  { PIN_PF1, PIN_PF1, PIN_PE3, NOT },
};

For simplicity I outline the NOT gate as a two enter gate the place each inputs are the identical pin.

For those who needed to vary the kind of a gate merely change its truthtable worth on this desk. For instance, you may change all of the two-input gates into NAND gates by altering their definitions to NAND, or you may add some XNOR gates by additionally defining them in truthtable_t.

Configuring the outputs

In setup() the suitable I/O pins are configured as outputs:

void setup () {
  // Set outputs
  for (int i=0; i<12; i++) {
    pinMode(gates[i].output, OUTPUT);
  }
}

Processing the gates

Lastly in loop() we repeatedly scan by every gate, learn the inputs, and set the output based on the gate’s reality desk:

void loop () {
  for (int i=0; i<12; i++)  inb;
    bool out = (gate.truthtable >> val) & 1;
    digitalWrite(gate.output, out);
  
}

That is all there’s to it.

Compiling this system

AVR128DA48

For those who’re utilizing an AVR128DA48, or something from the AVR32DA48 or AVR32DB48 upwards, compile this system utilizing Spence Konde’s Dx Core on GitHub (I used 1.5.3). Select the AVR DA-series (no bootloader) or AVR DB-series (no bootloader) choice as acceptable underneath the DxCore heading on the Board menu. Test that the next choices are set as follows (ignore some other choices):

Chip: “AVR128DA49 or AVR128DB48
Clock Velocity: “4 MHz inside”

Then add this system to the processor on the breadboard utilizing a UPDI programmer linked to the GND, +5V, and UPDI pins.

The beneficial choice is to make use of a USB to Serial board, such because the SparkFun FTDI Primary board [12], or a USB to Serial cable [13], linked with a 4.7kΩ resistor as follows:

SerialUPDIProgrammer.gif

  • Set Programmer to the primary of the “SerialUPDI – 230400 baud” choices.
  • Choose the USB port similar to the USB to Serial board within the Port menu.
  • Select Add from the Arduino IDE Instruments menu to add this system.

Utilizing a clock velocity of 4MHz reduces the processor energy consumption from 4.7mA to 1.1mA.

ATmega4809

For those who’re utilizing an ATmega4809, or something from the ATmega809 upwards, compile this system utilizing MCUdude’s MegaCoreX on GitHub. Select the ATmega4809 choice as acceptable underneath the MegaCoreX heading on the Board menu. Test that the next choices are set as follows (ignore some other choices):

Clock: “Inside 4 MHz
BOD: “BOD disabled”

Pinout: “48 pin commonplace”

On the ATmega4809, selecting a clock velocity of 4MHz ensures that the processor will run right down to the minimal voltage of 1.8V, for optimum battery life.

Then add this system utilizing a USB to Serial board, as described above. See the MegaCoreX documentation for additional particulars.

Sources

Here is the Logic Lab program: Logic Lab Program.

Get the Eagle recordsdata or Gerber recordsdata for the PCB on GitHub right here: https://github.com/technoblogy/logic-lab.

Or order boards from OSH Park right here: Logic Lab.

Acknowledgements

Due to Dashi for encouraging me to construct this, and to Chris Jordan for collaborating on the design.


  1. ^ A-Level Computer Science Logic and Arithmetic Kit on the College of Southampton web site.
  2. ^ AAA x 1 Battery Holder PCB Mount on Swap Electronics.
  3. ^ Premium Female/Female Jumper Wires on The Pi Hut.
  4. ^ Jumper Wires 10pk (Female/Female) on The Pi Hut.
  5. ^ PCB Fab on Elecrow.
  6. ^ Acrylic Laser Cutting on Elecrow.
  7. ^ MIL-STD-806B Graphical Symbols for Logic Diagrams on bitsavers.org.
  8. ^ 36-pin 0.1″ Female header on The Pi Hut.
  9. ^ AAA x 1 Battery Holder PCB Mount on Swap Electronics.
  10. ^ 15mm nylon pillars on Swap Electronics.
  11. ^ M3 x 6mm nylon screws on Swap Electronics.
  12. ^ SparkFun FTDI Basic Breakout – 5V on Sparkfun.
  13. ^ FTDI Serial TTL-232 USB Cable on Adafruit.


blog comments powered by

Source Link

What's Your Reaction?
Excited
0
Happy
0
In Love
0
Not Sure
0
Silly
0
View Comments (0)

Leave a Reply

Your email address will not be published.

2022 Blinking Robots.
WordPress by Doejo

Scroll To Top