It is often useful to define an instruction parameter as a Variable instead of a Constant (e.g. “JointMove Speed=D002” instead of “JointMove Speed=50.00”). This allows the parameter to be calculated inside the job or even passed from a different job. This article will describe the meanings of Variable Parameters and demonstrate how to edit an Instruction to use them.
Variables as Parameters
If using a B/I/D variable with an Integer parameter (i.e. parameter with no decimal point) or an R variable with a Real parameter (i.e. parameter with a decimal point), then the value of variable is just a direct substitution into the parameter.
For example, if B004=5, then the two commands below would be equivalent:
The value of B004 can be verified by pressing the {Variables} button in the navigation menu at the bottom of the screen.
Likewise, the two commands below are equivalent if R005=2.5:
If using a B/I/D variable with a Real parameter with n decimal places, you will need to enter an Integer value where the last n digits represent the decimal places. For example, to enter “512.25” using an Integer, the integer value would be “51225”. To enter “75.5” using an integer, the integer value would be “755”.
One place where this comes up is entering the Speed for JointMove or LinearMove. As shown below, the JointMove speed has two decimal places while the LinearMove speed has one decimal place:
To enter these as variables, we will need to set an integer to “7520” for the JointMove and “752” for the LinearMove as shown below.
Array Variables
An array variable can be used to dynamically change the variable number that is used in the program. The index can be provided as a constant as another variable (B/I/D). The value of the index is simply the Variable number. So, B[2] is the same as B002, and I[B005] where B005=4 is the same as I004.
This is especially useful when used inside of FOR loops where the loop index can be used to change the variable. For example, the FOR loop shown below would shift by the value of P001 in the first loop, P002 in the second loop, P003 in the third loop, etc.…
Entering Variable Parameters
Changing a variable from Constant->Variable (or Variable->Constant) can only be done from the Detail Edit panel. To open this panel, press the modify icon on the desired instruction line:
From the Detail Edit panel, select the parameter that you want to change to a Variable. For this example, we will use the PositionLevel parameter:
To change to a variable, select the “User Variable” tab at the top of the screen. Next, select the variable type that you would like to use (e.g. selecting “(I)nteger” in the picture below). Only the variable types allowed for a particular parameter will be displayed (B, I, and D here).
The variable number can then be entered form the keypad. The {Browse Variables} switch can be used to select the variable from a list instead of manually entering.
Pressing the {SAVE ALL} button now would set the instruction as below:
To use an Array Variable, select the desired type from the {Array VAR} drop down list:
Now, the type of the Index variable can be selected and entered. For example, the screen below shows selecting a (D)ouble index variable (e.g. PositionLevel=I[D005]).
Example of instruction with an Array Variable:
Comments
0 comments
Please sign in to leave a comment.