User Tasks

Modbus Motion Interface

Write_Word(SystemPage_+_UserTask1_w,<Control Value>);
Write_Word(SystemPage_+_UserTask2_w,<Control Value>);
Write_Word(SystemPage_+_UserTask3_w,<Control Value>);
Write_Word(SystemPage_+_UserTask4_w,<Control Value>);
Write_Word(SystemPage_+_UserTask5_w,<Control Value>);
Write_Word(SystemPage_+_UserTask6_w,<Control Value>);
Write_Word(SystemPage_+_UserTask7_w,<Control Value>);
Write_Word(SystemPage_+_UserTask8_w,<Control Value>);
Write_Word(SystemPage_+_UserTask9_w,<Control Value>);
Write_Word(SystemPage_+_UserTask10_w,<Control Value>);
Write_Word(SystemPage_+_UserTask11_w,<Control Value>);
Write_Word(SystemPage_+_UserTask12_w,<Control Value>);
Write_Word(SystemPage_+_UserTask13_w,<Control Value>);
Write_Word(SystemPage_+_UserTask14_w,<Control Value>);
Write_Word(SystemPage_+_UserTask15_w,<Control Value>);
Write_Word(SystemPage_+_UserTask16_w,<Control Value>);
Read_Word_Register(SystemPage_+_UserTask1_w); {Return non-zero if User Task 1 present}
Read_Word_Register(SystemPage_+_UserTask2_w); {Return non-zero if User Task 2 present}
Read_Word_Register(SystemPage_+_UserTask3_w); {Return non-zero if User Task 3 present}
Read_Word_Register(SystemPage_+_UserTask4_w); {Return non-zero if User Task 4 present}
Read_Word_Register(SystemPage_+_UserTask5_w); {Return non-zero if User Task 5 present}
Read_Word_Register(SystemPage_+_UserTask6_w); {Return non-zero if User Task 6 present}
Read_Word_Register(SystemPage_+_UserTask7_w); {Return non-zero if User Task 7 present}
Read_Word_Register(SystemPage_+_UserTask8_w); {Return non-zero if User Task 8 present}
Read_Word_Register(SystemPage_+_UserTask9_w); {Return non-zero if User Task 9 present}
Read_Word_Register(SystemPage_+_UserTask10_w); {Return non-zero if User Task 10 present}
Read_Word_Register(SystemPage_+_UserTask11_w); {Return non-zero if User Task 11 present}
Read_Word_Register(SystemPage_+_UserTask12_w); {Return non-zero if User Task 12 present}
Read_Word_Register(SystemPage_+_UserTask13_w); {Return non-zero if User Task 13 present}
Read_Word_Register(SystemPage_+_UserTask14_w); {Return non-zero if User Task 14 present}
Read_Word_Register(SystemPage_+_UserTask15_w); {Return non-zero if User Task 15 present}
Read_Word_Register(SystemPage_+_UserTask16_w); {Return non-zero if User Task 16 present}

Description

User Tasks permit delegating to the controller real-time activities. On-board commands run at approximately 1 microsecond per command and are able to perform at a much higher level than a external directing device such as a PC or PLC. Activities such as homing, wafer mapping, high speed measurement, non-trapezoidal profiles, filtering, camming, and other types of IO and motion coordination can be accomplished with programs written in SnapTrack, resident on the controller, and managed by the User Task registers.

There can be 16 user tasks defined in the controller. A general procedure becomes a user task when it uses the predefined names UserTaskN where N can be from 1 to 16. Reading from the user task register indicates if that particular task is presently running. A non-zero value indicates the task is active. A 0 value indicates it has completed. Writes to the User Task register use the following values to perform task operations.

Begin Task - Writing a 1 to the User Task register begins the indicated user task. It is scheduled to begin execution on the next controller sample period and the modbus command interpreter immediately returns. The task will run until completion unless it is aborted early. The task can continue indefinitely based on how it has been written.

Execute Task - Writing a 2 to the User Task register executes the indicated user task. This is a blocking command. The modbus command interpreter will suspend until the task completes. There is no opportunity to control the task since the modbus communication channel is blocked. This is intended to perform programs that can do their entire jobs in a single controller sample period. When the modbus communication resumes it is assured that the task has finished. It is likely this method of use would only be advised by technical support to solve a very specific and time critical task.

Abort Task - Writing a 0 to the User Task register aborts the indicated user task. Note that aborting the task does not necessarily stop any motion the task had initiated. The motion system is independent of the task system. To fully stop an axis that is controller by a resident task first abort the task and then explicitly stop the motion when the task can no longer restart it. It is often better to have graceful task termination of a task by using a User Boolean to request it stop and then waiting for the task to finish after it has cleanly shutdown whatever it was controlling.

Escapes

If there are 16 tasks running and a request is made to start an additional task an Unable To Begin Task Escape Code will result. Note that other software components, such as the Modbus Interpreter itself, may be deducting from the total available 16 task budget.

Examples

Begin the task named UserTask1 in a controller resident program

Write_Word(System_+_UserTask1_w,1);

Qeury if the task is still running

if Read_Word(System_+_UserTask1_w) <> 0 then
 Show_Message('Task still present');

Abort the task early}

Write_Word(System_+_UserTask1_w,0);

Related Topics

Unable To Begin Task Escape Code