Professional Documents
Culture Documents
Laboratory objectives:
1. Learn how to work with an oscilloscope
2. Implement a digital-to-analog converter (DAC) based on R-2R resistor ladder, with and
without a buffer.
3. Integrating Arduino with electric circuits
4. Simulate circuits using TinkerCAD
PART A: Tutorials
A.1 Mixed Domain Oscilloscope:
An oscilloscope is an instrument used to display and analyze waveforms of electronic
signals. The device displays a graph of the instantaneous signal voltage (y-axis) as a
function of time (x-axis). Tektronix MDO3024 is the model used in the lab.
Controls dials allow you to adjust the scale of the graph, both vertically and horizontally
and zoom in and out on a signal. An oscilloscope (or scope) is useful for troubleshooting
circuit design, including:
- Determining frequency and amplitude of signals (circuit’s input and output).
- Identifying the shape of a waveform (sine, square, triangle, sawtooth, etc.)
- Quantifying phase differences between two different signals.
1
Scopes help to quickly quantify frequency, amplitude, and other waveform
characteristics. In general, a scope can measure both time-based and voltage-based
characteristics:
- Frequency (f) and period (T): – frequency is defined as the number of times per
second a waveform repeat. And the period is the reciprocal of that (number of
seconds each repeating waveform takes). The maximum frequency a scope can
measure varies, for the model mentioned it is 200 MHz.
- Duty cycle: the percentage of a period that a wave is positive or negative. It is a ratio
that determines how long a signal is “on” versus how long it is “off” during one
period.
- Rise and fall time: the duration it takes a wave to go from a low value to a high
value. Fall time measures reverse direction. These characteristics are important when
considering how fast a circuit can respond to signals.
- Amplitude: a measure of the magnitude of a signal. Can be a peak-to-peak amplitude
(absolute difference between a high and low voltage) or peak amplitude (measures
how high or low a signal is with respect to 0V).
- Maximum/minimum voltage: determine how high and low a circuit voltage gets.
- Average voltage: can calculate the average or mean of a signal.
The Tektronix MDO3024 model includes 4 analog channels, 16 digital channels and can
analyze a frequency range of 9kHz to 200 MHz (spectrum analyzer).
Detail information can be found at: https://www.tek.com/oscilloscope/mdo3000-mixed-
domain-oscilloscope-manual/mdo3000-series-3
2
3
4
5
PART B: Op-Amps and Implementation of Electric Circuit
In other words, a 4-bit DAC with an output voltage between 0V to 4.5V will have a
( )
∆𝑣 = = 0.3125𝑉 . It will map 16=2 levels {0, 1, 2, 3, …, 14, 15} to voltage
levels {0V,0.3125V,0.625V, …, 4.375V,4.6875V}. Table 1 demonstrates the mapping
for this DAC.
Table 1: 4-bit DAC
Binary Level
MSB LSB Decimal Analog
𝟐𝟑 =8 𝟐𝟐 =4 𝟐𝟏 =2 𝟐𝟎 = 𝟏 Level Output
𝒃𝒊𝒕𝟑 𝒃𝒊𝒕𝟐 𝒃𝒊𝒕𝟏 𝒃𝒊𝒕𝟎 (volts)
0 0 0 0 0 0V
0 0 0 1 1 0.3125 V
0 0 1 0 2 0.625 V
0 0 1 1 3 0.9375 V
0 1 0 0 4 1.25 V
0 1 0 1 5 1.5625 V
0 1 1 0 6 1.875 V
0 1 1 1 7 2.1875 V
1 0 0 0 8 2.5 V
1 0 0 1 9 2.8125 V
1 0 1 0 10 3.125 V
1 0 1 1 11 3.4375 V
1 1 0 0 12 3.75 V
1 1 0 1 13 4.0625 V
1 1 1 0 14 4.375 V
1 1 1 1 15 4.6875 V
This device enables a microcontroller to set a required voltage level with a resolution of
∆𝑣 at 2 levels.
6
B.2 DAC implementation using R-2R resistor ladder
This can be implemented using several methods. One of them is using a R-2R resistor
ladder as shown in Figure 1.
A microcontroller can use a DAC to generate a desired waveform and drive an external
device such as a speaker. Implementation of a DAC with an op-amp buffer is depicted
in Figure 2.
Figure 2: DAC implementation using R-2R resistor ladder with a buffer at the output.
The buffer stage is acting as a limiter on the current drawn from the microcontroller
digital IOs.
7
B.3 Thevenin Equivalent for DAC
Assuming each one of the digital IOs can be modeled using a voltage source that can be
either at 5V or 0V (GND), it can be shown that the Thevenin Equivalent for the DAC
will result with the circuit shown in Figure 3.
As digital IOs can be set to either LOW (0V) or HIGH (5V) the minimum for 𝑣 will
be with all bits at LOW and thus 𝑣 = 0𝑉 and the maximum will be when all bits are
at HIGH and thus 𝑣 = 4.6875𝑉. Without the use of an op-amp, the output voltage
will change based on the load while, with a buffer (as seen in Figure 4) the output
voltage, independent of the load, will always be:
𝑣 =𝑉
8
Figure 4: Thevenin equivalent for the DAC in Figure 3 with a buffer.
9
Figure 5: Periodic waveforms.
10
PART C: Pre-Lab
𝟏 𝟏
Assuming an amplitude 𝑨 = 𝟐𝑽 and 𝑻 = 𝟐𝟎𝒎𝒔 or 𝒇 = = = 𝟎. 𝟎𝟓𝒌𝑯𝒛 = 𝟓𝟎𝑯𝒛
𝑻 𝟐𝟎𝒎𝒔
DAC data
t (msec) 𝒗𝑺𝑸𝑹(𝒃𝒊𝒂𝒔𝒆𝒅) Closest decimal Corresponding
value from Table 1 voltage level
[USE in LAB
experiment 2a]
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
11
C.2 If we wanted to generate a sinusoidal output:
𝟏 𝟏
Assuming an amplitude 𝑨 = 𝟐𝑽 and 𝑻 = 𝟐𝟎𝒎𝒔 or 𝒇 = = = 𝟎. 𝟎𝟓𝒌𝑯𝒛 = 𝟓𝟎𝑯𝒛
𝑻 𝟐𝟎𝒎𝒔
DAC data
t (msec) 𝒗𝑺𝒊𝒏(𝒃𝒊𝒂𝒔𝒆𝒅) Closest decimal Corresponding
value from Table 1 voltage level
[USE in LAB
experiment 2b]
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
12
PART D: In Lab Experiments
Laboratory instruments:
Power supply: Keithley 2231-30-3
Digital Multimeter (DMM): Keysight (Agilent) 34461A
Mixed Domain Oscilloscope: Tektronix MDO3024
Breadboard/Arduino set
1k and higher resistors by design
LM741 op-amp
Note: in both experiment we will be using this basic R-2R resistor ladder-based DAC! In
the next steps we will only add to this basic circuit
b. Choose for all resistors a value of R=10k
13
c. Connect the Arduino and multimeter as follows:
d. Connect BIT0 through BIT3 to either ‘+’ (5V) for HIGH or ‘-‘ (0V) for LOW to measure the
output voltage for Table 2.
e. Measurement recording:
Table 2: implemented 4-bit DAC output voltage measurements
SET Binary Level to:
MSB LSB Decimal Measured
𝟐𝟑 =8 𝟐𝟏 =2 𝟐𝟎 = 𝟏 Level Output Voltage
𝒃𝒊𝒕𝟑 𝒃𝒊𝒕𝟏 𝒃𝒊𝒕𝟎 𝒗𝒐𝒖𝒕 (volts)
0 0 0 0 0
0 0 0 HIGH 1
0 0 HIGH 0 2
0 HIGH 0 0 4
0 HIGH HIGH 0 6
HIGH 0 0 0 8
HIGH 0 HIGH 0 10
HIGH HIGH 0 0 12
HIGH HIGH HIGH 0 14
HIGH HIGH HIGH HIGH 15
14
Experiment # 5.1: PART B
Wiring Part 1b:
With the R-2R resistor ladder connected as before, connect the four inputs
(𝑏𝑖𝑡 , 𝑏𝑖𝑡 , 𝑏𝑖𝑡 , 𝑏𝑖𝑡 ) to the Arduino digital IOs as follows:
Arduino DAC
D0 𝑏𝑖𝑡
D1 𝑏𝑖𝑡
D2 𝑏𝑖𝑡
D3 𝑏𝑖𝑡
Software for Part 1b: you may use the Arduino sketch ‘BareMinimum’ under
File>Examples>01.Basics’ as a starting point or upload the file from a memory stick.
------------------
void setup(){
// RUNs once: LAB 5-part 1a
// we first need to define D0 to D3 as digital outputs
// DDRD: command that sets Port D Data Direction Register-read/write
// its sets Arduino pins 0 to 7 as outputs
15
// equivalent to: pinMode(0,OUTPUT);pinMode(1,OUTPUT); …;pinMode(7,OUTPUT);
DDRD = B11111111;
}
void loop() {
// RUNs repeatedly:
// PORTD is the register for the state of the outputs
// ++ increments the value of a variable by 1
PORTD ++;
// Wait for 1000 millisecond(s)
delay(1000);
}
------------------
TA Verification: _____________
Save an image of the scope to be added later to the post lab report (use either the USB port
with a memory stick or take a picture of the screen).
What is the period T of the sawtooth waveform?
o T = ______________
16
Experiment # 5.2: DAC with a buffer stage and more
17
Connect the DMM and the scope to the op-amp output 𝑣 _ .
Use ±𝟏𝟓𝑽 for the op-amp references. Make sure to connect ALL ground points on the
breadboard.
Based on the pre-lab, use the values you found for the triangular waveform to set the DAC
output using the following sketch:
Software for Part 2a: you may use the Arduino sketch ‘BareMinimum’ under
File>Examples>01.Basics’ as a starting point or upload the file from a memory stick.
------------------
// Define a data array size= 20
const int size = 20;
// initial value for index variable: will be used to read info from mBuffer
int index = 0;
void setup(){
// RUNs once: LAB 5-part 1a
// we first need to define D0 to D3 as digital outputs
// DDRD: command that sets Port D Data Direction Register-read/write
// its sets Arduino pins 0 to 7 as outputs
// equivalent to: pinMode(0,OUTPUT);pinMode(1,OUTPUT); …;pinMode(7,OUTPUT);
DDRD = B11111111;
}
void loop() {
// RUNs repeatedly:
// increment index variable: read next value from mBuffer
index = index+1;
18
// read next value from mBuffer
unsigned char dvolt = mBuffer[index];
TA Verification: _____________
Save an image of the scope to be later added to the post lab report (use either the USB port
with a memory stick or take a picture of the screen).
What is the period T of the triangular waveform 𝑣 _ ?
o 𝑇 = ______________
What is the minimum and maximum voltage of the triangular waveform 𝑣 _ ?
o 𝑣 (𝑚𝑎𝑥𝑖𝑚𝑢𝑚) = ______________
o 𝑣 (𝑚𝑖𝑛𝑖𝑚𝑢𝑚) = ______________
o Is it also a triangular waveform? _______________
19
Experiment # 5.2: PART B
------------------
20
Experiment # 5.2: PART C
Using the amplitude values from Table 1 calculate a 10ms period waveform with 𝑨 = 𝟐𝑽 and
𝟏 𝟏
𝑻 = 𝟏𝟎𝒎𝒔 or 𝒇 = = = 𝟎. 𝟏𝒌𝑯𝒛 = 𝟏𝟎𝟎𝑯𝒛
𝑻 𝟏𝟎𝒎𝒔
DAC data
t (msec) 𝒗𝑺𝒊𝒏(𝒃𝒊𝒂𝒔𝒆𝒅) Closest decimal Corresponding
value from Table 1 voltage level
0
1
2
3
4
5
6
7
8
9
21
Speaker supplied:
- A 8 with maximum power of 0.5W. We can limit it by either:
setting the maximum allowable voltage drop across the speaker to:
𝑣 = 𝑃 ∙𝑅 = 2𝑉 or
setting the maximum allowable current flowing through the speaker to:
𝑖 = 𝑃 /𝑅 = 0.25𝐴
- It works with sinusoidal signal with frequency in the range of 40Hz-20kHz.
22
PART E: Post-Lab Report
The lab report should include a filled and signed copy of part D and analysis of the data based
on the following questions and required simulation.
1. Verifying theory:
a. Use superposition and source transformation to show that the Thevenin equivalent for
the DAC in Figure 1 is:
b. Using the Thevenin equivalent for the DAC in Figure 1, find the voltage drop across the
load connected to the DAC output, vload as a function of the D0-D3 voltage levels, R and
the load resistance
c. Using the Thevenin equivalent for the DAC with a buffer in Figure 2, find the voltage
drop across the load connected to the DAC output, vload as a function of the D0-D3
voltage levels, R and the load resistance
23
2. Analysis for experiment 5.1 (show all work for calculations and explain the experimental
results versus calculated ones in each of the relevant sections):
2.1 Compare the values measured for vout in Table 2 with the expected values in Table 1.
How do they compare? explain.
2.2 The digital IOs of an Arduino have an output current of 40mA. How much power can it
deliver at an output voltage of 5V?
2.3 For the DAC, connected to 4 IOs, what is the maximum power that the Arduino can
deliver to the DAC?
2.4 What will be the maximum current the DAC without a buffer can deliver at the output
(Hint: use the Thevenin equivalent) and how does it relate to the short circuit current for
the DAC?
3. Analysis for experiment 5.2 (show all work for calculations and explain the experimental
results versus calculated ones in each of the relevant sections):
3.1 Output short circuit current information for the LM 741 op-amp determines the
maximum current the op-amp can source or sink at the output pin (typically 25mA).
Assuming we use the DAC with a buffer (as we did) to feed the speaker, what is
the maximum current that will be delivered to the speaker?
Assuming we use the DAC without the buffer to feed the speaker, what would
be the maximum current delivered to the speaker?
What will you need to change in the DAC design in order to deliver more current
to the speaker and how will the digital IOs output current limit this design?
24
3.2 Evaluate the output of the DAC with the op-amp (buffer) for the triangular and
sinusoidal signals. Include images of the actual waveforms
3.3 What is the period (T) and the frequency (f) for the periodic function in part 2a and 2b
when the delay command in the software was set to1ms?
4. Simulation:
Simulate the networks used for experiment 5.1 and experiment 5.2 using TinkerCAD.
25