585,708 active members*
3,708 visitors online*
Register for free
Login
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2013
    Posts
    17

    Tool length setting from C code

    Tom,
    I am setting up my machine with a tool length sensor, I can make a program to move to the sensor and drop the Z axis until the tool tip touches the sensor, but I’m unsure of how to have this apply the tool compensation automatically, I could zero the Z axis, but I think it would be best to use the tool length, can this be set from C code??

    Thanks,

    Rich.

  2. #2
    Join Date
    May 2006
    Posts
    4045

    Re: Tool length setting from C code

    Hi Rich,

    You might look at the ToolTableSet.c example (below).

    HTH
    Regards
    TK

    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;
    
    	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);
    }
    TK
    http://dynomotion.com

Similar Threads

  1. New Tool Length Offset Setting Device
    By ljh34481 in forum News Announcements
    Replies: 14
    Last Post: 12-13-2012, 01:21 PM
  2. Replies: 13
    Last Post: 03-25-2009, 08:06 PM
  3. setting lathe tool length offsets on ah ha control
    By machinewerks in forum G-Code Programing
    Replies: 2
    Last Post: 02-28-2007, 04:09 AM
  4. Ejector pin machining? Length setting?
    By DomB in forum Moldmaking
    Replies: 9
    Last Post: 12-30-2006, 10:21 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •