Adventures (WIP)

Adventure 0: Install Digital, run tutorial

Goal: Install Digital. Run its tutorial and simulate a logic circuit.

  1. Download and install Digital.

    1. Install Temurin for Windows x64 from https://adoptium.net/

    2. Download Digital from GitHub

    3. Extract in a local directory, e.g., C:\WinPRG\Digital

    4. Double-click Digital.jar to run.

  2. Go through the Digital tutorial. If you want to repeat it in the future, it is available at View –> Start tutorial.

  3. Save your work as adv-0.dig.

Adventure 1: Logic gates [NOT, AND, OR, XOR, NAND, NOR, XNOR]

Goal: Understand all basic logic gates and build a logic circuit which uses all of them.

Adventure 1A: Logic gates: Design and simulate circuit

Goal: Build a circuit will all basic logic gates: NOT, AND, OR, XOR, NAND, NOR, XNOR in Digital.

  1. Create a new circuit in Digital.

  2. Insert two inputs.

  3. Label them A and B: To label an input right-click on it, and edit the Label text entry.

  4. Insert two NOT gates.

  5. Wire input A to the first NOT gate, and input B to the second NOT gate. Note a NOT gate accepts a single input.

  6. Insert each one of the remaining logic gates, 6 in total.

  7. Insert an LED output for each gate, 8 in total.

  8. Wire input A to the first input of each 2-input gate (AND, OR, XOR, NAND, NOR, XNOR).

  9. If you make a mistake while adding wires, hold down Ctrl and click the offending wire, then drag it to its new location. Similarly, Ctrl-click a wire and drag it to the trashcan icon in the toolbar, then click the trashcan icon, to delete it.

  10. Wire input B to the second input of each 2-input gate.

  11. Label each LED according to its role: NOT_A, NOT_B, AND, OR, NAND, etc.

  12. Simulate your circuit. How does each logic gate function? If there are disconnected input pins (“floating” inputs), Digital will complain with an error message similar to this:

    Error creating the circuit. Nothing connected to input 'in_2' at component
    'XNOr'. Open inputs are not allowed.
    

    If this happens, make sure you have connected every input of every gate to either input A or B and try again. If things still fail, remove some of the logic gates to simplify your circuit, until you can get it to work, then add them back gradually.

  13. Notice how some wires are light green, some others are dark green, depending on whether their current state is 1 or 0, respectively.

  14. Write down the truth table for each one of the gates, according to your testing.

  15. Navigate to Analysis –> Analysis in the menu. See Digital produce the truth table for each one of your outputs automatically.

  16. Save your work as adv-1a.dig.

Adventure 1B: Logic gates: Simulate with 74LS chips

Goal: Build a circuit similar to the one in Adventure 1A, but use 74xx chips in Digital.

Place the 7404 in the middle of your breadboard. You may have to bend some pins slightly, experiment, don’t worry if you break things. Connect the VCC pin to the VCC bar, and the GND pin to the GND bar. Connect to the power supply and ensure the the chip gets 5V across its VCC and GND pins. Bridge all pins you will not be using [3A, 4A, 5A, 6A] to GND with small wires. Connect a pushbutton [a “momentary switch”], so that one of the side pins to VCC, the other to GND, so that the middle pin stays LOW when you do nothing, and turns to HIGH when you push the button. Use your multimeter to verify. Switch the jumper wires until you make it happen. Connect the middle pin of the momentary switch to the 1A input of the 7404. Use your multimeter to measure all voltages. If they are not 0V and ~5V [i.e., a clear LOW, or HIGH] make sure you’ve seated all of your jumper wires properly, one connection make be flaky. Do not move on until you’ve confirmed this, a clear signal at the input pin of the 74LS04.

OUTPUT: Measure the voltage at the output pin of the 74LS04 when you do nothing [4.57V] and when you push the button [0.14V]. What is happening? The 74LS04 is an inverter, i.e., it implements a NOT gate.

Connect an LED: VCC -> resistor –> anode of the LED –> cathode of the LED –> 1Y. Voltage: 4.58V. Button pushed, voltage: 0.51V

  1. Have a look at the list of logic gates in the 74LS family (Wikipedia) of integrated circuits (“chips”, “ICs”). We care about the “Normal inputs / push-pull outputs” category.

  2. See we will be using chips 74LS04, 74LS08, 74LS32, 74LS86, 74LS00, 74LS02, 74LS7266. How many gates and of which kind does each IC implement?

  3. Find the documentation for Digital as a PDF file in the docu/ directory, e.g., docu/Documentation_en.pdf. Section E Library contains a full list of all supported 74xx ICs.

  4. Create a new circuit in Digital.

  5. Navigate to Components –> Library –> DIL chips –> 74xx –> basic.

  6. Insert one of each of the 7404, 7408, 7432, 7486, 7400, 7402, 747266 chips. Arrange them one below the other, in two or three columns, any way you like.

  7. Use the scroll wheel of your mouse to zoom in and out of the circuit, hold down the right mouse button and drag the circuit, to move it around.

  8. Notice the pinout for each chip. There are pins for each input and output, as well as pins to connect to power [VCC] and to the ground [GND].

  9. Insert two inputs, label them A and B.

  10. Wire the inputs to create a circuit equivalent to the one in Adventure 1A, this time using 74xx chips instead of the basic LED gates. For each chip implementing 2-input gates, wire input A to input 1A of each chip, and input B to input 1B of each chip. Notice chip 7404 implements NOT gates which only accept one input. Also note the pin layout differs slightly between different chips, so you need to be paying attention.

  11. Insert an LED output per gate you have used, 8 total. Label them according to their role, as in Adventure 1A. Wire the output of each logic gate you have used to the right LED. When adding wires, pay attention to not touch other pins on the chip. It is OK if the wires go over the chip itself, but they should not touch other pins, because you will find it difficult to wire these pins later on.

  12. Navigate to Components –> Wires –> Supply voltage and add a power source next to each chip. Label it VCC. Connect the VCC pin of each chip to VCC.

  13. Navigate to Components –> Wires –> Ground and add a ground terminal next to each chip. Label it GND. Connect the GND pin of each chip to GND.

  14. Notice each chip implements more than one logic gates, but you only need to use one input of each chip, except the 7404 chip, where you use two inputs. Connect every single unused input of every chip to VCC [a logical 1] or to GND [a logical 0]. It does not matter, as long as every single input is connected to either VCC or GND.

  15. Simulate your circuit. How does each logic gate function? If there are disconnected input pins (“floating” inputs), Digital will complain with an error message similar to this:

    Error creating the circuit. No output connected to a wire ([In_2; NAnd]).
    The state of the wire is undefined. Ocured in file 7400.dig.
    

    If this happens, make sure you have connected every single input to either VCC or GND, and try again. See this issue in Digital for technical details.

  16. Compare the truth table of your new circuit to the truth table of Adventure 1A. They should be identical.

  17. Save your work as adv-1b.dig.

Adventure 1C: Logic gates: Build physical circuit with 74LS chips

Goal: Use a breadboard and 74LS chips to build an actual, real-world version of the circuit in Adventure 1B.

Tools: Here is a list of the tools you will need to buy. You will re-use these tools throughout the tutorial:

Quantity

Name

Description

Links

1

needle nose pliers

Fanos

1

wire cutter

Fanos

1

wire stripper

Fanos

1

multimeter

Fanos

1

small organizer box

Fanos

Components: Here is a list of the components you will need to buy:

Quantity

Name

Description

Links

1

5V power supply

E.g., any USB charger

Buy a breakout plug, so we can connect

1

breadboard

Breadboard

Fanos

1

65-piece jumper wire kit

Many small jumper wires to use with the breadboard

Fanos

1

74LS04

Hex inverter

Fanos

1

74LS08

Quad 2-input AND gate

Fanos

1

74LS32

Quad 2-input OR gate

Fanos

1

74LS00

Quad 2-input NAND gate

Fanos

1

74LS02

Quad 2-input NOR gate

Fanos

1

74LS86

Quad 2-input XOR gate

Fanos

1

74LS7266

Quad 2-input XNOR gate

Not sure it is actually available

2

SPDT switch

Single Pole Double Throw Switch

Fanos

10

LED, red

LED, red 2-2.5V, 20mA

Fanos

2

1kΩ resistors

Resistors, ½W

Fanos

2

150Ω resistors

Resistors, ½W

Fanos

2

300Ω resistors

Resistors, ½W

Fanos

2

500Ω resistors

Resistors, ½W

Fanos

1

0.1μF capacitor

Ceramic capacitor

Fanos

TODO: Revisit this list. 74LS is TTL and cannot drive output LEDs directly, it can only source 1mA, LEDs need ~5-20mA. See: https://www.eevblog.com/forum/beginners/driving-leds-with-74ls-logic/

TTL is better at sinking current, so run the LEd’s from the 5V rail with the logic low turning them on. Use 5mA as a current and most modern LED devices will be very bright at this current. Typically this means a 470R resistor per LED. A typical 74LS00 output pin can sink significant current to drive a standard LED. Just wire the cathode to the output pin through a suitably sized series resistor (calc for maybe 10 ma, plenty bright) to then to +5vcc. You just have design for circuit so that a LOW output is the active (lite) state. On the other hand, people have been doing it, but it’s not guaranteed to work if you also want to drive the input of a different 74LS chip: https://forum.allaboutcircuits.com/threads/74ls-outputs-drivind-leds.133593/ So, the conclusion is, it’s best to use an actual buffer/inverter. I can use 74LS04 [inverter] or 74LS07 [high-voltage open-collector buffer].

TODO: Use a pull-up resistor for HIGH inputs. Do not use a pull-down resistor at all, just connect inputs to GND. See: https://www.edaboard.com/threads/using-sinlge-pull-down-resistor-for-inputs-to-mutiple-gates-ito-74ls-ics.360131/post-1542109

Example on 74LS00 (TI datasheet): Given: 5V supply, V_IH =2V, V_IL=0.8V, I_IH=20uA, I_IL =-0.4mA. Pulldown to ensure valid low level: R = V / I = V_IL / I_IL = 0.8V / 0.4mA = 2000Ohms. or less. –> use 1K (down to 0R) Pullup to ensure valid high level: R = (5V - V_IH) / I_IH = (5V - 2V) / 20uA = 3V/20uA = 150k. or less. –> Use 10k (down to 0R) Standardize on a 1k pull-up resistor.

WIP: