User manual
Toolbox 32 User Manual 1.47d www.cse-semaphore.com/mykingfisher
Page
137
Example - Polling RTUs Using A Function Block
The amount of ladder logic required to poll a number of RTUs can be greatly reduced by using a function
block as shown below.
The function block allows the RTU address (%1) and the polling period in seconds (%2) to be specified. The
RTU is only polled if a successful exception report has not been received for the last period seconds. The
registers that are exception reported should be the same as the registers that are polled. The PollRoutine
function block will poll the same registers from each RTU as defined in the RX Data block (these may need
to be adjusted).
The following registers are used:
#NRrrr.63 The last value of the success counter for RTU rrr
#NRrrr.64 Quiet Timer. The amount of seconds since the last successful message to or from RTU rrr.
#R200 Temporary storage of the RTU address
│ │
├Call Function Block to Poll RTUs ┼ ┼ ┤
│ │
│DoEverySec Poll RTU1 │
│ #YTICK.SEC PollRoutine │
├─────┤ ├────────────────────────────────────────────────────────┬──( CALL )───┤
│ │ │
│ │Poll RTU2 │
│ │PollRoutine │
├ ┼ ┼ ┼ ┼ └──( CALL )───┤
│ │
│ FUNC BLOCK │
├ ========== ─ ┼ ┼ ┼ ┼ ┤
│PollRoutine │
│ StoreRTU No. │
│ #R200 │
├────────────────────────────────────────────────────────────────────(Copy)────┤
│ %1 │
│New Data? StoreSuccCtr │
│#NR[R200].63 #NR[R200].63 │
├─────[!]────────────────────────────────────────────────────────┬───(Copy)────┤
│YLSUCC[R200] │YLSUCC[R200] │
│ │QuietTimer=0 │
│ │#NR[R200].64 │
├ ┼ ┼ ┼ ┼ └───(Copy)────┤
│ 0 │
│DoEverySec QuietTimer │
│ #YTICK.SEC #NR[R200].64 │
├─────┤ ├─────────────────────────────────────────────────────────────(Inc)────┤
│ │
│QuietTimer>? P2 Waiting Poll RTU │
│#NR[R200].64 #YPST2.2 RTU %1 │
├─────[>]─────────────────────────────────────────────────┤/├────┬──(RX_DATA)──┤
│ %2 │ #R1 │
│ │ResetPollTim │
│ │#NR[R200].11 │
├ ┼ ┼ ┼ ┼ └───(Copy)────┤
│ 0 │
│ │
├───────────────────────────────────────────────────────────────────(RETURN)───┤
│ │
Figure: RTU polling function block