|
|
BACK
NEXT
2.5. Analog to Digital
Converter
The easiest way to do analog
to digital conversion is to use an IC such as the ADC0804 that does
the work for you. The analog voltage is applied to pin 6 and the result
is available at pins 11 through 18. We will connect pin 1 and 2 (Chip
Select and Read) to ground so that the chip is always enabled. (If you
wanted to use more than one ADC you could use this pin to control which
chip is currently enabled).
Connect pin 7 (Vin - ) to ground. The ADC0804 includes an internal oscillator
which requires an external capacitor and resistor to operate. Connect
the 150 pF capacitor from pin 4 (CLOCK IN) to ground and the 10k ohm
resistor from pin 4 to pin 19 (CLOCK R). ( Download
Complete Circuit File : ADC.pdf )
Figure 2.5.1 Typical connection
of free running mode
For example:
The input range of ADC is 0 - 5 volt
then we must setting Vref = 0.5 Vin maximum or = 2.5 volt
because this ADC0804 is 8 bit then V resolution = 5/255 = 0.02 volt this is mean that ADC will respon each 0,02V increasing
Vin
(volt)
|
D0 |
D1 |
D2 |
D3 |
D4 |
D5 |
D6 |
D7 |
Des |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0.02 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
1 |
1 |
0.04 |
0 |
0 |
0 |
0 |
0 |
0 |
1 |
0 |
2 |
0.06 |
0 |
0 |
0 |
0 |
0 |
0 |
1 |
1 |
3 |
0.08 |
0 |
0 |
0 |
0 |
0 |
1 |
0 |
0 |
4 |
0.10 |
0 |
0 |
0 |
0 |
0 |
1 |
0 |
1 |
5 |
0.12 |
0 |
0 |
0 |
0 |
0 |
1 |
1 |
0 |
6 |
: |
|
|
|
|
|
|
|
|
: |
5 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
255 |
Stage 1)
to operate this ADC, we use a free running mode, by connecting WR to
INT
Stage 2)
When the conversion process is complete, pin 5 (Interrupt) will go low
and this signal is used to convert ADC again.
Stage 3)
Next we read the values into the 89s51 Port 0.
The assembly program will be:
Org 0h
start: mov A,P0 ; saving data ADC to Accumulator sjmp start end
BACK
NEXT
|
|
Lesson 1:
T
o o l
1.1. Programmer
1.2. Edsim
51
1.3. MIDE-51
1.4. ATMEL
ISP
Lesson 2:
Input Output
2.1.LED
2.2.Swicht
2.3.7
Segmen
2.4.LCD
Character
2.5.ADC
2.6.DAC
2.7.Motor
Stepper
2.8.Keypad
Lesson 3:
Timer Counter
3.1.Basic
3.2.Mode
0
3.3.Mode
1
3.4.Mode
2
3.5.Mode
3
Lesson 4:
Serial Comm.
4.1.Basic
4.2.LED
4.3.Rotate
LED
4.2 ADC
4.3.LCD
Lesson 5:
Interuption
5.1.Basic
5.2.Timer
5.2.External
|