Abort User Task

Command

AUT <task number>

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.

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

The following resident procedure named UserTask2 is described in blocks to blink a light:

The following list of commands begin and abort the blinking user task behavior:

The problem is that half the time the led remains on and half the time the led remains off after it stops blinking. A better solution would be to use a User Boolean to indicate that the task should stop and establish the desired off condition for the LED:

This list of commands starts the blinking and then turns it off cleanly:

Related Topics

Yield
Begin User Task
User Task Present