View Full Version : How do I use AND in a program?


g-codeguy
04-07-2009, 10:39 PM
I've looked in the Fanuc manual and in Peter Smid's book for Fanuc Macro B programming, but can't find an example. Both say that the output value is 1 if true, and 0 if false. Not much help. I have to assume these values aren't stored anywhere, or one of the books would have mentioned that little fact.

Can I use AND in IF[...AND...]GOTO or IF[,,,AND...]THEN type of statements?

Thanks.

cogsman1
04-10-2009, 06:19 PM
You would use this for checking multiple values.

IF[#100EQ.9999]AND[#101EQ.8888]GOTO1234

If BOTH values are as stated then and only then will it jump to N1234. If they do NOT both equal those values then it will advance to the next line of code.
Not all controls will allow this feature even though macro is available.

g-codeguy
04-11-2009, 01:11 AM
You would use this for checking multiple values.

IF[#100EQ.9999]AND[#101EQ.8888]GOTO1234

If BOTH values are as stated then and only then will it jump to N1234. If they do NOT both equal those values then it will advance to the next line of code.
Not all controls will allow this feature even though macro is available.

Will give it a try. Posted the same question on the "General Machining" forum. I may have to change a parameter to be able to use such a statement.

Will take a bit longer to finish my Macro subroutine, as it is a bit involved. At least for me. :D What is done was written while I was on vacation. Will try to post my results once finished.

dpuch
04-14-2009, 08:13 PM
Some additional info, you should be able to nest to at least 4 sets of brackets on fanuc and probably the rest as well.

IF [#100EQ.9999]AND[[#101EQ.8888]OR[#101EQ#[#105]]] GOTO1234

Just added an OR, and random variable usage on the lase EQ statement to show 3 deep nesting.

g-codeguy
04-15-2009, 09:12 AM
Some additional info, you should be able to nest to at least 4 sets of brackets on fanuc and probably the rest as well.

IF [#100EQ.9999]AND[[#101EQ.8888]OR[#101EQ#[#105]]] GOTO1234

Just added an OR, and random variable usage on the lase EQ statement to show 3 deep nesting.



I will give your example a try, but this is what I got from the Fanuc tech.

In Macro B, the AND/OR/XOR statements are bitwise operators, used as one would a math function, such as:

#1=#2 AND 8;

and this

They actually do it bit by bit. I will show this as 8 bit binary data:

#2=155 or 10011011
8 would be 00001000

ANDing them together would give 00001000

I dropped the decimal point as floating point math and bitwise operations don't mix well

dpuch
04-15-2009, 03:59 PM
Yes, the statement will distill down to a bitwise and/or line
IF [#100EQ.9999]AND[[#101EQ.8888]OR[#101EQ#[#105]]] GOTO1234
IF [1]AND[[0]or[1]] goto 1234
IF [1] goto 1234

But it is only one bit 0 or 1 (meaning yes or no for each comparison) unless you do something weird.

sinha_nsit
09-25-2009, 07:02 AM
AND, OR and XOR can be used as logical functions also depending on a parameter setting. On Fanuc 0i series, 6006#0 should be 1, otherwise only bitwise operation would be possible. On other controls, parameter number might be different.