Digital To Analog Converter with Sine Wave Output Overview In this Lab we will build a resistive ladder network and use the BASIC Stamp to generate the digital data for the D/A conversions. PBASIC will be used to program the BASIC Stamp to send the resistive ladder network sets of binary values that will yield distinct voltage levels at the output of the network. . Parts Required Gather these parts from your parts: (10) 2 k resistors (7) 1 k resistors (1) Red LED (1) 270 resistor (1) LM 358 op-amp Converter Discussion A simplified example with only four of the eight inputs needed of resistive ladder network for this experiment is shown in shown in Figure 1. It's components are definitely an inexpensive alternative compared to an integrated circuit digital to analog converter (D/A converter or DAC). A few resistors are a fraction of the cost of an integrated circuit, however when manufacturing a large number of circuits the cost of inserting so many components would be much more than the cost of inserting one IC. Then there is the size and power issues. The resistive ladder network is also used in many A/D and D/A integrated circuits, such as the ADC0831. The resistors used in integrated circuits are microscopic implants on the surface of a silicon wafer. One advantage of IC converters is that they have a high degree of accuracy. Another advantage an IC has extra built in output circuitry such as a voltage follower. Circuit Discussion. The following R2R Ladder network is different from the one that is in the textbook (see Figure 3- NOTE it has 8 inputs). The changes were necessary for building a simple DAC that doesn’t have negative voltages at the output. The digital inputs to the ladder network are held at either 0 VDC or approximately 5.0VDC and are tied to the I/O pins on the Basic Stamp Prototyping board. Figure 2 Figure 1 P0 – P15 I/O Pins for the Basic Stamp Due to the construction of the circuit the VRef voltage has a different relationship with the output. Specifically the Vfs voltage approaches to 2/3 of VRef , but it is always one VLSB less that 2/3 VRef . VRef equals the Logic 1” level that can be on the Basic Stamp I/O pins. The Logic “1” voltage is 5VDC and the Logic “0” voltage is 0VDC. 2 VRe f 3 VLSB 2n 1.a.) Use Figure 1 as an example. Calculate DAC Output for 1111 2 in, using super positioning. DAC Out = DAC Out 0001 + DAC Out0010 + DAC Out0100 + DAC Out1000 = ________________ 1.b.) Calculate DAC Output for 1000 2 in. ________________ 1.c.)Calculate DAC Output for 1001 2 in. ________________ Directions Figure 3 Resistive Ladder D/A Converter. = 5 VDC | | P1 P0 P1 P0 This resistive ladder network can be used as a D/A converter. The binary number input is sent in parallel as 8-bits across 8 separate data lines, P0 through P7. As long as the value of all eight bits are present at the same time, the output of the D/A converter output will be the intended discrete voltage value. Step 1. Build it per the circuit is in Figure 3. Vss and Vdd along with the P0 – P7 data outputs come from the Circuit board on the Lab robot. Most of the parts will be in the Basic AD kit. Use lab stock for any missing items. Programming for the Digital Signal Source. The digital input will come from the Stamp micro controller. It will provide the digital input signals for this Lab. Step 2. Getting the range of values for you specific configuration. Connect the P0-P7 pins of your circuit and load the following program into the microcontroller on the Lab robot. If you are having problems with the programming start with the “Your First Program” on page 22 of the book from Parallax called “Robotics with the Boe Bot”. 'Basic Analog and Digital PL4_1R0.bs2 ' Simple DAC with conversion held for 4 seconds ' {$STAMP BS2} ' {$PBASIC 2.5} counter n VAR Word VAR Byte '--------------------------Initialize------------------------n=0 OUTPUT 7 OUTPUT 6 OUTPUT 5 OUTPUT 4 OUTPUT 3 OUTPUT 2 OUTPUT 1 OUTPUT 0 OUTL = n DO '----------------------Get Input----------------------------DEBUG "Enter decimal number between 1-255: " DEBUGIN DEC n ' ---------------Set ports as outputs----------------------- OUTPUT 7 OUTPUT 6 OUTPUT 5 OUTPUT 4 OUTPUT 3 OUTPUT 2 OUTPUT 1 OUTPUT 0 '----------Display for 4 seconds-----------------FOR counter = 1 TO 200 OUTL = n PAUSE 30 NEXT LOOP The values sent to the resistive ladder network, aka Digital to Analog Converter (DAC) will be referred to as the D value and be expressed in a decimal number. The above program will open a window on the computer screen, the bottom window shows the results sent to the window by the PBASIC command of Debug. The top window is where you enter the D values. 2.a. Set D=0 and send it to the DAC. ____________________V (aka,VD0). 2.b. If a a value of 255 was sent to the DAC what voltage would you expect at the output? ________ Set D=255 and send to the DAC. _____________________V(aka,V D255). How the measured amount compare with your calculated value – Percentage error? What would account for the difference? 2.c. If a a value of 128 was sent to the DAC what voltage would you expect at the output? ________ Set D=128 and send it to the DAC _____________________V (aka,V D128). How the measured amount compare with your calculated value – Percentage error? What would account for the difference? This will be your reference voltage for the center of the output waveform V180 Degrees and also equals the magnitude of the signal amplitude (A). 2. d. Calculate the value of VOut Resolution, aka VLSB using the following: VO RES = (V Out D=255 – VOut D=0)/(2n-1) = (V D255 – VD0)/(2n-1) Step 3. Calculate the Y component values and then the value of D required as an input to the DAC to generate an output approximately equal to Y. Use the formula below to calculate the Y component and use Y/VO RES to calculate the D values for the table. The program for the Boe Bot will use the decimal value. Y = A [SIN(X) + 1], where X equals an angle listed in the table below and A the absolute value measured for a D value of 128, VD128. Angle (x) Degrees Ycomp D YMeasured 0 22.5 45 67.5 90 112.5 135 157.5 180 202.5 225 247.5 270 292.5 315 337.5 360 (same as 0) Don’t use this as a value in the next program!!! Percent Error Step 3. Use the above program and the derived values for D to generate and measure the output voltages. Record the measured D values for the specified analog input. Determine the error percentage for the measured verse he calculated D values. Step 4. After confirming the values for D, Modify the first program to reflect the following code. The vales for D will replace the listed DATA values. Run the program and measure the output voltage with an O-scope (Note: ensure that the scopes ground pin is isolated from building ground). 'Basic Analog and Digital PL4_1R0-8step-Plus.bs2 ' Simple DAC 8-bit DAC Data input. ' {$STAMP BS2} ' {$PBASIC 2.5} OutsideCounter VAR Word n VAR Byte address VAR NIB '--------------------------Initialize------------------------DATA 0,16,32,48,64,80,96,112,128,144,160,176,192,208,224,240 '--------------------------Run-------------------------------data OUTPUT 7 OUTPUT 6 OUTPUT 5 OUTPUT 4 OUTPUT 3 OUTPUT 2 OUTPUT 1 OUTPUT 0 DO READ address, n address = address + 1 OUTL = n LOOP ‘ Even faster replace the “+ 1” with “+ 2” Step 5. Draw the output waveform. V AV 0V time Vp = __________ T = __________ F = __________ NOTE: Most of the graphics are from the Parallax Text on Basic Analog and Digital text and from their Robotics with the Boe-Bot text. Significant parts of the text of the Lab are also from those books and Warren Hioki’s Lab Manual for telecommunications. Questions: 1. What is the factor that limits the output frequency? 2. What common commercial products change digital information into audio frequency sine waves? 3. What type of IC is a DAC0830. a.) What is it’s resolution? b.) What is it’s power supply voltage requirements?