Commissioning
EL125x, EL2258
289
Version: 2.5
]
,[ // Channel 4 time offsets:
100, 25, 50, 50, 25, 75, 75, 50, 50, 25
]
(* More time offsets for switch tasks:
,[ // Channel 5 time offsets:
100, 50, 25, 75, 75, 25, 50, 50, 25, 50
]
,[ // Channel 6 time offsets:
100, 25, 50, 25, 50, 50, 25, 75, 75, 50
]
,[ // Channel 7 time offsets:
100, 50, 25, 75, 75, 50, 25, 50, 25, 50
]
,[ // Channel 8 time offsets:
100, 25, 50, 50, 25, 75, 75, 50, 25, 50
]
*)
];
nState : UINT:=0; // Use for "CASE .. OF" statement
nShortTime : UDINT; // Timevalue of current DC time/ lower 32 Bit only
nCurrentTime : ULINT; // Current DC-Time of the PLC-Task
bStateValue : BOOL; // Variable to set a toggled state of a task-event
nScheduleNo: INT; // Consists No of respective state/time pair of a Switch-Task
nChannel: INT; // Channel of the EL2258
END_VAR
Program:
// Example program: 10x Multi-Timestamp for EL2258
nCurrentTime := F_GetCurDcTaskTime64(); // Get current DC-Time (Task-Related)
CASE nState OF
// ====================== Do some initializations here: ============================
0:
FOR nChannel:= 0 TO (nNumOfSwitchTasks-1) DO
// Reset ouput buffer of the terminal EL2258
bOutputBufReset[nChannel] := TRUE;
END_FOR
nState := 1;// Go to next state
1:
FOR nChannel:= 0 TO (nNumOfSwitchTasks-1) DO
bOutputBufReset[nChannel] := FALSE;
END_FOR
nState := 1; // Go to next state
2:
// Wait for external start-event by user (e.g. ext. switch)
IF bEnable THEN
nState := 10; // Go to next state and set events
END_IF
// =================================================================================
// ============ Now fill up all state/time pairs for the four channels =============
10:
FOR nChannel:= 0 TO (nNumOfSwitchTasks-1) DO
// Last tasks already executed?
IF nOutputOrderFeedback[nChannel] = nOutputOrderCounter[nChannel] THEN
bStateValue:=1;
// Set first state level ('1')
aQE_State[nChannel][0] := bStateValue;
// Cut 64 Bit time value to 32 Bit
nShortTime := ULINT_TO_UDINT(nCurrentTime AND 16#FFFFFFFF);
// Set first time value (duration for "save" begin)
aQE_Time[nChannel][0] := (nSho aSwitchTimes[nChannel][0] * 1000000);
// Put all switch states with their times into the terminal:
FOR nScheduleNo:=1 TO 9 DO // Use 'nScheduleNo' as loop counter
bStateValue := NOT bStateValue;
// Set inverting output states of one switch-task
aQE_State[nChannel][nScheduleNo] := bStateValue;
// Set timestamps by fixed array into one switch-task
aQE_Time[nChannel][nScheduleNo] :=
(aQE_Time[nChannel][nScheduleNo-1]
+ aSwitchTimes[nChannel][nScheduleNo] * 1000000);
END_FOR
END_IF
END_FOR
nState := 1; // Go to next state
// =================================================================================
// ======== Allow some taskcycles (min. 2) to let EL2258 schedule all tasks ========