Page 1 of 1

Using multiple Kflop boards

Posted: Tue Sep 15, 2020 9:26 pm
by curtiskelowna
Hi Tom, hope you are doing well.

I have an application where I would like to control a 5 axis gantry CNC as well as a number of linear actuators used for automation, loading etc. 6 axis channels would be used for coordinated motion on XYZAB, controlled through kmotionCNC. To be clear, the additional actuators dont need to perform coordinated moves with the XYZAB system.

My thought would be to create an mcode with parameters to command an axis on the second board to move to a position. For example, m110 P200 might move axis 0 to position 200 (with the right C program). Is there a way to address a specific kflop board within a C program?

I have done some digging and found this:

Re: Using multiple Kflop boards

Posted: Tue Sep 15, 2020 9:27 pm
by curtiskelowna

Re: Using multiple Kflop boards

Posted: Tue Sep 15, 2020 10:04 pm
by TomKerekes
Hi Curtis,

KMotionCNC isn't setup to work with multiple boards.

If you wrote a PC App to send a command to a 2nd board you could then configure a KMotionCNC MCode to invoke the PC App.

KMotionCNC can pass GCode P Q R parameters to the App on the command line to specify which axis and how much to move.

I'm not sure what your preferred language is. You might look at the SimpleCoffLoad C++ example. Which is a stand alone program to invoke a C Program in a KFLOP.

The '0' in this line:

CKMotionDLL *KM = new CKMotionDLL(0);

specifies which KFLOP to work with. '0' means the first board found. Changing to a specific USB Location ID will make it use a particular board.

You will also need to add in the code to read the Windows command line to get the parameters and send them to KFLOP.

Code: Select all

// SimpleCoffload.cpp 

#include "stdafx.h"
#include "..\..\KMotionDll\KMotionDll.h"  // KMotion DLL Header

CKMotionDLL *KM;                // one instance of the interface class

void MyError();


int main(int argc, char* argv[])
{
	CKMotionDLL *KM = new CKMotionDLL(0);

	// Compile and Download a C Program into Thread #1

	if (KM->CompileAndLoadCoff("..\\..\\C Programs\\BlinkKFLOP.c",1))	MyError();

	// Execute Thread 1
	
	if (KM->WriteLine( "Execute1")) MyError(); 
	
	return 0;
}

// Display Error and terminate

void MyError()
{
	printf("Unable to communicate with KMotion board");
	exit(1);
}
HTH

Re: Using multiple Kflop boards

Posted: Wed Sep 16, 2020 6:09 pm
by curtiskelowna
Hi Tom, that makes sense and is very helpful.

Is there a way to launch two instances of KMOTIONCNC, one for each board? I know this is possible with kmotion.exe but I am not sure about the CNC interface. Having a second interface with jogs and DRO's would give a lot of functionality (probably with a simplified custom screen).

Ideally I would still use an mcode to run a PC App to communicate to the second board. However, the PC app would instead load and run a gcode file. This would make programming the "robot routines" much easier with standard GCODE. I think this should be possible, I took a look at the SimpleGCode example. The question is, can I configure which board KMCNC talks to?

Thanks for your help

Re: Using multiple Kflop boards

Posted: Wed Sep 16, 2020 7:57 pm
by curtiskelowna
Hi Tom,

I did some testing on my end and here is what I have found:

1. create a second installation of KMOTION in C://Kmotion434_ALT/
2. create 2 shortcuts to kmotionCNC.exe each with a seperate usb identifier (C:\KMotion434\KMotion\Release\KMotionCNC.exe 0x19 etc..)

Unfortunately I am only able to test with one kflop right now but later tonight I will try with 2. From what I can see it actually works! With the KFLOP plugged in one USB port, it displays "connected" on the correct instance of kmotionCNC. If I unplug and switch to the other USB port, it disconnects from the first instance and connects to the second kmotionCNC interface.

Do you expect this to work? Or am I stepping into complicated territory...

Thanks

Re: Using multiple Kflop boards

Posted: Wed Sep 16, 2020 8:18 pm
by curtiskelowna
https://imgur.com/gallery/Gf8cfIv

In case you are curious, here are some renderings of the gantry design where you can see the second "head" I intend to use for automation tasks. The robot head has a total of 4 axis (the gripper can rotate). The machining head and dual drive gantry total 5 axis. I intend to install a rotary table for full 5 axis machining. Kflop 1 would drive the 6 axis for machining and kflop 2 the 4 axis robot.

The robot would be able to load and unload CNC jobs as well as act as a tool changer for an ATC spindle

Re: Using multiple Kflop boards

Posted: Wed Sep 16, 2020 9:46 pm
by TomKerekes
Hi Curtis,

That should work. You shouldn't have needed a 2nd installation. Only a second configuration. See here.

Cool design. Can't wait for the video :)