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, voltmeter, and resistors). Introduce the relationship between digital and analog signals. Lab Overview: In this lab you will be building a digital to analog 8 (DAC), specifically, an R–2R resistor ladder network. The switches on your FPGA board will generate a 4-bit digital value that is converted, via your DAC circuit, to an analog voltage that 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) Lab 01 Page 1 of 9 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)? Fill in the table. 1st Band brown Select Value 10 k 47 M 820 2.2 k Select Select 2nd Band select violet Select Select 3rd band Select Select 4th band Select Select Select Select gold Select Question 2. What is the value and tolerance for each resistor shown? Enter the value in Ohms. Value () Enter Text Tolerance Resistor Enter Text Color 1st Band (1st digit) 2nd Band (2nd digit) 3rd Band (multiplier) Black 0 0 100 Brown 1 1 101 Red 2 2 102 Orange 3 3 103 Yellow 4 4 104 Green 5 5 105 Blue 6 6 106 Violet 7 7 107 Grey 8 8 108 White 9 9 4th Band (tolerance) 2% 109 Gold 10-1 5% Silver 10-2 10% Figure 1 Resistor color codes Enter Text 10% Enter Text Enter Text In the lab we will be realizing a 4-bit digital to analog converter (DAC) via an R–2R resistor ladder network (see Figure 3) that 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 (1.1) Noting that the 4-bit digital pattern “0000” corresponds to a decimal value of 0 and “1111” a decimal value of 15, use Eqn. (1.1) to fill in the second and fourth columns of Table 1. Question 3. 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 Task 2. YOUR NAME(S) Watch the 12 min Digilent video on the oscilloscope. Lab 01 Figure 2 A 1 kHz square wave Page 2 of 9 CEC 222 Digital Electronics Lab Spring 2015 Experiments (90%) EXPERIMENT 1. DIGITAL TO ANALOG CONVERSION In this experiment, you will be building and testing a simple digital to analog converter (DAC) via the circuit shown in Figure 3. Follow the steps below to complete the experiment. Note the wireing color convention that RED = POWER (Vcc) and BLACK = GROUND (GND). 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 RED = Power (Vcc) BLACK = Ground Power switch LED3 to LED0 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 ( click on browse ( Program the board ( ), and on the row labeled “PROM” ) to select the “lab1.bit” file. ) with this file. Programming may take ~ 30 seconds. 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). TURN OFF your FPGA board before continuing!! YOUR NAME(S) Lab 01 Page 3 of 9 CEC 222 Digital Electronics Lab Spring 2015 Step 1.b: Build the resistor circuit (see Figure 3) 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 the voltmeter functionality of the Analog Discovery (see Appendix A: A1) Appendix A: ) to measure the output voltage (Vout) of your DAC as you vary the 4-bit binary pattern on port “JA” via the slide switches SW3 to SW0. Task 3. 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 Enter Text 0.00 Enter Text Enter Text Enter Text Enter Text Enter Text Enter Text Enter Text Enter Text Enter Text Enter Text Enter Text Enter Text Enter Text Enter Text Enter Text Enter Text Enter Text Enter Text Enter Text Enter Text Enter Text Enter Text Enter Text Enter Text 9 Enter Text Enter Text Enter Text Enter Text Enter Text Enter Text Enter Text Enter Text Enter Text Enter Text Enter Text Enter Text Enter Text Enter Text Enter Text Enter Text Enter Text 15 Enter Text 3.09 Question 4. Considering Table 1, determine which row exhibits the largest difference between measured and theoretical output voltages. Largest difference = ________________ in Volts. Question 5. Why is there a difference between the theoretical and measured values? __________________________________________ YOUR NAME(S) Lab 01 Page 4 of 9 CEC 222 Digital Electronics Lab EXPERIMENT 2. Spring 2015 INTRODUCTION TO THE OSCILLOSCOPE For this experiment you will be using your Analog Discovery USB 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 of 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) of the oscilloscope (assume 10 divisions)? in seconds Reasonable horizontal scale = Approximate period = s/division Question 7. What is a “reasonable” selection for the vertical scale (V/division) of the oscilloscope (assume 10 divisions)? Reasonable vertical scale = V/division Start the Digilent -> WaveForms software ( Oscilloscope ) and click on the “Scope” icon in order to start the oscilloscope. Connect “scope channel 1 positive” to the FPGA’s port JB pin C6 and “scope channel 1 negative” to GND (see Figure 9 for the connectivity details). Task 4. Take a screenshot (Figure 4) 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 scales, also, you will need to be able to see your horizontal and vertical scale choices. Figure 4 Screenshot of the waveform on pin C6. YOUR NAME(S) Lab 01 Page 5 of 9 CEC 222 Digital Electronics Lab Spring 2015 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 2.a: for this signal. Approximate period = ______________ in second Reasonable horizontal scale = s/division Reasonable vertical scale = _________ V/division Figure 5 Screenshot of the waveform on pin B6. Report Requirements Task 5. 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 (include a legend). YOUR NAME(S) Lab 01 Page 6 of 9 CEC 222 Digital Electronics Lab Spring 2015 Figure 6 Plot of the DAC output (measured & theoretical) vs decimal value. Question 8. What is the resolution1 of the DAC which you built (in Volts)? _____________ in Volts Question 9. What is the magnitude and frequency of the square wave on port JB pin C6? Magnitude = ___________ in Volts and Frequency = ________________ in Hz Question 10. What is the magnitude and frequency of the square wave on port JB pin B6? Magnitude = ___________ in Volts and Frequency = ________________ in Hz Optional Exercise(s) (+10% Extra Credit) 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. (Video -> Analog Discovery Tutorials: Scope 2: Triggered Acquisition) 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. You will also need to set the (triggering) level to about 1V. 1 Smallest change in the output voltage that is realizable. YOUR NAME(S) Lab 01 Page 7 of 9 CEC 222 Digital Electronics Lab Spring 2015 Figure 7 Screenshot of the waveform on pin C6 with rising edge triggering. Question 11. What is the width (in seconds) of first half of the square wave? ____________ in sec Set the scope to falling edge triggering and take a screenshot of the window showing more than ½, but, less than one period. Figure 8 Screenshot of the waveform on pin C6 with falling edge triggering. Question 12. What is the width (in seconds) of second half of the square wave? ___________ in sec Reference Material [1] Digilent Basys2 Board Reference Manual [2] Digilent ADEPT software (free download) [3] Analog Discovery video tutorials YOUR NAME(S) Lab 01 Page 8 of 9 CEC 222 Digital Electronics Lab Spring 2015 APPENDIX A: USING THE ANALOG DISCOVERY OSCILLOSCOPE Figure 9 Input / Output connections for the Analog Discovery. A1) VOLTMETER FUNCTIONALITY OF THE ANALOG DISCOVERY Start the Digilent -> WaveForms software ( ) and select “Voltmeter” from the pull-down menu via “More Instruments.” Connect “scope channel 1 positive” (i.e., 1+) to the signal of interest and “scope channel 1 negative” (i.e., 1-) to GND. YOUR NAME(S) Lab 01 Page 9 of 9