CEC 222 Digital Electronics Lab Spring 2015 Lab 1: Introduction to Digital Lab Learning Objectives: Develop familiarity with some of the lab equipment and simple components (e.g., oscilloscope, logic analyzer, voltmeter, inverter, and resistors). Introduce the relationship between digital and analog signals Lab Overview: In this lab you will be building a digital to analog converter (DAC), specifically, an R–2R resistor ladder network. The switches on your FPGA board will generate a 4-bit digital value which is converted, via your DAC circuit, to an analog voltage which you measure with a voltmeter. The latter part of the lab involves using an oscilloscope to determine the frequency and magnitude of mystery signals. YOUR NAME(S) Page 1 of 6 CEC 222 Digital Electronics Lab Spring 2015 Pre-Lab (10%) Question 1. What is the resistor color code for the following resistor values (assume a 5% tolerance)? Value 10 k 47 M 1st Band brown 2nd Band 3rd band 820 2.2 k 4th band gold Question 2. What is the value and tolerance for each resistor shown? Value Tolerance Resistor Figure 1 Resistor color codes 10% Question 3. In the lab we will be realizing a 4-bit digital to analog converter (DAC) via a R–2R resistor ladder network (see Figure 2) which transforms a digital input digital pattern (i.e., decimal value) into an analog output voltage (Vout). If the resistor values are exact the theoretical output of our ladder network DAC is Vout 3.3 Task 1. Decimal Value 24 Noting that the 4-bit digital pattern “0000” has a decimal value of 0 and “1111” has a decimal value of 15, use this formula to fill in the second and fourth columns of Table 1. Question 4. Considering the plot of a 0 V to 3.3 V magnitude 1 kHz square wave shown in Figure 2: a) What is the horizontal time scale? _______________________ seconds/division b) What is the vertical magnitude scale? ____________________ Volts/division Figure 2 A 1 kHz square wave YOUR NAME(S) Page 2 of 6 CEC 222 Digital Electronics Lab Spring 2015 Experiments (90%) EXPERIMENT 1. DIGITAL TO ANALOG CONVERSION For this experiment you will be building and testing a simple digital to analog converter (DAC) (specifically, an R–2R resistor ladder network) via the circuit shown in Figure 3. Follow the steps below in order to complete the experiment. Output Voltage (Vout) SW2 SW1 20 k 20 k 20 k SW3 10 k 20 k 10 k 20 k 10 k SW0 MODE jumper Port JA Power switch SW3 – SW0 switches Figure 3 Digital to analog conversion circuit configuration. Step 1.a: Load the file “lab1.bit” into your BASYS 2 FPGA board Set the MODE jumper on your FPGA board (from PC) to ROM Connect your board to a PC (via USB cable) and turn on the board’s power Download the “lab_1.bit” file onto your desktop, start the “Adept” software, and on the row labeled “PROM” click on browse ( board ( ) to select the “lab1.bit” file. Program the ) with this file. You should now be able to generate a 4-bit pattern on port “JA” via the slide switches SW3 to SW0. The pattern will also be displayed on the LEDs next to the switches (LED3 to LED0). YOUR NAME(S) Page 3 of 6 CEC 222 Digital Electronics Lab Spring 2015 TURN OFF your FPGA board before continuing!! Step 1.b: Build the resistor circuit on your breadboard and connect to port “JA” Obtain five 20 k and three 10 k resistors Note the connectivity between the holes on a breadboard On your breadboard, build the resistor circuit shown in Figure 3 and make the connections between your circuit (i.e., breadboard) and the six nodes of port JA of your FPGA. Have the instructor or TA inspect your circuit before turning on the power to your FPGA Step 1.c: Vary the four switches to generate all possible 4-bit binary patterns and record the resulting output voltages using a voltmeter. Turn on the power to your FPGA and use a voltmeter to measure the Output Voltage of your DAC as you vary the 4-bit binary pattern on port “JA” via the slide switches SW3 to SW0. Task 2. Record your results in column three of Table 1. Binary Pattern (SW3 …SW0) 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 Table 1 Results of Digital to Analog Conversion Measured Output Theoretical Output Decimal Value Voltage (Vout) in Volts Voltage (Vout) in Volts 0 0.00 9 15 3.09 Question 5. Considering Table 1 which row exhibits the largest difference between measured and theoretical output voltages, what is this difference (in Volts), and why is there a difference between the theoretical and measured values? YOUR NAME(S) Page 4 of 6 CEC 222 Digital Electronics Lab EXPERIMENT 2. Spring 2015 INTRODUCTION TO THE OSCILLOSCOPE For this experiment you will be using an oscilloscope to determine the frequency and magnitude of two “mystery” waveforms. The file which you loaded/programmed into your FPGA board also generates two square wave signals on port JB, specifically, on the pins labeled C6 and B6. Step 2.a: Determine the frequency and magnitude of the signal on port JB pin C6. Assume that the signal on pin C6 has a frequency around 1 kHz and amplitude of approximately 3 V. Question 6. What is the approximate period of the waveform and hence what is a reasonable selection for the horizontal time scale (time/division)? Question 7. What is a “reasonable” selection for the vertical scale (V/division)? Take a screenshot of the window showing more than one, but, less than two periods of the waveform (you will likely need to further adjust the horizontal and vertical scale). Compute the magnitude and frequency from this screenshot (i.e., you will need to see your horizontal and vertical scale choices). Step 2.b: Determine the frequency and magnitude of the signal on port JB pin B6. Assume that the signal on pin B6 has a frequency around 10 kHz and amplitude of approximately 3 V. Repeat Step 1 for this signal. Report Requirements Task 3. Plot the values from Table 1. Specifically, plot a line for the theoretical voltages (vertical axis) vs decimal values (horizontal axis) and a second line corresponding to the measured voltages vs decimal values on the same graph. Question 8. What is the resolution of the DAC which you built (in Volts)? Question 9. What is your determination of the magnitude and frequency of the square wave on port JB pin C6? Question 10. JB pin B6? YOUR NAME(S) What is your determination of the magnitude and frequency of the square wave on port Page 5 of 6 CEC 222 Digital Electronics Lab Spring 2015 Optional (10% Extra Credit) Exercise(s) EXPERIMENT 3. ADDITIONAL FUNCTIONALITY OF THE OSCILLOSCOPE For this experiment you will be repeating the steps of experiment 2, however, we will also explore the effects of triggering and coupling. Step 3.a: Recapture the screenshot of the signal on port JB pin C6 with edge-triggering Set the scope to rising edge triggering and take a screenshot of the window showing more than ½, but, less than one period. Question 11. What is the width (in seconds) of first half of the square wave? Set the scope to falling edge triggering and take a screenshot of the window showing more than ½, but, less than one period. Question 12. What is the width (in seconds) of second half of the square wave? Step 3.b: Recapture the screenshot of the signal on port JB pin B6 with coupling (MSO-28 Oscilloscope only) Set the scope to DC coupling and take a screenshot of the window showing more than one, but, less than two periods of the waveform. Question 13. What are the minimum and maximum magnitudes of the signal? Set the scope to AC coupling and take a screenshot of the window showing more than one, but, less than two periods of the waveform. Question 14. What are the minimum and maximum magnitudes of the signal? Reference Material [ 1] Digilent Basys2 Board Reference Manual [ 2] Digilent ADEPT software (free download) Appendix A: Using the Analog Discovery Oscilloscope Appendix B: Using the MSO-28 Oscilloscope YOUR NAME(S) Page 6 of 6