# EE109 – Fall 2017: Introduction to Embedded Systems

## Digital Logic - Gates

### Introduction

This lab assignment has three purposes:

• Learn how to use the oscilloscope to observe and analyze signals. An important aspect of this is learning how to set up the oscilloscope triggering so signals can be clearly seen.
• Learn how to implement a simple logic expression by building a circuit using the basic logic gates.
• Study the time it takes for digital signals to propagate through circuits.

### Part 1: Using an Oscilloscope

An oscilloscope like the Agilent MSO-X 3024A models in VHE 205 are used to show a graph of one or more signals as they change with time. The scope plots the signals showing their:

• Voltage level along the vertical axis, and
• Time along the horizontal axis

By displaying multiple signals on the same plot, it's possible to see how they are interacting with each other. The scopes in VHE 205 are capable of displaying signals from four signals (channels 1-4) at the same time on the display.

Note: The oscilloscopes in VHE 205 were made by Agilent, but the company is now called Keysight. Some of the pictures of the scope screens many show the Agilent name, while others may say Keysight, but the only difference is in the name. If the name on your scope screen doesn't match the one in this web page, just ignore the mismatch.

To get started follow the steps below.

1. Turn on the oscilloscope by pressing the white button in the lower left of the front panel and wait for it to go through a bunch of self tests. In less than a minute it should be ready to go.
2. Press the "Default Setup" button in the upper right portion of the front panel.
3. After it says on the screen that the default setup has been restored, press the "Back" button in the lower left corner. This should restore the scope to the default settings in case someone has altered them. You should see a screen like this.

Notice the grid lines on the screen. There are eight vertical grid spaces (a.k.a. "divisions") and ten horizontal "divisions". These are used in conjunction with the vertical and horizontal scale factors to measure the voltages and timing of signals. The first two numbers to look for are the scale factors for the vertical and horizontal axis. The vertical scale factor is shown in the upper left corner of the screen, and the horizontal scale factor is also along top about 2/3 of the way to the right side.

Note: Each of the four channels can have a different vertical scale factor and these are shown along the upper left of the screen (i.e. channel 1 can be displayed with each division representing 1V while channel 2 is displayed 5V per division). In the default settings, only channel 1 (yellow) is turned on, and the display shows that the vertical scale factor is "5.00V". This means that each of the grid lines represents 5 volts of signal level. The horizontal scale factor is set to "100μs" meaning that the signal is plotted with each horizontal grid space representing 100 microseconds of time. We'll be using the grid lines and the vertical and horizontal scale factors to make voltage and time measurements on signals.

Since there is no input signal connected to channel 1, the plot or "trace" for channel 1 is just a horizontal line across the screen. Look at the left side of the screen where the horizontal line ends. You should see a small "Ground" symbol there aligned with the line. This is how the scope shows you where the Ground or 0 Volt level is displayed on the screen. Since there is no input signal on channel 1, the whole display for that channel is at the ground level.

The position of the trace can be adjusted with the small knob just below the illuminated "1" in the Vertical section of the front panel. Try rotating that knob back and forth and observe how the trace moves up and down on the screen. The position knobs for the four channels are used to spread the four traces out on the screen so you can see them.

Now let's look at some signals.

1. Open up the storage compartment on the top of the scope and remove the scope probe that has the yellow markers on the cable.
2. Insert the probe's connector onto the metal BNC connector for channel one. To make proper contact, the connector needs to be pushed onto the scope's connector fully and then rotated clockwise to lock it in place. You'll know it's locked in place if you can't pull it off (with a gentle pull) without first rotating it counter-clockwise. The probe has a metal hook at the tip that is exposed by pulling back on the plastic body of the probe. At the lower edge of the scope, hook the probe tip onto the metal tab that says "Probe Comp" just right of the USB port.

Note 1: The "Probe Comp" metal tab is only used for testing and calibrating the scope. We don't use it for any of our normal measurements. This is probably the only time this semester that you will be attaching the probe to it.

Note 2: The black ground clip on the probe does not have to be connected to a ground point when the probe is attached to the Prop Comp test point. In all other situations the ground lead must be connected to the circuit ground in order work.

3. You should now see two yellow lines going across the screen about a half a grid spacing apart. To get a better view of the signal we need to change the vertical scale factor to make the signal bigger on the screen.

4. In the Vertical section of the front panel, just above the illuminated "1", the large knob is the vertical scale adjustment. There is one for each channel.

Rotate the one for channel 1 a couple of clicks to change the vertical scale factor to 1.0 volts/division (shown at the top left of the display) and this will move the two yellow lines further apart.

5. You should be able to see a lot of vertical lines running around on the screen between the two horizontal lines. The display should look something like this.

The next step is to get the display to sit still so we can see what it looks like. To do this we need to set up the triggering on the scope. On an oscilloscope, "triggering" means the set of conditions that cause the scope to start drawing a picture of the signals present on its input channels.

Understanding how triggering works and setting up the triggering conditions is probably the most important aspect of making a scope into a useful diagnostic tool.

6. The scope can be set to trigger when the input signal meets a set of conditions and it will then display the signals on all the channels that occurred before and after that time. It will then wait until the conditions are met again, and then display the signal again. With periodic signals this gives you stable display of the signals since each time they are drawn on the screen they are in the same position. When the scope doesn't know what to trigger on (like now), it just shows a running (live-stream) display of the incoming signal which usually results in the plot of the signal dancing around on the screen. While you are seeing the signal, it probably won't be stable on the screen and it will be difficult to analyze. When the triggering has been adjusted properly a stable display will be shown and you can get a clear look at the shape of the signal.

7. In the Trigger portion of the front panel, press the "Trigger" button and the Trigger Menu will appear at the bottom of the screen. Pressing the button below one of the options will bring up a list of all the possible settings for that option. Note that the one pressed will also have a green circle with an arrow on it. This indicates that the setting can be adjusted using the knob just below the "Trigger" button.

Trigger Type
Determines what type of signal to trigger on. Pressing the button will show all the different triggering types the scope supports. "Edge" triggering is the most common and that's what we will use today. If it doesn't say "Edge"', use the knob to select it.
Source
Tells which input channel to use for triggering. Set it to channel 1.
Slope
For edge triggering, determines whether to trigger on a signal edge when the signal is going from a low voltage to a high voltage, high to low, either, etc. Set it for a rising edge (little arrow pointing up).

Now that the scope knows to trigger on a rising signal edge on channel 1, we need to tell the scope exactly what voltage level to trigger on. The trigger level is adjusted with "Level" knob in the Trigger section and the value is shown at the top right of the display. Right now it probably says "0.0V" and this is the problem. Since the signal goes from 0 volts to about 2.5 volts, there is no rising edge where it is zero volts so the scope is not triggering. The scope actually tells us that it's not triggering by putting "Auto?" in the top right of the screen. The question mark is the scope's way of saying that it's not triggering.

8. Rotate the Level knob until the value in the upper right says 1.0V and the display should freeze and show something like this. Note that the "Auto?" has changed to "Auto".

The trigger level is always indicated on the display with the small "T" and triangle along the left side of the display. When the level is being adjusted it also shows it as a horizontal line through the display. Look at the top center part of the display and there should be small triangle pointing down. This indicator shows the point along the horizontal (time) axis where the trigger condition was met. The default position is in the middle of the screen so you can see what the signal looked like before and after the triggering occurred. To see more of the signal before or after the trigger point, rotate the small knob in the Horizontal section of the controls to move the trigger point (and the displayed signal) back and forth.

Useful Tip: You can always return the trigger point to the center of the screen by pressing the horizontal position knob.

9. The last step is to change the horizontal scale factor, also known as the "time base" so we can see more of what the signal looks like. Rotate the large knob in the Horizontal section of the front panel to change the time per division (shown at the top of the display) until it says 500μs. We can now see that the signal is a square wave that repeats every 1000 microseconds, or 1msec. From the vertical scale we can see that the signal goes between zero volts and +2.5 volts.

10. Try playing with the controls (horizontal scale, vertical scale, horizontal position, vertical position, trigger level) to get a feel for how they affect what you see on the screen. Note that using the vertical position control to move the trace up and down on the screen does not affect the triggering level, it moves with the trace.

### Part 2: Construct a Digital Circuit

In your ee109 folder, create a lab2 folder. From the class web site download into the lab2 folder the file "lab2.zip" and extract the contents: "Lab2_Answers.txt". This is a text file that you can edit with your text editor to record your answers to the questions below. This file must be uploaded to Vocareum by the lab due date.

We want to build the digital circuit shown in the schematic diagram below.

The circuit has two pushbuttons for inputs, A and B, and one output Z which has an LED connected to it. Note: The circuit diagram above does not show the power and ground connections required for the 74LS00 and 74LS04 integrated circuits, but these will be required (see step 4 below).

From the instructor's podium get the following items:

• Additional buttons so you have two (any colors). These will be used for the two digital inputs.
• Two 1kΩ resistors to be used as pull-ups for the switches.
• A 470Ω resistor to be used for limiting current through the LED.
• A 74LS00 integrated circuit. This contains four 2-input NAND gates.

In addition to these new parts you will need the following from last week's lab:

• The 74LS04 (inverter)
• The LED

If you don't have those parts they are also available at the podium.

Follow the steps below to install the the two switches, two ICs, LED and resistors on the breadboard.

1. Install the two buttons and wire their associated 1kΩ pull-up resistors and their connections to ground. When installing the buttons position them so you have access to at least one of the holes in the row the button's pins are inserted. Remember to orient the switches so the flat side of the switch is towards either of the long sides of the breadboard.
2. Install The 74LS04 inverter and the 74LS00 quad NAND gate. Note: both ICs should be installed with their pin 1 in the same orientation (to the left or the right) to help reduce wiring errors.
3. Install the LED and its current limiting resistor.

This picture shows the buttons, ICs and LED installed on the breadboard. (Note: You will also need to connect the pull-up resistors to the buttons and a current-limiting resistor to the LED. But that is not shown in this picture.)

1. Make connections from the +5V (red) bus strip to pin 14 off both ICs, and from the ground (blue) bus strip to pin 7 of both ICs.
2. The 74LS04 contains six inverter (NOT) gates as shown below. You use any of them for your circuit. Make connections from the 'A' button to the inputs of one of the inverters in the 74LS04.

3. Before going any further, it is strongly recommended that you test the circuit you have assembled to this point. As you did last week set up the power supply for 5.0V. Using a pair of red and black test leads with banana plugs on one end and the pins on the other, connect the red power banana jack to the red bus strip on the breadboard and the black power supply banana jack to the blue bus strip for ground.

Turn on the DMM, set it to measure DC Volts, and connect the test leads to the inverter output and to ground. Turn on the power supply 5V output to the breadboard. If the A switch is not pressed, the inverter input will be a logical 1, and the output should be a logical 0 (<0.5 volts). When the switch is pressed, the inverter output should go to the 1 state (>4 volts). Also check that the signal from button B changes in this range when it is pushed. If something is not working, you might as well fix it now before proceeding since the overall circuit is not going to work until it's fixed.

4. The 74LS00 contains four independent two-input NAND gates as shown below.

You can pick any of these to be either of the two in the schematic. Follow the schematic diagram above and make the connections to the inputs and outputs of the NAND gates.

5. Connect the LED and current limiting resistor to the output of the NAND gate.

Once the circuit is wired, turn on the power to the board and test all four input combinations with the buttons. Remember the inputs will be a logical 0 when the button is pushed.

#### Whoops! It doesn't seem to be working. Now what do I do?

If your circuit isn't working (LED stays on or off for all four input combinations), then it's time to do some debugging. When a circuit doesn't work it's probably only one part that isn't functioning correctly but that makes the whole circuit not work right. When trying to debug a circuit it's necessary to isolate where the problem is by testing separate parts of the circuit to see if they work or not. For this circuit try the following.

• First, make sure the power supply voltage is present on the breadboard and at the ICs. Also make sure the ground connections are installed.
• Use the scope or the DMM to test the output of the inverter at point P2 on the schematic. Does it change properly when button A is pressed? It should be high (logical 1) when the button is pressed and 0 when not pressed.
• Check the output of the lower NAND gate (P3) by making its upper input (P2) a 1 by pressing button A, and then see if the output changes when button B is pressed.
• Check the output of the upper NAND gate in the same way by making the P2 input a one and making the P3 input change by pressing B.

Your goal is to figure out what is working and what isn't, so you can isolate the problem to a subset of the whole circuit. Here are some other debugging tips.

• Just because you installed a wire between two points doesn't guarantee the signal is getting from one end to the other. The wire may be broken or not making good contact. Test the signal at both ends to make sure the connection is working.
• Make sure the ICs are plugged fulling into the breadboard, and all the pins are in the breadboard holes. When inserting an IC it's easy to bend a pin so it's not going into the holes. If this happens and a pin is bent so badly it can't be straightened, discard that IC and get another.
Question 1:
Fill in the truth table for the circuit on the answer sheet.
Question 2:
Based on the truth table, this circuit performs the same function as which other 2-input logic gate?

### Part 3: Measuring Propagation Delays

In this part of the lab we will be measuring the time it takes for your logic circuit output to change in response to a change at the input. When a button is pressed changing the state of an input signal, this change may have to propagate through multiple gates before the output changes. Each of these gates has a small individual delay from an input changing until the output changes, and since the output of one gate is attached to the input of another, the total propagation delay through the circuit is the sum of the individual delays.

To measure the propagation delay we have to use the oscilloscope.

1. Get two probes from the scope's storage compartment. Note that the probes probably have colored bands on them, either yellow or green. These are there so you can easily see which probe is associated with each signal trace on the screen. Attach the probe with the yellow band to channel 1, and the one with the green band to channel 2.
2. Turn on channel 2 by pressing the button with the big "2" on it above the position knob for channel 2. This should put a green signal trace somewhere on the screen.
3. Adjust the vertical scale for both channels to be 2.0V per division.
4. Use the positioning controls to put the yellow trace three divisions below the top of the screen, and put the green trace one division above the bottom.
5. Adjust the horizontal scale setting to 20ns per division.
6. Set the triggering for edge triggering, channel 1 and falling edge. We have to set it to a falling edge since we want to trigger when the button pressed, and when that happens the button signal goes from 1 to 0.
7. Use the Level knob to set the trigger voltage to 2.0 Volts.
8. Press the horizontal position knob near the top of the controls to move the trigger point to the middle of the screen.

The next step is to connect the scope to both the input signal and the output signal so both can be observed together. We are going to use channel 1 to observe the input signal and channel 2 to see the output signal.

1. Attach the probe for channel 1 to the circuit node where button A, its pull-up resistor and the inverter are connected. This is the node labeled "P1" on the schematic.
2. Attach the probe for channel 2 to the output of the inverter (point P2).
3. Attach one or both of the two probe ground wires to the breadboard ground.

With button A not pressed the two input signal is a logical 1 and you should see both the yellow trace at just under 5V, indicating a logical 1 state. The green trace should be near 0V indicating a logical 0 state.

Press button A to make the input go to a logical 0 state. Both traces should move, the yellow from around 5V down to 0V, and the green from 0V up to near 5V. This shows the inverter circuit is working but the signals are too fast to see the propagation delay on the screen. To see them we have to capture the signal at the instant it changes and freeze the display.

Press the "Single" button in the upper right. This tells the scope to wait for the next time the input matches the trigger condition, capture and display the signals, and then freeze the display so we can look at them. Now try pressing the buttons to change the output. The scope should acquire the signals as they are changing and display them frozen on the screen as shown in the picture below.

From the scope display you can see the propagation delay from to output since the output signal (green) is lagging behind the input signal (yellow). In addition, neither signal changes from the 1 state to the 0 state instantly. To measure the propagation delay we have to make an arbitrary decision as to what voltage level to use for saying the signal has changed. For this experiment, we'll use 2.0V. We want to measure the the time between when the input signal crossed the 2.0V level to when the output signal crossed that same 2.0V level.

Since the trigger voltage was set to 2.0V, the point where the yellow input trace crossed 2.0V should be where it passes through the center vertical line. The vertical scale factor was set to 2.0V/division so this point should be one division above the ground level for the yellow signal trace. Now look for the place where the green output signal also crosses 2.0V above its ground level. Estimate how many horizontal division are between these two points. Knowing that we have set the horizontal scale to 20ns/division, determine the time it takes for the output to change after the input changes. This is the propagation delay from the button input to the inverter output.

Now we want to measure the delay from button A to the output at point Z. Take a look at the circuit diagram and recall that for a NAND gate if either input is 0, then the output is 1. For our circuit this means that in order for the output of the upper NAND gate to change when the inverter output changes, point P3 must be a logical 1. If P3 is a zero then point Z will always be a 1 and we won't be able to see the signal changing. Therefore for this next measurement we have to force P3 to a 1. We can do this by simply pressing button B and holding it down. This puts a zero on one of the inputs to the lower NAND gate and its output (P3) will be a 1.

To make the measurement do the following.

1. Remove the channel 2 probe from the inverter output and attach it to the output of the upper NAND gate at point Z.
2. Press the "Single" button on the scope to get it ready to trigger.
3. Press and hold down button B so point P3 is a logical 1.
4. Press button A and the scope should acquire the signals.

You should get a scope display similar to this.

The yellow trace is showing the button being pressed, and the green trace is showing the NAND gate output that controls the LED. As before determine the propagation delay from the button to the NAND output by examining the two scope traces.

Question 3:
What are the propagation delays from the button A input through the inverter to point P2, and from the button A input through the NAND gate to point Z?

### Part 4: Sequential Circuits

In this part of the lab we will build a small sequential digital circuit and measure how fast it can be operated. This circuit will use a register (remember this is the primary building sequential building block in digital circuits and can remember 1 value when you trigger it with a clock signal) and a combinational adder circuit (performs SUM = A + B in binary). The result of the circuit will be a 2-bit counter. You should eventually see two LEDs producing all the 2-bit numbers starting at 00 then progressing to 01, 10, 11, and then wrapping back to 00 again. A block diagram is shown below.

We will start at the output, Q, of the register. This represents the 2-bit number you will see on the LEDs. Notice how it feeds back to the A input of the adder and gets summed with 01 binary (i.e. Q+1). This value then becomes the D-input to the register and, on the next clock edge, will become the new Q value. So this is a clear example of sequential logic. We need to remember the last value (Q) to produce the next value (Q+1).

To implement the circuit you will use two integrated circuits: a 74LS283 four-bit adder circuit and 74LS175 four-bit register. The schematic for this part of the circuit is shown below. (Note: the small numbers on the schematic are the pin numbers of each IC.)

The 74LS283 and 74LS175 are "Medium-Scale Integration", or MSI, integrated circuits. They are the next step up in complexity above ones like the 74LS00 that just contain a few gates. MSI circuits perform more complex operations, in this case a four-bit adder (74LS283) and a four-bit register (74LS175). By combining them we can create a four-bit counter but here we will only build a two-bit counter.

The 74LS283 adds the two four-bit numbers consisting of the bits A4,A3,A2,A1 and B4,B3,B2,B1 to form the sum Y4,Y3,Y2,Y1. Our circuit saves the low two bits of the sum (Y2,Y1) in the register each time the clock signal goes from the 0 state to the 1 state. The saved sum bits appear on the register outputs Q2 and Q1. This sum is then fed back to the "A" input of the adder (Q2 → A2 and Q1 → A1) where it is added to the the "B" input that has been set to the value of 1 (B2 = 0 and B1 = 1) to create a new sum. The result is that each time there is a clock signal, the value on the output of the register increments by one from 0,0 to 0,1 to 1,0 to 1,1 and then back to 0,0 and repeats.

The following steps should be followed to build the circuit.

1. Remove the two pushbuttons and the two ICs (74LS00 and 74LS04) from the breadboard. Leave the LED and its 470Ω current limiting resistor on the board.
2. Get one each of the 74LS283 and 74LS175 from the instructor's podium. Also get an additional LED and a 470Ω resistor.
3. Mount the two ICs on the breadboard. As done previously, make sure they are installed with pin 1 in the same orientation.
4. First install the wiring for the power and ground connections. Both ICs should have pin 16 connected to +5V, and pin 8 to ground.
5. Make the other connections required to +5V and ground. These are for the input pins that need to have a logical 0 or 1 on them.
6. Follow the diagram and make the rest of the wiring between the two chips, the resistors and the LEDs. Make sure to note which LED is connected to the Q1 output and which to the Q2 output.

The only thing missing from the circuit is the "CLOCK" signal that causes the counter to operate. The next section describes how we will generate that. But at this point your breadboard should look something like the following image.

#### Clock Generation

The clock is a simple digital signal that constantly switches back and forth between 0 and 1 at a known rate. The oscilloscopes contain a waveform generator that can be used to create a clock signal.

1. From the podium at the the front of the room, get one of the black cables that has a BNC connector on one end, and the other end is a pair of white and black wires with pins on the end. Attach the cable to the BNC connector just to the right of the scope's on/off button that's labeled Gen Out.
2. If you haven't done so already, disconnect the scope probe on channel 1 from the Probe Comp tab and connect it to the pin on the end of the cable's white wire. Also attach the black alligator clip on the scope probe to the pin on the end of the cable's black wire. (So right now the scope is not attached to the actual circuit, instead we are just connecting it to the BNC cable and ensuring the clock signal is correct by viewing it on the scope's display. Once it is correct, we will connect it to the circuit on your protoboard.)
3. In the Trigger portion of the controls, press the Wave Gen button to bring up the wave generator options. You should see something like in picture below. The tabs along the bottom are used to change the type and shape of the wave that is being produced.
4. Select "Waveform" and use the knob to select "Square".
5. Select "Frequency" and use the knob to adjust it to 1Hz.
6. Select "Amplitude" and adjust it to 5Vpp.
7. Select "Offset" and adjust it to 2.5V.
8. Adjust the scope's controls to
• Vertical = 2V/division
• Horizontal = 500msec/division
• Trigger = 2.5V

The scope display will take a relatively long time to move across the screen at 500ms/div but eventually you should see a stable display of the waveform being generated that looks like the one below. This should work fine as a clock signal for your circuit.

1. Disconnect the cable from the scope probe and it's ground clip and connect the cable's black wire to ground on your breadboard.
2. Connect the cable's white wire to the clock input of the 74LS175 (pin 9). So now the clock signal should be connected to your counter circuit and you should see the output "counting".

At this point your circuit should be counting and the two LEDs should be going on and off. Observe the LEDs and confirm that they are counting with the Q1 LED the least significant bit and the Q2 LED the MSB. The Q2:Q1 sequence should be 00, 01, 10, 11, 00, 01, etc. Make certain the LEDs are blinking in this sequence and they should be spending the same amount of time in each of four counter states.

### Part 5: Counter Propagation Delay

Your two-bit counter is being clocked at a 1Hz rate which makes it easy to see the changes in the count values. The digital circuits used to build the counter can run much faster than 1Hz so let's try speeding it up.

1. If the waveform generator settings are not shown across the bottom of the scope display, press the Wav Gen button to bring them up.
2. Adjust the frequency of the clock signal to 10Hz. You should be able to still see the LEDs flashing in the 00, 01, 10, 11 sequence.
3. Continue to increase the frequency. As the LEDs blink faster eventually they simply appear to be on all the time but dimmer than at low frequencies. Your eyes are integrating the on-off-on-off pattern into something that looks like its on continuously at 50% brightness.
Question 4:
At approximately what frequency does it become impossible to see any blinking and the LEDs appear to be on all the time?

### Results

The answers to the above questions should be edited into the "Lab2_Answers.txt" file
and the file uploaded to the Vocareum web site by the due date. See the Assignments page of the class web site for a link for uploading.

Please return the various ICs to the instructor's podium. Keep the buttons, resistors and LEDs you acquired for this lab in your project box. These will be needed for next week's lab and you can return them at a later date.