Page 1 of 1

Tool Change tool number diffrent bit output

Posted: Wed Mar 06, 2019 10:14 pm
by JonnyIWright
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

Re: Tool Change tool number diffrent bit output

Posted: Wed Mar 06, 2019 11:31 pm
by TomKerekes
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);
}

Re: Tool Change tool number diffrent bit output

Posted: Thu Mar 07, 2019 8:57 pm
by JonnyIWright
Hi Tom

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

Thanks