Activity 3.1.2f Variable Programming Information Sheet

advertisement
Activity 3.1.2f Variable Programming
Information Sheet
Variable programming is a powerful option when programming a robot. Variables are
useful for creating loops and subroutines in robot programs. This will allow you to
write significantly shorter programs when your robot is performing a repetitive task.
Overview
The following are the generic steps that will be used when programming with
variables.
 Step 1: Define the variable(s).
o Use the Set Variable to Computation (SV) command
 Step 2: Identify the start of the program sequence.
o Use the Label (LA) command
 Step 3: Perform the program sequence.
 Step 4: Increment the variable(s).
o Use the Set Variable to Computation (SV) command
 Step 5: Evaluate the variable to determine whether the program sequence
has been completed.
o Use the If Jump … (IF) command
 Step 6: If the program sequence has been completed, end the program.
o Use the Jump to … (JU) command
 Step 7: Identify the end of your program.
o Use the Label (LA) command
Commands
Set Variable to Computation (SV)
 This command allows you to assign a value or expression to a variable.
 In your program, you instructed the robot to drop off a part at a certain
location, such as position #3. You could define position #3 by using a variable
called DROP.
 Instead of instructing the robot to go to position #3, you will instruct it to go to
position DROP.
 When you select this command, the following dialog box will open.
© 2013 Project Lead The Way, Inc.
CIM Activity 3.1.2f Variable Programming Information Sheet – Page 1



In the Name section, type DROP.
In the Value or Expression section, type 3 to represent position #3.
After you click OK, the following line will be inserted into your program.
o Set Variable Drop = 3
Incrementing Variables



After running through your program the first time, you must increment the
variable so that it will progress to the next position in the sequence.
Again, you will use the Set Variable to Computation dialog box.
In our example we want to increment the variable Drop by 1, making its new
value 4.


The variable name would again be DROP.
The new Value or Expression would be DROP = DROP + 1.
© 2013 Project Lead The Way, Inc.
CIM Activity 3.1.2f Variable Programming Information Sheet – Page 2
Download