Handling G30 in KMotionCNC and Probe signal?

Moderators: TomKerekes, dynomotion

larryjamessmith
Posts: 22
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: 2529
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 123 times
Regards,

Tom Kerekes
Dynomotion, Inc.

larryjamessmith
Posts: 22
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: 2529
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.

Gerad
Posts: 6
Joined: Thu Feb 27, 2020 4:29 pm
Location: Austria

Re: Handling G30 in KMotionCNC and Probe signal?

Post by Gerad » Thu Feb 27, 2020 4:51 pm

Hi Tom

I use Kflop with MACH3 and Schmidt Screen.
Now I tried to work with Fusion360.
The postprocessor from Fusion like to use G28
I have set home offsets in MACH3 parameter list, but if G28
occurs the machine likes to go to 0,0,0.
Normal homing process works well, I have defined my switch positions
in C-Code at startup.
I have read this parameters for G28 could be set in ems.var if KMotion is used.
Where or how can it be set in C-program on KFlop?

BR
Gerad

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

Re: Handling G30 in KMotionCNC and Probe signal?

Post by TomKerekes » Thu Feb 27, 2020 7:37 pm

Hi Gerad,
I use Kflop with MACH3 and Schmidt Screen.
Now I tried to work with Fusion360.
The postprocessor from Fusion like to use G28
I have set home offsets in MACH3 parameter list, but if G28
occurs the machine likes to go to 0,0,0.
I don't understand what you mean by "MACH3 parameter list".

I think in Mach3 the G28 position is set in Config | Homing Limits

G28.png


I have read this parameters for G28 could be set in ems.var if KMotion is used.
That only applies when using KMotionCNC not Mach3



Where or how can it be set in C-program on KFlop?
I don't think there is a way to change G28 from KFLOP. Depending on how you home you can set 0,0,0 to be anywhere you wish if that helps. To do this set some position at your home location other than 0,0,0


HTH
Regards,

Tom Kerekes
Dynomotion, Inc.

Gerad
Posts: 6
Joined: Thu Feb 27, 2020 4:29 pm
Location: Austria

Re: Handling G30 in KMotionCNC and Probe signal?

Post by Gerad » Fri Feb 28, 2020 6:29 pm

Hi Tom

thanks for fast response.
Another question: I would like to measure spindle revolutions with magnetic sensor
and display it in MACH3 screen.
Is it possible to count the tics/sec an send to MACH3?

BR

Gerad

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

Re: Handling G30 in KMotionCNC and Probe signal?

Post by TomKerekes » Fri Feb 28, 2020 6:59 pm

Hi Gerad,
I would like to measure spindle revolutions with magnetic sensor
and display it in MACH3 screen.
Is it possible to count the tics/sec an send to MACH3?
Its simplest to have a quadrature encoder on the Spindle.

Otherwise you should be able to either:

1 - monitor the pulses with a C Program (which executes at least every 270us) and update an Axis Position with a pulse count.
2 - use a circuit (RC delay) to form a quadrature type of A B signal and have an KFLOP encoder input count pulses.

Then configure Mach3 Threading as described in Step 5 here.

Update rate may likely be low with only 1 pulse per revolution.
Regards,

Tom Kerekes
Dynomotion, Inc.

Gerad
Posts: 6
Joined: Thu Feb 27, 2020 4:29 pm
Location: Austria

Re: Handling G30 in KMotionCNC and Probe signal?

Post by Gerad » Sat Feb 29, 2020 12:24 pm

Hi Tom

can you recommend an encoder?

BR

Gerad

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

Re: Handling G30 in KMotionCNC and Probe signal?

Post by TomKerekes » Sat Feb 29, 2020 4:27 pm

Hi Gerad,

USDigital is a good source. Choose a differential output as those can be connected to differential inputs or single ended inputs. Choose a resolution that will keep the cycles/second less than 250,000 cycles/second (1,000,000 quadrature counts/second) at your highest speed.

HTH
Regards,

Tom Kerekes
Dynomotion, Inc.

Post Reply