Phase advance and High Speed

165 views
Skip to first unread message

Xing Yu

unread,
Aug 29, 2019, 9:47:16 PM8/29/19
to Smart Stepper
Hi All,

I have tried the phase advancement feature in the 0.38 firmware, by enabling " #define ENABLE_PHASE_PREDICTION" in the board.h.  However I didn't see any difference in terms of speed performance,  the highest speed the NEMA17 can run is around 800RPM, with or without phase advancement.   I have tested the pwm pulse input and position move command, the top speed is similar at around 800RPM.

I really like to get as much speed as possible from the stepper motor.  If anyone knows how to enable the 'phase advancement' feature, and get the motor running at 2000RPM (as stated in the manual), please let me know.

Many thanks,
Xing

Andrew Moody

unread,
Aug 30, 2019, 7:06:01 AM8/30/19
to Smart Stepper
I haven't looked at v38 code, but the v36 code had what I thought were bugs with phase prediction.  I'm not a professional motion control engineer, so take all of this with a grain of salt.

These were the notes I took, but I haven't revisited later firmware versions to see if any of this has changed.  I don't really need phase prediction in my application, so I haven't been keeping this updated when I bump up to the new firmware versions.

//phase prediction notes:
//(phase prediction did not take into account that PID results in oscillations around the target and reversing direction occurs as a normal part of finding the target.
//It did not properly handle a negative oscillation from a positive move.  Ideally, phase prediction should understand when a particular move starts and when it ends,
//to eliminate introducing error into the movement by carrying over the mean from a target seek in one direction to another target seek in the opposite direction.
//phase prediction should identify the original direction of error and reset the PID calculations when that direction changes.
//Making travel direction work correctly revealed additional issue in the PID algorithm.  The threshold is much higher than anticipated (notes below in simplefeedback comments).
//  Mean and dx scaling alignment
//  corrected mean increase math
//  accept error as parameter
//  store last error
//  compare sign of last error to current error
//  clears mean, lastdx, and lastloc when error sign changes
//  sets lastloc to currentloc when lastloc is 0 to prevent incorrect error calculations on first pass
//
//simplefeedback notes:
//output threshold is calculated as a function of the microsteps systemparam in order to achieve a realistic amount of adjustment during a processor cycle
//  adds threshold comparison to error such that deltas below threshold are not output
//  clears lasterror, iterm, i, maxerror, errorcount, lastprobestate, maxma, and probecount when error sign changes - this prevents bleedover from previous error correction into new error correction

Xing Yu

unread,
Aug 30, 2019, 11:36:57 AM8/30/19
to Smart Stepper
Hi Andrew,

Thanks for the reply.  I am trying to understand your notes on phase prediction.  

In the meanwhile,  just a quick question -- were you able to use 'phase prediction' to increase the top speed of the motor ?  If so, what was the top speed?

Many thanks

Andrew Moody

unread,
Aug 30, 2019, 1:25:33 PM8/30/19
to Smart Stepper
I never measured the speed.
These notes were concerning code changes I had made to my own fork of firmware v36.
Sorry, I may not be very much help.

misfittech

unread,
Oct 28, 2019, 4:44:25 PM10/28/19
to Smart Stepper
How are you commanding the motor to move? 

joel silvestre

unread,
Jan 7, 2020, 5:57:29 AM1/7/20
to Smart Stepper
Hi all,

I dug a little bit the phase prediction and came to pretty good results, 1800 rpm and much more torque. Without phase prediction max rpm is #500rpm at 24V. 
The resulting code is very simple.
But the latency have to be constant and actually it's not the case. There is a lot of jitter, so much that sometimes the deadline is crossed and a full loop period is lost causing noise and lost of torque.
I found the main cause to be the eeprom storage because it disable the loop timer interrupts when calling some A5047 functions. Currently I disabled it totally. Reworking to remove the interrupts disabling should make it works.

Joël

int64_t StepperCtrl::calculatePhasePrediction(int64_t currentLoc)
{
    static int64_t lastLoc=0;
    int32_t dx;

#ifndef ENABLE_PHASE_PREDICTION
    return 0;
#endif
   
    /*     AS5047 latency #100µs + 55µs for the pid loop = 155µs
   
    velocity rps = dx / 360 * 6000 -> max = 30rps = 1800rpm = 10800°/s         dx=currentLoc-lastLoc
    velocity °/s = dx * 6000
   
    theta = dx * 6000 * t = dx * 0.9        theta = phase delay to be added , t = angle measurement latency #155µs
   
    Experience shows much better velocity and torque when theta is around dx * 1.8    
    */
   
    //what was our change in the location
    dx=currentLoc-lastLoc;  //max value is typically less than 327(1.8 degrees) or 163(0.9 degree)
    lastLoc=currentLoc;
   
    return (dx*1800)/1024;
}


Reply all
Reply to author
Forward
0 new messages