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.

wrong Parameters defined in user.h

Why USER_MOTOR_MAX_CURRENT in user.h of lab12b can not be difined greater than 128.0 ?

But The CCS Compile correct when I difine USER_MOTOR_MAX_CURRENT greater than 128.0 in user.h of lab03b . 

 The maximum current of my motor is 259A .

  • Stefan,

    The reason you get this build error is because in InstaSPIN-MOTION we allow you to run-time modify the output maximum and minimum of the speed regulator.   The interaction variable has the unit of Amps and is an IQ24 variable.  So when you set USER_MOTOR_MAX_CURRENT to 259.0, the software has a build error because it tries to place a value of 259.0 into an IQ24 variable.  The way to fix this is to change the units of these variables from Amps to Scaled Amps.  I've included the code changes below:

    spintac_velocity.h:

    //! \brief Initalization values of SpinTAC global variables
    #define ST_VARS_DEFAULTS {false, \
                              ST_VEL_ID_IDLE, \
                              0, \
                              0, \
                              0, \
                              0, \
                              0, \
                              true, \
                              ST_CTL_IDLE, \
                              _IQ24(USER_SYSTEM_BANDWIDTH_SCALE), \
                              0, \
                              _IQ24(USER_MOTOR_MAX_CURRENT / USER_IQ_FULL_SCALE_CURRENT_A), \
                              -_IQ24(USER_MOTOR_MAX_CURRENT / USER_IQ_FULL_SCALE_CURRENT_A), \
                              0, \
                              ST_MOVE_IDLE, \
                              ST_MOVE_CUR_STCRV, \
                              0, \
                              false, \
                              0, \
                              ST_PLAN_STOP, \
                              ST_PLAN_IDLE, \
                              false, \
                              0, \
                              0, \
                              0, \
                              0}
    

    proj_lab12b.c:

    // initialize the watch window with maximum and minimum Iq reference
    gMotorVars.SpinTAC.VelCtlOutputMax_A = STVELCTL_getOutputMaximum(stObj->velCtlHandle);
    gMotorVars.SpinTAC.VelCtlOutputMin_A = STVELCTL_getOutputMinimum(stObj->velCtlHandle);
    // set the maximum and minimum values for Iq reference
    STVELCTL_setOutputMaximums(stObj->velCtlHandle, gMotorVars.SpinTAC.VelCtlOutputMax_A, gMotorVars.SpinTAC.VelCtlOutputMin_A);
    // get the Iq reference from the speed controller
    gMotorVars.IqRef_A = STVELCTL_getTorqueReference(stObj->velCtlHandle);

    If you make those code changes, then the variables gMotorVars.SpinTAC.VelCtlOutputMax_A, gMotorVars.SpinTAC.VelCtlOutputMin_A, and gMotorVars.IqRef_A will no longer be in the units of Amps.  They will be Amps scaled by USER_IQ_FULL_SCALE_CURRENT_A.  This will remove the build errors you are seeing.

  • Adam,
    Thanks for your reply. The errors is removed , but you said "the variables gMotorVars.SpinTAC.VelCtlOutputMax_A, gMotorVars.SpinTAC.VelCtlOutputMin_A, and gMotorVars.IqRef_A will no longer be in the units of Amps. They will be Amps scaled by USER_IQ_FULL_SCALE_CURRENT_A." and the value of USER_IQ_FULL_SCALE_CURRENT_A must be larger than the maximum current , so
    in user.h

    #define USER_IQ_FULL_SCALE_CURRENT_A (250.0) // 41.25 Example for drv8301_revd typical usage
    
    #define USER_ADC_FULL_SCALE_CURRENT_A (500.0) // 82.5 drv8301_revd current scaling

    but there is two Warnings, I modify the code like you said , Warnings removed .

  • Stefan,

    Your modifications look good to me. I would recommend that you set USER_IQ_FULL_SCALE_CURRENT_A so that it is greater than USER_MOTOR_MAX_CURRENT.
  • Adam,
    Though the errors and warnings are removed , but when I run the project , the motor doesn't move , and the current is too high that my PCB board is burn out , and ouch ! it break my little heart deeply...

  • Adam,
    Except the code you want me to modify , is there anything we miss ? 

  • Stefan,

    I'm not aware of other modifications that might be needed. There could be additional modifications in the rest of the software to make sure that there are no issues with numerical over/under flows. That would probably be the best place to start, going through the code and making sure that there aren't any other places where modifications are required.

    I think we would need to pull in the Ti expert for the underlying FOC. Unfortunately, due to the holiday you probably won't be able to get a response until after the new year.
  • ^_^ Merry Christmas !
  • Adam,
    As far as I'm concerned , there could be two possibility .
    1) My board cannot drive the motor with so big power , but the possibility is low , because, at least, it is feasible in theory.
    2)Maybe the program has something missed , or something wrong, so the program cannot give a correct drive signal and the MOSFET has been turn-on, in that condition, the motor just like a resistor and cause the current too high to burn my board . And I think there's a very real possibility.
    so if you are agree my analysis , could you give me some advise ?
  • Stefan,

    I don't have great advice to give.  My background is software.  There are some good hardware experts on this forum.  I know there have been some posts here about creating high power drives.  I've linked one below that might be some help:

    There could be another issue in the software, but I'm not sure what it could be.

  • Adam,
    thanks , I have been reading this post before,Brant is my partner ,it is the same issue on data type, I will try again and figure out what is wrong.
    But they talk about "gMotorVars.Id_kA = _IQmpy(CTRL_getId_in_pu(ctrlHandle), _IQ(USER_IQ_FULL_SCALE_CURRENT_A / 1000.0));" cannot be found in any labs , neither do I. Is this methods same as your suggest above ?