Wednesday, October 6, 2010

ADC-DAC Interfacing

ADC-DAC Interfacing


Analog signals are very common inputs to embedded systems .Most transducers and sensors such as temperature ,pressure ,velocity ,humidity are analog. Therefore we need to convert these analog signals in to digital so that 8051 can read it.

 

 ANALOG DIGITAL TO CONVERTER - ADC

Commonly used ADC device – ADC804
 

ABOUT IC

  PinOut
 
• CS – Chip Select , active low
 • RD – Read Digital data from ADC, H-L edge triggered
 • WR -- Start conversion, L-H pulse edge triggered
 • INTR -- end of conversion, Goes low to indicate conversion done
 • Data bits -- D0-D7

 • CLK IN & CLK R
–  CLK IN is an input pin connected to an external clock source when an external clock is used for timing. However, ADC804 has an internal clock  

   generator.
   To use the internal clock generator of the ADC804, the CLK IN and CLK R pins are connected to a capacitor and a resistor. In that case, the  

   clock frequency is determined by the equation.
 

   f = 1/1.1RC
   R=10K and C=150pF f=606Hz
   the conversion time is 110us. 

 

 Input Voltage range

Vref/2

(Volts)

Vin

(Volts)

Step size (mV)

Open (2.5)

0 to 5

5/256 = 19.53

2.56

0 to 5.12

5.12/256 =20

1.28

0 to 2.56

2.56/256 = 10

0.5

0 to 1

1/256=3.90

• Default 0-5V. Can be changed by setting different value for Vref/2 pin.
   Vin=Vin(+) – Vin (-)

• Range = 0 to 2x Vref/2.
    for Vin = 2x Vref/2. we get 256 as a digital output on D0-D7. (Refer Table)

•Step Size a Smallest change
– (2 x Vref/2)/ 256 for ADC804

for eg for  step size 10mv ,digital output on D0-D7 changes by one count for every 10mv change of  the input analog voltage.

 Data Out
 Dout = Vin / Step Size

for input vtg. of 2.56 volts (Vref=1.28 volts)  and stepsize of 10mv Dout =2560/10 =256  or FF that is full scale output.

Conversion Time
 
Greater than 110us for ADC804 

Resolution
 
8 bits for ADC804

 

INTERFACING ADC804 TO 8051


Signals to be interfaced (on the ADC804)
– D0-D7, RD, WR, INTR, CS
 Can do both Memory mapping and IO mapping
 

Memory Mapping (timing is critical)
– Connect D0-D7 of ADC804 to the data bus of the 8051 system
– Connect RD, WR of the ADC804 to the 8051 system (ensure polarity)
– Connect CS of ADC804 to an appropriate address decoder output
– Connect INTR of ADC804 to an external interrupt Pin on the 8051 (INT0 or INT1) 

IO Mapping (easiest - I prefer )
– Connect D0-D7, RD, WR, CS, INTR to some port bits on the 8051 (12 in all).

 

 

Algorithm
• Make CS=0 and send a low-to-high to pin WR to start the conversion.
• Keep monitoring INTR
– If INTR =0, the conversion is finished and we can go to the next step.
– If INTR=1, keep polling until it goes low.
• After INTR=0, we make CS=0 and send a high-to-low pulse to RD to get the data out of the ADC804 chip.

 

ASSEMBLY LANGUEGE       (A51)

 

 

 

 

 

 

 

 

ADC_IO:

mov P1, #0xff ; To configure as input

 

AGAIN

clr p3.7 ;Chip select

setb P3.6 ;RD=1

clr P3.5 ;WR=0

setb P3.5 ;WR=1- low to high transition

 

WAIT:

 jb P3.4, WAIT ;wait for INTR

clr p3.7 ;generate cs to ADC

clr P3.6 ;RD=0 -High to low transition

mov A, P1 ;read digital o/p

sjmp AGAIN

 

 

 

 

INTERFACING ADC804 TO 8051

 

ADC808/809 Chip with 8 analog channel. This means this kind of chip allows to monitor 8 different transducers.
• ADC804 has only ONE analog input: Vin(+).

• ALE: Latch in the address 
• Start : Start of conversion (same as WR in 804)

• OE: output enable (same as RD in 804)

• EOC: End of Conversion (same as INTR in 804)


 

Channel

C B A

IN0

000

IN1

001

IN2

010

IN3

011

IN4

100

IN5

101

IN6

110

IN7

111



 

 

 

 

 

 

 

 

 

 

 

 

 

Algorithm

Notice that the ADC808/809 that there is no self-clocking and the clock must be provided from an external source to the CLK pin. (you can use programmable clock oscillator to enable or disable clock by programmable bit. )
 

• Select an analog channel by provide bits to A, B, C.
• Enable clock

• Activate ALE with a low-to-high pulse.
• Activate SC with a high-to-low pulse (start conversion) The conversion is begun on the falling edge of the start conversion pulse. you can use circuit like

• Monitor EOC Pin .After conversion this pin goes high.
• Activate OE with a high-to-low pulse to read data out of the ADC chip.

 

No comments:

Post a Comment