Begin User Task

Command

BUT <task number>

Description

This command causes a procedure in the controller to begin executing as an independent activity concurrent along with with other tasks and motion. Application procedures to be managed as concurrent tasks should be named UserTask1, UserTask2, etc. The task number is referenced by this command.

The MMC Family supports 16 concurrent tasks in addition to concurrent motion which does not consume task resources

Escapes

If all of the available task slots are filled an attempt to start another task will result in an Unable To Begin Task Escape Code. If the task number is specified that is less than 1 or greater than the MaxUserTasks constant inside the interpreter package a Parameter Out Of Range Escape Code error will occur. MaxUserTasks has a value of 16 but can be adjusted if more tasks need to be invoked from the host. Note that only 14 additional tasks can run at one time as two are used to sustain host communication.

Examples

In this example a resident program has been described with blocks that look like this:

The current is set and the motor turned on. The position of the motor is set to 0. Then a number of loops are performed based on a Ascii Commands User Longint value at index 1. The motor moves back and forth by a display specified as an Ascii Commands User Number value at index 1. This is a different array of values so even though the index is 1 in both cases these are two different values.

This series of commands provides the parameters needed by the resident routine and starts the routine:

The position of the motor is noted and seen to be changing. A check is made to see if User Task 1 is still operating and it is. Additional motion is seen until the motion stops at position 0. A check is made to see if User Task 1 is still running and it is seen that the task is no longer running.

Related Topics

Yield
Abort User Task
User Task Present