Beruflich Dokumente
Kultur Dokumente
COMPUTER SYSTEMS
2006
1.
Vref
D0 D1 D2 D3 D4 D5 D6 D7
D A C
Vo
Staircase
Digital Values
COMP1208-Notes05-DAC.doc RevPA1
Page 1-1
28/03/2007
COMP1208
COMPUTER SYSTEMS
2006
1.1
D0 D1 D2 D3
D A C
Vo
D 3 D2 D1 D 0 or Vo = Vref + + + 4 8 16 2
D Vo = Vref n 2
D = Vref 16
Vo 0.000 0.625 1.250 1.875 2.500 3.125 3.750 4.375 5.000 5.625 6.250 6.875 7.500 8.125 8.750 9.375
Note: The maximum output voltage of the DAC < Vref. As the number of bits increases the maximum output voltage -> Vref. Example 1 What is Vo of a 4-bit DAC if the input is 0x7 and Vref = 10V? Answer 1: 0x7 = 0111 = 7 decimal. So Vo=10(7/24 ) = 70/16 = 4.374V Exercise1 What is the maximum output voltage Vo of a 4-bit DAC if Vref = 5V?
COMP1208-Notes05-DAC.doc RevPA1
Page 2-2
28/03/2007
COMP1208
COMPUTER SYSTEMS
2006
1.2
D A C
Vo
or
D Vo = Vref n 2
D = Vref 256
Table below shows the output voltage for a reference voltage of 10V and various digital inputs.
A7 A6 A5 A4 A3 A2 A1 A0 Decimal
0 0 0 0 0 0 0 0 | V 1 1 1 1 0 0 0 0 0 0 0 0 | V 1 1 1 1 0 0 0 0 0 0 0 0 | V 1 1 1 1 0 0 0 0 0 0 0 0 | V 1 1 1 1 0 0 0 0 0 0 0 0 | V 1 1 1 1 0 0 0 0 1 1 1 1 | V 1 1 1 1 0 0 1 1 0 0 1 1 | V 0 0 1 1 0 1 0 1 0 1 0 1 | V 0 1 0 1 0 1 2 3 4 5 6 7 | V 252 253 254 255 9.843750 9.882813 9.921875 9.960938
Vo
0.000000 0.039063 0.078125 0.117188 0.156250 0.195313 0.234375 0.273438
Example 2 What is Vo if the input is 0x30 and Vref = 10V? Answer 1: 0x30 = 00110000b = 48 decimal So Vo=10(48/256) = 1.875V Exercise 2 What is Vo if the input is 0x73 and Vref = 10V?
COMP1208-Notes05-DAC.doc RevPA1
Page 3-3
28/03/2007
COMP1208
COMPUTER SYSTEMS
2006
2.
2.1
for(int count=0;count<=255;count++) { _outp(DATA_PORT,count); //output the data to the port delay(100); //add a delay to vary frequency if(count==255) count=0; } return 0; } // Rough delay function void delay(int time) { for (int i=0;i<time;i++) for (int j=time;j>0;j--); }
Viewing the output of the DAC (assume Vref=10V) produces the following sawtooth waveform.
Sawtooth Waveform from 8-bit DAC 11 10 9 8 7 6 5 Voltage (V) 4 3 2 1 0 0 0.005 0.01 Time (s) 0.015 0.02 0.025 255 Steps Vref=10V
Figure 2:
Sawtooth Waveform
A low pass filter can be used to smooth out the digital stairsteps
COMP1208-Notes05-DAC.doc RevPA1
Page 4-4
28/03/2007
COMP1208
COMPUTER SYSTEMS
2006
false
2.2
int main() { _outp(CONTROL_PORT,0x01); while( true ) { for(int count=0;count<=255;count++) { _outp(DATA_PORT,count); delay(100); } for(count=254;count>=0;count--) { _outp(DATA_PORT,count); delay(100); } } return 0; } // Rough delay function void delay(int time) { for (int i=0;i<time;i++) for (int j=time;j>0;j--); }
Page 5-5
28/03/2007
COMP1208
COMPUTER SYSTEMS
2006
2.3
COMP1208-Notes05-DAC.doc RevPA1
Page 6-6
28/03/2007