Program Triggers

To access the Program Triggers: In the Project pane, expand Programming, and double-click Program Triggers.

 

The Program Triggers start user programs when user-specified events occur. For example, you can set up the Program Triggers to start a user program when an input turns on, or to start a user program when a variable becomes a certain value. This is a good way to start RMC user programs from a PLC or host controller.

For a real programming example of using the Program Triggers, see the Example: Jogging an Axis topic.

Triggers

The Program Triggers can contain the following number of Triggers:

 

Number of Triggers

RMC75S

64

RMC75P

64

RMC75E

64

RMC150E

64

RMC200

128

 

A trigger is one complete row in the table, consisting of a Condition and Task Actions. The RMC checks all the conditions every loop time. When a condition becomes true, the user program(s) specified by the user are started on the specified tasks. The user programs are started only on the rising edge of the entire condition becoming true (one-shot). The user program will be started on that task even if the task is already running a user program. The task will stop running the current user program an run the new one.

The Task Actions are performed only on the rising edge of the entire condition. Therefore, when the entire condition becomes true, the specified Task Actions will be performed. While the condition remains true, the trigger will not start or stop anything.

 

Important!
The Task Actions are performed only on the rising edge of the entirecondition. Therefore, when the entire condition becomes true, the specified Task Actions will be performed once. While the condition remains true, the trigger will not start or stop anything.

Conditions

The Program Triggers can handle simple or complex conditions. For example, a condition can check for certain inputs to be on and the Actual position to be greater than a certain value. Conditions are created using expressions and are therefore very flexible. For details on expressions, see the Expressions topic. To find out how to create a condition, see Creating a Trigger below.

Task Actions

Task Actions can start or stop Tasks. Tasks run User Programs. For each trigger, you can define which Tasks to start, stop, or do nothing to. The Program Triggers will allow a Task to be started only at a label in a User Program. To find out how to set up the Task Action, see Creating a Trigger below.

The Program Triggers has one column for each Task. To increase the number of tasks, use the General page of the Programming Properties dialog.

Example

This is an example of two triggers in the Program Triggers:

The first trigger will cause the user Program "Cycle" to be started on Task 0 when the variable StartProgram becomes 1, and the second trigger will cause the user Program "MoveHome" to be started on Task 0 when the variable StartProgram becomes 2. As illustrated here, writing to a variable that triggers a user program is an easy way for a PLC to start a user program in the RMC.
Notice that the user program will be started when the condition becomes true. It will not restart while the condition remains true.

Order of Execution

If there are multiple triggers (rows), they will be executed in order from top to bottom. Therefore, if two triggers become true in the same loop time, and they start different user programs on the same task, the user program specified by second of these two triggers will end up running on the task. This is because the RMC will always do the last thing it is instructed to do.

Typically, in well-structured programs, this type of conflict does not occur.

How to Create and Manage Triggers

Create a Trigger

  1. In the last row of the Program Triggers, click the Condition cell, then click the ellipsis button . The New Condition Wizard will open.

  2. Select the type of condition you want to create, and continue through the wizard to complete the condition.

Note:
If you want to create a complex condition, double-click the Condition cell. It will let you create a custom condition. See the Expressions topic for details on creating expressions.

 

  1. In each Task cell for the condition you just entered, click the cell and select one of the following options from the drop-down box:

  1. Note:
    The Program Triggers Editor has one column for each Task. To increase the number of tasks, use the General page of the Programming Properties dialog.

Move Triggers

To move rows up or down, select one or more rows, then use the Move Up and Move Down buttons. To delete rows, select one or more rows, then click the Delete Row button.
The order of the triggers can be important. If several conditions become true at the same time and multiple actions are triggered on the same Task, the last action for that Task will be the one that runs.

Download the Program Triggers

In the Project Pane, right-click Programming and click Download Programs.

After the Program Triggers are downloaded, the RMC must be put into RUN mode before the Task Actions will be performed whenever when the associated conditions becomes true.

Print the Program Triggers

To print the Program Triggers, on the Program Triggers Editor toolbar, click the Print button. Or, on the File menu, choose Print.

Special Case: When the RMC Enters RUN Mode

With older firmware, the Program Triggers will trigger when a condition was true when the RMC enters Run mode. Newer firmware has a selection for this behavior, and defaults to triggering only when a rising edge of the condition occurs, and therefore, will not trigger simply because a condition happens to be true when the RMC enters Run mode. RMC75/150 firmware versions 3.64.0 and and later and RMC200 firmware 1.01.0 and later support the selection.

The Program Trigger behavior can be selected in the Programming Properties dialog. The following two options are available:

Legacy Behavior

With older firmware, when the RMC transitions from PROGRAM mode to RUN mode, it assumes all the Program Trigger conditions were previously false. Therefore, when the RMC enters RUN mode, all Program Trigger conditions that evaluate to true will run the corresponding Task actions, because the RMC thinks their states just transitioned from true to false.

Example

Consider a trigger with the condition MyInput = False. If MyInput is off when the RMC enters RUN mode, the Task action for that loop time will run.

If several conditions become true at the same time and multiple actions are triggered on the same Task, the last action for that Task will be the one that runs.

If your Program Triggers has any conditions that may be true when the RMC enters RUN mode, but you do not wish those Task actions to run when you enter RUN mode, you can do the following:

  1. Use the FirstScan bit (see below) in the condition in the last line of the Program Triggers.

  2. For each task that you do not wish to start when entering RUN mode, choose <StopTask>. Alternatively, if you have a user program that you want to run when the RMC enters RUN Mode, you can enter that user program for the desired Task.

The method above works because the FirstScan condition will become true at the same time as the other items when you enter RUN mode, and since it is the last item in the Program Triggers, it will override the other items.

First Scan Bit

The _FirstScan bit is true during the first loop time after the RMC enters RUN Mode. The _FirstScan bit is false otherwise. This bit can be used in a trigger condition to start programs when the RMC starts up. In order to do so, you must configure the RMC to start in RUN mode.

The _FirstScan bit is a Controller Status Bit.

To use the FirstScan bit:

  1. In the last row of the Program Triggers, double-click in the Condition cell. The Expression Editor will open below the Condition cell.

  2. In the Tags list, expand Controller and double-click FirstScan so that it appears in the box at the top.

  3. Click OK.

  4. In the Task columns, choose the user program you wish to run. You must have created a user program first.

  5. To apply the changes to the RMC, right-click Programming and click Download Programs.

Starting a User Program when the RMC Powers Up

To automatically start a user program when the RMC powers up:

  1. Create a user program that contains the commands you would like to run when the RMC powers up.

  2. In the Program Triggers, create a condition using the _FirstScan bit as described above. The condition should be "_FirstScan".

  3. For the condition you entered in the Program Triggers, choose the user program on a task.

  4. On the RUN/PROGRAM page of the Program Properties dialog, set the RMC to start up in RUN Mode.

  5. Update Flash.

  6. Cycle power to the controller. You can view the Event Log Monitor to see if the user program did start immediately after the RMC powered up.

See the Example: Closed Loop Motion on Startup for a detailed walk-through example.

Running a User Program on Startup Only

If you wish to have the Program Triggers start a user program only when the RMC starts up, and not each time it enters RUN mode thereafter (such as after you download the Programming node), do the following:

  1. Create a variable called Running, and set the Default Value to 0.

  2. Create the following Program Triggers condition:
    _FirstScan and Running = 0

  3. In the first step of the user program, add an Expression (113) command with the following expression:
    Running := 1

When the RMC starts up in RUN mode, it will run the user program. However, it if exits and enters RUN mode after that, the user program will not start because the variable Running is not zero.

Disabling the Program Triggers Task

Sometimes when troubleshooting or setting up the RMC, you may wish to be in RUN Mode but have the Program Triggers disabled.

To disable the Program Triggers:

  1. In the Project pane, expand the desired controller.

  2. Right-click Programming and click Properties.

  3. On the General page, in the Program Triggers section, set the Program Triggers to Disabled. Click OK.

  4. In the Project pane, right-click Programming and click Download Programs to apply the changes to the RMC.

Note:
The Program Triggers will never run when the RMC is in PROGRAM Mode.

 

See Also

Programming Overview | User Program Overview


Send comments on this topic.

Copyright © 2024 Delta Computer Systems, Inc. dba Delta Motion