Chapter 4. Ladder Diagram (LD) Programming
GFK-2950C
February 2018
187
4.9.9
Table Read
The Table Read (TBL_RD) function sequentially reads values in a table.
When the pointer reaches the end of the table, it wraps around to the
beginning of the table. (TBL_RD is like FIFO_RD with a wrap-around.)
Mnemonics:
TBL_RD_DINT
TBL_RD_DWORD
TBL_RD_INT
TBL_RD_UINT
TBL_RD_WORD
When TBL_RD receives power flow:
1.
TBL_RD increments the pointer by one.
2.
TBL_RD copies data indicated by the pointer to output parameter Q. Additional program logic
must then be used to capture the data from the output reference.
3.
Steps 1 and 2 are repeated each time the instruction is executed, until the end of the table is
reached (PTR=the length specified in Length). When the end of the table is reached, the pointer
wraps around to the beginning of the table.
When TBL_RD receives power flow, the pointer (PTR) increments by one. If this new pointer location
is the last item in the table, the output EM is set ON. The next time TBL_RD executes, PTR is
automatically set back to 1. After PTR is incremented, the content at the new pointer location is
copied to output Q.
TBL_RD always passes power to the right when it receives power.
Note:
The TBL_RD and TBL_WRT functions can operate on the same or different tables. By
specifying a different reference for the pointer, these functions can access the same data
table at different locations or at different rates.
Operands
Note:
For each mnemonic, use the corresponding data type for the TB and Q operands. For
example, TBL_RD_DINT requires TB and Q to be DINT variables.
Parameter
Description
Allowed Operands
Optional
Length
1
Length
32,767
Constants
No
TB (must be the same
type as Q)
The elements in the table
All except constants
No
PTR
Pointer. Index of the next
element.
All except data flow, S - SC, constants
No
EM
Energized when the last element
of the table is read
Power flow
No
Q (must be the same
type as TB)
The element read from the table All except constants, S. SA, SB, SC
allowed only for WORD, DWORD
No
Table Read Example
WIDGETS is a table with 20 integer elements. When the
enabling input %M00346 is ON, the pointer increments and
the contents of the next element of the table are copied
into ITEM_CT. %L00001 functions as the pointer into the
data table. %M01001 is used to signal when all items of
the data table have been accessed.
Summary of Contents for PACSystems RSTi-EP
Page 357: ......
Page 466: ...Chapter 9 Diagnostics GFK 2950C February 2018 451 ...