Topic: DMD0192 Termination Behavior |
|
Termination behavior describes the actions that program elements perform when they stop executing. Termination behavior is implemented through the use of termination logic, which consists of additional processing that the program element does on the termination scan. The termination scan is the PLC scan which immediately follows the scan where the program element was last executed.
The purpose of termination behavior is to make sure that program elements are shut down cleanly so that subsequent executions of the program element will always start from a known, initialized state. Doing this provides predictable results each time the program element is executed. The termination logic is executed whether the program element completes normally or if its execution is stopped by an external action.
Termination logic for all of the Programs and Tasks is run each time there is a RUN mode -to- PROGRAM mode change.
Any time a Halt Program or Task (HALT), Restart Program or Task (RESTART), or EXIT This Program (EXIT) is executed, the termination logic for that specific Program or Task is executed.
When Enable Task (ENTASK) runs a Task one time: the termination logic is executed when the Task completes. When Enable Task (ENTASK) runs a Task recurrently, the termination logic is executed when the ENTASK itself is disabled.
|
|
Code-blocks with Termination Logic:During their termination scan, Programs and Tasks will run the termination logic for each individual instruction that is contained within the code-block, then will run their own termination logic. All of the Output Coil (OUT) instructions, and any output coil in any instruction that has one as a parameter (for example TIMEPROP) are turned OFF. All of the Timers and Counters are reset. If the Program contains Stage (SG) instructions, all of the Stages in that Program will be disabled. The code-block's associated structure will be initialized (clearing internal flags, counters, etc.) in preparation for being restarted.
When a Stage (SG) ends (either by a JMP or SGRST operation), all of the Output Coil (OUT) instructions in the Stage are turned OFF; all of the Timers and Counters in the Stage are reset.
Subroutines and Interrupt Service Routines DO NOT have termination logic. This means that Output Coils that are turned ON inside the Subroutine in Interrupt Service Routine will remain ON after the Subroutine or ISR ends.
|
|
Instructions with Termination Logic:Some of the Do-more instructions have termination logic that will execute
during the termination scan of their containing Program, Task or Stage. Refer to the Instruction
Set Help topic to see which instructions contain termination logic
(indicated by
For instructions that have termination logic, this can range from turning off outputs, to clearing internal variables, to resetting flags, to logging error codes. A good example of a programming element that has termination logic is the Stage instruction. On the termination scan all of the Output Coil (OUT) instructions in the disabled Stage are turned OFF, and Timers and Counters in that Stage are reset.
|
|
See Also:
|
|
Related Topics:
ENDC - Conditional End of Code Block
RESTART - Restart Program or Task
SUSPEND - Suspend Program or Task
|
|