Follow the steps below to create a User Program. For example user programs, see the Programming Examples Overview topic.
Note:
In order to run User Programs or the Program Triggers, the RMC must be
in RUN mode. See the RUN/PROGRAM
Mode topic for details.
Basics of Creating a User Program
Create a User Program
In the Project Pane, expand the desired controller, expand the Programming node, right-click User Programs and choose New Programs.
Enter a name for the program. Names are limited to 64 characters.
If desired, change the Program Number.
Click Finish. The Step Editor will open with the new user program. The user program will appear in the Project pane, under Programming and User Programs.
Now you can use the instructions below to add steps and commands, do any additional editing, and download the user program.
Add a Program Comment
To add a comment for the entire program, right-click anywhere in the program and choose Edit Program Comment. Enter a description of the program and click Save.
Add Steps
You may add steps to a User Program at any time. On the Step Editor menu, click the Insert Step button. Or, right-click the space below the step number and choose Add Step Before or Add Step After. To add a step to the end of the program, right-click the empty space below the last step and choose Append Step.
Edit the Step
See the Editing a Step section below.
Verify the Program
After you have created the program you must verify it before downloading it and running it. See the Verify topic for instructions. After creating and verifying a User Program, the next step is to download it before running it on the RMC.
You may edit the steps at any time. For each step in the User Program, do any of the following:
Add Commands
Each step can have multiple commands and can issue any of the RMC commands. A maximum of one command per axis can be issued in a single step. However, there is no limit to the number of immediate commands that can be issued per step. Immediate commands include the Expression (113) and discrete I/O commands. The RMC controller can process a maximum of one step of a User Program per Task per loop time. A step is not required to have a command.
Add a Command to the Step
On the Step Editor toolbar, click the Insert Command button .
Or, right-click close to a command and choose Add Before or Add After.
Or, select a command and press Ctrl+Insert to add a command before, or Ctrl+Alt+Insert to add a command after.
Click the Command box and then click the Details button. Choose a command from the Command List and click OK. The commands are grouped by type in the hierarchical list to help you find the one you want.
Alternately, you can select a command by clicking the Command box and begin typing the command name or number. Use the arrow keys or the mouse to select the command.
Immediate Commands
A maximum of one non-immediate command per loop time can be issued to each axis. There is no limit to the number of immediate commands that can be issued to an axis per loop time.
To determine whether a command immediate, see the List of Commands.
Enter the Command Parameters
If the command has any parameters, enter their values. In most parameters, you may enter a number, tag, or an expression. If you use a tag name, register, or expression, it must evaluate to the data type required by the parameter, typically a REAL.
Tip:
For help on the command's parameters, click the command box and press F1.
Click a parameter box.
To enter a number, type the number.
To enter a tag, click the Details button and choose the tag from the list. Or, start typing the tag name and then use the arrow keys to select the address.
To enter an expression or a tag, type it in the box. The Expression Browser is not available for command parameters, but the auto-complete will assist you.
Selecting Commanded Axes
The Commanded Axes specifies which axes to issue the command to.
Click the Commanded Axes button and choose the axes you wish to issue the command to, then click OK. For example, selecting Axis 0 and Axis 1 will make the command be issued to both axes.
The Default Axis and Use Expression options are typically used only in advanced applications. If you choose Default Axis, the command will be issued to the same axis as the Start Task command was issued to. The Use Expression option can be used to programmatically select the commanded axes.
Important: A maximum of one non-immediate command per axis can be issued in a single step. If you try to issue more than one command to an axis per step, the verify will report an error and you will not be able to download the programs.
Add Expressions
To add expressions to a step, choose the Expression (113) command. Local variables can also be declared in a user programs step. To add a local variable to a user program step, on the Step Editor toolbar, click the Add Step Declarations button. Or, right-click the step and choose Add Step Declarations. See Local variables for more details.
Select a Link Type
The Link Type specifies when the program will jump to another step, and which step it jumps to. A step can jump to any step in the current user program, or to any labeled step in another user program.
Select one of the Link types in the Link Type box:
Immediate
Immediately jumps to the next step in the User Program. The next step is then executed in the next control loop of the RMC.
Jump
Jumps to the step specified in the Jump To box. You can enter a step number or label, or choose a step label from the drop-down list. The specified step is then executed in the next control loop of the RMC.
Delay
Waits the number of seconds specified in the Time to Delay box before jumping to the step specified in the Jump To box. You can enter a step number or label, choose a step label from the drop-down list, or choose ”Next” to jump to the next step in the sequence.
Wait For
Waits for the specified Link Condition to become true before jumping to the next step in the User Program.
Conditional Jump
The Conditional Jump link type can have one or more conditions. The conditions are evaluated in order. For the first condition that evaluates to True, the program jumps to the destination specified in its Jump On True box. If all conditions evaluate to False, then the program jumps to the destination specified in the Jump On False box.
The Jump destinations can contain a step number, a step label, ”Wait”, ”Next”, or "Repeat":
Next: The program will jump to the next step in the sequence.
Wait: The program will stop evaluating the conditions, and re-evaluate the conditions the next control loop. For Conditional Jumps with multiple link conditions, ”Wait” must only be used for the Jump On True/False boxes for the last condition, and only in one of the boxes.
Repeat: The program will repeat the entire step, which means it will issue all the commands in the step.
To add, delete, or re-order link conditions in a Conditional Jump link type, use the Condition buttons on the Step Editor toolbar ( ).
End
Ends the User Program.
Add a Step Comment
If you wish, you may add a comment to the step. Comments help you keep track of what the step is for and what it does.
On the Step Editor toolbar, click the Edit Step Comment button , or right-click anywhere within the step and click Edit Step Comment.
Type your comment and click Save.
Add a Step Label
If you wish, you may add a label to the step. Labels can be used when specifying the step to jump to. See the labels topic for details on labels.
On the Step Editor toolbar, click the Insert Step button, or right-click in area below the step number and choose Edit Label. Type the label name and click OK.
To browse all the labels in a project, use the Browse Labels dialog.
Assigning labels to every step is not good programming practice.
Additional Tasks
Adding, Deleting and Moving Steps
Add a Step:
On the Step Editor toolbar, click the Insert Step button . Or, right-click the area below the step number and choose Add Before or Add After, or press Insert to add a step before the current step, or Alt + Insert to add a step after the current step.
To add a step to the end of the program, right-click the empty space below the last step and choose Append Step.
Delete a Step:
On the Step Editor toolbar, click the Delete Step button . Or, select the entire step by clicking the area below the step number, then press Delete, or click Remove Step on the Step Editor toolbar. Or, right-click the area below the step number and choose Delete Step.
Move a Step:
Select a step by clicking the area below the step number, then drag the step to the desired location, or use the Move Step Up and Move Step Down buttons on the Step Editor toolbar. Or, right-click the area under the step number, then choose Move Step Up or Move Step Down.
When adding and deleting steps, the Step Editor automatically updates the Link Jump To numbers so that they jump to the same step that they did before the add or delete. For example, if step 3 has a Jump To number of 4, and you insert a step before step 3, then the old step 3 becomes the new step 4. Its Jump To number is automatically changed from 4 to 5.
If a deleted step was linked to with a number from some other step, a warning will appear in the Output window.
Adding, Deleting and Moving Commands
Add a Command:
On the Step Editor toolbar, click the Insert Command button . Or, right-click a command and choose Add Before or Add After.
Or press Ctrl + Insert to add a command before the currently selected command or press Ctrl + Alt + Insert to add a step after the currently selected command.
Delete a Command:
On the Step Editor toolbar, click the Delete Command button . Or, select the entire command by clicking close to —but not inside—a command box. Make sure the entire command, including parameters, is selected, then press Delete, or click Remove Command on the Step Editor toolbar.
Or, right-click the command so that the entire command with parameters is selected and choose Delete Command.
Move a Command:
Click a command such that the entire command with parameters is selected and drag it the desired location.
Or, select the entire command with parameters and use the Move Command Up and Move Command Up buttons on the Step Editor toolbar, or right-click a command and choose Move Command Up or Move Command Down.
Deleting a Step or Program Comment
Double-click the comment to open the Edit Comment dialog and click Delete.
Showing and Hiding All Comments
On the Step Editor toolbar click the Show/Hide all Comments button , or right-click a step and click Show Comments or Hide Comments.
Renaming User Programs
In the Project pane, right-click the User Program and click Rename, or select the User Program and press F2.
Assigning Tasks the User Program May Run On
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.
See Also
User Program Overview | Example: Basic User Program
Copyright © 2024 Delta Computer Systems, Inc. dba Delta Motion