I am writing a macro tutorial for my trainees and am testing syntax on my machines with a Fanuc 0i-TD control.
The following syntaxes failed. Can you see anything wrong with these statements?
IF[[#105NE1]OR[#105NE2]]THEN#3000=5(INVALID TAB NUMBER. MUST BE 1 OR 2)
IF[[#105GE1]OR[#105LE2]]THEN#3000=5(INVALID TAB NUMBER. MUST BE 1 OR 2)
IF[[#105GT1]OR[#105LT2]]THEN#3000=5(INVALID TAB NUMBER. MUST BE 1 OR 2)
IF[[#105NE101]OR[#105NE202]OR[#105NE303]]THEN#3000=1(BAD TOOL/OFFSET NUMBER. MUST BE 0101, 0202, OR 0303)
IF[[#105NE101.]OR[#105NE202.]OR[#105NE303.]]THEN#3000=1(BAD TOOL/OFFSET NUMBER. MUST BE 0101, 0202, OR 0303)
The issue is that even when the logic is true and no alarm should generate, the alarm still appears. For example, in the first example I set #105=1.000 but the alarm still appeared.
For comparison, the following syntax worked as expected
IF[[#105EQ1]OR[#105EQ2]OR[#105EQ3]OR[#105EQ4]OR[#105EQ5]]GOTO1123
#3000=1(INVALID TAB NUMBER. MUST BE 1,2,3,4,OR 5)
N1123
IF[#26EQ#0]THEN#3000=1(ERROR: Z LOCATION MISSING IN G101 LINE)
IF[[#105GT1000]AND[#500LE2000]]THEN#600=202
IF[[#105EQ101]OR[#105EQ202]OR[#105EQ303]]GOTO110
#3000=1(BAD TOOL/OFFSET NUMBER. MUST BE 0101, 0202, OR 0303)
N110
Based on what worked or failed, it seems as if I cannot use IF/OR/THEN but I can use IF/AND/THEN. Can anyone confirm this or is there a parameter setting or syntax error im not seeing?
Thanks in advance
Similar Threads:
- how to shut off Fapt on a 1999 daewoo with FANUC Puma 200 with FANUC 18T control
- Need Help!- Fanuc Robocut Alpha 0B with Fanuc Series 16-W control 910 SRAM Parity System Error
- Weird Rs232 issue/Mystery with Fanuc 6M on Mori Seiki . Calling all Fanuc Masters !
- Need Help!- Fanuc drill tap center equipped with Fanuc OM-C i/o card details
- can fanuc ac digital servo amplifiers be run by a controller other than fanuc?
CNC Product Manager / Training Consultant
is there more of the macro then what is here ?
the reason i ask is because the first 3 statements have #105 at 1 or 2 but the last 2 statements have it at 101,202,303
IF[[#105NE1]OR[#105NE2]]THEN#3000=5(INVALID TAB NUMBER. MUST BE 1 OR 2)--------this seems ok as it is not equal to 1,2 then alarm
IF[[#105GE1]OR[#105LE2]]THEN#3000=5(INVALID TAB NUMBER. MUST BE 1 OR 2)-------this one is less than or equal to 1 and 2 then alarm it should alarm out with a 1 or a 2
IF[[#105GT1]OR[#105LT2]]THEN#3000=5(INVALID TAB NUMBER. MUST BE 1 OR 2)------this one there is a conflict in the statements-- 1st has to be greater then 1 where as statement 2 must be less then 2 so it can not be a 1 or a 2
IF[[#105NE101]OR[#105NE202]OR[#105NE303]]THEN#3000=1(BAD TOOL/OFFSET NUMBER. MUST BE 0101, 0202, OR 0303)
IF[[#105NE101.]OR[#105NE202.]OR[#105NE303.]]THEN#3000=1(BAD TOOL/OFFSET NUMBER. MUST BE 0101, 0202, OR 0303)
The OR statement will process the THEN command if either of the conditions are true.
So if #105=1,
IF[[#105NE1]OR[#105NE2]]THEN#3000=5(INVALID TAB NUMBER. MUST BE 1 OR 2)
Is going to run the #3000 error, since #105 is not equal to 2. Likewise, if #105=2, it's still going to error because #105 is not equal to 1. If #105 is anything else, both statements are true and it will still process the error call.
IF[[#105LT1]OR[#105GT2]]THEN#3000=5
If #105 is greater than 2, or less than 1, set #3000 to 5.
For your code to work, perhaps try replacing the OR with an AND.
I'll try to break down all.
IF[[#105NE1]OR[#105NE2]]THEN#3000=5(INVALID TAB NUMBER. MUST BE 1 OR 2)
Replace "OR" with "AND".
IF[[#105GE1]OR[#105LE2]]THEN#3000=5(INVALID TAB NUMBER. MUST BE 1 OR 2)
No need for that one. What you're saying (spelling it out works wonders!) is "if x is 1 or above, or if x is 2 or below, then ERROR. But if you want this type of code, you can use:
IF [[#105LT1] OR [#105GT2] OR [FIX[#105]NE#105] THEN#3000=5(INVALID TAB NUMBER. MUST BE 1 OR 2)
Reason for "OR [FIX[#105]NE#105]" is I assume you want an integer, not "1.009"? Good thing about this way of coding is you can make it accept numbers 1...10, for example.
IF[[#105GT1]OR[#105LT2]]THEN#3000=5(INVALID TAB NUMBER. MUST BE 1 OR 2)
Same reasoning applies. Check above examples.
IF[[#105NE101]OR[#105NE202]OR[#105NE303]]THEN#3000=1(BAD TOOL/OFFSET NUMBER. MUST BE 0101, 0202, OR 0303)
Again, just replace OR with AND and you're fine.
IF[[#105NE101.]OR[#105NE202.]OR[#105NE303.]]THEN#3000=1(BAD TOOL/OFFSET NUMBER. MUST BE 0101, 0202, OR 0303)
Redundant.
I may have left out a "[" or something, just scribbling in Chrome. And it seems most is already answered by others, hah. Plus the question is two months old. Oh well.
Good luck!
It is two years old thread.