Handling G30 in KMotionCNC and Probe signal?

Moderators: TomKerekes, dynomotion

Post Reply
larryjamessmith
Posts: 10
Joined: Mon Dec 23, 2019 9:18 pm

Handling G30 in KMotionCNC and Probe signal?

Post by larryjamessmith » Fri Feb 07, 2020 5:31 am

I am interested in using G30 which appears to be supported since it is on the help screen but there is no information on how it is implemented and what default hardware bits are used to communicate with a probe. Is that only available in Mach plugins, or can it be used by anyone with Kflops/Kanalog hardware? Is there a way to change mapping of Probe bits if the defaults are already used for other functions?

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

Re: Handling G30 in KMotionCNC and Probe signal?

Post by TomKerekes » Fri Feb 07, 2020 4:57 pm

Hi Larry,

KMotionCNC implements G30 as Move to Reference Position #2 (ie Home position #2) not Probing.

You can implement Probing in KMotionCNC with an M Code that calls a C Program.

Here is the ProbeDirection.c example to simply probe in a specified direction, at a specified speed, and stop when the probe triggers.

Code: Select all

#include "KMotionDef.h"

// For basic KMotionCNC Probing configure KMotionCNC to call this C Program
// with an MCode and 3 parameters P Q R passed in variables 50,51,52 to 
// specify the X Y Z Probe directions speeds
//
// Modify this program for the input bit you are using for your probe.  As
// written the program keeps moving until the bit goes high.  If the polarity
// of your probe is opposite this then remove the NOT Symbol '!' applied to the
// ReadBit result. 
//
// For Example:
//
// M100 = Exec/Wat/Sync  Thread 2 Var 50 <>\C programs\ProbeDirection.c
//
// Then to probe in the X direction at 100 counts/sec use GCode as:
//
// M100 P100 Q0 R0
//
// Then to probe in the Y direction at 50 counts/sec use GCode as:
//
// M100 P0 Q50 R0
//
// 

main()
{
	Jog(0,*(float *)&persist.UserData[50]);	// move in the velocites specified
	Jog(1,*(float *)&persist.UserData[51]);
	Jog(2,*(float *)&persist.UserData[52]);

//	printf("X Y Z Speeds = %f %f %f\n",
//		*(float *)&persist.UserData[50],
//		*(float *)&persist.UserData[51],
//		*(float *)&persist.UserData[52]);

	while (!ReadBit(46)) ;   		// wait for switch to go high

	Jog(0,0); 						//Stop
	Jog(1,0);
	Jog(2,0);
}



Jeremy Brown posted a nice Probe routine and Video. I've attached a version of his code.

Attachments
jerbroZCircles_Rev2.c
(6.97 KiB) Downloaded 1 time
Regards,

Tom Kerekes
Dynomotion, Inc.

larryjamessmith
Posts: 10
Joined: Mon Dec 23, 2019 9:18 pm

Re: Handling G30 in KMotionCNC and Probe signal?

Post by larryjamessmith » Fri Feb 07, 2020 6:27 pm

Tom,
Thank you for this info. I will use your method.
So, out of curiosity, what is "Reference Position 2"? I know Reference Position 1 is machine 0,0,0.

Larry

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

Re: Handling G30 in KMotionCNC and Probe signal?

Post by TomKerekes » Fri Feb 07, 2020 7:26 pm

Hi Larry,

Actually setting GCode Variables with the Vars file specified in Tool Setup can be used to configure where G28 and G30 go. By default they will be zero.

The related GCode Vars are listed below:

Code: Select all

static const int _required_parameters[] = {
 5161, 5162, 5163,   /* G28 home */
 5164, 5165, 5166,
 5181, 5182, 5183,   /* G30 home */
 5184, 5185, 5186,
 5211, 5212, 5213,   /* G92 offsets */
 5214, 5215, 5216,
 5220,               /* selected coordinate */
 5221, 5222, 5223,   /* coordinate system 1 */
 5224, 5225, 5226,
 5241, 5242, 5243,   /* coordinate system 2 */
 5244, 5245, 5246,
 5261, 5262, 5263,   /* coordinate system 3 */
 5264, 5265, 5266,
 5281, 5282, 5283,   /* coordinate system 4 */
 5284, 5285, 5286,
 5301, 5302, 5303,   /* coordinate system 5 */
 5304, 5305, 5306,
 5321, 5322, 5323,   /* coordinate system 6 */
 5324, 5325, 5326,
 5341, 5342, 5343,   /* coordinate system 7 */
 5344, 5345, 5346,
 5361, 5362, 5363,   /* coordinate system 8 */
 5364, 5365, 5366,
 5381, 5382, 5383,   /* coordinate system 9 */
 5384, 5385, 5386,
 RS274NGC_MAX_PARAMETERS
};
Regards,

Tom Kerekes
Dynomotion, Inc.

Post Reply