Professional Documents
Culture Documents
Chapter5 Adc Mo Tim
Chapter5 Adc Mo Tim
ADC Interfacing
• Interfacing ADC In most of the cases, the PIO
8255 is used for interfacing the analog to
digital converters with microprocessor.
• The analog to digital converters is treaded as
an input device by the microprocessor
• The MPU sends an initializing signal to the
ADC to start the analog to digital data
conversation process.
• The start of conversation signal is a pulse of a
specific duration.
ADC Interfacing
• Interfacing ADC The process of analog to digital
conversion is a slow process, and the
microprocessor has to wait for the digital data till
the conversion is over.
• After the conversion is over, the ADC sends end of
conversion EOC signal to inform the
microprocessor that the conversion is over and
the result is ready at the output buffer of the
ADC.
• These tasks of issuing an SOC pulse to ADC,
reading EOC signal from the ADC and reading the
digital output of the ADC are carried out by the
CPU using 8255 I/O ports.
ADC Interfacing
• The time taken by the ADC from the active edge of SOC pulse
till the active edge of EOC signal is called as the conversion
delay of the ADC.
13 GND GND
Example:
Interfacing ADC 0808 with 8086 using 8255
ports. Use port A of 8255 for transferring
digital data output of ADC to the CPU and port
C for control signals. Assume that an analog
input is present at I/P2 of the ADC and a clock
input of suitable frequency is available for
ADC.
Interfacing of ADC 0808 to 8086 through 8255
Solution:-
3 GND GND
4 – 11 B1 – B8 Binary Input
1, 2 OUT1, OUT 2 Analog output
12, 13 NC No connection
16 RFB R Feedback (Feedback
resistor )(To be connected
with Op amp)
Pin Description of AD 7523 DAC
• The maximum analog output voltage will be any
where between -10V to +10V, when all the digital
inputs are at logic high state.
• An operational amplifier is used as a current to
voltage converter at the output of DAC to convert
the current output of DAC to a proportional output
voltage.
• Usually a Zener is connected between OUT1 and
OUT2 to save the DAC from negative transients.
• An external feedback resistor acts to control the
gain. One may not connect any external feedback
resistor, if no gain control is required.
Interfacing of AD 7523 with 8086
Problem:--
Interface DAC AD7523 with the 8086 running at 8MHz & write ALP
to generate a saw tooth waveform of period 1ms with Vmax 5v.
Solution:--
Code segment
Assume cs:code
Start: MOV AL, 80H
OUT CWR, AL
AGAIN: MOV AL, 00H
BACK: OUT Port A, AL
INC AL
CMP AL, 0F2H
JB BACK
JMP AGAIN
Code ends
End Start
Program Explanation
• In the above program, port A is initialized as the
output port for sending the digital data as input to
DAC. The ramp starts from the 0V (analog), hence
AL starts with 00H.
• To increment the ramp, the content of AL is
increased during each execution of loop till it
reaches F2H.
• After that the saw tooth wave again starts from
00H, i.e. 0V(analog) and the procedure is repeated.
• The ramp period given by this program is precisely
1.000625 ms.
ALP Program to generate Triangular waveform
• 2000: RPT1: MOV CX, 0FF;
MOV AL, 00;
UP: INC AL;
MOV DX, 0FFE0 ;
OUT DX, AL;
MOV DX, 0FFE2 ;
OUT DX, AL;
LOOP UP
MOV CX, 0FF;
MOV AX, CX;
ALP Program to generate Triangular waveform
• DOWN: DEC AL MOV DX, 0FFE0 ;
OUT DX, AL;
MOV DX, 0FFE2 ;
OUT DX, AL;
LOOP DOWN
• Flash Conversion
• Successive Approximation Conversion
• Delta-encoded ADC (up-down counter type).
3-bit Flash type ADC
Successive Approximation type ADC
Successive Approximation type ADC
DAC Conversion Techniques
Number to be PA7 PA6 PA5 PA4 PA3 PA2 PA1 PA0 Code
displayed dp a b c d e f g
1 1 1 0 0 1 1 1 1 CF
2 1 0 0 1 0 0 1 0 92
3 1 0 0 0 0 1 1 0 86
4 1 1 0 0 1 1 0 0 CC
5 1 0 1 0 0 1 0 0 A4
Anticlockwise 1 1 0 0 0
2 0 0 0 1
3 0 0 1 0
4 0 1 0 0
5 1 0 0 0
ALP:
Assume cs:Code
Code segment
Start: MOV AL, 80H
OUT CWR, AL
MOV AL, 88H; Bit pattern 10001000
MOV CX, 1000
Again1: OUT Port A, AL
CALL DELAY
ROL AL, 01
DEC CX
JNZ Again1
MOV AL, 88H
MOV CX, 1000
Again2: OUT Port A, AL
CALL DELAY
ROR AL, 01
DEC CX
JNZ Again2
MOV AH, 4CH
INT 21H
Code ends
End start
8254 - Programmable Interval Timer
Given
• Chip select is enabled when address line A7=1,
• Address lines A1 and A0 are connected to the
A1 and A0 pins of 8254,
• The 8254 chip is I/O mapped,
• The clock frequency is 2MHz (0.5μs clock
period)
Solution
Subroutine:
COUNTER PROC NEAR
CNT2 EQU 8002H
CNTR EQU 8003H
MOV AL, B0H
OUT CNTR, AL
MOV AL, 50H
OUT CNTR2, AL
MOV AL, C3H
OUT CNTR2, AL
READ: MOV AL, 80H
OUT CNTR, AL
IN AL, CNT2
MOV DL, AL
IN AL, CNT2
OR AL, DL
JNZ READ
RET
COUNTER ENDP
Solution (c) Clock frequency, fc = 2 MHz
Time period of each clock cycle: 𝑡𝑐 = (1/2𝑥106 )= 5𝑥10−7 sec
Every time subroutine is called then, 50000 × 5 × 10^(−7) = 25 𝑚𝑠= is counted.
To count 1 sec subroutine needed to be called, 1𝑠/ 25𝑚𝑠 = 40 𝑡𝑖𝑚𝑒𝑠 = 28𝐻 𝑡𝑖𝑚𝑒
Main Program:
Assuming segment registers are already initialized.
MOV BL, 00H
SECOND:
MOV CL, 28H
WAIT: CALL COUNTER
DEC CL
JNZ WAIT
MOV AL, BL
ADD AL, 01
DAA
OUT 25H, AL ; assuming 8 bit port 25H
MOV BL, AL
JMP SECOND
HLT
Ex2: Write instructions to generate a 1 KHz square wave
from Counter1. Assume the gate of counter1 is tied to +5V
through a 10K resistor. Explain the significance of connecting
the gate to +5V. (use figure of problem 1)
Ex3:Write a subroutine to generate an interrupt every 1sec.
Consider the figure of problem1.