Registers: Difference between revisions
Line 503: | Line 503: | ||
Anything minus itself will always equal zero, so no matter what the contents of each element in the position register happen to be, it will become zero after this instruction is reached. |
Anything minus itself will always equal zero, so no matter what the contents of each element in the position register happen to be, it will become zero after this instruction is reached. |
||
Since position registers are global variables, they may be used in other programs and can contain values that are unrelated to your own. You should never assume a position register will be at specific values before the program begins. |
Since position registers are global variables, they may be used in other programs and can contain values that are unrelated to your own. You should never assume a position register will be at specific values before the program begins. It is best, whenever possible, to design your program based on the starting values of zero and simply add the subtraction instruction in the beginning of your program, outside any loops that may depend on changes to the variable. |
||
==Division Instruction == |
==Division Instruction == |
Revision as of 14:46, 11 April 2020
Hello! You've reached a page in progress. Currently, the "valid variables" section of each instruction on this page needs to be expanded to note the validity of each regarding their data types. Additionally, better page organization is required as separating each into headings and subheadings is visually displeasing. Check back soon for changes!
This page details the Register Instructions available on the FANUC Teach Pendant Programmers. For information on the data within the variables, see Data.
Register instructions do not involve motion. They are simply math operations with one or more inputs and an output.
When the program reaches a register instruction, it completes the math operation, overwrites the destination variable, and moves forward.
Result | = | Variable | OPERATION | ||
---|---|---|---|---|---|
Result | = | Variable | + | Variable | Addition |
Result | = | Variable | - | Variable | Subtraction |
Result | = | Variable | / | Variable | Division |
Result | = | Variable | * | Variable | Multiplication |
Result | = | Variable | DIV | Variable | Division Whole # |
Result | = | Variable | MOD | Variable | Division Remainder |
Result | = | (...) | Mixed Logic |
Note that Position Registers must be initialized before any instructions that use them can run. For instructions on how to initialize a position register, see
Equals Instruction
R | [1] | = | R | [2] | Equals Instruction |
---|---|---|---|---|---|
PR | [1] | = | PR | [2] | |
PR | [i,j] | = | 1 | ||
R | [1] | = | PR | [i,j] |
When this instruction is reached
The contents of the left variable are set to the right variable.
When to add this instruction
Use this instruction whenever you need to set a variable’s contents to the contents of another.
In the Non-Motion Instructions menu, select the “Registers” Category. In the “Registers” menu, select “... = ...”. Once inserted, select your left variable. Type the numbers for the variable, then hit enter. Select the right variable. Type the numbers for the variable, then hit enter.
What else is needed to use this instruction
None.
Valid Variables
R [1] - Data Registers
PR [1] - Position Registers (Must set all 6 elements at once)
PR [i,j] - Position Register Element (Sets element j in position register i)
SR [1]
PL [1]
Constant
Example
Before Instruction: R1 contains 7. R2 contains 3.
R[1]=R[2]
After Instruction: R1 now contains 3. R2 still contains 3.
Special Notes
You cannot perform operations between entire position registers and other variables, as position registers contain 6 separate elements. You can only work with one element at a time, using PR[i,j].
Addition Instruction
R | [1] | = | R | [1] | + | 28 | Add Instruction | |
---|---|---|---|---|---|---|---|---|
PR | [1] | = | PR | [1] | + | PR | [7] | |
PR | [i,j] | = | R | [3] | + | 100 | ||
R | [1] | = | PR | [i,j] | + | PR | [i,j] |
When this instruction is reached
The contents of the left variable are set to the middle variable plus the right variable.
When to add this instruction
Use this instruction whenever you need to set a variable’s contents to the contents of multiple variables added together.
What else is needed to use this instruction
None.
Valid Variables
R [1] - Data Registers
PR [1] - Position Registers (Must set all 6 elements at once)
PR [i,j] - Position Register Element (Sets element j in position register i)
SR [1]
PL [1]
Constant
Special Notes
You cannot perform operations between entire position registers and other variables, as position registers contain 6 separate elements. You can only work with one element at a time, using PR[i,j].
Subtraction Instruction
R | [1] | = | R | [1] | - | 28 | Subtract Instruction | |
---|---|---|---|---|---|---|---|---|
PR | [1] | = | PR | [1] | - | PR | [7] | |
PR | [i,j] | = | R | [3] | - | 100 | ||
R | [1] | = | PR | [i,j] | - | PR | [i,j] |
When this instruction is reached
The contents of the left variable are set to the middle variable minus the right variable.
When to add this instruction
Use this instruction whenever you need to subtract one variable from another.
What else is needed to use this instruction
None.
Valid Variables
R [1] - Data Registers
PR [1] - Position Registers (Must set all 6 elements at once)
PR [i,j] - Position Register Element (Sets element j in position register i)
SR [1]
PL [1]
Constant
Special Notes
You cannot perform operations between entire position registers and other variables, as position registers contain 6 separate elements. You can only work with one element at a time, using PR[i,j].
Common Examples
PR[#] = PR[#] - PR[#] is a commonly seen instruction in the beginning of programs that ensures the position register is completely zeroed before the program's main components begin.
Anything minus itself will always equal zero, so no matter what the contents of each element in the position register happen to be, it will become zero after this instruction is reached.
Since position registers are global variables, they may be used in other programs and can contain values that are unrelated to your own. You should never assume a position register will be at specific values before the program begins. It is best, whenever possible, to design your program based on the starting values of zero and simply add the subtraction instruction in the beginning of your program, outside any loops that may depend on changes to the variable.
Division Instruction
R | [1] | = | R | [1] | / | 28 | Division Instruction | |
---|---|---|---|---|---|---|---|---|
PR | [1] | = | PR | [1] | / | PR | [7] | |
PR | [i,j] | = | R | [3] | / | 100 | ||
R | [1] | = | PR | [i,j] | / | PR | [i,j] |
When this instruction is reached
The contents of the left variable are set to the middle variable divided by the right variable.
When to add this instruction
Use this instruction whenever you need to divide two variables.
What else is needed to use this instruction
None.
Valid Variables
R [1] - Data Registers
PR [1] - Position Registers (Must set all 6 elements at once)
PR [i,j] - Position Register Element (Sets element j in position register i)
SR [1]
PL [1]
Constant
Special Notes
You cannot perform operations between entire position registers and other variables, as position registers contain 6 separate elements. You can only work with one element at a time, using PR[i,j].
MOD Instruction
R | [1] | = | R | [1] | MOD | 28 | MOD Instruction | |
---|---|---|---|---|---|---|---|---|
PR | [1] | = | PR | [1] | MOD | PR | [7] | |
PR | [i,j] | = | R | [3] | MOD | 100 | ||
R | [1] | = | PR | [i,j] | MOD | PR | [i,j] | |
PR | [1] | = | PR | [3] | MOD | P | [1] |
When this instruction is reached
The contents of the left variable are set to the remainder of the division operation between the middle variable and the right variable.
When to add this instruction
Use this instruction whenever you need to get the remainder of a division operation.
What else is needed to use this instruction
None.
Valid Variables
R [1] - Data Registers
PL[1] - Pallet Registers
PR [1] - Position Registers (Must set all 6 elements at once)
PR [i,j] - Position Register Element (Sets element j in position register i)
SR [1]
Constant
Special Notes
You cannot perform operations between entire position registers and other variables, as position registers contain 6 separate elements. You can only work with one element at a time, using PR[i,j].
Mixed Logic Instruction
This section is incomplete and has yet to be worked on.
R | [1] | = | R | [1] | 28 | Mixed Logic Instruction | ||
---|---|---|---|---|---|---|---|---|