Motion Control... and More.
RMCTools Online Help
Tasks

Tasks

Tasks

Tasks are for running User Programs. Each task is an execution engine that can run one User Program at a time.

The RMC70 has up to four tasks. Therefore, the RMC70 can run up to four User Programs simultaneously. The RMC150 has up to ten tasks. Therefore, the RMC150 can run up to ten User Programs simultaneously. Use the Task Monitor to monitor what each task is doing. To change the number of tasks, see the Changing the Number of Tasks below.

To start running a User Program on a task, use the Start Task (90) command.

Example

You have created a User Program called MyProgram. You want to run MyProgram. To do this, you need to run it on a task. Use the Start Task (90) command to start running MyProgram on any task, for example task 0.

Example

You have created two User Programs called MyProgram1 and MyProgram2. You want to run MyProgram1 and MyProgram2 simultaneously. To do this:

  1. Use the Start Task (90) command to start running MyProgram1 on any task, for example task 0.

  2. Since task 0 is already running, you must start MyProgram2 on another task, for example on task 1. If you were to start MyProgram2 on task 0, then task 0 would immediately stop running MyProgram1, and then start running MyProgram2. Then they would not be running simultaneously.

 

Note:
In order to run tasks or the Program Triggers, the RMC must be in RUN mode. See the RUN/PROGRAM Mode topic for details.

Starting Tasks

Tasks can be started in several ways:

  • Start Task (90) command
    Send a command to specify which user program to run on a certain task.

  • Program Trigger
    Automatically start a task based on a user-defined condition. See the Program Triggers topic for details.

  • Task Monitor in RMCTools
    In the Task Monitor, right-click a task and click Start Task.

  • Project Pane
    In the Project pane, in the User Programs node, right-click a user program, choose Run Program, and click the task to run the program on.

 

Note:
If a user program is started on a task that is already running, the task will stop the user program it is already running and immediately start at the User Program you specify.

Stopping Tasks

Tasks can stop in several ways:

  • End Link Type
    If a User Program is done running, the task it is running on will also stop. A User Program is done running when it encounters an End link type.

  • Stop Task (91) command
    The Stop Task (91) command immediately stops the specified task. The User Program currently running on the task will immediately stop.

  • Program Triggers
    A trigger in the Program Triggers can stop a task. See the Program Triggers topic for details.

  • Axis Halt
    If a halt occurs on any axis, the RMC immediately stops all tasks by default. This default setting can be changed on the Programming Properties dialog.

  • Program Mode
    When the RMC enters Program mode, all task will stop.

  • Task Fault
    A task will be halted if any of the following runtime errors occur:

    • Command overwritten within a Task step for Axis n.

    • Array Index out of range.

    • Internal Interpreter Error.

    • Task not allowed to run this program.

    • Unsupported address range in COPY function.

    • Divide by zero.

    • Undefined numerical operation.

  • Task Monitor
    In the Task Monitor, right-click a task and click Stop Task.

Task Monitor

Use the Task Monitor to see which tasks are currently running User Programs. The Task Monitor shows each task, its state, and which program and step it is currently on or the last step it was on. See the Task Monitor topic for details.

Changing the Number of Tasks

By default, the RMC has 2 tasks. The RMC70 can have up to four tasks and the RMC150 can have up to ten.

To increase the number of tasks:

  • In the Project pane, right-click Programming and click Properties.

  • On the General page, select a number in the Number of User Tasks box and click OK.

  • Apply the changes to the RMC by right-clicking Programming  and clicking Download Programs to Controller.

Assigning User Programs to Tasks

By default, a user program is allowed to run on only one task at a time. This setting is usually sufficient for most applications. You can change this to specify a certain task that the user program is allowed to run on, or allow the user program to run on any number of tasks simultaneously. Restricting the tasks that a program can run on will help detect program errors and help reduce the maximum programming execution time.

To change this setting, in the Project pane, right-click the user program, choose Properties, and choose the Tasks page.

Default Axis

Each task has a Default Axis associated with it. The Default Axis is used in a User Program when a command’s Commanded Axes field is set to “Default Axis” or when an expression in a user program contains an axis register, but does not specify the axis (for example, _Axis[].StatusBits.InPos).

When a task is started using a Start Task (90) command, the Default Axis for the task will be automatically set to the axis that received the Start Task command.

When a task is started from the Program Triggers, the Default Axis for the task is left unchanged. On power-up, the Default Axis for task #n is Axis n, up to the number of available axes. For any additional tasks, the Default Axis is Axis 0 on power-up. However, the Default Axis for a task can change through Start Task commands (see above) or the Current Axis register (see below).

The Default Axis for a task can be changed at any time by changing the Current Axis register for the task (see _CurAxis below). For example, to restore the Default Axis for a task to its power-on default axes on an 8-axis controller, you could use the following expression:

_CurAxis := SEL(_CurTask < 8, _CurTask, 0);

The Default Axis is typically used only in advanced applications and is not recommended for new users.

Why Bother?

Consider a multi-axis application where each axis runs the exact same sequence. Instead of creating one user program for each axis, you can create a single user program that issues commands to the Default Axis, and does not specify an axis in the link condition. Simply issue the Start Task commands to each axis. The user program can run independently on separate tasks simultaneously.

Using the Task Tags in Expressions

This section is for advanced users only.

The _Task[] tag has several members that can be used to manage tasks with expressions. The "_Task[]" tag can be used without any value in the brackets to reference the task that is running that user program.

_Task[].CurAxis

_Task[].CurProg

_Task[].CurStep

_Task[].Status

_Task[].CurProgStep

Using the Default Axis

In expressions in the user programs, the "_Axis[]" tag can be used without any value in the brackets to reference the default axis.

Changing the Default Axis

To change the default task, you can use the _Task[].CurAxis tag.  The tag _CurAxis is equivalent to _Task[].CurAxis, which references the current axis of the current task.

Example 1

"_Task[0].CurAxis := 2" will change the default axis of the task zero to Axis 2.

Example 2

"_Task[].CurAxis := 0" will change the default axis of the current task to Axis 2. The current task is whatever task is running the user program.

 

See Also

User Program Overview


Copyright (c) 2005-2012 by Delta Computer Systems, Inc.