0% found this document useful (0 votes)
127 views3 pages

M31

This document outlines a macro for automatic tool length measuring after M6 calls, detailing the probing process at the current and fixed plate locations. It includes various parameters such as plate thickness, material offset, and probing rates, along with safety checks for machine homing. The macro concludes by calculating the difference between the fixed plate and Z-zero, updating the C-axis DRO, and returning the machine to its original position safely.

Uploaded by

laflutte
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
127 views3 pages

M31

This document outlines a macro for automatic tool length measuring after M6 calls, detailing the probing process at the current and fixed plate locations. It includes various parameters such as plate thickness, material offset, and probing rates, along with safety checks for machine homing. The macro concludes by calculating the difference between the fixed plate and Z-zero, updating the C-axis DRO, and returning the machine to its original position safely.

Uploaded by

laflutte
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

//This macro is the inital probing for automatic tool length measuring after M6

calls
//It probes at the current location, then moves to the fixed plate location and
probes again.
//The Z distance between the fixed plate and the mobile plate is stored in the C-
axis DRO

double FixedPlateX = 28.16; //Fixed plate X position (machine coordinate)


double FixedPlateY = 19.2; //Fixed plate Y position

double PlateThickness = .124; //thickness of the probing plate


double MaterialOffset = 0.006; //compensation for part thickness

double SafeZ = -.01; //Safe Z in machine coordinates


double ZRetractHeight = 3; //Height above Z0 to which probe will retract
double CoarseRate = 10; //Feedrate for initial probing
double FineRate = 1; //Feedrate for fine probing
double Zmin = -8; //maximum probing distance

double CombinedOffset = PlateThickness - MaterialOffset; //really for use later


when PlateThickness and MaterialOffset are DROs

if(MaterialOffset !=0) //warning that materialoffset in <> 0


{
MessageBox.Show("Material offset ="+MaterialOffset+" press OK to continue");
}

if(!exec.GetLED(56)||!exec.GetLED(57)||!exec.GetLED(58)) // If machine was not


homed then it is not smart to do this, stop here...
{
MessageBox.Show("The machine was not yet homed, home the machine before setting
Z-zero");
exec.Stop();
return;
}

// G91 Sets incremental mode,


// G90 Sets absolute distance mode
// G53 Sets move in absolute coordinate for that line

//int originaldistancemode = exec.actualdistmode; // remember the distance mode


//int originalmodalmode = exec.actualmodal; // remember the modal mode

exec.Code ("G91"); //sets incremental mode for the whole macro

double XOriginalPos = exec.GetXmachpos(); // Get current X


double YOriginalPos = exec.GetYmachpos(); // Get current Y
double ZOriginalPos = exec.GetZmachpos(); // Get current Z

exec.Code("G31 Z" + Zmin + "F" + CoarseRate); // Probe Z quickly to get rough


height
while(exec.IsMoving()){}
exec.Wait(200);

exec.Code ("G00 Z" + .050); // Retract .05" above the plate


while(exec.IsMoving()){}
exec.Wait(100);

exec.Code("G31 Z" + Zmin + "F" + FineRate); // Probe Z slowly for better resolution
while(exec.IsMoving()){}
exec.Wait(200);

double Zzero = exec.GetZmachpos(); //temporary variable with Zzero in machine


coordinate
exec.mainform.sumoffsetcontrol1.G54.newCzinput(CombinedOffset); // Set G54 to new
Zzero
exec.mainform.sumoffsetcontrol1.G55.newCzinput(CombinedOffset); // Set G55 to new
Zzero
exec.mainform.sumoffsetcontrol1.G56.newCzinput(CombinedOffset); // Set G56 to new
Zzero
exec.mainform.sumoffsetcontrol1.G57.newCzinput(CombinedOffset); // Set G57 to new
Zzero
exec.mainform.sumoffsetcontrol1.G58.newCzinput(CombinedOffset); // Set G58 to new
Zzero
exec.mainform.sumoffsetcontrol1.G59.newCzinput(CombinedOffset); // Set G59 to new
Zzero

exec.Code("G00 Z" + ZRetractHeight); //Retracts Z for move to plate


while(exec.IsMoving()){}
exec.Wait(1000);

exec.Code ("G53 G00 X" + FixedPlateX + " Y" + FixedPlateY);//Move to fixed plate
position
while (exec.IsMoving ()){}
exec.Wait (200);

exec.Code("G31 Z" + Zmin + "F" + CoarseRate); // Probe Z quickly to get rough


height
while(exec.IsMoving()){}
exec.Wait(200);

exec.Code ("G00 Z" + .050); // Retract .05" above the plate


while(exec.IsMoving()){}
exec.Wait(100);

exec.Code("G31 Z" + Zmin + "F" + FineRate); // Probe Z slowly for better resolution
while(exec.IsMoving()){}
exec.Wait(200);

double Zcurrent = exec.GetZmachpos(); // Gets the Z-value for the fixed Plate
double PlateDifference = Zcurrent - Zzero + CombinedOffset;// calculates the
difference between the fixed plate and Zzero

exec.mainform.sumoffsetcontrol1.G54.newCcinput(PlateDifference); // writes Plate


Difference to axis C DRO for all offsets
exec.mainform.sumoffsetcontrol1.G55.newCcinput(PlateDifference);
exec.mainform.sumoffsetcontrol1.G56.newCcinput(PlateDifference);
exec.mainform.sumoffsetcontrol1.G57.newCcinput(PlateDifference);
exec.mainform.sumoffsetcontrol1.G58.newCcinput(PlateDifference);
exec.mainform.sumoffsetcontrol1.G59.newCcinput(PlateDifference);

exec.Code ("G53 G00 Z" + SafeZ); //Retracts Z to SafeZ


while(exec.IsMoving()){}
exec.Wait(200);
exec.Code ("G90"); //sets back to absolute mode for next move
exec.Code ("G53 G00 X" + XOriginalPos + " Y" + YOriginalPos); //Return to
original XY position
while(exec.IsMoving()){}
exec.Wait(200);

double SaferZ = ZOriginalPos+ZRetractHeight;


exec.Code ("G53 G00 Z" + SaferZ); //Return to original Z position + retrace
height just to be safe
while(exec.IsMoving()){}
exec.Wait(200);

//exec.Code("G" + originaldistancemode); // Set system back to the original


distance mode
//exec.Code("G" + originalmodalmode); // Set system back to the original distance
mode

You might also like