Results 1 to 11 of 11

Thread: SIMPLE MACRO QUESTION

  1. #1
    Registered
    Join Date
    Oct 2008
    Location
    USA
    Posts
    25
    Downloads
    0
    Uploads
    0

    SIMPLE MACRO QUESTION

    We are setting up a program in a sub-spindle lathe for parts where some get tapped in one end and some in both. We are using a simple macro where 1= a tap in both ends and 0= not tapping the part in both ends:

    IF[#509 EQ 1]GOTO 10
    IF[#509 EQ 0]GOTO 20
    N10 (TAP ON SUB-SPINDLE)
    N20 M30

    A fairly simple direct approach, right?
    What we found by "accident proofing" the program is if the variable is anything other than a 1 (ex. 22) but not 0, the control will read right thru the variables like they weren't there and continue to N10. We were expecting an alarm to fire at that point. I know that we could put in a conditional branch to set off our own alarm, but were very surprised that when the control didn't see either it didn't throw it's own. It does work as expected with the 0.
    We've tried this on both a Fanuc 21i and 18i and it reacts the same.
    Anyone else run into this issue?


  2. #2
    Registered beege's Avatar
    Join Date
    Feb 2008
    Location
    USA
    Posts
    546
    Downloads
    0
    Uploads
    0
    Looks like, if you follow the logic, if #509 is any number other than 0 or 1, it will just step thru each block, with no re-direction at all.

    IF[#509 EQ 1]GOTO 10
    IF[#509 EQ 0]GOTO 20
    #3000=1(CHECK VARIABLE # 509 FOR EITHER A 0 OR 1)
    N10 (TAP ON SUB-SPINDLE)
    N20 M30

    and get your alarm.


  3. #3
    Registered
    Join Date
    Jun 2008
    Location
    United States
    Posts
    1,509
    Downloads
    0
    Uploads
    0
    As Beege has already pointed out the conditions were not met so the program will not jump. This is not abnormal. That is how the code works. If the conditions are not met you cannot expect an alarm. Look at it this way. If you were expecting an alarm to generate because the condition was not met then imagine if #509 was set =0 the program would alarm out on IF[#509EQ1]GOTO10.

    You could add more conditions as you stated so it will alarm or jump to a message something like
    IF[#509GT1]GOTO()
    IF[#509LT0]GOTO()
    IF[#509EQ#0]GOTO()

    However Beege has the perfect example of how it should be set.

    The question you should probably ask yourself is why is #509 set to something other than 1 or 0 if you are using it. Correct that problem first.

    Stevo


  4. #4
    Registered
    Join Date
    Oct 2008
    Location
    USA
    Posts
    25
    Downloads
    0
    Uploads
    0
    Thanks Beege
    I guess we assumed that the control had some sort of embedded code where if it didn't have the proper information it would alarm. Didn't think of the lack of re-direction. We did in fact write in our own alarm.


  • #5
    Registered
    Join Date
    May 2007
    Location
    US
    Posts
    779
    Downloads
    0
    Uploads
    0
    If you just want to turn the tap cycle ON or OFF I would likly do it like this.
    If you want it to tap make sure #509 is a 1, anything else and it skips the tap cycle.
    Code:
    IF[#509 EQ 1]GOTO 10
    GOTO 20
    N10 (TAP ON SUB-SPINDLE)
    N20 M30


  • #6
    Registered
    Join Date
    Feb 2008
    Location
    The Edge of Obscurity
    Posts
    240
    Downloads
    0
    Uploads
    0
    Quote Originally Posted by Andre' B View Post
    If you just want to turn the tap cycle ON or OFF I would likly do it like this.
    If you want it to tap make sure #509 is a 1, anything else and it skips the tap cycle.
    Code:
    IF[#509 EQ 1]GOTO 10
    GOTO 20
    N10 (TAP ON SUB-SPINDLE)
    N20 M30


    You could take it one step further and say that if #509 IS NOT = 1 then skip...

    Code:
    IF[#509 NE1]GOTO20
    (TAP ON SUB-SPINDLE)
    N20 M30
    Control the process, not the product!
    Machining is more science than art, master the science and the artistry will be evident.


  • #7
    Registered
    Join Date
    Jun 2008
    Location
    United States
    Posts
    1,509
    Downloads
    0
    Uploads
    0
    Now we are splitting hairs. That’s why I love macro’s.

    Everything suggested will Net the same result. I would just like to throw in my 2cents as to why I would use Beege’s suggestion based on my experience.

    If you are going to designate a variable for a specific function then the proper checks must be made to ensure that it is set to a value in the range you are expecting. Depending on how much user interface the macros have you want to be able to halt an operation if something is amiss. That is what Beege’s suggestion does. If #509 is used as 1 or 0 and nothing else then stop the program if it is anything other than 1 or 0.

    If #509 ends up being something other than 1 or 0 then something or someone has changed the process and it should be stopped to verify what is happening.

    This may sound unbelievable but I have gone into shops to setup or streamline and I have seen the same variable used for a check in 1 macro and a Z clearance in another. Disaster!!! Don’t get me wrong I have made my share of mistakes. On a large project of having about 30 programs run together with all of the variables constantly changing I lost track of a lot of the current and changing values of them and had to insert a small sub to actually clear them out before running a process.

    Stevo


  • #8
    Registered
    Join Date
    Apr 2008
    Location
    USA
    Posts
    49
    Downloads
    0
    Uploads
    0
    How about something like this..


    N1
    #100=ABS[#509]
    IF[#100 GT 1] GOTO 11
    IF[#100 EQ 0]GOTO 20
    GOTO 10

    N11
    ( ....INVALID ENTRIES, TRY AGAIN ...)
    M00
    GOTO 1


    N10 (TAP ON SUB-SPINDLE)
    N20 M30


  • #9
    Registered
    Join Date
    May 2007
    Location
    Thailand
    Posts
    251
    Downloads
    0
    Uploads
    0

    Smile

    Dear All,
    If I need to learn VB to control mach3 for lathe&mill,how to begin? pls advise.

    Mongkol


  • #10
    Registered
    Join Date
    Jun 2008
    Location
    United States
    Posts
    1,509
    Downloads
    0
    Uploads
    0
    Yup...that will work to. Same result as Beege below except its less code. The other thing you have to remember is that if #509 was set to null then #100 would be null and not all controls would view null=0 when comparing in a IF statement so you would have to have another IF statement to account for null.

    Quote Originally Posted by guru View Post
    How about something like this..
    N1
    #100=ABS[#509]
    IF[#100 GT 1] GOTO 11
    IF[#100 EQ 0]GOTO 20
    GOTO 10

    N11
    ( ....INVALID ENTRIES, TRY AGAIN ...)
    M00
    GOTO 1


    N10 (TAP ON SUB-SPINDLE)
    N20 M30

    Quote Originally Posted by beege View Post
    IF[#509 EQ 1]GOTO 10
    IF[#509 EQ 0]GOTO 20
    #3000=1(CHECK VARIABLE # 509 FOR EITHER A 0 OR 1)
    N10 (TAP ON SUB-SPINDLE)
    N20 M30


  • #11
    Registered
    Join Date
    Jun 2008
    Location
    United States
    Posts
    1,509
    Downloads
    0
    Uploads
    0
    Mongkol...you are best off starting a new thread asking that question. I believe there is a mach3 forum here that you could post it on. Most people are not going to be looking for your question in a thread not pretaining to your question.

    Quote Originally Posted by Mongkol View Post
    Dear All,
    If I need to learn VB to control mach3 for lathe&mill,how to begin? pls advise.

    Mongkol


  • Similar Threads

    1. a simple but big question
      By pato feo in forum Forum Questions or Problems
      Replies: 0
      Last Post: 05-11-2009, 10:55 PM
    2. Newbie- Probably a very simple question
      By Soloratov in forum General Metal Working Machines
      Replies: 2
      Last Post: 03-29-2009, 08:07 PM
    3. just one simple question..
      By nascarstewartfa in forum General Waterjet
      Replies: 1
      Last Post: 10-30-2008, 03:43 PM
    4. Simple question
      By monte55 in forum Xylotex
      Replies: 2
      Last Post: 12-02-2006, 09:38 PM
    5. Simple Question Simple Answer ?
      By p3t3rv in forum Stepper Motors and Drives
      Replies: 6
      Last Post: 02-16-2006, 10:00 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.