You are on page 1of 16

9.24.

18

EGR 262
Lab #4
Digital to Analog Conversion

9.24.18

Nicholas Pauza
Dakota Bernacki

1
9.24.18

Table of Contents

Pre-lab
1. Fritzing breadboard layout.
2. Fritzing schematic layout.
3. 3-bit ladder network analysis.
4. Arduino program with DAC control function.
5. Written explanation of how the program and circuit work in concert.
Lab Work
1. Circuit construction.
2. Program test.
Post-lab report
1. Discussion of program performance.
2. Comparison of Analog outputs.
3. DAC resolution.
4. Restructuring as a 10-bit DAC.
5. Lessons Learned.

Pre-Lab
2
9.24.18

1. Fritzing breadboard layout:

2. Fritzing schematic:

3
9.24.18

[common cathode display part swapped to common anode]

3. 3-bit Ladder Network Bit-by-bit Voltage Contributions:


a. Analysis
i. Digital input 100

R 1 R 2 R 4 R 6
A B C
4 .4 K 2 .2 K 2 .2 K 4 .4 K
V1
D C = 5V R 3 R 5
AC = 0 4 .4 K 4 .4 K
TR A N = 0

Find Req:
4.4 kΩ /¿ 4.4 kΩ=2.2 kΩ
2.2 kΩ+ 2.2 kΩ=4.4 kΩ
4.4 kΩ /¿ 4.4 kΩ=2.2 kΩ
4.4 kΩ+ 2.2 kΩ+2.2 kΩ=8.8 kΩ
Req=8.8 k
Find V0 :

4
9.24.18

5V 1
I o= = A
8.8 kΩ 1760
1
V 5 V −V = A∗4.4 kΩ=2.500V
0
1760
V 0=5 V −2.500V =2.500 V

For input 100:V 0=2.500 V

ii. Digital input 010

R 13 R 14 R 15
H I J
2 .2 K 2 .2 K 4 .4 K

R 16 R 17 R 18
4 .4 K 4 .4 K 4 .4 K

i1 V 6 i2 i3
D C = 5V
AC = 0
TR A N = 0

KCL i1:
4.4 kΩ∗i1+2.2 kΩi 1+ 4.4 kΩ ( i1−i 2 ) +0∗i3+5 V =0
11∗i1−4.4∗i2+0∗i 3=5 V

KCL i2:
4.4 kΩ ( i 2−i1 ) +2.2 kΩ∗i2+4.4 kΩ (i 2−i 3 )−5 V =0
−4.4 kΩ∗i1+11 kΩ∗i2−4.4 kΩ∗i3=5V

KCL i3:
0∗i1+4.4 kΩ (i 3−i 2 ) +2.2 kΩ∗i3=0
0∗i1−4.4 kΩ∗i2+8.8 kΩ∗i3=0

[ ]
−0.28 mA i 1
rref = 0.43 mA i 2
0.21mA i3

V0 : Find
V 0=−0.28 mA∗4.4 kΩ=−1.250V

5
9.24.18

For input 010: V 0=1.250 V


iii. Digital input 001

R 13 R 14 R 15
G H I
2 .2 K 2 .2 K 4 .4 K

R 16 R 17 R 18
4 .4 K 4 .4 K 4 .4 K

i1 i2 V3 i3
D C = 5V
AC = 0
TR AN = 0

KCL i1:
6.6 kΩ∗i 1+4.4 kΩ ( i 1−i2 ) +0∗i 3=0
11∗i1−4.4∗i2+0∗i 3=0

KCL i2:
4.4 kΩ ( i 2−i1 ) +2.2 kΩ∗i2+4.4 kΩ (i 2−i 3 ) +5 V =0
−4.4 kΩ∗i1+11 kΩ∗i2−4.4 kΩ∗i3=−5 V

KCL i3:
−5 V + 4.4 kΩ ( i3−i2 ) + 4.4 kΩ∗i 3=0
0∗i1−4.4 kΩ∗i2+8.8 kΩ∗i3=5V

[ ]
−0.14 mA i1
rref = −0.36 mA i 2
0.39 mA i 3

Find V 0 :
V 0=−0.14 mA∗4.4 kΩ=−0.625 V

For input 010:V 0=0.625

Digital Input (b2 , b3, b0) Analog Output (V0)


000 0V
001 0+0+0.625 = 0.625V
010 0+1.250+0 = 1.250V
011 0+1.250+0.625 = 1.875V
100 2.500+0+0 = 2.500V
101 2.500+0+0.625 = 3.125V
110 2.500+1.250+0 = 3.750V 6
111 2.500+1.250+0.625 = 4.375V
9.24.18

b. Step Graph

3 Bit Ladder DAC


5
4.5
4
3.5
Analog Voltage [V]

3
2.5
2
1.5
1
0.5
0
000 001 010 011 100 101 110 111
Digital Input

Voltage
Binary [V]
000 0
001 0.625
010 1.25
011 1.875
100 2.5
101 3.125
110 3.75
111 4.375

7
9.24.18

4. Arduino Program With DAC Control Function:

8
9.24.18

9
9.24.18

10
9.24.18

5. Program circuit interaction:


This is a 3-bit DAC used for counting mod-7 in analog. Increment and decrement buttons are used to count
down or up through the cycle [0-7] which will also be shown on the 7-segment display. The DAC should
convert the binary output into a step voltage, from about 0V to about 4.375V, with each voltage step being
about 0.625V. An analog output wire is available to read the step voltage after the DAC conversion.

Lab Work
1. Build Circuit 1
a. Most of the circuit should already be in place from Lab #3. Add the additional parts.
b. The circuit should match your Fritzing breadboard layout.
c. Use neat wiring practices.

11
9.24.18

2. Testing the Program


a. Download and run the program for Lab 4. Verify that the counter properly increments and
decrements (mod-8) both on the 7-segment display and on the computer screen.
DONE

b. Connected a voltmeter to output V0 on the R-2R ladder network. Recorded voltages for all 8
possible inputs:
Bit Voltage [V]
000 0.012
001 0.629
010 1.260
011 1.880
100 2.500
101 3.130
110 3.750
111 4.370

c. Program serial output to the computer screen:

12
9.24.18

d. Demonstrate the program to the instructor.


DONE

e. Lab problems encountered or lessons learned:


During the lab it was noticed that sometimes the voltmeter would step up or step down at
intermittent intervals between counts (ie. when changing from 0 to 1, the voltmeter would
display 0.012, then flash 0.362 briefly before settling out at 0.629). We experimented with the
results to see if there were certain positions that this phenomenon would occur more or less
likely. At first, it seemed like when incrementing from 5 to 6 it would always happen, but then
that was proved false. Likewise, this phenomenon never happened when changing from step 1
to 2. A theory was developed that maybe the voltmeter samples at a certain interval, say for
example every 10 milliseconds. If it takes the circuit on the circuit-board 5 milliseconds to reach
equilibrium, there is a small chance that the voltmeter would sample while the voltage in the
circuit is still climbing, and it would then display a value somewhere in between the previous
voltage and the next step voltage. Since the phenomenon never occurred when changing
position from 1 to 2, it was decided to just keep cycling from 1 to 2 to see if it would eventually
happen; It did after 15 or so tries. It was then likely that this is what was causing the
intermediate step voltage.

13
9.24.18

Post Lab
1. Program performance:

The program has 2 loops running, the increment loop and the decrement loop. If a valid
button press is detected from either the increment or the decrement button, then the
corresponding “if” statement will be initiated. In the “if” statement, the “x” value will either
be incremented or decremented. The “display_digit” function and the “R2R” function will be
called out so that the 7-segment display will display the current count and the binary number
will be displayed on the screen. The valid button press is a function that will avoid the button
bouncing and continuously incrementing or decrementing the number. This way when the user
presses the button once, the number increments or decrements once.

2. Comparison of the measured analog outputs with the predicted analog outputs for each digital
(binary) input. Identification of major contributors to this error:

14
9.24.18

Actual Error Percent


Theory Voltage [V] Measured Voltage [V] [V] Error
0.000 0.012 0.012 12.0%
0.625 0.629 0.004 0.6%
1.250 1.260 0.010 0.8%
1.875 1.880 0.005 0.3%
2.500 2.500 0.000 0.0%
3.125 3.130 0.005 0.2%
3.750 3.750 0.000 0.0%
4.375 4.370 -0.005 -0.1%

=N25-M25 =O25/M25*100

While all of our measured values were quite close to their expected values we can still speculate
on why there was variation. There is never an absolute 0V being output by the Arduino; this most
likely is why we had a small voltage present for binary 000. The other voltages likely varied from
our predictions due to the resistors we used not possessing exactly their professed resistances.
However, since our error is so small, it seems that the resistors we used were quite close to their
expected resistances.

3. Voltage resolution of the 3-bit DAC used in this lab:


The voltage resolution of our 3-bit DAC is 0.625V; which is, (0.625V/4.375V) = 0.1429, about
14.3% of our DAC’s max voltage output.

4. If we replaced the 3-bit R-2R ladder network with a 10-bit R-2R ladder network:
a. How many digital output pins would be needed for the R-2R circuit:
10 output pins are required.

b. How many 2.2 k resistors would be needed:


10 2.2kΩ resistors are required as well as 10 4.4kΩ resistors.

c. How many different analog voltages would be available:


1024 different analog voltages.

d. What would be the increment between voltages (the resolution as a voltage):


Max voltage = ½+1/4+1/8+1/18+1/64+1/128+1/256+1/512+1/1024+1/2048 = 0.99902
5V*0.99902 = 4.9951V

4.9951V/1024 = 0.00489V giving us a resolution of 4.89mV.

5. Lessons learned:
In this lab we learned how to convert digital signals to analog utilizing
voltage stepping. We gained a base understanding of how a DAC can be
built and how it leverages the circuit principles we know to achieve the
conversion from analog to digital.

15
9.24.18

16

You might also like