Welcome to Our Community

Some features disabled for guests. Register Today.

How to write a macro to Set work zero

Discussion in 'CNC Mills/Routers' started by Örjan, Feb 11, 2025.

Tags:
  1. Örjan

    Örjan New
    Builder

    Joined:
    Nov 19, 2018
    Messages:
    8
    Likes Received:
    0
    I have a WorkBee CNC and have just bought a PanelDue screen for my Duet control board. Through the screen, it is not possible to set Work Zero, but macros can be run. Can someone help me with the G-code for a macro to set Work Zero and another macro to return to Work Zero?
     
  2. Alex Chambers

    Alex Chambers Master
    Moderator Builder

    Joined:
    Nov 1, 2018
    Messages:
    2,809
    Likes Received:
    1,383
    Yes, I can, but it's bedtime here in the UK and I'm busy tomorrow. To answer the first question I need to know what version of Ooznest's firmware you are using.
    The macro to return to workplace zero is an easy one :-
    G0 X0 Y0
    G0 Z0
    Notice there are two lines so it moves to X0Y0 first and then lowers to Z0.

    Alex.
     
  3. Örjan

    Örjan New
    Builder

    Joined:
    Nov 19, 2018
    Messages:
    8
    Likes Received:
    0
    And so in Sweden :). Firmware: 3.3.0-1.2
    Thanks for answer.

    /Örjan
     
  4. Örjan

    Örjan New
    Builder

    Joined:
    Nov 19, 2018
    Messages:
    8
    Likes Received:
    0
    Can the right macro be: G92 X0 Y0 Z0
     
  5. David the swarfer

    David the swarfer OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Aug 6, 2013
    Messages:
    3,520
    Likes Received:
    1,933
    no, avoid G92
    The correct code is 'G10 L20 Ps X. Y. Z' as in G Codes
    You will need 3 macros, one for each axis
    for X
    Code:
    G90 G17
    G10 L20 P0 X0
    for Y
    Code:
    G90 G17
    G10 L20 P0 Y0
    for Z
    Code:
    G90 G17
    G10 L20 P0 Z0
    You could combine X and Y but I don't recommend combining with Z
    for XY
    Code:
    G90 G17
    G10 L20 P0 X0 Y0
    The 'P0' tells it to use the current work offset system, which avoids having to know which one is in use, though G54 is the default.

    Then for the gotos I would use 2 macros
    first, goto X0 y0 and a safe Z height
    Code:
    G90 G17 G21
    G53 G0 Z-5
    G0 X0 Y0
    That sets millimeter mode then raises Z to 5mm below the Z limit switch. IF that is not far enough to avoid triggering the limit, then use -10
    G53 is a machine coordinate move, referenced to home rather than workpiece 0, G90 is absolute coordinates (as opposed to relative), G17 is XY plane, G21 is millimeters.
    Macros must always set the modes they expect, never assume that the mode, like G90, is already in effect, someday, it won't be )-:

    now for Z, I would not rapid move to Z0, that would not give me time to abort if there was a problem
    Code:
    G90 G17 G21
    G1 Z0 F400
    This sets the modes as before, then uses a feedrate of 400mm/min to move to the current work Z0.
    This will do 100mm in 15 seconds, which should give you time to emergency stop if there is a problem, without taking so long you get bored.
    Of course you can adjust this feedrate to be faster, your machine, your risk, I find fast Z moves to happen much too quickly for comfort so I take the slow road.
     
  6. Örjan

    Örjan New
    Builder

    Joined:
    Nov 19, 2018
    Messages:
    8
    Likes Received:
    0
    Thank you so much for your help!
     
  7. Alex Chambers

    Alex Chambers Master
    Moderator Builder

    Joined:
    Nov 1, 2018
    Messages:
    2,809
    Likes Received:
    1,383
    All good except for the one in the quote above - that is perfectly correct for most cnc controllers but won't work with the Duet controller and Ooznest's firmware.

    So ;-
    G90 G17 G21
    G53 G0 Z80
    G0 X0 Y0

    Alex.
     
    Örjan likes this.
  8. Örjan

    Örjan New
    Builder

    Joined:
    Nov 19, 2018
    Messages:
    8
    Likes Received:
    0
    Thanx Alex
     

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