585,591 active members*
2,575 visitors online*
Register for free
Login
IndustryArena Forum > Machine Controllers Software and Solutions > Fanuc > Help with with using an m code and canceling it with a macro
Results 1 to 9 of 9
  1. #1
    Join Date
    Dec 2015
    Posts
    7

    Help with with using an m code and canceling it with a macro

    Hello,
    I am trying to implement a arduino controlled Hass indexing head into the g code for indexing. I have an arduino running a stepper motor index head. I have a fanuc 0mc on a supermax max 3 mill. The MTB has supplied a couple of m codes that can be used. M40, M80. I can call a M40 and it will turn on a relay to activate the index cycle on the head. The ladder then requires a limit switch input to turn off the m40 code and continue with the g code. According to the ladder diagram when m40 is called It turns on r538.2. I am not very familiar with Macros. The machine has macro a. From reading the fanuc manual it looks like you can manipulate some register bits with macros. I am not sure if this one is one of them or not.

    What I am trying to do is call m40 in the code and use a g04 to set a dwell time as a variable while the index head makes its move, say one second or so. Then cancel the m40 command so that the g code continues on until the next indexing command. Is this something that is possible or is the only way to cancel this type of command through a limit switch input being x20.2.

    Any help would be greatly appreciated.
    Thanks
    Scott

  2. #2
    Join Date
    Dec 2015
    Posts
    7

    Re: Help with with using an m code and canceling it with a macro

    here is a pic of the ladder it may help

  3. #3

    Re: Help with with using an m code and canceling it with a macro

    Yes you are correct. You must have x20.2 go high (on) in order to fin out the M40.

  4. #4
    Join Date
    Dec 2005
    Posts
    7
    I got that much figured out. I need to know if that is the only way to cancel an m code like this. I was wondering of there was a way to change the register value that holds the m40 code without a physical input.
    Scott

  5. #5
    Join Date
    Feb 2013
    Posts
    151

    Re: Help with with using an m code and canceling it with a macro

    Scott,

    I don't think you need a limit switch... you just need to fire x20.2 for a second to have the mill continue on. A relay or mosfet transistor output on your Arduino would work. Using the M40 finished input seems safer if your Auduino faults out during the move... With only a delay, the machine would continue on regardless of whether or not your part is correctly orientated. Just something to think about.

    Cj

  6. #6
    Join Date
    Dec 2015
    Posts
    7

    Re: Help with with using an m code and canceling it with a macro

    I think I have got a solution. I changed the arduino code so that after it makes its move it activates a relay which will be hooked to x20.2 like you mentioned. I have it set for a 100ms pulse right now, I am assuming that will be plenty long enough to cancel m40. bench testing everything works well the next step is to hook things up to the machine and try it out.

    Does anyone know if you can program a macro with macro a to count indexes and then stop the code after say 72 index events? From what I can tell you can put the number of index events into a variable and then count and compare with the macro until the desired number has been reached. Then a goto command to a portion of the code to finish the g code program.
    Thanks
    Scott

  7. #7
    Join Date
    Feb 2013
    Posts
    151

    Re: Help with with using an m code and canceling it with a macro

    Scott,

    Yes you can program in a counter... you don't even need a macro to do it. You have the basic idea already. I just did this a couple of months ago to cut 31 splines on a shaft. I'll post the code after I get a chance to copy it off the mill. You may need to make a couple of changes as I'm using an 11m, but otherwise it should be pretty close.

    Cj

  8. #8
    Join Date
    Dec 2005
    Posts
    7

    Re: Help with with using an m code and canceling it with a macro

    I would appreciate that thanks.
    Scott

  9. #9
    Join Date
    Feb 2013
    Posts
    151

    Re: Help with with using an m code and canceling it with a macro

    Scott,

    Here it is..

    %
    O0100
    (SPLINE PROGRAM7-23-2018)
    ( +++ USE M01 +++ )
    (USE T6M6)
    N3G0G40G80G91G28Z0
    G90G55X4.35Y-3.8
    G43Z6.0H6S100
    G1Z4.0F2.0
    #100=1 <- variable setup
    WHILE[#100LE31]DO1 <- while loop
    M3
    G1Y-3.693F0.5M8
    X7.25F1.0
    G0Y-3.8
    X4.35
    G1Y-3.69F0.5
    X7.25F1.0
    G0Y-3.8
    X4.35M5
    M9
    M01 <- I don't have an automatic indexer so I was using the optional stop to catch the machine in between splines. I would put the M40 here or on a line after the M01. Then you can stop the machine if you need to at the end of one of the indexing operations..
    #100=#100+1 <- counter increment loop
    END1 <- end of while loop
    G0Z7.0
    G91G28Z0M19
    G91G28X0Y0
    M30
    %

    Here is a picture of the setup just for reference. You can see my poor man's indexer on the far side. Worked out really well.
    Attachment 416440

Similar Threads

  1. Replies: 3
    Last Post: 08-26-2016, 12:36 PM
  2. Canceling program input? 0m
    By landslide1 in forum Fanuc
    Replies: 6
    Last Post: 07-03-2013, 04:56 AM
  3. Help with macro code...
    By sicknote in forum G-Code Programing
    Replies: 0
    Last Post: 11-26-2010, 10:12 PM
  4. canceling tool offsets
    By howling60 in forum CamSoft Products
    Replies: 4
    Last Post: 04-04-2006, 08:33 PM
  5. Canceling G54 offsets....
    By howling60 in forum CamSoft Products
    Replies: 6
    Last Post: 12-15-2005, 01:11 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •