DAC interfacing with 8051
Session Objectives
To explain the DAC interface using 8051 .
Session Outcomes
At the end of the session, students will be able to
Understand DAC interfacing using 8051.
DAC
• The Digital to Analog converter (DAC) is a device, that is widely used for
converting digital pulses to analog signals.
• There are two methods of converting digital signals to analog signals.
• These two methods are binary weighted method and R/2R ladder method.
• Use the MC1408 (DAC0808) Digital to Analog Converter.
• This chip uses R/2R ladder method.
• This method can achieve a much higher degree of precision.
DAC
• DACs are judged by its resolution.
• The resolution is a function of the number of binary inputs.
• The most common input counts are 8, 10, 12 etc.
• Number of data inputs decides the resolution of DAC.
• So if there are n digital input pin, there are 2n analog levels.
• So 8 input DAC has 256 discrete voltage levels.
DAC 0808
DAC
Parameters IC DAC0808
DAC channels One
Architecture DAC Multiplying
Interface Parallel
Minimum o/p range 0 mA/V
Maximum o/p range 4.2 mA/V
Type of output Unbuffered Current
Type of Reference Ext
Settling time 0.15 µs
Operating temperature range (C) 0 to 70
Rating Catalog
Resolution 8 Bits
DAC
• The Iref is the input current. This must be provided into the pin 14. Generally
2.0mA is used as Iref
• connect the Iout pin to the resistor to convert the current to voltage.
• But in real life it may cause inaccuracy since the input resistance of the load will
also affect the output voltage.
• So practically Iref current input is isolated by connecting it to an Op-Amp with
Rf = 5KΩ as feedback resistor. The feedback resistor value can be changed as per
requirement.
DAC
Sine wave generation
• For generating sinewave, at first we need a look-up table to represent the
magnitude of the sine value of angles between 0° to 360°.
• The sine function varies from -1 to +1. In the table only integer values are
applicable for DAC input.
• In this example we will consider 30° increments and calculate the values from
degree to DAC input.
• We are assuming full-scale voltage of 10V for DAC output. We can follow this
formula to get the voltage ranges.
• Vout = 5V + (5 × sinθ)
Sine wave generation
• Vout = 5V + (5 × sinθ)
Angle(in θ ) sinθ Vout (Voltage Magnitude) Values sent to
DAC
0 0 5 128
30 0.5 7.5 192
60 0.866 9.33 238
90 1.0 10 255
120 0.866 9.33 238
150 0.5 7.5 192
180 0 5 128
Sine wave generation
• Vout = 5V + (5 ×sinθ)
Angle(in θ ) sinθ Vout (Voltage Magnitude) Values sent to
DAC
210 -0.5 2.5 64
240 -0.866 0.669 17
270 -1.0 0 0
300 -0.866 0.669 17
330 -0.5 2.5 64
360 0 5 128
Sine wave generation
Sine wave generation
#include<reg51.h>
sfr DAC = 0x80; //Port P0 address
void main(){
int sin_value[12] = {128,192,238,255,238,192,128,64,17,0,17,64};
int i;
while(1){
//infinite loop for LED blinking
for(i = 0; i<12; i++)
{
DAC = sin_value[i];
}
}
}
Simple wave generation
ORG 00H
CLR A
CHECK: JB P1.0, SAW
CLR A
TRIANG: MOV P2, A
INC A
CJNE A, #0FFH,TRIANG
DECR: MOV P2,A
DEC A
CJNE A,#00H,DECR
SJMP CHECK
SAW: CLR A
SAWT: MOV P2, A
INC A
CJNE A, #0FFH, SAWT
CLR A
MOV P2, A
SJMP CHECK
END
Summary
• .
Interfacing DAC with 8051 is studied
References
• Muhammad Ali Mazidi, Janice Gillispie Mazidi and Rolin McKinlay,
“The 8051 microcontroller and Embedded Systems: Using Assembly
and C”, Pearson education, Second Edition, 2013.
Thank you