Page 1 of 1

spindle servo tuning for heavy chuck and overall mass

Posted: Sat Apr 27, 2024 2:21 am
by turbothis
is there some reading i can get a link to?
i try the step response and the spindle over shoots bad and i cant get any of the settings to calm it down
i tried a bunch of PID and low amounts
high jerk and accel and low amounts

making some cuts, the chuck will fall behind and then it burst too far forward and then oscillates.....
in my mind i am feeling it needs lots of power but at slow amounts of change to not over shoot?

Re: spindle servo tuning for heavy chuck and overall mass

Posted: Sat Apr 27, 2024 7:35 pm
by TomKerekes
Tuning any servo is fundamentally the same, but with different response times and such. If the Spindle Drive has a excessive delay that can be problematic.

Is the Drive input commanding torque or velocity?

Please post Step Response Screen Plots with also your IIR Filter and Configuration settings and we may be able to see something.

Re: spindle servo tuning for heavy chuck and overall mass

Posted: Mon Apr 29, 2024 10:58 pm
by turbothis
jeez it gave me grief to just move the spindle again....

anyways, it is a DC servo with a +/- 10V drive so torque right?

should i try and use "move" or "step"?

i dont think i have anything on the IIR settings

Code: Select all

#include "KMotionDef.h"

void main() 
{
    //  spindle

	ch2->InputMode=ENCODER_MODE;
	ch2->OutputMode=DAC_SERVO_MODE;
	ch2->Vel=  200000;
	ch2->Accel=70000;
	ch2->Jerk= 70000;
	ch2->P=5;
	ch2->I=0;
	ch2->D=10;
	ch2->FFAccel=0;
	ch2->FFVel=0;
	ch2->MaxI=200;
	ch2->MaxErr=1e+06;
	ch2->MaxOutput=2000;
	ch2->DeadBandGain=1;
	ch2->DeadBandRange=0;
	ch2->InputChan0=2;
	ch2->InputChan1=0;
	ch2->OutputChan0=2;
	ch2->OutputChan1=0;
	ch2->MasterAxis=-1;
	ch2->LimitSwitchOptions=0x100;
	ch2->LimitSwitchNegBit=0;
	ch2->LimitSwitchPosBit=0;
	ch2->SoftLimitPos=1e+30;
	ch2->SoftLimitNeg=-1e+30;
	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=1;
	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(0);
    EnableAxis(1);
    EnableAxis(2);
    
	DefineCoordSystem(0,-1,1,-1);
  }

Re: spindle servo tuning for heavy chuck and overall mass

Posted: Mon Apr 29, 2024 11:14 pm
by turbothis
first step response with "move"

edit. says file is too big to upload?
how do i upload the step response data?

Re: spindle servo tuning for heavy chuck and overall mass

Posted: Tue Apr 30, 2024 12:03 am
by turbothis
ok, so i manually tuned it and it is real nice performing on ramping up and down drastically with the MDI and feed override slider
however when the program is run it is very different

is there spindle performance parameters for running the C code that are different than just MDI and slider bar?

Code: Select all

#include "KMotionDef.h"

void main() 
{
    //  spindle

	ch2->InputMode=ENCODER_MODE;
	ch2->OutputMode=DAC_SERVO_MODE;
	ch2->Vel=  200000;
	ch2->Accel=300000;
	ch2->Jerk= 300000;
	ch2->P=20;
	ch2->I=0;
	ch2->D=50;
	ch2->FFAccel=0;
	ch2->FFVel=0;
	ch2->MaxI=200;
	ch2->MaxErr=1e+06;
	ch2->MaxOutput=2000;
	ch2->DeadBandGain=1;
	ch2->DeadBandRange=0;
	ch2->InputChan0=2;
	ch2->InputChan1=0;
	ch2->OutputChan0=2;
	ch2->OutputChan1=0;
	ch2->MasterAxis=-1;
	ch2->LimitSwitchOptions=0x100;
	ch2->LimitSwitchNegBit=0;
	ch2->LimitSwitchPosBit=0;
	ch2->SoftLimitPos=1e+30;
	ch2->SoftLimitNeg=-1e+30;
	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=1;
	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(0);
    EnableAxis(1);
    EnableAxis(2);
    
	DefineCoordSystem(0,-1,1,-1);
  }

Re: spindle servo tuning for heavy chuck and overall mass

Posted: Tue Apr 30, 2024 9:05 pm
by TomKerekes
edit. says file is too big to upload?
how do i upload the step response data?
Top
To upload the raw data you might zip the file or change to a smaller time.

anyways, it is a DC servo with a +/- 10V drive so torque right?
Well no, the voltage could command a velocity. In this case the drive would need to be measure velocity with an encoder or tachometer.

Its not really clear to me what is happening. The first thing you might do is command DAC voltages manually on the Console screen and observe what the Spindle does. ie. DAC2=1024 (half of output). Are there any delays? Then Stop DAC2=0 how long to stop?

Re: spindle servo tuning for heavy chuck and overall mass

Posted: Tue Apr 30, 2024 11:13 pm
by turbothis
on the console screen it will spin up real fast and DAC0 instantly

i wish i could get a long log of the command, position and output like in megasquirt ECU.
to see where it fails and then see what needs to be adjusted

Re: spindle servo tuning for heavy chuck and overall mass

Posted: Wed May 01, 2024 12:21 am
by TomKerekes
If the DAC/Spindle responds correctly then the problem is likely with the configurations/tuning. I assume there is encoder Feedback? Please post your Config/Step Response/Filter screens and Spindle Programs. One thing that may be happening is the output is limited so it can't keep up with the commanded speed. In this case it will lag far behind and after it is commanded to stop it will need to continue for some time to catch up with where it is supposed to be. This can only occur if the max Following Error is set to a huge value. If set to a small value the axis will immediately fault as it begins to lag behind to let you know it is being commanded to something it cannot do.

I think a Step Response Plot would clearly show what is happening.

If you would like to log data for plotting see how in the wiki here. I normally use MS Excel to plot things.

There is also the included Extended Logging contributed by User Greg. \KMotion\Release\ExtendedLoggingKflop.exe
Readme in Github by Greg here.


Re: spindle servo tuning for heavy chuck and overall mass

Posted: Wed May 01, 2024 2:51 pm
by turbothis
thanks for the info
ill study this for a couple days while i am camping this weekend
Monday i will try some stuff and get back to here :D