Chapter
7
7-1
Understanding Discrete I/O
This chapter explains how to access the scanner I/O image tables to read
and modify discrete I/O. After reading this chapter, you should be able to:
examine any discrete inputs
set or clear any discrete outputs
examine any outputs that you set or cleared previously
input change of state detection
interrupt at end of scan list
You should be able to do all three of these directly, by subscripting into the
I/O image tables.
The output and input image tables are two unsigned integer arrays of 256
words each, named output_image_table and input_image_table
respectively. You can directly read either table using C language
assignment statements, and you can directly write to the output image table
in the same way.
ATTENTION: Make sure that you don’t write to the output
image table bytes that correspond to intelligent I/O (block
transfer) modules. If you do write to these bytes, you’ll be
unintentionally requesting a block transfer. For more details,
see chapter 5, “Issuing Block-Transfer Commands.”
Access by Word
The image tables are tables of words, where each 16-bit word corresponds
to the 16 terminals of a module group. Terminal 17 octal (15 decimal)
corresponds to bit 017 (15 decimal) of the word, and so on down to
terminal 0 and bit 0. (16 bits times 256 words gives 4096 output terminals
and 4096 input terminals. Though possible, it is very unlikely that any
given application would use all I/O points.)
To address a particular module group in either the output or the input
image table, the subscript is 4 times the link address plus the group. For
instance, if you wanted to return the 16-bit contents of link address 2,
group 1 from the input image table, you could code it this way:
value = input_image_table[4*2+1];
Chapter Preview
Direct Image Table Access