SPINDLE SERVO SPECS

Moderators: TomKerekes, dynomotion

Moray
Posts: 282
Joined: Thu Apr 26, 2018 10:16 pm

Re: SPINDLE SERVO SPECS

Post by Moray » Wed Apr 10, 2019 11:55 am

turbothis wrote:
Tue Apr 09, 2019 8:04 pm
outstanding
it is working good

for some reason the CCW program spins CW too

Code: Select all

#define SPINDLEAXIS 2			// Axis Channel to Jog to rotate Spindle
#define FACTOR (11872.46/60.0)  	// to convert RPM to counts/sec (counts/rev / 60.0sec)
#define SPINDLECW_BIT 154   	// bit to activate to cause CW rotation
#define SPINDLECCW_BIT 155		// bit to activate to cause CCW rotation
#define SPEEDVAR 99				// global persistant variable to store latest speed
#define STATEVAR 98				// global persistant variable to store latest state (-1=CCW,0=off,1=CW)
#define KMVAR PC_COMM_CSS_S 	// variable KMotionCNC will pass speed parameter (113)
#define USE_POS_NEG_VOLTAGE 0 	// 0 = output Magnitude, 1 = output positive and negative speed 
Have you changed the USE_POS_NEG_VOLATGE define to 1?
I've not checked all the code, but setting that to one should cause a Jog to be commanded either positive or negative depending on direction, whereas with it set to zero, the Jog is always in the same negative or positive direction, with the CW/CCW outputs controlling the direction (i.e. how a typical VFD would run, with the direction set by a dedicated signal, then just 0-10V to control speed)

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

Re: SPINDLE SERVO SPECS

Post by turbothis » Wed Apr 10, 2019 1:54 pm

no i did not change that. works great now
i always know what i need is right in front of my eyes but i just cant see it
thanks for the pointer
thanks

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

Re: SPINDLE SERVO SPECS

Post by turbothis » Fri Jul 26, 2019 2:43 am

trying to tune the spindle is turning out to be very difficult

problem #1
turning at 1500 rpm and then in the program i slow to 800 rpm and the spindle will stumble and get very erratic.
i imagine this is due to simple motor tuning. i plan on working on this but really cant make much sense of the step/response parameters to notice a change

problem #2
if i have the spindle running at 1000 rpm and hit the CCW button again with the same 1000 rpm the spindle will get erratic and out of control
maybe this has to do with the CCW program?
like it wants to start from zero rpm when the CCW button is pushed and this starts it out of control because of the tune
the spindle has a lot of momentum due to it being about 120 pounds

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

Re: SPINDLE SERVO SPECS

Post by turbothis » Fri Jul 26, 2019 3:02 am

Code: Select all

#include "KMotionDef.h"

#include "MySpindleDefs.h"

int   *css_mode = &persist.UserData[PC_COMM_CSS_MODE];			// Mode 1=Normal RPM mode. 2=CSS

// 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()
{
	EnableAxis(SPINDLEAXIS);
	float speed = *(float *)&persist.UserData[SPEEDVAR];  // value stored is actually a float 
	float LastState = persist.UserData[STATEVAR];  // get last state 
	
	if (LastState==1)  
	{
		// if spindle was CW now we want CCW 
		// spin down
		
		ClearBit(SPINDLECW_BIT);
		ClearBit(SPINDLECCW_BIT);
		Jog(SPINDLEAXIS,0);
		while (!CheckDone(SPINDLEAXIS)) ;
	}
	
	// turn spindle on CCW and ramp to new speed
	SetBit(SPINDLECCW_BIT);
	
	LastState = -1;
	
	if (*css_mode != 2)
	{
		// spindle is already on, so ramp to new speed
		if (USE_POS_NEG_VOLTAGE)
			Jog(SPINDLEAXIS,speed * FACTOR * LastState);
		else
			Jog(SPINDLEAXIS,speed * FACTOR);
		
		printf("Jogging Spindle %f counts/sec\n",speed * FACTOR);
	}	
	persist.UserData[STATEVAR] = -1;  // remember we are CCW
}


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

Re: SPINDLE SERVO SPECS

Post by turbothis » Fri Jul 26, 2019 10:15 pm

this was a good read
file:///C:/Users/Turbo/Desktop/downloadz/Servo_tuning_tutorial%20(1).pdf

Moray
Posts: 282
Joined: Thu Apr 26, 2018 10:16 pm

Re: SPINDLE SERVO SPECS

Post by Moray » Fri Jul 26, 2019 10:29 pm

turbothis wrote:
Fri Jul 26, 2019 10:15 pm
this was a good read
file:///C:/Users/Turbo/Desktop/downloadz/Servo_tuning_tutorial%20(1).pdf
You might want to either attach the document to a post, or post the link to where the document can be found online, rather than a link to where you've stored it on your computer... ;)

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

Re: SPINDLE SERVO SPECS

Post by turbothis » Fri Jul 26, 2019 10:59 pm


Moray
Posts: 282
Joined: Thu Apr 26, 2018 10:16 pm

Re: SPINDLE SERVO SPECS

Post by Moray » Fri Jul 26, 2019 11:03 pm

turbothis wrote:
Fri Jul 26, 2019 10:59 pm
win some you lose some.......
ftp://ftp.pmccorp.com/pub/support/docs/ ... torial.pdf
:D
Thanks for that. I've just had a quick skim of it and it certainly looks good.

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

Re: SPINDLE SERVO SPECS

Post by TomKerekes » Sat Jul 27, 2019 1:10 pm

Hi turbothis,
turning at 1500 rpm and then in the program i slow to 800 rpm and the spindle will stumble and get very erratic.
i imagine this is due to simple motor tuning. i plan on working on this but really cant make much sense of the step/response parameters to notice a change
Sounds like the Spindle is not tuned properly. You would need to post your settings and plots at various velocities for us to help.
problem #2
if i have the spindle running at 1000 rpm and hit the CCW button again with the same 1000 rpm the spindle will get erratic and out of control
maybe this has to do with the CCW program?
like it wants to start from zero rpm when the CCW button is pushed and this starts it out of control because of the tune
the spindle has a lot of momentum due to it being about 120 pounds
The CCW program unconditionally enables the axis. You shouldn't do this if the axis is already enabled and in motion. You might change:

EnableAxis(SPINDLEAXIS);

to

if (!chan[SPINDLEAXIS].Enable) EnableAxis(SPINDLEAXIS);
Regards,

Tom Kerekes
Dynomotion, Inc.

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

Re: SPINDLE SERVO SPECS

Post by turbothis » Sat Jul 27, 2019 4:20 pm

ya i am trying to learn a lot about the tuning. the axis are pretty easy and straight forward being they can get to full rapid in like 1/2 second. the spindle has a lot of mass to spool up so i am not there yet

thanks! i will try your line of code

Post Reply