CCS/DRV8305: wrong handover for Ls and Rs values

Prodigy 80 points

Replies: 4

Views: 37

Part Number: DRV8305

Tool/software: Code Composer Studio


I started to become familiar with an existing Firmware for a custom designed Motor driver (F28069M+DRV8305). Basicly the system works but I think there are a lot improvements possible.

First I started to check all user parameters. Thereby I found some wrong values. (But this is not part of my question ;) )

During debugging I saw that Ls an Rs have strange values:

The values are much higher than in the user.h file. Looks like an overflow?!

Furthermore I have following warning:

Can this be the problem? This is my struct:

typedef struct _MOTOR_Vars_t_
  bool Flag_enableSys;
  bool Flag_Run_Identify;
  bool Flag_MotorIdentified;
  bool Flag_MotorAligned;
  bool Flag_enableForceAngle;
  bool Flag_enableFieldWeakening;
  bool Flag_enableRsRecalc;
  bool Flag_enableUserParams;
  bool Flag_enableOffsetcalc;
  bool Flag_enablePowerWarp;

  unsigned int MotorAlign_Rampup_Ticks;
  unsigned long MotorAlign_Ticks;

  CTRL_State_e CtrlState;
  EST_State_e EstState;

  USER_ErrorCode_e UserErrorCode;

  CTRL_Version CtrlVersion;

  _iq IdRef_A;
  _iq IqRef_A;
  _iq StopSpeedRef_krpm;
  _iq SpeedRef_krpm;
  _iq SpeedTraj_krpm;
  _iq MaxAccel_krpmps;
  _iq MaxAccel_index_krpmps;
  _iq20 MaxJrk_krpmps2;
  _iq Speed_krpm;
  _iq SpeedQEP_krpm;
  _iq OverModulation;
  _iq RsOnLineCurrent_A;
  _iq SvgenMaxModulation_ticks;
  _iq Flux_Wb;
  _iq Torque_Nm;
  _iq I_Max_A;

    float_t MagnCurr_A;
  float_t Rr_Ohm;
  float_t Rs_Ohm;
  float_t RsOnLine_Ohm;
  float_t Lsd_H;
  float_t Lsq_H;
  float_t Flux_VpHz;

  _iq Kp_spd;
  _iq Ki_spd;

  _iq Kp_Idq;
  _iq Ki_Idq;

  _iq Vd;
  _iq Vq;
  _iq Vs;
  _iq VsRef;
  _iq VdcBus_kV;

  _iq Id_A;
  _iq Iq_A;
  _iq Is_A;

  MATH_vec3 I_bias;
  MATH_vec3 V_bias;

  ST_Vars_t SpinTAC;

  //float Axis_Offset_Ang;


With my eval-Kit and lab03a everthing looks fine. On our custom board we  use the FPU.  Maybe is there the source of the problem?


4 Replies

  • 1. It seems like you or your customer had changed the example code, please check and change the "MOTOR_Vars_INIT" accordingly if you added any variable in MOTOR_Vars_t struct.

    2. Make sure the current & voltage sensing signals are good for motor control.

    3. Set the appropriate identification variables (USER_MOTOR_RES_EST_CURRENT, USER_MOTOR_IND_EST_CURRENT, USER_MOTOR_MAX_CURRENT,  USER_MOTOR_FLUX_EST_FREQ_Hz) according to the motor specification.


  • In reply to Yanming Luo:


    1.  My fault was that I defined the  _iq MaxAccel_krpmps value higher than 127 (IQ24)

    2. Do you mean to run lab1b and lab1c or to check the signal at my hardware?. I´m a beginner in this subject.

    3. I will try this.  If i set the Flag  "Flag_enableRsRecalc"  to 1  is only Rs new calculated or both? Rs und Ls

  • In reply to Yanming Luo:

    After I set gMotorVars.Flag_Run_Identify to 1 the values Ls and Rs change immediately to this values. When I change the values im my user.h file the wrong values also change ?!

  • In reply to Yanming Luo:

    One more question:

    When I use the FPU I get an int32 value:

    //! \brief     Gets the stator resistance value in Ohms (\f$\Omega\f$).
    //! \param[in] handle  The estimator (EST) handle
    //! \return    The stator resistance value, Ohm
    #ifdef __TMS320C28XX_FPU32__
    extern int32_t EST_getRs_Ohm(EST_Handle handle);
    extern float_t EST_getRs_Ohm(EST_Handle handle);

    Inside th struct they are defined as float_t

     float_t MagnCurr_A;
      float_t Rr_Ohm;
      float_t Rs_Ohm;
      float_t RsOnLine_Ohm;
      float_t Lsd_H;
      float_t Lsq_H;
      float_t Flux_VpHz;

    I tried following things:

    //   get the stator resistance
    //  gMotorVars.Rs_Ohm=EST_getRs_Ohm(obj->estHandle);
      tmp = EST_getRs_Ohm(obj->estHandle);
      gMotorVars.Rs_Ohm = *((float_t *)&tmp);

    result: no errors, but program doesn´t work. Program get stuck  at some point.

    The same thing happens when I comment the whole line

    //  gMotorVars.Rs_Ohm=EST_getRs_Ohm(obj->estHandle);

    My questions:
    1. Is the reason that the motor works because "inside" InstaSpin the values for Rs an Ls are correct and only the handover to the gMotorVars.Rs value is wrong?
    2. Why I can´t comment a get-line inside void updateGlobalVariables_motor(CTRL_Handle handle)
    3. I read in another thread that all gMotorValues are read only. Is this correct?
    4. What can I do that I have the rigth values for Rs an Ls in my expressions?