# EE109 – Fall 2017: Introduction to Embedded Systems

## Electronic Circuits

### Introduction

This lab assignment has two purposes: to give you some experience assembling basic electronic circuits on the breadboard from your project box and using a couple of pieces of test equipment in the VHE 205 lab. Various circuits will be constructed and the test equipment will be used to make measurements to confirm some of the fundamental laws that apply to electronic circuits.

Each station in the VHE 205 lab consists of a collection of electronic test equipment. Some of the equipment is designed to generate signals, others are for observing signals. This equipment will be used in subsequent labs assignments so it is important that all students become familiar with the operation of the different items of test equipment.

### Create a Lab 1 Folder

In Lab 0 you learned how to create a new folder for a project, and now we want to do the same for Lab 1. In your "ee109" folder create a new folder called "lab1".

$cd Desktop$ cd ee109
\$ mkdir lab1


The "ee109" folder should now contain a "lab0" folder and a "lab1" folder.

From the class web site, download the file lab1.zip. As was done in Lab 0, extract the contents and place them in the "lab1" folder. You should end up with one file in the "lab1" folder: Lab1_Answers.txt.

At several places in this assignment you will be asked to either calculate a voltage, current or resistance value, or to use the test equipment to measures these. Your answers should be edited into the file Lab1_Answers.txt.

Important: The Lab1_Answers.txt is a plain text file so it should be edited in a text editor like you use for editing your C source code. Don't edit it in a word processor. Also don't edit it on either Windows or Macs by simply double clicking on the Lab1_Answers.txt file since this may open up the file in the system's default editor and those can sometime mess up a plain text file.

If you don't want to edit the file while doing the lab, you can fill the answers in on the sheet provided in class and then transfer them to the file later.

### Submission via Vocareum

We will submit all of our labs via a website called Vocareum. This site allows us to not only grade your code but to mark-up your code with suggestions and improvements to consider. You should receive an email inviting you to join Vocareum. If you do NOT receive such an email, talk to your instructor during lab. When you login to Vocareum you should be able to see a Lab 1. By selecting it you should be able to upload your Lab1_Answers.txt file. Be sure to hit Submit and not just save.

The solderless breadboards included in your project kit and shown below allows components and wires to be easily inserted and removed in order to quickly modify a circuit. In the center section of the board are around 60 sets of five holes on each side of the center of the board. In the picture below the center of the board is running horizontally so the sets of five holes are actually above and below the center. All five of the holes in each of these sets are connected together electrically as shown in the connection diagram on the right below. When you need to connect components and wires together, plug all of them into one set of the five holes and they will be connected. If you need more than five things connected together, use wire to connect other sets of five holes to the first set to expand the number of connection points.

Along the sides of the breadboard (top and bottom in breadboard above) are columns of holes running in rows alongside blue and red lines. These are different in that all the holes in one column of holes are connected together. Thus we have four electrical nodes. Normally these are used for power and ground connections and are often referred to as "bus" connections. As a matter of convention, the holes next to the red lines should be used for power, and the ones next to the blue lines should be used for ground.

### DC Power Supply (Background + Lab Tasks)

Electrical power comes in two types: alternating current (AC) in which the voltages varies with time, and direct current (DC) where the voltage is a constant value. The power supplies in VHE 205 (shown below) are triple output variable-voltage DC power supplies meaning that they can simultaneously produce three different DC voltages and that the voltages can be changed by the user. Two of the outputs can produce voltages from zero to 30 Volts with current up to 1.5 Amps. The third output is variable from zero to 6 Volts with current up to 5 Amps. All of these limits are more than any of the requirements we will need in this class, so for all of the lab assignments you can use any of the three channels.

To set up the power supply for this experiment perform the following actions. We recommend you read this whole list of actions before you start performing them so you know what to expect

1. Disconnect any cables from the red and black jacks on the front of the power supply.
2. Press the power switch in the lower left corner to turn it on. The display should light up indicating the voltage settings for the three outputs. Below each voltage reading it should say "<OFF>". This indicates that while the output may be adjusted for a certain voltage, at this time the output is turned off. This is done to prevent circuits from being burned out in case the output voltage was set by the previous user to some voltage that is incorrect for what it's now connected to.
3. Press the CH1 button and then the I-Set button so you can adjust the current limit on channel 1. The display should show the maximum amount of current the power supply will provide for the three outputs and the one for channel 1 should be blinking with an underline cursor under one of the digits. If no action is taken to adjust the current within about 4 seconds, the display stops blinking and you'll have to press the I-Set button again to make an adjustment.
4. Rotate the wheel to the right of the display until the current limit for channel 1 is at least 0.3A. The exact value is not important, it just has to be something around there. If it's already set to some higher value, you can just leave it there.
5. Press the CH1 button and then the V-Set button so you can adjust the voltage on output channel 1. The display should now show the voltages that are set for the three outputs and the one for channel 1 should be blinking with a underline cursor under one of the digits. If no action is taken to adjust the voltage within about 4 seconds, the display stops blinking and you'll have to press the V-Set button again to make an adjustment.
6. The wheel to the right of the display is used to adjust the digits above the cursor. The cursor can be moved left or right with the triangular buttons next to the Enter button to make changes to each digit individually. Use the buttons to move the cursor until it is under the tenths of a volt digit, just right of the decimal point. Rotate the knob back and forth and note how the number above the cursor changes but the ones to the right (hundredth and thousandths of a volt) do not change. Also note that if you change the tenths of a volt far enough the number to the left of the decimal point will change accordingly as you move the voltage setting up or down. The voltage setting can be set by changing each digit individually, or by using the knob to change one of the fraction of volt numbers and doing a lot of spinning of the knob until the other digits also are set properly.
7. Use the controls to set the voltage for channel 1 to 2.58 Volts. After you do this the display still shows "<OFF>" for each channel since the outputs have not yet been turned on.
8. From the rack of test leads in the right front corner of the classroom, get a red and black test lead. These should have a banana plug on one end and a metal pin on the other end (see below).
9. Plug the red and black banana plugs into the Channel 1 output banana jacks (red to red, black to black.)
10. Plug the pins on the other ends of the test leads into one of the the red and blue bus strips on the breadboard as shown below on the right.

### Digital Multimeter (Background + Lab Tasks)

The digital multimeter (DMM) is a combination of several instruments and can be used to make a variety of measurements on electrical signals.

• Voltmeter for measuring AC and DC voltages. The voltage level is indicated in volts (V), millivolts (mV) or microvolts (μV).
• Ammeter for measuring AC and DC current. Current is measured in units of amperes or amps (A), milliamps (mA) or microamps (μA).
• Ohmmeter for measuring electrical resistance. Electrical resistance is measured in units of ohms (Ω), kilohms (kΩ), or megohms (mΩ).
• Frequency meter. The frequency of a time varying signal is measured in cycles per second or Hertz (Hz)

To set up the DMM for this lab experiment, perform the following steps.

1. Turn on the digital multimeter (shown below) by pressing the green button in the lower right corner.
2. After it's done starting up, press the "DC V" button to set it for measuring DC voltages. All measurements except DC and AC current use the "HI" and "LO" input jacks at the far left side of the front panel under the word "INPUT". Don't use the two jacks under the word "SENSE" or the two bottom ones.
3. From the rack of test leads get another set of red and black test leads with banana plugs and pins.
4. Put the red and black banana plugs in the "HI" and "LO" jacks on the multimeter (red = HI, black = LO). Make sure you are using the inputs on the left under the word "INPUT".

5. Plug the pins on the other ends of the test leads into the same red and blue bus strips
on the breadboard as was done with the leads from the power supply in the previous section.

6. Once both pairs of test leads from the power supply and DMM are attached to the breadboard, press the "On/Off" button just left of the digit "7" on the power supply keypad to turn on the power supply outputs. The button should illuminate with a green light and on the display the "<OFF>" indicators should be replaced by numbers showing how much current is flowing on each power supply channel (probably zero).
7. The multimeter should now be showing the voltage it is measuring from the power supply. It probably isn't exactly 2.58 Volts but should be close.
Question 1:
What voltage was the power supply set for, and what voltage did the DMM measure?

Once you have recorded the voltage on the answer sheet, turn off the power supply outputs by pressing the illuminated green "On/Off" button. Note: Throughout this lab and ones in the weeks to come, when the instructions say to turn on or off the power supply outputs, do this with the green "<OFF>" button below the OUTPUT label. That button controls the power supply outputs but leaves the instrument itself turned on. Don't turn off the power to the whole power supply with the green POWER button or you will likely lose the settings you have made.

### Resistor Color Code (Background + Lab Tasks)

From the instructor's podium at the front of the room get one of each of the three resistors that will be used in the following experiments. In this experiment, we will determine the resistance marked on each resistor and then use the DMM to measure the actual resistance.

The resistors have a cylindrical body with wire leads coming out of each end. The body of the resistor is marked with a series of four color bands (see below) that are used to identify the resistance value. To determine the resistor value, first figure out which way to read the color bands. One of the bands at the end of the resistor body will be either a silver or gold color indicating the precision of the resistance value (silver = 10%, gold = 5%). The three bands at the other end indicate the value. The first and second bands are the first and second digits of the resistance value as given by the color codes shown below. The third band is the number of zeros that follow the first two digits. For example, a resistor with yellow, violet and red bands is a 4700Ω or 4.7kΩ resistor.

Make sure you have three resistors with different values (color bands are different) and then do the following:

1. From the color bands determine the resistance of each of the three resistors. Note: You should have resistors of at least 100Ω and less then 1.5kΩ. If the values are outside that range get other ones from the bins on the podium.

Important: We will be using these resistors in later parts of this lab. The one with the lowest resistance will be referred to as resistor "R1", the middle resistance as "R2", and the one with the highest resistance as "R3". Record your results on the answer page.

2. Remove the test leads with the pins from the multimeter and replace them with the pair that have the test clips on one end and banana plugs on the other as shown below on the left.
3. On the front of the multimeter, set it for making resistance measurements by pressing the "Ω" button.

For each of the three resistors, do the following two steps and record your results on the answer sheet.

1. Connect each of the two test clips to one of the two leads coming from the resistors as shown below on the right. Hold the body of the test clip with a couple of fingers and then with your thumb press the back of the test clip to cause the metal hook to extend from the other end of the clip.
2. Once both clips are connected to the resistor leads, the meter should display the resistance in either Ohms, KOhms, or MOhms. The values of the three resistors that you measured should be within about 5% of the component values you determined above by reading the color bands.

Question 2:
What are the values of the resistors R1, R2 and R3 from the color bands?

What are the values of the resistors R1, R2 and R3 by measuring with the DMM (round to the nearest integer)?

### Schematic Diagrams (Background)

Electronic circuits are drawn using a schematic diagram. These show what types of components are in the circuit and their values, and also shows the interconnections between all the components. With a schematic of a circuit, an engineer has all the information needed to wire up the circuit in the way intended by the person who designed it. However it's important to remember that a schematic is not a diagram of how the components are physically arranged. The components can be laid out physically in numerous ways.

When assembling a circuit on a breadboard, examine the schematic and look for the connection points where multiple components must be tied together. For example, the schematic diagram below on the left shows four components of some type that are connected together at a common connection point. The output of component A is connected to inputs of three other components (B, C and D). Therefore on the breadboard you would need to have a point where the four wires coming from the components are electrically connected together. By plugging the four wires from these devices into one of the sets of five holes that are connected together as shown on the right the connection is established. Throughout a circuit each connection point of two more signals will need to use a separate strip of the five breadboard holes to connect them together. As mentioned above, if a point in the circuit requires that more that five signals be connected together, simply use a piece of wire to connect two multiple 5-hole strips together effectively building a larger connection point.

### Resistors in Series (Background + Lab Tasks)

Using the resistor with the smallest resistance as R1, and the one with the middle resistance as R2, build the circuit shown below on the left with the two resistors in series. Resistors are not polarized meaning that they can be connected in a circuit in either orientation. The figure on the left shows how the resistors are placed on the breadboard.

When resistors are connected in series their resistances add together. The total resistance in the circuit is then R = R1 + R2 and by Ohm's Law the current flowing in the circuit is given by

Since the same amount of current is flowing through both of the resistors, the voltage across each resistor is then

Using this equation with Vs = 5V, and using the values of R1 and R2 that you measured with the DMM, calculate using pencil/paper what the voltage should be across each of the two resistors.

Question 3:
What are the calculated voltages V1 and V2 across resistors R1 and R2?

To test the above results we have to provide the Vs power supply to the circuit.

1. Make sure the power supply outputs are off (green button not lit up)
2. Plug the red and black banana plugs of the test leads with the pins on the end into channel 1 of the power supply.
3. Plug the pins on the other ends of the test leads into the breadboard at the points where the positive and negative Vs voltages are to be connected to your circuit as shown above on the right.
4. Adjust the voltage on channel 1 of the power supply to be 5.0V.
5. Turn on the power supply outputs.
6. Plug the test leads with banana plugs on one end and test clips on the other into the DMM if they aren't there already.
7. Set the multimeter to measure DC volts and measure the voltage drop across each resistor. You're measuring the V1 and V2 voltages as shown above on the left.
Question 4:
What are the measured voltages V1 and V2 across resistors R1 and R2?

### Switches for Inputs (Background + Lab Tasks)

A common input device for our embedded circuits is a simple pushbutton switch. The button consists of two electrical contacts, and when the button is pressed it connects them together. When the button is not pressed, the two contacts can have different voltages on them. When the button is pressed, whatever voltage is present on one contact is now on the other contact. We will use the switches as inputs to the Arduino in a way that allows the Arduino's program to sense whether the button has been pressed or not, and take different actions accordingly.

1. From the instructor's podium get one of the small plastic buttons shown below on the left. On the bottom of the button are four pins that can be inserted into your breadboard.
2. Install the button on the breadboard as shown in below on the right. To make the circuit work, the button must be oriented properly when installed on the breadboard. Note that one side of the round button is flat. The flat side of the button must be toward the bus connections, and it should be installed in the holes near the channel in the middle of the breadboard so the holes below the flat side are accessible.

3. Get a small piece of wire from the instructor and strip the insulation off both ends using your wire cutters.
4. Insert one end of the wire in one of the ground bus hole (blue bus) and the other into one of the holes below the button as shown in above.
5. Connect the power supply to the breadboards with the black lead going to the ground bus on the breadboard and the red lead to the power bus as shown.
6. Connect the multimeter to the breadboard in a similar fashion. The black lead from the DMM goes to the same ground bus that the power supply is attached to. The red lead goes to the other switch contact. Note that there should be one unused hole between the button's ground connection and the red DMM lead as shown in the figure.

7. Set the DMM to measure DC Volts by pressing the "DC V" button.
8. Set the power supply output for 5.0 Volts and turn the output on with the green button.
9. Note: What we have wired is an INCORRECT way of wiring a button. We want to show you that while you CAN produce a clean '0' (low) voltage, you CANNOT produce a clean '1' (high) voltage.
10. The meter is now measuring the voltage on one of the switch contacts. Try pressing the button and see how much the voltage changes. When the button is not pressed the voltage reading will NOT be stable. It will slowly increase. Spend a few seconds watching the voltage value "float" around. Read below to understand why.

When the switch is pressed, the output side of the switch that is connected to the DMM should show the voltage is pretty close to zero volts since the switch is connecting it to ground. However when the switch isn't pressed, the voltage can be just about anything since the switch output isn't connected to anything. It will probably be close to zero volts but may be something a bit higher (perhaps somewhere between 0 and 1.0 volts), and the value may drift up or down as you watch it. Try touching the metal part of the red lead near the switch with your finger and this may cause the measured voltage to change. This circuit isn't really doing anything useful and the reason is because when the switch is open (not pressed) the output isn't connected to anything that would cause a known non-zero voltage to appear there. In electronic circuit terminology, we would say the output is floating.

Question 5:
What are the voltages (or range of voltages after watching for a few seconds) on the switch output when it is not pressed and when it is pressed?

To make the switch circuit into something useful we need to change the circuit so the output isn't floating when the button is not pressed. Turn the power supply output off with green button and then make the changes shown below.

1. Remove the DMM red lead from the hole below the button and move it
to some unused five hole connection block.

2. Using resistor "R2", the one with the middle resistance value from the three you worked with in Part A, install it with one end in the +5V bus and the other end in connection blocks where the DMM's red lead is.
3. Take a piece of wire and make a connection between the hole below the switch and the connection block where the DMM and resistor are wired.

Turn the power supply output back on and repeat the observations you did before.

Question 6:
With resistor R2 added to the circuit, what are the voltages on the switch output when it is not pressed and when it is pressed?

If you wired the circuit properly, the output should be very close to +5V when the button is not pressed and be very close to zero volts when it is pressed. By adding the resistor between the button output and the +5V, we've eliminated the floating problem and the output of the button now covers a much wider range of voltage between the pressed and not pressed state. The output is also now solidly fixed at the value you are reading. It won't wander up and down like it did when it was floating.

For now don't worry about why this works. We'll cover the details of why the resistor is needed in a later lecture.

### Light Emitting Diodes (LEDs) (Background + Lab Tasks)

LEDs are hooked up in circuits in a similar fashion as resistors in that they both have two leads and current goes in one and out the other. However unlike a resistor the two leads are different. One is the "anode" and the other is the "cathode". Current can flow through the LED from the anode to the cathode but not the other way. When a voltage is applied across the LED causing current to flow from the anode to the cathode the LED lights up.

LEDs come in several package shapes and sizes. For this lab we are using LEDs in a 5mm round case. These have two leads on the bottom and the anode lead is slightly longer than the cathode. In addition there is a flat spot on one side of the plastic case to indicate the cathode. Get an LED from the instructor's podium and examine it. Make sure you can identify which lead is the anode (longer lead, round side of case) and which is the cathode (shorter lead, flat side of case).

LEDs also respond to a voltage across it differently from a resistor. Unlike a resistor where the voltage across it goes up linearly with the amount of current passing through it, an LED has the property that the voltage across the LED is always about the same (around 2.0 volts) for the typical amount of current needed to light up the LED. However, if the LED is just connected to a voltage source by itself, the LED will allow as much current to pass through it as the voltage source can supply. This can result in way too much current going through the LED and may cause it to burn out. To prevent this we always use a resistor in series with the LED to limit the amount of current passing through the LED to a reasonable value.

By selecting the appropriate value for the resistor the amount of current through the LED can be limited to whatever is needed. Referring to schematic above, Kirchoff's Voltage Law says that

Vs = V + VLED = IR + VLED

where VLED is the voltage drop across the LED. Solving for I gives

I = (Vs - VLED)/R

We'll use the equation in the next section to determine how much current is flowing through the LED for different values of the current limiting resistor.

### Logic Circuits (Background + Lab Tasks)

Now that we have an input device that can signal two different states, and an output device to use as an indicator, let's use some digital logic to hook them together and make them do something.

We want to make the switch turn the LED on when the switch is pressed and off when it's not pressed. In the experiment above when the switch was pressed a it produced a low voltage (logical zero), however the LED lit up when a high voltage (logical one) was present to cause current to flow through it. To make the circuit operate as desired, we need a digital circuit that causes an input of a one to produce a output of zero, and vice versa. As we will see in later classes, the action of changing a signal from high to low or low to high is known as a logical inversion.

For the inverter operation we'll use a 74LS04 integrated circuit which you can get from the instructor's podium. The 74LS04 contains six logical inverters that each change an input of zero to a one, and a one to a zero. The IC has 14 pins on it, numbered from 1 to 14. Use the diagram below to locate on the IC the mark or notch that identifies the location of pin 1. Once you have identified pin 1, install the 74LS04 on your breadboard as shown so that the chip straddles the slot down the center of he board and is oriented so pin 1 is on the side of the slot closest to the blue line. Make sure the 74LS04 is seated firmly into the holes of the breadboard otherwise its pins will not make solid contact with the breadboard connections.

Remove the connections to the DMM and follow the schematic diagram and picture above to make the following wiring connections.

1. Connect pin 14 of the 74LS04 to the red power bus.
2. Connect pin 7 of the 74LS04 to the blue ground bus.
3. Connect the input of the inverter (pin 1) to the connection block with the R2 resistor and the switch. This is the green wire in the picture above.
4. Insert one lead of resistor R1 (the lowest resistance value) into a hole in an unused connection block, and the other end of the resistor R1 goes into a hole in the blue bus (Ground). This will be the LED's current limiting resistor.
5. Install the LED so the cathode (shorter lead, flat side of case) is in the connection block with resistor R1, and the anode (longer lead, round side of case) is in another available connection block. Don't worry if you get it backwards. The LED is not going to burn up, it just won't light up like it should. If that happens, pull it out and try it the other way.
6. Connect the output of the inverter (pin 2) to the anode of the LED (round side). This is the yellow wire in the picture above.

Turn on the power supply outputs and try pressing the button. If it's wired properly, pressing the button puts a logical zero on the inverter input, which produces a logical one on the output and that lights up the LED.

As discussed above, the value of the resistor determines how much current will flow through the LED, and therefore how bright it will be.

1. Replace the the R1 resistor with R3, the resistor with the highest resistance of the three, and see if the brightness of the LED changes. Since the R3 resistor is about 6 times higher than R1, it allows much less current to flow through the LED and it should be noticeably dimmer.

Question 7:
In the circuit we've just built with an LED as an output indicator, the output voltage on pin 2 of the 74LS04 is probably around 4.0V. Using equation above and assuming Vs = 4.0V and a VLED of 2.0V, calculate the current the R1 resistor and the R3 resistor is allowing to flow through the LED.

### Logic Thresholds (Background + Lab Tasks)

Logic circuits have to interpret voltage levels and determine if the voltage represents a logical zero or one. This usually down by setting a threshold voltage in logic circuit. If the input voltage is below the threshold, it's interpreted as a logical zero, and if it's above the threshold it's considered to be a one. In this experiment you will try to determine what the threshold voltage is for the 74LS04 inverter that you used above.

In this experiment channel 1 will provide power to the IC and channel 2 will serve as the input signal. Note on the diagram below that all four black wires from the 74LS04, both power supplies and DMM plug into ground bus. This connects them all together and establishes a common ground for both power supplies, the DMM and the 74LS04.

1. Turn off the outputs of the power supply.
2. If you haven't done so already, remove the LED, the switch and the two resistors from the board. All you need on the breadboard for this experiment is the 74LS04 and its power and ground wires.
3. Set channel 1 of the power supply to output +5V. Connect the black lead from channel 1 to the ground bus on the breadboard and connect the red lead to the red power bus.
4. Set the DMM to display DC volts and connect the read lead to inverter output (pin 2) of the IC. The black lead from the DMM should be connected to the ground bus on the breadboard.
5. As you did for channel 1 at the start of this lab, now set the current limit for channel 2 of the power supply to something like 0.3A.
6. Set the output voltage of channel 2 of the power supply to 0V. Connect the black lead from channel 2 to the ground bus and connect the red lead to inverter input (pin 1) of the 74LS04.
7. Turn on the outputs of the power supply

Note: Once you apply power to the 74LS04, the indicated voltage for channel 2 on the power supply may not be at 0V any longer. Even though you set it for 0V in step 5 above, the 74LS04's input may drag the voltage up a bit when it is turned on. You can ignore this in the steps below. Just record the value you set the power supply to even though it may show a different value on the display.

The DMM should show a voltage of between 4 and 5 volts. Since you are putting a logical 0 on the input of the inverter, the output is in the logical one state which for this type of IC is a voltage above 4 volts.

Select channel 2 on the power supply and move the underline cursor until it is under the tenths of a volt digit. Rotate the knob to increase the input voltage by 0.1 volts with each click of knob and observe the inverter output voltage displayed on the DMM. Note that as you increase the input voltage the output changes very little until the input reaches the logic threshold, and then the output drops rapidly towards zero volts.

Question 8:
Show the measured output voltages for the input voltages listed in the table on the question sheet.

### Results

The answers to the above questions should be edited into the "Lab1_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.

The three resistors can be returned to the instructors podium. Keep the other parts you acquired for this lab (button, LED, 74LS04) in your project box. These will be used for next week's lab and you can return them at a later date.