How does probing work?

Look here to see if your question has already been answered.
PNSNengineering
Posts: 14
Joined: Tue Jun 01, 2021 5:15 pm

Re: How does probing work?

Post by PNSNengineering » Fri Jun 04, 2021 9:11 pm

Thanks, that actually helped a lot. I knew about parameters (vaguely) but I didn't see any free parameters to use when glancing through the LinuxCNC documentation - although I could have missed it, a lot of that is foreign to me. But for example the Haas control has a range of numbers that are unused parameters that can be used by the programmer.

Anyways, the ability to change and set parameters I think solves my problem. Since the BB control doesn't currently have a display for the tool table and this will happen automatically I think it's easiest just to touch off at each tool change. Here's what I came up with - basically just store the Z height of the last tool touched off, then after the tool change compare it to the new height the tool touched off at. The difference is the amount the Z offset needs updated by. See code below - note that I have not tested this on machine yet, I've just been writing it as I learn more about the LinuxCNC parameters and gcode programming. Ill try to run it this weekend.

(CODE REDACTED - SEE CORRECTED VERSION IN BELOW POST)

This is just the tool change script, I'll also need to touch off once before the program starts (not to change any values, but just to set the #<_last_z> parameter for the next tool change. I'll probably also set up macros to touch off a tool whenever I want.

Side note - the Buildbotics control demo (https://demo.buildbotics.com/#control) has been really helpful with trial and error as I learn the gcode, and I don't have to be at the machine to run anything.
Last edited by PNSNengineering on Sun Jun 06, 2021 12:05 pm, edited 1 time in total.
--
Alex Pinson
IG: pnsn.engineering

PNSNengineering
Posts: 14
Joined: Tue Jun 01, 2021 5:15 pm

Re: How does probing work?

Post by PNSNengineering » Sun Jun 06, 2021 12:04 pm

Okay, here's what I've got (and it works!):

First I have to run this. I have it set up as a macro, so I put my probe in (which is just a 1/8" ground pin) and press the button to run this macro. This just sets the #<_last_z> parameter for the next tool changes, and then after that I use the probe tool to set XYZ offsets. Here's the macro:

M70 (save machine state)
G20 (set to imperial units)
G90 (absolute distance mode)

G53 G0 Z6.985 (move Z to highest height - CHANGE VALUE PER MACHINE)
G53 G0 X16.131 Y7.209 (move above touch probe - CHANGE VALUE PER MACHINE)

G91 (incremental distance mode)
F15.0 (slow-ish feed)
G38.2 Z-6.985 (move Z until probe makes contact - CHANGE VALUE PER MACHINE)
G0 Z0.05 (move Z up a bit)
F0.5 (sloooow feed)
G38.2 Z-.06 (move Z back down more slowly for fine touch)
#<_last_z> = #<_z> (store z height for next tool change)

G90 (absolute distance mode)
G53 G0 Z6.985 (move Z to highest height - CHANGE VALUE PER MACHINE)
M72 (recover saved state)

And then in the tool change section of the control I am running this code (I also found it helpful to set it up as a macro, minus the M0 M6 line). The only real difference between this and the code I posted earlier (which I am going to redact from that post so no one accidentally runs the wrong thing) is that I changed the order of the parameters in the #<_z> - #<_last_z> line and added G53 so that the moves to the probe location aren't relative to the current work offset but instead the machine's absolute coordinates. Here's that code:

M70 (save machine state)
G20 (set to imperial units)
G90 (absolute distance mode)

G53 G0 Z6.985 (move Z to highest height - CHANGE VALUE PER MACHINE)
G53 G0 X16.131 Y7.209 (move above touch probe - CHANGE VALUE PER MACHINE)
M0 M6 (MSG, Change tool)

G91 (incremental distance mode)
F5.0 (slow-ish feed)
G38.2 Z-6.985 (move Z until probe makes contact - CHANGE VALUE PER MACHINE)
G0 Z0.05 (move Z up a bit)
F1.0 (sloooow feed)
G38.2 Z-.06 (move Z back down more slowly for fine touch)
#<_adjust_by> = #<_z> - #<_last_z> (find difference between current location and last touch point)
#<_update_z> = #<_z> + #<_adjust_by> (find the new z value based on height difference)
G92 Z#<_update_z> (update the Z height)
#<_last_z> = #<_z> (store z height for next tool change)

G90 (absolute distance mode)
G53 G0 Z6.985 (move Z to highest height - CHANGE VALUE PER MACHINE)
M72 (recover saved state)

Hopefully that helps anyone else trying to solve the same issue in the future. I'll post if I make any significant edits or find any issues in the future, thanks for the help!

EDIT: As of 7/5/21 I'm still tweaking this. It doesn't work quite as well as I'd thought and I'm still seeing some funky behavior, so I'm trying to dive in and understand what's going on. I suspect something to do with the different work offsets, although the BB control doesn't seem to have certain parameters available for use (e.g. #5323, Z coordinates in G59, always returns zero...).
Last edited by PNSNengineering on Mon Jul 05, 2021 11:34 am, edited 1 time in total.
--
Alex Pinson
IG: pnsn.engineering

rtkracht
Posts: 10
Joined: Tue Mar 23, 2021 2:36 pm

Re: How does probing work?

Post by rtkracht » Mon Jun 07, 2021 9:43 am

Alex, thanks for the update.
R.T.Kracht
Huffman, TX

PNSNengineering
Posts: 14
Joined: Tue Jun 01, 2021 5:15 pm

Re: How does probing work?

Post by PNSNengineering » Tue Jul 06, 2021 5:34 pm

Just wanted to post another update - the code above I believe should work, but there's an issue with the parameter #<_z>. This parameter returns a positive value in the BB control whether the position is positive or negative, and regardless of whether this is the intended functionality or not it means the code I was using doesn't always work - especially if the work offset is set to zero above the probe surface.

My workaround was to switch to an unused work offset (G59) which gets reset at the beginning of the program. This way unless the probe surface is somehow under the machine table the #<_z> parameter won't cause an absolute value issue since the Z position is always greater than zero in G59. Then, instead of using G92 to set the current position in G54 (which wouldn't work with either #<_z> in G59 or an incorrectly positive value) I use the numbered parameter that stores the current work offset (#5213) and add the tool height difference to that. Since #5213 does return negative numbers correctly this is working for me. I also touch off both tools in the program just to avoid any potential issues with work offsets changing between tool changes.

One last side note before I get to the code - there is a documented issue with using G53 in the tool change section of code which causes the 3D view window to display incorrectly and an over-travel warning to show when you try to load a program. I didn't work around this in the code, instead I have to post my CAM programs in separate files by tool, run this code as a macro, and then load up the next file. Not ideal, but it works and hopefully we see a fix soon. Here's the code:

Code: Select all

(Alex Pinson)
(Pinson Engineering)
(7.7.2021)
(Use ETS to touch off tool and update height)

( --------------------- MACHINE STATE SETTINGS --------------------------------)
M70 (save machine state)
G10 L2 P6 X0 Y0 Z0 (clear offsets for X, Y, & Z axes in G59 so position always > 0)
G20 (set to imperial units)
G90 (absolute distance mode)

( -------------------------- TOOL CHANGE --------------------------------------)
G53 G0 Z6.985 (move Z to highest height - CHANGE VALUE PER MACHINE)
G53 G0 X16.131 Y7.209 (move above touch probe - CHANGE VALUE PER MACHINE)

( -------------------------- TOUCH PROBE AND SET OFFSET --------------------------------------)
G54 (switch to G54 - I may do this more than necessary, not sure how G53 affects current WCS)
G91 (incremental distance mode)
F5.0 (slow-ish feed)
G38.2 Z-6.985 (move Z until probe makes contact - CHANGE VALUE PER MACHINE)
G0 Z0.05 (move Z up a bit)
F1.0 (sloooow feed)
G38.2 Z-.06 (move Z back down more slowly for fine touch)
G59 (switch to unused WCS)
#<_last_z> = #<_z> (set touch height, this will always be > 0)
G90 (absolute distance mode)
G53 G0 Z6.985 (move Z to highest height - CHANGE VALUE PER MACHINE)
M0 (MSG, Change Tool)(Add M6 after M0 if not running this as a macro!)
G91 (incremental distance mode)
F5.0 (slow-ish feed)
G38.2 Z-6.985 (move Z until probe makes contact - CHANGE VALUE PER MACHINE)
G0 Z0.05 (move Z up a bit)
F1.0 (sloooow feed)
G38.2 Z-.06 (move Z back down more slowly for fine touch)
#<_adjust_by> = #<_z> - #<_last_z> (find difference between current location and last touch point)
G54 (switch back to used WCS, don't want to update unused one)
#<_update_z> = #5213 + #<_adjust_by> (find the new z OFFSET value based on height difference)
G52 Z#<_update_z> (update the Z offset in G54)

G90 (absolute distance mode)
G53 G0 Z6.985 (move Z to highest height - CHANGE VALUE PER MACHINE)
M72 (recover saved state)
--
Alex Pinson
IG: pnsn.engineering

User avatar
Doug
Posts: 239
Joined: Fri Feb 02, 2018 4:56 pm

Re: How does probing work?

Post by Doug » Sat Jul 10, 2021 4:58 pm

Thank you for your good work on this subject.

I am trying to reproduce the problem that you described where "the #<_z> parameter always returns a positive value". I created this small macro:

Code: Select all

G21
G90
G0 Z10
(debug, Z = #<_z>)
G0 Z-10
(debug, Z = #<_z>)
M2
This produces two messages. The first says "Z = 10", and the second says "Z = -10".

Can create the shortest possible code that demonstrates the problem that you reported and post it?

Thanks

PNSNengineering
Posts: 14
Joined: Tue Jun 01, 2021 5:15 pm

Re: How does probing work?

Post by PNSNengineering » Sat Jul 10, 2021 5:10 pm

Doug,

Absolutely - the abridged version is below. Worth noting that I set Z = 0.0045" (my part zero) before running this, and this surface was approximately 1.4" above the height the tool stops after the G38.2. I'm not sure exactly what gcode pressing this button executes or if it matters much.
control.png

Code: Select all

G20 (set to imperial units)
G90 (absolute distance mode)
G53 G0 Z6.985 (move Z to highest height - CHANGE VALUE PER MACHINE)
G53 G0 X16.131 Y7.209 (move above touch probe - CHANGE VALUE PER MACHINE)
G91 (incremental distance mode)
F5.0 (slow-ish feed)
G38.2 Z-6.985 (move Z until probe makes contact - CHANGE VALUE PER MACHINE)
(debug, Z = #<_z>)
--
Alex Pinson
IG: pnsn.engineering

User avatar
Doug
Posts: 239
Joined: Fri Feb 02, 2018 4:56 pm

Re: How does probing work?

Post by Doug » Sat Jul 10, 2021 6:12 pm

OK, just so I understand everything, let me talk it through.
  • You set the absolute position of the Z axis to 0.0045" using the 'Set position' button.
  • The first line of code moves Z up to 6.985"
  • The G38.2 command probes downward by as much as 6.985". It stops when it touches the probe.
  • Finally, after the probe completes, it reports the z position
What position is reported in the message?

I'm confused by this sentence, "Worth noting that I set Z = 0.0045" (my part zero) before running this, and this surface was approximately 1.4" above the height the tool stops after the G38.2." I think you are saying that you set the position to 0.0045", which is about 1.4" above the probe plate. If I understand this correctly, then the probe raises to 6.985" plus 1.4" above the probe plate, then probes downwards to the plate a maximum distance of 8.985". Since the tool is now probing down from 1.4" + 6.985" = 8.385", it seems to me that the probing will fail because the tool does not touch the probe plate within 6.985", and the program will stop.

PNSNengineering
Posts: 14
Joined: Tue Jun 01, 2021 5:15 pm

Re: How does probing work?

Post by PNSNengineering » Sun Jul 11, 2021 6:07 am

Doug,

Yes, you are correct with that sequence. The #<_z> parameter reported is +1.4 (instead of -1.4).

The only issue with your last post is that the machine is not moving to Z8.385 - I'm doing this move as a G53, so regardless of the fact that I set my WCS on top of the part it is always going to move to 6.985" in the machine's absolute coordinates. It's not moving to 6.985" in G54 (which would be 8" in absolute but 6.985 in relative coordinates), but moving to 6.985" with respect to how the machine axes and soft limits are set up. Regardless of work offset / current position this takes the machine to the very top of my Z column, right before the limit switch. So when I do the G38.2 Z-6.985, I'm essentially just telling it to traverse the entire Z axis until it touches as my Z- soft limit is at zero.

I made a quick graphic that explains the relative G54 positions (in grey) and the machine's absolute coordinates (in blue). Since #<_z> should report the current relative offset it should be giving -1.4 but again was positive. I did also while I was playing with it move the machine to the actual +1.4 position and confirmed that the parameter returned the same value in both positions.
Screenshot 2021-07-11 090408.jpg
--
Alex Pinson
IG: pnsn.engineering

Post Reply