Macros for 3D probing

I have a few 3D probe macros that I would be happy to share too - if they help someone get started, or seed an idea, then it is succeeding!

As someone with a new 3D probe and a new SLB ā€“ curious to try out your 3D probe macros!

John - attached is a JSON file you can import directly into gSender macros tab. All of these use the new ā€˜PRBā€™ functionality that came out in the last ā€˜Edgeā€™ version, and is now standard in the main release code. PRB offers better accuracy than was previously available.
The description of each Macro tells what it is for, with ā€˜FLā€™ meaning front-left, ā€˜no Zā€™ meaning it doesnā€™t alter the Z-zero, etc.
To use the macro, say the front-left, position the probe 10mm above and 10mm ā€˜in landā€™ of the corner, then run it. The sequence will be to move towards you on Y, drop down and locate the edge, then lift up move inland then left on X, drop down and locate the edge. It then sets 0,0 for you, lifts and positions the probe exactly on 0,0 so you can visually confirm position.
There is also a ā€˜Sin-A probeā€™ which uses circular trigonometry to find the centre of a solid cylinder running along the Y axis, such as is a common need when using a rotary axis. It works very well from my trials - certainly far better than eye-balling.
Iā€™ve tried to document the macros within, and used sensible variable names to aid understanding. If thereā€™s anything that doesnā€™t make sense, message me and I will try to help.
As ever with these things, use entirely at your own risk,
gSender-macros-31_08_2024-15_27_09 copy.json (28.8 KB)

1 Like

Thanks! Sounds like a perfect thing to test this 3-day weekend!

I tidied up the JSON to remove some duplicatesā€¦ a hint to the developers: managing macros is not easy in gSender. Editing them is OK, running them is OK except it might be useful to show hints to the user before they run the chosen macro
gSender-macros-31_08_2024-16_09_48.json (23.6 KB)

1 Like

Just a word of caution using probe macros. The macro doesnā€™t know if something is wrong (incorrect starting position, probe not plugged in etc), and as a result your probe is vulnerable to the forces of the machine (as I found outā€¦ now I have 2 probes, one broken).
To enhance macro functionality and safety, it would be really neat if simple dialogs could be popped up asking for confirmation of some fact or position - with the option to Cancel or Proceed. Were this an accepted line of thinking to the developers, allowing dialogs to feed back a choice/choices and perhaps a value/values would open up a whole new world for macro creatorsā€¦

1 Like

Yeah - I think my first test will be while holding a block of hard foam with my fingersā€¦ :slight_smile:

Greetings!

Iā€™ve loaded the macros, and have been testing with a ā€œsafeā€ block of foam (with some card stock on top to get a somewhat hard surface). Using the Probe FL PRB XYZ macro, the probing action seems correct (approach, touch, back-off, approach, touch) but then the probe moves well away from the workpiece, and X and Y are showed are reset to zero, at this far left position, well away from the workpiece.

My machine is pretty small, with build area of roughly 305 mm in X and 235 in Y. Curious if you have any thoughts, or suggestions to troubleshoot.

The Macro:

(Probe FRONT LEFT TOP with $# PRB. Position probe up to 15mm inland and above corner)

; Set user-defined variables

%PROBE_TIP_DIA = 2.0		; Diameter in mm
%PROBE_INERTIA_Z = 0.00		; Machine overshoot Z due to inertia
%PROBE_INERTIA_XY = 0.00	; Machine overshoot XY due to inertia

%PROBE_BLOCK_X = 0		; Probe/puck thickness, X
%PROBE_BLOCK_Y = 0		; Probe/puck thickness, Y
%PROBE_BLOCK_Z = 0		; Probe/puck thickness, Z

%PROBE_PROBE_RANGE = 10.0	; Range that G38.x will use
%PROBE_CLOSE_RANGE = 1.0	; Distance to retreat before slow probe
%PROBE_PROBE_SLOW = 50.0	; Slow probe rate for G38.x
%PROBE_PROBE_FAST = 150.0	; Fast probe rate for G38.x
%PROBE_DROP_BY = 4.0		; Distance Z drops before probing (typ double WITHDRAW) JO: Was 7 now 4
%PROBE_WITHDRAW = 3.0		; Distance axes pull back after probing

; Wait until the planner queue is empty

%wait

; *** FRONT LEFT 'TO and AWAY' PROBE XYZ ***

G21		; Make sure weā€™re in mm
M5		; Just to be sure, ensure spindle is stopped
G91 	; Incremental mode

; *** Z Probe *** Downwards is -ve

G38.2 Z[-PROBE_PROBE_RANGE] F[PROBE_PROBE_FAST]	; First probe quickly to find Z
G0 Z[PROBE_CLOSE_RANGE]	; Withdraw now Z crudely located, raise Z a little
%wait
G38.2 Z[-PROBE_PROBE_RANGE] F[PROBE_PROBE_SLOW]	; Now probe TO slowly to reduce inertia
$# ; Ask for PRB report
%wait ; Let Reports catch up
%PROBE_Z=(params.PRB.z) ; Retrieve Z from PRB
([PROBE_Z])
;([JSON.stringify(params.PRB.z)])
G10 L20 P1 Z[PROBE_Z +PROBE_BLOCK_Z -PROBE_INERTIA_Z]	; Set Z0 with PRB compensations

G0 Z[PROBE_WITHDRAW]	; Pull up Z to clear puck/workpiece

; *** X Probe *** Rightwards is +ve

G0 X[-PROBE_PROBE_RANGE]	; Move left
G0 Z[-PROBE_DROP_BY]		; Drop Z below top of puck/workpiece

G38.2 X[PROBE_PROBE_RANGE] F[PROBE_PROBE_FAST]	; Probe TO X to the right quickly
G0 X[-PROBE_CLOSE_RANGE]	; Withdraw a little
%wait
G38.2 X[PROBE_PROBE_RANGE] F[PROBE_PROBE_SLOW]	; Now probe TO slowly to reduce inertia
$# ; Ask for PRB report
%wait ; Let Reports catch up
%PROBE_X=params.PRB.x ; Retrieve X from PRB
G10 L20 P1 X[PROBE_X -PROBE_TIP_DIA/2.0 +PROBE_BLOCK_X -PROBE_INERTIA_XY]	; Set X0 with compensations

G0 X[-PROBE_WITHDRAW]	; Move left by retract distance to clear block
G0 Z[PROBE_DROP_BY]	; Raise Z to avoid conflict when moving

; *** Y Probe *** Backwards is +ve

G0 Y[-PROBE_PROBE_RANGE]	; Move forward towards front of machine
G0 X[PROBE_PROBE_RANGE]		; Move right
G0 Z[-PROBE_DROP_BY]		; Drop Z below top of puck/workpiece

G38.2 Y[PROBE_PROBE_RANGE] F[PROBE_PROBE_FAST]	; Probe TO Y rearwards quickly
G0 Y[-PROBE_CLOSE_RANGE]	; Withdraw a little forwards

G38.2 Y[PROBE_PROBE_RANGE] F[PROBE_PROBE_SLOW]	; Probe TO Y slowly
$# ; Ask for PRB report
%wait ; Let Reports catch up
%PROBE_Y=params.PRB.y ; Retrieve Y from PRB
G10 L20 P1 Y[-PROBE_Y -PROBE_TIP_DIA/2.0 -PROBE_BLOCK_Y +PROBE_INERTIA_XY]	; Set Y0 with compensations

G0 Y[-PROBE_WITHDRAW]	; Move forward to clear puck/workpiece
G0 Z[PROBE_DROP_BY]	; Raise Z to avoid conflict when moving

; *** Wrap-up ***

G90		; Back into Absolute mode
G0 X0Y0		; Go to this new X0Y0

; *** All Done ***

The console output:

ok

feeder (Probe FRONT LEFT TOP with $# PRB. Position probe up to 15mm inland and above corner)
ok
feeder G4 P0.5
ok
feeder G21
ok
feeder M5
ok
feeder G91
ok
feeder G38.2 Z-10 F150
[PRB:103.416,29.417,-21.306,0.000:1]
ok
feeder G0 Z1
ok
feeder G4 P0.5
ok
feeder G38.2 Z-10 F50
[PRB:103.416,29.417,-21.199,0.000:1]
ok
feeder $#
[G54:1.007,59.364,-0.007,0.000]
[G55:0.000,0.000,0.000,0.000]
[G56:0.000,0.000,0.000,0.000]
[G57:0.000,0.000,0.000,0.000]
[G58:0.000,0.000,0.000,0.000]
[G59:0.000,0.000,0.000,0.000]
[G59.1:0.000,0.000,0.000,0.000]
[G59.2:0.000,0.000,0.000,0.000]
[G59.3:0.000,0.000,0.000,0.000]
[G28:0.000,0.000,0.000,0.000]
[G30:0.000,0.000,0.000,0.000]
[G92:0.000,0.000,0.000,0.000]
[HOME:0.000,0.000,0.000,0.000:7]
[TLO:0.000,0.000,0.000,0.000]
[PRB:103.416,29.417,-21.199,0.000:1]
ok
feeder G4 P0.5
ok
feeder (-21.199)
ok
feeder G10 L20 P1 Z-21.199
ok
feeder G0 Z3
ok
feeder G0 X-10
ok
feeder G0 Z-4
ok
feeder G38.2 X10 F150
[PRB:96.165,29.417,-22.208,0.000:1]
ok
feeder G0 X-1
ok
feeder G4 P0.5
ok
feeder G38.2 X10 F50
[PRB:96.213,29.417,-22.208,0.000:1]
ok
feeder $#
[G54:1.007,59.364,-0.009,0.000]
[G55:0.000,0.000,0.000,0.000]
[G56:0.000,0.000,0.000,0.000]
[G57:0.000,0.000,0.000,0.000]
[G58:0.000,0.000,0.000,0.000]
[G59:0.000,0.000,0.000,0.000]
[G59.1:0.000,0.000,0.000,0.000]
[G59.2:0.000,0.000,0.000,0.000]
[G59.3:0.000,0.000,0.000,0.000]
[G28:0.000,0.000,0.000,0.000]
[G30:0.000,0.000,0.000,0.000]
[G92:0.000,0.000,0.000,0.000]
[HOME:0.000,0.000,0.000,0.000:7]
[TLO:0.000,0.000,0.000,0.000]
[PRB:96.213,29.417,-22.208,0.000:1]
ok
feeder G4 P0.5
ok
feeder G10 L20 P1 X95.213
ok
feeder G0 X-3
ok
feeder G0 Z4
ok
feeder G0 Y-10
ok
feeder G0 X10
ok
feeder G0 Z-4
ok
feeder G38.2 Y10 F150
[PRB:103.219,24.837,-22.208,0.000:1]
ok
feeder G0 Y-1
ok
feeder G38.2 Y10 F50
[PRB:103.219,24.749,-22.208,0.000:1]
ok
feeder $#
[G54:1.006,59.364,-0.009,0.000]
[G55:0.000,0.000,0.000,0.000]
[G56:0.000,0.000,0.000,0.000]
[G57:0.000,0.000,0.000,0.000]
[G58:0.000,0.000,0.000,0.000]
[G59:0.000,0.000,0.000,0.000]
[G59.1:0.000,0.000,0.000,0.000]
[G59.2:0.000,0.000,0.000,0.000]
[G59.3:0.000,0.000,0.000,0.000]
[G28:0.000,0.000,0.000,0.000]
[G30:0.000,0.000,0.000,0.000]
[G92:0.000,0.000,0.000,0.000]
[HOME:0.000,0.000,0.000,0.000:7]
[TLO:0.000,0.000,0.000,0.000]
[PRB:103.219,24.749,-22.208,0.000:1]
ok
feeder G4 P0.5
ok
feeder G10 L20 P1 Y-25.749
ok
feeder G0 Y-3
ok
feeder G0 Z4
ok
feeder G90
ok
feeder G0 X0Y0
ok

Thanks!

Iā€™ve read through your console output and compared this to the macro expectations, line by line, and all is as expected except for the final G10 L20 setting Y zero. It looks like your machine has a ā€˜machine zeroā€™ other than top right corner (where 0,0 is located). If yours happens to be top left corner, it might explain why I am seeing a negative G10 L20 offset for Y, when all of your PRB coordinates in Y are positive.
If your machine is fixed in what it uses as its 0,0 datum, then the macro will have to be tweaked. If it is just your habit to move the machine to top left and then reset, then either tweak the macro or change habit to be top right (per most of the machines I am aware of).
The macro line that will need editing is:
G10 L20 P1 Y[-PROBE_Y -PROBE_TIP_DIA/2.0 -PROBE_BLOCK_Y +PROBE_INERTIA_XY] ; Set Y0 with compensations
Any other macros dealing with Y axis zero will need similar editing

You are correct ā€“ my machine homes to top left. Iā€™ll modify the macros as needed. Thanks!

2 Likes

Interestingly, the built-in gSender 1.4.9 probing routines (at least for Z, and XYZ) almost works. When probing for XYZ, after probing for Z, when the probe moves left and then down to start probing for X, itā€™ll attempt to move down too far, if the workpiece is thin. For example, if I try to probe something 10mm thick, itā€™ll hit the build plate before running inwards towards the piece.

So closeā€¦ Back to macro hacking. :slight_smile:

I donā€™t believe the ā€˜movement rangeā€™ and ā€˜depth soughtā€™ parameters are configurable in gSender, so if you want to probe slimmer pieces than they designed for, you have no choice but to use macros. They work nicely and are configurable, so all good :slight_smile:

Yes ā€“ the Sienci ā€œLongmill mindsetā€ for defaults doesnā€™t match my typical use-case of sub 20mm thick 6061 aluminum stock to create parts for 3D printers, etc. (Those are M3 bolt holes bored and threaded via my CNC machine. The milled piece is alongside the 3D printed part it is replacing.)

Iā€™ve modified the G10 entries to deal with my XY Zero position. Unfortunately, behavior is still not what Iā€™m expecting.

Are you using the SuperLongBoard and grblHAL? I wonder if that could be a difference?

From what I can see, the 38.2 commands are functioning properly and the PRB shows the correctly probed coordinates. It also appears the correct value is being stuffed into the G10 commands, but at the end when I expect G0 XY0 to move to the freshly set work coordinates XY0, it instead goes to machine XY0 (and also shows work coordinate XY0 being within 1mm of XY0).

Iā€™ve attached my revised XYZ macro and corresponding output.

Thanks!
Updated XYZ macro.txt (3.2 KB)
Updated XYZ output.txt (2.4 KB)

Iā€™m not using LB, SLB or have a LM, although wish I could convince myself to get the new AltMill!
My machine was a Carbide3D 3XL, but it is extensively modified including a replacement controller - a Teensy 4.1 running GrblHAL and a Bob Barrett break-out-board for the machine connections. So it is ā€˜much likeā€™ the new SLB in many ways.
One thing that comes to mind - are you using G54 as the default coordinate workspace? I am sure 99% of users will be just using the gSender default that is this. Worth a check - I think the drop-down that selects this is somewhere upper right in the main UI (donā€™t have sight of mine, so doing this from memory).
I will take a read of your notes tomorrow and see if I can spot anything else.

Thanks for the info. Yes, I am using the standard G54. But you are tracking with one of my areas of investigation. You see, the PRB line of data is correct, but I never see the new values being stuffed into the G54 line in this table. But I donā€™t know enough to know if that is an issue or not.


feeder $#
[G54:1.007,1.003,-0.005,0.000]
[G55:0.000,0.000,0.000,0.000]
[G56:0.000,0.000,0.000,0.000]
[G57:0.000,0.000,0.000,0.000]
[G58:0.000,0.000,0.000,0.000]
[G59:0.000,0.000,0.000,0.000]
[G59.1:0.000,0.000,0.000,0.000]
[G59.2:0.000,0.000,0.000,0.000]
[G59.3:0.000,0.000,0.000,0.000]
[G28:0.000,0.000,0.000,0.000]
[G30:0.000,0.000,0.000,0.000]
[G92:0.000,0.000,0.000,0.000]
[HOME:0.000,0.000,0.000,0.000:7]
[TLO:0.000,0.000,0.000,0.000]
[PRB:53.911,48.490,-18.508,0.000:1]

If this was a cut from the console output you posted before, it was in response to the $# command immediately after the G38.2 but prior to the G10 L20 command that sets the Y offset into the P1 workspace (G54). So this was reporting the coordinates and offsets as probing finished (and PRB at the exact location where the probe triggered).
Given that your machineā€™s absolute zero is top left, probe coord Y absolute (from PRB) was 48.490 and allowing for half of the 2mm dia probe tip, I would expect the G10 L20 to compute 47.490 to store in G54, which it does.
Can I suggest an experiment to find out what is going on from cold?

  • re-start the machine and zero it as usual
  • move to somewhere away from machine zero, but not near the corner of your workpiece and manually set X and Y zeros (just so old and new zero positions donā€™t get confusing to read when the macro runs)
  • add an extra $# into the macro just after the G91 line (right near the start), so we can capture the status before the macro starts changing things
  • add a ? line immediately after this to ask for machine and work coords at the current position
  • add an extra $# into the macro just after the line G10 L20 P1 Y[PROBE_Y ā€¦ so we can capture the exact status after G54 should have been updated
  • run the macro and capture the macro and console output in TXT files as you did before

I remain a little confused as to why your machine Y coords are not reporting negative. Top right homing machines report all X and Y as machine negative, top left would logically to my mind report X positive and Y negative. Hopefully the extra $# and ? commands will help resolve what is happening

One thing Iā€™ve noticedā€¦ you are using an early version amongst the macros I posted. After writing this one I tidied things up and made things more robust in macro: PRB.xyz FL with z

This probes Z first, sets Z-zero, then probes X and zeros it, then probes Y and zeros it.

A significant difference is that I call the Machine Position (mpos) in addition to the Probe position (params.prb) when calculating Work Coordinate offsetsā€¦ it sounds awfully close by subject to the issues you are seeing - I should perhaps have deleted that earlier macro before posting my collection!

Repeated here, complete with the extra fault finding steps discussed above added. Note in this later macro version that I have used G38.2 then G38.4 for the probing (to and away, respectively) as it is faster and more elegant as a solution than probing to, moving back and then probing to again.

Macro code:

(Probe FRONT LEFT TOP with PRB. Position probe up to 15mm inland and above corner)

;*** Set user-defined variables
%PROBE_LAG = 0.20 ; Lag from touch to trigger
%PROBE_TIP_DIA = 2.00 ; Measured tip dia in mm
%PROBE_PROBE_RANGE = 10.0 ; Range that G38.x will use
%PROBE_CLOSE_RANGE = 1.0 ; Distance to retreat before slow probe
%PROBE_PROBE_SLOW = 50.0 ; Slow probe rate for G38.x
%PROBE_PROBE_FAST = 150.0 ; Fast probe rate for G38.x
%PROBE_DROP_BY = 5.0 ; Distance Z drops before probing JO: was 7 now 5
%PROBE_WITHDRAW = 3.0 ; Distance axes pull back after probing

; *** Would be good if BLOCK dimensions could be pulled from gSender setup
%PROBE_BLOCK_X = 0 ; Probe/puck thickness, X
%PROBE_BLOCK_Y = 0 ; Probe/puck thickness, Y
%PROBE_BLOCK_Z = 0 ; Probe/puck thickness, Z

; *** Wait until the planner queue is empty
%wait

; Keep a backup of current system status
%WCS = modal.wcs
%PLANE = modal.plane
%UNITS = modal.units
%DISTANCE = modal.distance
%FEEDRATE = modal.feedrate
%SPINDLE = modal.spindle
%COOLANT = modal.coolant

; *** Ensure we are in the right mode
G21 ; Make sure weā€™re in mm
M5 ; Just to be sure, ensure spindle is stopped
G91; Incremental mode

$# ; JO: debug command
(X:[mposx], Y:[mposy], Z:[mposz]) ; JO: debug command

; *** Z Probe *** Downwards is -ve *** Find Z then zero Z ***
G38.2 Z[-PROBE_PROBE_RANGE] F[PROBE_PROBE_FAST] ; Probe down quickly find Z
G38.4 Z[PROBE_PROBE_RANGE] F[PROBE_PROBE_SLOW] ; Probe back up slowly for Z
%wait
%PROBE_Z = params.PRB.z ; Retrieve Z from PRB
%MPZ = mposz ; Get machine resting absolute position to compare PRB to
%ADJZ = MPZ - PROBE_Z

; *** Set Z-Zero to accurate PRB.z position
G10 L20 P1 Z[ADJZ +PROBE_BLOCK_Z] ; Set Z0 with PRB & Puck compensation
G0 Z[PROBE_WITHDRAW - ADJZ] ; Pull up Z to clear puck/workpiece, if G38.4

; *** X Probe *** Rightwards is +ve
G0 X[-PROBE_PROBE_RANGE] ; Move left
G0 Z[-PROBE_DROP_BY] ; Drop Z below top of puck/workpiece
G38.2 X[PROBE_PROBE_RANGE] F[PROBE_PROBE_FAST] ; Probe TO X to right quickly
G38.4 X[-PROBE_PROBE_RANGE] F[PROBE_PROBE_SLOW] ; Slow AWAY probe
%wait
%PROBE_X = params.PRB.x ; Retrieve X from PRB
%MPX=mposx
%ADJX = MPX - PROBE_X - PROBE_LAG ; *** CHECK ORIENTATION ********
; Print to console the ADJ calculation
(MPX - PROBE_X - PROBE_LAG is: [MPX] - [PROBE_X] - [PROBE_LAG] = [ADJX])

; *** Set X0 to accurate PRB.x position
G10 L20 P1 X[ADJX -(PROBE_TIP_DIA/2.0) +PROBE_BLOCK_X] ; Set X0 with comps

$# ; JO: debug command
(X:[mposx], Y:[mposy], Z:[mposz]) ; JO: debug command

G0 X[-PROBE_WITHDRAW] ; Move left by retract distance to clear block
G0 Z[PROBE_DROP_BY] ; Raise Z to avoid conflict when moving

; *** Y Probe *** Backwards is +ve
G0 X[PROBE_PROBE_RANGE] Y[-PROBE_PROBE_RANGE] ; Move frontward and right
G0 Z[-PROBE_DROP_BY] ; Drop Z below top of puck/workpiece
G38.2 Y[PROBE_PROBE_RANGE] F[PROBE_PROBE_FAST] ; Probe TO Y rearwards quickly
G38.4 Y[-PROBE_PROBE_RANGE] F[PROBE_PROBE_SLOW] ; Probe AWAY Y to the front slowly
%wait
%PROBE_Y = params.PRB.y ; Retrieve Y from PRB
%MPY=mposy
%ADJY = MPY - PROBE_Y - PROBE_LAG ; *** CHECK ORIENTATION ********
; Print to console the ADJ calculation
(MPY - PROBE_Y - PROBE_LAG is: [MPY] - [PROBE_Y] - [PROBE_LAG] = [ADJY])

; *** Set Y0 to accurate PRB.y position
G10 L20 P1 Y[ADJY -PROBE_TIP_DIA/2.0 -PROBE_BLOCK_Y ] ; Set Y0 with comps

$# ; JO: debug command
(X:[mposx], Y:[mposy], Z:[mposz]) ; JO: debug command

G0 Y[-PROBE_WITHDRAW] ; Move forward to clear puck/workpiece
G0 Z[PROBE_DROP_BY] ; Raise Z to avoid conflict when moving

; *** Wrap-up, position to above newly found X0Y0
G90 ; Back into Absolute mode
G0 X0 Y0 ; Go to this new X0Y0

; All done, Restore modal state
[WCS] [PLANE] [UNITS] [DISTANCE] [FEEDRATE] [SPINDLE] [COOLANT]

I suggest you still run through the experiment steps mentioned 2 posts ago (re-start, home etc) but using this new macro code.
Hopefully this will get us to understand any issues and get you working as you hope for!

@AndyCXL @JohnOCFII Iā€™ve created a new topic and moved your posts. I believe the new topic better describes this conversation. Keep up the good work.

1 Like