Table of contents |

MCodes with Parameters

KMotionCNC allows MCodes 100-119 with parameters when configured to Execute a KFLOP User C Program. The P Q and R words in the GCode block will be downloaded to KFLOP's persist.UserData variables before the C program is executed. The parameters will be placed into consecutive KFLOP variables as 32-bit floating point values starting with the variable specified in the MCode Configuration. Zero, one, two, or all three parameters may be specified in the GCode block (line). The order they are placed into the variables will always be in the P Q R order where any or all of the parameters will be omitted if they are not explicitly specified in the GCode Block. If no parameters are specified then the MCode number will be stored into the one Var specified.

Example MCode Configuration

Example MCode

Example MCode Usage with all 3 parameters:

M110 P1.23 Q4.56 R-1

Example C Code accessing parameters:

	#include "KMotionDef.h"

		printf("P = %f Q = %f R = %f\n",
			*(float *)&persist.UserData[0],
			*(float *)&persist.UserData[1],
			*(float *)&persist.UserData[2]);

Printed Result

P = 1.230000 Q = 4.560000 R = -1.000000