Schedule Task

Tasks Block

Description

This command causes a procedure in the controller to periodically execute as an independent activity concurrent along with with other tasks and motion. When the task completes it will start again after the indicated period which is expressed in milliseconds. Note that any yields performed by the task are magnified by the period. Each yield is extended in duration to the period value in milliseconds. If a period of zero is provided the task will be scheduled to run at the controller sample rate restarting as soo as it finishes on the next sample. To avoid having every yield be the period in duration it is often more convenient to begin a task that has an explicit loop with a period delay inside the loop at a specific place. Procedures can be run as concurrent tasks if they have no parameters. Only procedure blocks can be included within the Begin Task block. Multiple procedures can be enclosed within Begin Task and all enclosed procedures will begin at the same discrete time moment, all starting on the same controller sample. There is no control over which task runs first on each subsequent sample. The task scheduler places tasks into the next available task slot which might be before, or after, any other task based on slot availability. Avoid any task dependence where sequence is important.

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

Related Topics

Yield
Abort User Task
User Task Present
Procedure Needed for Task