Invoking C Programs with Execute Only for previously Downloaded Programs

From Dynomotion

Jump to: navigation, search

KMotionCNC can Execute previously loaded C Programs by leaving the C Program Filename Blank in the Tool Setup Action Configuration.  Note the Program must be previously loaded somehow.  This can be significantly faster than compiling and downloading the program each time it is executed.

One possibility is to Flash it.  We normally discourage this because it can be confusing.  You must keep track of what program is Flashed into what Thread.  If you change KFLOP boards or upgrade firmware you will need to re-flash the the program into that Thread.  It also means all the default KFLOP Settings with thereafter be whatever they were when User Data was Flashed rather than the normal defaults.  This usually is not a problem but something to be aware of.  If it gives a significant performance improvement it might be worth the trouble.

Another option is to have a different M Code or Action such as "Prog Start" configured to download/Compile/Execute the program first one time.  If it is a problem having the Program execute the first time the "Var" variable will contain the Action Code which might be tested in the C Program to determine if it should really do something or not.  For example the test might be:

if (persist.UserData[0] == 103) ...

Example Program to print passed Var value:

C:\KMotionSrc\C Programs\PrintMCodeVar.c

#include "KMotionDef.h"

	printf("Var = %d\n",persist.UserData[0]);

KMotionCNC Tool Setup Configuration for M3 (Load Program to Thread #2, pass MCode in Var 0, and Execute)


KMotionCNC Tool Setup Configuration for M103 (pass MCode in Var 0 and Execute Only)





resulting output:

Var = 3

Var = 103