# of registers/bits is the number of consecutive registers, memory locations,
or bits that you wish to read. Most PLC interfaces only allow you to read one
at a time, and for many applications that is all you will need to read. If this is
the case, # of registers/bits will be 1. If you wish to read more than one
register or memory location at a time, this number will be the number of
consecutive registers or locations you wish to read. If you are reading the
status of more than one I/O bit, this number will be the number of
consecutive bits you wish to read.
variable/array is the variable name or array name where you wish to store
the data you are reading. This variable MUST be a short integer (%
variable). If the value of # of registers/bits (see above) is 1, this will be a
variable expression. If you are reading registers or memory locations that
are stored as words (cmd = 1, 4, 5, 6, 7, 8) and the # of registers/bits is
greater than one, this will be a short integer array (make sure you properly
dimension the array prior to using it). If you are reading the status of more
than one, but less than 16 I/O bits, you will be reading one word, and
therefore will need to use a single short integer. If you are reading more than
16 bits, you will need to use a short integer array. The dimension of the array
variable will be the next integer greater than the desired number of bits
divided by 16. For example, if you wish to read the status of bits 1-24 you will
need to dimension your array to at least two since 24/16 = 1.5 and two is the
next greater integer. Remember, any time you are reading more than one
word of data (more than one register or more than 16 bits) you must use a
dimensioned short integer array.
Examples:
10 DIM stat%(2)
20 CALL PLCREAD(1,1,0,2,stat%(1))
This command returns the ID of the PLC as stat%(1) and the current run
status as stat%(2) from the Modbus or GE Series 90 PLC with an id (address)
= 1.
10 DIM regdat%(10)
20 CALL PLCREAD(1,4,16,5,regdat%(4))
This command returns the contents of register 16 in regdat%(4), register 17
in regdat%(5), register 18 in regdat%(6), register 19 in regdat%(7), register 20
in regdat%(8), from any of the PLC’s currently implemented.
10 CALL PLCREAD(1,5,47,1,regdat1%)
This command reads the data in input register number 47 in the Modbus
PLC with id (address) = 1 and stores it in the variable regdat1%
10 CALL PLCREAD(1,7,3,1,analog1%)
This command reads the value of analog input number 3 in a GE Series 90 or
TI 505 PLC with address = 1 and stores it in the variable analog1%
T-60 Operator's Manual
64