ECU391

MICROPROCESSORS AND MICROCONTROLLERS LAB

Experiment Number: 1 Date: : 04/08/2010

ADC and DAC Interfacing
Aim:

1. 2. 3. 4.

Use ADC to measure a dc voltage at any pin of the ADC and get a digital output. Use DAC, to generate a triangular waveform of T=10 m sec Using DAC, generate a ramp waveform with T=10 m sec Using DAC, generate a staircase waveform with 6 steps and each step is 0.5 m sec

Submitted by Sarath A Y B080229EC S5 ECE, Batch: B

0FFH JNZ UP .calling a delay procedure to hold the value of al at .MODEL SMALL .the output port to get the required delay . jump to 'down' and continue the loop .the output port to get the required delay .EXIT END Delay Calculations: Required time period of wave=10 ms Half time period = 5ms Clock frequency of 8086 processor = 4.if al ≠FF.return from procedure to main program . jump to 'up' and continue the loop .if al ≠00h.of wave .incrementing value of al to get increasing portion .loop to get decreasing portion of the wave DOWN: OUT 0C8H.00H .stay in this location for cx times .of wave .77 MHz Duration of one clock cycle = 1/(4.STARTUP ORG 1000H START: MOV AL.end of procedure .0H JNZ DOWN JMP START DELAY PROC NEAR MOV CX.Program 1: Triangular waveform of T=5 m sec using DAC DAC used: 0800 Program: .AL CALL DELAY DEC AL CMP AL.procedure for creating required delay .moving lowest value of wave to al .code starts from 1000H .AL CALL DELAY INC AL CMP AL.loop to get increasing portion of the wave UP: OUT 0C8H.calling a delay procedure to hold the value of al at .compare al with 0 .sending value of al to output port .jump to 'start' and repeat the whole process .store the required value to cx .sending value of al to output port .end of program .CODE .04H HERE:LOOP HERE RET DELAY ENDP .77*10^6) .incrementing value of al to get decreasing portion .small model .compare al with FF(255) .

if al ≠FF.the output port to get the required delay .CODE .code starts from 1000H .0FFH JNZ RAMP JMP START DELAY PROC NEAR MOV CX. N=4 Waveform: Program 2 : Ramp waveform with T=10 m sec using DAC DAC Used: 0800 Program: .incrementing value of al to get increasing portion . jump to 'up' and continue the loop .AL CALL DELAY INC AL CMP AL.procedure for creating required delay .of wave .209 μ sec = 5 m sec Solving .209 μ sec Number of machine cycles for the instructions are: LOOP: 17 MOV: 4 CMP: 9 JNZ: 16 INC: 2 Total delay= (4+17.MODEL SMALL .calling a delay procedure to hold the value of al at .end of program .sending value of al to output port .compare al with FF(255) .209 u sec) = 10 m sec .00H .N +2+9+16).255 * 0.moving lowest value of wave to al .= 0.small model .return from procedure to main program .STARTUP ORG 1000H START: MOV AL.EXIT END Delay Calculation Required time period of wave = 10ms Total delay = (4+17N+2+9+16)*255*(0.store the required value to cx .loop to get increasing portion of the wave RAMP: OUT 0C8H.end of procedure .stay in this location for cx times .04H HERE:LOOP HERE RET DELAY ENDP .

return from procedure to main program . N= 138 =8A H Waveform: .252 JNZ L1 JMP START DELAY PROC NEAR MOV CX.calling a delay procedure to hold the value of al at .compare al with 252(after 6 times. 6*42 =252) .end of procedure .code starts from 1000H .store the required value to cx .00H OUT 0C8H.if al ≠255.increment al by 42 .EXIT END Delay Calculation Delay required for one step = 0.stay in this location for cx times . jump to 'L1' and continue the loop .procedure for creating required delay .AL CALL DELAY ADD AL.end of program .8AH HERE:LOOP HERE RET DELAY ENDP .5 m sec solving.STARTUP ORG 1000H START: L1: MOV AL.the output port to get the required delay .small model .5 m sec using DAC DAC used: 0800 Program: .209 u sec = 0. al becomes 252 .solving.5m sec Delay = (4+17N + 4+9+19)*0. N=9 Waveform: Program 3: Staircase waveform with 6 steps and each step is 0.moving lowest value of wave to al .sending value of al to output port .CODE .MODEL SMALL .42H CMP AL.

00 OUT ODOH. ADC Used: 0809 Program: .AX .00 MOV AL.select adc channel .checking for end of conversion .send al value to ALE .sending start of conversion signal .delay given to adc to get digital value L1: .00 MOV AL.01H JNZ L1 IN AL.01H CMP AL.0C0H MOV BX.code starts from 1000H .10H OUT 0C8H.continue checking for end of conversion .AL MOV AL.sending ale high to start .CODE .EXIT END .read analog data from channel 1 .small model .1200H MOV [BX].00 MOV AL.AL MOV AL.AL MOV AL.AL IN AL.STARTUP ORG 1000H MOV AL.make soc signal low .Program 4:Use ADC to measure a dc voltage at any pin of the ADC and get a digital output.MODEL SMALL .01 OUT ODOH.18H OUT 0C8H.0D8H AND AL.store the result in 1200H .