Dynomotion

Group: DynoMotion Message: 1490 From: morgtod Date: 7/11/2011
Subject: More Tool changer questions
I've included my toolchanger.c below the questions.

1- I cannot make Reboot! work in console.
2- How do you make the g43's and other offsets automatic with the tool change?
3- How do you make KCNC wait for the toolchange to completely finish before it continues executing code?
4- Is it possible to make the printf's print to a popup screen instead of to console?

The code below is working nicely, I just need to work out a few kinks for fully automatic toolchanges.

Todd


#include "KMotionDef.h"

#define toolarm 152
#define arm_retracted 136
#define arm_extended 137
#define low_drawbar 155
#define low_drawbar_sensor 138

#define CNTS_PER_INCH_X 127000
#define CNTS_PER_INCH_Y -127000
#define CNTS_PER_INCH_Z 127000
#define CNTS_PER_TOOL_A 1666.6666666666666666666

#define X 0
#define Y 1
#define Z 2
#define A 3

#define HIGH 1
#define LOW 0

void MoveX(double v); // define sub functions
void MoveY(double v);
void MoveZ(double v);
void MoveA(double v);
int WaitBit(int bit, int state);

main()
{
int Tool = persist.UserData[9]; // value stored is actually a float
//printf("Tool Set to %d\n",tool); // print the desired speed


MoveZ(-3.750); //move table to tool change position
MoveX(0.0);
MoveY(-2.0);

SetBit(toolarm); // extend the tool arm
Delay_sec(1.0);

if (WaitBit(arm_extended,HIGH)) return; // check the tool arm extended sensor

printf("Tool Arm Extended \n");
MoveZ(-4.0); // good tool release height

Delay_sec(1.0);
SetBit(low_drawbar); // release the tool into the tray

Delay_sec(1.0);
if (WaitBit(low_drawbar_sensor,LOW)) return;
printf("Tool dropped \n"); // check tool dropped sensor

MoveZ(-.500); // move up to clear tool shanks

MoveA(Tool); // spin to new tool

MoveZ(-4.050); // lower to tool pickup level

ClearBit(low_drawbar); // pickup new tool
Delay_sec(1.0);

if (WaitBit(low_drawbar_sensor,HIGH)) return;
printf("Tool picked \n");

MoveZ(-3.75); // raise to clear tool tray
ClearBit(toolarm); // retract tool arm

if (WaitBit(arm_retracted,HIGH)) return; // check tool arm retractd sensor

printf("Tool arm Retracted\n");

}

// wait for a bit to go to a state
// return 0 if ok, 1 if timed ouut
int WaitBit(int bit, int state)
{
double T0=Time_sec();
while (ReadBit(bit) != state)
{
WaitNextTimeSlice();
if (Time_sec() > T0 + 20.0)
{
DisableAxis(0);
DisableAxis(1);
DisableAxis(2);
return 1;
}
}
return 0;
}

void MoveX(double v)
{
Move(X,v * CNTS_PER_INCH_X);
while (!CheckDone(X));
}

void MoveY(double v)
{
Move(Y,v * CNTS_PER_INCH_Y);
while (!CheckDone(Y));
}

void MoveZ(double v)
{
Move(Z,v * CNTS_PER_INCH_Z);
while (!CheckDone(Z));
}

void MoveA(double v)
{
Move(A,v * CNTS_PER_TOOL_A);
while (!CheckDone(A));
}
Group: DynoMotion Message: 1491 From: Tom Kerekes Date: 7/11/2011
Subject: Re: More Tool changer questions
Hi Todd,
 
#1 there are some cases where Reboot! from the console may not work.  You will need to cycle power in those cases.
 
#2 I'm not sure what you mean by automatic.  There is an example GCode file called ToolLengthOffsetsDemo.ngc that shows how to specify G43 and an H parameter to select parameters in the Tool Table.
 
#3  In the KMotionCNC ToolSetup M6 option select Exec/Wait/Sync rather than Execute Prog
 
#4 Not currently.  We will consider that for a future option
 
Thanks
TK
 
 
 


--- On Mon, 7/11/11, morgtod <todmorg@...> wrote:

From: morgtod <todmorg@...>
Subject: [DynoMotion] More Tool changer questions
To: DynoMotion@yahoogroups.com
Date: Monday, July 11, 2011, 3:49 PM

 
I've included my toolchanger.c below the questions.

1- I cannot make Reboot! work in console.
2- How do you make the g43's and other offsets automatic with the tool change?
3- How do you make KCNC wait for the toolchange to completely finish before it continues executing code?
4- Is it possible to make the printf's print to a popup screen instead of to console?

The code below is working nicely, I just need to work out a few kinks for fully automatic toolchanges.

Todd

#include "KMotionDef.h"

#define toolarm 152
#define arm_retracted 136
#define arm_extended 137
#define low_drawbar 155
#define low_drawbar_sensor 138

#define CNTS_PER_INCH_X 127000
#define CNTS_PER_INCH_Y -127000
#define CNTS_PER_INCH_Z 127000
#define CNTS_PER_TOOL_A 1666.6666666666666666666

#define X 0
#define Y 1
#define Z 2
#define A 3

#define HIGH 1
#define LOW 0

void MoveX(double v); // define sub functions
void MoveY(double v);
void MoveZ(double v);
void MoveA(double v);
int WaitBit(int bit, int state);

main()
{
int Tool = persist.UserData[9]; // value stored is actually a float
//printf("Tool Set to %d\n",tool); // print the desired speed

MoveZ(-3.750); //move table to tool change position
MoveX(0.0);
MoveY(-2.0);

SetBit(toolarm); // extend the tool arm
Delay_sec(1.0);

if (WaitBit(arm_extended,HIGH)) return; // check the tool arm extended sensor

printf("Tool Arm Extended \n");
MoveZ(-4.0); // good tool release height

Delay_sec(1.0);
SetBit(low_drawbar); // release the tool into the tray

Delay_sec(1.0);
if (WaitBit(low_drawbar_sensor,LOW)) return;
printf("Tool dropped \n"); // check tool dropped sensor

MoveZ(-.500); // move up to clear tool shanks

MoveA(Tool); // spin to new tool

MoveZ(-4.050); // lower to tool pickup level

ClearBit(low_drawbar); // pickup new tool
Delay_sec(1.0);

if (WaitBit(low_drawbar_sensor,HIGH)) return;
printf("Tool picked \n");

MoveZ(-3.75); // raise to clear tool tray
ClearBit(toolarm); // retract tool arm

if (WaitBit(arm_retracted,HIGH)) return; // check tool arm retractd sensor

printf("Tool arm Retracted\n");

}

// wait for a bit to go to a state
// return 0 if ok, 1 if timed ouut
int WaitBit(int bit, int state)
{
double T0=Time_sec();
while (ReadBit(bit) != state)
{
WaitNextTimeSlice();
if (Time_sec() > T0 + 20.0)
{
DisableAxis(0);
DisableAxis(1);
DisableAxis(2);
return 1;
}
}
return 0;
}

void MoveX(double v)
{
Move(X,v * CNTS_PER_INCH_X);
while (!CheckDone(X));
}

void MoveY(double v)
{
Move(Y,v * CNTS_PER_INCH_Y);
while (!CheckDone(Y));
}

void MoveZ(double v)
{
Move(Z,v * CNTS_PER_INCH_Z);
while (!CheckDone(Z));
}

void MoveA(double v)
{
Move(A,v * CNTS_PER_TOOL_A);
while (!CheckDone(A));
}