Registers: Difference between revisions

No edit summary
 
(11 intermediate revisions by the same user not shown)
Line 1:
<br />[[File:REGISTER Instruction menu.png|thumb|600x600px|REGISTER Instruction menu]]
This page details the Register Instructions available on the FANUC Teach Pendant Programmers. For information on the data within the variables, see [[Data|Data.]]
''This page details the Register Instructions available on the FANUC Teach Pendant Programmers. For information on the data within the variables, see [[Data|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.
 
The leftmost variable in a register instruction is where the result is stored. Everything to the right of the equal sign is the equation to be performed.
 
{| class="wikitable"
Line 11 ⟶ 14:
!
!
! OPERATION
! Equals
|-
| Result
Line 44 ⟶ 47:
| =
| Variable
| DivDIV
| Variable
| Division Whole Number Division#
|-
| Result
| =
| Variable
| ModMOD
| Variable
| Whole Number Division Remainder
|-
|Result
|=
|(...)
|
|
|Mixed Logic
|}
A common use for Register instructions is a counter that increases the value of a register by one each time a program runs.
==Equals Instruction==
 
Example:
 
R[1] = R[1] + 1
 
This will take whatever is in R[1], add 1 to it, and store it to R[1]. Every time you run a program that contains this line, it will count up. This means a technician can walk up to a robot cell and glance at the register's contents to know exactly how many times the robot performed its task.
 
 
Below is a detailed explanation with examples of each of the register instructions from the table above.
 
==Equals Instruction==
 
{| class="wikitable"
Line 120 ⟶ 138:
 
=== When this instruction is reached ===
 
===When this instruction is reached ===
 
Line 430 ⟶ 447:
|}
 
===When this instruction is reached ===
 
 
The contents of the left variable are set to the middle variable minus the right variable.
===When this instruction is reached ===
 
 
The contents of the left variable are set to the middle variable minus the right variable.
 
Line 490 ⟶ 504:
 
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 ==
Line 641 ⟶ 660:
 
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==
 
{| class="wikitable"
 
! 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==
[[File:Mixed Logic.png|thumb|500x500px]]
'''This section is incomplete and has yet to be worked on.'''
{| class="wikitable"
 
! R
 
! [1]
 
! =
 
! R
 
! [1]
 
!
 
! 28
 
!
 
! Mixed Logic Instruction
 
|-
 
|
 
|
 
|
 
|
 
|
 
|
 
|
 
|
 
|
 
|-
 
|
 
|
 
|
 
|
 
|
 
|
 
|
 
|
 
|
 
|-
 
|
 
|
 
|
 
|
 
|
 
|
 
|
 
|
 
|
|-
|
|
|
|
|
|
|
|
|
|}
===When this instruction is reached ===
It will perform whatever equation it contains and store to the variable to the left of the equal sign.
 
===When to add this instruction ===
This option lets you manually build register instructions using variables and operations that may not come up in the default listing of options. For example, certain software packages use their own variable types that are outside the scope of the original menus. Additionally, you may have to use mixed logic when building an equation in an IF statement if the variables you are comparing are individual position register elements.
 
===What else is needed to use this instruction ===
None
 
===Valid Variables ===
All available variables. It will let you enter invalid choices as well, although they won't run and will error out when the instruction is reached in a running program.
 
===Special Notes ===
It is easy to accidentally build a mixed logic instruction incorrectly. Unlike the default choices, mixed logic won't force you to choose valid options and variables as you build it. Extra parenthesis are a common mistake and it may take some doing to ensure you have an equal amount of opening and closing parenthesis.
 
__NOTOC__