Welcome to Our Community

Some features disabled for guests. Register Today.

tool X,Y offset... G10? G92? other?

Discussion in 'CAM' started by base1379, Jan 28, 2021.

  1. base1379

    base1379 New
    Builder

    Joined:
    Jan 9, 2017
    Messages:
    34
    Likes Received:
    5
    Hello,
    I'm in the process of writing a postprocessor for a machine that has 2 tools: a laser and a pen.
    My goal is to apply an offset to X and Y depending on which tool is used. The delta X and delta Y are known between the 2 tools and doesn't change.

    I've tried both G10 L2 and G92 without success.
    Which one is best suited for this application? I've read that G92 is deprecated.

    Here's one attempt with G92, what am I doing wrong?
    function onSection() {
    ...
    var OFFSETX; // offset to be applied in G92 call
    var OFFSETY; // offset to be applied in G92 call
    switch (tool.type) {
    case TOOL_WATER_JET: // pen
    switch (properties.toolzero) {
    case 1: // laser was zeroed
    OFFSETX = properties.offsetX;
    OFFSETY = properties.offsetY;
    break;
    case 2: // pen was zeroed
    OFFSETX = 0.0;
    OFFSETY = 0.0;
    break;
    } // properties.toolzero
    break;
    case TOOL_LASER_CUTTER: // laser
    switch (properties.toolzero) {
    case 1: // laser was zeroed
    OFFSETX = 0.0;
    OFFSETY = 0.0;
    break;
    case 2: // pen was zeroed
    OFFSETX = -properties.offsetX;
    OFFSETY = -properties.offsetY;
    break;
    } // properties.toolzero
    break;
    default:
    error(localize("The CNC does not support the required tool."));
    return;
    }
    writeBlock("G92.1", "; delete tool offset");
    //writeBlock(gAbsIncModal.format(91), "; Relative Positioning for offset");
    writeBlock(gFormat.format(92), xOutput.format(OFFSETX), yOutput.format(OFFSETY), "; apply tool offset"); //writeBlock(gAbsIncModal.format(90), "; Absolute Positioning after offset");
    ...


    I've even considered applying the offsets directly to the X and Y g codes, but I'm trying to avoid that.

    Thanks,
    wolfgang
     
  2. David the swarfer

    David the swarfer OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Aug 6, 2013
    Messages:
    3,461
    Likes Received:
    1,915
    I would use G54 and G55 work coordinate systems

    say G54 for the pen and G55 for the laser

    User sets G54 mode and then sets 0,0,0 WCS
    a MACRO (not part of post) can now autoset the G55 relative to G54
    something like
    G54
    G0 x0 y0
    G10 L20 P2 X[xoffset] Y[yoffset]

    now the post can output a G54 for pen moves and G55 for laser moves, no knowledge of offsets needed at all though of course the onOpen could do the offset 'macro' if you really wanted to.
     
    base1379 likes this.
  3. Rob Taylor

    Rob Taylor Master
    Builder

    Joined:
    Dec 15, 2013
    Messages:
    1,470
    Likes Received:
    749
    Use two different WCS? G54 for laser, G55 for pen. So you have a G10 L20 P0 for laser and P1 for pen. You'd only need to zero one of them, G-code could set the other in the header lines.
     
    base1379 likes this.
  4. David the swarfer

    David the swarfer OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Aug 6, 2013
    Messages:
    3,461
    Likes Received:
    1,915
    snap.

    P1 and P2 though, numbering starts at 1 for G54
     
    base1379 likes this.
  5. Rob Taylor

    Rob Taylor Master
    Builder

    Joined:
    Dec 15, 2013
    Messages:
    1,470
    Likes Received:
    749
    Ha! Didn't even see that, that's funny. Definitely the way to do it though. Ohh, yeah, P0 is "active WCS", which isn't very helpful in a situation like this, but this isn't usually how I'm using G10 L20. Good call.
     
    base1379 likes this.
  6. David the swarfer

    David the swarfer OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Aug 6, 2013
    Messages:
    3,461
    Likes Received:
    1,915
    I like the macro solution rather than building it into the post because I would want to check before the code runs. I have not crashed into anything in a long time, because I CHECK incessantly (-:
    If only GRBL had a 'single block' mode.
     
  7. Rob Taylor

    Rob Taylor Master
    Builder

    Joined:
    Dec 15, 2013
    Messages:
    1,470
    Likes Received:
    749
    Since most of my programs only run once or twice, very much agree! I'm getting better about that as I go, but sometimes I'll still use an old TLO or fat-finger an accidental X/Y offset somewhere because I'm looking at the machine and not the control. Gonna build some proper controls at some point for the mill and M4 for the exact reason he explained- I hate not being able to drive by feel or having too many easily-pressed buttons in one spot.

    Keyboard shortcuts in LinuxCNC are pretty nice and logical- F1, F2, ctrl-Home to startup, XYZ-> End, Z-> ctrl-End for zeroing and toolsetting, number row for feed override, etc etc. but you're always quite close to doing something you don't wanna do. I'm constantly checking my TLO coords to make sure XY are zero and my modals in MDI now. Better to build a hardwired control panel interfacing with the UI and not have to worry about keyboards so much.
     
    David the swarfer likes this.
  8. base1379

    base1379 New
    Builder

    Joined:
    Jan 9, 2017
    Messages:
    34
    Likes Received:
    5
    Thank you very much David the swarfer and Rob Taylor!
    I've got it doing what I need now using G54 and G55 like you recommended.
    Here's what I got:

    function onOpen() {
    if(properties.writeMachine){
    writeBlock(";", description);
    writeBlock(";", vendor);
    writeBlock(";", vendorUrl);
    writeBlock(";", legal);
    } // properties.writeMachine
    if (programName) {
    writeBlock(";", programName, programComment ? "(" + programComment + ")" : "");
    } // programName
    writeBlock(gUnitModal.format(unit_int), ";", unit_str + "-mode");
    writeBlock(gUnitModal.format(54), "; Work Coordinates");
    writeBlock(gAbsIncModal.format(90), gMotionModal.format(0), xOutput.format(0), yOutput.format(0), "; Absolute Positioning, rapid to zero");
    var sign;
    switch (properties.toolzero) {
    case 1: // pen was zeroed
    sign = 1;
    break;
    case 2: // laser was zeroed
    sign = -1;
    break;
    } // properties.toolzero
    writeBlock(gFormat.format(10), lFormat.format(20), pFormat.format(2), xOutput.format(sign*properties.offsetX), yOutput.format(sign*properties.offsetY), "; offset G55");
    writeBlock("\n");
    } // onOpen



    function onSection() {
    <...>
    switch (tool.type) {
    case TOOL_WATER_JET: // pen
    writeBlock(gUnitModal.format(54), "; switch to pen coordinate system");
    break;
    case TOOL_LASER_CUTTER: // laser
    writeBlock(gUnitModal.format(55), "; switch to laser coordinate system");
    break;
    default:
    error(localize("The CNC does not support the required tool."));
    return;
    } // tool.type
     
  9. base1379

    base1379 New
    Builder

    Joined:
    Jan 9, 2017
    Messages:
    34
    Likes Received:
    5
    When you say "MACRO", what does this mean? Where would this macro be defined? (I've never used or heard of a macro before in the CAM/post process).
    Thanks,
    Wolfgang
     
  10. David the swarfer

    David the swarfer OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Aug 6, 2013
    Messages:
    3,461
    Likes Received:
    1,915
    macro: (googles definition)
    noun: macro; plural noun: macros; noun: macro instruction; plural noun: macros instruction; plural noun: macro instructions
    1. Computing
    a single instruction that expands automatically into a set of instructions to perform a particular task.


    In our case a macro is a short segment of Gcode that does a job (often used) for us, that is stored and attached to a macro button.
    Different GUI's do it their own way, bCNC looks like this
    macro03.png
    The 12 items in that section are user assignable buttons, the red dots have not yet been assigned.

    OpenbuildsCONTROL has a macro tab
    macro01.png
    and there are 2 defined macros. CONTROL accepts macros in either Gcode or Javascript.

    I have defined the laser offset macro I described as follows
    macro02.png
    This bit of Gcode tells the machine to go to X0 Y0 using the G54 Work Coordinate System
    Then it sets the G55 offset (P2) to be offset by 55.2 and 23.7 (millimeters assumed, the macro should have a G21 at the start to make sure GRBL is in the right mode)
    Different laser installations will have different offsets, obviously.

    To use this macro one would set up the router bit and set X, Y and Z zero (with G54 active) for that tool according to what the job needs.
    The user then presses the macro button and the G55 WCS is set relative to the 0,0,0 the user has set (one might need to set the Z offset as well, to stay in focus).

    Now the user can run the router file which was generated with G54 as the WCS (WCS=1 in Fusion360), and then run the laser file which was generated with G55 (WCS=2 in Fusion360).
    For production one could use a text editor to join the 2 files together so they run as 1 job. The order of the files does not matter unless the laser operations rely on something cut by the router.
     
    base1379 likes this.
  11. theshort

    theshort New
    Builder

    Joined:
    Dec 7, 2016
    Messages:
    19
    Likes Received:
    6
    I think this is what I'm needing for a registration laser for X/Y on my Workbee. I'm new to all this and not following. I just need to create an offset from where I will mount the laser pointer so when I zero X/Y it will cut from where the laser pointer indicated it would. I use OpenBuilds CONTROL, any help would be greatly appreciated.
     
  12. David the swarfer

    David the swarfer OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Aug 6, 2013
    Messages:
    3,461
    Likes Received:
    1,915
    so the laser is just a pointer for setting X and Y, right?

    How are you setting Z?
    since you have to set Z with the current tool you may as well just set X and Y with it as well, surely?

    anyhow, to answer the question....
    upload_2021-4-29_19-31-26.png

    We have the laser mounted to the left and forward of the spindle by the amounts in the drawing above.

    Process:
    1. load the Gcode file
    2. jog the laser to the XY Work co-ordinate system 0,0 for this part
    3. SetZero for X and Y using the buttons in OBControl.
    4. Click the LaserOffset macro button (which you have to create).
    5. set Z zero!
    6. Click the Run button
    Content of the 'LaserOffset' macro
    Code:
    G21 G90 G17         ; set some modes so we get what we expect
    G0 X-60 Y-30          ; move spindle left and forward
    G10 L20 P0 X0 Y0 ; do what the SetZero buttons do for X and Y
    
     
  13. theshort

    theshort New
    Builder

    Joined:
    Dec 7, 2016
    Messages:
    19
    Likes Received:
    6
    Great I will give it a go. I only use a Z probe, I have no need for an X/Y probe at this time.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice