Hello Tom.
I have such a problem. When executing an G code, any M6 command of the T slot number does not apply the tool lenght specified in the tool table. Remains the length used before running the G-code. Amount when manually selected everything works fine. It also doesn't work when collecting code transfer via MDI. The variable in the converted M6 code is designated as 9, stream 4. Code With inclusion.
Code:
#include "KMotionDef.h"
#define TMP 10
#include "KflopToKMotionCNCFunctions.c"
#define X_axis 0
#define Z_axis 2
#define X_SENSOR (268.828 * 800)
#define SPINDLE_ON_OFF 29
#define EMERGENCE 23
#define Z_Parking (-4 * 1000)
#define VALVE 33
main()
{
int Answer, Units, TWORD, HWORD, DWORD, oldTool;
double Length, ToolDiameter;
char str[80];
SetBitDirection(SPINDLE_ON_OFF, 1);
SetBitDirection(VALVE, 1);
SetBitDirection(EMERGENCE, 0);
if (ch0->Enable && ch1->Enable && ch2->Enable && ReadBit(EMERGENCE))
{
ClearBit(SPINDLE_ON_OFF);
FPGA(IO_PWMS+1) = 1; // enable the PWM
FPGA(IO_PWMS) = 0; // set the PWM off
printf("Spindle OFF \n");
oldTool = persist.UserData[8];
printf("Old Tool %d\n", oldTool);
int slot = persist.UserData[9]; // value stored is an int
int id = persist.UserData[9+1]; // value stored is an int
GetMiscSettings(&Units, &TWORD, &HWORD, &DWORD);
printf("Units=%d T=%d H=%d D=%d\n",Units, TWORD, HWORD, DWORD);
if (oldTool != slot)
{
MoveAtVel(Z_axis, Z_Parking, 100000);
while (ch2->Dest != Z_Parking);
MoveAtVel(X_axis, X_SENSOR, 100000);
while (ch0->Dest != X_SENSOR);
SetBit(VALVE);
GetToolDiameter(TWORD,&ToolDiameter);
GetToolLength(TWORD, &Length);
printf ("Tool Length L = %3.4f\n", Length);
sprintf(str, "?????????????n T%d ??????2g ?n", slot, ToolDiameter);
Answer = MsgBox(str, MB_YESNO|MB_ICONEXCLAMATION);
if (Answer == IDNO)
{
Answer = MsgBox("?????????????",MB_OK|MB_ICONEXCLAMATION);
DoPC(PC_COMM_HALT);
return;
}
else {;}
printf("Tool Set to slot %d id %d \n",slot, id); // print the slot and id
printf("Answer %d\n", Answer);
oldTool = slot;
persist.UserData[8] = oldTool;
Delay_sec(0.3);
}
else {;}
}
else {;}
}