3D Touch Probe: gSender macros

Would you mind posting an issue on my github repo with the code for this change? I’d like to make the same change in the repo.

Thanks!

1 Like

sure!

20 characters limit.


results of setting XY zero with the touch probe using gSender. pretty damn good. Using the “stock” X & Y probing routines in gSender is pretty user friendly, and it attempts to probe the way the endmill/probing dowel would move using the bitzero. I did a test before actually sending the probe towards a solid object. I used 100mm/min and 50mm/min speeds for the initial and accurate probe speeds.

You have to specify the diameter of the “tool” you are using, in this case the probe tip diameter is 2mm

I didnt think to get a video, but it looks the same as everyone elses.

i got crpalmers probe_hole macro working after a slight modification, not sure if CNCjs differs from gSender, but it gave me errors running as is.

the picture above, is after running this macro to get my hole center on this part.

%RESTORE_FEEDRATE=600

%x0 = posx
%y0 = posy
%global.state.PROBE_DISTANCE = 25
%global.state.PROBE_FEED_FAST = 100
%global.state.PROBE_FEED_SLOW = 75

G91 ; Relative positioning

; ====================== X pass 1 ===============================

; Probe toward right side of hole with a maximum probe distance,
; zero at the point and then return to the starting point

G38.2 X[global.state.PROBE_DISTANCE] F[global.state.PROBE_FEED_FAST]
G38.4 X[-global.state.PROBE_DISTANCE] F[global.state.PROBE_FEED_SLOW]
G38.2 X[global.state.PROBE_DISTANCE] F[global.state.PROBE_FEED_SLOW]
%wait
%return_x = x0 - posx
G10 L20 X0
([return_x])
G1 X[return_x] F[RESTORE_FEEDRATE]

; Probe toward Left side of hole with a maximum probe distance,
; zero in the middle based on where it touches and return to X=0

G38.2 X[-global.state.PROBE_DISTANCE] F[global.state.PROBE_FEED_FAST]
G38.4 X[global.state.PROBE_DISTANCE] F[global.state.PROBE_FEED_SLOW]
G38.2 X[-global.state.PROBE_DISTANCE] F[global.state.PROBE_FEED_SLOW]
%wait
%return_x = -posx/2
G10 L20 X[posx/2]
G1 X[return_x] F[RESTORE_FEEDRATE]

; ====================== Y pass 1 ===============================

; Probe toward back side of hole with a maximum probe distance,
; zero at the point and return to the starting point

G38.2 Y[global.state.PROBE_DISTANCE] F[global.state.PROBE_FEED_FAST]
G38.4 Y[-global.state.PROBE_DISTANCE] F[global.state.PROBE_FEED_SLOW]
G38.2 Y[global.state.PROBE_DISTANCE] F[global.state.PROBE_FEED_SLOW]
%wait
%return_y = y0 - posy
G10 L20 Y0
G1 Y[return_y] F[RESTORE_FEEDRATE]

; Probe toward front side of hole with a maximum probe distance,
; zero in the middle when it touches and return to X,Y=0

G38.2 Y[-global.state.PROBE_DISTANCE] F[global.state.PROBE_FEED_FAST]
G38.4 Y[global.state.PROBE_DISTANCE] F[global.state.PROBE_FEED_SLOW]
G38.2 Y[-global.state.PROBE_DISTANCE] F[global.state.PROBE_FEED_SLOW]
%wait
%return_y = -posy/2
G10 L20 Y[posy/2]
G1 Y[return_y] F[RESTORE_FEEDRATE]

g90
2 Likes

I love seeing more of you using G38.4 in your macros!

2 Likes

i take zero credit, just modifying existing macros lol.

I did way too much testing on probing back when this all started. The combo of G38.2 & G38.4 really helped to increase the precision of the probing. I think there will always be limitations with the original grbl controllers, so every bit helps.

2 Likes

I added a comment in github but I guess you figured out what the error was. It would be good to get the Probe_Insert_Probe macro into your workflow though. With that you can set a Z zero using the probe as well. If you aren’t doing a tool length measurement of the probe, you’ll have problems trying to set Z zeros.

1 Like

yeah im not sure how i would get that working with the nomad toolsetter, wouldn’t i need to know the z difference between where the Nomad’s BitSetter triggers and where I would be probing with the touch probe (probably in a corner of the bed, since I dont think I can move the bed out of the way enough to probe the aluminum base plate.)

for the moment I’ve been re-running a BitSetter tool change after setting XY zero with the probe, and setting z zero by eye, but I would definitely like to get some variation of that macro working.

Ah now that’s clever! Trigger the sensor and set 0 as soon as the sensor is no longer tripped.
Today I learned.

(Thanks for giving me an hour or so of macro cleanup work :sweat_smile: )

I have bought and wired in a 0.01mm capable touch probe (various people have referred to one, from Amazon or wherever for about $70). It works really well, and leaves me now to adapt @NeilFerreri macros to be able to probe back left as well as front left.

These macros are up and running, and working exactly as I hoped, except for inertial errors…

The probing technique in these macros is to call G38.2 and wait for a trigger, then read the machine position.

Link to Chamnit discussing this (Grbl leader/guru): Change probe architecture from polled to interrupt · Issue #1095 · grbl/grbl · GitHub

I am seeing a consistent X and Y error when using my 0.01mm touch probe, and from what I can read this is down to deceleration (of necessity) in the X and Y gantries, the ‘inertia’ mentioned above. A suggestion to improve this (0.3mm approx) error is to read the PRBZ, PRBX and PRBY machine co-ordinates that are stored in the same stepper ‘step’ as the trigger happened, rather than the machine position when G38.2 returns.

The original macro line that stores X after probing is, current X ± probe dimensions etc;
G10 L20 P1 X[-ENDMILL_DIAMETER/2 -PROBE_BLOCK_X]

This would become, I think, with PRBX access;
G10 L20 P1 X[PRBX -ENDMILL_DIAMETER/2 -PROBE_BLOCK_X]

So, can gSender read PRB etc parameters? They appear in the console log, so I reckon gSender might have seen them…

I can concoct a test tomorrow, when I can get back on my machine, but I wonder if anyone knows for fact EDIT: testing doesn’t reveal any obvious way to obtain the PRB: results that happen in the instant the probe triggers - without access to this, one is reliant upon ‘calibrating the overshoot’ and compensating accordingly…

Any inputs on the PRB: data, and whether it does in fact get captured into a variable(s) would be much appreciated - for example: Tormach describe exactly this capture, but I cannot find anything in gSender or CNCjs that refers…

3 Likes

I think the G38.4 would be much more accurate than the 38.2s.
It’s probably still a similar issue in that it’s not storing the exact coordinates but moving away from the target can be done at a much slower rate without extending the probe time too much.

So leveraging a very slow G38.4 may be the most accurate we can get with an unmodified setup :thinking:

Not yet…

@neilferreri OK, understood.

@HeuristicBishop My approach to compensate for the overshoot is to approach the workpiece/puck with G38.2 at 150/mm-min, then retreat using G38.4 at 15mm/min. Observing the machine during this, with Chamnit’s explanation of deceleration in mind, even at very slow speeds (2mm/min) the steppers continue for 12 steps after first contact - almost like the deceleration routine has ‘12’ somewhere enshrined in its logic.

One last optimisation is have in mind to explore: storing current machine pos from a slow G38.2 approach, then retreating using slow G38.4 and halving the positions to give the mid-point. It will mean 3 G38’s if a fast approach is also necessary (for time reasons). One to have a play with…

It’s the best I have for now, and hopefully ‘Not yet…’ will bring something along :slight_smile:

If 12 really is a magic number like some hardcoded minimum deceleration value then at least it’s consistent.

If it’s consistent then maybe hardcoding your offset in the routines isn’t terribly crazy.
Splitting the difference should do roughly the same thing, with the 12 steps in opposite directions effectively cancelling but i wonder if it’s necessary :thinking:

I suppose at the end of the day, either method would net you some exceptionally accurate results compared to what most folks are looking for :grin:

Thanks for sharing this new found quirk of gSender

I’ve coded two macros for gSender (or CNCjs, based on @neilferreri published examples) that bisect the error from a G38.2 followed by a G38.4 probe cycle. With these (one for front/left and one back/left) I am seeing approx 0.03mm error, noting that the step resolution on the ShapeOKO 3XL is (1.8deg-step and 8 micro-steps on GT2/20T) 0.025mm.

Macro logic is: Probe G38.2 fast to locate edge, retreat a little, probe G38.2 slowly and note machine position on completion, probe ‘away’ G38.4 slowly and again note machine position. Halve the difference, adjust for the probe/puck size and probe tip diameter, set zero.

Unless or until Sienci incorporate PRB: capture into gSender, this is likely as good as it gets. I have made a feature request accordingly.

Files attached, hopefully self-explanatory. The key controlling ‘dimension variables’ are all at the top of the scripts, so you can tweak according to your preference.

gSender Macro Probe Scripts.zip (4.0 KB)

As is usual: Caveat Emptor…

1 Like

I was trying to determine the offset that would be needed for using the probe tip with the bitsetter, so i ran a modified version of the bitsetter tool change macro, having the machine stop after the last G38.4 command

I noted down the machine position after that macro ran. then i moved the spindle up & over to a probably touch probe probing location (just left of the bitsetter pin). I moved the endmill as close as possible to the aluminum shroud that acts as the floor of the nomad.

To do my best to verify my accuracy, I moved the endmill up by 0.1mm and I was barely able to slip the paper under the endmill. After moving the endmill back down by .08mm, the thickness of the paper, i was still above my set Z zero by .02mm, so i know my Z zero is set as accurately as i think is possible)

I noted the machine position after moving the endmill as described. Then taking those 2 values and subtracting them from each other, that should result in the height of the bitsetter when active, which should be approximately 23.86mm.

If anyone wants to run this test, run the same test and post your results.

In theory this value could be used to offset a tool length measurements taken off a probing point that has a known height, something like this:

this little probe point would be held in place with 3M adhesive, and the bitsetter pin would go through the hole, and the touch probe would touch off on the flat portion, just to the left.


modified bitsetter routine, to stop after bitsetter is no longer engaged, after the G38.4

;Bitsetter measure tool better

; Wait until the planner queue is empty
%wait

%global.state.SAFE_HEIGHT = -10          ; clear everything height(negative number, distance below Z limit)
; Set BitSetter probe location
%global.state.BITSETTER_X_LOCATION = -5  ; machine coordinates
%global.state.BITSETTER_Y_LOCATION = -3  ; machine coordinates
%global.state.BITSETTER_Z_LOCATION = -20 ; machine coordinates --> lower this (more negative) to start the probing closer to wasteboard

; Location for tool changes
%global.state.TOOLCHANGE_X = -125

%global.state.BITSETTER_PROBE_DISTANCE = 100
%global.state.BITSETTER_PROBE_FEEDRATE = 300 ; mm/min

; Wait until the planner queue is empty
%wait

; Keep a backup of current work position
%X0=posx, Y0=posy, Z0=posz

; Save modal state
%WCS = modal.wcs
%PLANE = modal.plane
%UNITS = modal.units
%DISTANCE = modal.distance
%FEEDRATE = modal.feedrate
%SPINDLE = modal.spindle
%COOLANT = modal.coolant

G21 ; metric
M5  ; Stop spindle
G90 ; Absolute positioning

; Get to a safe height and park for tool change
G53 G0 Z[global.state.SAFE_HEIGHT]
G53 X[global.state.TOOLCHANGE_X] Y[global.state.BITSETTER_Y_LOCATION]

; Pause for manual tool change & probing
%wait
M0 ; Please insert a tool

; Go to BitSetter
G53 X[global.state.BITSETTER_X_LOCATION] Y[global.state.BITSETTER_Y_LOCATION]
G53 Z[global.state.BITSETTER_Z_LOCATION]

%probe_start_z = posz

G91 ; Relative positioning

G38.2 z-[global.state.BITSETTER_PROBE_DISTANCE] F[global.state.BITSETTER_PROBE_FEEDRATE]; fast probe (so it doesn't take forever)
G0 z2
G38.2 z-5 F40 ; "dial-it-in" probes
G4 P.25
G38.4 z10 F20
G4 P.25
G38.2 z-2 F10
G4 P.25
G38.4 z10 F5 ; probe away from bitsetter and then stop
1 Like

I finished off the probesetter (all the credit to @HeuristicBishop for the name.) touch locations, now to put some double sided tape on them and put one in place, and see if my idea for the necessary macro will work to set tool length for the touch probe.





4 Likes

I tested my first version of what I am calling the Touch Probe Tool Change macro, and my order of operations went like so to test it, and it seems to have worked swimmingly.


PRE-MACRO SETUP

I first ran the modified bitsetter routine, to determine the activation height relative the the aluminum shroud/floor of the nomad. I then measured my ProbeSetter Pad’s height, and subtracted the two to get an appropriate offset. For me, that is noted as variable %probesetter_height_offset

This will probably be different on a machine to machine basis, and obviously on whatever type of pad one decides to come up with and the accuracy of how the machine it or make it.


FIRST TEST RUN

Step 1: Open gSender
Step 2: Insert Touch Probe
Step 3: Run Touch Probe Tool Change macro
Step 4: Set Z zero using Touch Probe (and set XY somewhere i wouldnt hit anything)
i set my Z zero at the height of my SMW soft jaw, just as a useful datum that i could jog over/to later

Step 5: Run BitSetter ToolChange macro [from @natewalck]
Step 6: Move tool back to XY zero, then manually jog back to work zero
(i used the goto once before and it went too low because i forgot a step, and nearly s**t myself)

During Step 6 i slowly jogged over to the SMW jaw, and 1mm at a time, jogged the new tool (actually a probing dowel for the bitzero) over the jaw, and the bottom of the dowel right up against the jaw. I had the ability to slide the jaw (with resistance) under the dowel, which indicates to me that its pretty damn close.

without an indicator of some sort im not sure of a more accurate method of verification.


Tentative Touch Probe Tool Change Macro [in reality this is @natewalck’s BitSetter Macro modified to adjust the X position for the ProbeSetter pad location, the tooltip to remind the user to plug in the cable for the touch probe, and the additional offset subtraction]

; measure touch probe length

; Wait until the planner queue is empty
%wait

%global.state.SAFE_HEIGHT = -10          ; clear everything height(negative number, distance below Z limit)
; Set BitSetter probe location
%global.state.PROBESETTER_X_LOCATION = -18.50  ; machine coordinates
%global.state.PROBESETTER_Y_LOCATION = -3  ; machine coordinates
%global.state.PROBESETTER_Z_LOCATION = -20 ; machine coordinates --> lower this (more negative) to start the probing closer to wasteboard

; Location for tool changes
%global.state.TOOLCHANGE_X = -125

%global.state.BITSETTER_PROBE_DISTANCE = 100
%global.state.BITSETTER_PROBE_FEEDRATE = 100 ; mm/min

; Wait until the planner queue is empty
%wait

; Keep a backup of current work position
%X0=posx, Y0=posy, Z0=posz

; Save modal state
%WCS = modal.wcs
%PLANE = modal.plane
%UNITS = modal.units
%DISTANCE = modal.distance
%FEEDRATE = modal.feedrate
%SPINDLE = modal.spindle
%COOLANT = modal.coolant

G21 ; metric
M5  ; Stop spindle
G90 ; Absolute positioning

; Get to a safe height and park for tool change
G53 G0 Z[global.state.SAFE_HEIGHT]
G53 X[global.state.TOOLCHANGE_X] Y[global.state.PROBESETTER_Y_LOCATION]

; Pause for manual tool change & probing
%wait
M0 ; Please insert touch probe and connect cable!

; Go to BitSetter
G53 X[global.state.PROBESETTER_X_LOCATION] Y[global.state.PROBESETTER_Y_LOCATION]
G53 Z[global.state.PROBESETTER_Z_LOCATION]

%probe_start_z = posz

G91 ; Relative positioning

G38.2 z-[global.state.BITSETTER_PROBE_DISTANCE] F[global.state.BITSETTER_PROBE_FEEDRATE]; fast probe (so it doesn't take forever)
G0 z2
G38.2 z-5 F40 ; "dial-it-in" probes
G4 P.25
G38.4 z10 F20
G4 P.25
G38.2 z-2 F10
G4 P.25
G38.4 z10 F5
G4 P.25

G90 ; Absolute positioning
%wait

; Get the Z position at the end of measuring tool length
; the probe_setter_height_offset will be different for each user or machine
%probesetter_height_offset = 14.51; mm height to subtract from tool length because probesetter is shorter than bitsetter activation height
%probe_end_z = posz
%probe_actual_distance = probe_start_z - probe_end_z
%probe_compensated_distance = probe_actual_distance - probesetter_height_offset ; subtract offset from actual length, because it will always be longer by offset.
(actual=[probe_actual_distance] compensated=[probe_compensated_distance])
%probe_actual_distance = probe_compensated_distance ; assign tempvariable we used for printing to console
%is_initial_tool = ! (global.state.PROBE_ACTUAL_DISTANCE > 0)

; Update Z offset for new tool
; note: do this in individual steps otherwise it sometimes treats some variables as strings (wtf??)
;     resulting in new_z=-31.0423.3225252

%delta_z = is_initial_tool ? 0 : probe_actual_distance*1.0 - global.state.PROBE_ACTUAL_DISTANCE*1.0
%new_z = posz*1.0 + delta_z*1.0
%new_z  =  Math.round(new_z * 1000) / 1000
(old=[global.state.PROBE_ACTUAL_DISTANCE] new=[probe_actual_distance] new_z=[new_z])

G10 L20 Z[new_z]

%global.state.PROBE_ACTUAL_DISTANCE = probe_actual_distance

%wait

G91 ; Relative positioning
G0 Z5
G90 ; Absolute positioning
G53 Z[global.state.SAFE_HEIGHT] ; Move in machine coordinates to safe height
%wait
; go back to tool change location to begin toolpath again
G53 X[global.state.TOOLCHANGE_X] Y[global.state.PROBESETTER_Y_LOCATION]

; Restore modal state
[PLANE] [UNITS] [DISTANCE] [FEEDRATE] [SPINDLE] [COOLANT]
3 Likes

This topic was automatically closed after 30 days. New replies are no longer allowed.