Need Help! Resonance with Kflop + Kstep


Results 1 to 14 of 14

Thread: Resonance with Kflop + Kstep

  1. #1

    Default Resonance with Kflop + Kstep

    I'm building some 4 axis gantry style machines with Kflop + Kstep in closed loop stepper mode. XY axes have 270 oz-in 2.8A steppers wired in series with 900CPR (3600 ct) encoders and 5mm pitch ball-screws connected with flexible alum coupling. Everything works great except I am experiencing some resonance at low velocities in XY that cause some undesirable vibrations when doing certain slow moves, especially interpolating circles. I have attached a screen shot of the normal step response plot at max vel as well as a plot with the velocity limited to 4000 to cause it to stay in the resonant range-The heavy banding shows the resonant area. Currently using Low Pass 2nd at 110 Hz Q1.41. Have also tried adding a notch filter at 4000 Hz 1 damping, to no effect. (Assume velocity of 4000 steps per sec equates to 4000 Hz?) Problem persists with PID all set to zero also.

    Can someone recommend an IIR filter or other settings that might address this?

    Thank you!
    Troy

    Similar Threads:
    Attached Thumbnails Attached Thumbnails Resonance with Kflop + Kstep-resonance-normal-velocity-jpg   Resonance with Kflop + Kstep-resonance-4000-sps-png  


  2. #2
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4045
    Downloads
    0
    Uploads
    0

    Default Re: Resonance with Kflop + Kstep

    Hi Troy,

    This should be interesting. I suspect the resonant vibrations are much lower than the microstep rate of 4000Hz. More likely something like the cogging on the motor poles would be a disturbance that is exciting the resonance in your system. With KSTEP 16X microstepping there is a motor pole every 64 microsteps. So that would be 4000/64 = 62.5Hz. Or maybe a harmonic (multiple of that)? You could see the resonance clearly if you zoom in (left mouse drag) across the plot. Please use the Save Data button to save the data to a text file and post it that way we can zoom in and plot it in KMotion.exe however we wish.

    A notch filter is not likely to help. It would help if the Servo feedback was causing the servo to be unstable and oscillate. But I believe this is more like an external disturbance that we need to dampen. A notch filter will kill all servo output at the notch frequency so the feedback will never excite the resonance, but it also will not dampen any oscillation caused by something else.

    Is the encoder on the motor or the lead screw?

    Have you tried some P or D gains to see if it has an effect? (Possibly even negative values)

    Regards

    Regards
    TK http://dynomotion.com


  3. #3
    Member
    Join Date
    Jun 2013
    Location
    USA
    Posts
    1041
    Downloads
    0
    Uploads
    0

    Default Re: Resonance with Kflop + Kstep

    😱 You can use negative pid settings? What is the difference in how negative vs positive gains affect a system. Also can some be negative and some positive? Man every time I think I might be starting to understand how things work ...

    Ben



  4. #4
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4045
    Downloads
    0
    Uploads
    0

    Default Re: Resonance with Kflop + Kstep

    Hi Ben,

    Now that you mention it I'm not entirely sure it makes sense as negative gains could result in positive feedback and runaway. But I think if small enough (ie P much less than 1) it would not run away. Take this example:

    Assume P Gain = -0.1, Commanded position = 0, but somehow encoder position = 1.0

    Error of -1 should require an Output Offset -1 (left) to correct the error, however P = -0.1 would cause the Offset to be +0.1 eventually causing the position to move to 1.1.
    Now error of -1.1 should require an Output Offset -1.1 to correct the error, so the offset will now be adjusted to +0.11 eventually causing the position to move to 1.11
    etc... I believe the position will converge to 1.1111111... Worse than before but without runaway.

    Why do such a stupid thing? The idea of damping is to apply a small force in the opposite direction of velocity. Think of a resonant system like a swinging mass pendulum. Applying a small force proportional and in the opposite direction to the mass's velocity will bring it to a stop. With a classic servo system where the output is torque and the motor position is measured then positive Derivative gain works as damping. But this situation is probably more complicated. #1 If we are not measuring the position of the motor but rather measuring the position of the lead screw then at the resonant frequency the phase of the motion of the motor and that of the lead screw are likely to be 180 degrees out of phase. #2 commanding the stepper driver to "step" some amount may take some time to actually generate a torque into the motor resulting in a phase shift.

    So basically even with an unknown amount of phase shift between measured position and velocity, and unknown amount of phase shift between commanded output and generated force, there should be a way to get the force in the phase we want to damp out the oscillation by adjusting the signs (+/-180 degree shifts) or D vs P gain (+/-90 degree phase shifts).

    Anyway that's my thinking

    Regards

    Regards
    TK http://dynomotion.com


  5. #5
    Member
    Join Date
    Jun 2013
    Location
    USA
    Posts
    1041
    Downloads
    0
    Uploads
    0

    Default Re: Resonance with Kflop + Kstep

    Thanks for the explanation Tom. My first thought when I read your post mentioning negative gains was will it cause run away. I didn't even consider how it would affect a system that has the encoder mounted off the motor. Luckily I don't have that issue but I can see where the negative value could be helpful in sum situations.

    Ben



  6. #6
    Member
    Join Date
    Jun 2013
    Location
    USA
    Posts
    1041
    Downloads
    0
    Uploads
    0

    Default Re: Resonance with Kflop + Kstep

    Thanks for the explanation Tom. My first thought when I read your post mentioning negative gains was will it cause run away. I didn't even consider how it would affect a system that has the encoder mounted off the motor. Luckily I don't have that issue but I can see where the negative value could be helpful in some situations.

    Ben

    Quote Originally Posted by bhurts View Post
    Thanks for the explanation Tom. My first thought when I read your post mentioning negative gains was will it cause run away. I didn't even consider how it would affect a system that has the encoder mounted off the motor. Luckily I don't have that issue but I can see where the negative value could be helpful in sum situations.

    Ben
    Quote Originally Posted by bhurts View Post
    Thanks for the explanation Tom. My first thought when I read your post mentioning negative gains was will it cause run away. I didn't even consider how it would affect a system that has the encoder mounted off the motor. Luckily I don't have that issue but I can see where the negative value could be helpful in sum situations.

    Ben




  7. #7

    Default Re: Resonance with Kflop + Kstep

    Quote Originally Posted by TomKerekes View Post
    Hi Troy,

    This should be interesting. I suspect the resonant vibrations are much lower than the microstep rate of 4000Hz. More likely something like the cogging on the motor poles would be a disturbance that is exciting the resonance in your system. With KSTEP 16X microstepping there is a motor pole every 64 microsteps. So that would be 4000/64 = 62.5Hz. Or maybe a harmonic (multiple of that)? You could see the resonance clearly if you zoom in (left mouse drag) across the plot. Please use the Save Data button to save the data to a text file and post it that way we can zoom in and plot it in KMotion.exe however we wish.

    A notch filter is not likely to help. It would help if the Servo feedback was causing the servo to be unstable and oscillate. But I believe this is more like an external disturbance that we need to dampen. A notch filter will kill all servo output at the notch frequency so the feedback will never excite the resonance, but it also will not dampen any oscillation caused by something else.

    Is the encoder on the motor or the lead screw?

    Have you tried some P or D gains to see if it has an effect? (Possibly even negative values)

    Regards
    Hi Tom,

    Thanks for the input., I will try some negative P or D gains (positive didn't seem to have an effect). Hopefully I can apply the gains only in that 62.5 Hz frequency range with a filter?. I have also uploaded a step response .txt plot of a move at normal velocity and one with the velocity limited to 4000 to stay in resonant range. (see zip)

    The encoders are mounted on the back of the double shaft motors.

    I also tried using lead compensation values of 25-30 since that's a similar range to what I calculated the knee frequency to be (around 60-80 Hz). Lead compensation also had no effect.

    Thank you,
    Troy

    Attached Files Attached Files


  8. #8
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4045
    Downloads
    0
    Uploads
    0

    Default Re: Resonance with Kflop + Kstep

    Hi Troy,

    I tried a number of things and I found something that looks promising. Simply feeding back a portion of the position error delayed by a fraction of the resonant oscillation period seems to be pretty effective. See this Video:



    I used a size34 Stepper that had a pretty bad resonance when unloaded and unmounted on the table. The Resonance was at ~137Hz. It was excited the most when microstepping at 2200 microsteps/sec which is 137 Full Steps per second (KSTEP uses 16X microstepping)


    Here is a Plot accelerating through the resonance (with no Damping)

    Velocity Profile
    Resonance with Kflop + Kstep-slowvelramp-png

    Position error plot through resonance (no damping)
    Resonance with Kflop + Kstep-withnodelayedfeedback-png

    Position error plot at resonance (no damping)
    Resonance with Kflop + Kstep-positionerrornodelayedfeedback-png

    Zoom in to measure resonant Frequency (~13.7 cycles over 0.1 seconds)
    Resonance with Kflop + Kstep-measurefreq-png

    Position error plot through resonance (with damping)
    Resonance with Kflop + Kstep-withdelayedfeedback-png

    Position error plot at resonance (with damping)
    Resonance with Kflop + Kstep-positionerrorwithdelayedfeedback-png



    Here is the code I used. It is also attached as a text file.
    Code:
    #include "KMotionDef.h"
    
    // Demo for testing Active Damping of Resonant Vibrations
    //
    // Technique used is to feed back a portion of the Position Error delayed in time.
    //
    // GAIN is the portion that is to be fed BACKLASH_OFF
    // Freq and DELAY_CYCLE determines the amount of Time Delay
    // (Typical vales are Freq = Resonant Frequency of system and 0.75 of a cycle)
    //
    // This program sets up a Servo Sample callback to perform the calculations.
    // Note that once the program sets up variables and the callback it Terminates
    // However the callback continues to execute.  Downloading a new or modified
    // program into the Thread space before stopping the Callback (UserCallBack = NULL)
    // can cause a crash.  The program is setup to toggle the Callback On and Off each
    // time it is executed 
    // 
    // A circular buffer is used to delay the signal for a Freq=137Hz and Delay_Cycle=0.75
    // the signal is delayed 61 Servo Samples
    //
    // The program also contains anti-dither code where below a certain speed (100uSteps/sec)
    // for at least 0.03sec the Closed Loop and Damping Feedback is disabled 
    //
    // The Damping can also be enabled and disabled by seatting/clearing persist variable 100  
     
    
    #define Freq 137.0 			// Resonant Frequency to be supressed
    #define DELAY_CYCLE 0.75	// Fraction of cycle to be delayed
    #define GAIN 0.25f			// portion of error to be fed back
    
    #define MAXD 1024
    
    int nDelay;
    float Delay[MAXD];
    
    float TimeDelay(float I);
    void DoDither(CHAN *ch, float P_original, float P_low, float I_original, double *T0, double T1);
    
    // Anti dither variables
    double T1,T0_0=0;  
    float P_original_0;
    float P_low_0;
    float I_original_0;
    
    // Called before every servo Sample
    void CallBack(void)
    {
        // Compute Error and Time Delay it
        ch0->DestOffset = TimeDelay(ch0->Dest-ch0->Position)*GAIN;
    
        // Force no Damping if Stopped (Integrator off) or User on/off
        if (ch0->I < 1e-6f || persist.UserData[100]==0.0) ch0->DestOffset=0.0;
        
        // maintain Dither mode
        T1=Time_sec();  // returns current time
        DoDither(ch0, P_original_0, P_low_0, I_original_0, &T0_0, T1);
    }
    
    
    main()
    {
        int i;
        
        for (i=0;i<MAXD;i++)Delay[i]=0.0f;  // clear delay buffer
        
        // Compute number of samples signal should be delayed
        nDelay = (int)(DELAY_CYCLE*((1.0/Freq)/TIMEBASE)+0.5);
        printf("nDelay = %d\n",nDelay);
        
        // define Closed Loop PI parameters to be used while moving and when stopped
        P_original_0 = 0.05;
        P_low_0      = 0.0;
        I_original_0 = 0.0008;
        
        //Toggle Callback On and Off
        if (UserCallBack)
        {
            printf("Callback Off\n");
            UserCallBack = NULL;  //Stop the callback
        }
        else
        {
            printf("Callback On\n");
            UserCallBack = CallBack;  // start the callback
        }
    }
    
    // Performs Time Delay by saving New Value into a Circular
    // buffer and retrieving older value delayed by nDelay samples 
    float TimeDelay(float I)
    {
        static int iDelay=0;
        int i;
    
        // Save new value
        Delay[iDelay]=I;
        
        // Get old value
        i=iDelay++ - nDelay;
        if (iDelay>=MAXD)iDelay=0;
    
        if (i<0) i+=MAXD;  // wrap?
        return Delay[i];
    }
    
    
    #define SMALL_VEL 100 // step/sec
    #define LONG_TIME 0.03
    
    // Change Gains for one Axis Based on being nearly stopped for a least some period of time
    void DoDither(CHAN *ch, float P_original, float P_low, float I_original, double *T0, double T1)
    {
        if (fast_fabs(ch->last_vel) > SMALL_VEL) *T0=T1;
    
        if (T1 - *T0 > LONG_TIME)// error for a long time
        {
            ch->P = P_low;   // reduced gain
            ch->I = 0.0;     // no integrator
        }
        else
        {
            ch->P = P_original;    // normal gain
            ch->I = I_original;    // normal integrator
        }
    }
    Maybe you could give this a try. Let me know how much of it makes sense.

    Regards

    Attached Files Attached Files
    Regards
    TK http://dynomotion.com


  9. #9

    Default Re: Resonance with Kflop + Kstep

    Hi Tom,

    Thanks for taking the time to investigate this. Sorry for the delayed response- I've been dialing in other parts of the system and have finally found some settings that work for the resonance. Your method makes sense but I couldn't get it to eliminate the resonance in my Nema 23 system. However, I adapted your program to reduce the D gain exponentially for each axis as it approaches the known resonant frequency. The setting seems extreme, but applying a Derivative gain of -12 to -7 at those frequencies depending on the axis has really smoothed them out. This also requires ramping a negative Feed Forward acceleration at the same rate as the D gain is decreased below zero to maintain position.
    As an interesting side note, I switched from helical style aluminum motor couplers to the spider style with an elastomer element and the frequency and duration of the resonant areas were reduced by about 35%. I will post the code I used for controlling resonance on the 4 axes after I clean it up a bit.

    Thanks again for the awesome support!
    Troy



  10. #10
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4045
    Downloads
    0
    Uploads
    0

    Default Re: Resonance with Kflop + Kstep

    Hi Troy,

    Interesting. Thanks for posting and would love to see what you did.

    Regards

    Regards
    TK http://dynomotion.com


  11. #11

    Default Re: Resonance with Kflop + Kstep

    Hi Tom,

    The below code applies different gains with an exponential ramp in profile to avoid abrupt gain changes. Note that two target freqencies (velocities really), ranges, and D damping variables are available for each stepper channel as I found that some need damping at two velocity intervals. Normally a D gain of -9 to -12 is very effective at killing low frequency instability and resonance in this Nema 23 application. In rare cases a large positive D gain will help.

    #include "KMotionDef.h"

    //V1 2-15-15 Added FFVel original and D_lown to allow 2 freq ranges

    void DoRes(CHAN *ch, float D_original, float FFVel_original, float D_low, float D_lown, int freq, int range, int freqn, int rangen, float factor);

    main()
    {
    // save original gains and do anti-dither
    float D_original_0 = ch0->D;
    float FFVel_original_0 = ch0->FFVel;
    float D_low_0 = -12.; //normal damping gain, usually negative
    float D_lown_0 = 0; //secondary damping gain applied to freqn rangen
    int freq_0 = 3900; //vel for normal damping gain
    int range_0 = 1950; //range for normal damping gain
    int freqn_0 = -1; //vel for n damping gain
    int rangen_0 = 0; //range for n damping gain
    float factor_0;

    float D_original_1 = ch1->D;
    float FFVel_original_1 = ch1->FFVel;
    float D_low_1 = -12.; //normal damping gain, usually negative
    float D_lown_1 = -9.; //secondary damping gain applied to freqn rangen
    int freq_1 = 2500; //vel for normal damping gain
    int range_1 = 475; //range for normal damping gain
    int freqn_1 = 4900; //vel for n damping gain
    int rangen_1 = 600; //range for n damping gain
    float factor_1;

    float D_original_2 = ch2->D;
    float FFVel_original_2 = ch2->FFVel;
    float D_low_2 = -12.; //normal damping gain, usually negative
    float D_lown_2 = 0; //secondary damping gain applied to freqn rangen
    int freq_2 = 2875; //vel for normal damping gain
    int range_2 = 1850; //range for normal damping gain
    int freqn_2 = -1; //vel for n damping gain
    int rangen_2 = 0; //range for n damping gain
    float factor_2;

    float D_original_3 = ch3->D;
    float FFVel_original_3 = ch3->FFVel;
    float D_low_3 = -12.; //normal damping gain, usually negative
    float D_lown_3 = -12.; //secondary damping gain applied to freqn rangen
    int freq_3 = 2100; //vel for normal damping gain
    int range_3 = 400; //range for normal damping gain
    int freqn_3 = 3600; //range for n damping gain
    int rangen_3 = 700; //vel for n damping gain
    float factor_3;

    for (; //loop forever
    {
    DoRes(ch0, D_original_0, FFVel_original_0, D_low_0, D_lown_0, freq_0, range_0, freqn_0, rangen_0, factor_0);
    DoRes(ch1, D_original_1, FFVel_original_1, D_low_1, D_lown_1, freq_1, range_1, freqn_1, rangen_1, factor_1);
    DoRes(ch2, D_original_2, FFVel_original_2, D_low_2, D_lown_2, freq_2, range_2, freqn_2, rangen_2, factor_2);
    DoRes(ch3, D_original_3, FFVel_original_3, D_low_3, D_lown_3, freq_3, range_3, freqn_3, rangen_3, factor_3);
    }
    }


    void DoRes(CHAN *ch, float D_original, float FFVel_original, float D_low, float D_lown, int freq, int range, int freqn, int rangen, float factor)
    {

    if(fast_fabs(ch->last_vel) > freqn-rangen && fast_fabs(ch->last_vel) < freqn+rangen)
    {
    factor = fast_fabsf(fast_fabs(ch->last_vel)- freqn); //find distance from target speed for ramping
    ch->D = D_lown*(1+-(powf((factor/rangen),12))); //apply positive damping in freq range n
    if(D_lown<0)
    {
    ch->FFVel=-FFVel_original*(1+-(powf((factor/rangen),12))); //ramp in at a negative feed forward vel to counter negative P gain effect
    }
    }
    else if (fast_fabs(ch->last_vel) > freq-range && fast_fabs(ch->last_vel) < freq+range)// less than high end of resonant range
    {
    factor = fast_fabsf(fast_fabs(ch->last_vel)- freq); //find distance from target speed for ramping
    ch->D = D_low*(1+-(powf((factor/range),12))); // damping gain
    ch->MaxErr=.01; //set PID error allowance low to avoid large corrections at low speed
    if(D_low<0)
    {
    ch->FFVel=-FFVel_original*(1+-(powf((factor/range),12))); //ramp in at a negative feed forward vel to counter negative P gain effect
    }
    }
    else
    {
    ch->D = D_original; // normal gain
    ch->MaxErr=100; //normal max allowable pid error
    ch->FFVel=FFVel_original; //normal feed forward Vel
    }
    }


    I also attached the C program as a text file.

    Let me know if this makes sense.
    Thanks,
    Troy

    Attached Files Attached Files


  12. #12
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4045
    Downloads
    0
    Uploads
    0

    Default Re: Resonance with Kflop + Kstep

    Hi Troy,

    Very clever, but I can't say I really understand it. You didn't include what the normal settings are so it makes it hard to see what is being adjusted. It seems like the D gain is being switched abruptly from whatever normal is to zero when the frequency range is entered. It then "ramps" to nearly D_low at the center frequency.

    Can you show a Step Response Plot similar to what I did with and without the program running to show the difference? Or maybe a video?

    Thanks for sharing.
    Regards

    Regards
    TK http://dynomotion.com


  13. #13

    Default Re: Resonance with Kflop + Kstep

    Hi Tom,

    The normal D gains are 0. The program causes the D to be temporarily set to a large negative D (d_low) when at velocities in the "freq" + or - "range" area with the "max" (lowest really) D value occurring exactly at "freq" for that channel. It works best for making drastic derivative changes to target resonance at very specific, short problem frequency ranges which I have found occurring in many Nema 23 steppers around 1500-5000 microsteps/sec (16x microstepping). In this case it overdrives or oversteps the motor to eliminate some spring mass problem at that speed. Sometimes a positive D value helps but at these low speeds a derivative of -9 to -12 has been most effective for me. The below clip shows a step response move at 2650 steps/sec both with and without the Change_D_Res thread shown below running. I attached a dial indicator so you can see as well as hear the resonance. The corresponding step/response plots are also attached in a zip file.



    Thanks,
    Troy

    Attached Files Attached Files


  14. #14
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4045
    Downloads
    0
    Uploads
    0

    Default Re: Resonance with Kflop + Kstep

    Thanks for the explanation and video. Impressive.

    Regards

    Regards
    TK http://dynomotion.com


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

Resonance with Kflop + Kstep

Resonance with Kflop + Kstep