You're right...
I used the pin mapping plugin and it was being used by some other output that I had forgotten to remove.
May I now ask another question that relates directly to the one above...
I'll include the macro M31 below for all to see, it's not written by me but I've managed to work out where to put the Setoutpin(x, x) but it would be better if there was a conditional statement that only allows the Setoutpin function to run only after and if the AS3.Setfield and AS3.Validtefield have been completed. Currently if I press the Tool Measure button and press Cycle Stop before the tool has been measured the Setoutpin function runs and turn the LED on indicating that the tool has been measured which has the potential to be a false indication.
I am assuming it should be a simple snippet of code with a simple 'if' statement.
I'd also be interested to know if there is any way to have an output in high or low depending upon the current position of the machine. Eg. If the machine is parked at Park Position 1, 900,500,100 the LED/Output pin goes high and whenever it's not at that position it's off/low.
Anyway here's the M31 macro code I'm currently using...
- Code: Select all
//M31 Probing Macro
//Fixed Position Tool Sensor
double probeX = 886.229;
double probeY = 501.017;
//Mobile Position Sensor
//double probeX = 31.75;
//double probeY = 31.75;
double xyFeedrate = 6000;
double Zmin = -142;
double Feedrate = 400;
double Feedrateslow = 100;
double Slowretract=5;
double SafeZ = -5;
double retractheight = 80;
// Standard MDF 40mm Pitch Bed
double platethick = 33.85;
// Trespa 16mm Pitch Bed @ 15.42mm Thick
//double platethick = 18.61;
// Homed Check
if(!exec.GetLED(56)||!exec.GetLED(57)||!exec.GetLED(58)) // If machine was not homed then it is unsafe to move in machine coordinates, stop here...
{
MessageBox.Show("The machine was not yet homed, home the machine before run to parking position!");
exec.Stop();
return;
}
while(exec.IsMoving()){}
exec.Wait(200);
double Xoriginalpos = exec.GetXmachpos(); // Get the current machine coordinates
double Yoriginalpos = exec.GetYmachpos(); // Get the current machine coordinates
exec.Code("G00 G53 Z" + SafeZ); // Move Z up first
while(exec.IsMoving()){}
exec.Code("G01 G53 F" + xyFeedrate +" X" + probeX +" Y" + probeY); // Move to the probe sensor position in XY
while(exec.IsMoving()){}
exec.Code("G31 Z" + Zmin + "F" + Feedrate); // Move to the probe sensor position in XY
while(exec.IsMoving()){}
exec.Wait(200);
double Zupslow = exec.GetZmachpos() + Slowretract;
if(Zupslow > SafeZ)
{
Zupslow = SafeZ;
}
exec.Code("G00 G53 Z" + Zupslow); // Move to slow clearance plane
while(exec.IsMoving()){}
exec.Wait(1000);
exec.Code("G31 Z" + Zmin + "F" + Feedrateslow); // Move to the probe sensor position in XY
while(exec.IsMoving()){}
exec.Wait(200);
AS3.Setfield(platethick, 228); //Sets the value of the z current coordinate field to 'platethick'
AS3.Validatefield(228); //Validates the 'platethick' valuefor the z current coordinate field with writting the offset coordinates as nessessary.
//------------------------------------------------------------------------------------------------------------------
exec.Setoutpin(3, 14); // Turns on the Tool Measured LED
// The code to set output pin (3, 14) should only run if the 2 lines above it, starting with "AS3." have been executed and not before in order to prevent the pin going high if the tool measurment process is interupted by a 'cycle stop'. I would assume there is some snippet of C# that checks if something's been done and if it has it will run the Setoutpin line.
//------------------------------------------------------------------------------------------------------------------
double Zup = exec.GetZmachpos() + retractheight;
if(Zup > SafeZ)
{
Zup = SafeZ;
}
exec.Code("G00 G53 Z" + Zup); // Move 1inch above probe plate
while(exec.IsMoving()){}
exec.Wait(1000);
exec.Code("G01 G53 F" + xyFeedrate +" X" + Xoriginalpos +" Y" + Yoriginalpos); // Move back to the original XY position
If you need any more information just let me know.
Many thanks once again.