Aim:
This section will show how to interface a DAC (digital-to-analog converter) to the ARM Microcontroller (LPC2148). Then we demonstrate how to generate a sine wave on the scope using the DAC.
Description:
Digital-to-analog (DAC) converter
The digital-to-analog converter (DAC) is a device widely used to convert digital pulses to analog signals. In this section we discuss the basics of interfacing a DAC to the ARM Microcontroller (LPC2148).
Recall from your digital electronics book the two methods of creating a DAC: binary weighted and R/2R ladder. The vast majority of integrated circuit DACs, including the MC1408 (DAC0808) used in this section, use the R/2R method since it can achieve a much higher degree of precision. The first criterion for judging a DAC is its resolution, which is a function of the number of binary inputs. The common ones are 8, 10, and 12 bits. The number of data bit inputs decides the resolution of the DAC since the number of analog output levels is equal to 2″, where n is the number of data bit inputs. Therefore, an 8-input DAC
such as the DAC0808 provides 256 discrete voltage (or current) levels of output.Similarly, the 12-bit DAC provides 4096 discrete voltage levels. There are also16-bit DACs, but they are more expensive.
MC1408 DAC (or DAC0808)
In the MC1408 (DAC0808), the digital inputs are converted to current (Iout), and by connecting a resistor to the Ioutpin, we convert the result to voltage.The total current provided by the Iout pin is a function of the binary numbers at the DO – D7 inputs of the DAC0808 and the reference current (Iref), and is as follows:
where DO is the LSB, D7 is the MSB for the inputs, and Iref is the input current that must be applied to pin 14. The Iref current is generally set to 2.0 mA. Figure 13-18 shows the generation of current reference (setting Iref = 2 mA) by using the standard 5-V power supply and IK and 1.5K-ohm standard resistors. Some DACs also use the zener diode (LM336), which overcomes any fluctuation associated
Figure 13-18. ARM Microcontroller (LPC2148) Connection to DAC808
Example 13-3
with the power supply voltage. Now assuming that Iref = 2 mA, if all the inputs to the DAC are high, the maximum output current is 1.99 mA (verify this for yourself).
Converting lout to voltage in DAC0808
Ideally we connect the output pin Iout to a resistor, convert this current to
voltage, and monitor the output on the scope. In real life, however, this can cause inaccuracy since the input resistance of the load where it is connected will also affect the output voltage. For this reason, the Iref current output is isolated by connecting it to an op-amp such as the 741 with Rf = 5K ohms for the feedback resistor. Assuming that R = 5K ohms, by changing the binary input, the output voltage changes
Block Diagram
Schematic
Code
Main File:
// ******************************************************* // Project: Interfacing DAC with ARM Microcontroller (LPC2148) // Author: Hack Projects India // Module description: Operate DAC0808 // ******************************************************* #include<lpc214x.h> unsigned char sine[50] = {52,57,62,66,70,74,77,80,82,84,85,86,86,86,85,83,81,78,75,72,69,65,61,56,52,48,44,39,35,31,28,25,22,19,17,15,14,14,14,15,16,18,20,23,26,30,34,38,43,48}; void delay_ms(double ms) { unsigned int i,j; for(i=0;i<ms;i++) for(j=0;j<1000;j++); } int main() { int i; PINSEL0=0x00000000; PINSEL1=0x00000000; PINSEL2=0x00000000; IO0DIR=0xff; while(1) { for(i=0;i<50;i++) { IO0SET=sine[i]; // assign the sine wave values to PORTB for DAC0808 IC delay_ms(10); IO0CLR=sine[i]; } } }
Downloads:
The code was compiled in Keil uvision4 and simulation was made in Proteus v7.7.
To download code and proteus simulation click here.
Further Reading suggestions:
You may also like,
- Interfacing keypad with ARM(LPC2148)
- Interfacing with UART of ARM(LPC2148) controller
- Interfacing SPI communication with PIC
- ARM(LPC2148) Displaying Custom Characters on LCD
- RTC interfacing using I2C in ARM(LPC2148)
- Interfacing Graphical LCD with ARM(LPC2148)
- Interfacing ultrasonic sensor with ARM(LPC2148)
- Interfacing GPS Modu with ARM(LPC2148)
- Interfacing GSM Module with ARM(LPC2148)
- Interfacing PWM in ARM(LPC2148)
- Interfacing ADC with ARM(LPC2148)
- Scrolling string on LCD using ARM(LPC2148)
- Interfacing keypad with ARM(LPC2148)
- Interfacing with UART of ARM(LPC2148) controller
- Interfacing SPI communication with PIC
- ARM(LPC2148) Displaying Custom Characters on LCD
- RTC interfacing using I2C in ARM(LPC2148)
- Interfacing Graphical LCD with ARM(LPC2148)
- Interfacing ultrasonic sensor with ARM(LPC2148)
- Interfacing GPS Modu with ARM(LPC2148)
- Interfacing GSM Module with ARM(LPC2148)
- Interfacing PWM in ARM(LPC2148)
- Interfacing ADC with ARM(LPC2148)
- Scrolling string on LCD using ARM(LPC2148)
No comments:
Post a Comment