This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

InstaSpin-MOTION Velocity, Acceleration and Jerk Profiles

Other Parts Discussed in Thread: CONTROLSUITE

I'm evaluating InstaSPIN/SpinTAC on a F28069M processor.  I am looking to replace a current product that runs ControlSuite on a F28335.  The current product uses an S-curve motion profile.  We set jerk, max acceleration and max velocity.  The profiler uses the jerk value, then adjusts the acceleration and velocity according to the move distance.  The acceleration and velocity cannot exceed the max, but typically they are determined to be less than the max.  The following graph shows our current profiler doing a 5 rev move with a jerk of 9 normalized units/s^3, an acceleration of 2.2 normalized units/s^2 and a velocity of 0.63 normalized units/s.

I did the same move with InstaSPIN MOV - 5 revs, and all the same parameters converted to krpm for velocity, krpm/s for acceleration and krpm/s^2 for jerk and got a very different profile set.  See below.

In this case, InstaSPIN uses the max acceleration as the acceleration to use.  My question is: how does the profiler work?  I need to understand it to make the moves complete in the same time as the previous product.

Also, I took reference data of the velocity and acceleration of a trapezoid profile.  The InstaSPIN acceleration is approximately half of what I would expect.  When I calculated the acceleration based on [(vel2 - vel1)/ deltaTime], it came out to be twice what InstaSpin gives as the acceleration.  See below:

Again - I would like to understand how the profile is determined.

Thanks-

Mary

  • Mary,

    The SpinTAC profile generator does a similar function to your profile generator. It takes in the user provided Jerk Limit, Acc Limit, Dec Limit, Velocity Limit, and Position Step. From those limits it will construct a time-optimal profile that respects all of the provided limits.

    One key difference is that the SpinTAC profile generator features the st-curve which handles the jerk differently. Instead of using a fixed jerk like in a s-curve, it uses a continuously varying jerk which results in even smoother motion.

    I'm concerned about your logging. When you showed the image for what the SpinTAC profile looks like it was missing a couple of features of the jerk. And the acceleration reference had a strange shape to it.

    One of the outputs from the SpinTAC profile generator is the amount of time (in samples) that it will take to generate a profile. You should be able to use this in order to adjust the limits in order to get the profile to take the same amount of time as your previous design.
  • Hi Adam-

    Thanks for looking at this.

    The comparison plots are for the S-Curve in InstaSPIN, not the stCurve. I'm datalogging every 25 ms, which may explain the weird acceleration reference shape. What I don't understand is that the acceleration goes straight to the max value.

    Also, in the third plot for the trapezoid profile, I don't understand why the InstaSPIN acceleration is so different from the calculated value.

    Thanks-
    Mary
  • Mary,

    If you are using an s-curve it should take 0.24 sec to reach maximum acceleration. Are you doing this logging through CCS or are you using a data buffer on the DSP? The debugger through CCS won't give you precise timing.

    What is the conversion factor you are using from velocity, accel, and jerk for converting from scaled to krpm? Also what Q-types? Velocity and accel are Q24 while jerk is Q20.
  • Hi Adam-

    The jerk being a Q20 got me.  That was the problem for the shape of the jerk, acceleration and velocity.  Now they show up with the correct jerk/accel/vel values but the move completes in half the time as it should.  It takes roughly 0.12 seconds to get to the max acceleration.

    I also have not figured out why the acceleration plot from InstaSPIN trapezoid does not match the [(velocity_2_InstaSPin - velocity_1_InstaSpin)/deltaTime] plot. This is the third plot above. 

    I'm using a data logger running on the processor, not the one in the debugger.

  • Mary,

    My guess about why it is reaching the max acceleration in 0.12 sec instead of 0.24 seconds is that maybe the jerk setting isn't what you thought it was.  The variable gMotorVars.MaxJrk_krpmps2 is Q20 as well.  There could be a translation error between the two profile generations.  

    I just ran your profile settings (with a couple guesses based on the plots) in MATLAB and it came out exact.  My guess is that there could be some issue in the logging or the conversion from pu to krpm.  The way tot check this would be to run the trap curve and look at st_obj.pos.move.msg.ActualAccLim (Q24) this is the maximum acceleration that was used in the profile.

    Can you post your exact profile settings (Pos Step, * Lim, etc), this will let me run it in the simulator and on some target hardware.

  • Hi Adam-

    I'm finally back to this project...

    I'm getting rid of my normalized units scale and dealing in revolutionss, krpm, krpm/s and kprm/s^2 only.  The velocity was 0.63 normalized units (nu) which translates to krpm as follows as follows:

    0.63 nu/sec * 61.516 revs/nu * 60 sec/min / 1000 rev/krev = 2.325 krpm  (Max Velocity)

    The acceleration is 2.2 nu/sec^2 which translates to krpm/sec as follows:

    2.2 nu/s^2 *61.516 revs/nu * 60 sec/min / 1000 rev/krev = 8.120 krpm/sec (Max Accel)

    The jerk is 9.0 nu/sec^3 and is adjusted as follows:

    9.0 nu/s^3 * 61.516 revs/nu * 60 sec/min / 1000 rev/krev = 33.218 krpm/sec^2 (Max Jerk)

    I enter these values into the debugger in the following variables:

    _iq gMotorVars.MaxVel_krpm = 2.3  (iq24)

    _iq gMotorVars.MaxAccel_krpmps = 8.12 (iq24)

    _iq gMotorVars.MaxAccel_krpmps = 8.12 (iq24)

    _iq20 gMotorVars.MaxJrk_krpmps2 = 33.218 (iq20)    I enter it in the debugger as as iq20 as well.

    The move is 5 revolutions. 

    Here is the Move function that picks up the variables:

    void ST_runPosMove(ST_Handle handle)
    {
    ST_Obj *stObj = (ST_Obj *)handle;
    
    // Run SpinTAC Position Profile Generator
    // If we are not running a profile, and command indicates we should has been modified
    if((STPOSMOVE_getStatus(stObj->posMoveHandle) == ST_MOVE_IDLE) && (gMotorVars.RunPositionProfile == true)) {
    // Get the configuration for SpinTAC Position Move
    STPOSMOVE_setCurveType(stObj->posMoveHandle, gMotorVars.SpinTAC.PosMoveCurveType);
    STPOSMOVE_setPositionStep_mrev(stObj->posMoveHandle, gMotorVars.PosStepInt_MRev,  gMotorVars.PosStepFrac_MRev);
    STPOSMOVE_setVelocityLimit(stObj->posMoveHandle, _IQmpy(gMotorVars.MaxVel_krpm, _IQ(ST_SPEED_PU_PER_KRPM)));
    STPOSMOVE_setAccelerationLimit(stObj->posMoveHandle, _IQmpy(gMotorVars.MaxAccel_krpmps, _IQ(ST_SPEED_PU_PER_KRPM)));
    STPOSMOVE_setDecelerationLimit(stObj->posMoveHandle, _IQmpy(gMotorVars.MaxDecel_krpmps, _IQ(ST_SPEED_PU_PER_KRPM)));
    STPOSMOVE_setJerkLimit(stObj->posMoveHandle, _IQ20mpy(gMotorVars.MaxJrk_krpmps2, _IQ20(ST_SPEED_PU_PER_KRPM)));
    // Enable the SpinTAC Position Profile Generator
    STPOSMOVE_setEnable(stObj->posMoveHandle, true);
    // clear the position step command
    gMotorVars.PosStepInt_MRev = 0;
    gMotorVars.PosStepFrac_MRev = 0;
    gMotorVars.RunPositionProfile = false;
    }
    
    STPOSMOVE_run(stObj->posMoveHandle);
    }

    The values I plot during the move are:

    gMotorVars.velProfileRef_krpm = _IQmpy(STPOSMOVE_getVelocityReference(stObj->posMoveHandle), _IQ(ST_SPEED_KRPM_PER_PU));

    gMotorVars.accelProfileRef_krpmps = _IQmpy(STPOSMOVE_getAccelerationReference(stObj->posMoveHandle), _IQ(ST_SPEED_KRPM_PER_PU));

    gMotorVars.jerkProfileRef_krpmps2 = _IQ20mpy(STPOSMOVE_getJerkReference(stObj->posMoveHandle), _IQ20(ST_SPEED_KRPM_PER_PU));

    gMotorVars.velProfileRef_krpm and gMotorVars.accelProfileRef_krpmps are iq24.  gMotorVars.jerkProfileRef_krpmps2 is iq20.

    Should I datalog different variables to see the profiles (other that the references)?

    For both the trapezoidal profile and the S-curve, I'm still seeing a discrepancy in the calculated acceleration [(velocityRef -velocityRefLast)/delta time] vs the acceleration reference from InstaSpin.  The calculated value is approximately twice as big.  

    Thanks-

    Mary

  • Hi Adam -

    I'm looking at the mrev_TO_pu variable. I am using a QEP so the USER_IQ_FULL_SCALE_FREQ_HZ is (3 pole pairs/0.008). So mrev_TO_pu comes out to be 0.008. Could this be a problem? What is the 'per unit' in this case?

    -Mary
  • Mary,

    It seems like you are logging things correctly.  

    Have you looked at the output values in STPOSMOVE_getActualVelocity, STPOSMOVE_getActualAcceleration, and STPOSMOVE_getActualJerk?  These will give you the maximum values during the profile.  Also look at the values from STPOSMOVE_getProfileTime_tick.  This will give you the profile time.  Lets make sure those are aligning.

  • Hi Adam-

    Here is the data you requested:

    st_obj.pos.move.msg.ProTime_tick  = 337

    st_obj.pos.move.msg.ActualVelLim (iq24) = 0.119 pu/s  which divided by ST_SPEED_PU_PER_KRPM =  0.8925 krpm

    st_obj.pos.move.msg.ActualAccLim (iq24) = 0.0.7087 pu/s^2 which converted is 5.315 krpm/s

    st_obj.pos.move.msg.ActualJerkLim (iq20) = 4.2696 pu/s^3 which converted is 32.02 krpm/s^2

    The values from my data logging are:

    Time ~= 0.35 sec

    Max Vel = 0.893 krpm

    Max Accel = 4.93 krpm/s

    Max Jerk = 32.022 krpm/s^2

    I've attached an Excel file of the move.

    Thanks-

    MaryL1Y_SpinTAC_SCurve_j33a8v2.xlsx

  • Hi Adam-

    Another bit of information...

    The SpinTac tick time is 0.002 sec.

    -Mary

  • Mary,

    I ran your profile through our MATLAB environment and saw no issues.  I've updated your excel file with the simulation data.  This was ran against the exact source code you run on the F28069M, and it simulates fixed point math. 

    Profile Settings: [TI_C2K] [SCRV] J: 4.26958 A: 0.708699 D: 0.708699 V: 0.119053 P: 5 PTC: 337 PTMC: 0

    0647.L1Y_SpinTAC_SCurve_j33a8v2.xlsx

    My calculated acceleration matches (within a reasonable amount of error) the acceleration reference.  When I do some down sampling of the signal, I do start to see some deviations in terms of the acceleration.  

    When you mentioned that the sample time is 0.002 sec, you configured that via the user.h file, correct?  If your profile ticks are 337, that is the number of samples a move will take, and so it should take 337 * 0.002 = 0.674 seconds, but your data doesn't reflect that.  

  • Hi Adam -

    I found the problem. After your last post, I went back and looked at the isr and saw that I was calling ST_runPosMove twice in the isr. Duh!! Now the move happens in the appropriate amount of time and the SpinTAC acceleration match the calculated acceleration. I'm sorry for the oversight and that I wasted a lot of your time.

    -Mary
  • Mary,

    I'm glad you were able to find the issue and get it resolved!