Probing from a Program
The panel cycles cover the usual measurements. When you need one they do not cover, such as
a feature at an angle, a check in the middle of a program, or a decision that depends on
what was measured, you write it with G31.
G31 moves until it touches
Section titled “G31 moves until it touches”G31 Z-50. F100. (feed down until the probe triggers)IF [#5070 EQ 0] GOTO 900 (it never touched)#100 = #5063 (the Z it triggered at)The move stops the moment the probe trips, and where it stopped is recorded:
| Variables | Hold |
|---|---|
#5061 … #5066 | the trip position: X, Y, Z, A, B, C in machine coordinates |
#5070 | 1 if it triggered, 0 if it ran all the way to the target |
A move that does not touch leaves the trip position as it was. It holds the previous
touch, not an error and not zero, so read #5070 first. A macro that skips that check
can measure the touch before last and carry on as though nothing were wrong.
P selects which input to watch: P1 is the tool probe, P2 is the part probe. P1 is
the default.
G38.2 is refused. G31 is the probing move on this control.
Moving without measuring
Section titled “Moving without measuring”G31 P11 and G31 P12 run the same move on the same inputs, but as a protected move
rather than a measurement.
Nothing is being measured. The control is watching for an obstacle, and a trigger is a fault, not a result.
Use it to travel through space you are not certain is clear: reaching into a fixture, or
approaching a part whose position you only roughly know. Use plain G31 when you want a
number.
Reading a cycle’s result
Section titled “Reading a cycle’s result”Every probe cycle publishes the same record, so a macro can check what happened instead of assuming it worked:
| Variable | Holds |
|---|---|
#900 | which cycle ran |
#901 | run counter, incremented every run |
#902 | status: 0 is OK, anything else is the alarm number |
#903 | 1 when the cycle wrote the active work offset |
#911 | the run number the values below belong to |
#904 onwards | the cycle’s own values: trigger position, compensated position, stylus radius applied |
Check #911 before you believe anything
Section titled “Check #911 before you believe anything”The values persist after a cycle finishes, so reading them tells you nothing about
which run left them there. #911 is stamped with the run that wrote them:
IF [#911 NE #901] GOTO 900 (stale: this run did not write these)IF [#902 NE 0] GOTO 910 (the cycle alarmed)Without that check a macro reads whatever the previous cycle left behind, and cannot tell the difference between a fresh measurement and yesterday’s.
Writing your own cycle
Section titled “Writing your own cycle”The pieces are all here: G31 to touch, #5061… to read where, the
tool table for the stylus radius to take off, and
G10 L2 to write the datum you worked out.
Keep the approach protected and the retreat along a path you know is clear. The shipped cycles return to the position they were handed, in machine coordinates, for exactly that reason.
Where to go next
Section titled “Where to go next”- Custom Macros: variables, flow control and
G65. - Part Zero with a Probe, the cycles that already exist.