LATHE INDEXING SPINDLE DISABLES ON M30

Moderators: TomKerekes, dynomotion

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

Re: LATHE INDEXING SPINDLE DISABLES ON M30

Post by TomKerekes » Sat Aug 24, 2019 10:03 pm

Hi turbothis,

In this case you might change your M5 program to only disable in the case there is no A axis defined as an Indexing axis.

Code: Select all

	if (CS0_axis_a == -1) // is A axis not defined in the Coordinate System?
		DisableAxis(2);   // yes, disable the axis, otherwise leave it enabled
Regards,

Tom Kerekes
Dynomotion, Inc.

turbothis
Posts: 325
Joined: Fri Mar 15, 2019 4:07 pm
Location: southern oregon

Re: LATHE INDEXING SPINDLE DISABLES ON M30

Post by turbothis » Sat Aug 24, 2019 10:18 pm

ok so my offjog program

Code: Select all

#include "KMotionDef.h"

#include "MySpindleDefs.h"


// desired speed is passed from KMotionCNC in variable KMVAR
// save in user variable STATEVAR whether it was off, CW, or CCW (0,1,-1)
// save in user variable SPEEDVAR the last desired speed

main()
{
	// spin down
	
	Jog(SPINDLEAXIS,0);
	printf("Jogging Spindle Stop\n");
	persist.UserData[STATEVAR] = 0;  // remember we are Off
	while (!CheckDone(SPINDLEAXIS)) ;
	DisableAxis(SPINDLEAXIS); 
}

turns into this?

Code: Select all

#include "KMotionDef.h"

#include "MySpindleDefs.h"


// desired speed is passed from KMotionCNC in variable KMVAR
// save in user variable STATEVAR whether it was off, CW, or CCW (0,1,-1)
// save in user variable SPEEDVAR the last desired speed

main()
{
	// spin down
	
	Jog(SPINDLEAXIS,0);
	printf("Jogging Spindle Stop\n");
	persist.UserData[STATEVAR] = 0;  // remember we are Off
	while (!CheckDone(SPINDLEAXIS)) ;
		if (CS0_axis_a == -1) // is A axis not defined in the Coordinate System?
		DisableAxis(2);   // yes, disable the axis, otherwise leave it enabled
}


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

Re: LATHE INDEXING SPINDLE DISABLES ON M30

Post by TomKerekes » Sat Aug 24, 2019 10:49 pm

Correct. That should work, but the way you indented the lines hurts my eyes. Your formatting style implies that the 'if' is inside the 'while' and the DisableAxis is not conditioned by the 'if'. Both incorrect. To an experienced C programmer its like reading a book with line breaks in the middle of sentences and no breaks where they should be. Please read this.

KMotion will also automatically indent for you:

Regards,

Tom Kerekes
Dynomotion, Inc.

turbothis
Posts: 325
Joined: Fri Mar 15, 2019 4:07 pm
Location: southern oregon

Re: LATHE INDEXING SPINDLE DISABLES ON M30

Post by turbothis » Sat Aug 24, 2019 11:39 pm

works great like all your additions to my machine. :D
i am trying to get better at all this stuff but it is pretty hard for a high skhool drop out.
i will study up on your link and watch the video
thanks matt

Post Reply