584,865 active members*
4,901 visitors online*
Register for free
Login
Results 1 to 10 of 10
  1. #1
    Join Date
    Nov 2014
    Posts
    20

    auto tool change on axis A

    Hi Tom
    I ask for help in writing a tool changer script.
    You already helped me with RTCP on this machine https://www.cnczone.com/forums/dynom...ml#post1831860
    RTCP works great!
    The machine is now equipped with 2 spindles of 2 tools total 4 tools. The tool is changed by turning the axis A by 90 degrees and after zeroing the machine coordinate.
    I still changed the instrument manually, first I put the first instrument on the sensor at home, then, depending on the instrument I wanted, I turned the axis A 90 ... 180 or 270 degrees and selected the tool I needed from the table of tools on the main screen with the necessary correctors. In manual mode, everything works as it should, but I would like to call a shift from the program on an M6T.. command.
    Can you help me with the M6 ? ??program?
    Thank you.

    To understand the kinematics, here's a video of how the tool changes and how the spindles are located.
    https://www.youtube.com/watch?v=Q6BoCf5tLJE

  2. #2
    Join Date
    May 2006
    Posts
    4043

    Re: auto tool change on axis A

    Hi vector_z,

    I'm not entirely sure I understand your configuration. Each spindle uses both ends?

    You should be able to shift the A Axis machine origin based on Tool Number with the following:

    Code:
        double Adjustment = (Tool - CurrentTool) * 90.0 * CNT_PER_DEGREE_A;
    
        DisableAxis(AXISA);
        WaitNextTimeSlice();	// make sure we don't get interrupted
        chan[AXISA].Position -= Adjustment;	// Adjust machine coordinates
        EnableAxisDest(AXISA, chan[AXISA].Position);	// re-enable where we now are
    I've merged that into a Tool Change Program that you might try. See attached.
    TK
    http://dynomotion.com

  3. #3
    Join Date
    Nov 2014
    Posts
    20

    Re: auto tool change on axis A

    Quote Originally Posted by TomKerekes View Post
    Hi vector_z,

    I'm not entirely sure I understand your configuration. Each spindle uses both ends?

    Yes, tools can be installed at both ends of the spindle.

    Quote Originally Posted by TomKerekes View Post

    I've merged that into a Tool Change Program that you might try. See attached.



    Yes, thanks, this code works as I need.


    But there is one problemma.
    When I select a tool from the tool list on the main screen manually, corrections are long and tool offsets in X and Y are applied from the table.
    And if the tool is changed through the M6T command, then the correction and offset in X and Y is not accepted.
    Also, my work coordinates work in mm and in the table the offset setting is entered in inches, and there is no correlation between the corrections and the work coordinates.
    Example:
    The tool length in the table is recorded in inches = 2 inches, and the correction in working coordinates is set to 2 mm, this is not true, since 2 inches = 5.08 mm

  4. #4
    Join Date
    May 2006
    Posts
    4043

    Re: auto tool change on axis A

    When I select a tool from the tool list on the main screen manually, corrections are long and tool offsets in X and Y are applied from the table.
    And if the tool is changed through the M6T command, then the correction and offset in X and Y is not accepted.
    To turn on tool lenght/offset compensation use G43

    G43 Hn (Tool #n length comp On)
    G43.4 Hn (Tool #n length On with RTCP On)


    my work coordinates work in mm and in the table the offset setting is entered in inches, and there is no correlation between the corrections and the work coordinates.
    Example:
    The tool length in the table is recorded in inches = 2 inches, and the correction in working coordinates is set to 2 mm, this is not true, since 2 inches = 5.08 mm
    The Tool Table Lengths and Offsets don't have units. They are just treated as numbers in the current units.
    TK
    http://dynomotion.com

  5. #5
    Join Date
    Nov 2014
    Posts
    20

    Re: auto tool change on axis A

    Quote Originally Posted by TomKerekes View Post
    To turn on tool lenght/offset compensation use G43

    G43 Hn (Tool #n length comp On)
    G43.4 Hn (Tool #n length On with RTCP On)
    Thanks, the G 43 correction is working.
    Quote Originally Posted by TomKerekes View Post

    The Tool Table Lengths and Offsets don't have units. They are just treated as numbers in the current units.

    but this will need to be dealt with, since I always have a table and engine settings of a unit in inches, and a unit of working coordinates in a DRO in mm.

  6. #6
    Join Date
    May 2006
    Posts
    4043

    Re: auto tool change on axis A

    Hi vector_z,

    but this will need to be dealt with, since I always have a table and engine settings of a unit in inches, and a unit of working coordinates in a DRO in mm.
    The servo settings and Tool Table are different. Why can't you enterthe Tool Table values in mm to match your Job and DROs?

    What version are you using? There was a bug regarding Tool Offsets in mm and RTCP but that should now be corrected.
    TK
    http://dynomotion.com

  7. #7
    Join Date
    Nov 2014
    Posts
    20

    Re: auto tool change on axis A


    Quote Originally Posted by TomKerekes View Post
    Hi vector_z,

    The servo settings and Tool Table are different. Why can't you enterthe Tool Table values in mm to match your Job and DROs?
    Hi Tom

    I did, everything worked as I need in mm. For RTCP to work properly, I needed to enter the tool length in inches in the table.
    That's why I asked why everything works for me in mm, and the tool length should be entered in inches.

    Quote Originally Posted by TomKerekes View Post

    What version are you using? There was a bug regarding Tool Offsets in mm and RTCP but that should now be corrected.
    I am using version 434a.
    Perhaps this is the problem of not correct operation of the RTCP and tool length in mm.


    And another such question, is there any possibility to promptly disable / enable RTCP using G code or a button in KMotion? I sometimes need a job without RTCP.

    Thanks.

  8. #8
    Join Date
    May 2006
    Posts
    4043

    Re: auto tool change on axis A

    Hi vektor_z,

    I did, everything worked as I need in mm. For RTCP to work properly, I needed to enter the tool length in inches in the table.
    That's why I asked why everything works for me in mm, and the tool length should be entered in inches.

    Quote Originally Posted by TomKerekes View Post

    What version are you using? There was a bug regarding Tool Offsets in mm and RTCP but that should now be corrected.
    I am using version 434a.
    Perhaps this is the problem of not correct operation of the RTCP and tool length in mm.
    Support of metric Tool Table values was corrected in Version 4.34k (1/13/2018). Please try Release Version 4.34 or later.



    is there any possibility to promptly disable / enable RTCP using G code or a button in KMotion? I sometimes need a job without RTCP.
    You can use these GCodes:

    G43 Hn (Tool #n length comp On)
    G43.4 Hn (Tool #n length On with RTCP On)
    G49 (Tool length and RTCP comp off)


    But your Kinematics Class must support m_MotionParams.TCP_Active with something like:

    Code:
    	if (m_MotionParams.TCP_Active)
    	{
    		x -= m_MotionParams.TCP_X;
    		y -= m_MotionParams.TCP_Y;
    		z -= m_MotionParams.TCP_Z;
    
    		// Determine where the commanded XYZ point will be after C rotation
    		Rotate3(CTableAZeroXCenterpoint, CTableAZeroYCenterpoint, CTableAZeroZZero, x, y, z, 0, 0, -c, &CP_Rotated_C_x, &CP_Rotated_C_y, &CP_Rotated_C_z);
    		// Determine where the commanded XYZ point will be after A rotation
    		Rotate3(CTableAZeroXCenterpoint, ASaddleYCenterpoint, ASaddleZCenterpoint, CP_Rotated_C_x, CP_Rotated_C_y, CP_Rotated_C_z, -a, 0, 0, &CP_Rotated_AC_x, &CP_Rotated_AC_y, &CP_Rotated_AC_z);
    
    		// Translate XYZ target for AC rotation
    		x = CP_Rotated_AC_x + m_MotionParams.TCP_X;
    		y = CP_Rotated_AC_y + m_MotionParams.TCP_Y;
    		z = CP_Rotated_AC_z + m_MotionParams.TCP_Z;
    	}
    TK
    http://dynomotion.com

  9. #9
    Join Date
    Nov 2014
    Posts
    20

    Re: auto tool change on axis A

    Quote Originally Posted by TomKerekes View Post
    Hi vektor_z,

    Support of metric Tool Table values was corrected in Version 4.34k (1/13/2018). Please try Release Version 4.34 or later.


    Hi Tom
    Yes, you were right, updated the version to the latest and the length of the tool from the table works in mm.


    I edited the C program a little, I need the axis to physically rotate 90 degrees when the tool is changed, and then the axis A is reset.

    Code:
    #include "KMotionDef.h"#define TMP 10					// which spare persist to use to transfer data
    #include "C:\KMotion434\C Programs\KflopToKMotionCNCFunctions.c"
    
    
    //-----------------------------------------
    //      Rotary TOOL CHANGING
    //-----------------------------------------
    #define AXISA 3
    
    
    #define TOOL_VAR 9				// Tool changer desired new tool Var
    
    
    // Tool changer Last tool loaded is saved globally in this Var
    #define LAST_TOOL_VAR 8			//  -1=Spindle empty, 0=unknown, 1-4 Tool Slot loaded into Spindle
    #define TOOL_DISK_FILE "c:\\Temp\\ToolChangerData.txt"
    
    
    //#define TOOL_DISK_FILE "C:\\KMotion434\\C Programs\\ToolChangerData.txt"
    
    
    #define CNT_PER_DEGREE_A 1125.25
    
    
    // function prototypes
    int DoToolChange(int ToolSlot);
    int GetCurrentTool(int *tool);
    int SaveCurrentTool(int tool);
    BOOL ToolNumberValid(int tool);
    int UnloadTool(int CurrentTool);
    int LoadNewTool(int CurrentTool, int Tool);
    
    
    
    
    main()
    {
    	int ToolSlot = persist.UserData[TOOL_VAR];	// Requested tool to load (value stored an integer) 
    
    
    	if (DoToolChange(ToolSlot))	// perform Tool Change
    	{
    		// error, Halt Job
    		DoPC(PC_COMM_HALT);
    	}
    }
    
    
    // Perform Tool Change.  Return 0=Success, 1=Failure
    int DoToolChange(int ToolSlot)
    {
    	int CurrentTool;
    
    
    	if (GetCurrentTool(&CurrentTool))
    		return 1;				//  -1=Spindle empty, 0=unknown, 1-4 Tool Slot loaded into Spindle
    
    
    	printf("Load Tool Slot %d requested, Current Tool %d\n", ToolSlot, CurrentTool);
    
    
    	if (!ToolNumberValid(ToolSlot))	// check if invalid
    	{
    		char s[80];
    		sprintf(s, "Invalid Tool Change Number %d\n", ToolSlot);
    		printf(s);
    		MsgBox(s, MB_ICONHAND | MB_OK);
    		return 1;
    	}
    
    
    	// load requested tool
    	if (LoadNewTool(CurrentTool, ToolSlot))
    		return 1;
    
    
    	SaveCurrentTool(ToolSlot);	// save the one that has been loaded
    	return 0;					// success
    }
    
    
    
    
    // - Load new Tool by adjusting A Axis machine coordinate appropriately
    int LoadNewTool(int CurrentTool, int Tool)
    {
    	if (CurrentTool != Tool)
    	{
    		double Adjustment = (Tool - CurrentTool) * -90.0 * CNT_PER_DEGREE_A;
    
    
    		//DisableAxis(AXISA);
    		WaitNextTimeSlice();	// make sure we don't get interrupted
    		//chan[AXISA].Position -= Adjustment;	// Adjust machine coordinates
    		//EnableAxisDest(AXISA, chan[AXISA].Position);	// re-enable where we now are
            MoveAtVel(3,Adjustment, 100000);          // ??????????? ??? Y ? ??????? ? ??????? 819 ??? (??? ???????? 1?? ??? ??????? ????) ?? ???????? 20480???/???
                while (!CheckDone(3)) ;             // ???????? ????????? ???????? ??? b
                Zero(3);
    
    
    
    
    			
    			//????????? 1-2 ???????? ? ??????????? ?? ????? ???????????
    	}
    	
    	
    	if (Tool == 1)
    	{
    	ClearBit(23);	
        ClearBit(24);
        	
    	}
    	
    	if (Tool == 2)
    	{
    	SetBit(24);	
        SetBit(23);
        
    	}
    	
    	if (Tool == 3)
    	{
    	ClearBit(23);
        SetBit(24);
        
    	}
    	
        if (Tool == 4)
    	{
    	SetBit(23);
        ClearBit(24);
        
    	}	
    	
    	return 0;					//success
    }
    
    
    
    
    
    
    
    
    // Get the last loaded tool.  Parameter points to where to return tool
    // First try to get from KFLOP memory
    // if memory is invalid, try to read from disk
    // if can't read disk then ask Operator
    // returns 0 on success, 1 on fail or Operator asked to abort
    
    
    int GetCurrentTool(int *ptool)
    {
    	int success, Answer, result, tool;
    	float value;
    
    
    	tool = persist.UserData[LAST_TOOL_VAR];
    	success = ToolNumberValid(tool);	// check if valid
    
    
    	if (!success)				// invalid after power up, try to read from PC Disk File
    	{
    		// Try to open file
    		FILE *f = fopen(TOOL_DISK_FILE, "rt");
    		if (f)					// did file open?
    		{
    			// read a line and convert it
    			result = fscanf(f, "%d", &tool);
    			fclose(f);
    
    
    			if (result == 1 && ToolNumberValid(tool))
    			{
    				printf("Read Disk File Value of %d\n", tool);
    				success = TRUE;	// success if one value converted
    			}
    		}
    
    
    		if (!success)
    			printf("Unable to open/read file:%s\n", TOOL_DISK_FILE);
    	}
    
    
    	if (!success)				// if still no success ask Operator
    	{
    		
    		
    		//???? ????????? ?? ???????? ?? ????? ???? ?? A ? ????????? 1 ??????????
        
                           ch1->LimitSwitchOptions=0x100; // ?????????? ????????? ????????? ??????? ?? ??? b, ????? ?? ????????????? ???
                Jog(3,20000);                            // ??????????? ??? Y ? ????????????? ??????????? ?? ???????? 10% ?? ???????????? 204800 ???/???
                while (ReadBit(15)) ;                // ???????? ???????????? ??????? ?? b- ??? 139
                Zero(3);                                    // ????????? ?????????? ??? b
                Jog(3,0);                              // ????????? ??? Y
                MoveAtVel(3,-300, 1000);          // ??????????? ??? Y ? ??????? ? ??????? 819 ??? (??? ???????? 1?? ??? ??????? ????) ?? ???????? 20480???/???
                while (!CheckDone(3)) ;             // ???????? ????????? ???????? ??? b
                                    Jog(3,300);                            // ????????? ??????????? ??? Y ? ????????????? ??????????? ?? ???????? 5% ?? ???????????? 204800 ???/???
                while (ReadBit(15)) ;               // ???????? ???????????? ??????? ?? b- ??? 139
                Zero(3);                                    // ????????? ?????????? ??? b
                Jog(3,0);                              // ????????? ??? Y
                MoveAtVel(3,-5380, 30000);          // ??????????? ??? Y ? ??????? ? ??????? 819 ??? (??? ???????? 1?? ??? ??????? ????) ?? ???????? 20480???/???
                while (!CheckDone(3)) ;             // ???????? ????????? ???????? ??? b
                Zero(3);
    		
    		    tool = 1;
    		
    		
    		
    		
    		
    		
    		
    	//	Answer = InputBox("Tool in Spindle or -1", &value);
    	//	if (Answer)
    		
    	//	{
    	//		printf("Operator Canceled\n");
    	//		return 1;
    	//	}
    	//	else
    	//	{
    	//		tool = value;
    	//		printf("Operator Entered Value of %d\n", tool);
    	//	}
    	//}
    
    
    	//if (!ToolNumberValid(tool))	// check if invalid
    	//{
    	//	char s[80];
    	//	sprintf(s, "Invalid Current Tool Number %d\n", tool);
    	//	printf(s);
    	//	MsgBox(s, MB_ICONHAND | MB_OK);
    	//	return 1;
    	}
    
    
    	printf("Current tool = %d\n", tool);
    	*ptool = tool;				// return result to caller
    	return 0;					//success
    }
    
    
    // save the tool number to KFLOP global Variable and to PC Disk file in case we loose power
    int SaveCurrentTool(int tool)
    {
    	persist.UserData[LAST_TOOL_VAR] = tool;
    	FILE *f = fopen(TOOL_DISK_FILE, "wt");
    	fprintf(f, "%d\n", tool);
    	fclose(f);
    	return 0;
    }
    
    
    // check if Current Tool number Valid
    // -1 = no tool loaded
    // 1-4 = valid tool
    BOOL ToolNumberValid(int tool)
    {
    	return tool == -1 || (tool >= 1 && tool <= 4);
    }
    But I still need to with each Homing axis A, the tool is dropped to the number 1.
    I have on the main screen a button home axis A,
    she executes this code

    Code:
      ch1->LimitSwitchOptions=0x100; 
                Jog(3,20000);                            
                while (ReadBit(15)) ;                
                Zero(3);                                   
                Jog(3,0);                             
                MoveAtVel(3,-300, 1000);          
                while (!CheckDone(3)) ;            
                                    Jog(3,300);                        
                while (ReadBit(15)) ;               
                Zero(3);                                  
                Jog(3,0);                             
                MoveAtVel(3,-5380, 30000);         
                while (!CheckDone(3)) ;            
                Zero(3);
    I need to install tool # 1 while executing this code.

    thank.

  10. #10
    Join Date
    May 2006
    Posts
    4043

    Re: auto tool change on axis A

    Hi vektor_z,

    I don't really understand what you are doing or what the issue exactly is.

    But after homing maybe you need to do something like:

    persist.UserData[LAST_TOOL_VAR] = 1; //set as Tool 1 is currently in use.
    TK
    http://dynomotion.com

Similar Threads

  1. Heidenhain M101 - Auto Tool Change If Tool Life Expires
    By Scott_1979 in forum G-Code Programing
    Replies: 0
    Last Post: 08-21-2018, 03:25 PM
  2. Auto tool change position
    By Tobione in forum Cincinnati CNC
    Replies: 6
    Last Post: 04-24-2018, 11:46 AM
  3. Tool Change - Can I set it to auto stop?
    By inthezone in forum Fanuc
    Replies: 16
    Last Post: 01-23-2008, 12:56 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
  •