Need some help with an M6 macro.
I rewrote a macro, but I had a few problems with ATC monitoring.
ATC Spindle has 2 PNP sensors. Which are connected to X310 & X311 on the UC300ETH & UB1. (Say port 3 / pin 10 & 11).
LED 95 (LED_DRAWBAR) = Drawbar State
LED 96 (LED_TOOL_INSERT) = Tool Insert State
ATC Spindle Initial state empty = LEDs (Both) -> ON
Drawbar Open = LED 95 (LED_DRAWBAR) -> Off
Drawbar Closed = LED 95 (LED_DRAWBAR) -> ON
and
Tool Insert = LED 96 (LED_TOOL_INSERT) -> Off
- Code: Select all
// Opens power drawbar to ensure that the new tool can be accepted
if (Debug) { MessageBox.Show("Debug: Open Drawbar ...(Unclamp)"); }
exec.Setoutpin(Chuckopenport, Chuckopenpin); // Opens power drawbar to ensure that the new tool can be accepted
while(exec.IsMoving()){}
exec.Wait(UnclampTimer);
// check Collet has opened
while(!AS3.GetLED(LED_DRAWBAR))
{
if (Debug) { MessageBox.Show("Debug: ATC Drawbar Open!"); }
Thread.Sleep(1);
if(exec.Ismacrostopped())
ErrorCheck = true;
{
exec.Clroutpin(Chuckopenport, Chuckopenpin);
exec.Wait(10);
exec.StopWithDeccel();
exec.Setvar(0, 100); //stops manual change macroloop blocking the output for eject
MessageBox.Show("Tool change was interrupted at collet open!");
return;
}
}
// Pick new tool
if (Debug) { MessageBox.Show("Debug: Pick New Tool"); }
exec.Code("G00 G53 Z"+ Ztoolpickup); // Move Z axis down to tool holder position
while(exec.IsMoving()){}
// Clamp power drawbar to retrieve tool
if (Debug) { MessageBox.Show("Debug: Close Drawbar...(Clamp)"); }
exec.Clroutpin(Chuckopenport, Chuckopenpin); // Close the chuck with pneumatic valve
exec.Wait(ClampTimer); // Wait
// Check Drawbar is Closed
while(AS3.GetLED(LED_DRAWBAR)) // check tool has locked
{
if (Debug) { MessageBox.Show("Debug: Drawbar Close / Clamp"); }
exec.Wait(100);
//Thread.Sleep(1);
if(exec.Ismacrostopped())
{
exec.Setvar(0, 100); //stops manual change macroloop blocking the output for eject
MessageBox.Show("Tool not locked or no tool!");
exec.StopWithDeccel();
return;
}
}
// Move to Pre Position
if (Debug) { MessageBox.Show("Debug: Z UP to Pre-Position!"); }
exec.Code("G1 F5000 G53 Z"+ (Ztoolrelease + Zprepos)); // Move Z axis down to tool holder position
while(exec.IsMoving()){}
// Check Tool Insert
while(!AS3.GetLED(LED_TOOL_INSERT)) // check tool has locked
{
if (Debug) { MessageBox.Show("Debug: Tool Locked / Insert!"); }
Thread.Sleep(1);
if(exec.Ismacrostopped())
{
exec.Setvar(0, 100); //stops manual change macroloop blocking the output for eject
MessageBox.Show("Tool not locked or no tool!");
exec.StopWithDeccel();
return;
}
}
// Move back to Pre Release Y
if (Debug) MessageBox.Show("Debug: Move Out of Pocket to PreRelease Y...!");
exec.Code("G00 G53 Y" + ypre);
while(exec.IsMoving()){}
Everything works fine until "Check Tool Insert". This keeps running in the loop.
Does anyone know where my mistake is?
Thank you in advance.