585,761 active members*
4,163 visitors online*
Register for free
Login
Results 1 to 19 of 19
  1. #1
    Join Date
    Oct 2005
    Posts
    8

    Macro b work offset

    I have Fanuc 18i-mb controlled vmc and the parts that we machine, it is usually necessary to put the program zero at the center of the part in XY direction. To save time at setup I´ve been thinking of creating a macro to make the calculations for me.

    This is what I need: touch (x+) -> cycle start -> touch (x-) -> cycle start -> touch (y+) -> cycle start -> touch (y-) -> cycle start -> touch part surface (z-zero) -> cycle start

    So that pressing cycle start would record the position and at the end make the calculation and set the work offset automatically.

    How hard would this be to make with a macro b? Keeping mind I have zero experience with it

  2. #2
    Join Date
    Aug 2009
    Posts
    684
    Not difficult. All you need to know are the system variable numbers for current position (#5001-#5003 typically) and the formula to find the variables for the current work offset (depends whether you are using extended work offsets or not). I'm pretty sure this will be in one of your fanuc manuals in custom macro section.

    Simply save current position at each cycle start to a custom macro variable (#501-#505 for example - ie #501=#5001 etc), do the maths to find mid-point (eg #506=#501+[[#502-#501]/2.] ) and add the error to the relevant work offset system variable. To measure the z position you may/may not need to find the system variable for current tool length offset.

    DP

  3. #3
    Join Date
    Feb 2007
    Posts
    314
    another thing, macro is executed in auto mode and you cannot move manually in auto mode. you have to switch to handwheel mode, go to position, return in auto mode, then press cycle start.

    Maybe with ladder editing you could allows manual move in auto mode with user input variable, but this could be really tricky.

    it could be a good thing to add some operator message saying witch point to touch (X+,X-,Y+ Y-)

  4. #4
    Join Date
    Aug 2011
    Posts
    2517
    move in manual. switch to auto. press start. value is set. program execution is stopped with M00. switch to manual, move, switch back to AUTO, press start. value is set then M00 again. etc

  5. #5
    Join Date
    Aug 2009
    Posts
    684
    At machine realised that #5001-3 are not updated in hand/jog modes. Would be better to use #5021-3 machine position coordinates.

    DP

  6. #6
    Join Date
    Sep 2010
    Posts
    1230
    Quote Originally Posted by Cannon View Post
    I have Fanuc 18i-mb controlled vmc and the parts that we machine, it is usually necessary to put the program zero at the center of the part in XY direction. To save time at setup I´ve been thinking of creating a macro to make the calculations for me.

    This is what I need: touch (x+) -> cycle start -> touch (x-) -> cycle start -> touch (y+) -> cycle start -> touch (y-) -> cycle start -> touch part surface (z-zero) -> cycle start

    So that pressing cycle start would record the position and at the end make the calculation and set the work offset automatically.

    How hard would this be to make with a macro b? Keeping mind I have zero experience with it
    Rather than use M00, include the following when manual mode needs to be selected and a touch made.
    #3006=1 (MANUAL MODE TOUCH X PLUS)
    ---------
    ---------
    #3006=1 (MANUAL MODE TOUCH X MINUS)
    ---------
    ---------
    #3006=1 (MANUAL MODE TOUCH Y PLUS)
    ---------
    ---------
    #3006=1 (MANUAL MODE TOUCH Y MINUS)
    etc

    This will halt the program and display an Operator Message

    Regards,

    Bill

  7. #7
    Join Date
    Oct 2005
    Posts
    8
    Thanks everyone for good advices. I think I might be able to build something out of this. For sure i will be asking more questions when I get this going!

  8. #8
    Join Date
    Feb 2006
    Posts
    338
    Something like this should work for you. I did not check the variable #'s but they sound right. Regardless you should look them up on your machine and make sure what they are calling.

    Position X+, run the program. It stops to tell you what it will do, press cycle start to set that position. It then stops with the error to move to the next position. Go to X- and rerun the program. Rinse/repeat until then end when it calculates the offsets and then clears the variables for the next time it is run.

    Edit the M0 and #3006 lines for the stopping behavior you prefer/need.

    Code:
    O0001 (set fixture offset)
    (Check if anything is set)
    IF [#501EQ0] GOTO 10
    IF [#502EQ0] GOTO 20
    IF [#503EQ0] GOTO 30
    IF [#504EQ0] GOTO 40
    N10 (X+ setting)
    M0
    (press cycle start to set X+)
    #501=#5021
    #3006=1 (MANUAL MODE TOUCH X MINUS)
    N20 (X1 setting)
    M0
    (press cycle start to set X-)
    #502=#5021
    #3006=1 (MANUAL MODE TOUCH Y PLUS)
    N30 (Y+ setting)
    M0
    (press cycle start to set Y+)
    #503=#5022
    #3006=1 (MANUAL MODE TOUCH Y MINUS)
    N40 (Y- setting)
    M0
    (press cycle start to set Y-)
    #504=#5022
    
    N100 (Set XY G54 Offset)
    #5221=[#501+#502]/2
    #5222=[#503+#504]/2
    (clear #501-504)
    #501=0
    #502=0
    #503=0
    #504=0
    M30

  9. #9
    Join Date
    Oct 2005
    Posts
    8
    Dpuch, thank for helping me out. I havent had time to do much on my own yet but this looks pretty damn close!
    Now im wondering if I could use this same macro in a situation when I only have to take X or Y to the center. I presume I would have to zero the work offset first and then go take the axis manually that is on a part side, then get back to the macro and put IF [#....EQ0] GOTO .. line before every axis center point measuring to jump over it if there is something in that axis work offset.
    Does this sound right?

  10. #10
    Join Date
    Oct 2005
    Posts
    8
    One thing... how does putting #3006=1 or just M00 to the macro differs? the #3006=1 line I can write a message to operator but I still have to go to hand wheel mode for taking the point, right?

  11. #11
    Join Date
    Sep 2010
    Posts
    1230
    Quote Originally Posted by Cannon View Post
    One thing... how does putting #3006=1 or just M00 to the macro differs? the #3006=1 line I can write a message to operator but I still have to go to hand wheel mode for taking the point, right?
    When “#3006=1 (MESSAGE)” is commanded in the macro, the program executes blocks up to the immediately previous one and then stops. Using M00 just causes the program to stop without a message. You still have to use the Hand Wheel to make the touch.

    Regards,

    Bill

  12. #12
    Join Date
    Sep 2010
    Posts
    1230
    Quote Originally Posted by Cannon View Post
    Dpuch, thank for helping me out. I havent had time to do much on my own yet but this looks pretty damn close!
    Now im wondering if I could use this same macro in a situation when I only have to take X or Y to the center. I presume I would have to zero the work offset first and then go take the axis manually that is on a part side, then get back to the macro and put IF [#....EQ0] GOTO .. line before every axis center point measuring to jump over it if there is something in that axis work offset.
    Does this sound right?
    Hi Cannon,
    If I understand your question, you want to be able to set either the X or the Y axis Work Shift Offset independently, and be able to make the choice as to which axis will be set. If this is the case, the following will work as explained.

    In any case, the Work Shift Macro has to be called. Therefore, you will be able to select which axes are to be set by passing an argument via the Macro Program Call block. The Macro Program can either be called using the Macro Call G code G65, or via a G or M code. The advantage of using a Custom G or M code is that its easier via MDI if you chose to do so, rather than executing a set program. Its easier via Custom G Code because you don't have to specify a program number in the MDI command string.

    A Custom G code is created by registering a number, corresponding to the G code you wish to create, in a parameter that relates to a corresponding program number. For example, if the number 100 is registered in parameter #6050, a program registered under O9010 will be called when G100 is executed. No program number needs to be specified when G100 is executed.

    As with a G65 Macro call, arguments can be passed to local variables in the Macro Program Being called by a G or M code. Accordingly, the axes to be set can be specified by either including or omitting X or Y as an argument in the call statement. The value passed in the X, Y arguments can be any value whatsoever if you want to set either axis, but for convenience and consistency, X1 Y1 would be a good choice. If you want to only set one axis, simple omit the unwanted axis from the call statement.

    I've included an S argument as the Work Shift Offset Number to set. The value passed is in the range of 1 to 6, corresponding to the standard Work Shift system G54 to G59. If an Out of Range value is passed as an argument by S, or if S is omitted in the call statement, the Macro Program will fall through to the end and report an error.

    G100 X1 Y1 S2
    In the above example, the G55 Work Shift Offset for both X and Y axis are flagged to be set.

    G100 X1 S1
    This will flag the G54 X Work Shift Offset to be set.

    The conditional statements included in the Macro Program will cause the program to bypass the code for setting a particular axis if the axis address is omitted in the Macro Call block.

    I see no need for Common, Non Volatile variables (#500 plus) to be used in the Macro program. When using such variables, you need to be certain that the variables are not being, or may be used by another program, as their values are changed across all programs. Conversely, Local variables (#1 to #33) are only effected locally.

    Regards,

    Bill

    G100 X_ Y_ S_ (Call Block that can be executed via MDI or via a program)
    Where:
    X = Any value to flag X axis to be set (Omit if not to be set)
    Y = Any value to flag Y axis to be set (Omit if not to be set)
    S = 1 to 6 to specify Work Shift Offset Number to set (Must be included)

    %
    O9010(XY BORE WORK SHIFT MACRO)
    IF[[#19EQ#0] OR [#19LT1] OR [#19GT6]]GOTO30
    IF[#25EQ#0]GOTO10
    (SET Y STARTS HERE)
    #3006=1 (MANUAL MODE TOUCH Y PLUS)
    (TOUCH 1ST POINT IN Y AXIS)
    #1=#5022
    #3006=1 (MANUAL MODE TOUCH Y MINUS)
    (TOUCH 2ND POINT IN Y AXIS)
    #2=#5022
    #3=[#1+#2]/2
    #[5202+[20*[#19]]]=#3
    N10 (SET X STARTS HERE)
    IF[#24EQ#0]GOTO20
    #3006=1 (MANUAL MODE TOUCH X PLUS)
    #1=#5021
    #3006=1 (MANUAL MODE TOUCH X MINUS)
    (TOUCH 2ND POINT IN X AXIS)
    #2=#5021
    #3=[#1+#2]/2
    #[5201+[20*[#19]]]=#3
    GOTO20
    N30
    #3006=1 (WORK SHIFT NUMBER ERROR]
    N20
    M99
    %

  13. #13
    Join Date
    Feb 2006
    Posts
    338
    Nice macro angelw.

    Regarding the use of #500 and above you are right. In my example there is no need, and they should be replaced with #100 series variables. As for the difference between M0 and #3006 it is mostly visual, as the one outputs an error message that may send the wrong message to operators. Also I have not used it that way personally, especially where I intended to continue the program after that line. I intentionally wrote it so the program could be interrupted and restarted. The logic was because I have machines that do not like to cycle start a program if not at home position. Of course looking back at it that still would have been an issue without going the custom G-code route as angelw describes. His solution should be a lot nicer to use.

  14. #14
    Join Date
    May 2012
    Posts
    100
    Is it possible to program like this?
    (Thanks for all the ideas by the way)

    %
    O9010(XY BORE WORK SHIFT MACRO)
    IF[[#19EQ#0] OR [#19LT1] OR [#19GT6]]GOTO30
    IF[#25EQ#0]GOTO10
    (SET Y STARTS HERE)
    M19 S0 (M19 positioning for eliminating throw on probe)
    #3006=1 (MANUAL MODE TOUCH Y PLUS)
    (TOUCH 1ST POINT IN Y AXIS)
    #1=#5022
    G00 G91 G95 Y-10 F50 (Press cycle stop at prefered location)
    M19 S180
    #3006=1 (MANUAL MODE TOUCH Y MINUS)
    M00
    (TOUCH 2ND POINT IN Y AXIS)
    #2=#5022
    #3=[#1+#2]/2
    #[5202+[20*[#19]]]=#3
    G54 G90 Y0
    X1.75 (X= Bore radius minus probe radius and clearance)
    N10 (SET X STARTS HERE)
    M19 S90
    IF[#24EQ#0]GOTO20
    M00
    #3006=1 (MANUAL MODE TOUCH X PLUS)
    #1=#5021
    X-1.75 (Bore radius minus probe radius and clearence)
    M19 S270
    #3006=1 (MANUAL MODE TOUCH X MINUS)
    M00
    (TOUCH 2ND POINT IN X AXIS)
    #2=#5021
    #3=[#1+#2]/2
    #[5201+[20*[#19]]]=#3
    GOTO20
    N30
    #3006=1 (WORK SHIFT NUMBER ERROR)
    X0 Y0
    N20
    G90 G53
    M99
    %

  15. #15
    Join Date
    Sep 2010
    Posts
    1230
    Quote Originally Posted by dpuch View Post
    Nice macro angelw.

    Regarding the use of #500 and above you are right. In my example there is no need, and they should be replaced with #100 series variables. As for the difference between M0 and #3006 it is mostly visual, as the one outputs an error message that may send the wrong message to operators. Also I have not used it that way personally, especially where I intended to continue the program after that line. I intentionally wrote it so the program could be interrupted and restarted. The logic was because I have machines that do not like to cycle start a program if not at home position. Of course looking back at it that still would have been an issue without going the custom G-code route as angelw describes. His solution should be a lot nicer to use.
    The same precaution needs to be observed when using the #100 series Common Variables. These are effected across all programs the same as #500 Series, but are initialized to vacant (Null) when the control is turned off.

    Sometimes the Bore or Boss feature may consist of an arc, not a full circle where a -X-Y, +X+Y touch is possible. In this case, the following Macro will get the X,Y centre coordinates and the Radius of the arc feature.

    In this case only the S argument has to be passed by either a Custom G code or conventional G65 call.

    G100 S4
    or
    G65 P9010 S4

    The Macro Program in my previous Post #12 can also be called using the conventional G65 call as follows:

    G65 P9010 X1 Y1 S4

    Regards,

    Bill

    %
    O9010(XY BORE WORK SHIFT MACRO - ARC THROUGH 3 POINTS)
    IF[[#19EQ#0] OR [#19LT1] OR [#19GT6]]GOTO10

    #3006 = 1 (MAN TOUCH 1 - CYCLE START)
    #1=#5021
    #2=#5022

    #3006 = 1 (MAN TOUCH 2 - CYCLE START)
    #3=#5021
    #4=#5022

    #3006 = 1 (MAN TOUCH 3 - CYCLE START
    #5=#5021
    #6=#5022

    (GET PERPENDICULAR BISECTOR OF #1 #2 AND #3 #4)
    #7 = [#3 + #1] / 2
    #8 = [#4 + #2] / 2
    #9 = #3 - #1
    #10 = -[#4 - #2]

    (GET PERPENDICULAR BISECTOR OF #3 #4 AND #5 #6)
    #11 = [#5 + #3] / 2
    #12 = [#6 + #4] / 2
    #13 = #5 - #3
    #14 = -[#6 - #4]

    (GET LINE INTERSECTION)
    #15 = [#8 * #10 * #14 + #11 * #10 * #13 - #7 * #9 * #14 - #12 * #10 * #14] / [#10 * #13 - #9 * #14]
    #16 = [#15 - #7] * #9 / #10 + #8
    (GET ARC RADIUS IF OF INTEREST - USEFUL IF USING THE MACRO AS A MEASURING PROGRAM)
    #17 = SQRT[[[#1 - #15] * [#1 - #15]] + [[#2 - #16] * [#2 - #16]]]

    #[5201+[20*[#19]]]=#15 (CALCULATE THE X WORK SHIFT SYSTEM VARIABLE NUMBER AND SET)
    #[5202+[20*[#19]]]=#16 (CALCULATE THE Y WORK SHIFT SYSTEM VARIABLE NUMBER AND SET)
    GOTO20
    N10
    #3006=1 (WORK SHIFT NUMBER ERROR]
    N20
    M99
    %

  16. #16
    Join Date
    Feb 2006
    Posts
    338
    The M19 part yes, provided of course that the machine can orient to specific rotations and you can still read your probe. My suggestion would be to limit the changes to this, and an incremental move just large enough to get the probe off the last probed wall so the next orientation can be done without contact.

    Code:
    G00 G91 G95 Y-10 F50 (Press cycle stop at prefered location)
    Why involve an automatic move when setting up the part? Cycle stop has no effect on the code, it will just resume when cycle start is pressed. Also G95? On my machine that is feed per rev, but the spindle would not be moving...

    Code:
    G54 G90 Y0
    As Y has been set this might be ok, but you would need to use
    Code:
    G[53+#19] G90 Y0
    so you call the same offset you just set instead of a static G54

    My suggestion for what you proposed.
    Code:
    %
    O9010(XY BORE WORK SHIFT MACRO)
    #10=0.2 (distance just enough to clear the probe from the wall contact)
    IF[[#19EQ#0] OR [#19LT1] OR [#19GT6]]GOTO30
    IF[#25EQ#0]GOTO10
    (SET Y STARTS HERE)
    M19 S0 (M19 positioning for eliminating throw on probe)
    #3006=1 (MANUAL MODE TOUCH Y PLUS)
    (TOUCH 1ST POINT IN Y AXIS)
    #1=#5022
    G01 G91 Y-#10 F50 (move just clear of the wall for orientation)
    M19 S180
    #3006=1 (MANUAL MODE TOUCH Y MINUS)
    M00
    (TOUCH 2ND POINT IN Y AXIS)
    #2=#5022
    #3=[#1+#2]/2
    #[5202+[20*[#19]]]=#3
    G5[53+#19] G90 Y0
    N10 (SET X STARTS HERE)
    M19 S90
    IF[#24EQ#0]GOTO20
    M00
    #3006=1 (MANUAL MODE TOUCH X PLUS)
    #1=#5021
    G01 G91 x-#10 F50 (move just clear of the wall for orientation)
    M19 S270
    #3006=1 (MANUAL MODE TOUCH X MINUS)
    M00
    (TOUCH 2ND POINT IN X AXIS)
    #2=#5021
    #3=[#1+#2]/2
    #[5201+[20*[#19]]]=#3
    G5[53+#19] G90 X0
    M19 (reset spindle if needed)
    GOTO20
    N30
    #3006=1 (WORK SHIFT NUMBER ERROR)
    N20
    G90 G53
    M99
    %

  17. #17
    Join Date
    Sep 2010
    Posts
    1230
    Quote Originally Posted by Anders6612 View Post
    Is it possible to program like this?
    (Thanks for all the ideas by the way)

    Sorry dpuch, you made your Post whilst I was typing mine. However, point 2 of this Post is relevant when controlled moves are made in the Macro Program.

    Anders,
    Mostly yes, but
    1. instead of using G54 to move to the Y centre, you should use G[53 + #19] G90 Y0, because #[5202+[20*[#19]]]=#3 can be setting any Work Shift from G54 to G59

    2. you have to be careful when making incremental moves off of a feature surface. In your example, you're relying on the operator making a +Y touch first. The instruction is there in the Message, but that does not stop the operator from making a touch on the -Y side of the feature first by mistake. I didn't want to confuse the issue in the example in my first post, so I gave the example so that the operator had to make all moves manually.

    A safer method that will result in correct direction move irrespective of the order in which the +Y -Y and +X -X touches are made is as follows

    #3006=1 (MANUAL TOUCH 1ST Y POINT)
    (TOUCH 1ST POINT IN Y AXIS)
    #1=#5022
    #3006=1 (MANUAL TOUCH OPP Y POINT)
    (TOUCH 2ND POINT IN Y AXIS)
    #2=#5022
    #3=[#1-#2]/2 (GET HALF THE DIFFERENCE BETWEEN THE TWO TOUCHES AND THE DIRECTION OF MOVE)
    G01 G91 Y#3 F2000 (THIS WILL MOVE THE SLIDE IN THE CORRECT DIRECTION TO THE CENTRE OF Y)
    #[5202+[20*[#19]]]=#5022 (SET THE Y WORK SHIFT)

    You can also use the same following logic to determine the direct to step off just to make the spindle index. For example:

    #10 = 2.0 (2MM clearance from feature surface for spindle Index)
    The above variable can be either hard coded in the Macro Program, or passed as an argument via the Macro call block
    #3=[#1-#2]
    IF[#3 LT 0] TH #10 = -#10
    G00 G91 Y#10 F2000
    #10 = ABS[#10] (ENSURE #10 IS MADE ABSOLUTE BEFORE NEXT TEST)

    Repeat the above for X axis

    3. I don't see how you get X1.75. You've made no calculation for the radius of the bore, and no constant for the probe radius is provided.

    4. Only use #3006 = 1 (MESSAGE), or M00; not both. Using both will require two presses of the cycle start and as there will be no operator message with the M00, may be confusing for the operator.

    Regards,

    Bill

  18. #18
    Join Date
    Aug 2011
    Posts
    2517
    M00 ;
    (OPERATOR MESSAGE HERE) ;

    == same thing.....

    also #3006 = 1 (MESSAGE) only works on machines that have an operator message screen. not all of them do.
    otherwise it'll stop but no operator message is displayed, you just see the program in a stop mode equivalent to M00

  19. #19
    Join Date
    May 2012
    Posts
    100
    Thanks, i was tired yesterday and got it wrong.
    I think i get a hang of it now.

    And of course, G95 is mm/r it should be G94

Similar Threads

  1. Macro and Z fixture offset
    By Techman in forum Fadal
    Replies: 0
    Last Post: 08-06-2009, 07:56 PM
  2. Sinumeric Offset Value macro
    By sanjeevlj in forum Mastercam
    Replies: 3
    Last Post: 05-06-2009, 11:05 AM
  3. tool offset macro
    By cnc-king in forum Fanuc
    Replies: 6
    Last Post: 09-22-2008, 04:43 AM
  4. macro program for work offset
    By cncwhiz in forum Fanuc
    Replies: 4
    Last Post: 12-14-2007, 01:28 PM
  5. Macro for positive offset
    By qmas99 in forum Uncategorised CAM Discussion
    Replies: 0
    Last Post: 02-12-2006, 04:37 AM

Posting Permissions

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