Interfacing of Digital to Analog Converter

Updated on 2017/08/10 10:38

Syllabus

  • Interfacing of 8051 Microcontroller with DAC (Digital to Analog Converter)

Introduction to DAC

I_{out}=I_{ref}\left [ \frac{D7}{2}+\frac{D6}{4}+\frac{D5}{8}+\frac{D4}{16}+\frac{D3}{32}+\frac{D2}{64}+\frac{D1}{128}+\frac{D0}{256} \right ]

where, Iref=Reference current=2mA
            D7 = MSB bit
            D0=LSB bit

How to convert Iout to voltage in DAC0808?
DAC gives output in the form of cureent, so outside of the DAC current(I) to voltage(V) converter is connected, which is then provided to oscilloscope.

Interfacing

Algorithm and Flowchart

Interfacing Diagram

8051_dac.jpg

1DAC interfacing with 8051 microcontroller

Assembly Language Programs

Program: Write an ALP to generate Square wave form on port P1 of 8051 microcontroller using DAC.

Square Wave Generation - DAC - Flowchart

Flowchart for Square Wave generation using DAC

Square Wave Generation using DAC
ORG 0000h
mov P1,#00H
repeat:Acall squarwave 
sjmp repeat
squarwave:mov P1,#FFH
Acall delay
mov P1,#00H
Acall delay
ret
delay:mov r0,#20
up2:mov r1,#250
up1:mov r2,#250
Here:djnz r2,Here
djnz r1,up1
djnz r0,up2
ret
END

Program: Write an ALP to generate Triangular wave form on port P1 of 8051 microcontroller using DAC.

Tringular Wave Generation - DAC - Flowchart

Flowchart for Tringular Wave Generation using DAC

ORG 0000h
mov P1,#00H
repeat:Acall triwave; generate triangular wave
sjmp repeat
triwave:mov A,#00H
INCR:mov P1,A
INC A
CJNE A,#0FFH,INCR                  
DECR:mov P1,A
DEC A
CJNE A,#00H,DECR
ret
END

Program: Write an ALP to generate Stair-case wave form (with 5-steps) on port P1 of 8051 microcontroller using DAC.
Solution:- As we need 5-Step staircase waveform.Hence Accumulator can have maximum value of 255 hence to get 5 steps initial value to be added is 51H

ORG 0000h
mov P1,#00H
repeat:Acall stair_case_wave; generate staircase wave
sjmp repeat
stair_case_wave:mov A,#00H
mov P1,A
Acall delay
Back:ADD A,#51H
mov P1,A
Acall delay
CJNE A,#0FFH,Back
SJMP stair_case_wave
delay:mov r0,#20
up2:mov r1,#250
up1: mov r2,#250
here:djnz r2,here
djnz r1,up1
djnz r0,up2
ret
END

References

  • Interfacing diagram by Jayesh Gopal, WikiNote Volunteer, SKNCOE,Pune
  • Created and developed by Prof. S.M.Wagh, SKNCOE, Pune
  • WikiNote Foundation
  1. ^ Image by Jayesh Gopal, SKNCOE, Pune
Tags:
Created by Sujit Wagh on 2017/08/03 16:36