Download Print this page

Keithley ADC-16 User Manual page 90

Analog input board

Advertisement

CHAPTER
8:
REGISTER-LEVEL I/O MAPS
IPO
&
IP1=
Digital Inputs.
INTO-INT4
=
Interrupt Level Select. Reflects the Intempt Level as specified
in the
Control Register.
8.7 TYPICAL PROGRAMMING
SEQUENCE
A sample programming sequence for performing an A/D conversion on the ADC-16 is as follows:
1. Write to MUX/Gain Register (Base Address +2) to select desired channel and gain.
2. Poll the Status Register (read Base Address +3) to check that the D7 (BUSY) bit is zero.
3. Start A/D conversion by writing any data to Base Address +O.
4.
Poll the Status Register (read Base Address +3) until D7 (BUSY) bit is zero.
5. Set D6 in the Control Register (write Base Address +3) to 1 to read overrange.
6. Read the A/D high byte (read Base Address +O).
7. If Overrange Bit D7 is high, an input-overload condition exists.
8. Clear D6 in the Control Register (read Base Address +3) to 0 to read polarity.
9. Read the A/D high byte and sign (read Base Address
+O).
10. Read the A/D low byte (read Base Address +l).
11. Assemble high/low byte data into one signed data word (16-bit integer).
12.
Repeat cycle for another conversion, gain, channel, etc.
Since the A/D converter
performs
a conversion between Steps 3 and 4 of the above sequence, there is
always a delay of about 50 milliseconds between these two steps before BUSY goes low and the
conversion is completed. An example BASIC program that performs these steps is in the following
section.
8.8 BASIC EXAMPLE PROGRAM
10 'REG.BAS", a 'neat save trick: type EDIT 10, F4, CR
20FALSE=O:TRUE=NOT FALSE
30CHAN%=O
start on channel0; gain
=
1
40 DONE%=FALSE
50WHILE ((INP(&H313) AND &H80)
=
&H80
'check for not busy
60 WEND
70WHILE (NOT DONE%)
80 OUT hH312,
CHAN%
90 OUT hH310, 0
start conv
100
WHILE ((INP(&H313)
AND
&H80) = bH80)
110
WEND
120
OUT &H313, &H40
'set overrange ON
130
OVR%=INP (&H310)
read overrange bit
140
IF(OVR% AND &H80) = &H80 THEN PRINT "OVER RANGE on Channel
'I;
CHAN%
150
OUT &H313, 0 'reset overrange bit to polarity
160
LOW=INP (hH311)
170
HI
=
INP(CH310)
8 - 5

Advertisement

loading