Tool Change tool number diffrent bit output

Moderators: TomKerekes, dynomotion

Post Reply
JonnyIWright
Posts: 2
Joined: Wed Mar 06, 2019 9:03 pm

Tool Change tool number diffrent bit output

Post by JonnyIWright » Wed Mar 06, 2019 10:14 pm

Hi I am integrating a kflops, kanolog, konnent into a Biesse CNC Router, I have finally got it up and running, it has multiple spindles all mounted to the z-axis and uses Pneumatic cylinders to lower each spindle for use, I need to output a bit to activate a different valve for each spindle, Im using KmotionCNC and currently configuring the Tool table, Has anyone got a C program that will do this ?

ie: tool call M6 T1 and output bit 152 for tool 1 or bit 153 for tool 2 etc

I'm trying to learn C but I am in the early stages

Thanks

User avatar
TomKerekes
Posts: 2529
Joined: Mon Dec 04, 2017 1:49 am

Re: Tool Change tool number diffrent bit output

Post by TomKerekes » Wed Mar 06, 2019 11:31 pm

Hi JonnyIWright,

Maybe something like this?

Code: Select all

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

main()
{
	int slot = persist.UserData[9];	// value stored is an int 
	int id = persist.UserData[9 + 1];	// value stored is an int 
	printf("Tool Set to slot %d id %d\n", slot, id);	// print the slot and id

	if (slot == 1)
	{
		ClearBit(153);
		SetBit(152);
	}
	else if (slot == 2)
	{
		ClearBit(152);
		SetBit(153);
	}
	else
	{
		char s[80];
		sprintf(s,"Invalid Tool Slot Number!  slot=%d",slot);
		MsgBox(s,MB_ICONEXCLAMATION);
		DoPC(PC_COMM_HALT);
		return;
	}

	Delay_sec(2.0);
}
Regards,

Tom Kerekes
Dynomotion, Inc.

JonnyIWright
Posts: 2
Joined: Wed Mar 06, 2019 9:03 pm

Re: Tool Change tool number diffrent bit output

Post by JonnyIWright » Thu Mar 07, 2019 8:57 pm

Hi Tom

Thank you for your swift help I will give this try and let you know if it works out

Thanks

Post Reply