Module 5 : Experiments on Microcontrollers

Lecture 38 : Interfacing of A/D and D/A with AT89C51


To convert an analog signal to its digital equivalent and read the digital value from one port of AT89C51, write the same data on to other port to convert it back to analog value.


  1. Atmel 89C51 microcontroller
  2. 8051 simulator- Win8051
  3. Universal SP3 Programmer
  4. Win8051 Simulator and Software to load the code into Universal SP3 Programmer
  5. Computer System with Windows 98 or later operating system and RS-232 Cable
  6. +5V D.C Power Supply
  7. Analog to Digital converter (AD7574), Digital to Analog converter (DAC08)
  8. Resistors
  9. Capacitors
  10. 10 MHz crystal oscillator
  11. Signal Generator and CRO

An analog signal is converted to 8-bit digital value using the ADC chip AD7574. After the conversion is complete, AD7574 will set    pin to high. As   (connected to P3.1) pin goes high, chip select pin and read pin (connected to P3.0) are made low to get valid digital data on to the bus (PORT1).The digital equivalent data is read from Port 1 and written back to Port 2. Digital data from port 2 is connected to DAC08 to convert it back to analog signal. As soon as data is read from the Port 1, P3.0 is set to start next conversion. Since analog output of DAC08 is an inverted one, an inverting amplifier (TL081CP) is employed to invert it back and for the gain adjustment. The details of ICs used are given below.

  • 8-bit resolution Analog to digital converter
  • Employs successive approximation technique
  • Microprocessor compatible
  • Conversion time 15 sec
  • Analog input can vary in between 0 to |-Vref|
  • 8-bit Digital to Analog converter
  • 85 nsec settling time
  • Operational amplifier (in present context operating as an inverting amplifier)
  1. Write the assembly code in Win8051. Compile and simulate it.
  2. Once the code is error free, run it and check output with the Simulator
  3. After checking the code in the simulator, the code (file with .HEX extension) is loaded into Atmel 89C51 microcontroller using Universal SP3 Programmer.
  4. Now connections are made as shown in the circuit diagram.
  5. Switch on the supply and push Reset button.
  6. Observe the results.
  7. Switch off the supply.
Assembly Code:


Both analog signal input and analog output are of same shape with out any distortion with a sampling period of 15 sec.


An analog signal is converted to digital equivalent using AD7574. Using AT89C51 the resultant digital data is read from a port and written to other port to convert it back to analog form using DAC08.


Fig 38.1 Circuit diagram for A/D and D/A interfacing with AT89C51