LATHE INDEXING SPINDLE DISABLES ON M30

Moderators: TomKerekes, dynomotion

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

LATHE INDEXING SPINDLE DISABLES ON M30

Post by turbothis » Fri Aug 23, 2019 5:47 pm

i was playing with my indexing program to see about cutting 33 spline on a round bar in the lathe chuck

Code: Select all

#include "KMotionDef.h"


void main()
{
	     // CH2 A axis
	   
	ch2->InputMode=ENCODER_MODE;
	ch2->OutputMode=NO_OUTPUT_MODE;
	ch2->Vel=  100000;
	ch2->Accel=500000;
	ch2->Jerk= 5000000;
	ch2->P=25;
	ch2->I=0.001;
	ch2->D=5;
	ch2->FFAccel=0;
	ch2->FFVel=0;
	ch2->MaxI=200;
	ch2->MaxErr=1e+006;
	ch2->MaxOutput=2048;
	ch2->DeadBandGain=1;
	ch2->DeadBandRange=0;
	ch2->InputChan0=2;
	ch2->InputChan1=2;
	ch2->OutputChan0=5;
	ch2->OutputChan1=4;
	ch2->MasterAxis=-1;
	ch2->LimitSwitchOptions=0x0;
	ch2->SoftLimitPos=1e+030;
	ch2->SoftLimitNeg=-1e+030;
	ch2->InputGain0=-1;
	ch2->InputGain1=1;
	ch2->InputOffset0=0;
	ch2->InputOffset1=0;
	ch2->OutputGain=1;
	ch2->OutputOffset=0;
	ch2->SlaveGain=1;
	ch2->BacklashMode=BACKLASH_OFF;
	ch2->BacklashAmount=0;
	ch2->BacklashRate=0;
	ch2->invDistPerCycle=0.0003662109375;
	ch2->Lead=0;
	ch2->MaxFollowingError=1000000;
	ch2->StepperAmplitude=20;

	ch2->iir[0].B0=1;
	ch2->iir[0].B1=0;
	ch2->iir[0].B2=0;
	ch2->iir[0].A1=0;
	ch2->iir[0].A2=0;

	ch2->iir[1].B0=1;
	ch2->iir[1].B1=0;
	ch2->iir[1].B2=0;
	ch2->iir[1].A1=0;
	ch2->iir[1].A2=0;

	ch2->iir[2].B0=1;
	ch2->iir[2].B1=0;
	ch2->iir[2].B2=0;
	ch2->iir[2].A1=0;
	ch2->iir[2].A2=0;
	
	    EnableAxis(2);
	 	DefineCoordSystem(1,-1,0,2);  // define the coordinate system
        
}
for some reason at the end of the cycle it will disable the A axis. not sure if M30 is doing this or what
i have no special C program written for M30. might need a "for (;;)" in the code?
here is my code i was running

Code: Select all

N1 G20 G18 G80 G40 G49 
G00Z0.1X0.2  (START)
X-0.005      (DOC)
Z-1.75       (CUT)
X0.2         (CLEAR)
Z0.1X0.2     (RESTART)
Z0.1X0.2  (START)
X-0.010      (DOC)
Z-1.745       (CUT)
X0.2         (CLEAR)
Z0.1X0.2     (RESTART)
Z0.1X0.2  (START)
X-0.015      (DOC)
Z-1.74       (CUT)
X0.2         (CLEAR)
Z0.1X0.2     (RESTART)
Z0.1X0.2  (START)
X-0.020      (DOC)
Z-1.735       (CUT)
X0.2         (CLEAR)
Z0.1X0.2     (RESTART)
Z0.1X0.2  (START)
X-0.025      (DOC)
Z-1.730       (CUT)
X0.2         (CLEAR)
Z0.1X0.2     (RESTART)
Z0.1X0.2  (START)
X-0.030      (DOC)
Z-1.725       (CUT)
X0.2         (CLEAR)
Z0.1X0.2     (RESTART)
Z0.1X0.2  (START)
X-0.0325      (DOC)
Z-1.720       (CUT)
X0.2         (CLEAR)
Z0.1X0.2     (RESTART)
Z0.1X0.2  (START)
X-0.035      (DOC)
Z-1.715       (CUT)
X0.2         (CLEAR)
Z0.1X0.2     (RESTART)
Z0.1X0.2  (START)
X-0.0375      (DOC)
Z-1.710       (CUT)
X0.2         (CLEAR)
Z0.1X0.2     (RESTART)
Z0.1X0.2  (START)
X-0.040      (DOC)
Z-1.705       (CUT)
X0.2         (CLEAR)
Z0.1X0.2     (RESTART)
Z0.1X0.2  (START)
X-0.0425      (DOC)
Z-1.700       (CUT)
X0.2         (CLEAR)
Z0.1X0.2     (RESTART)
Z0.1X0.2  (START)
X-0.045      (DOC)
Z-1.695       (CUT)
X0.2         (CLEAR)
Z0.1X0.2     (RESTART)
Z0.1X0.2  (START)
X-0.0475      (DOC)
Z-1.690       (CUT)
X0.2         (CLEAR)
Z0.1X0.2     (RESTART)
Z0.1X0.2  (START)
X-0.050      (DOC)
Z-1.685       (CUT)
X0.2         (CLEAR)
Z0.1X0.2     (RESTART)
Z0.1X0.2  (START)
X-0.0525      (DOC)
Z-1.680       (CUT)
X0.2         (CLEAR)
Z0.1X0.2     (RESTART)
Z0.1X0.2  (START)
X-0.055      (DOC)
Z-1.675       (CUT)
X0.2         (CLEAR)
Z0.1X0.2     (RESTART)
Z0.1X0.2  (START)
X-0.0575      (DOC)
Z-1.67       (CUT)
X0.2         (CLEAR)
Z0.1X0.2     (RESTART)

A10.909
G04P1

Z0.1X0.2  (START)
X-0.005      (DOC)
Z-1.75       (CUT)
X0.2         (CLEAR)
Z0.1X0.2     (RESTART)
Z0.1X0.2  (START)
X-0.010      (DOC)
Z-1.745       (CUT)
X0.2         (CLEAR)
Z0.1X0.2     (RESTART)
Z0.1X0.2  (START)
X-0.015      (DOC)
Z-1.74       (CUT)
X0.2         (CLEAR)
Z0.1X0.2     (RESTART)
Z0.1X0.2  (START)
X-0.020      (DOC)
Z-1.735       (CUT)
X0.2         (CLEAR)
Z0.1X0.2     (RESTART)
Z0.1X0.2  (START)
X-0.025      (DOC)
Z-1.730       (CUT)
X0.2         (CLEAR)
Z0.1X0.2     (RESTART)
Z0.1X0.2  (START)
X-0.030      (DOC)
Z-1.725       (CUT)
X0.2         (CLEAR)
Z0.1X0.2     (RESTART)
Z0.1X0.2  (START)
X-0.0325      (DOC)
Z-1.720       (CUT)
X0.2         (CLEAR)
Z0.1X0.2     (RESTART)
Z0.1X0.2  (START)
X-0.035      (DOC)
Z-1.715       (CUT)
X0.2         (CLEAR)
Z0.1X0.2     (RESTART)
Z0.1X0.2  (START)
X-0.0375      (DOC)
Z-1.710       (CUT)
X0.2         (CLEAR)
Z0.1X0.2     (RESTART)
Z0.1X0.2  (START)
X-0.040      (DOC)
Z-1.705       (CUT)
X0.2         (CLEAR)
Z0.1X0.2     (RESTART)
Z0.1X0.2  (START)
X-0.0425      (DOC)
Z-1.700       (CUT)
X0.2         (CLEAR)
Z0.1X0.2     (RESTART)
Z0.1X0.2  (START)
X-0.045      (DOC)
Z-1.695       (CUT)
X0.2         (CLEAR)
Z0.1X0.2     (RESTART)
Z0.1X0.2  (START)
X-0.0475      (DOC)
Z-1.690       (CUT)
X0.2         (CLEAR)
Z0.1X0.2     (RESTART)
Z0.1X0.2  (START)
X-0.050      (DOC)
Z-1.685       (CUT)
X0.2         (CLEAR)
Z0.1X0.2     (RESTART)
Z0.1X0.2  (START)
X-0.0525      (DOC)
Z-1.680       (CUT)
X0.2         (CLEAR)
Z0.1X0.2     (RESTART)
Z0.1X0.2  (START)
X-0.055      (DOC)
Z-1.675       (CUT)
X0.2         (CLEAR)
Z0.1X0.2     (RESTART)
Z0.1X0.2  (START)
X-0.0575      (DOC)
Z-1.67       (CUT)
X0.2         (CLEAR)
Z0.1X0.2     (RESTART)
M30
also i would like to learn if there is a repeating macro or command i can get to run the same cutting path then stop and index to a new position. then repeat this 32 times.

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

Re: LATHE INDEXING SPINDLE DISABLES ON M30

Post by TomKerekes » Fri Aug 23, 2019 7:34 pm

Hi turbothis,
for some reason at the end of the cycle it will disable the A axis. not sure if M30 is doing this or what
i have no special C program written for M30
What is the C Program you are showing assigned to?

What do you have configured for M30? M5? How are they configured in Tool Setup?

Try to troubleshoot what exactly is causing the problem.

Try changing M30 to M0 to see if it makes a difference.

Add M0's or G4P10's to pause to help determine where the problem occurs.

Any Disable messages on the Console?

also i would like to learn if there is a repeating macro or command i can get to run the same cutting path then stop and index to a new position. then repeat this 32 times.
See the Polygon.ngc example that creates an N sided polynomial using a subroutine (O100) called N times:

Code: Select all

(simple polygon)
#1=0 (start angle)
#2=10 (number of sides)
#3=1 (radius)
G20 G90
G0 X#3 Y0
F40
m100
M98 P100 L[#2+1]
M2

O100
G1 X[cos[#1] * #3] Y[sin[#1] * #3]
#1 = [#1 + 360.0 / #2]
M99
Poly.png
Poly.png (7.69 KiB) Viewed 2562 times
Regards,

Tom Kerekes
Dynomotion, Inc.

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

Re: LATHE INDEXING SPINDLE DISABLES ON M30

Post by TomKerekes » Fri Aug 23, 2019 7:54 pm

Hi turbothis,

On a minor note I see:
ch2->MaxOutput=2048;

2047 should be the maximum for a Kanalog DAC. 2048 will wrap to 0 and can cause problems. But this isn't an issue unless you saturate the output which shouldn't occur in normal operation.

It's not really a good idea to set parameters multiple place in multiple programs unless there is really some need to change them. Otherwise you are just increasing your chances for errors and confusion.
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 » Fri Aug 23, 2019 8:55 pm

ok i will fix that 2047....
i just need the INDEXING program to stay enabled
i am using the lathe for both indexing and turning functions. i have 2 separate C programs for this

"What is the C Program you are showing assigned to?"

it is my indexing servo (CH2) tune after i use the main enable C program.

What do you have configured for M30? M5? How are they configured in Tool Setup?

i have nothing added to these in there

the Polygon.ngc example is absolutely over my head. i understand about 10% of it

"Try changing M30 to M0 to see if it makes a difference."
it ran the cycle and then paused on M0 with no disable or error

"Any Disable messages on the Console?"
console says "Jogging Spindle Stop" with the M30 at the end

my offjog C program prints this it looks like

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); 
}


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

Re: LATHE INDEXING SPINDLE DISABLES ON M30

Post by TomKerekes » Sat Aug 24, 2019 4:44 pm

Hi turbothis,
What do you have configured for M30? M5? How are they configured in Tool Setup?

i have nothing added to these in there
That's hard to believe. The M5 Action is what turns off the Spindle. Don't you have M5 configured to execute the offjog C program you posted? Are you able to turn the Spindle off?

i just need the INDEXING program to stay enabled
Do you see the "DisableAxis" function call in the program you posted?

the Polygon.ngc example is absolutely over my head. i understand about 10% of it
It is very simple. If you told us what parts you understand and what parts you don't we could help. Its hard to help without feedback. Imagine someone telling you they only know 10% of how to drive a car. How would you help them?

Do you understand GCode Variables - #nnn ??
Do you understand formula of a circle - X = Radius * sin(theta), Y = Radius * cos(theta) ??
Do you understand the concept of subroutines - Beginning label (O100), Return from subroutine (M99), Subroutine Calls (M98) ? ??

Try changing M30 to M0 to see if it makes a difference."
it ran the cycle and then paused on M0 with no disable or error
Thanks. That affirms that the End-of-Program M30 turning off the spindle by calling the M5 Action is likely the culprit.
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 6:37 pm

ok ya your right i do have a M5 program.
is there a stop and rewind M code that does not call out the M5 program? like M02?
this way i would just put that at the end of the G code

yes it does disable the spindle axis

i will break down what makes sense with the poly and get back to you
thanks for the help as always

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

Re: LATHE INDEXING SPINDLE DISABLES ON M30

Post by TomKerekes » Sat Aug 24, 2019 6:54 pm

Hi turbothis,
is there a stop and rewind M code that does not call out the M5 program? like M02?
this way i would just put that at the end of the G code
No


yes it does disable the spindle axis
Why did you put this in and for what purpose? Why not simply remove it?
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 9:36 pm

it was added so the spindle would free wheel when not in use
other wise it would hold position

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

Re: LATHE INDEXING SPINDLE DISABLES ON M30

Post by TomKerekes » Sat Aug 24, 2019 9:48 pm

Hi turbothis,

I'm confused. You are expecting it to remain enabled yet also free to spin like being disabled?
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 9:52 pm

sorry it is mixing modes there
in the TURNING program i want it to be disabled at the end of the cycle
in the INDEXING program i would like it to remain enabled

TURNING

Code: Select all

#include "KMotionDef.h"
#include "MySpindleDefs.h"

void main()
{
	// CH2 - spindle

	ch2->InputMode=ENCODER_MODE;
	ch2->OutputMode=NO_OUTPUT_MODE;
	ch2->Vel  =300000;
	ch2->Accel=80000;
	ch2->Jerk =150000;
	ch2->P=10;
	ch2->I=0;
	ch2->D=10;
	ch2->FFAccel=0;
	ch2->FFVel=0;
	ch2->MaxI=200;
	ch2->MaxErr=1e+006;
	ch2->MaxOutput=2047;
	ch2->DeadBandGain=1;
	ch2->DeadBandRange=0;
	ch2->InputChan0=2;
	ch2->InputChan1=2;
	ch2->OutputChan0=5;
	ch2->OutputChan1=4;
	ch2->MasterAxis=-1;
	ch2->LimitSwitchOptions=0x0;
	ch2->SoftLimitPos=1e+030;
	ch2->SoftLimitNeg=-1e+030;
	ch2->InputGain0=-1;
	ch2->InputGain1=1;
	ch2->InputOffset0=0;
	ch2->InputOffset1=0;
	ch2->OutputGain=1;
	ch2->OutputOffset=0;
	ch2->SlaveGain=1;
	ch2->BacklashMode=BACKLASH_OFF;
	ch2->BacklashAmount=0;
	ch2->BacklashRate=0;
	ch2->invDistPerCycle=0.0003662109375;
	ch2->Lead=0;
	ch2->MaxFollowingError=60000;
	ch2->StepperAmplitude=20;

	ch2->iir[0].B0=1;
	ch2->iir[0].B1=0;
	ch2->iir[0].B2=0;
	ch2->iir[0].A1=0;
	ch2->iir[0].A2=0;

	ch2->iir[1].B0=1;
	ch2->iir[1].B1=0;
	ch2->iir[1].B2=0;
	ch2->iir[1].A1=0;
	ch2->iir[1].A2=0;

	ch2->iir[2].B0=1;
	ch2->iir[2].B1=0;
	ch2->iir[2].B2=0;
	ch2->iir[2].A1=0;
	ch2->iir[2].A2=0;
	
     EnableAxis(0);  // Enable servo    Z axis
     EnableAxis(1);  // Enable servo    X axis 
	DefineCoordSystem(1,-1,0,-1);  // define the coordinate system
}
INDEXING

Code: Select all

#include "KMotionDef.h"


void main()
{
	     // CH2 A axis
	   
	ch2->InputMode=ENCODER_MODE;
	ch2->OutputMode=NO_OUTPUT_MODE;
	ch2->Vel=  100000;
	ch2->Accel=500000;
	ch2->Jerk= 5000000;
	ch2->P=25;
	ch2->I=0.001;
	ch2->D=5;
	ch2->FFAccel=0;
	ch2->FFVel=0;
	ch2->MaxI=200;
	ch2->MaxErr=1e+006;
	ch2->MaxOutput=2047;
	ch2->DeadBandGain=1;
	ch2->DeadBandRange=0;
	ch2->InputChan0=2;
	ch2->InputChan1=2;
	ch2->OutputChan0=5;
	ch2->OutputChan1=4;
	ch2->MasterAxis=-1;
	ch2->LimitSwitchOptions=0x0;
	ch2->SoftLimitPos=1e+030;
	ch2->SoftLimitNeg=-1e+030;
	ch2->InputGain0=-1;
	ch2->InputGain1=1;
	ch2->InputOffset0=0;
	ch2->InputOffset1=0;
	ch2->OutputGain=1;
	ch2->OutputOffset=0;
	ch2->SlaveGain=1;
	ch2->BacklashMode=BACKLASH_OFF;
	ch2->BacklashAmount=0;
	ch2->BacklashRate=0;
	ch2->invDistPerCycle=0.0003662109375;
	ch2->Lead=0;
	ch2->MaxFollowingError=1000000;
	ch2->StepperAmplitude=20;

	ch2->iir[0].B0=1;
	ch2->iir[0].B1=0;
	ch2->iir[0].B2=0;
	ch2->iir[0].A1=0;
	ch2->iir[0].A2=0;

	ch2->iir[1].B0=1;
	ch2->iir[1].B1=0;
	ch2->iir[1].B2=0;
	ch2->iir[1].A1=0;
	ch2->iir[1].A2=0;

	ch2->iir[2].B0=1;
	ch2->iir[2].B1=0;
	ch2->iir[2].B2=0;
	ch2->iir[2].A1=0;
	ch2->iir[2].A2=0;
	
	    EnableAxis(2);
	 	DefineCoordSystem(1,-1,0,2);  // define the coordinate system
        
}

Post Reply