Professional Documents
Culture Documents
Lab Manual
Lab Manual
Lab Manual
Enrique J. Galvez
Department of Physics and Astronomy
Colgate University
February 2015
ii
1
Preface
This lab manual provides lab exercises for most of the topics covered in Electronics
with Discrete Components. With a couple of exceptions, all the labs have been tested
in our own course, at Colgate University. So they work. I have tried to emphasize
applications to make the subject more relevant and interesting. It is important to
make the labs fun, because then, students will want to do more and explore on their
own.
Some of the topics have more labs that can be accommodated in a single afternoon,
so the instructor should use judgment in deciding which to use, or expand to two
different days. However, I find it important to do labs that are closely tied to the
lecture that immediately preceded it. Electronics has so many details that lecture
alone is not a good learning environment. The real learning occurs in the lab, where
students get a feel for what works, and absorb the details that the lecture is so
ineffective at conveying. It is good practice to give students pre-lab assignments
where they have a task to study a data sheet or some aspect of the lab, so that when
they come in they are more familiar with the course
This edition of the Lab Manual manual incorporates the Arduino UNO board,
which introduces students to interfacing and programming. I am not done; it does
not include the use of Arduino for analog labs. Arduino makes the labs “smarter,”
as some jobs can not be done by a small processor, but it also adds a new dimension
for designing the stand-alone smart circuit. It is good to still have a good dose of
wiring in the lab because it teaches students troubleshooting and finding ways to
solve problems.
The Appendix has my own comments and recommendations to the instructor.
Students should not get the Appendix because in some cases I describe the outcome
and give answers to questions. The appendix also has the Arduino programs for use
in the labs. Finally, I want to thank Carl Grossman for introducing me to Arduino,
and to Shannon Zachow for helping with the circuits and scripts.
E.J. “Kiko” Galvez,
February, 2015.
2
Chapter 1
Figure 1.1: Lab exercise for Section 1.1: Circuit that senses a darkened environment.
The circuit has four main parts. On the left side of the figure you see a 5-V power
supply. There are two resistors in series in the branch next to it. Then there is a
3
4 CHAPTER 1. LAB 1: THE BASICS
box, labeled CD4066. It is an electronic switch. To the right of the box is a branch
that has a resistor in series with a circuit element labeled LED. The latter is a light
emitting diode (LED). When current passes through it, it emits light. Let us see how
we use this circuit.
2. Electronic Switch Our electronic switch is the CD4066 IC. It works the fol-
lowing way: when the voltage it senses on pin 13 is VC > 2.5 V a voltage applied
to Vin (pin 1) gets connected to Vout (pin 2). If the 5-V at Vin is connected to
Vout , a current will flow through the LED. Therefore, if we apply more than 2.5
V to pin 13, the circuit for the LED gets switched on and it will emit light.
Make a diagram of the full circuit showing the calculations that led you to the
values of the components that you chose. How well does it work? What would you
change to make the delay longer?
6 CHAPTER 1. LAB 1: THE BASICS
2. Using Kirchhoff’s laws calculate the values of the currents I1 , I2 and I3 using
the measured values of the other components.
3. Using The DVM (in the 300mA scale) measure the currents I1 , I2 and I3 , and
compare those values to the predicted ones.
1. Assemble the circuit of Figure 1.5 using the function generator as the source.
The condition that must be satisfied to make the capacitor behave as an inte-
grator is VC V . This is achieved whenever T RC, where T is the period
of the input voltage. Verify the integrating properties of the above circuit for
1.4. RC CIRCUIT AS AN INTEGRATOR AND DIFFERENTIATOR 7
square waveforms with the oscilloscope (for better comparison display VC and
V in channels 1 and 2 of the scope). Measure the peak-to-peak voltage and
period (T ) of both waves. If you consider that
1 Z T /2
VC (T /2) − VC (0) = V (t)dt, (1.1)
RC 0
and since V (t) is constant during half a period, you can obtain a relationship
between both peak to peak voltages. Compare the measured values with the
calculated ones.
2. Switch the resistor and capacitor from the previous circuit. The differentiator
condition is dV /dt dVr /dt occurs when ωsource 1/RC. In this case the
signal after the filter is proportionally to the derivative of the input signal:
dV (t)
VR = RC . (1.2)
dt
Connect the function generator (set to triangular waveform) at a frequency that
satisfies the above condition and observe and measure the resulting waves with
the scope. Compare your measurements of VR with the value you expect from
the calculation. Without change anything else, switch the waveform setting
of the function generator to a square wave. Record your observations. Is this
consistent with what you expect?
8 CHAPTER 1. LAB 1: THE BASICS
Chapter 2
Required equipment: Arduino UNO board, PC with a serial port (see Figure 2.3),
oscilloscope and probe with a “hook” (this is so the student does not need to be
holding the probe with his or her hands), serial-port driver program (free downloads
from the internet are available).
Required components: serial port connector with the following connections pins 2
& 3, 4 & 6, and 7 & 8 (see Figure 2.4), switch and 1 kΩ resistor.
2.1.1 Description
The Arduino UNO board is one of a series of smart boards that can be programmed
and detach to operate by themselves or for interfacing with the real world via the USB
port of the computer. Figure 2.2 shows a view of the device. It has the ATmega48PA
micro controller– a computer in itself, set up to be programmed and to do basic
computing operations. The Arduino UNO has the following features:
• 14 digital I/O lines
• 6 analog (10 bit) input lines
• 16 MHz clock
9
10 CHAPTER 2. LAB 2: DIGITAL I/O
Figure 2.1: View of the Arduino UNO board showing its main components.
• 32 kB of memory
• 2 kB of SRAM
• USB connection
• Optional power input when not drawing power from USB
• Programmable via C-language-based instructions
Throughout this course we will use the Arduino board to make our circuits smarter
and more versatile.
2.1.2 Programming
The Arduino UNO board gets programmed with a script program. The instruction
set can be found in http://arduino.cc/en/Reference/HomePage. It is based on the
C-language instructions. The board is set up to be always working, so its instruc-
tions have two environments: setup and loop. In setup we define the functionality
(input/output) of on-board pins or variables. The setup or loop environments is
contained within curly brackets { and }. Comment lines begin with a double slash
(//).
For example, if we want to define I/O pin #4 as an output, we define it with
instruction “pinMode”
2.1. I/O WITH THE ARDUINO UNO MICROCONTROLLER 11
void setup() {
pinMode(4, OUTPUT);
}
void loop() {
digitalWrite(4, HIGH); // high part of the pulse
digitalWrite(4, LOW); // low part of the pulse
}
Note that we put a comments on each line. It is good practice to do this so you
know what your program does.
2.1.3 Procedure
Pulse Out
• Double-click on the Arduino icon to load up the editor. In that area you enter
the program. Enter the example program listed above.
• Press the checkmark to compile it. Errors will appear if you do not have the
correct syntax. if this is successful, press the right-arrow button to upload the
program. Once it is loaded, it starts running.
• With the oscilloscope observe the output of pin 4. Make sure the oscilloscope
ground is connected to the board ground. Make a sketch of the oscilloscope
display with the correct scale (vertical and horizontal). The information gives
you an idea of how fast the Arduino processor goes.
• Let us add some delay. Insert the instruction “delay(10);” and delay(20); after
the first and second digitalWrite instructions, respectively. They add 10 and 20
milliseconds delay, respectively. Examine the waveform with the oscilloscope.
12 CHAPTER 2. LAB 2: DIGITAL I/O
LED on
Let us get more advanced:
• Program a lighting pattern. Note that we our eyes need times of the order of
50 ms or longer to see distinct blinks. Verify this.
• Now program a second pattern. Use the “if” instruction so that the LED
alternates between patterns every loop. This will require some thinking and
clever programming. You may need a variable (let us call it “flag”) to use with
the if instruction, then you have to define it before the “void setup” instruction:
int flag = 1;
void setup() {
pinMode(13, OUTPUT);
}
void loop() {
if(flag == 1) {
// do something (output high, low, with pin 13, delays, etc.)
}
else {
// do something else
}
Input In
Now let us provide Arduino program with an external input, and make the program
respond to the setting (high/low) of the input.
• The input has to be a logic signal, so you need to wire the switch shown in the
Fig. 2.2, and connect it to pin 5. Grounds of the external circuit and Arduino
have to be connected (but not the power).
• Now let’s do something cool: use the input in pin 5, controlled by the switch,
to flip between the two sequences of lightings that you programmed earlier.
As you will gather from this exercise, we can use digital I/O to communicate with
the external world. This is just the beginning: all the physical quantities in the real
world can be inputted through sensors and I/O operations, and conversely, anything
that can be controlled by electrical means can be controlled by our device as well.
Figure 2.3: Back side of a typical computer from 2006. It shows the various I/O ports
that it has.
other that is it ready to send data, and the receiver responds with a signal indicating
it is ready (or not) to receive the data. This is called “hand shaking.”
Most PCs still have a serial port that supports the RS-232 protocol. The connector
that attaches the serial port is a 9-pin “female” connector. Pins 2 and 3 are to transmit
and receive data, respectively, a number of other pins are for the handshaking, and
pin 5 is a common reference line. Table 2.1 below shows the pin definitions.
Here we will see how data is sent serially by “faking” the PC. That is, connecting
pins 2 and 3, so that the PC receives what it sends, and connecting the other control
lines (7 & 8 and 4 & 6) such that the PC interprets that all is fine with the commu-
nication. Pin 5 is signal ground. A summary of the connections is given in Table 2.1,
and photos of the rigged connector are shown in Figure 2.4.
Procedure
Plug the 9-pin connector with the rigged transmission lines to the serial port of your
PC (port A if there are more than one). Connect also pin 2 of the connector to
channel 1 of the scope, and pin 7 to the ground of the scope. Turn the PC on and run
the terminal emulator program. You will receive instructions from your instructor.
Go into line settings and set the communications to COM1, 9600 baud, even parity,
and 7 bits. Measure the waveform that results after pressing a key.
Serial transmission follows a certain protocol:
• The data is preceded by a high-voltage start bit.
2.2. SERIAL TRANSMISSION OF ASCII-CODED CHARACTERS 15
Table 2.1: Connections for the RS-232 serial port with a 9-pin connector.
Figure 2.4: Two views of the rigged 9-pin serial connector. Pins 2 and 3, 4 and 6,
and 7 and 8 are connected together. Connecting pin 5 (signal ground–not shown) is
optional because the computer grounds pins 7-8 during communications.
• The last bit is a “parity” bit, used as a check for any errors in the transmission.
When the parity is set to even, the parity bit is set accordingly such that the
total number of 1’s in the character and the parity bit is an even number. That
is, it will be set to 1 when there is an odd number of 1’s in the character.
Questions:
1. Your challenge is to determine how the data is transmitted. This entails figuring
out the logic levels (0=high-voltage, 1=low-voltage, or vice versa), and the order
in which the bits are transmitted (i.e., MSB first or last).
16 CHAPTER 2. LAB 2: DIGITAL I/O
2. Measure the bit transmission frequency and identify the units of the baud rate.
1. The goal of this lab is to implement the half adder, shown schematically below.
It performs the addition of two binary digits x and y yielding a sum bit S and
a carry C.
x
plus y
C S
Fill in the truth table below by writing the values for the outputs S and C.
x y C S
0 0
0 1
1 0
1 1
17
18 CHAPTER 3. LAB 3: COMBINATIONAL LOGIC
2. After you have filled the table find a Boolean expression for S and C.
3. The circuits for S and C obtained above require NOT, AND and OR gates.
Wiring such a circuit can prove to be wasteful. If we use all (universal) gates of
one kind, such as NAND gates, the task will be more efficient. Apply DeMor-
gan’s theorem to the Boolean expressions for C and S, and obtain expressions
in terms of NAND operators (for example, A + B = [(A + B)0 ]0 = [A0 · B 0 ]0 ).
Draw the circuit diagrams for C and S. As you will see, you will only need
two-input NAND gates for the diagram. However, you still have to worry about
the NOT gates. Use NAND gates in some clever design to replace the NOT
gates. This way you will fully use a single type of gate.
4. In the diagram of Figure 3.1 you will find the pin connections for the “quad
two-input NAND gate” chip, the 74LS00 (see Figure 3.2). (In the future you
will have to look up the pin connections yourself in the data sheets.)
1 V c c 1 4
2 1 3
3 1 2
4 1 1
5 1 0
6 9
7 G N D 8
Figure 3.2: View of the integrated circuit (chip) containing four two-input NAND
gates, the 74LS00.
As a general rule for preventing later nightmares, label your circuit the following
way: on the outside of each gate symbol label the inputs and output of each
3.1. THE TTL HALF ADDER: DESIGN AND CONSTRUCTION 19
gate with the pin number of the chip, and in the inside of the gate symbol write
a chip label. All chips look alike, and if your circuit is a bit sophisticated and
doesn’t work you are in for a long afternoon trying to figure out what is wrong.
Make a diagram of your circuit now. See the example of Figure 3.3.
A 1 3
2
1
1 3 4 6
1 1
1 5
1 F
1 2 9
B 8
1
1 0
1
2 3
2
5. There are also some other general guidelines that will save you trouble in the
long run: orient all chips the same way, and color-code at least the power
(VCC = +5V , for example, red) and ground (for example, black) for each chip.
Do not use a breadboard that is old or with burnt spots, because one bad
connection (a bad bit) can ruin the whole circuit.
Use short wires, but do not let them go on top of chips since these may have to be
replaced. In general, the more “artistic” your circuit looks the less nightmares
you will avoid.
6. Before you wire your circuit show the diagram to your instructor to make sure
it is OK. Get the chip(s) you need from the chip rack and wire the half adder
circuit. Connect the inputs of the adder (x and y) to switches and the outputs
(C and S) to LEDs. Once it is all wired up turn the logic board ON and test
the truth table of the half adder. Good luck!
7. Now let us go “pro” with Arduino. Set it up in the script so that pins 4 and
5 of Arduino are variables x and y, respectively. Connect them to LEDs as
well. Now write a script that sets the values of x and y according to the truth
table for 1 second in each combination and loop indefinitely. Make sure that
the grounds of Arduino and the logic board are connected together.
If your circuit works, congratulations! Indeed after all those physics labs, you get
a sense of letdown when the answer is just: it works! Well, it is also a happy feeling.
Next we have one further embellishment, and then we are done. But do not get too
comfortable because we are just getting started.
20 CHAPTER 3. LAB 3: COMBINATIONAL LOGIC
(a ) (b )
+ 5 V
a
a + 5 V
f b f
g b
e c g
d
e
c
d
Each of the seven segments of the display is a different LED. The segments you
will use are wired in the “common anode” configuration, as shown in Figure 3.5. To
wire them you need to put a 220 Ω resistor in series with each LED. However, since
this is a common occurrence in digital, the seven resistors that are needed come in a
single package. The package is set up so that the resistors connect the pins that are
opposite to each other in the chip. Wire the resistor package to the seven-segment
display and test it.
3.3. THE 74LS47 BCD TO SEVEN SEGMENT DECODER 21
_ _ _ _ _ _ _
a b c d e f g
_ _
L_ T_ _ 7 4 4 7
R B I
D C B A
4.1.2 Procedure
1. Wire all the inputs (data and control) to switches and all the data outputs to
LED’s in the logic board. Try a few operations and verify that the ALU works
as specified.
23
24CHAPTER 4. LAB 4: COMBINATIONAL LOGIC AND ARITHMETIC LOGICAL UNIT
2. Connect the inputs of the 74LS47 decoder that you wired previously to the F
outputs of the ALU, as shown in Figure 4.1. It is very important that you do not
leave any unused inputs unconnected. Refer to the data sheet of the 74LS181
for a diagram of pin connections and functions.
Try a few operations with the ALU that will give a result between 0 and 9. Once
you reach this point you are done for the day. Read the next section because
you will need to come to the next lab with a circuit diagram.
7 4 4 7
F 3 F 2 F 1 F 0
S 3
S 2
S 1
A L U
S 0 7 4 1 8 1
M
C n
A 3 A 2 A 1 A 0 B 3B 2B 1B 0
Figure 4.1: Wiring of the outputs of the ALU to the seven-segment display.
ations. Then having to provide the six control lines of the ALU is wasteful. Since
there are eight possible combinations of three bits, the minimum number of variables
that we need to specify the eight functions is three. In the circuit of Figure 4.2 the
control lines of the ALU are fed from a decoding circuit, which you will design and
build. This circuit tells the ALU which operation to perform.
The decoding circuit that we will use today has three inputs variables x, y and z
that represent a “code.” This code will specify which operation will be performed.
The role of the decoder circuit is to set the inputs of the ALU to the levels required
for the corresponding operation, as shown in Figure 4.1.
The first two sections of Table 4.2 give the correspondence between the input
variables x, y and z and the operations that the ALU must perform. A completely
filled third section will have the values that each ALU input requires for setting the
proper ALU operation.
4.2.2 Design
The inputs of the ALU S3 , S2 , S1 , S0 , M , and Cn can be thought of as Boolean
functions of x, y and z.
26CHAPTER 4. LAB 4: COMBINATIONAL LOGIC AND ARITHMETIC LOGICAL UNIT
S 3 F 3 F 2 F 1 F 0
x S 2
Y o u r S
y
1
A L U
d e c o d e r S 0 7 4 1 8 1
z c ir c u it
M
C n A 3A 2A 1A 0 B 3B 2B 1B 0
Figure 4.2: Block diagram of the circuit design for the customized ALU.
Table 4.2: Truth Table for the Lines of the ALU as a Function of the Input Variables
of the Decoder
x y z ALU OPERATION S3 S2 S1 S0 M Cn
0 0 0 F=A+B 1 1 1 0 1 ×
0 0 1 F=A·B 1
0 1 0 A 0
0 1 1 B 0
1 0 0 F=A⊕B 0
1 0 1 F=AB 1
1 1 0 F=A minus B 0
1 1 1 F=A plus B 1
1. Using the functional table of the 74LS181 (Table 4.1, complete Table 4.2 for all
the decoder outputs. As an example, the truth table has been partially filled.
Since Cn does not need to be specified when M = 1 we put the don’t care
symbol (×) in the truth table.
2. From the truth table of Table 4.2, draw the Karnaugh map for each variable and
arrive to a simplified expression of each output variable/function. Re-express
the functions in terms of NAND gates and draw a circuit diagram for the whole
decoder.
4.2.3 Wiring
Before wiring anything check with the instructor that your circuit is correct. You
will also need to use 3-input NAND gates, which are in the 74LS10 chips (see the
TTL data sheets for the pin connections). The wiring that you performed in the
first section has to be modified slightly; only the inputs Si ’s, M and Cn should be
4.2. PART II. CUSTOMIZING THE ALU 27
disconnected. The inputs Ai ’s and Bi ’s, and the outputs Fi ’s should not be touched.
Wire your decoder circuits, connecting x, y, z, to switches in the logic board. Connect
the outputs of your decoder circuits: S3 , S2 , S1 , S0 , M and Cn to the corresponding
inputs of the ALU. For a given combination of variables A and B check that all
operations are performed successfully. This is a massive wiring project, and success
calls for celebration: so indulge in couple of high-fives. Okay, you can take a picture
if you must.
4.2.4 Questions
1. If we would not have simplified the functions from the truth table how many
chips would we have needed? How much longer would have taken you to do it?
2. If we wouldn’t have used NAND gates but NOT, AND and OR gates, how many
more chips would we have needed? Use these answers to elaborate your final
conclusions about the usefulness of our method of arriving to a circuit diagram
from a truth table.
4.2.5 Digest
One final word. Stare at your proud circuit and see what will make it easier to debug:
shorter wires are good, color coding and labels are good. A good circuit diagram is
one that can be debugged by others. If your circuit looks like a jungle so that even
you cannot debug it, then it needs some repair work. Make those repairs now because
we are going to continue to work with this circuit.
28CHAPTER 4. LAB 4: COMBINATIONAL LOGIC AND ARITHMETIC LOGICAL UNIT
Chapter 5
5.1 Multiplexing
5.1.1 Arduino as a 4-bit counter
In previous exercises we wrote 1’s or 0’s to individual pins of the Arduino. There is
a way to write four pins at a time using the instruction PORTB. This instruction
groups 6 bits made to work as a single variable, so you can store or read values
simultaneously. They are defined the following way:
(pin#) (13) (12) (11) (10) (9) (8)
MSB LSB
You set the function of the pins with the instruction “DDRB” in the setup part of
the script. In our case we want the pins to be outputs, so we do:
DDRB = B111111;
which defines all six bits as outputs. If we put a 0 in any of the locations of the
declaration above, we should be specifying an input function, but we do not want to
do this for our case. Now suppose that we want to assign the bits of a variable, say
“x” to port B. We first define “x” as a binary variable. In the variable-declaration
section of the script (at the top of the script) we would do:
byte x;
29
30 CHAPTER 5. LAB 5: MULTIPLEXING I/O
Then in the loop part of the script we can assign port B a value:
x = 12;
PORTB = x;
We would be storing the binary number 001100 into our port B, which will set pins
11 and 10 to 1 and pins 13, 12, 9, 8 to 0.
In our application we want to define an integer variable (x) to count from 0 to
15, stepping every half second (i.e., with “delay(500)”), and output the count bits
to a circuit. To do this we will use a new instruction. The instruction may already
be familiar to you if you know Matlab or other programming languages: it is the
for instruction. A for loop repeats a sequence of instructions as an index variable is
changed from an initial value to a final value meeting a certain condition, with an
increment to the variable applied at the end of every loop. A formal definition of the
for loop is:
For example, if we want a for-loop that increases variable y by 1 ever loop, starting
from 1, until it reaches 5, then we do
1. The 4 data inputs of the 4x1 multiplexer are connected to the four I/O pins of
the Arduino UNO board that earlier you connected to LEDs.
2. The select inputs of the multiplexer are wired to digital I/O switches.
5.2 Demultiplexing
Wire a 4 × 1 demultiplexer (153). Study the data sheet for the 74LS153. It has
a function table that specifies it as a “1-line-to-4-line decoder demultiplexer.” Note
that it has its own labelings, plus it has an input (strobe) that activates or deactivates
the device. Wire the demultiplexer with with the following specifications:
1. Wire the output of the multiplexer (previous circuit) to the data input of the
demultiplexer.
2. The outputs of the demultiplexer must be wired to LEDs (each in series with a
resistor). Wire the LED’s so that they turn-on with a 0.
3. Wire the select inputs of the demultiplexer to those of the multiplexer so that
the outputs of the demultiplexer are correlated to the inputs of the multiplexer.
4. The 2-bit counter can be made of two D flip-flops, which we will cover in the
following class. The circuit is shown in Figure 5.1. Wire the outputs of the
2-bit counter to the select inputs of the multiplexer and demultiplexer so that
the LED’s shows the output of the decade counter.
5. The clock input (CLKin) to the counter comes from the logic board. Use the
“TTL mode” output of the function generator. Adjust the frequency to 5 kHz.
Questions:
Lab 8: Circuits
7.1 DC Circuits
Required equipment: DC power supply, multimeter.
Required components: Resistors.
Use V0 = 4.4 V and R1 = R2 such that the current in the loop is 1 mA. Once
you pick the resistors, measure their resistance.
37
38 CHAPTER 7. LAB 8: CIRCUITS
2. Calculate and measure VThev and RThev between points A and B. Compare the
calculated and measured values.
3. Suppose we now use VAB as a voltage source to some circuit that has an effective
resistance RL , as shown in Figure 7.2.
Calculate VAB using the Thevenin method. Also calculate VAB using the stan-
dard circuit-solving method. Assume RL = 1kΩ. Which calculation took less
time? Measure VAB and compare it with your predictions.
4. Repeat the calculation of VAB for RL = 10 kΩ, 100 kΩ and 1 MΩ. Pick the
most convenient method. What do you conclude?
5. Let’s turn this around: Suppose RL = 5 kΩ, what should R1 and R2 be such
that VAB does not get “loaded” too much (that is, VAB−loaded ≥ 0.9VAB−unloaded ).
Select the new resistors R1 and R2 and confirm your calculations with measure-
ments. Give your conclusions regarding the use of a voltage divider as a voltage
source given RL .
Vertical Scale
This part is simple to understand. There is a knob to control the vertical scale in the
screen. It tells you the voltage per vertical division.
All scopes have three settings: DC, AC and GND. The DC setting lets you see the
input in the rawest form. You should try to use it always. There is a lot of confusion
on what the AC setting means. It is not meant to be the setting for AC signals. It
connects the input to a low-pass filter (to be discussed in the next chapter), which
removes the DC component before displaying it. Using it may be convenient, but it
also has its consequences: (1) it let’s you see only an aspect of the input waveform
because it displays all periodic signals relative to their average, and (2) by removing
the low frequencies it distorts the shape of the waveform (i.e., square waves do not
look “square” anymore). The GND setting is useful for knowing the zero-voltage level
of the scope.
Trigger
You should know how to use the trigger. If you do not know the difference between
NORM and AUTO settings, you are only a beginner. In AUTO, the scope displays
the input always. In NORM the scope displays the input waveform only if it meets
the trigger criteria: when the signal input to the channel selected as the SOURCE
has the specified SLOPE and voltage LEVEL settings. (The capitalized words are
standard names across oscilloscope brands, but they may not be fully universal.)
There is a choice for the trigger input: INTERNAL (most common) is used for
triggering on one of the inputs; LINE is for triggering on waveforms that are derived
from the 60-Hz input line frequency, and EXTERNAL is used for triggering on an
external signal input through a separate connection. We must deem the external
input so reliable and that we do not need to see it (for example, a TTL pulse). A
sophisticated user will use EXTERNAL often. Some function generators have a TTL
output that can be used in connection with EXTERNAL so you can see the input
waveform without having to worry about the trigger LEVEL.
Ground Connections
Remember that the ground of the channel inputs are all connected together internally.
They are also connected to the ground of the line input (the third round prong of the
power plug in the U.S.). This limits what you can do when making measurements
on a circuit: you can only measure voltages relative to ground, and when trying to
measure two parts of a circuit simultaneously you may be shorting part of the circuit.
It is not recommended that you bypass the safety grounding of the scope by use
of the “cheater plug” (the plug that converts three prongs to two). The outlets in
40 CHAPTER 7. LAB 8: CIRCUITS
2. Replace the long cable for the short cable. Diagnose the signal in the same way
as before and compare it to the results of the previous section.
42 CHAPTER 7. LAB 8: CIRCUITS
3. Put a tee at the output of the function/pulse generator, connecting the short
cable to the second input of the scope plus tee and terminator. Measure the
propagation time of the signal through the coaxial cable, and compare the
propagation speed to the speed of light (0.98 ft/ns).
Chapter 8
Filters
43
44 CHAPTER 8. FILTERS
Solution
Design a three-stage RC filter that should be put in between the PC and the amplifier,
and before the speaker, such that the noise is filtered out (see Figure 9.2).
Im p e d a n c e
C D p la y e r F ilte r
tra n s fo rm e r
Figure 8.2: Block diagram of circuit for filter a noisy audio signal.
The entire circuit has the four main parts: the PC player, your filter, the audio
amplifier section and the 8-Ω speaker. At the output of the PC player you should
put a load resistor close to 8 Ω; the player will work best if it sees the 8 Ω. Your
three-stage filter must be designed such that each section does not load the previous
one (use the ×10 criteria).
Since the output impedance of your filter will be much greater than the speaker’s
impedance, the audio amplifier also serves as an impedance matching device. The
one we use is the LM380 audio amplifier. It not only takes care of the impedance
problem but also introduces a maximum gain of 50. The LM380 will work well with
small signals so we introduced the 100 kΩ “trimpot” to voltage divide the input in
case it is too high. Wire the circuit exactly as shown. The device generates 2.5 W,
so it needs to dissipate heat. You also need to use speakers (supplied) prepared to
dissipate that amount of power. Otherwise they will burn!
Analysis
Connect the oscilloscope to the speaker. Analyze the waveform with no filter, and
one-, two- and three stages of filtering. Make a sketch of the different waveforms and
explain them.
Chapter 9
Filters
45
46 CHAPTER 9. FILTERS
Solution
Design a three-stage RC filter that should be put in between the PC and the amplifier,
and before the speaker, such that the noise is filtered out (see Figure 9.2).
Im p e d a n c e
C D p la y e r F ilte r
tra n s fo rm e r
Figure 9.2: Block diagram of circuit for filter a noisy audio signal.
The entire circuit has the four main parts: the PC player, your filter, the audio
amplifier section and the 8-Ω speaker. At the output of the PC player you should
put a load resistor close to 8 Ω; the player will work best if it sees the 8 Ω. Your
three-stage filter must be designed such that each section does not load the previous
one (use the ×10 criteria).
Since the output impedance of your filter will be much greater than the speaker’s
impedance, the audio amplifier also serves as an impedance matching device. The
one we use is the LM380 audio amplifier. It not only takes care of the impedance
problem but also introduces a maximum gain of 50. The LM380 will work well with
small signals so we introduced the 100 kΩ “trimpot” to voltage divide the input in
case it is too high. Wire the circuit exactly as shown. The device generates 2.5 W,
so it needs to dissipate heat. You also need to use speakers (supplied) prepared to
dissipate that amount of power. Otherwise they will burn!
Analysis
Connect the oscilloscope to the speaker. Analyze the waveform with no filter, and
one-, two- and three stages of filtering. Make a sketch of the different waveforms and
explain them.
Chapter 10
47
48 CHAPTER 10. LAB 11: DIODES
1. First, using the load-line method determine the best resistor to put in series
with each color. They may be different, so do it for all three colors. Make sure
you know the leads of the LED.
(a) Take the battery off the holder (if already installed).
(b) Solder first the cathode (longer) lead of the LED to the negative terminal
of the battery holder. Using pliers, bend the lead in the form of a hook
first. Squeeze the hook connection with the pliers so that the components
are mechanically hooked. Best technique involves first putting some solder
on the heated iron and heating the two metals to be joined with the iron.
Optimum soldering temperature (about 200◦ C) is reached when the solder
looks wet. Then place more solder on the place where both metals hook
with each other. The final weld should look shiny. Warning: do NOT
inhale! Fumes contain lead and are toxic.
(c) Solder one color at a time. For each color:
i. With the pliers that are supplied bend the lead of an LED color and
10.2. MAKE-AND-TAKE LED FLASHER 49
Figure 10.2: Components of the LED flasher plus the finished product (resistors not
included).
2. We will also provide transparent shrink tubing to provide a cover for the LED
flasher.
Good luck!
50 CHAPTER 10. LAB 11: DIODES
1 k W
~ +
6 .3 V A C b r id g e
~ -
7 8 0 5
IN G N D O U T
2. Calculate the value of the capacitor for the following requirements: a maximum
ripple voltage of 1V and a load of 830 Ω. The latter resistance is the worst-
case load (that is, you will not normally use a 830 Ω resistor). Connect the
capacitor to the output of the bridge and use the 10 kΩ resistor as the load.
Sketch the waveform that you observe on the scope. Measure the ripple voltage
and compare it to what you expect. Repeat the procedure for loads of 1 kΩ
and 500 Ω. Explain the drawbacks of the unregulated supply.
7 8 0 5
~ + IN O U T
C G N D
6 .3 V A C b r id g e R L
1 0 k W 0 .1 m F
~ -
1. Set the function generator to a 1 kHz sine wave. Wire an inverting amplifier
(shown in Figure 14.1) with R1 = 1 kΩ and with supply voltages of ±15 V. Set
R2 such that the gain of the amplifier is 1 and verify it by measuring the input
and output waveforms with the scope.
Figure 14.1: Pin connections of the LM741 or equivalent and circuit to wire the
inverting amplifier.
2. Determine the highest gain that you can achieve. Find out by incrementing the
gain by powers of 10 (you may have to adjust the input voltage). Remember
that the output voltage cannot exceed the supply voltage.
75
76 CHAPTER 14. LAB 14: OPERATIONAL AMPLIFIERS
3. Speaker Microphone
A speaker can work as a microphone. Connect the speaker directly to the scope
and observe the waveform that you get. Small amplitudes? That is what all
audio systems have to deal with: small signals. Send the signal through a
suitable inverting amplifier and observe the output. This output is probably
ready to be sent to a second speaker (in the correct direction now). However,
op-amps do not put out more than a 10 mA, so connecting the op-amp directly
to an 8 Ω speaker will load it too much. Wire a follower/power-booster to drive
the speaker.
+5V
R1
D Vout
E
E D
R2
The output of optointerruptor circuits has high output impedances and small
output signals. Although we could design an optointerrupter circuit ourselves,
we will defer that for another time and just follow the design given below (use
R1 = 180 Ω and R2 = 220 Ω). Wire it and locate the motor blade such that
it interrupts the path of the light from the LED to the detector. Observe the
output of the photodetector with the scope. Connect the motor to a DC power
supply and increase the voltage until you see the chopped waveform in the scope
(just keep the motor/wheel from becoming a helicopter). Wear safety glasses!
Hard crashes of the chopper wheel with the optointerrupter pillars can send
parts flying off.
3. Design a circuit that will invert the waveform of the previous section. The
inverted output should still be between 0 and 5 V.
R '
V in
V o u t
C
R
78 CHAPTER 14. LAB 14: OPERATIONAL AMPLIFIERS
+ 15 V
3904
V1
0-6V
2. Photodetector
(b) Wire the circuit shown below such that the photodetector is nearby the
light bulb. Invert the output to generate an output V3 = −V2 , and observe
with the scope V3 as a function of V1 .
V 2
V 3
B C
p h o to tr a n s is to r
( b o tto m v ie w )
3. Differential Amplifier
VA
R
V4
VB
V5 V6
1
(c) Invert the output of the integrator such that that V6 = −V5 =
R
RC
V4 dt.
80 CHAPTER 14. LAB 14: OPERATIONAL AMPLIFIERS
V A
V 6
c ir c u it o f p a r t 3
V B
V 1
c ir c u it c ir c u it
o f p a rt 1 V 3
o f p a rt 2
14.5. VOLTAGE-CONTROLLED OSCILLATOR 81
1. Set R0 = 50 kΩ. Find a value of R and C such that the frequency is 5 kHz when
Vin = 12 V. Use 12-V power supply for the op-amps. Measure the frequency of
the output for Vin = 2, 4, 6 V, and sketch V1 and V2 for Vin = 6 V. Label your
axes.
3. Generate Vin from the output of a photodiode (properly biased and amplified).
Make sure that Vin varies between 0 and VCC . Can you play a song by blocking
the light reaching the photodiode?
R 2
R 1
V o u t
83
84 CHAPTER 15. LAB 13: REAL OP-AMPS
2. Reduce the input to 5 V and change the waveform to sine-wave. Observe the
output as you increase the frequency. Above a certain frequency, the op-amp
will not be able to follow the input. Measure the slew rate from the output
above that frequency. Compare your result with the previous one.
V o u t
1 0 k W
1 0 k W
Figure 15.2: Circuit to measure the input offset voltage of the op-amp.
3. Take the feedback resistor and measure the output. Trim it further to have Vout
as close to zero as possible. Once you do that put back the feedback resistor
and measure Vout
15.3. INPUT OFFSET VOLTAGE AND BIAS CURRENT 85
1 0 0 k W
V o u t
5
1
1 0 k W tr im p o t
1 0 k W
1 0 k W - V c c
This lab manual is divided in distinct lab experiments that for the most part take
one afternoon. Below are some comments and answers to the lab questions.
3
4 APPENDIX A. COMMENTS FOR THE INSTRUCTOR
position the resistor is connected to the power supply, and in the other position it
is connected to ground. The capacitor must be picked first because, in general, labs
have a lesser variety of capacitors than resistors. Students must do this calculation:
V0
= V0 1 − e−t/RC
2
where V0 = 5 V and t = 2 s. This gives RC = 2s/ ln 2 = 2.88 s. Note that 2
s is a long time, electronically speaking, so we must pick a large capacitor. If we
make C = 10 µF (which has to be electrolytic - make sure students know about the
polarity), then R = 288 kΩ (using 300 kΩ is fine because of the 5% tolerance of the
resistors).
In this lab we ask them to put digital outputs out and realize that their actions
produce signsls they can measure. Then we ask them to input signals and change the
int flag = 1;
void setup() {
pinMode(13, OUTPUT);
}
void loop() {
if(flag == 1) {
digitalWrite(13,HIGH);
delay(1500);
digitalWrite(13,LOW);
delay(1500);
digitalWrite(13,HIGH);
delay(1500);
flag=2;
}
else {
digitalWrite(13,LOW);
delay(100);
digitalWrite(13,HIGH);
6 APPENDIX A. COMMENTS FOR THE INSTRUCTOR
delay(100);
digitalWrite(13,LOW);
delay(100);
flag=1;
}
void setup() {
pinMode(5, INPUT);
pinMode(13, OUTPUT);
}
void loop() {
if(digitalRead(5) == 1) {
digitalWrite(13,HIGH);
delay(1500);
digitalWrite(13,LOW);
delay(1500);
digitalWrite(13,HIGH);
delay(1500);
}
else {
digitalWrite(13,LOW);
delay(100);
digitalWrite(13,HIGH);
delay(100);
digitalWrite(13,LOW);
delay(100);
}
A.3. LAB 3: COMBINATIONAL LOGIC 7
void setup(){
8 APPENDIX A. COMMENTS FOR THE INSTRUCTOR
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
}
void loop() {
digitalWrite(4,LOW);
digitalWrite(5,LOW);
delay(1000);
digitalWrite(4,HIGH);
digitalWrite(5,LOW);
delay(1000);
digitalWrite(4,LOW);
digitalWrite(5,HIGH);
delay(1000);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
delay(1000);
}
3.2 Seven Segment Display
The purpose of this lab is for students to understand that the displays, seven-
segment in this case, are made of lights that have to be powered separately. We
must use common-anode displays because the driver, the 74LS47 IC, is designed to
turn the segment lights with a logic 0. That is, all the segments are connected to
+5 V internally, and we turn each segment by completing the circuit. Here we push
analog without explaining things entirely, something that is done later. Since the
seven-segment display is composed of diodes, we cannot hook them directly to the
supply voltage. We must do this using a resistor in series to limit the current. This
resistor is typically about 200 Ω. The exact value is not critical.
3.3 The 74LS47 BCD to Seven Segment Decoder
For driving seven-segment displays we have two options: The TTL 74LS47, or
its CMOS equivalents, 74HC4511 or 74HCT4511. These are decoders that have four
inputs that represent a binary-coded decimal (BCD) number. The pin connections for
the decoder are given in the data sheets. The TTL and CMOS ICs are pin-compatible.
The outputs labeled a, b, c, d, e, f, and g are functions whose output should light
the LED segments. The decoders have a shortfall, though: They decode and display
A.4. LAB 4: COMBINATIONAL LOGIC AND THE ARITHMETIC LOGICAL UNIT9
Table A.1: Steps to Drive the Seven-Segment Display Depending on the Digital IC
Used
properly decimal numbers (from 0 to 9), but do not decode binary numbers above
9. The 74LS47 has low-active outputs: They output 0 to light the corresponding
common-anode LED. Conversely, the CMOS 4511s are high active, so a common-
cathode display must be used. A second difference that is important to us is that the
CMOS decoder is latched, and updates the segment outputs only when the LE input
goes from low to high. Table A.1 gives the steps you must follow depending on which
family of IC you use. Because our lab experiments are based on TTL ICs, we prefer
to use the 74LS47 here. Wire the decoder and display according to the steps in the
table. If 74LS47 is not available, then use the 74HCT4511 and wire it according to
the table. The resistor package is convenient, but in its absence we can use individual
resistors.
In the last section the students should wire the circuit so that the seven-segment
display shows the result of the addition: 0 to 3, depending on the inputs.
// Lab 5
int x;
byte count0=B000000;
byte count;
boolean flag = false;
void setup() {
DDRB = B111111;
}
void loop() {
if(flag)
count = count0+32;
}
else
{
count = count0;
for(x=0;x<=15;x++) {
PORTB=count;
count=count+1;
delay(500);
}
flag = !flag;
}
exercise in charging and discharging a capacitor. Note that since, in general, there are
fewer capacitor values than resistor values available in the lab, it is better to pick a
capacitor that is available. For example, if we pick C = 0.1 µF, then RA +2RB = 1.44
MΩ. We can then pick, for example RB = 500 kΩ and RA = 440 kΩ.
6.1.3 Counter
In this part of the lab we use the 74LS190 decade counter used in the previous
lab experience. Instead of rewiring we ask them to understand its operation.
6.1.4 Latch
This is one more component to use in the final circuit. It also serves to illustrate
the operation of a latch or register in a computer. We then put it all together using
the wiring of the previous lab (4) on the ALU. The final circuit shows a display that
can show the value of a counter or the frozen value of the counter at a desired time.
6.1.5 And Now Some Trickery...
Up to here students have learned all they need with digital, so it is good to turn
them loose and play with all they know. Creativity is important, because it drives
ambition.
Arduino PWM
// Lab 6
int value;
byte x;
void setup() {
DDRB = B000000; //Initializing PORTB
Serial.begin(9600);
}
void loop() {
//value = 0;
x = PINB; // reads port B
value = x*28; // make value go from 0 to 252
Serial.println(value); // prints x to the serial port
delay(1);
value = x*28 + 3; // make value go from 0 to 252
analogWrite(5, value);
}
A.7. LAB 7: MEMORY ACCESS 13
// Lab 7
byte x; // This is the address
int i; // this is a counter variable
void setup() {
DDRB = B111111; //Setting up Port B
DDRD = B11111111; // Setting up Port D
//Write to memory
x=0; // Memory 0
PORTB = x+32; //Prepare memory
PORTD = B11001000; // data lines for H
PORTB = x; //Writing
delay(1000); //allowing time to see
x=1; // Memory 1
PORTB = x+32; //Set memory address
PORTD = B10110000; // data lines for E
PORTB = x; //Writing
delay(1000); //allowing time to see
x=2; // Memory 2
PORTB = x+32; //Set memory address
PORTD = B11110001; // data lines for L
PORTB = x; //Writing
delay(1000); //allowing time to see
14 APPENDIX A. COMMENTS FOR THE INSTRUCTOR
x=3; // Memory 3
PORTB = x+32; //Set memory address
PORTD = B11110001; // data lines for L
PORTB = x; //Writing
delay(1000); //allowing time to see
x=4; // Memory 4
PORTB = x+32; //Set memory address
PORTD = B10000001; // data lines for O
PORTB = x; //Writing
delay(1000); //allowing time to see
}
// Now read
void loop(){
x=0;//initialize memory address
for(i=0; i<6; i++){
PORTB = x+48; //Set the memory address
PORTB = x+16; //enable memory read
delay(1000); //Allow time to see
PORTB = x+32; //disable memory
x=x+1;
}
}
complement this section with information that is more specific to the type of scope
used.
8.3 Diagnosing AC Signals
This section is important for learning to use the scope, especially its DC and AC
settings. We also use it to measure the output impedance of the function generator
(50 Ω). A final part of the lab uses an RC circuit to show how they change when
the frequency is changed. As the frequency is increased, the voltage across the two
components change (VR increases and VC decreases–they should be VR /VC ∼ 0.6 at
1 kHz, exactly equal at 1.6 kHz, and VR /VC ∼ 3 at 5 kHz). Both signals are out of
phase by 90 degrees. It is another exercise on manipulating the controls of the scope.
If the function generator with the ungrounded common is not available, then we can
use the ordinary function generator, but compare the source voltage to the capacitor
voltage. In this case, the amplitude and phase of the voltage across the capacitor
change (the amplitude changes from about 1.7 V to about 0.6 V).
8.4 Impedance Matching
This lab is aimed at understanding some of the finer points about pulse electronics:
impedance matching. If the load is not matched to the source, some of the signal will
be reflected at the load end. The last section is a nice use of the scope to measure
time, and to realize that signals take a finite amount of time to propagate through
cables. The speed of the signal propagation should come out to about 2/3 of the
speed of light.
break;
case WAVE SAW UP:
mod = loop count
valu = VOLTAGE MAX * (mod / (float)freq);
transferFloat(valu);
break;
case WAVE SAW DOWN:
mod = loop count
valu = VOLTAGE MAX * ((freq - mod) / (float)freq);
transferFloat(valu);
break;
case WAVE TRIANGLE:
div = loop count / (freq/2);
mod = loop count
if(div & 1L)
valu = VOLTAGE MAX * (mod / (float)(freq/2));
else valu = VOLTAGE MAX * (((freq/2) - mod) / (float)(freq/2));
transferFloat(valu);
break;
case MYSONG:
delayT=1; // in milliseconds
transferFloat(8);
delay(delayT);
transferFloat(7.7);
delay(delayT);
transferFloat(7.4);
delay(delayT);
transferFloat(8);
delay(delayT);
transferFloat(7.4);
22 APPENDIX A. COMMENTS FOR THE INSTRUCTOR
delay(delayT);
transferFloat(6);
delay(delayT);
transferFloat(7.4);
delay(delayT);
transferFloat(5);
delay(delayT);
transferFloat(4);
delay(delayT);
transferFloat(4.5);
delay(delayT);
transferFloat(4.8);
delay(delayT);
transferFloat(3);
delay(delayT);
transferFloat(2.5);
delay(delayT);
transferFloat(1);
delay(delayT);
transferFloat(0);
delay(delayT);
++loop count; // incr counter once every time through
void transferFloat(float v)
int d, lob, hib, bits, bitshift, Nmax, volt, voltlow;
float voltf;
bits = 12;
bitshift = 12-bits;
volt = (int) DIGITAL MAX * (v/VOLTAGE MAX);
voltlow = volt >> bitshift;
Nmax = DIGITAL MAX >> bitshift;
A.16. LAB 16: DIGITAL-ANALOG 23