why ...macro ATC not work

If you have a question about the software please ask it here.

why ...macro ATC not work

Postby narasake » Mon Nov 05, 2018 4:54 pm

Code: Select all
//Example linear toolchanger code
//Tool positions definition

double[] ToolZ = new double[11];
double[] ToolY = new double[11];
double[] ToolB = new double[11];
double[] ToolC = new double[11];

ToolZ[0] = 0;      // Tool0 Z position
ToolY[0] = 0;      // Tool0 Y position
ToolB[0] = 0;      // Tool0 B position
ToolC[0] = 0;      // Tool0 C position

ToolZ[1] = -300;   // Tool1 Z position
ToolY[1] = 100;    // Tool1 Y position
ToolB[1] = 90;     // Tool1 B position
ToolC[1] = 0;      // Tool1 C position

ToolZ[2] = -250;   // Tool2 Z position
ToolY[2] = 100;    // Tool2 Y position
ToolB[2] = 0;      // Tool2 B position
ToolC[2] = 0;      // Tool2 C position

ToolZ[3] = -200;   // Tool3 Z position
ToolY[3] = 100;    // Tool3 Y position
ToolB[3] = 90;     // Tool3 B position
ToolC[3] = 0;      // Tool3 C position

ToolZ[4] = -150;   // Tool4 Z position
ToolY[4] = 100;    // Tool4 Y position
ToolB[4] = 100;    // Tool4 B position
ToolC[4] = 0;      // Tool4 C position

ToolZ[5] = -100;   // Tool5 Z position
ToolY[5] = 100;    // Tool5 Y position
ToolB[5] = 90;     // Tool5 B position
ToolC[5] = 0;      // Tool5 C position

ToolZ[6] = -50;    // Tool6 Z position
ToolY[6] = 100;    // Tool6 Y position
ToolB[6] = 90;     // Tool6 B position
ToolC[6] = 0;      // Tool6 C position

ToolZ[7] = 0;      // Tool7 Z position
ToolY[7] = 0;      // Tool7 Y position
ToolB[7] = 0;      // Tool7 B position
ToolC[7] = 0;      // Tool7 C position

ToolZ[8] = 0;      // Tool8 Z position
ToolY[8] = 0;      // Tool8 Y position
ToolB[8] = 0;      // Tool8 B position
ToolC[8] = 0;      // Tool8 C position


double SafeY = 200;
double Ytoolpickup = 100;
double SafeZ = -10;
double SafeB = 0;

int Newtool = exec.Getnewtool();
int Currenttool = exec.Getcurrenttool();

if(Newtool == -1)
return;


if(Newtool <1 || Newtool >6)           
return;


if(Newtool == Currenttool)                                                                     
return;

if(!exec.GetLED(56)||!exec.GetLED(57)||!exec.GetLED(58)||!exec.GetLED(60)||!exec.GetLED(61))

  MessageBox.Show("The machine was not yet homed, do homeing before executing a tool change!");
  exec.Stop();
  return;
}

while(exec.IsMoving()){}                   
double Zoriginalpos = exec.GetZmachpos();
double Yoriginalpos = exec.GetYmachpos();
double Boriginalpos = exec.GetBmachpos();
double Coriginalpos = exec.GetCmachpos();

exec.Stopspin();                            // Stop spindle if running and Move Z up
exec.Code("G00 G53 Z"+ SafeZ);              // Move Z up
while(exec.IsMoving()){}

if(Currenttool!=0)                          // No need to drop down tool if current tool number is zero
{
  exec.Code("G00 G53 C" + ToolC[Currenttool] + " B" + ToolB[Currenttool]);  // Move to old tool position on CB plane
  while(exec.IsMoving()){}
  exec.Code("G00 G53 Y" + ToolY[Currenttool] + " Z" + ToolZ[Currenttool]);  // Move to old tool position on YZ plane
  while(exec.IsMoving()){}     
  exec.Setoutpin(5,1);              // MAGAZINE  IN
  exec.Wait(1000);                 // Wait one 1000msec
  while (AS3.GetLED(129)){}       // Wait SENSOR LEAD IN
  exec.Wait(1000);               // Wait one 1000msec
  exec.Setoutpin(5,14);             // SPINDLE UNLOCK
  exec.Wait(1000);                 // Wait one 1000msec
  while (AS3.GetLED(121)){}       // Wait SENSOR UNLOCK
  exec.Wait(1000);               // Wait one 1000msec
  exec.Code("G00 G53 Y"+ SafeY);    // Move Y OUT
  while(exec.IsMoving()){}
}

  exec.Code("G00 G53 Z" + ToolZ[Newtool]);     // Move to new tool position on XY plane
  while(exec.IsMoving()){}
  exec.Code("G00 G53 Y" + Ytoolpickup);          // Move Z axis down to tool holder position
  while(exec.IsMoving()){}
  exec.Clroutpin(5,14);                     // SPINDLE LOCK
  exec.Wait(1000);                         // Wait one 1000msec
  while (AS3.GetLED(122)){}
  exec.Clroutpin(5,1);                      // MAGAZINE OUT
  exec.Wait(1000);                         // Wait one 1000msec
  while (AS3.GetLED(130)){}
  exec.Code("G00 G53 Z"+ SafeZ + " B " + SafeB);           // Move Z up
  while(exec.IsMoving()){}

  exec.Code("G00 G53 X" + Xoriginalpos + " Y" + Yoriginalpos);   // Move back to start point
  while(exec.IsMoving()){}
  exec.Wait(200);
  while(exec.IsMoving()){}

if(!exec.Ismacrostopped())                   // If tool change was not interrupted with a stop only then validate new tool number
{
  exec.Setcurrenttool(Newtool);              //Set the current tool -> the new tool
  MessageBox.Show("Tool change done.");
}
else
{
  exec.StopWithDeccel();
  MessageBox.Show("Tool change was interrupted by user!");
}
narasake
 
Posts: 2
Joined: Mon Nov 05, 2018 4:45 pm

Re: why ...macro ATC not work

Postby dezsoe » Mon Nov 05, 2018 7:43 pm

Please, write some details about your problem. If you have a compile error then correct line 122 which is:

Code: Select all
  exec.Code("G00 G53 X" + Xoriginalpos + " Y" + Yoriginalpos);   // Move back to start point

where Xoriginalpos is unknown. Your code saves Z, Y, B and C axes.
dezsoe
 
Posts: 2049
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary


Return to Ask a question from support here

Who is online

Users browsing this forum: No registered users and 22 guests