Pages created and updated by Terry Sturtevant Date Posted: April 29, 2015


PC/CP220 Digital Electronics Lab

Digital I/O (Input/Output) Lab

Objective:

Background:

In this lab you will wire switches to NAND gates with LEDs for output.


inputs and 
outputs

Light Emitting Diodes

Light Emitting Diodes, or LED's for short, emit light when an electric current is passed through them. The amount of current must be limited, however, or the diode will be destroyed. Usually a current of 10 mA is sufficient to light a diode, so if a 5 volt supply is being used, a 500 resistor placed in series with the diode will provide the right current. Note that the diode has one long pin, called the anode, and one short pin, called the cathode. The longer pin is connected to the higher (i.e., more positive) voltage, and the short pin goes to ground.

Note in the following image, the two LEDs on the right light with a high signal (on the yellow wires), while the two LEDs at the left light with a low signal (on the orange wires).
Note that the order of the resistor and LED don't matter as long as the circuit is connected correctly.


LEDs with resistors

Note: You don't have to wire up all of these different configurations; use whichever one suits the application at hand.

Switches

A Dual Inline Package, or DIP switch can be used to select between 0 and 5 volts at some point in a circuit. Since the DIP switch does not have any power or ground connectors this must be done externally.
In this lab exercise, we'll use some prototype switches instead of DIP switches because they are easier to manipulate by hand, even though they work exactly the same as DIP switches.
protoype 
         and DIP switches compared

In our case we want a high (5V) when then switch is turned on, so each input pin we are using must be connected to power. When the switch is off we want a low (0V); but remember when the switch is off it is in a floating state. To resolve our floating pins issue we need to add a resistor from each of the output pins to ground. The output signal comes from where the resistor and switch meet. (In the picture below, the signal wires are green.)
protoype switch wired 
         active high

In the image below, the cases have been reversed, so that when the switch is closed, the output is low, and when the switch is open, the output is high. Note the changes that happen in this case.

The yellow wires are the signals coming from the switches.

protoype switch wired 
         active low

Usually it doesn't matter which switch position (i.e. "on" or "off") gives a high, so either setup is fine.

The output is always taken from the side of the switch with the resistor.



Since all of the points in a row are connected, the output can come from any place in the correct row.



7400 IC

For this lab we will be using the 7400 Quad NAND gate IC. This chip contains four 2-input NAND gates. The pin numbers associated with each input and output of this chip are listed above the input and output of the NAND gates in the diagram. You can also find more information in the datasheet. The pinout is shown below.

NAND pin description

Modular design and debugging

When building a circuit with several components, it's easier to debug if you build it in a modular fashion. This circuit will be in three modules:

Daisychaining boards

When you have multiple breadbords and/or debugger boards, applying power and ground to each board should be achieved by daisy-chaining them.
This makes things organized and easy to debug. It also prevents poor connections due to trying to hold more than one wire in an alligator clip.

daisychaining 
boards

Here's a photograph.

daisychaining

Here's how a modular circuit might look on a single board.

modular layout

You'll build them one at a time, and as each module is known to work, use it to help test the others.

Task:

In this lab you will create a circuit which will turn an LED (light emitting diode) on or off depending on the selected input. The LEDs will give a visual indication of a 1 (LED lighted) or a 0 (LED dark). We connect the switch to select between 1 (high voltage +5v) and 0 (low voltage).

Parts List

Plan of attack

Below there is a schematic diagram for one gate of the completed circuit, but don't look at it yet. The following description of modular construction and testing applies to any circuit so that you don't waste a lot of time trying to debug a complete circuit without knowing which, if any, parts of the circuit are correct.

Output module

For debugging purposes, it's easiest to make sure your outputs work first. If you don't know your outputs are working, you have no way of knowing whether the rest of your circuit is working or not.

For the output module, choose a colour of wire other than red or black.

  1. On one end of the breadboard, wire up one of the LEDs with its resistor.
  2. Test to see that the LED lights up when the other end of the resistor attached to the LED is connected to Vcc (i.e. power). If the LED is very dim, try using a lower resistor; down to 100 Ω or so should be fine.
  3. Once you have one LED working, wire up the other LED with its resistor and test it.
    This is the output module.
Input module

Once you have the output working, you can use it to test the inputs.

For the input module, choose a colour of wire different from what you used for the output module and black. other than red or black.

  1. On the other end of the breadboard, connect the switches and the resistor.
  2. Now connect one of the inputs directly to one of the outputs you wired previously. If it works, the switching the switch should turn the LED on and off.
  3. Repeat this to test each input.
    This is the input module.
Logic module

Since you have now verified that the inputs and outputs work, you should be able to connect them to the gates to see if the gates work.

  1. Put the chip in the middle of the breadboard.
    This is the logic module.
    (Usually the logic module will be more than one chip, in which case using separate breadboards for each module is a good habit to get into.)
  2. Hook up the two inputs and the output of one gate on the chip. If everything has been wired correctly everything should work.

    When you have one gate working, demonstrate it to the lab demonstrator.

  3. Once you have one gate working, wire up the inputs and outputs to one other gate and verify the operation of each of the gates.

Schematic diagram

Here's the schematic for the completed circuit for one gate. The lines with arrows represent the switches. (When the switch is closed, the input will be HIGH. When the switch is open, the input will be LOW. This is called active high configuration.)

circuitry for 7400 
test

 

Demonstrate your results to the lab demonstrator.

Resources

To view pdf documents, you can download Adobe Acrobat Reader .
get Acrobat Reader
If you need to update a browser, you might try Firefox which is Get Firefox!
Since this page uses cascading style sheets for its layout, it will look best with a browser which supports the specifications as fully as possible.

If you are looking for an office package, with a word processor, spreadsheet, etc., you might try LibreOffice which is Get LibreOffice!

Go to the main page for the Department of Physics and Computer Science.

Valid XHTML 1.1

Valid CSS!

WCAG 2.0
(Level AA)

Wilfrid Laurier University