Machine Coordinates from G-Code, #<_hal[]> support

More
13 years 1 month ago #39415 by andypugh

awetmore wrote: It assumes that tool heights are measured as tool stick out from the spindle to the surface (a zero tool height would mean the spindle nose touches the surface).

That is one way to do it. Many folk use a "reference tool" (often a touch probe) which is the nominal zero length.

Please Log in or Create an account to join the conversation.

More
7 years 7 months ago - 7 years 7 months ago #129916 by spicer

awetmore wrote: Thanks, that did the trick. I had missed that G28.1 worked that way.

Here is what I ended up with, maybe it'll be useful to someone else. It assumes that tool heights are measured as tool stick out from the spindle to the surface (a zero tool height would mean the spindle nose touches the surface).

Code:
( measure the height of a tool using a probe plate ) o<measuretool> sub ; machine specific parameters #1000=-5.5 (max Z depth in absolute coordinates) ; setup G49 (cancel tool lengths) G91 (incremental mode) G28.1 (copy absolute coordinates into #5161-#5169) #1001=#5163 (current depth) #1002=[#1000-#5163] (probe depth) ; measure G38.3 Z#1002 F10 (probe fast down) G38.4 Z1 F1 (probe slow up) G43.1 Z#5422 (save current Z as tool height) ; cleanup G90 (return to absolute mode) G53 G0 Z#1001 (return to original Z) o<measuretool> endsub M2

We'll use this now to make it a lot easier to measure tool heights on a Bridgeport Boss (which has repeatable tool heights in it's quick change chuck).

Once the remap stuff becomes available in a tested release I'll be able to use this along with a remapped M6 to automatically measure tool heights on my Taig CNC mill (ER16) on every tool change.


I have modified your subroutine a little bit for my plasma cutter.
With this it gives no error when i move Z near 0 first.
Code:
measuretool.ngc in Verzeichnis nc_files o<measuretool> sub ; machine specific parameters ; #1000=-100 (max Z depth in absolute coordinates) ; setup G49 (cancel tool lengths) G91 (incremental mode) G28.1 (copy absolute coordinates into #5161-#5169) ; #1001=#5163 (current depth) ; #1002=[#1000-#5163] (probe depth) #1002=[-#5163] (probe depth) ; measure G38.2 Z#1002 F20 G92 Z-2.05 (distance switch_on to Workpiece surface) G90 G0 Z1 o<measuretool> endsub M2
Last edit: 7 years 7 months ago by spicer.

Please Log in or Create an account to join the conversation.

More
7 years 7 months ago - 7 years 7 months ago #129929 by Richard J Kinch
Replied by Richard J Kinch on topic Machine Coordinates from G-Code, #<_hal[]> support

awetmore wrote: I'm trying to read the raw machine coordinates from G-Code.


This simple idea should be plainly documented, but is not. It also needs a formal name, which I propound should be "the instant ordinate" of an axis (calling it "raw" or "machine" is not informative since the G-code machine model is a hairball of confusion). Here is an O-code subroutine gem to do it universally for any machine state and axis:

Code:
( Subroutine: read current g53 location ) ( Input: #1 = axis code 0..8 ) ( Returns: #31 = location ) ( Side effects: clobbers #5161--#5169 by using g28.1 ) ( RJK 02/2019 ) o<read_ordinate> sub ( Scaffold: modify this using a subr which push-probe-pops #5161--#5166 ) ( to avoid potentially interfering with caller's state ) ( Scaffold: does not check axis is a valid code, both in range and ) ( installed. ) g28.1 ( Read current g53 coordinates into #5161--#5166 ) #31 = [#[5161+#1]] ( G53 ordinate for axis of interest ) o<read_ordinate> endsub

You can see there are only two lines of code required. This is clumsy and not obvious even to experts, but that's G-code.

Even this subroutine is not quite pure; it ought to push and pop the g28.1 conditions, such as with subroutine local variables, to guarantee no global side effects. Such purity requires it be done in a subroutine, which is itself an insoluble impurity; there's no proper way to do this in G-code that is both "flat" and not dependent on a language extension (such as a subroutine). This model deficiency explains the embarrassment of it not being documented. The ugliest measles always get documented last.
Last edit: 7 years 7 months ago by Richard J Kinch.

Please Log in or Create an account to join the conversation.

More
7 years 7 months ago - 7 years 7 months ago #129932 by spicer
Our solutions are very close. :)
The most important lines in my subroutine are:
Code:
G91 (incremental mode) G28.1 (copy absolute coordinates into #5161-#5169) G38.2 Z[-#5163] F20 (Z probe) G90 (return to absolute mode)
Last edit: 7 years 7 months ago by spicer.

Please Log in or Create an account to join the conversation.

More
7 years 7 months ago #129944 by tommylight
Is this probing for plasma ?

Please Log in or Create an account to join the conversation.

More
7 years 7 months ago - 7 years 7 months ago #129948 by spicer
Yes.
Test video you see here:
www.xup.in/dl,15200380/plasma_kopf.MOV/
The hole on top is for the 12mm capacitive (or inductive) sensor.

I work with 2 dimensions ^^
Code:
measuretool.ngc o<measuretool> sub ; setup G49 (cancel tool lengths) G91 (incremental mode) G28.1 (copy absolute coordinates into #5161-#5169) #1002=[-#5163] (probe depth) ; measure G38.2 Z#1002 F20 (Z probe) G92 Z-2.05 (distance switch_on to Workpiece surface) G90 G0 Z1 (after probing move to 1mm up from workpiece) o<measuretool> endsub M2

This is very easy for the user.
It have 2 buttons. One for XY zeroing,
other for probing.
The solution of the problem "MDI mode" is here
forum.linuxcnc.org/24-hal-components/363...i-mdi-command#129952
Last edit: 7 years 7 months ago by spicer.

Please Log in or Create an account to join the conversation.

Time to create page: 2.987 seconds
Powered by Kunena Forum