Tool table
Moderators: TomKerekes, dynomotion
-
- Posts: 39
- Joined: Wed May 03, 2023 12:54 am
Tool table
I made a tool measurement program on a toolsetter. First, the program asks the operator for the tool number, and at the end of the program, used the function SetToolLength(TWORD,NewToolLength);
And here there is an ambiguity with entering values into the tool table.
The tool table has arguments SLOT and ID.And the TWORD parameter is the ordinal number in the tool table (after sorting). And it may not match with SLOT and ID. How can I avoid problems with incorrect entry of tool numbers in the table?
P.S. If the Edit Tool Table window is open in KMotionCNC, the function SetToolLength(TWORD,NewToolLength) does not add any values to the table. This can also be a source of errors.
And here there is an ambiguity with entering values into the tool table.
The tool table has arguments SLOT and ID.And the TWORD parameter is the ordinal number in the tool table (after sorting). And it may not match with SLOT and ID. How can I avoid problems with incorrect entry of tool numbers in the table?
P.S. If the Edit Tool Table window is open in KMotionCNC, the function SetToolLength(TWORD,NewToolLength) does not add any values to the table. This can also be a source of errors.
Re: Tool table
It's been a while since I've looked at the KMotionCNC code, but IIRC as long as you are reading the TWORD in use prior to using SetToolLength(), then the length of the currently active tool will be updated, and the tool table updated as required.
ToolID and Slot should remain the same, and only get altered if changed manually via the Edit Tool Table window.
The reason it appears that using SetToolLength() doesn't add any values to the tool table when the Edit Tool Table window is open, is that the tool table is updated when the Edit Tool Table window is closed, so any tool updates that have occurred via a different source, such as SetToolLength(), will be overwritten.
It's probably worth knowing that the Edit window doesn't read the tool table file directly, it reads the values in the internal interpreter tool table.
The edit window is essentially just a GUI for the internal table, with the interpreter handling the reading/updating/writing of the external tool table file.
ToolID and Slot should remain the same, and only get altered if changed manually via the Edit Tool Table window.
The reason it appears that using SetToolLength() doesn't add any values to the tool table when the Edit Tool Table window is open, is that the tool table is updated when the Edit Tool Table window is closed, so any tool updates that have occurred via a different source, such as SetToolLength(), will be overwritten.
It's probably worth knowing that the Edit window doesn't read the tool table file directly, it reads the values in the internal interpreter tool table.
The edit window is essentially just a GUI for the internal table, with the interpreter handling the reading/updating/writing of the external tool table file.
- TomKerekes
- Posts: 2676
- Joined: Mon Dec 04, 2017 1:49 am
Re: Tool table
Hi Alexanders,
Otherwise there is a function to retreive the Tool Table index from the Slot or ID.
I assume you don't have an automatic tool loader. The normal process would be to have the Operator first select the Tool to measure and then run the tool setter program.I made a tool measurement program on a toolsetter. First, the program asks the operator for the tool number, and at the end of the program, used the function SetToolLength(TWORD,NewToolLength);
And here there is an ambiguity with entering values into the tool table.
The tool table has arguments SLOT and ID.And the TWORD parameter is the ordinal number in the tool table (after sorting). And it may not match with SLOT and ID. How can I avoid problems with incorrect entry of tool numbers in the table?
Otherwise there is a function to retreive the Tool Table index from the Slot or ID.
Code: Select all
int GetToolTableIndexFromID(int ToolID, int *TIndex)
As Moray pointed out when the Edit Tool Table Screen is closed all the screen values are saved to the Tool Table which would overwrite any changes made while the screen is open. While the Tool Table Screen is open the operator is locked out from pushing buttons so it isn't clear how the measurement program would be run with the Screen open. Maybe you have an external button?P.S. If the Edit Tool Table window is open in KMotionCNC, the function SetToolLength(TWORD,NewToolLength) does not add any values to the table. This can also be a source of errors.
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
-
- Posts: 39
- Joined: Wed May 03, 2023 12:54 am
Re: Tool table
Thanks for the tips! I changed the program so that, it does not require the operator to enter the tool number, but requires confirmation of the previously selected tool number.
There is one more question. First, the program must save some of the original coordinates of the axes in order to return them to their original position.
I'm using a function to save the original coordinates.
To return, I use the function
However, the function GetMachine returns a variable Machinez whose value is many times greater than required for the function MoveAtVel.
There is one more question. First, the program must save some of the original coordinates of the axes in order to return them to their original position.
I'm using a function to save the original coordinates.
Code: Select all
GetMachine(&Machinex,&Machiney,&Machinez,&Machinea,&Machineb,&Machinec);
To return, I use the function
Code: Select all
MoveAtVel(int chno, double x, float MaxVel);
Re: Tool table
Tom will correct me if needed, but I think it's because you're mixing the KMotionCNC interpreter value, which is what GetMachine returns, and IIRC is the DRO value (aka the position in mm/inches), whereas MoveAtVel is using axis/channel counts.
If you're doing this in C in the KFlop, you probably want to capture the channel position -
Otherwise you need to use the relevant C code to send a GCode command to KMotionCNC.
The KFlop/Kogna itself doesn't know the physical units being used, it simply knows the axis positions based on the raw channels/axes positions.
The interpreter on the PC does all the conversion between the channel counts, and physical units.
If you're doing this in C in the KFlop, you probably want to capture the channel position -
Code: Select all
ch0->Position
The KFlop/Kogna itself doesn't know the physical units being used, it simply knows the axis positions based on the raw channels/axes positions.
The interpreter on the PC does all the conversion between the channel counts, and physical units.
- TomKerekes
- Posts: 2676
- Joined: Mon Dec 04, 2017 1:49 am
Re: Tool table
Please follow Moray's advice with the exception of saving the commanded Destination rather than the measured Position. Some systems may not have a measured Position and the measured position may be slightly different from the commanded Destination if there is any Servo error. So then afterward you can command the axis back to the exact same place it was commanded before.
Code: Select all
double SaveX;
SaveX = ch0->Dest;
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
-
- Posts: 39
- Joined: Wed May 03, 2023 12:54 am
Re: Tool table
I did as you said and now it works. But there was another problem.
This is an automatic toolsetter measurement program that finally changes the value to tool table.
The final part of the work is as follows:
The result of the program is a significant measurement inaccuracy (0.01- 0.03mm at low measurement speed). At first, I thought the problem was with the toolsetter itself. Then I tried to measure the execution time of the function GetMachine().
And this time turned out to be quite long (0.1- 0.26sec). And this is the reason for the inaccurate measurement.
Is it possible to replace the GetMachine() function with the value ch2->Dest ? For further use in the function NewToolLength() and
SetToolLength() ? How to do it correctly?
This is an automatic toolsetter measurement program that finally changes the value to tool table.
The final part of the work is as follows:
Code: Select all
Jog(Z, Z_Velocity_Down_slow_search);
while (ReadBit(TolsetterBIT) !=Tolsetter_ACTIVE);
GetMachine(&Machinex,&Machiney,&Machinez,&Machinea,&Machineb,&Machinec); //Store all current coordinates.
NewToolLength = RoundToReasonable(Machinez,Units);
SetToolLength(TWORD,NewToolLength); // Change Currently Selected Tool Length
Jog(Z,0);
while(!CheckDone(Z));
Code: Select all
time=Time_sec();
GetMachine(&Machinex,&Machiney,&Machinez,&Machinea,&Machineb,&Machinec); //Store all current coordinates.
time= Time_sec()-time;
printf("\nTime= %f \n", time);
Is it possible to replace the GetMachine() function with the value ch2->Dest ? For further use in the function NewToolLength() and
SetToolLength() ? How to do it correctly?
- TomKerekes
- Posts: 2676
- Joined: Mon Dec 04, 2017 1:49 am
Re: Tool table
You might stop first and then make the call. The stopping distance should be a constant offset.
If the offset is an issue you might sample the ch2->Dest then move back to that position, wait until move completed, then make the call.
If the offset is an issue you might sample the ch2->Dest then move back to that position, wait until move completed, then make the call.
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.