Lab Manual

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 83

Electronics with Discrete Components

Lab Manual with Arduino-based labs

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

Lab 1: The Basics

1.1 An Application of the Voltage Divider: A Dark-


ness Sensor.
Required equipment: power supply, multimeter.
Required components: Cd-photoresistor, CMOS CD4066 digital switch (not 74HC4066),
LED.
Suppose we want to turn on automatically the lights of some place as soon as it
gets dark. A lot of devices work like this (for example, street lights, night lights).
The circuit must consist of a light sensor and an electronic switch. The sensor tells
the switch to close when it is dark, and the switch connects power to the lights, or
whatever else you want on. A circuit that implements this is shown in Figure 1.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.

1. Photoresistor The light-sensitive device we will use is a photoresistor. It has


a resistance that varies with the intensity of the light that it receives (see photo
below). Place the photoresistor in the breadboard and use a multimeter, set to
measure resistance (likely a knob setting labeled “Ω”), to measure its resistance
for both light and dark situations. Record your findings in a table. Compare
your findings to the discussion on photoresistors in the text (page 11).

Figure 1.2: Photo of a photoresistor.

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.

3. Voltage Divider Resistors R1 and R2 form a voltage divider. The switch is


connected to the mid point of the divider (VC ), but it only senses the potential at
that point. One of the resistors (R1 or R2 ) should be the photoresistor, and the
other one, a resistor whose value you have to calculate. Once the photoresistor
and resistor are in the proper place, the circuit should operate the following
way: when there is light, the potential VC is less than 2.5 V (and the LED is
off); and when it is dark, VC is greater than 2.5 V (and the LED is on). Make
sure that the LED is not too close to the photoresistor.
Check that the color coding of the resistor corresponds to the resistance that
you wanted. Before you put the resistors in the circuit measure and record their
resistance with the digital multimeter (DVM). Do not measure the resistance
with the circuit all assembled; otherwise you will be measuring the resistance of
the resistor in parallel with another resistance (the circuit). The CD4066 IC is a
1.2. DELAYED SWITCH 5

network of transistors that needs to be powered by +5 V (pin 14), and connected


to ground (pin 7). The pins of the IC are numbered in a counterclockwise order,
with pin 1 being on the top left (the top is defined by a small circular mark in the
IC). Try your divider before connecting it to the IC. Record your observations.
Were there any complications? How did you resolve them?

Do not disassemble the circuit, as parts of it will be used next.

1.2 Delayed switch


Required equipment: power supply
Required components: SPDT switch, CD4066 digital switch, LED, resistors, ca-
pacitors.
Often we want to take a group photo but we want everybody in the picture. A
delayed shutter is the solution. Here we use a circuit similar to the one in Section
1.1, with the difference that now we need to delay the closing of the switch by two
seconds (a fast run to join the group). Study the schematic of the circuit shown in
Figure 1.3. There is a manual switch connected to a circuit that you must design,
which is also connected to pin 13 of the switch.
Design a circuit that involves the charging of a capacitor, such that it triggers
the switch (VC > 2.5V ) 2 seconds after the manual switch is closed. When deciding
values for components, first see the capacitor values that are available, as they are
less common than resistors.

Figure 1.3: Circuit for a delayed light switch.

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

1.3 Kirchhoff ’s Laws


In this exercise we will wire a two-loop circuit and compare our analytical solution
to our measurements.

1. Assemble the circuit shown in Figure 1.4.

Figure 1.4: Circuit for the lab exercise 1.3.

Use the following values: VA = 10 V, VB = 5 V, R1 = R2 = 1 kΩ and R3 = 2 kΩ


(nominal values).

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.

4. Another way to measure currents is by measuring the voltage drop across a


known resistor. Find the values of I1 , I2 and I3 using this method. Compare
those values with what you expect.
Finally, give your conclusions about this section.

1.4 RC Circuit as an Integrator and Differentiator


Required equipment: function generator, oscilloscope
Required components: resistor, capacitor.

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

Figure 1.5: Circuit for lab exercise 1.4.

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

Lab 2: Digital I/O

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 I/O With the Arduino UNO Microcontroller


We will move onto a more modern electronics incarnation: exchanging data with a
small processor: The Arduino UNO. A first section of this experience will be a crash
course on how to program the device. The good news is that it is straightforward to
use it. The flip side is that it involves programming, with all its evils: learning the
syntax. The lab will be simple: to program the Arduino UNO to output 1’s and 0’s.

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);
}

Note the syntax: capitalizing and the semicolon.


Now let’s do something. The loop environment does what its name says: it loops
indefinitely. As an exercise, let’s put out a pulse. We do this by outputting a logic 1
(HIGH) and then a logic 0 (LOW), and repeat. Instruction “digitalWrite” does the
job.

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:

• Pin #13 is also connected to an on-board LED, so define pin 13 (instead of 4)


as the output.

• 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
}

You can also look up the “if” instruction at http://arduino.cc/en/Tutorial/IfStatement.


Make sure you recognize the two distinct patterns.

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).

• You will need to define pin 5 as an input with “pinMode(5, INPUT)”


2.2. SERIAL TRANSMISSION OF ASCII-CODED CHARACTERS 13

Figure 2.2: Switch to provide input to Arduino.

• 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.

• Verify that the program works as planned.

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.

2.2 Serial Transmission of ASCII-coded Charac-


ters
Serial transmission of digital data is an important component of computer communi-
cations. The Ethernet system uses this mode of transmission of data. It consists of
sending the information bit-by-bit in a sequence. Today we will see how this is done
for a popular communications protocol called the RS-232. This type of communica-
tion is used when a PC communicates with peripherals. It is becoming increasingly
obsolete today, being replaced by another new serial-port technology: universal serial
bus (USB), and a new protocol (NRZI). The difference in the new system is that the
electronics at both ends is smarter. In turn, the series communication is more com-
plicated. For our purposes, the more basic RS-232 will be better because it transmits
bytes of data in a way that is easy to recognize.
The RS-232 “protocol” works the following way: it uses two electrical lines to send
the data back and forth, plus a series of other lines for control. One device tells the
14 CHAPTER 2. LAB 2: DIGITAL I/O

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.

Description Name Pin I/O Rigged connector


Transmit data TD 3 Output Connected to pin 2
Receive data RD 2 Input Connected to pin 3
Request to send RTS 7 Output Connected to pin 8
Clear to send CTS 8 Input Connected to pin 7
Data terminal ready DTR 4 Output Connected to pin 6
Data set ready DSR 6 Input Connected to pin 4
Data carrier detect DCD 1 Input Not connected
Ring indicator RI 9 Input Not connected
Signal ground SG 5 Used as ground.

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.

• Seven bits follow with the ASCII code.

• 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.

3. Show an example of your mastery of the protocol by picking a character to


transmit and predict, by making a detailed drawing, what you will observe on
the oscilloscope when you press that key. Identify also each bit (i.e., start bit,
MSB, LSB, parity, etc.) in your drawing.
Chapter 3

Lab 3: Combinational Logic

3.1 The TTL Half Adder: Design and Construc-


tion
Required equipment: Logic board (The logic board is a box that provides logic
inputs to a circuit via switches and displays the outputs of a circuit on light-emitting
diodes, LED. For details on making one see Appendix A of the textbook.)
Required components: 74LS00 (or 74HCT00) ICs, common-anode seven-segment
display, resistor array chip, 74LS47 (or 74HCT4511) seven-segment driver.
NOTE: You must look at the pin connections and specifications of all chips at
http://www.datasheetcatalog.com.

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.1: Internal wiring of the 74LS00 IC.

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

Figure 3.3: A well specified circuit diagram is important for troubleshooting.

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

3.2 Seven Segment Display


Most digital displays use the so called seven segment display. This type of display is
shown in the photo of Figure 3.4.

Figure 3.4: Photo of two seven-segment displays.

A schematic of the display is shown in Figure 3.5.

(a ) (b )
+ 5 V
a
a + 5 V
f b f
g b
e c g

d
e
c
d

Figure 3.5: Diagram of the wiring of a common-anode seven segment display.

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

3.3 The 74LS47 BCD to Seven Segment Decoder


The 74LS47 chip is a decoder that has four inputs that represent a binary coded
decimal (BCD) number. The pin connections for the 74LS47 are given in the data
sheets. The outputs labeled a, b, c, d, e, f and g are functions whose output should
light the LED segments. There is a shortcoming to the 74LS47 though: it only works
from 0 to 9, it displays nonsense from A to F. The 74LS47 puts out a 0 at a given
output in order to light the corresponding common-anode LED. Wire the 74LS47, by
connecting (1) the RBI and LT pins to +5V, (2) the outputs of the segments to the
resistor unit connected to the display, and (3) its logic inputs to switches in the logic
board. You will need this circuit for next lab.

3.4 Displaying the Result of the Half Adder in the


Seven Segment Display
Your third challenge today will be to find a way to display the result of your adder on
the seven-segment display. The basic connection between the display and the 74LS47
is shown in Figure 3.6.

_ _ _ _ _ _ _
a b c d e f g
_ _
L_ T_ _ 7 4 4 7
R B I
D C B A

Figure 3.6: Driving the seven-segment display.


22 CHAPTER 3. LAB 3: COMBINATIONAL LOGIC
Chapter 4

Lab 4: Combinational Logic and


Arithmetic Logical Unit

Required equipment: Logic board


Required components: 74LS00 (or 74HCTS00), 74LS10 (or 74HCT10), 74LS47
(or 74HCT4511), and 74LS181

4.1 Part I. The Arithmetic Logical Unit


4.1.1 Functional
One of the computer’s most important parts is the device that performs all the arith-
metic and logical operations: the arithmetic logical unit (ALU). The ALU is a large
combinational circuit that has control inputs, data inputs and data outputs. In the
next two lab exercises we will use a 4-bit ALU: the 74LS181. The technical spec-
ifications and pin connections of the 74LS181 are listed in the data sheets. Here
we will discuss only the functional details. The data inputs (B = B3 B2 B1 B0 and
A = A3 A2 A1 A0 ) and data outputs (F = F3 F2 F1 F0 ) represent 4-bit binary variables,
with the F being the result of an operation between A and B. The control inputs
S3 , S2 , S1 , S0 , M and Cn specify the operation as given in Table 4.1. Note that the
functions under “M = 1” are independent of the input Cn .

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

Table 4.1: Functional Description of the 74LS181 Arithmetic Logical Unit

S3 S2 S1 S0 M=1 M=0, Cn =1, M=0, Cn =0


0000 F = A0 F =A F = A plus 1
0001 F = (A + B)0 F =A+B F = (A + B) plus 1
0010 F = A0 B F = A + B0 F = (A + B 0 ) plus 1
0011 F =0 F = minus 1 F = ZERO
0100 F = (AB)0 F = A plus AB 0 F = A plus AB 0 plus 1
0101 F = B0 F = (A + B) plus AB 0 F = (A + B) plus AB 0 plus 1
0110 F =A⊕B F = A minus B minus 1 F = A minus B
0111 F = AB 0 F = AB 0 minus 1 F = AB 0
1000 F = A0 + B F = A plus AB F = A plus AB plus 1
1001 F =A B F = A plus B F = A plus B plus 1
1010 F =B F = (A + B 0 ) plus AB F = (A + B 0 ) plus AB plus 1
1011 F = AB F = AB minus 1 F = AB
1100 F =1 F = A plus A† F = A plus A plus 1
1101 F = A + B0 F = (A + B) plus A F = (A + B) plus A plus 1
1110 F =A+B F = (A + B 0 ) plus A F = (A + B 0 ) plus A plus 1
1111 F =A F = A minus 1 F =A

plus represents addition.


minus represents subtraction.

Each bit is shifted to the left.

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.

4.2 Part II. Customizing the ALU


4.2.1 The Problem
As you have seen, there are 48 operations can be performed with the 74LS181 ALU.
However, suppose that for a given application we want to use only 8 of those oper-
4.2. PART II. CUSTOMIZING THE ALU 25

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=A B 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

Lab 5: Multiplexing I/O

Required equipment: Logic board. Arduino UNO board.


Required components: 4x1 multiplexer (’153) and demultiplexer (’155) ICs, 74LS47,
and seven-segment display.
The objective of this lab is to understand multiplexing.

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(initial setting of the index variable; condition on index variable to


remain in the loop; increment of the index variable) {
// statement
}

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

for( y = 1 ; y < = 5 ; y++) { }

In this language incrementing by 1 is so common that it can be abbreviated by “y++”.


You could have also done “y = y + 1;”
So now write a script that does a for-loop that adds 1 to a variable that increments
it from 0 to 15. Within the for loop write a byte variable (x) to port B (such as in
the example above). Also include an instruction that increments x so that next time
around it has a higher value (be sure to set it to 0 before the for loop). Connect the
four least significant pins of port B (pins 8-11) to individual LEDs, and verify that it
works. Remember to connect the grounds of the Arduino and the logic board.

5.1.2 Wire a Multiplexer


Select 4×1 multiplexer 153 IC. Study two aspects of its data sheet: the pin connections
(they have their own set of labels) and the function table. Wire a circuit that has the
following specifications:
5.2. DEMULTIPLEXING 31

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.

Verify that the multiplexer operates as expected in this circuit.

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:

1. Make a circuit diagram of the entire circuit.

2. Explain what the circuit is doing.

3. How could this method be used in the real world?


32 CHAPTER 5. LAB 5: MULTIPLEXING I/O

Figure 5.1: Two-bit binary counter, wired using a “D flip-flop” IC.


Chapter 7

Lab 8: Circuits

7.1 DC Circuits
Required equipment: DC power supply, multimeter.
Required components: Resistors.

The Voltage Divider and Thevenin’s Theorem


1. Assemble the voltage divider circuit shown in Figure 7.1.

Figure 7.1: A Voltage divider.

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.

Figure 7.2: Connecting a load to a volgate divider.

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 .

7.2 A Note on the Use of the Oscilloscope


In this analog part of the course you will find the oscilloscope to be an indispensable
tool. Do not avoid it. Take your time to learn how to use it. Below are a few specific
notes on important parts of the oscilloscope.
7.2. A NOTE ON THE USE OF THE OSCILLOSCOPE 39

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

your lab should have the three-prong outlets.

7.3 Diagnosing AC Signals


Required equipment: Function generator, AC source (function generator) with
ungrounded common (for Section 4), multimeter, oscilloscope.
We have two types of diagnosis tools at our disposal: the multimeter and the
scope (short for oscilloscope-we will use these terms interchangeably). By the end of
the course you are expected to master the use of these two measuring tools.
1. Set the function generator to a sinusoidal waveform of amplitude 5 V (i.e., 10
V peak-to-peak) and frequency 1 kHz. Use the scope to verify these settings.
Predict and then measure the voltage of the function generator using the mul-
timeter.
2. Now add a DC offset of 5 V to the signal. The function generator has the
capability of doing this on its own. Using this input signal explain the difference
between the DC and AC settings of the scope. (The answer is not that “DC”
is for measuring DC voltages and “AC” is for measuring AC voltages.)
3. Switch the input signal to square wave. The function generator allows you
to change the duty cycle of the square wave. Measure the signal with the
multimeter for different values of the duty cycle. What does the multimeter
measure?
4. Set the function generator back to sinusoidal output with no zero offset, an
amplitude of 2 V and a frequency of 500 Hz. Assemble a circuit with the
function generator as the source connected to a 50 Ω resistor. Explain the value
of the voltage that you measure across the 50 Ω resistor. If you are out of clues,
try putting a 100 Ω resistor instead.
5. Now use the AC source (function generator) with ungrounded common (very
important!) to assemble the circuit of Figure 7.3 with V0 = 2 V, R = 1 kΩ,
and C = 0.1 µF. Connect the channels 1 and 2 of the oscilloscope as shown and
invert the channel 2 input (an option of the oscilloscope). You must trigger with
channel 1 of the scope. Learn how to use the trigger. Adjust the amplitudes
of the two signals. Compare and observe the two signals when you change
the frequency from 1 kHz to 5 kHz (you may have to readjust the amplitude
settings of the scope). If a function generator with an ungrounded common is
not available, compare instead the source voltage with the voltage across the
capacitor–same procedure otherwise.
7.4. IMPEDANCE MATCHING 41

Figure 7.3: Diagnose a circuit powered by an ungrounded supply.

7.4 Impedance Matching


Required equipment: Fast oscilloscope (100 MHz or higher), pulse generator.
Required components: Short (2 ft) RG-58 (50 Ω) coaxial cable with BNC connec-
tors, long (10-m/25-ft or greater) RG-58 coaxial cable with BNC connectors, cable
tee (3), 50-Ω terminator (2).
1. With the pulse generator, generate as short a pulse as possible: 50 ns or shorter
is ideal; it still works with 1-10 µs pulses (but use longer cable). Connect the
short cable to an oscilloscope and diagnose the signal. Disconnect the cable from
the oscilloscope and connect it to the coaxial tee and then to the scope, with
the other connection of the tee connected to the terminator (see Figure 7.4).
Comment on the difference in the two signals (with and without terminator).

Figure 7.4: Setup for measuring short pulses.

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

Required equipment: Oscilloscope, PC with audio player, speaker.


Required components LF380 audio amplifier, capacitors, resistors.

8.1 Application: Audio Filter


The Problem
You will be given a music file with a defective recording. The piece (Beethoven’s
Moonlight sonata) has music superimposed with an unwanted pitch. Because the PC
signal is too weak, wire the amplifier (gain of 50) shown in the figure below before the
speaker. Connect the output of the PC player to a speaker and identify the problem.
Look at the audio signal with the scope and identify the frequency of this pitch.

Figure 8.1: Integrated-circuit-based audio amplifier and impedance transformer.

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

Required equipment: Oscilloscope, PC with audio player, speaker.


Required components LF380 audio amplifier, capacitors, resistors.

9.1 Application: Audio Filter


The Problem
You will be given a music file with a defective recording. The piece (Beethoven’s
Moonlight sonata) has music superimposed with an unwanted pitch. Because the PC
signal is too weak, wire the amplifier (gain of 50) shown in the figure below before the
speaker. Connect the output of the PC player to a speaker and identify the problem.
Look at the audio signal with the scope and identify the frequency of this pitch.

Figure 9.1: Integrated-circuit-based audio amplifier and impedance transformer.

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

Lab 11: Diodes

10.1 I–V Curve


Required equipment: Curve tracer (if a commercial one is not available see Ap-
pendix C of the textbook for a home-made one).
Required components: Silicon diode (1N4005), red, green and blue LEDs, Zener
diode.
Measure and get a printout (if possible) of the I–V curve of:
• Standard (IN4002) diode (forward bias)
• Red from RGB LED(forward bias)
• Green from RGB LED (forward bias)
• Blue from RGB LED (forward bias)
• 5-V Zener diode (reverse bias)
Recognizing the terminals of a diode:
• On tubular diodes, the cathode end is marked with a bar.
• The longer leg of an LED denotes the anode (see Figure 10.1).
• If you are still not sure, use a multimeter set to measure resistance (Ω). It will
conduct in the forward direction but not in the reverse direction.
• For the RGB LED the diodes all have a common cathode (), which is the longest
lead. The one lead next to the longest one is red. The other two leads are green
and blue; the green lead is next to the cathode.
Compare the I–V curves of the different LEDs.

47
48 CHAPTER 10. LAB 11: DIODES

Figure 10.1: Identifying the terminals of an LED.

10.2 Make-And-Take LED Flasher


Required equipment: Soldering equipment: iron, solder wire, shrink tubing, heat
gun, needle-nose pliers, safety glasses.
Required components: Make-and-take materials: RGB LED, 2 3-V batteries, bat-
tery holder, small push-button switches.
The objective of this section is to learn to solder. In reward each student will take
his or her trophy home. The work area must be ventilated and students must use
safety glasses.
LEDs powered by a 5-V supply need a resistor to drop the voltage on the diode to
a value that corresponds to the expected current. For the LED this current is between
10 mA and 20 mA– let’s pick 15 mA. We want to make three separate circuits for
each color. The components to be assembled are: two mercury batteries, a battery
holder, an RGB LED, and 3 push-button switches. These are shown the Figure 10.2
together with the finished product.

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).

hook it to the appropriate resistor. Cut the resistor’s leads to conve-


nient (shortest) length. Solder the LED lead to the resistor.
ii. Now we need to solder the other end of the resistor to a leg of the
switch. Stretch out the leg of the switch because it is curled up. Hook
the resistor lead as before, and solder.
iii. Solder one end of an appropriately colored wire to the switch contact
that is opposed diagonally to the one soldered to the resistor.
(d) Bend the three soldered circuits around the battery holder so that they
do not touch each other or holder contacts. You also want the base of
the switches to be up against the non-metal part of the battery holder so
you can push the button against it to turn it on. The final step is to cut
the remaining unconnected wires to size and solder them together to the
positive terminal of the battery holder.

2. We will also provide transparent shrink tubing to provide a cover for the LED
flasher.

Good luck!
50 CHAPTER 10. LAB 11: DIODES

10.3 Diode Clamp


Required equipment: Function generator, oscilloscope.
Required components: Silicon diode (1N4005), resistor.
Wire the circuit of Figure 10.3. Look at the output waveform with the scope and
explain it fully.

1 k W

Figure 10.3: A voltage clamp.

10.4 Application: A Regulated Power Supply


Required equipment: 6.3 VAC Vacuum tube filament supply or 12 V transformer,
oscilloscope.
Required components: Full-wave bridge, 7805 5-V voltage regulator, resistors ca-
pacitors.
The most important application of diodes is rectification. They are also the main
ingredient of a power supply. A regulated power supply consists of a transformer, a
bridge rectifier, a capacitor, a bleeder resistor and a regulator.

10.4.1 The Unregulated Supply


1. Build the circuit shown in Figure 10.4. The 6.3 VAC supply is not the function
generator. It is an ungrounded AC source. For the purpose of observing the
waveform with the scope connect a 10 kΩ resistor as a load.

~ +

6 .3 V A C b r id g e

~ -

Figure 10.4: Rectifying an ac signal.


10.4. APPLICATION: A REGULATED POWER SUPPLY 51

7 8 0 5

IN G N D O U T

Figure 10.5: Terminals of the 7805 +5 V voltage regulator.

The full-wave bridge is supplied as an integrated package. Measure the voltage


output of the 6.3 VAC supply with the scope. What is the peak output voltage
of the supply? Measure the output of the bridge and explain its shape (make
sure that you have a load resistor connected to it—diodes need to conduct!).
Make a sketch. (Use the scope in the DC setting! Should we use the LINE
trigger setting of the scope?)

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.

10.4.2 The Regulator


Connect the 7805 voltage regulator (see Figure 10.5) to the output of the previous
circuit, introducing also a 10 kΩ bleeder resistor. The final circuit should look like
the one given in Figure 10.6. Measure the ripple voltage for the loads applied to
the unregulated supply. Make a comparison between the regulated and unregulated
supplies and state your conclusions.
52 CHAPTER 10. LAB 11: DIODES

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
~ -

Figure 10.6: Diagram of the regulated DC voltage supply.


74 CHAPTER 10. LAB 11: DIODES
Chapter 14

Lab 14: Operational Amplifiers

14.1 Inverting Amplifier


Required equipment: Power supply, 2 speakers.
Required components: LM741 or LF411 op-amp, resistors.

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.

14.2 Noninverting Amplifier


Required equipment: Oscilloscope, power supply, safety glasses.
Required components: LM741or LF411 op-amp, optointerrupter, DC motor-chopper.

1. An optointerrupter is shown in Figure 14.2. It has a horizontal base with


two pillars rising from the base. There is an infrared LED in one pillar and
a photodetector on the other pillar. The LED and photodiode are facing each
other such that one can use them to determine whether something is in between
them. They are normally used to control the revolutions of a motor through a
chopper wheel connected to the axis of a motor, as shown in the figure.

+5V

R1

D Vout

E
E D
R2

Figure 14.2: Optointerruptor and its biasing.


14.3. MYSTERY CIRCUIT 77

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.

2. Normally the revolution control of a motor/chopper is done digitally. Amplify


the output of the optointerrupter such that the amplitude of the output wave-
form is 5 V.

3. Design a circuit that will invert the waveform of the previous section. The
inverted output should still be between 0 and 5 V.

14.3 Mystery Circuit


Required equipment: Function generator, oscilloscope, power supply.
Required components: LM741or LF411 op-amp, resistors, variable resistor, ca-
pacitor.
Set up the circuit below and study the input and output when a 1 V 10 kHz sine
wave is applied to the input. Use a 10 kΩ pot for R and set C ∼ 0.003µF.
R '

R '
V in

V o u t

C
R
78 CHAPTER 14. LAB 14: OPERATIONAL AMPLIFIERS

14.4 Servo and Constant-Illumination Controller


Required equipment: Power supply.
Required components: LM741 or LF411 op-amp, phototransistor, 6-V filament
light-bulb.
We will design one of the most useful applications of op-amps: a servomechanism.
Our design involves controlling a light-detector system, such that the illumination
of a light detector by a bulb remains constant. We will exercise on the use of the
op-amp while building the different components. You will use six op-amps in this lab,
so organize and wire your breadboard neatly.

1. Light Bulb Driver


We have provided you with a 6 V light bulb that we wish to drive with an
op-amp. The bulb requires currents that exceed the 20 mA rating of the ’741.
The circuit shown below uses an op-amp in combination with a transistor to
drive the light bulb. Complete the wiring such that the light bulb is driven
by the input V1 . A partial schematic is shown below. You must complete the
missing part.

+ 15 V

3904
V1
0-6V

2. Photodetector

(a) Of the various photodetectors that we have available, phototransistors are


very suitable for applications that involve low speeds and high gain. The
photocurrent generated by the p-n junction of the detector is amplified
internally by feeding it as a base current to a transistor. When biased as
shown in the figure below, the phototransistor acts as a current source.
The output voltage V2 is negative. Explain why.
14.4. SERVO AND CONSTANT-ILLUMINATION CONTROLLER 79

(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

(a) Wire a differential amplifier circuit such that the output V4 = VA − VB ,


where VA and VB are input voltages.
(b) Connect the output V4 to an integrator with a time constant of 1 s, as
shown below.
C

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

(d) Connect VB to ground. Connect the output of the function generator


(working in the DC mode) to VA and observe VA and V6 with the scope.
Explain the response of V6 to when VA is positive or negative.
(e) Decrease the time constant of the integrator to 1 ms and repeat the pre-
vious step.
(f) Disconnect VB from ground and connect it to V6 . Explain the behavior of
V6 vs. VA .
(g) Increase the time constant of the integrator to 1 s and repeat the previous
step.

4. Putting it all Together


Assemble the circuit as shown in the block diagram. We will complete the
feedback loop of this “slow follower” through the light source/detector. Follow
Appendix B of the textbook for help in troubleshooting. All individual parts of
the circuit must work separately. Otherwise the whole circuit will not work.

(a) Set VA to zero.


(b) Disconnect V6 from VB , and connect VB to the output of the detector
circuit V3 .
(c) Connect the output of the integrator V6 to the input of the light bulb
circuit V1 .
(d) Increase VA until the light bulb starts to glow not too strongly. Now move
the light bulb away from the detector. The light bulb should get brighter.
Explain why. If you explained it, congratulations (!), you now understand
how feedback allows automation, how the cruise control of your car works,
how missiles “lock” to their targets, and much more...
(e) Reduce the time constant of the integrator and observe the response of the
circuit.

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

14.5 Voltage-Controlled Oscillator


Required equipment: Power supply, speaker.
Required components: LM741 op-amp or equivalent, resistors, capacitor, 3904 or
equivalent npn transistor, photodiode.
It is often necessary to generate a periodic waveform with a frequency that depends
on an input voltage. The circuit is called a voltage-controlled oscillator (VCO). It also
allows frequency modulated signals. That is, signals where the information resides
on the frequency of the signal, instead of the amplitude. This is the essence of FM
radio broadcasting.
The circuit of Figure 14.3 shows an analog VCO. It is a two op-amp oscillator.
The first one is closed-loop, working as an integrator. The second one, operating
open loop, switches between +VCC and −VCC . So V2 is a square wave. Since V1 is the
output of the integrator that charges and discharges the capacitor when the second
op-amp switches, it has a triangular waveform. The charge and discharge times are
VCC
tc = td = 2RC (14.1)
Vin
and so the frequency is
Vin
f= (14.2)
4RCVCC
Note then that the highest frequency is fmax = 1/4RC

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.

2. Use an inverting amplifier to reduce the amplitude of V1 by a variable amount.


Use the output of the amplifier to drive a speaker.

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?

4. This last part is an exercise in understanding the circuit.

(a) What is the purpose of the transistor in Figure 14.3?


(b) Derive Equation 14.1.
82 CHAPTER 14. LAB 14: OPERATIONAL AMPLIFIERS

Figure 14.3: A voltage-controlled oscillator.


Chapter 15

Lab 13: Real Op-Amps

Required equipment: Power supply.


Required components: LM741 op-amp, resistors, trimpot.

15.1 Gain vs. Frequency


Wire a simple inverting amplifier, as shown in Figure 15.1. Keeping R2 = 100 kΩ
choose R1 for gains of 1, 10, 100 and 1000. Find the 3 dB bandwidth for each gain.
Compare your results with the specifications of the 741.

R 2

R 1

V o u t

Figure 15.1: Circuit to measure the gain of the op-amp.

15.2 Slew Rate


1. Set an op-amp follower and connect a 1 kHz 1V-peak square wave to its input.
Observe the input and the output as you increase the amplitude of the input.

83
84 CHAPTER 15. LAB 13: REAL OP-AMPS

Measure the slew rate.

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.

15.3 Input Offset Voltage and Bias Current


1. Wire the circuit shown in Figure 15.2. Measure the output with the DVM.
Explain the result.

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.

2. Connect a feedback resistor to the previous circuit, as shown in Figure 15.3,


and “trim” the output so that is is zero. You will have to use the “300 mV”
scale.

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

Figure 15.3: Method to reduce to zero the input offset voltage.


Appendix A

Comments for the Instructor

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.

A.1 Lab 1: The Basics


The goal of this lab is to get students to wire a first circuit that does something
tangible: light something up.
1.1 Darkness Sensor
This lab relies on an obsolete switch that is still available. Its switching threshold
is 2.5 V. Other analog switches, such as 74HC4066, have a much higher threshold, so
the lab parameters need to modified if those are used. Otherwise, it works very well.
It is a nice way to show students that they can make lights blink with simple circuits.
It also makes students think about the voltage divider.
The photoresistor’s parameters depend on the individual one that is used. There
are many types and sizes, but they are cheap and widely available. The dark resistance
is about 1 MΩ, and the resistance with room lights incident on it is about 10 kΩ.
Thus, the photoresistor should be R2 and the other resistor (R2 ) should be about 100
kΩ. If the LED is not as bright we can lower the value of the resistor that is in series
with it.
1.2 Delayed Switch
If the students followed the discussion of charging the capacitor in the course,
or previous ones, they should not have trouble with this exercise. Students’ design
should be a resistor in series with a capacitor (see Figure A.1, with the resistor end
of the capacitor connected to the sensing pin of the switch (pin 13 in CD4066), and
the other end connected to ground. The capacitor needs to be discharged before the
switch is turned on. A variation of this could be a double throw switch, where in one

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).

Figure A.1: Analog delay for Exercise 1.2.

1.3 Kirchhoff ’s Laws


This is a standard circuit. The answers are I1 = 4 mA, I2 = 1 mA (flowing down),
and I3 = 3 mA.
If we want to spice up the circuit make R3 = 1 kΩ, which yields I2 = 0. Students
spend some time solving the circuit and find that result analytically, but when they
wire the circuit, they find that the current through R2 is small but not zero, and get
stuck. This is where the instructor makes them realize that the resistor values are
not all the same, and small differences will create a current that goes through R2 . So
a second-order lesson here is the tolerance of the resistors. Students still do not like
it, because the measurements do not confirm their calculations exactly.
1.4 RC circuit as an Integrator and a Differentiator
This circuit is somewhat advanced, so it may be just for the advanced students.
The goal is to make them realize interesting connections between voltage and current.
It definitely makes the lab too long, but could be used on a different day. It also uses
the oscilloscope, which is introduced later. The students see how the triangular
waveform gets converted into a square wave and vice versa, depending on how we
arrange the circuit components and the source.
A.2. LAB 2: SERIAL TRANSMISSION OF ASCII-CODED CHARACTERS 5

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

A.2 Lab 2: Serial Transmission of ASCII-coded


Characters
bf 2.1 I/O With the Arduino UNO Microcontroller
Here students may be getting their first exposure to coding, and what best than
with a device that talks to the outside world: the Arduino UNO. Besides being very
cheap, this little circuit can do a lot of fun things for the students. They quickly warm
up to it, although student crash confronting the syntax requirements; they are used
to smartphones that guess what they mean to say, but not programming languages.
Arduino also has lots of examples, so students (and professors) can easily learn that
way. A student program that uses the “if” instruction:

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;
}

Then a program that makes a decision based on an input:

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

2.2 Serial Transmission of ASCII-coded Characters


This is a nice lab where students get so see that information is indeed sent one
bit at a time. The protocol makes the lab more of a challenge experiment: to figure
out the order of the bits and the polarity of the signals. This has to be done with
the serial port. Unfortunately the USB uses the NZRI protocol that makes it too
confusing to figure out.
There are three ingredients to the lab: a PC with a serial port, a rigged 9-pin
connector, and a serial-port communications software.
The rigged connector is an item of advanced preparation. You need to acquire a
9-pin female connector (see Figure 2.4) and solder pins 2 and 3 (send/receive), pins 4
and 6 (ready to communicate), and 7 and 8 (waiting for data to come/go). Because
the computer grounds this pin 7, it can be used as signal ground. Otherwise, pin 5
is the signal ground. The wires should have bald spots for the oscilloscope hook-ups
(as shown in the photo). There should be as many connectors as there are PCs for
the lab.
The instructor may need to do some research finding a serial-port driver software.
There are several available as freeware in the internet. We used “Procomm” for a
while, but more recently we used a terminal emulator “Minicom.”
The communications protocol is the least intuitive: low active data signals, with
LSB coming out first, following the start bit. The logic levels are the opposite of
one would think: −V for logic 1, and +V for a logic 0 (with V ∼ 10V). The parity
protocol is also unintuitive. These factors make the lab exercise non-trivial, forcing
students to understand ASCII codes to unravel the protocol.

A.3 Lab 3: Combinational Logic


This lab starts the process of learning how to wire digital circuits.
3.1 The TTL Half Adder: Design and Construction
This is the first true digital lab. It is best done with the TTL chips 74LS00.
These are becoming increasingly obsolete, and any new design must use the CMOS
standard, 74HC00. However, these can be a bit tricky to use, and for a lab with
students learning things the hard way it is better to use the more rugged TTL family
whenever possible. It is good to insist that students make a drawing of the circuit in
their lab book, and for the circuit to look neat on the board. Points should be taken
off for failing to do this. It is a bad habit to have a wired circuit with no diagram of
it.
The Arduino program is:

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

Step TTL(74LS47) CMOS (74CHT4511)


1 RBI (pin 4) and LT (pin RBI (pin 4) and LT (pin
3) to +5 V. 3) to +5 V.
2 BI (pin 5) to +5 V (op- LE (pin 5) to a switch in
tional). the logic board.
3 The a, b, c, d, e, f, g out- The a, b, c, d, e, f, g out-
puts to the resistor unit. puts to the resistor unit.
4 Resistor unit to Resistor unit to
common-anode dis- common-cathode dis-
play. play.
5 Data inputs (A3, A2, Data inputs (D3, D2,
A1, A0) to switches in D1, D0) to switches in
the logic board. the logic board.

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.

A.4 Lab 4: Combinational Logic and the Arith-


metic Logical Unit
This lab may take two periods.
4.1 Part 1: The Arithmetic Logical Unit
This part involves getting familiar with the ALU IC 74LS181.
10 APPENDIX A. COMMENTS FOR THE INSTRUCTOR

4.2 Part II. Customizing the ALU


As mentioned earlier, this part must be designed and finished by the students
ahead of time. If they do not, they will be spending lab time doing the design. This
design is also Problem 14 of Chapter 3. The instructor should check their designs
(the solutions are given below). It is more painful to wire circuits that are inherently
wrong. The wiring will be massive, so students need to have well labeled diagrams
and neat circuits. Points should be taken off for circuits that are a jungle, even if
they work. This same design will be used later, so they must put the wired circuit
aside and not take it apart.
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 1 1 ×
0 1 0 F=A0 0 0 0 0 1 ×
0
0 1 1 F=B 0 1 0 1 1 ×
1 0 0 F=A⊕B 0 1 1 0 1 ×
1 0 1 F=A B 1 0 0 1 1 ×
1 1 0 F=A minus B 0 1 1 0 0 0
1 1 1 F=A plus B 1 0 0 1 0 1
Solutions:
S3 = x0 y 0 + xz
S2 = y 0 z 0 + x0 yz + xz 0
S1 = x0 y 0 + xz 0
S0 = z
M = y 0 + x0
Cn = z

A.5 Lab 5: Multiplexing I/O


This lab introduces students into the concept of multiplexing.
5.1 Multiplexing
The goal of this exercise is to understand multiplexing. It requires students to
wire two counters without really knowing how they work. Do not disassemble the
decade counter, as it gets understood and used in the next lab.
5.2 Demultiplexing
This exercise conveys the essence of the time-binned multiplexing used in commu-
nications. We use a slow counter to show binary values that do something, but we
display them after the multiplexing and demultiplexing. The fast 2-bit counter sends
the counter outputs serially, with our eye doing the averaging.
The Arduino program is:
A.6. LAB 6: SEQUENTIAL CIRCUITS 11

// 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;
}

A.6 Lab 6: Sequential Circuits


6.1 Lap Timer
6.1.1 The LM555 Timer
If no alternative is available, the LM555 is the easiest IC to use for generating
periodic signals. The operation of the LM555 as a pulse generator can be used as an
12 APPENDIX A. COMMENTS FOR THE INSTRUCTOR

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

A.7 Lab 7: Memory Access


This exercise provides the flavor of memory and I/O addressing, which includes con-
trol signals, address lines and data lines. It uses a classic IC, the TMM2114 static
RAM. It is pretty obsolete, because it holds so little memory, but it is good enough
for our purposes. Newer memory ICs are inadequate, because they have either 1
bit of storage, with many more memory locations, or have surface-mount packaging,
which is very hard to use with a breadboard. The temporal messaging part can be
laborious but also fun. It gives students ideas for what they can do with memory for
their projects. The Arduino program is:

// 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;
}
}

A.8 Lab 8: Circuits


8.1 DC Circuits
This lab makes Thevenin equivalent circuits real. This is a very difficult concept
for students. It seems like an abstraction, but it is the beginning of modeling a circuit
by its equivalent one. It also illustrates the concept of loading.
8.2 A Note on the Use of the Oscilloscope
Here the instructions give generic instructions. The exact locations of the controls
of the scope depend on the particular device you have available. The instructor should
A.9. LAB 9: FILTERS 15

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.

A.9 Lab 9: Filters


9.1 Low-Pass Filter
In Part 3 of this section we use a low-frequency AC signal (60 Hz) with a high-
frequency signal on top. On the scope you see a 60 Hz sinusoidal signal with a
“fuzzy” outline, the 10 kHz signal. The filter rids the high frequency by decreasing
the amplitude of the “fuzz.”
9.2 Application: Audio Filter
This lab makes filtering more real. We need a source of low frequency that can
be recognized (music with lots of low frequencies–cello concert?) and superimposed
on it is a high frequency pitch; the highest possible that can be heard. This can be
synthesized digitally (students may be experts at this!) or recorded the old fashioned
way. We provide an audio amplifier if one is not available. Other types may be
available.
16 APPENDIX A. COMMENTS FOR THE INSTRUCTOR

A.10 Lab 10: Fourier Analysis


This is a sturdy lab. It relies on a specific IC, the AD532 multiplier. The instructions
explain how to use it. It could be skipped if the section of Fourier analysis is not
covered.

A.11 Lab 11: Diodes


11.1 I–V Curve A curve tracer is needed for making I-V curves of the diodes.
If you have the Tektronics model 571, the settings are: DIODE, 10V, 50 mA,
10 Ω and 2 W. Once you press START the tracer will take the curve. If you then
press COPY it will make a hard copy of the curve. The curve tracer will display
the diode curve only for positive voltages. For the standard diode and LED you will
take only a curve when the diode is forward biased. This is because their reverse
voltage breakdown is above 100 V. In contrast, the Zener diode has a reverse voltage
breakdown of about 5 V.
If you use the homemade curve tracer, follow the instructions in Appendix C of
the textbook.
11.3 Make-And-Take LED Flasher
This is our only chance to teach students how to solder. They love it. Besides
that, they get really into making something they are going to take home. You must
buy an assortment of bright LEDs of different colors. Students will likely pick the
uncommon colors (teal, pink, etc.). The switches must be push-button type and
small. The holders and batteries are standard, which can be acquired from any
electronics vendor (for example, Digikey). The instructor must make a demonstration
of soldering to the class first, teaching students how to “wet” the contacts with the
solder. Tweezers and heat guns are needed. The work area must be ventilated and
students must use safety glasses.
11.4 Application: A Regulated Power Supply
This type of supply is the conventional. It may be getting a bit dated, but serves
the purpose to provide a basic experience for making a standard power supply. This
lab is also known locally as the “smoker.” This is because despite warnings students
find it too irresistible to measure the input and output signals with the two channels
of the scope. In doing so, they are effectively applying the input voltage directly to
a diode, which overloads, overheats, and starts smoking (heavily!).
11.6 Solar Cells
For this lab we need a 0-100 Ω power resistor.
A.12. LAB 12: BIPOLAR-JUNCTION TRANSISTOR 17

A.12 Lab 12: Bipolar-Junction Transistor


12.1 Transistor Curve
If you have the Tektronics 571 curve tracer, the settings are: NPN, IC (max) =
20 mA, VCE (max) = 20 V, IB /step = 10 µA, Nr of steps = 10, Rload = 0.25 Ω and
P max = 0.5 W.
12.2 Transistor Switch
This is one of two important applications of transistors. We add a relay to give
it a sense of purpose. If the relay can turn a power device, like a motor would give it
more sense of purpose, plus illustrate the utility of relays.
12.3 The Emitter Follower
This is the second main function of the transistor. This lab shows how to use
transistors to deliver power. The application will really be demonstrated when we
cover op-amps, which are excellent amplifiers but poor at delivering power. The op-
amp/transistor is a versatile combination in electronics applications. The speaker
could be any inexpensive one, but not earphones. It is easy for students to wire the
transistors incorrectly. If so, they can get very hot. If they drive the transistors very
hard, they may need a heat sink: attach an aluminum plate to them.
12.4 Current Source
This lab is mostly a demonstration of a transconductance amplifier: specifying a
voltage and obtaining a current. The potentiometer could really be anything that is
available.

A.13 Lab 13: Field-Effect Transistors


13.1 FET’s I–V Curve
If you have the Tektronics 571 curve tracer, use the following settings: N-FET,
IS (max) = 10 mA, VDS (max) = 5 V, Vg /step = 0.5 V, Nr of steps = 10, Offset = -5.00
V, Rload = 0.25 Ω and P max = 0.1 W. Get a printout. The highest curve corresponds
to VG = 5V . VG increases by 0.5 V from curve to curve.
13.2 Variable Resistor FET and AM Modulation
This is a fun application. It gives students the sense and ease of wireless trans-
mission of signals. It works very well. It is best done with one AM radio put in the
front of the lab room, since it makes the broadcasting a bit more dramatic.
13.3 MOSFET Switch
This lab illustrates the use of a MOSFET switch. Since they have already seen
the transistor switch, this lab could be skipped.
18 APPENDIX A. COMMENTS FOR THE INSTRUCTOR

A.14 Lab 14: Operational Amplifiers


14.1 Inverting Amplifier
This lab is a basic exercise on the use of the op-amp. It ends with its use as
microphone-speaker, using one speaker as a microphone, and another one as a speaker.
For the latter, students should wire the push-pull configuration per Figure 10.8 of the
textbook.
14.2 Noninverting Amplifier
This lab is another exercise in the use of op-amps. It has moving parts. The
tolerance of passage of the chopper wheel through the opening of the optointerrupter
is not high. Safety glasses should be used because students make that chopper wheel
fly, and sometimes the chopper blade crashes on the optointerrupter frame and parts
may fly off.
14.3 Mystery Circuit
This lab is used in conjunction with Exercise 10.6 of the textbook. It is a phase
shifter. The two extremes are R = 0 (in phase) and R → ∞ (out of phase). One can
use discrete resistors, but never not use one (for the R → ∞ case) because we need
a path to ground for capacitor charges.
14.4 Servo and Constant-Illumination Controller
This is the author’s favorite lab. It shows negative feedback to students, which is
the basis for many control systems. It also has several blocks, which require students
to understand amplification, the differential amplifier, integration and current ampli-
fication. It is a good exercise in troubleshooting. See Appendix B of the textbook for
a guide in troubleshooting analog circuits. The phototransistor can be replaced by a
photodiode.
14.5 Voltage-Controlled Oscillator
This lab is a useful illustration of oscillators. It has enough components and
interesting parts that it is worth the try. The end result is a play device. If we need
to choose, because of time, it could replace 14.2.

A.15 Lab 15: Real Op-Amps


This lab is necessary if students are expected to do serious use of op-amps in upper-
level labs or the research laboratory. Op-amps have limitations, and it is good to
know them. The wiring is otherwise straightforward.

A.16 Lab 16: Digital-Analog


This lab has a few exercises that combine digital and analog.
A.16. LAB 16: DIGITAL-ANALOG 19

16.1 Stepper Motor


This lab involves wiring a circuit that produces digital outputs to drive a stepper
motor. It is a good recipe for applications in the research lab. The final stage involves
power transistors, which are needed to drive the motor. The cover of this lab manual
is a stepper-motor circuit used to drive two stepper motors connected to an XY optical
stage. It was an upper-level capstone research project.
16.2 Connecting to the Analog World
This lab uses a D/A to play some musical tones stored in memory. These are
effectively numbers, so students have to play for a while to get something right. It
requires a function generator with a VCO input, unless a dedicated VCO circuit is
built (see lab 14.5). The students use and modify an Arduino program that is supplied
and listed below.

#include <SPI.h> // use Arduino’s SPI library


// digital pins used by the SPI library:
#define PIN MOSI 11 // Connected to PIN 2 Din of DAC
#define PIN MISO 12 // Not used
#define PIN SCK 13 // Connected to PIN 1 of DAC
#define PIN SS 10 // Not used
#define PIN nLOAD 9 // Connected to PIN 3 of DAC
#define VOLTAGE MAX (9.0) // max output of DAC = Vref pin 6
#define DIGITAL MAX (4095) // biggest 12bit integer + 1.
// different wave types
#define WAVE SQUARE 0
#define WAVE SINE 1
#define WAVE TRIANGLE 2
#define WAVE SAW UP 3
#define WAVE SAW DOWN 4
#define MYSONG 5
long loop count = 0;
// setup() is automatically called just once at startup or reset
void setup ()
pinMode(PIN nLOAD, OUTPUT); // configure our load pin
20 APPENDIX A. COMMENTS FOR THE INSTRUCTOR

SPI.begin(); // start SPI bus (configs all SPI pins automatically)


SPI.setClockDivider(SPI CLOCK DIV16);
// arduino runs at 16MHz
// LTC1257 DAC max speed 1.4MHz
// divide arduino clock speed by 16 to clock LTC1257 @ 1MHz
SPI.setBitOrder(MSBFIRST); // LTC1257 expects bits to arrive MSB
first
SPI.setDataMode(SPI MODE0);
loop count = 0;
// loop() is automatically called over and over for you.
void loop()
float valu;
long div,mod,freq;
int wave, delayT;
// transferFloat(3.14159);
wave = WAVE SINE;
freq = 5000; // this is not Hz... it is counts of loop count variable.
switch(wave)
default:
case WAVE SQUARE:
div = loop count / (freq/2);
if(div & 1L)
valu = VOLTAGE MAX;
else valu = 0.0;
transferFloat(valu);
break;
case WAVE SINE:
mod = loop count
valu = (VOLTAGE MAX / 2.0) * (1.0 + sin((2.0*PI) * (mod / (float)freq)));
transferFloat(valu);
A.16. LAB 16: DIGITAL-ANALOG 21

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

voltf = (float) voltlow/Nmax;


d = (int) (DIGITAL MAX * voltf);
// SPI library is set up to transfer one byte (8bits) at a time.
// we have 12bits, so we need 2 bytes.
// separate the integer value ’d’ into a low-byte and a high-byte.
lob = (d & 0x00ff);
hib = (d & 0x0f00) >> 8;
// LTC1257 expects MSB first, so make sure we ship ’hib’ first!
SPI.transfer(hib);
SPI.transfer(lob);
// 12bits are now in LTC1257’s serial-in-shift-register.
// Toggle LOAD pin so this is latched to LTC1257’s DAC output register.
// minimum toggle time = 150ns.
// include delayMicroseconds(1); call just to make sure.
digitalWrite(PIN nLOAD, LOW);
delayMicroseconds(1);
digitalWrite(PIN nLOAD, HIGH);
// if our peripheral had a Chip-Select pin, we would need to disable that
here.
// digitalWrite(pinCS, HIGH);

You might also like