Mach3 Plugin - Probe Setup

The following describes the use of DynoMotion Probing with Mach3. Probing in Mach3 is selected by using the G31 code. Such as:

G31 Z-4 F40

This example command line would cause a motion from the current position to a absolute position of z = -4 at a feed rate of 40 units/minute and stop as soon as the probe input becomes active.

When the probe input becomes active the current positions of all axes will be captured and the motion will decelerate to a stop in a controlled manner. Mach3 variables 2000-2005 will be filled with the captured position.

The following sequence might be used to perform a probe and then perform a move relative to the captured Z position.

G31 Z-4.0 F40 (Probe in Z)
G1 Z #2002 (move back to trip point)
M30

Note: If the Probe input is already active at the beginning of the probe, or the motion completes without the Probe input ever becoming active, an error will be displayed and G Code execution wi/l stop.

Required KMotion/KFLOP User Program

In order to perform Probing, the the Notify User Program must be configured to properly handle message 20000 and selected in the Mach3 Plugin configuration.

Add the message handler shown below to the Notify program for your system. During probing the DynoMotion Plugin sends a Notification 20000 message to the configured KMotion/KFlop Notify User Program.

The message handler must:

#1 set status (user var 62) to zero

#2 wait for the probe to become active

#3 sample the current positions of the defined axes (as doubles into 50-61)

#4 set status to 1 or 2 depending on if the probe was ever inactive

#5 feedhold the system

#6 exit

Note defines below in PC-DSP.h should be used to symbolically reference the persist.UserData Variables

#define

MACH3_PROBE_STATUS_VAR 62

#define

MACH3_PROBE_RESULTS_VAR 50

In most cases the only modification required will be the defined bit number and active state.

However any number of other techniques might be used such as monitoring analog inputs, or capturing other variables such as encoder positions.

Excerpt from Example File: <Install Dir>\C Programs\NotifyProbeMach3.c

// handles probing

//

// flag is 0 - while watching for probe hit

// flag is 1 - if probe was already set from start

// flag is 2 - after successful probe hit

// flag is 3 - Tells Plugin to upload status (3) to

// DRO 1100 and let User handle the error

//

// returns the captured results in User Variables

// X - 50+51

// Y - 52+53

// Z - 54+55

// A - 56+57

// B - 58+59

// C - 60+61

// status result 62

#define PROBE_BIT 0

#define PROBE_ACTIVE_STATE 1

#define PROBE_ERROR_HANDLING 0 // 0 Stops Mach3 on probe error

// #define PROBE_ERROR_HANDLING 3 // 3 User must query DRO 1100 and handle error

if (msg==20000)

{

double *d = (double *)&persist.UserData[MACH3_PROBE_RESULTS_VAR];

int flag=1;

persist.UserData[MACH3_PROBE_STATUS_VAR]=PROBE_ERROR_HANDLING;

while (ReadBit(PROBE_BIT)!=PROBE_ACTIVE_STATE)

{

flag=2;

WaitNextTimeSlice();

}

if (CS0_axis_x>=0) d[0]=chan[CS0_axis_x].Dest;

if (CS0_axis_y>=0) d[1]=chan[CS0_axis_y].Dest;

if (CS0_axis_z>=0) d[2]=chan[CS0_axis_z].Dest;

if (CS0_axis_a>=0) d[3]=chan[CS0_axis_a].Dest;

if (CS0_axis_b>=0) d[4]=chan[CS0_axis_b].Dest;

if (CS0_axis_c>=0) d[5]=chan[CS0_axis_c].Dest;

persist.UserData[MACH3_PROBE_STATUS_VAR]=flag;

StopCoordinatedMotion();

}

}