Welcome to Our Community

Some features disabled for guests. Register Today.

Using Gcode as macro for probing XYZ

Discussion in 'Control Software' started by deonholt, Dec 13, 2023.

  1. deonholt

    deonholt New
    Builder

    Joined:
    Nov 6, 2023
    Messages:
    8
    Likes Received:
    0
    Hi and thank for your help.

    I had my own XYZ probe machined. I used it a couple of times as Z-probe only and I manged to do the custom setup.
    I then got a custom written code to use and had to change a few settings in it. I want to use it as a macro for probing XYZ.

    In Openbuilds CONTROL I clicked on the Macros-tab and then on the big "Create New Macro" button. From here I labeled it and clicked on GCODE.

    I copied the text of the Gcode and pasted it in the box. I clicked apply and it was there under macros.
    (The code follows below.)

    When I run the Macro, I get this error message:
    error: 2 - Numeric value format is not valid or missing an expected value.
    [ %ENDMILL_DIAMETER = 3.175 ]

    I there something I am doing wrong?
    Thank you so much.


    ; Set user-defined variables
    %ENDMILL_DIAMETER = 3.175 ;in millimeters

    %PROBE_BLOCK_Z = 3.88 ;Thickness of 3-axis probe in Z direction
    %PROBE_BLOCK_Y = 12.8 ;Thickness of 3-axis probe in Y direction
    %PROBE_BLOCK_X = 12.8 ;Thickness of 3-axis probe in X direction

    G21 ;make sure we are in mm
    G91 ;Incremental mode
    G38.2 Z-25 F75 ;Probe Z
    G0 Z2 ;lift 2mm
    G38.2 Z-25 F45 ;Probe Z
    G4 P0.1
    G10 L20 P1 Z[PROBE_BLOCK_Z] ;Set Current Z as plate thickness
    G4 P0.1
    G0 Z3 ;lift Z 3mm
    G0 X-25 ;Move left 25mm
    G0 Z-10 ;Move down 10mm, should be 7mm below probe surface
    G38.2 X30 F75 ;Probe X to the right 30mm
    G0 X-2
    G38.2 X30 F45 ;Probe X to the right 30mm
    G4 P0.1
    G10 L20 P1 X[-ENDMILL_DIAMETER/2 -PROBE_BLOCK_X] ;Set current X location as negative half the bit diameter
    G4 P0.1
    G0 X-20 ;Move left 20mm
    G0 Y-35 ;Move forward 35mm
    G90 G0 X5 ;Move to X5 (absolute) - will put you 5mm to the right of left edge of stock
    G91 ;incremental
    G38.2 Y30 F75 ;Probe Y
    G0 Y-2
    G38.2 Y30 F45 ;Probe Y
    G4 P0.1
    G10 L20 P1 Y[-ENDMILL_DIAMETER/2 -PROBE_BLOCK_Y] ;Set current Y location as negative half the bit diameter - 7mm thickness
    G4 P0.1
    G0 Y-10 ;Move Y-10
    G0 Z10 ;Move Z up 10mm, should be 8mm above probe plate
    G90
    G0 X0Y0 ;Go to X0Y0
     
  2. David the swarfer

    David the swarfer OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Aug 6, 2013
    Messages:
    3,393
    Likes Received:
    1,892
    well, yeah, you didn't read the GRBL wiki (-:
    GRBL does not understand the %ENDMILL... variable definitions, you cannot use this code on a Blackbox 4x (however, similar code is possible on a X32, I hope to figure it all out over Christmas)

    in the code below I have replaced the variables with numbers and then calculated the results because GRBL cannot do the [] formulas
    will only work correctly with a 1/8" bit, I suggest using an accurate 1/8" pin instead of a bit, then swap to the bit and re-probe Z only

    Code:
    ; Set user-defined variables
    ;%ENDMILL_DIAMETER = 3.175    ;in millimeters    cant do this, need to remove variables from the code and put the numbers in where needed
    
    ;%3.88 = 3.88 ;Thickness of 3-axis probe in Z direction
    ;%PROBE_BLOCK_Y = 12.8 ;Thickness of 3-axis probe in Y direction
    ;%PROBE_BLOCK_X = 12.8 ;Thickness of 3-axis probe in X direction
    
    G21               ;make sure we are in mm
    G91               ;Incremental mode
    G38.2 Z-25 F75    ;Probe Z
    G0 Z2             ;lift 2mm
    G38.2 Z-25 F45    ;Probe Z
    G4 P0.1
    G10 L20 P1 Z3.88  ;Set Current Z as plate thickness
    G4 P0.1
    G0 Z3             ;lift Z 3mm
    G0 X-25           ;Move left 25mm
    G0 Z-10           ;Move down 10mm, should be 7mm below probe surface
    G38.2 X30 F75     ;Probe X to the right 30mm
    G0 X-2
    G38.2 X30 F45     ;Probe X to the right 30mm
    G4 P0.1
    G10 L20 P1 X-14.387    ;Set current X location as negative half the bit diameter
    G4 P0.1
    G0 X-20           ;Move left 20mm
    G0 Y-35           ;Move forward 35mm
    G90 G0 X5         ;Move to X5 (absolute) - will put you 5mm to the right of left edge of stock
    G91               ;incremental
    G38.2 Y30 F75     ;Probe Y
    G0 Y-2
    G38.2 Y30 F45     ;Probe Y
    G4 P0.1
    G10 L20 P1 Y-14.387  ;Set current Y location as negative half the bit diameter - 7mm thickness
    G4 P0.1
    G0 Y-10           ;Move Y-10
    G0 Z10            ;Move Z up 10mm, should be 8mm above probe plate
    G90               ; absolute mode
    G0 X0Y0           ; Go to X0Y0
    
    [/QUOTE]
     
  3. deonholt

    deonholt New
    Builder

    Joined:
    Nov 6, 2023
    Messages:
    8
    Likes Received:
    0
    [/QUOTE]

    Thank you so muck for your reply.
    No, I didn't read the Wiki. I just trusted that it will work.

    Thank you also for the tip on the bit. It really makes sense.

    Thanks again.
     
  4. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    14,701
    Likes Received:
    4,249
    You can still use it with CONTROL

    PROBE wizard > Probe Type > Custom > click the Gear icon > set your dimensions as offsets.

    No macro needed
     
  5. deonholt

    deonholt New
    Builder

    Joined:
    Nov 6, 2023
    Messages:
    8
    Likes Received:
    0
    Thanks. I tried but the spindle went the opposite direction of where the probe was. It went to the right hand top of the workpiece. I must have done something wrong. Will try again later.
     
  6. David the swarfer

    David the swarfer OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Aug 6, 2013
    Messages:
    3,393
    Likes Received:
    1,892
    check under advanced (top arrow in image below) for which corner you selected
    the bottom arrow points at the place where you set custom probe block size
    upload_2023-12-14_17-38-51.png
     
  7. deonholt

    deonholt New
    Builder

    Joined:
    Nov 6, 2023
    Messages:
    8
    Likes Received:
    0
    Thanks David.
    I have done that. What I don't understand is why I need to put in the dimensions of the work piece. II will try again and give feedback. Just to let you know, I don't have a Black Box or Openbuilds XYZ probe. I made my own XYZ probe.

    Thanks for your help.
     
  8. David the swarfer

    David the swarfer OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Aug 6, 2013
    Messages:
    3,393
    Likes Received:
    1,892
    you put in the stock dimension because we always probe front left corner and then set the offset from there using the stock dimensions.
    if you are probing and using the front left corner, then the dimensions are not needed
     
  9. deonholt

    deonholt New
    Builder

    Joined:
    Nov 6, 2023
    Messages:
    8
    Likes Received:
    0
     
    #9 deonholt, Dec 15, 2023
    Last edited: Dec 15, 2023

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