M code to instate my G54 work offset
Close
Login to Your Account
Results 1 to 19 of 19
  1. #1
    Join Date
    Jul 2020
    Country
    UNITED STATES
    State/Province
    Iowa
    Posts
    12
    Post Thanks / Like
    Likes (Given)
    0
    Likes (Received)
    2

    Default M code to instate my G54 work offset

    I would like to type in an M code and have my G54 work coordinate instated in my Fanuc Oi-MD vertical mill. Example I indicate the center of a part using my dial test indicator, go to Work offset and inter the coordinate under G54, How do I create a program that when I type in a M code it calls up a program and runs it (using macro statements to do this), fdes anyone know of a resource for doing this.
    Thank Greg

  2. #2
    Join Date
    Jan 2007
    Country
    UNITED STATES
    State/Province
    New Jersey
    Posts
    1,271
    Post Thanks / Like
    Likes (Given)
    708
    Likes (Received)
    732

    Default

    Typically, all you need to do to call any work offset is to just use G54, G55, etc. That will instate that offset. If you are describing your needs accurately, you can specify your own M & G codes (ones that are NOT already used) and assign a program to be run to those M & G codes. It requires the G or M code number to be assigned to a parameter so when that G or M code is used, it will run that program. Check your Fanuc parameter manual. I don't have one near me at the moment.

    Paul

  3. #3
    Join Date
    Jan 2019
    Country
    UNITED STATES
    State/Province
    Missouri
    Posts
    408
    Post Thanks / Like
    Likes (Given)
    107
    Likes (Received)
    102

    Default

    Quote Originally Posted by GSMachinist View Post
    I would like to type in an M code and have my G54 work coordinate instated in my Fanuc Oi-MD vertical mill. Example I indicate the center of a part using my dial test indicator, go to Work offset and inter the coordinate under G54, How do I create a program that when I type in a M code it calls up a program and runs it (using macro statements to do this), fdes anyone know of a resource for doing this.
    Thank Greg
    parameters 6071 through 6089 set the m-codes to call programs 9001 through 9029

    Hint : 6071 is usually set to 6

    you will also have to set parameter 3202.4 to enable editing of 9000 series programs.

  4. #4
    Join Date
    Jun 2015
    Country
    UNITED STATES
    State/Province
    Minnesota
    Posts
    760
    Post Thanks / Like
    Likes (Given)
    12
    Likes (Received)
    268

    Default

    Perhaps you don't realize that as soon as G54 appears in your program your G54 Work Coordinates are instated. How is it that typing in an M code to bring about a G code is saving you anything? As long as G54 appears in your program before the first move, the machine will move within the confines of the numbers you have set in your G54 Work Coordinate Screen. Besides, most machines default to G54, so it's already active when you turn on the machine.

    Others have given you info on creating programs (which can include G codes) called by M code, but unless I'm missing something or you haven't accurately explained your needs, I can't see the reasoning or usefulness behind it.

    EDIT ADD: On your Check Screen or one of the screens, I can't remember which, you can see all of the active G and M codes. More likely then not G54 will already be showing there. Meaning it's active and instated.

  5. #5
    Join Date
    Jul 2020
    Country
    UNITED STATES
    State/Province
    Iowa
    Posts
    12
    Post Thanks / Like
    Likes (Given)
    0
    Likes (Received)
    2

    Default

    yes I am having trouble explaining my needs. I'll try again, clamp part to table, indicate bore, go to G54 work offset and move cursor to G54 X, input value by pressing "X" then input, then move cursor to G54 Y, input value by pressing "Y" then input. G54 work coordinate is set. Want I want to do is simplify this process by putting a M code statement in the top of the program before program reads any G54. So I am able to eliminate the process of setting the G54 work offset my self.

  6. #6
    Join Date
    Jan 2007
    Country
    UNITED STATES
    State/Province
    New Jersey
    Posts
    1,271
    Post Thanks / Like
    Likes (Given)
    708
    Likes (Received)
    732

    Default

    Quote Originally Posted by GSMachinist View Post
    yes I am having trouble explaining my needs. I'll try again, clamp part to table, indicate bore, go to G54 work offset and move cursor to G54 X, input value by pressing "X" then input, then move cursor to G54 Y, input value by pressing "Y" then input. G54 work coordinate is set. Want I want to do is simplify this process by putting a M code statement in the top of the program before program reads any G54. So I am able to eliminate the process of setting the G54 work offset my self.

    Sorry, still not quite understanding. You do know, by entering these numbers, you are actually writing to a parameter and a system variable. There is no way to do what you just described. You can, however, use the G10 command to write values to the offsets but somewhere, you still need to enter these manually. The best option in case you haven't thought of this, is to get a probe. Best money ever spent.

  7. #7
    Join Date
    May 2007
    Country
    UNITED STATES
    State/Province
    Massachusetts
    Posts
    931
    Post Thanks / Like
    Likes (Given)
    14
    Likes (Received)
    112

    Default

    I really hate telling anyone this, but you could use G92 instead. Put a G92 X0Y0 at the top of the program, indicate the center of your part and press go? I've never done that myself, because I don't like using G92. Someone will chime in and tell me I'm nuts, I'm sure

  8. Likes 706jim liked this post
  9. #8
    Join Date
    Jun 2015
    Country
    UNITED STATES
    State/Province
    Minnesota
    Posts
    760
    Post Thanks / Like
    Likes (Given)
    12
    Likes (Received)
    268

    Default

    Okay I see. Other then a probe, which are great, I believe there are system variables that always know what the current machine position is. If your machine is ready to make chips at the current position in X and Y, you should be able to read these and apply them to any offset you like with your program heading M code. You could also simply have a subroutine call M98P01 say, at the head of your programs, and store your macro in that sub resident in your program file list. You'll have to dig in the manuals to find the proper system parameters that stores this stuff. I'm not much on writing Macros, but I bet this one would be easy once you knew what the place holder (system variable) numbers were.

    Looks like he got it.....

  10. #9
    Join Date
    Jul 2020
    Country
    UNITED STATES
    State/Province
    Iowa
    Posts
    12
    Post Thanks / Like
    Likes (Given)
    0
    Likes (Received)
    2

    Default

    Quote Originally Posted by LockNut View Post
    Sorry, still not quite understanding. You do know, by entering these numbers, you are actually writing to a parameter and a system variable. There is no way to do what you just described. You can, however, use the G10 command to write values to the offsets but somewhere, you still need to enter these manually. The best option in case you haven't thought of this, is to get a probe. Best money ever spent.

    Oh do I wish I had a probe!!!!!!!!!!!!

    I did figure this out, So when ever M154 is executed machine will read the following program and set G54 work Coordinate for me. I'll put M154 at the top of the program. it was figuring 6071 parameter would read program O9001.


    %
    O9001 (M154)
    (PROGRAM TO SET G54 USING M154)
    (SETTING X G54)
    #100=#5021
    G10L2P1X#100
    (SETTING Y G54)
    #101=#5022
    G10L2P1Y#101
    M30
    %

  11. Likes CORONA VIRUS liked this post
  12. #10
    Join Date
    Jul 2020
    Country
    UNITED STATES
    State/Province
    Iowa
    Posts
    12
    Post Thanks / Like
    Likes (Given)
    0
    Likes (Received)
    2

    Default

    used G92 for years, nothing wrong with it.

  13. #11
    Join Date
    Jan 2007
    Country
    UNITED STATES
    State/Province
    New Jersey
    Posts
    1,271
    Post Thanks / Like
    Likes (Given)
    708
    Likes (Received)
    732

    Default

    Quote Originally Posted by beege View Post
    I really hate telling anyone this, but you could use G92 instead. Put a G92 X0Y0 at the top of the program, indicate the center of your part and press go? I've never done that myself, because I don't like using G92. Someone will chime in and tell me I'm nuts, I'm sure

    Nope, not nuts. I used G92 for many years too. Just do not put any work offset calls like G54 in your program at all.

  14. #12
    Join Date
    Sep 2010
    Location
    Victoria Australia
    Posts
    4,114
    Post Thanks / Like
    Likes (Given)
    0
    Likes (Received)
    1740

    Default

    Quote Originally Posted by GSMachinist View Post
    yes I am having trouble explaining my needs. I'll try again, clamp part to table, indicate bore, go to G54 work offset and move cursor to G54 X, input value by pressing "X" then input, then move cursor to G54 Y, input value by pressing "Y" then input. G54 work coordinate is set. Want I want to do is simplify this process by putting a M code statement in the top of the program before program reads any G54. So I am able to eliminate the process of setting the G54 work offset my self.
    Hello GSMachinist,
    Your program example in your Post #9 will only set Offset G54. The following shows/explains how any Workshift Offset from G54 to G59 can be set by just editing the "S" argument value in the call program.

    You need to write a Macro program and have it called via a Custom M Code. Following is an example.

    1. Indicate the part so that the X/Y axes slides are at the work piece X/Y Zero.

    2. Select the program that contains the following, program O1000 for example:

    O1000
    M111 S1
    M30

    Where:
    M111 is your Custom M Code. In the following example "111" is registered in parameter 6080 so as to call program number O9020

    and

    S_ = The Workshift Offset Number 1 to 6 corresponding to G54 to G56 respectively, where _ = numbers 1 to 6.

    3. Edit the "S" argument to represent the Workshift Number.

    4. Execute the above program which will in turn, execute the following program.

    O9020
    IF [[#19 EQ #0] OR [#19 LE 0] OR [#19 GT 6]] GOTO 900 (ERROR TRAP FOR ARGUMENT OUT OF RANGE)
    #[5201 + 20 * #19] = #5021 (REGISTER CURRENT X MACHINE POSITION INTO G54 TO G56)
    #[5202 + 20 * #19] = #5022 (REGISTER CURRENT Y MACHINE POSITION INTO G54 TO G56)
    M99
    N900 #3000 = 1 (OFFSET NUM RANGE ERROR}
    %


    Regards,

    Bill
    Last edited by angelw; 05-08-2021 at 04:56 AM.

  15. Likes CarbideBob, yardbird, Mtndew, SumiSpy liked this post
  16. #13
    Join Date
    Jun 2019
    Country
    UNITED STATES
    State/Province
    Pennsylvania
    Posts
    8
    Post Thanks / Like
    Likes (Given)
    0
    Likes (Received)
    2

    Default

    GSMachinist,

    Yes, I believe what you would like to do, is possible.
    Or I should say, it would be possible on a standard "i" series Fanuc (ie. 18i/21i/31i).
    I have never had any exposure to an 0i controller.

    Basically, this would be similar to what a probe does, electronically/automatically, only you would be manually finding your position, and using your custom M-code to capture your location.
    Pretty much what you described in your post.

    The system variables that you will want to review and use for your macro program will be the #5021-#5028 Current Position - Machine.
    I would also want to look at the #5081-#5088 system variables, which are for the Tool Length Offset.
    You will then want to transfer the values from these system variables, into the Workpiece Coordinate Variables #5201-#5328.

    The macro program number will need to be O9020-O9029, in order to be used as a custom M-code.
    With this series of custom M-codes, you could also take your macro program one step further, and vary which Work Offset you want to save the current position to.

    If you are not familiar with Macro B programming, here is a some good reference material:
    https://sovathrothsama.files.wordpre...tom_macros.pdf

    Macros can be very useful, but sometimes very trying to develop!

    Very gratifying, when you get them to work like you want!

    Hope this helps!

    Good Luck!

  17. #14
    Join Date
    Jan 2014
    Country
    UNITED STATES
    State/Province
    Washington
    Posts
    5,615
    Post Thanks / Like
    Likes (Given)
    1008
    Likes (Received)
    3159

    Default

    Quote Originally Posted by sagande View Post
    GSMachinist,

    Yes, I believe what you would like to do, is possible........!
    I guess you did not see that angelw provided all the info needed for the OP to do what he wants before you decided to spam the forum with your link?

  18. Likes yardbird liked this post
  19. #15
    Join Date
    Jan 2003
    Location
    Tel Aviv, Israel
    Posts
    680
    Post Thanks / Like
    Likes (Given)
    117
    Likes (Received)
    182

    Default

    Quote Originally Posted by angelw View Post
    Hello GSMachinist,
    Your program example in your Post #9 will only set Offset G54. The following shows/explains how any Workshift Offset from G54 to G59 can be set by just editing the "S" argument value in the call program.

    You need to write a Macro program and have it called via a Custom M Code. Following is an example.

    1. Indicate the part so that the X/Y axes slides are at the work piece X/Y Zero.

    2. Select the program that contains the following, program O1000 for example:

    O1000
    M111 S1
    M30

    Where:
    M111 is your Custom M Code. In the following example "111" is registered in parameter 6080 so as to call program number O9020

    and

    S_ = The Workshift Offset Number 1 to 6 corresponding to G54 to G56 respectively, where _ = numbers 1 to 6.

    3. Edit the "S" argument to represent the Workshift Number.

    4. Execute the above program which will in turn, execute the following program.

    O9020
    IF [[#19 EQ #0] OR [#19 LE 0] OR [#19 GT 6]] GOTO 900 (ERROR TRAP FOR ARGUMENT OUT OF RANGE)
    #[5201 + 20 * #19] = #5021 (REGISTER CURRENT X MACHINE POSITION INTO G54 TO G56)
    #[5202 + 20 * #19] = #5022 (REGISTER CURRENT Y MACHINE POSITION INTO G54 TO G56)
    M99
    N900 #3000 = 1 (OFFSET NUM RANGE ERROR}
    %


    Regards,

    Bill
    This, as usual, is complete. I, in order to add some additional "intuitivity", would instead of using S1-S6 arguments, use S54-S59 for G54-G59.
    "
    O1000
    M111 S54
    M30

    Where:
    M111 is your Custom M Code. In the following example "111" is registered in parameter 6080 so as to call program number O9020

    and

    S_ = The Workshift Offset Number 54 to 59 corresponding to G54 to G59 respectively, where _ = numbers 54 to 59.

    3. Edit the "S" argument to represent the Workshift Number.

    4. Execute the above program which will in turn, execute the following program.

    O9020
    IF [[#19 EQ #0] OR [#19 LE 53] OR [#19 GT 59]] GOTO 900 (ERROR TRAP FOR ARGUMENT OUT OF RANGE)
    #[5201 + 20 * [#19-53]] = #5021 (REGISTER CURRENT X MACHINE POSITION INTO G54 TO G59)
    #[5202 + 20 * [#19-53]] = #5022 (REGISTER CURRENT Y MACHINE POSITION INTO G54 TO G59)
    M99
    N900 #3000 = 1 (OFFSET NUM RANGE ERROR}
    %

  20. Likes yardbird liked this post
  21. #16
    Join Date
    Jan 2014
    Country
    UNITED STATES
    State/Province
    Washington
    Posts
    5,615
    Post Thanks / Like
    Likes (Given)
    1008
    Likes (Received)
    3159

    Default

    Quote Originally Posted by sagande View Post
    ..........My bad for posting additional information (link, or as you stated SPAM),.......
    Yes, glad you agree it’s bad to post a link to someone’s copyrighted material. Wonder why you did it if you think it bad? I doubt that Mr Smid appreciates folks doing that too.

  22. #17
    Join Date
    Mar 2014
    Location
    Milford, NH
    Posts
    31
    Post Thanks / Like
    Likes (Given)
    13
    Likes (Received)
    5

    Default

    You don't use an M code You simply put a G54 in your program

  23. #18
    Join Date
    Sep 2010
    Location
    Victoria Australia
    Posts
    4,114
    Post Thanks / Like
    Likes (Given)
    0
    Likes (Received)
    1740

    Default

    Quote Originally Posted by Don Davis 87 View Post
    You don't use an M code You simply put a G54 in your program
    And what values would you register under G54 and how do you achieve that registration? That's what the OP is wanting to do programmatically.

    Regards,

    Bill

  24. #19
    Join Date
    Feb 2014
    Location
    FL
    Posts
    4,317
    Post Thanks / Like
    Likes (Given)
    13571
    Likes (Received)
    5145

    Default

    Quote Originally Posted by Vancbiker View Post
    Yes, glad you agree it’s bad to post a link to someone’s copyrighted material. Wonder why you did it if you think it bad? I doubt that Mr Smid appreciates folks doing that too.
    Odd question but.... If I already own the book, would/should I feel bad about downloading a copy of the .PDF?

    I didn't, and I won't, just a thought experiment.


Tags for this Thread

Bookmarks

Posting Permissions

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