Abort Task

Modbus Motion Interface

Write_Word(<SystemPage>_+_UserTask<N>_w,AbortUserTask);

Description

This command causes a procedure in the controller to abort execution. Resident application procedures to be managed should be named UserTask1, UserTask2, etc. The task number is referenced by this command.

The constant "AbortUserTask" is provided to use as the write parameter for the Modbus word write.

A task can only be aborted with Abort Task if it had been started with Begin User Task. A Task Identity is the procedure number that was used with the Begin User Task command that started it.

After aborting a task it is often necessary to "clean up" the residual condition of resources the task had been managing. For example if a homing procedure was using the Jog command to home and was counting on the detection of a sensor to stop it, aborting the homing routine would leave the motor still jogging but with no reason to stop. If a task managing a blinking light is aborted the light might remain in an active condition. It is usually better to avoid using the Abort Task command and to instead have the task terminate itself, and clean up after itself, based on a user boolean variable.

Escapes

If the task number is specified that is less than 1 or greater than the MaxUserTasks constant inside the AsciiCommands package a Parameter Out Of Range Escape Code error will occur.

Examples

Write_Word(SYSTEM_+_UserTask1, AbortUserTask);
Write_Word(SYSTEM_+_UserTask2, AbortUserTask);
Write_Word(SYSTEM_+_UserTask3, AbortUserTask);

Related Topics

Yield
Abort Task
Task Present