DM5210 analog input module 4-10 RTD Embedded Technologies, Inc.
A/D Conversions
The following paragraphs walk you through the programming steps for performing A/D conversions. Detailed
information about the conversion modes is presented in this section. You can follow these steps on the flow diagrams
at the end of this chapter and in our example programs included with the module. In this discussion, BA refers to the
base address.
• Initializing the 8255 PPI
Four of the eight 8255 Port B lines are used to control the channel selection for taking a reading. Port B is
programmed at I/O address location BA + 1:
D7
D6
D5
D4
D3
D2
D1
D0
x x x x CH3 CH2 CH1 CH0
BA + 1
Port B
Analog Input
Channel Select
0000 = channel 1
0001 = channel 2
0010 = channel 3
0011 = channel 4
0100 = channel 5
0101 = channel 6
0110 = channel 7
0111 = channel 8
1000 = channel 9
1001 = channel 10
1010 = channel 11
1011 = channel 12
1100 = channel 13
1101 = channel 14
1110 = channel 15
1111 = channel 16
D7
D6
D5
D4
D3
D2
D1
D0
1
X
X
X
X
0
0
X
The top four bits of Port B are brought out to on-board pads where they are available for your use. Keep in mind
that when you are programming some of the bits in this port, you may need to preserve the state of other bits.
• Selecting a Channel
To select a conversion channel, you must assign values to bits 0 through 3 in the PPI Port B port at BA + 1. The
bit structure diagram above shows you the four-bit instruction for each of the 16 channels.
• Enabling and Disabling Interrupts
Any time you use interrupts, this bit, bit 1 at port BA + 11, must be set high to enable the IRQ circuitry.
• Starting an A/D Conversion
A/D conversions are started by writing to the appropriate I/O port. For 12-bit conversions, Port BA + 8 is used.
For 8-bit conversions, Port BA + 9 is used. A START CONVERT command must be issued for each A/D conver-
sion. The data written to start a conversion is irrelevant. Figure 4-1 shows the timing diagram for A/D conversions.
• Channel Scanning
If you want to sample a sequence of channels, you can set up the 210/5210 for channel scanning. The main
concern when you scan channels is that you allow enough settling time between the selection of the channel and the
start of the A/D conversion. The channel scanning flow diagram at the end of this chapter explains how to properly
program for channel scanning and avoid settling time problems.
To use Port B for these control functions, the 8255 must be initialized so that Port B is set up as a Mode 0 output
port. This is done by writing this data to the PPI control word at I/O address BA + 3 (X = don’t care):
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com