Results 1 to 7 of 7

Thread: How do I use AND in a program?

  1. #1
    Registered
    Join Date
    May 2007
    Location
    USA
    Posts
    939
    Downloads
    0
    Uploads
    0

    How do I use AND in a program?

    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.


  2. #2
    Registered
    Join Date
    Jan 2005
    Location
    USA
    Posts
    277
    Downloads
    0
    Uploads
    0
    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.


  3. #3
    Registered
    Join Date
    May 2007
    Location
    USA
    Posts
    939
    Downloads
    0
    Uploads
    0
    Quote Originally Posted by cogsman1 View Post
    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. What is done was written while I was on vacation. Will try to post my results once finished.


  4. #4
    Registered
    Join Date
    Feb 2006
    Location
    United States
    Posts
    293
    Downloads
    0
    Uploads
    0
    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.


  • #5
    Registered
    Join Date
    May 2007
    Location
    USA
    Posts
    939
    Downloads
    0
    Uploads
    0
    Quote Originally Posted by dpuch View Post
    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


  • #6
    Registered
    Join Date
    Feb 2006
    Location
    United States
    Posts
    293
    Downloads
    0
    Uploads
    0
    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.


  • #7
    Registered
    Join Date
    Feb 2006
    Location
    india
    Posts
    1,273
    Downloads
    0
    Uploads
    0
    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.


  • Similar Threads

    1. Mazatrol Program into a G Code Program
      By fuzzman in forum Mazak, Mitsubishi, Mazatrol
      Replies: 15
      Last Post: 09-25-2012, 11:27 AM
    2. Replies: 12
      Last Post: 03-14-2010, 09:19 PM
    3. Where should PROGRAM ZERO be?
      By max90272 in forum General CAM Discussion
      Replies: 5
      Last Post: 02-19-2009, 12:29 AM
    4. Program Restart in mid program?
      By Donkey Hotey in forum Haas Lathes
      Replies: 16
      Last Post: 03-18-2008, 03:19 PM
    5. Replies: 11
      Last Post: 10-09-2005, 12:45 AM

    Posting Permissions


     


    About CNCzone.com

      We are the largest and most active discussion forum from DIY CNC Machines to the Cad/Cam software to run them. The site is 100% free to join and use, so join today!

    Follow us on

    Facebook Dribbble RSS Feed


    Search Engine Friendly URLs by vBSEO ©2011, Crawlability, Inc.