Tool Length Touch Probe

Moderators: TomKerekes, dynomotion

Post Reply
EondeK
Posts: 14
Joined: Thu May 17, 2018 3:29 pm

Tool Length Touch Probe

Post by EondeK » Sun May 20, 2018 12:16 pm

Hi

I am putting a conductive block on the work piece. Using a touch probe I can stop the axis when the tool touches. Next I need to update the tool length on the tool table setting.The idea is to
1) Determine the selected tool on the screen
2) Set the selected tool length in the table to 0
3) Read the DRO setting
4) Update the tool length in the table

Can the following work?
- I cannot find a command to determine which tool has been selected on the screen. Please assist.
- I can set the tool length using SetToolLength(int index, double Length)
- I can get the DRO reading with

GetDROs(double *DROx, double *DROy, double *DROz, double *DROa, double *DROb, double *DROc). I assume this is not in machine coordinates?

- I can set the tool length in the table using SetToolLength(int index, double Length). The length is DRO-blockthickness. This assumes the Z axis was set to 0 on the workpiece with the selected fixture offset.


Regards

Moray
Posts: 288
Joined: Thu Apr 26, 2018 10:16 pm

Re: Tool Length Touch Probe

Post by Moray » Sun May 20, 2018 10:07 pm

The ToolTableSet.c has the barebones for getting/setting the values required for setting the tool length.

And here's a copy of what I use on my lathe for setting the Z (which I do by touching of the end of a known length of bar, but also includes the option to use an offset)-

Code: Select all

#include "KMotionDef.h"
#include "cyclone.h"
#include "KflopToKMotionCNCFunctions.c"

main()
{
	printf("ToolSetZ.c started\n");
	int	Units, TWORD, HWORD, DWORD;
	double DROx, DROy, DROz, DROa, DROb, DROc, OffsetZ;
	double ZMeasured, ZDiff, ZNewOffset;
	float ZEntered;
	//float ZMeasured;
	// get current DRO reading (we only need X, but we have to handle them all)
	printf("Just about to GetDROs\n");
	GetDROs(&DROx, &DROy, &DROz, &DROa, &DROb, &DROc);
	printf("GetDros done\n");
	// get the current Units and ToolTblID (and ignore the H and D Words)
	GetMiscSettings(&Units, &TWORD, &HWORD, &DWORD);
	printf("GetMiscSettings done\n");
	// if KMotionCNC is in inch/G20 mode, then quit as it shouldn't be
	if(Units == CANON_UNITS_INCHES){
		MsgBox("KMotion set to inches. Set to MM and retry",MB_OK|MB_ICONEXCLAMATION);
		ThreadDone();
	}
	// get the Z offset from the tool table using the TWORD as index
	GetToolLength(TWORD, &OffsetZ);
	printf("GetToolLength done\n");
	// now we have those, ask the operator for the actual size
	int Answer = InputBox("Enter Z offset in MM (normally 0 if touching off)",&ZEntered);
	printf("ZEntered-%f\n",ZEntered);
	ZMeasured = ZEntered;
	printf("Value entered-%f\n",ZMeasured);
	if(Answer) {	// if true/1, then user cancelled
		MsgBox("Z Offset adjustment cancelled",MB_OK|MB_ICONEXCLAMATION);
		ThreadDone();		// and kill the thread
	} else { // else we got a value and need to do some calcs
		// first up we'll calculate the difference
		ZDiff = DROz + ZMeasured;
		printf("Z Difference-%f\n", ZDiff);
		// then the new offset with some rounding
		ZNewOffset = RoundToReasonable(OffsetZ + ZDiff,Units)*-1;
		printf("Z New Offset-%f\n",ZNewOffset);
		// and finally update the tool table
		printf("Setting new tool length\n");
		SetToolLength(TWORD, ZNewOffset);
		printf("New tool length set\n");
	}
}

EondeK
Posts: 14
Joined: Thu May 17, 2018 3:29 pm

Re: Tool Length Touch Probe

Post by EondeK » Tue May 22, 2018 8:18 pm

Thanks Moray
It worked well. I also managed to convert the C programs to functions and then I just call them from the Main program. in the end I only had to write about 10 lines of code.

mlinka
Posts: 3
Joined: Fri Jun 15, 2018 8:19 pm

Re: Tool Length Touch Probe

Post by mlinka » Tue Jun 19, 2018 8:31 am

Hy, can you share the C program for touch probe?
Thank you.

Post Reply