Uploaded by Erika Florence

FanucAdvTPPChpt7MixedLogic

advertisement
Advanced
7: Mixed and BG Logic
TPP
7 MIXED LOGIC AND BACKGROUND LOGIC
7.1
7.2
Learning Objectives
•
Understand Mixed Logic Instructions
•
Create Mixed Logic Instructions
•
Understand Background Logic
Mixed Logic Instructions
Mixed Logic Instructions provide the ability to include operators of AND and OR, as well as
arithmetic operations of+ and - with * and / in the same instruction. Also the NOT operator (!)
and parenthesis ("("and")") are supported.
MIXED_LOGIC
+._
1/4
.:I=
2:
3:
=
[B
DO[1]=(DI[1]
AND !DI[2])
WAIT (TIMER[3]>=15)
IF (DI[37]
AND !DI[38]
AND
DI[36]
OR !DI[35]
AND RI[6] AND
!DI[34]
OR R[2]<R[3]
AND GI[2]>=
52),PR[5,3]=(500+Gl[1])
[End]
The use of Mixed Logic can be applied in Register, 1/0, IF/SELECT and Wait instructions. With
the added ability to use Flag and Marker statements in Mixed Logic as well as the ability to
utilize Background (BG) Logic. BG Logic allows simultaneous, continuous, repeated execution
of as many as eight TP programs containing only assignment statements.
Mixed Logic actions also allow fewer lines of TPP code development than what is necessary for
standard logic instructions.
MIXED _EXAMPLE
+.._
1/8
=
[E
--Mixed
111111!=
2:
3:
4:
5:
6:
7:
Logic example
IF (DO[1]),R[5]=(10)
--Instead
with standard
logic
IF DO[1]
,JMP LBL[10]
--Further
on in the code
LBL[.10)
R[5]=10
[End]
In the example shown, the program, MIXED_EXAMPLE.TP, sets a value of ten into register five
if digital output one is ON. With Mixed Logic one line of code would be required for this
operation but in standard logic three lines of code would be necessary.
127
MATOGA1PP12191E
FANUC
AmericaCorporation© Copyright
2019:
DO
NOT
DUPLICATE
7: Mixed and BG Logic
AdvancedTPP
Also in standard logic a maximum of five logical conditions can be evaluated but in Mixed Logic
up to twenty conditions per statement are allowed depending on the data type used.
7.2.1
Data Types
The following data types are available for mixed logic instructions:
Type
Numerical
Value
The data can have numerical value.
Both integer and real values are
available.
The data can be On or Off
Boolean
Data
Register, Constant, Gl/O, Al/O,
Element of position register ,
Argument, System variable
Dl/O, Rl/O, Ul/O, S1/O,Wl/O, On,
Off, Flag, Marker
~ NOTE: Position type data and Palletizing type data cannot be specified in mixed logic
instructions
7.2.2
Order of Operations and Operators
When the operators are mixed together order of operations is used to determine priority
similar to the acronym PEMDAS (Parentheses, Exponents, Multiplication, Division, Addition
and Subtraction). The order precedence within the statement is usually from left to right
with the lowest priority being the OR operator.
MIXED_LOGIC
+._
1/5
•= 2:
3:
4:
=
[8
R[1]=(2+3*4)
--R[1]=14
R[2] = ( (2+3) *4)
--R[2]=20
[End]
In the example shown, the program, MIXED_LOGIC.TP, line one demonstrates that
multiplication has a higher precedence than addition. On line three, parentheses can be
used to force multiplication to follow addition.
The following arithmetic operators are available for mixed logic instructions:
Operator
+
*
I
MOD
DIV
128
Operation
Addition of left side and right side.
Subtraction of left side and riqht side.
Multiplication of left side and riqht side.
Division of left side and riqht side.
Remainder of the division of left side and riqht side.
Round of the decimal part of the division of left side and right side.
•
Arithmetical operators are used for numerical data only. If numerical operators are
used for Boolean data, the INTP-205 Variable Type Mismatch error occurs.
•
The output data type of arithmetical operators is always numerical.
MATOGATPP12191E
FANUC AmericaCorporation© Copyright2019: DO NOT DUPLICATE
7: Mixed and BG Logic
AdvancedTPP
The following logical operators are available for mixed logic instructions:
Operator
AND
OR
!
Operation
Logical AND of left side and right side.
Logical OR of left side and right side.
Logical NOT of left side and right side.
•
Logical operators are used for Boolean data only. If logical operators are used for
numerical data, the INTP-205 Variable Type Mismatch error occurs.
•
The output data type of logical operators is always Boolean.
The following comparison operators are available for mixed logic instructions:
Operator
=
<>
<
>
<=
>=
Operation
When the left side and right side are equal, returns ON; when unequal,
returns OFF.
When the left side and right side are not equal, returns ON; when equal,
returns OFF.
When the left side is less than the right side, returns ON; when greater,
returns OFF.
When the left side is greater than the right side, returns ON; when less,
returns OFF.
When the left side is less than the right side, or they are equal, returns ON;
when greater, returns OFF.
When the left side is greater than the right side, or they are equal, returns
ON; when less, returns OFF.
•
"=" and "<>" can be used for both numerical data and Boolean data.
•
"<",">","<=", and">=" are used for numerical data only. If they are used for Boolean
data, the INTP-205 Variable Type Mismatch error occurs.
The priority of the operators is indicated in the following table:
Operator
HIGHEST
MEDIUM
LOWEST
7.2.3
Operation
!
*, /, DIV , MOD
+ '
< , > ' <= ' >=
=,<>
AND
OR
Assignment Statement
A mixed logic assignment statement assigns a value to a Register or an Output based on
the result of mixed logic. The following is an example of a mixed logic assignment
statement:
Register instruction: R[1] = ((GI[1] + R[1]) * Al[1])
The outcome of this instruction will populate R[1] with the resultant value of Gl[1] plus R[1]
multiplied by the contents of Al[1].
MATOGA1PP12191E
FANUC AmericaCorporation© Copyright2019:DO NOT DUPUCATE
129
7: Mixed and BG Logic
Advanced TPP
1/0 instruction: DO[1] = (Gl[1] - Gl[2])
The outcome of this instruction will turn D0[1] ON if the result of Gl[1] - Gl[2] is greater
than 1 or less than -1 .
The outcome of this instruction will turn D0[1] OFF if the result of Gl[1] - Gl[2] is less than
1 or greater than -1.
The following data can be specified in the left side of the assignment:
Operator
Boolean
Numerical
7.2.4
Operation
DO, RO, UO, SO, WO, FlaQ, Marker
Register, GO, AO, element of a PR, System Variable
•
The first = from the left indicates an assignment statement. The other =s indicate
comparison. The result of the right side expression is assigned to the left side data.
•
When the left side data type is Boolean and the result of the right side expression is
numerical, left side data becomes OFF when the right side value is less than 1 and
greater than -1; the left side data becomes ON when the right side value is greater
than 1 or less than -1. This behavior is the same as a normal assignment
statement.
•
When the left side data type is numerical and the result of the right side expression is
Boolean, the left side data becomes O when the right side value is OFF, and the left
side data becomes 1 when the right side value is ON. This behavior is the same as a
normal assignment statement.
•
If a real value is assigned to GO, AO, or an integer type system variable, the decimal
part is rounded off.
•
"Pulse" cannot be specified in mixed logic instructions. You must use normal logic
instructions to specify "Pulse". Default Pulse length is specified in the System
Variable $DEFPULSE.
•
Position type data and palletizing type data cannot be specified in the right side or
left side of mixed logic instructions. You must use normal logic instructions to specify
position or palletizing type data.
•
The maximum number of items (data or operators) allowed in an assignment
statement is approximately 20. The exact maximum number allowed varies
according to data type.
IF Statement
A mixed logic IF statement will execute an action based on the verification of mixed logic
conditions. Like a traditional IF instruction, if the condition(s) are true, the action is
executed. If the condition(s) are not true the action is not executed. The following is an
example of a mixed logic IF statement:
IF (R[1] = (GI[1] + R[1]) * Al[1]) JMP LBL[1]
This is instruction will branch to LBL [1] if the contents of R[1] are equal to the value of Gl[1]
plus R[1] multiplied by Al[1]. Like the assignments statement from the previous section, the
order of operations is controlled by parenthesis.
130
MATOGATPP12191E
FANUC AmericaCorporation© Copyright2019: DO NOT DUPLICATE
7: Mixed and BG Logic
AdvancedTPP
IF (DI[1] AND {!Dl[2] OR DI[3])) JMP LBL[1]
This is instruction will branch to LBL [1] if:
•
D1[1] is ON and Dl[2] is OFF
•
Dl[1] is ON and Dl[3] is ON
•
Dl[1] is ON, Dl[2] is OFF, and Dl[3] is ON
Due to AND having a higher priority, parenthesis are required to analyze the OR portion.
The parenthesis evaluate the !Dl[2] as part of the OR statement. If there were no
parenthesis the !Dl[2] would be evaluated as part of the AND statement.
When using mixed logic IF statements remember:
•
You can specify mixed logic expressions in the condition part of an IF statement.
•
The result of the IF statement must be Boolean.
•
When the result of the expression is on, the action part of the statement, for
example, JMP LBL, is executed.
•
The following statements can be used in the action part of an IF statement when
mixE;idlogic is used in the condition part:
•
•
7.2.5
•
JMP LBL[]
•
CALL
•
Mixed Logic assignment statement
•
Pulse statement
Mixed Logic assignment statements and Pulse statements can be specified in the
action part of the IF statement only when the condition part is a Mixed Logic
expression. See the following example:
•
IF (Dl[1]), DO[1]=(On)
•
IF (Dl[2]), DO[1]=Pulse
The maximum number of items (data or operators) in an IF statement is
approximately 20. The exact maximum number of items varies according to data
type.
Mixed Logic Wait Statements
MIXED_WAIT
+..,
1/42
WAIT (DI[l.:Mach 1 Door Open] AND
(!DI[2:Mach 2 Door Open] OR
DI[3:Mach 3 Door Open]))
TIMEOUT,LBL[10]
=
MATOGATPP12191E
FANUC America Corporation© Copyright 2019: DO NOT DUPLICATE
[8
131
7: Mixed and BG Logic
Advanced TPP
In the example shown, the program, MIXED_WAIT.TP, will wait at line one until digital one is
ON and digital two is OFF or will wait until digital one is ON and digital three is ON, for the
amount of time in the Timeout variable. If the timeout period is reached and the wait condition is
still not satisfied then the program will branch to label ten.
7.2.6
•
Mixed Logic expressions can be specified in the condition of a WAIT statement
•
The result of the expression must be Boolean.
•
The WAIT statement waits until the result of the expression becomes ON.
•
"On+", "Off-" and "ERR_NUM" cannot be specified in mixed logic instructions. You
must use normal logic instructions to specify them.
•
The maximum number of items (data or operators) in a WAIT statement is
approximately 20. The exact maximum number of items varies according to the data
type.
To Add Mixed Logic Instructions To A Program
Procedure 7-1 To Add Mixed Logic Instructions To A Program
At the Edit menu,
1
MIXED_MAIN
+,
1/1
a
=
[8
Press F1, INST
lnstructlon
1/ 4
I Reg1st<!r'S
2 l/0
3 IF/SELECT
4 WAIT
5 JMP/LBL
6 CALL
7 Palletf21ng
8 --next page--
2
Select the kind of instruction you want to add: Register, 1/0, IF/SELECT, or WAIT. In
our example we will choose WAIT.
Instruction
1/ 'I
1 Registers
2 I/0
3 IF/SELECT
4 WAIT
5 JMP/LBL
6 CALL
7 Palletlz!ng
8 --next page--
132
MATOGATPP12191E
FANUC AmericaCorporation© Copyright2019: DO NOT DUPLICATE
7: Mixed and BG Logic
Advanced TPP
3
Select the Mixed Logic statement in the menu which contains parentheses:( ...)
Wait statements
1/ I
1 WAIT ... (sec)
2 WAIT ... =...
3 WAIT ... <> ...
4 WAIT ... < ....
5 WAIT ... <= ....
6 WAIT ... >....
7 WAIT ... >=...
8 WAIT( ... )
4
Build the instruction as you normally would.
3 DO[ ]
4 R(]
5 F[]
6 On
page--
---------on
8 --next page--
1:
...
WAIT (-)
I
■■•
S-
~
•••
<INSERT>
J
~
<DELETE>
[Jx
[CHOICE]
( 1)
3 DO{
4 R[]
5 F[]
6 On
7 Off
8 --next page--
MATOGATPP12191E
FANUC AmericaCorporation© Copyright2019: DO NOT DUPLICATE
133
7: Mixed and BG Logic
AdvancedTPP
MIXED_MAIN
+•.
=
+_,
=
1/2
1:
[E
WAIT {DI[-])
[End]
MIXED_MAIN
1/2
1:
WAIT (DI[1:Mach
[E
1 Door Open]fJ
[End]
You can insert items in any Mixed Logic statement, except for the left side of an
Assignment statement.
5
a
Press F1, INSERT. An empty item, " ..." is inserted before the cursor and an item
selection menu is displayed.
WAIT (D1(1:Mach
1 Door Open] -
3 OR
4+
56
*
7/
8 --next page--
6
To add or delete a NOT(!) operator, when the cursor is on a Digital 1/0 item of a Mixed
Logic expression, press F5, (!). The NOT(!) operator will be added or deleted.
MIXED_MAIN
+., :: [R
1/2
WAIT (DI[1:Ma.ch 1 Door Open] AND
DI[i:Mach
2 Door Open])
1:
[End]
Enter
134
value
::;
s-
f ,11.,
""'
dNSERT.
DIRECT
I'
:J
fNDfRECl
§
(CHO!CEJ
( t)
MATOGA1PP12191E
FANUCAmericaCorporation© Copyright2019:DO NOT DUPLICATE
7: Mixed and BG Logic
Advanced TPP
MIXED_MAIN
+._
1:
1/2
WAIT (DI[1:Mach 1 Door Open] AND
!DI[i:Mach
2 Door Open])
=
[8
[End]
You can delete items in any Mixed Logic statement except for the left side of an
assignment statement.
7
a
Move the cursor to the item and press CHOICE. The DELETE key will be displayed
on F2. If an operand is deleted, the following data item will also be deleted.
I[2:Mach
' ...
...
■■■
s-
2 Door
uJ
<INSERT>
<DELETE>
Open] )
.~
L___J
[CHOICE}
( I)
MIXED_MAIN
+•.
1/2
1:
WAIT (DI[1:Mach
1 Door
=
[E
Open]tJ
[End]
To change an item of a Mixed Logic statement, move the cursor to the item you want to
change.
8
MIXED_MAIN
1:
+.._
1/2
WAIT (DI[1:Mach 1 Door Open] AND
!DI[2:Mach 2 Door Open] OR DO[iJ
) TIMEOUT,LBL[10]
=
[8
[End]
a
Press F4, CHOICE. The available items will be displayed.
MATOGA1PP12191E
FANUCAmericaCorporation© Copyright2019:DO NOT DUPLICATE
135
7: Mixed and BG Logic
Advanced TPP
i---------<R[]
---------l
-------l
3 DO[
J
!------fR_OVERFLOW
!---------1
4 R[]
lt----------l]
5 F[]
6 On
t------PCT
page--
1--------«t
7 Off
page--
1--------------jl)(C
page--
8 --next page--
! DI [2 :Ma.ch 2 Door
3 DO[
Open]
OR
rtI•Jiul
]
4 R(]
5 F( ]
60n
7 Off
8 --next
I
page--
MIXED_MAIN
1:
=
+_._
WAIT (DI[1:Macb
1 Door Open]
rnI [2 :Mach 2 Door Open] OR
DI[i:Ma.cb
3 Door Open])
TIMEOUT,LBL[10]
1/2
AND
[8
[End]
9
For order of operations, parentheses may be added as necessary. Move to the item or
end of items to setup priority.
MIXED_MAIN
1:
+.._
WAIT (DI[1:Mach
1 Door Open]
!DI[i:Mach
2 Door Open] OR
DI[3:Ma.ch 3 Door Open])
TIMEOUT,LBL[10]
1/2
AND
=
[8
[End]
136
MATOGATPP12191E
FANUC America Corporation©
Copyright 2019: DO NOT DUPLICATE
7: Mixed and BG Logic
Advanced TPP
a
Press F1, INSERT and choose the appropriate parenthesis.
Mixed Logic
1/4
1 (
2 DI[ ]
3 DO[ ]
4 R[]
SF[]
6 on
7 Off
8 ~-next page--
b
If the number of parentheses are not an even number total, then the error
Parentheses mismatch will appear.
=
MIXED_MAIN
1:
:t-._
1/2
WAIT (DI[l:Mach
1 Door Open] AND
(!DI[~:Mach
2 Door Open] OR
DI[3:Mach
3 Door Open])
TIMEOUT,.LBL[10]
[B
[End]
Parentheses
c
mismatch
To complete the order of operations, move to the end of the priority items.
MIXED _MAIN
1:
=
+~.
1/2
WAIT (DI[l:Mach
1 Door Open] AND
(!DI[2:Mach
2 Door Open] OR
DI[3:Mach 3 Door Open]D
TIMEOUT,LBL[lO]
[B
[End]
d
Press F1 INSERT and choose the appropriate parenthesis.
MATOGATPP12191E
FANUC America Corporation© Copyright 2019: DO NOT DUPLICATE
137
7: Mixed and BG Logic
,' Mixed Logic
Advanced TPP
1/3
1 )
2ANO
3 OR
4+
s6*
7/
8 --next page--
IMIXED _MAIN
+~
1:
.
WAIT (DI[1:Mach
1 Door Open]
(!DI[2:Ma.ch
2 Door Open] OR
DI[3:Mach
3 Door Open])I
TIMEOUT,LBL [10]
1/2
AND
=
[8
[End]
7.2. 7
Mixed Logic Error Messages
The compiler checks the instructions when executed for validity, the below list are the
possible error messages when executing mixed logic instructions.
Error Message
Parenthesis Mismatch
Invalid Index
Variable Type
Mismatch
Invalid Parameter
Name
UntauQht Element
Invalid Motion Group
Invalid Item for Output
Invalid Item for Mixed
LoQic
Syntax Error
138
Explanation
The number of left parenthesis and right parenthesis are not
same.
Index number is not correct.
Data type is not correct for the operator.
System variable name is not correct.
Empty item( ...) exists.
The specified motion group of PR[] is not available for the
proQram.
The left side item of assignment statement is invalid.
The item cannot be used in Mixed Logical expression.
Invalid statement
MATOGATPP12191E
FANUC AmericaCorporation© Copyright2019: DO NOT DUPLICATE
7: Mixed and BG Logic
Advanced TPP
7.3
Background Logic Overview
Background logic (BG Logic) allows any teach pendant program that includes only mixed logic
statements to be executed in the background. The program is executed from beginning to end
repeatedly. This execution is not affected by E-STOP, HOLD, or any alarms.
There are two execution modes in Background Logic, Normal mode and High-level mode.
•
Normal Mode
All mixed logic instructions can be executed in the background. The
number of items that can be processed every ITP, (ITP is normally 8
msec) in normal mode, is dependent on the total number of items to
be scanned in Normal and High-Level modes. An "item" is data, an
operator or an allowed instruction.
•
High Level Mode
All mixed logic instructions can be executed in the background. Up to
540 items are processed every 8 msec
Mode
Max# items
Scanning Time
Normal
Mode
No
Limitation
(Total Num. of
items/ 600) * ITP
Number of items
means the total
items in all
background logic
programs.
(Normal and
High). ITP is
normally 8 msec.
HighLevel
Mode
7.3.1
540
8 msec
Available
Available
Data
Operators
F[], M[]*, DID, (, ), !, AND,
DO[], Al[],
OR,=,<>,<,
AO[],
< = > >=
' ' '
Gl[],GO[],
+,-, *,/,
SI[], SO[],
DIV, MOD
UI[], UO[],
RI[], RO[]
WI □, WO[]
On, Off R[],
PR[i.j], AR[]
Constant
Parameter
Timer, Timer
overrun
Same as
Same as
Normal Mode Normal Mode
Available
Instructions
All Mixed
Logic
Operations
JMP LBL[ ...]
(Only jumping
in the down
direction),
RUN,
UALRM[ ...]
Same as
Normal Mode
BG Logic Limitations/Restrictions
•
M[ ] cannot be specified as left side of assignment statement in background logic.
•
8 programs can be executed as Background Logic at the same time.
•
If the program includes anything but allowed statements, "INTP-443 Invalid item for
Mixed Logic" error occurs at execution.
•
While a program is being executed in the background, the program cannot be edited,
and the program cannot be executed as a normal task. If the program is not running in
the background, it can be run as a normal task in order to test it
MATOGATPP12191E
FANUC AmericaCorporation© Copyright2019: DO NOT DUPLICATE
139
7:. Mixed and ,BGLogic
AdvancedTPP
•
When a program is rur.mirig in the background, the program cannot be loaded as
overtvrite.
•
lfa program is executing as Background Logic at power down, the program is executed
at next power up automatically in the same execution mode.
•
The Background Logic execution occurs before normal program execution. The
Background Logic execution takes about 1 msec in every ITP. The background logic
execution may affect the cycle time of the normal program. To decrease the execution
time of Background Logic, change $MIX_LOGIC.$ITEM_COUNT to smaller value. The
default value of $MIX_LOGIC.$ITEM_COUNT is 600, which is the number of items
processed each ITP.
•
Assignment statements with the IF condition can be executed by Background Logic. The
. assignment statement is not executed when the condition is OFF. In the following
example:
:' IF (Dl[1]), DO[1]=(Dl[2])
The value of DO[1] is s_etto Dl[2] when D1[1] is ON, DO[1] is not changed when Dl[1] is
OFF.
•
•
Pulse instruction can be used in Background Logic. It can be combined with the IF
condition to create an OFF DELAY TIMER. In the example:
-IF(Dl[1]), D0[1]=Pulse 1sec
DO[1] has 1sec pulse when D1[1]stays ON more than 1 sec. If Dl[1] turns OFF before 1
sec, DO[1] tums OFF immediately. While D1[1] is OFF, this statement does not set
DO[1]. To keep DO[1]
for 1 sec even if Dl[1] turns OFF, use the following
statements.
on
F[1]=(D1[1] OR (F[1] AND DO[1]))
IF (F[1]), DO[1]=Pulse 1sec
•
If a Pulse instruction does not specify the time, it will be one scan pulse in Background
Logic execution. In the example:
IF (Dl[1]), DO[1]=Pulse
In this case, DO[1] becomes ON for only one scan when D1[1] is changed from OFF to
ON. This can be used as edge detection.
Pulse instruction without time means the pulse of $DEFPULSE in normal execution, so it
is different in Background Logic execution:
7.3.2
Setting Up Background Logic
In order to execute a program as BG Logic the program must be placed on the BG Logic
table.
140
MATOGATPP12191E
FANUC AmericaCorporation© Copyright2019: DO NOT DUPLICATE
7: Mixed and BG Logic
Advanced TPP
Background logic
+.. [E
Normal mode scan
PROGRAM
1
2
3
4
5
6
7
8
m
[ TYPE J
RUN
1/8
MODE
Normal
Normal
Normal
Normal
Nonnal
Normal
Nonnal
Normal
time:
8mseo
STATUS
Stop
Stop
Stop
Stop
Stop
Stop
Stop
Stop
STOP
[ CHOICE]
CLEAR
BG Lo ic Screen rtems
Description
Items
Pro ram
This item displays the status of the background logic program:
Status
•
Stop: The program is stopped
•
Running: The program is running in Normal mode.
• Runnin
ram is runnin •
Use this item to select the execution mode:
Mode
Function Key
RUN
STOP
CLEAR
• h-Level mode.
•
Normal: The program is always executed in Normal mode.
•
Default is "Normal". If you would like to execute the program in HighLevel mode but it is executed in Normal mode, set this item "High".
•
Hi
ram is alwa s executed in Hi h-Level mode.
BG Logic Screen Operations
Description
Press this key to execute the program as background logic. If it contains
statements that are not available in background mode, an error will be
posted.
Press this key to stop background execution of the program.
Press this key to remove a Background logic program from the list. (The
program must be in "STOP" mode before it can be removed.)
Procedure 7-2 Setting Up BG Logic
1
Press MENU.
a
Cursor to -6- SETUP.
MATOGATPP12191E
FANUC AmericaCorporation© Copyright2019: DO NOT DUPLICATE
141
7: Mixed and BG Logic
b
On the flyout menu highlight BG Logic
C
Press ENTER.
►I
MENU 1
1 UTILITIES
Advanced TPP
Background logic
+ [8
Norma.l JIIOde scan
1 Pro; Select
PROGRAM
1
►
S General
~I6 Coll Guard
6 SETUP
7 FILE
2
3
4
5
6
S iPendant Setup 1-------f
►f7~F~ram~e~s~--■■l-------j
7 Resume Offset
8 Macro
------i----------l8
9 USER
9 Ref Position
------i----------l9
0 -- NEXT -------"------lO
0 •• NEXT··
1--------1
7
8
Resume Toi.
Stroke limit
8msec
t1me:
STATUS
Stop
Stop
Stop
Stop
Stop
Stop
Stop
Stop
1/8
MODE
Normal
Normal
Normal
Normal
Normal
Normal
Normal
Normal
··NEXT··
·NEXT··
:::
( TYPE)
RUN
STOP
[ CtiOICE)
CLEAR
In the PROGRAM column, enter the name of the program you want to run as
Background Logic.
2
a
Press F4, [CHOICE] to get a listing of programs.
b
Select the desired program from the list.
~ NOTE: The STATUS column will display the status of the background logic program:
3
•
Stop: The program is stopped
•
Running: The program is running in Normal mode ..
•
Running (High): The program is running in High-Level mode.
In the MODE column, select the execution mode. Press F4, [CHOICE] to get a listing of
modes. Select the desired mode from the list.
•
Normal: The program is always executed in Normal mode.
•
High: The program is always executed in High-Level mode.
~ NOTE: The scanning time of Normal mode execution is displayed on the upper line of the
screen.
4
To run the program as background logic, press F2, RUN.
•
The program will run. If it contains statements that are not available in background
mode, an error will be posted.
5
To stop background execution of the program, press F3, STOP.
6
To remove a program from background execution, press FS, CLEAR.
7.4
Flag
Flags (F[]) are internal 1/0 ports that can be read and set. They are not connected to any actual
1/0 device, they are like a Boolean type variable.
142
MATOGATPP12191E
FANUC AmericaCorporation© Copyright 2019: DO NOT DUPLICATE
7: Mixed and BG Logic
AdvancedTPP
The value of flags can be recovered by Power Failure Recovery function (HOT Start). It is the
same as the other output ports, for example DO.
The following conditions set all Flags to OFF:
•
COLD start
•
CONTROL start
•
INIT start
•
1/0 assignment is changed, even though in HOT start.
•
1/0 configuration is changed, even though in HOT start.
DI, DO, UI, UO, GI and GO can be assigned to flags by configuring them as Rack 34, Slot 1,
Start point 1-1024.
When UI/UO are assigned to flags, program execution can be controlled by TP program or
Background Logic. In this case, when the flag assigned to Ul[6] is changed from ON to OFF,
Ul[6:STARTI is changed from ON to OFF, and the selected program is executed.
Procedure 7-3 Displaying the Flag Monitor Screen
1
Press MENU
a
Cursor to -5- 1/0
b
On the fly out menu highlight Flag
c
Press ENTER
#
F[
F[
F[
F(
F[
F[
F[
F[
F(
F[
F[
:::
f TYPE }
5/1024
STATUS
11
]
2]
3]
4]
5)
6]
7]
8)
9)
10)
11)
1
I
1
1
1
l
l
l
l
l
DEiAfL
ON
2
Press F4 to turn the Flag on or F5 to turn the Flag off.
3
To display the port detail menu, press F2, DETAIL.
OFF
MATOGA1PP12191E
FANUC AmericaCorporation© Copyright2019: DO NOT DUPLICATE
143
7: Mixed and BG Logic
AdvancedTPP
Outputs
+,
Port:
De=iJ.
Flag
I
1 comment:
i!i
~TYPE]
[B
1/1
5]
(
PRV-PT
Nxr
PT
At the detail screen you can add comments to the Flag.
4
7.4.1
Programming a Flag Instruction
Flags can be used in a normal TP program as well as in TP program intended to be
executed in BG Logic.
When using Flags in BG Logic fast mode has better performance than Normal mode, and
fast mode does not affect the performance of normal program execution. But Fast mode
cannot use numerical operation and Pulse instruction.
The following program is edge detection of DI[1]. DO[1] becomes ON only when DI[1] is
changed from OFF to ON.
•= 2:
DO[ll=(DI[l]
F[l]=fDI[l])
AND !F[ll)
(End]
F[1] has the DI[1] value of the previous scan. DO[1] becomes ON when DI[1] is ON and the
previous value of D1[1] is OFF. The below procedure will demonstrate how to code line 2.
Procedure 7-4 Programming a Flag Instruction
1
At the EDIT screen press F1 [INST], if F1 does not display [INST] press next.
~lA<i_tXAMPLt
•
=:l}J
2/2
lll
I Regisbn
7 Misc:ell~eou,
---------,,tpage--
144
>-----P-t
P"'98··
MATOGATPP12191E
FANUC AmericaCorporation© Copyright2019: DO NOT DUPLICATE
7: Mixed and BG Logic
Advanced TPP
2
Choose the Flag template (F[ ]=( ... ))
2 R[ J=OI[ ]
3 RO"
J-=...
4 R[ j-:=RI[ :
5 GOf J=...
6 R( }=GI{ ]
7 AO[ ·= ...
8 ··next page-8 ··next page-- '---,----~
3
Quantify the Flag to use.
4
Fill in the mixed logic portion as necessary.
l {
20J(
J
J 00(
-------i
4 RI)
J
>------<>1EILOVERFLOW
-----
1-----
S F, J
1-----
-------i]
6 On
--------!
7 Off
-------1ext
8 ··next page-·
2:
7.5
1-----
1-------<i,j]
>------
J
>------<ext
page··
1--------1ext
page--
page··
F[1]=(DI[1JD
Marker
The Marker Screen allows you to monitor the status of Markers.
Marker (M[]) is similar to flag, but the value of markers is not set directly. When Marker (M[]) is
specified in the left side of an assignment(=) in a TP program and the statement is executed,
the expressions are defined as Background Logic internally, and the expression is executed
repeatedly. The marker (M[ ]) always has the result of the expression.
By default, the Marker function is disabled, the Marker menu is not displayed, and M[] cannot
be taught in TP program. To use the Marker function, set $MIX_LOGIC.$USE_MKR to
TRUE.
Example:
M[1]=(D1[1] AND D1[2])
MATOGATPP12191E
FANUC AmericaCorporation© Copyright2019: DO NOT DUPLICATE
145
7:
Mixed
and
BG
Logic
AdvancedTPP
After this line is executed in a normal TP program (not in Background Logic), M[1] always has
the result of the right side expression. When both DI[1] and D1[2] are ON, M[1] is ON, in the
other case M[1] is OFF.
•
When a Marker assignment statement is executed in a normal TP program, the
statement is registered to Background Logic. The statement is executed as Background
Logic until another expression redefines the marker. Execution of the statement does not
stop even though the program is paused or aborted, because it is Background Logic.
•
By default, there are 8 markers (M[1]-M[8]). The number of markers can be changed by
system variable "$MIX_LOGIC.$NUM_MARKERS". Maximum number of markers is
100. One marker takes 300bytes permanent memory pool.
•
The scanning time to calculate a marker assignment statement is the same as the
scanning time of Normal mode Background Logic. Having marker assignment
statements defined affects the scan time of background logic.
•
Clear the defined marker expression to stop the calculation. To clear the defined
expression, execute the CLEAR operation in the Marker detail menu or execute the
following line of TP program.
M[1]=()
•
If a marker is not assigned to an expression and the marker is used in another
statement, the "INTP-347 Read 1/0 value failed" error occurs when the marker value is
read.
•
M[] cannot be specified in the left side of assignment statement in Background Logic.
Procedure 7-5 Displaying the Marker Monitor Screen
1
Press MENU
a
Cursor to -5- 1/0
b
On the fly out menu highlight Marker
~ NOTE: If Marker is not displayed on the 1/0 menu $MIX_LOGIC.$USE_MKR must be set
to true. Changes to this variable take effect immediately, you do not need to cycle power.
$MIX_LOGIC
1 $USE_FLG
2 $USE_KKR
2
146
2/25
TRUE
TRUE
Press ENTER.
MATOGA1PP12191E
FANUCAmericaCorporation© Copyright2019: DO NOT DUPLICATE
7: Mixed and BG Logic
Advanced TPP
+•. [B
Marker
I
K[
K[
K[
K[
M[
Kl
M[
K[
;;;
•••
1]
2]
]
[
(
[
[
{
[
[
[
3]
4]
5]
6]
7]
8)
[ TYPE )
1/8
STATUS
J
]
]
)
]
]
)
DETAIL
To display the port detail menu, press F2, DETAIL.
3
+._ [B
Port detail
1/5
Marker
[
1]
Comment:
Expression:
M[l)=(DI[l}
AND !DI[2])
Monitor:
M[l]
DI[l]
DI[2]
•••
:::
[ TYPE ]
OFF
OFF
OFF
PRV·PT
NXT·PT
CLEAR
4
At the detail screen if the monitor has been executed in a TP program it has been
registered in BG Logic and can be viewed from here.
5
The status of the Marker is displayed under the monitor heading.
6
To clear the Marker press FS, CLEAR.
a
Verify yes to clear the expression by pressing F4, YES.
MATOGATPP12191E
FANUC America Corporation© Copyright 2019: 00 NOT DUPLICATE
147
7: Mixed and BG Logic
7.6
AdvancedTPP
Chapter Review
1. What is the maximum number of items (data or operators) in a mixed
logic IF statement approximately?
A
5
B
10
C
20
D
50
2. When using mixed logic, which of the below operators has the highest
priority?
A
AND
B
OR
C
D
<
3. Background logic (BG Logic) allows any teach pendant program that
includes what type of instructions to be executed in the background?
A
All TPP instructions are allowed.
B
Only Motion Instructions are allowed
C
Only Non-Motion Instructions are allowed
D
Only Mixed Logic Instructions
4. When using Background Logic, an "item" is defined as what?
148
A
Data, an operator, or an allowed instruction.
B
A program.
C
A line of code.
D
The result of an instruction.
MATOGATPP12191E
FANUC America Corporation© Copyright 2019:DO NOT DUPLICATE
7: Mixed and BG Logic
Advanced TPP
Lab 9
Understanding Mixed Logic Instructions
Student Name:
Assignment:
--------------------The student will:
•
Condition:
Step:
Create Mixed Logic instructions
Given a FANUC Robot and a controller
1
1:
2:
3:
4:
5:
6:
7:
8:
9·
10::
Create the instructions shown below in your own .TP program.
R[l0]=(DO[l]
AND D0[2] 1)
R[ll]=(DO[l]
OR DO[2] AND 00[3])
D0[4]=(R[1]+5*2)
R[4]=(R[1)+5*2)
IF (R[5]=1),00[5]=(ON)
IF (D0[6])
THEN
R[7]=1
ELSE
R[8]=1
ENDIF
2
Set DO [2] and DO [6] to ON from the 1/0 menu.
3
Set R [1] to a value of two and R [5] to a value of 1.
4
Execute the program.
R [10] = 0, why?
R [11] = 0, why?
DO [4] is ON, why?
R [4] = 12, why?
DO [5] is ON, why?
R [7] = 1, why?
MATOGATPP12191E
FANUC AmericaCorporation© Copyright2019: 00 NOT DUPUCAlE
149
7: Mixed and BG Logic
5
Advanced
Manipulate the DO's and Registers to get different results from these
lines of mixed logic.
Completed: D
Instructor: -------------
150
MATOGATPP12191E
FANUC
TPP
America Corporation© Copyright
2019:
DO
NOT
DUPLICATE
7: Mixed and BG Logic
Advanced TPP
Lab 10
Creating Mixed Logic Instructions
Student Name:
Assignment:
---------------------The student will:
•
Condition:
Step:
Create a Mixed Logic Instruction
Given a FANUC Robot and a controller
1
Created a program called TOGGLE_GRIPPER.
2
Using only Mixed Logic Instructions:
3
a
If the gripper is open, close the gripper.
b
If the gripper is closed, open the gripper.
Assign this program as a MACRO to UK1.
Completed: D
Instructor:
--------------
MA.TOGA1PP12191E
FANUC AmericaCorporation© Copyright2019: DO NOT DUPLICATE
151
7: Mixed and BG Logic
Advanced TPP
Lab 11
Background Logic
Student Name: ---------------------Assignment:
The student will:
•
Condition:
Step:
Create a Background Logic Program
Given a FANUC Robot and a controller
1
Create a program called BG_LOGIC.
2
Create an instruction that checks if DI [41] and DI [42] are ON, turn on
DO [41].
3
Assign this program to BG_LOGIC and execute.
4
Using the metallic cylinders provided by your instructor, activate DI [41]
and DI [42]. Did DO [41] turn on?
Completed: D
Instructor:
152
--------------
MATOGATPP12191E
FANUC AmericaCorporation© Copyright2019: DO NOT DUPLICATE
Download