-- **************************************************************
-- SEQUENCE SLMASTER (SERIAL LINK MASTER SEQUENCE)
-- **************************************************************
-- ©2000 G&L Engineering Ltd.
-- CUSTOMER.
-- PROJECT
-- HISTORY
-- CODED BY:
--
--
--
-- This sequence monitors the status of the Primary and
Redundant Serial Link.
-- Watch Dog Timer (WDT) T_WDT_P monitors the Primary
serial link and WDT
-- T_WDT_R monitors the Redundant serial link. If a serial
link is BAD the relevant
-- WDT times out and generates alarm FAIL_P or FAIL_R.
-- When the WDT times out HOLD_FLAG is pulsed to hold
all associated sequences.
-- As a redundant serial link the Primary link is always
selected as the preferred link.
-- If the Primary Link is not available, the Redundant
Link is selected.
-- Primary serial link GOOD is indicated by an ON status
of flag STATUS_P.
-- Redundant serial link GOOD is indicated by an ON status
of flag STATUS_R.
-- The selected link is indicated by an ON status of Flag
INSERVICE_P (primary)
-- or INSERVICE_R (redundant) link.
-- This information is used by other sequences to determine
which Serial Link arrays
-- should be used. The link uses either uses the primary
array information, arrays
-- with suffix P or redundant array information arrays
with suffix R.
-- This sequence forms part of the overall Serial Interface.
-- The HPM/CL sequences including this one are;
-- SLMASTER.CL - Controls the Primary and Redundant Serial
Links.
-- SLINPUT.CL - transfers Input information from the serial
link.
-- SLOUTPUT.CL - transfers Output information to the serial
link.
-- HPM/Logic used with this sequence is:
-- WDT logic
LOCAL WDT AT NN(10)
-- WDT SP NORMALLY 5 SEC
-- **************************************************************
Sequence SLMASTER (HPM; POINT SL_INPUT)
-- xxxxxxxx.NO
-- **************************************************************
-- The suffix P array points contain information from
the primary serial link.
-- The suffix R array points contain information from
the redundant serial link.
-- **************************************************************
EXTERNAL WDT_LOGIC
EXTERNAL AI_ARRAY1_P, AO_ARRAY1_P, DI_ARRAY1_P, DO_ARRAY1_P
EXTERNAL AI_ARRAY1_R, AO_ARRAY1_R, DI_ARRAY1_R, DO_ARRAY1_R
EXTERNAL M_INPUT_ARRAY
EXTERNAL STATUS_P -- PRIMARY LINK GOOD
EXTERNAL STATUS_R -- REDUNDANT LINK GOOD
EXTERNAL INSERVICE_P -- PRIMARY LINK SELECTED
EXTERNAL INSERVICE_R -- REDUNDANT LINK SELECTED
EXTERNAL HOLD_FLAG, HOLD_FLAG_REQ -- SEQUENCE COMMAND
HOLD
EXTERNAL T_WDT_P -- PRIMARY LINK WDT
EXTERNAL T_WDT_R -- REDUNDANT LINK WDT
EXTERNAL T_WDT_INPUT, T_WDT_OUTPUT -- SEQUENCE WDT
LOCAL WDT AT NN(10) -- WDT SP NORMALLY 5 SEC
PHASE INITIAL
-- -----------
-- **************************************************************
-- Phase INITIAL, executes when this sequence is initially
initiated. This phase
-- checks the status of each of the Primary and Redundant
serial links. If both serial
-- links are operational, the primary link is selected.
If the primary link is not
-- operational the redundant link is selected.
-- **************************************************************
STEP STARTUP
-- ------------
-- Set up Process Module CLBACK parameter.
CALL CLBACK
-- **************************************************************
-- Ensure all associated logic and calculations are active.
IF ASSOCIATED_LOGIC.PTEXECST=INACTIVE THEN
& SET ASSOCIATED_LOGIC.PTEXECST=ACTIVE
-- **************************************************************
-- Ensure Watch Dog Timer Logic is active
IF WDT_LOGIC.PTEXECST=INACTIVE THEN SET WDT_LOGIC.PTEXECST=ACTIVE
-- Set up Watch Dog Timer
SET T_WDT_P.COMMAND, T_WDT_R.COMMAND = STOP
SET T_WDT_INPUT.COMMAND, T_WDT_OUTPUT.COMMAND = STOP
SET T_WDT_INPUT.TIMEBASE, T_WDT_OUTPUT.TIMEBASE = SECONDS
SET T_WDT_P.TIMEBASE, T_WDT_R.TIMEBASE = SECONDS
IF WDT < 2 THEN SET WDT = 5 IF WDT > 8 THEN SET WDT =
5
SET T_WDT_P.SP, T_WDT_R.SP = WDT
SET T_WDT_P.COMMAND, T_WDT_R.COMMAND = RESTSTRT
SET T_WDT_INPUT.COMMAND, T_WDT_OUTPUT.COMMAND = RESTSTRT
-- **************************************************************
-- IN THIS SATEMENT INCLUDE ALL ARRAYS
-- MESSAGE MUST BE CONFIRMED BUT WILL RESEND UNTIL FAULT
IS CLEARED
-- **************************************************************
IF (AI_ARRAY1_P.NNUMERIC <> AI_ARRAY1_R.NNUMERIC) OR
& (AO_ARRAY1_P.NNUMERIC <> AO_ARRAY1_R.NNUMERIC) OR
& (DI_ARRAY1_P.NFLAG <> DI_ARRAY1_R.NFLAG) OR
& (DO_ARRAY1_P.NFLAG <> DO_ARRAY1_R.NFLAG) THEN
& SEND (WAIT): "PRIMARY AND REDUNDANT ARRAY SIZE MISSMATCH"
-- Check if serial links are serviceable
A10: SET INSERVICE_P.PVFL, INSERVICE_R.PVFL = OFF
-- **************************************************************
-- In this statement include all primary arrays
-- **************************************************************
IF AI_ARRAY1_P.BADPVFL OR AO_ARRAY1_P.BADPVFL OR
& DI_ARRAY1_P.BADPVFL OR DO_ARRAY1_P.BADPVFL THEN
& SET STATUS_P.PVFL = OFF ELSE
& SET STATUS_P.PVFL = ON
-- **************************************************************
-- In this statement include all redundant arrays
-- **************************************************************
IF AI_ARRAY1_R.BADPVFL OR AO_ARRAY1_R.BADPVFL OR
& DI_ARRAY1_R.BADPVFL OR DO_ARRAY1_R.BADPVFL THEN
& SET STATUS_R.PVFL = OFF ELSE
& SET STATUS_R.PVFL = ON
IF STATUS_P.PVFL = ON THEN GOTO PHASE PRI_LINK
IF STATUS_R.PVFL = ON THEN GOTO PHASE RED_LINK GOTO A10
PHASE PRI_LINK (HOLD LINKFAIL)
-- ------------------------------
-- **************************************************************
-- Phase PRI_LINK, keeps the Primary and Redundant WDT's
alive and monitors the
-- Redundant Link for a status change. If the Redundant
link becomes BAD the
-- Redundant WDT is not updated.
-- **************************************************************
STEP MONITOR
-- ------------
-- Primary Link is available
SET STATUS_P.PVFL = ON
-- Link in service
SET INSERVICE_P.PVFL = ON
-- Link not in service
SET INSERVICE_R.PVFL = OFF
-- Set up Primary Link Watch Dog Timer every programme
cycle
SET T_WDT_P.COMMAND = STOP
SET T_WDT_P.TIMEBASE = SECONDS
IF WDT < 2 THEN SET WDT = 5
IF WDT > 8 THEN SET WDT = 5
SET T_WDT_P.SP = WDT
-- WDT refresh
SET T_WDT_P.COMMAND = RESTSTRT
-- **************************************************************
-- Ensure all associated logic and calculations are active.
IF ASSOCIATED_LOGIC.PTEXECST=INACTIVE THEN
& SET ASSOCIATED_LOGIC.PTEXECST=ACTIVE
-- **************************************************************
-- Ensure Watch Dog Timer Logic is active
IF WDT_LOGIC.PTEXECST=INACTIVE THEN SET WDT_LOGIC.PTEXECST=ACTIVE
-- **************************************************************
-- In this satement include all arrays
-- Message must be confirmed but will resend until fault
is cleared
-- **************************************************************
IF (AI_ARRAY1_P.NNUMERIC <> AI_ARRAY1_R.NNUMERIC) OR
& (AO_ARRAY1_P.NNUMERIC <> AO_ARRAY1_R.NNUMERIC) OR
& (DI_ARRAY1_P.NFLAG <> DI_ARRAY1_R.NFLAG) OR
& (DO_ARRAY1_P.NFLAG <> DO_ARRAY1_R.NFLAG) THEN
& SEND (WAIT): "PRIMARY AND REDUNDANT ARRAY SIZE MISSMATCH"
-- Check redundant serial link is OK
-- **************************************************************
-- IN THIS SATEMENT INCLUDE ALL REDUNDANT ARRAYS
-- **************************************************************
IF AI_ARRAY1_R.BADPVFL OR AO_ARRAY1_R.BADPVFL OR
& DI_ARRAY1_R.BADPVFL OR DO_ARRAY1_R.BADPVFL THEN
& (SET STATUS_R.PVFL = OFF; GOTO STEP MONITOR)
ELSE
& SET STATUS_R.PVFL = ON
-- Set up Redundant Link Watch Dog Timer every programme
cycle
SET T_WDT_R.COMMAND = STOP
SET T_WDT_R.COMMAND = RESET
SET T_WDT_R.TIMEBASE = SECONDS
IF WDT < 2 THEN SET WDT = 5
IF WDT >8 THEN SET WDT = 5
SET T_WDT_R.SP = WDT
-- WDT refresh
SET T_WDT_R.COMMAND = RESTSTRT
GOTO STEP MONITOR
PHASE RED_LINK (HOLD LINKFAIL)
-- ------------------------------
-- **************************************************************
-- Phase RED_LINK, keeps the Primary and Redundant WDT's
alive and monitors the
-- Primary Link for a status change. If the Primary link
becomes BAD the Primary WDT
-- is not updated
-- **************************************************************
STEP MONITOR
-- ------------
-- Link available
SET STATUS_R.PVFL = ON
-- Link in service
SET INSERVICE_R.PVFL = ON
-- Link not in service
SET INSERVICE_P.PVFL = OFF
-- Set up Redundant Link Watch Dog Timer every programme
cycle
SET T_WDT_R.COMMAND = STOP
SET T_WDT_R.TIMEBASE = SECONDS
IF WDT < 2 THEN SET WDT = 5
IF WDT > 8 THEN SET WDT = 5
SET T_WDT_R.SP = WDT
-- WDT refresh
SET T_WDT_R.COMMAND = RESTSTRT
-- Ensure all associated logic and calculations are active.
IF ASSOCIATED_LOGIC.PTEXECST=INACTIVE THEN
& SET ASSOCIATED_LOGIC.PTEXECST=ACTIVE
-- Ensure WDT logic is active
IF WDT_LOGIC.PTEXECST=INACTIVE THEN SET WDT_LOGIC.PTEXECST=ACTIVE
-- **************************************************************
-- In this satement include all arrays
-- Message must be confirmed but will resend until fault
is cleared
-- **************************************************************
IF (AI_ARRAY1_P.NNUMERIC <> AI_ARRAY1_R.NNUMERIC) OR
& (AO_ARRAY1_P.NNUMERIC <> AO_ARRAY1_R.NNUMERIC) OR
& (DI_ARRAY1_P.NFLAG <> DI_ARRAY1_R.NFLAG) OR
& (DO_ARRAY1_P.NFLAG <> DO_ARRAY1_R.NFLAG) THEN
& SEND (WAIT): "PRIMARY AND REDUNDANT ARRAY SIZE MISSMATCH"
-- Check primary serial link is OK
-- **************************************************************
-- In this statement include all primary arrays
-- **************************************************************
IF AI_ARRAY1_P.BADPVFL OR AO_ARRAY1_P.BADPVFL OR
& DI_ARRAY1_P.BADPVFL OR DO_ARRAY1_P.BADPVFL THEN
& (SET STATUS_P.PVFL = OFF; GOTO STEP MONITOR) ELSE
& SET STATUS_P.PVFL = ON
-- Set up Primary Link Watch Dog Timer every programme
cycle.
SET T_WDT_P.COMMAND = STOP
SET T_WDT_P.COMMAND = RESET
SET T_WDT_P.TIMEBASE = SECONDS IF WDT < 2 THEN
SET WDT = 2 IF WDT >8 THEN SET WDT = 5
SET T_WDT_P.SP = WDT
-- WDT refresh
SET T_WDT_P.COMMAND = RESTSTRT
GOTO STEP MONITOR
END SLMASTER
-- **************************************************************
-- LINKFAIL is activated from phase PRI_LINK or phase
RED_LINK when the serial link
-- currently in service fails. The Hold Handler will select
the redundant link or wait
-- until either the primary or redundant link is available.
-- **************************************************************
-- **************************************************************
HOLD HANDLER LINKFAIL (WHEN ((AI_ARRAY1_P.BADPVFL = ON
OR
& AO_ARRAY1_P.BADPVFL = ON OR DI_ARRAY1_P.BADPVFL = ON
OR
& DO_ARRAY1_P.BADPVFL = ON) AND INSERVICE_P.PVFL = ON)
& OR
& ((AI_ARRAY1_R.BADPVFL = ON OR
& AO_ARRAY1_R.BADPVFL = ON OR DI_ARRAY1_R.BADPVFL = ON
OR
& DO_ARRAY1_R.BADPVFL = ON) AND INSERVICE_R.PVFL = ON)
& OR HOLD_FLAG.PVFL = ON)
-- **************************************************************
SET HOLD_FLAG_REQ.PVFL = ON
-- Req. To HOLD all sequences WAIT 1 SECS
-- Allow sequences to HOLD
SET INSERVICE_P.PVFL = OFF
-- Deselect link in service
SET INSERVICE_R.PVFL = OFF
-- Deselect link in service
-- Set up Process Module datapoints CALL CLBACK
-- Resume when all arrays are OK and all holds have been
removed
-- **************************************************************
-- In this statement include all primary arrays
-- **************************************************************
A10: IF AI_ARRAY1_P.BADPVFL OR AO_ARRAY1_P.BADPVFL OR
& DI_ARRAY1_P.BADPVFL OR DO_ARRAY1_P.BADPVFL THEN
& SET STATUS_P.PVFL = OFF ELSE
& SET STATUS_P.PVFL = ON
-- **************************************************************
-- In this statement include all redundant arrays
-- **************************************************************
IF AI_ARRAY1_R.BADPVFL OR AO_ARRAY1_R.BADPVFL OR
& DI_ARRAY1_R.BADPVFL OR DO_ARRAY1_R.BADPVFL THEN
& SET STATUS_R.PVFL = OFF ELSE
& SET STATUS_R.PVFL = ON
IF HOLD_FLAG.PVFL = ON THEN GOTO A10
IF STATUS_P.PVFL = OFF AND STATUS_R.PVFL = OFF THEN GOTO
A10
RESTART
-- -------
IF STATUS_P.PVFL = ON THEN RESUME PHASE PRI_LINK
IF STATUS_R.PVFL = ON THEN RESUME PHASE RED_LINK RESUME
PHASE INITIAL
END LINKFAIL
-- **************************************************************
SUBROUTINE CLBACK
-- Set up Process Modules for CLBACK
-- **************************************************************
-- In this statement include all output primary arrays
+ 1,
-- Remove arrays not used
-- **************************************************************
IF SLOUTPUT.CLBACK <> (DO_ARRAY1_P.NFLAG + 5) THEN
& SET SLOUTPUT.CLBACK = (DO_ARRAY1_P.NFLAG + 5)
-- CLBACK + 5 includes for updating link status and subroutine
return.
-- **************************************************************
-- In this statement include all input primary arrays
-- Remove arrays not used
-- **************************************************************
IF SLINPUT.CLBACK <> (DI_ARRAY1_P.NFLAG + AI_ARRAY1_P.NFLAG)
THEN
& SET SLINPUT.CLBACK = (DI_ARRAY1_P.NFLAG + AI_ARRAY1_P.NFLAG)
END CLBACK
-- End of File
Goto our examples page
to see implementation examples.
This code is entirely original,
developed by G&L Engineering.
© 2000 G&L Engineering Ltd.