Topic: DMD0192

Help File Version: 2.10.0.636

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  (T) ), then refer to the Help topic for each of those instructions for the specific actions that occur during their termination scan.

 

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:

Code Block Overview

 

Programs

RUN - Run Program

EXIT - EXIT This Program or Task

Tasks

ENTASK - Enable Task

Subroutines

CALL - Call Subroutine

RET - Return Back to Call

RETC - Conditional Return Back to Call

Interrupt Service Routines

Setup Interrupt Triggers

INTCONFIG - Interrupt Configuration Editor

INTDECONFIG - Deconfigure Interrupt

INTRESUME - Resume Interrupts

INTSUSPEND - Suspend Interrupt

 


Related Topics:

END - End Program or Task

 

ENDC - Conditional End of Code Block

 

HALT - Halt Program or Task

 

RESTART - Restart Program or Task

 

SUSPEND - Suspend Program or Task

 

YIELD - Yield Program or Task