
Hercules-EBX CPU User Manual V1.02
Page 80
12.2 Performing an A/D Conversion
This chapter describes the steps involved in performing an A/D conversion on a selected input
channel using direct programming (not with the driver software).
There are seven steps involved in performing an A/D conversion:
1. Select the input channel
2. Select the input range
3. Wait for analog input circuit to settle
4. Initiate an A/D conversion
5. Wait for the conversion to finish
6. Read the data from the board
7. Convert the numerical data to a meaningful value
12.2.1 SELECT THE INPUT CHANNEL
To select the input channel to read, write a low-channel/high-channel pair to the “A/D Low
Channel Register” (Page 0:Base+2) and “A/D High Channel Register” (Page 0:Base+3) pair (see
page 63 ). For the Hercules-EBX, only 5 bits are supported for each setting: “0”-“31” for the 32
potential input source channels. When you write any value to these registers, the current A/D
channel is set to the low channel.
For example:
To set the board to channel 4 only, write 0x04 to Base + 2 (low channel) and 0x04 to Base +
3 (high channel).
To set the board to read channels 0 through 15, write 0x00 to Base + 2 (low channel) and
0x0F to Base + 3 (high channel).
⇒
Note:
When you perform an A/D conversion, the current channel is automatically incremented
to the next channel in the selected range. Therefore, to perform A/D conversions on a group of
consecutively-numbered channels, you do not need to write the input channel prior to each
conversion. For example, to read from channels 0 - 2, write Hex 00 to base + 2 and Hex 02 to
base +3. The first conversion is on channel 0, the second will be on channel 1, and the third will
be on channel 2. Then the channel counter wraps around to the beginning again, so the fourth
conversion will be on channel 0 again and so on.
If you are sampling the same channel repeatedly, then you set both high and low to the same
value as in the first example above. Then on subsequent conversions you do not need to set the
channel again.
12.2.2 SELECT THE INPUT RANGE
Select the input range from among the available ranges shown on page 79. If the range is the
same as for the previous A/D conversion then it does not need to be set again. Write this value to
the A/D Input Range Control Register at Base + 4 (see page 64).
For example:
For a global (affects all channels)
±
5V range (gain of 2), write 0x01 to Base + 4.
12.2.3 WAIT FOR ANALOG INPUT CIRCUIT TO SETTLE
After writing to either the channel registers (Base + 2, Base +3) or the input range register (Base
+ 4), you must allow time for the analog input circuit to settle before starting an A/D conversion.
The board has a built-in 10
µ
S timer to assist with the wait period. Monitor the WAIT bit at Base +
4 bit 6. When it is 1 the circuit is actively settling on the input signal. When it is 0 the board is
ready to perform A/D conversions.
Содержание HERCULES-EBX HRC400-5A128
Страница 9: ...Hercules EBX CPU User Manual V1 02 Page 9 3 HERCULES BOARD DRAWING...
Страница 118: ...Hercules EBX CPU User Manual V1 02 Page 118 Figure 14 Hercules EBX Cable Kit...
Страница 121: ...Hercules EBX CPU User Manual V1 02 Page 121...
Страница 123: ...Hercules EBX CPU User Manual V1 02 Page 123...