Hi everybody.
Now do automatic length measuring instruments, and then writing it to a table.
Code length measurement works. That is:

Code:
#include "KMotionDef.h"
#define TMP 10 // which spare persist to use to transfer data
#include "KflopToKMotionCNCFunctions.c"
#define Zaxis 2

main()
{
	int FixtureIndex,Units, TWORD, HWORD, DWORD;
	double NewToolLength,OriginOffsetZ,AxisOffsetZ;
	double Machinex,Machiney,Machinez,Machinea,Machineb,Machinec;
	double P0,P1;
	SetBitDirection(0,0); // для оси Z
	
	//сначала ось Z - 5000 имп/мм
	Jog(2,-4000); 
	while (!ReadBit(0)) ; 
	Jog(2,0); 
	P0 = chan[Zaxis].Dest;
	
	P1=P0+1000;
	MoveAtVel(Zaxis,P1,2000);
	while (ch2->Dest < P1) ;
	
	Jog(2,-1000); 
	while (!ReadBit(0)) ; 
	Jog(2,0); 


	
	//

	GetMiscSettings(&Units, &TWORD, &HWORD, &DWORD);

	GetFixtureIndex(&FixtureIndex);

	GetOriginOffset(&OriginOffsetZ, FixtureIndex, Zaxis);

	GetAxisOffset(&AxisOffsetZ, Zaxis);
	
	GetMachine(&Machinex,&Machiney,&Machinez,&Machinea,&Machineb,&Machinec);

	// Compute Tool Offset to make DRO zero when Tool Length selected and enabled
	//
	// Since Machine = DRO + OriginOffset + AxisOffset + ToolOffset
	//
	// Set DRO = 0 and solve for ToolOffset
	//
	NewToolLength = RoundToReasonable(Machinez - OriginOffsetZ - AxisOffsetZ,Units);

	// Change Currently Selected Tool Length
	SetToolLength(TWORD,NewToolLength);
}
But I have a different diameter tools. And I need to do offset of X and Y to the edge cutter hit the center of the sensor.
How to read the offset of X and Y from the tool table?
Sincerely, Alexander.