- Related Questions & Answers
- 8051 Microcontroller
- RAM Addressing of 8051 Microcontroller
- Data memory structure of 8051 Microcontroller
- Microcontroller Basics
- Interfacing ADC with 8085 Microprocessor
- Interfacing Stepper Motor with 8051Microcontroller
- Interfacing 8251 USART with 8085 Microprocessor
- Interfacing 8279 Keyboard with 8085 Microprocessor
- Interfacing 8279 Display with 8085 Microprocessor
- Interfacing 8253 (Timer IC) with 8085 Microprocessor
- Interfacing a simple keyboard with 8085 Microprocessor
- Interfacing a matrix keyboard with 8085 Microprocessor
- System Design Using Microcontroller
- why did apple really replace the headphone jack with dac technology
- Differences in Microcomputer, Microprocessor and Microcontroller

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

In this section we will see how DAC (Digital to Analog Converter) using Intel 8051 Microcontroller. We will also see the sinewave generation using 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. In this article we will 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. 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 2^{n} analog levels. So 8 input DAC has 256 discrete voltage levels.

In this chip the digital inputs are converted to current. The output current is known as *I*_{out} by connecting a resistor to the output to convert into voltage. The total current provided by the* I*_{out} pin is basically a function of the binary numbers at the input pins D_{0 }- D_{7 }(D_{0} is the LSB and D_{7} is the MSB) of DAC0808 and the reference current I_{ref}. The following formula is showing the function of *I*_{out}

$$I_{Out}=I_{ref}\lgroup\frac{D7}{2}+\frac{D6}{4}+\frac{D5}{8}+\frac{D4}{16}+\frac{D3}{32}+\frac{D2}{64}+\frac{D1}{128}+\frac{D0}{256}\rgroup$$

The I_{ref} is the input current. This must be provided into the pin 14. Generally 2.0mA is used as I_{ref}

We connect the I_{out} 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 I_{ref} current input is isolated by connecting it to an Op-Amp with R_{f} = 5KΩ as feedback resistor. The feedback resistor value can be changed as per requirement.

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.

V_{out}= 5V + (5 ×sinθ)

Let us see the lookup table according to the angle and other parameters for DAC.

Angle(in θ ) | sinθ | V_{out }(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 |

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 |

**Circuit Diagram −**

#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]; } } }

The output will look like this −

Advertisements