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.

TMS320F28069F: CTRL_angleDelayComp() need to be changed for using fpu

Part Number: TMS320F28069F
Other Parts Discussed in Thread: MOTORWARE, CONTROLSUITE

Hi All, 

I have a question about following snippet, it seems to be implemented for IQmath, not FPU.

CTRL_angleDelayComp() in ctrl.h

  uint32_t angleMask = ((uint32_t)0xFFFFFFFF >> (32 - GLOBAL_Q));
  _iq angleTmp_pu;
  _iq angleComp_pu;

  // increment the angle
  angleTmp_pu = angleUncomp_pu + angleDeltaComp_pu;

  // mask the angle for wrap around
  // note: must account for the sign of the angle
  angleComp_pu = _IQabs(angleTmp_pu) & angleMask;

When I enabled IQmath_fpu32, I encountered following error.

"C:/ti/motorware/motorware_1_01_00_17/sw/modules/ctrl/src/32b/ctrl.h", line 2142: error #31: expression must have integral type

I think angleMask is used for removal of 8bit of MSB, but it is applicable for integer, not float value.

would you please let me know how to change this code for float ?

Best Regards,

Hae Ryong

  • Dear Motorware team,

    Would you please take a look into my question ?
    if there is something wrong with my analysis, please let me know.

    Thanks in advance.

    Best Regards,
    Hae Ryong
  • Hae Ryong,

    This function does not have native support for FPU32, you'll have to change the code. You may try adding an #ifdef directive for FPU32, and if it is defined, do not perform the angleMask assignment. Also, you won't perform the "& angleMask" operation. You instead will need to add a conditional statement to make sure that angleTmp_pu is between _IQ(-1.0) and _IQ(1.0), which is what the function of angleMask was.

    You may try something like this.

    Sean
  • Hi Sean,

    Thanks for your feedback.

    Would you please take a look at following snippet is OK for the intention ?

    #if MATH_TYPE == FLOAT_MATH
    if(angleComp_pu > _IQ(1.0)) angleComp_pu = _IQ(1.0);
    else if(angleComp_pu < _IQ(-1.0)) angleComp_pu = _IQ(-1.0);
    #else
    // mask the angle for wrap around
    // note: must account for the sign of the angle
    angleComp_pu = _IQabs(angleTmp_pu) & angleMask;
    #endif


    there is one more thing to ask.
    To enable FPU32, do I need to add following definition in IQmathLib.h ?
    #define MATH_TYPE FLOAT_MATH

    motorware lab example for FPU32 seems not use it.
    because there was no compile error which I mentioned above, with the lab example

    Best Regards,
    Hae Ryong
  • Hae Ryong,

    I believe you have the right idea with the if/else statement to limit the angleComp_pu value.

    For your second point, yes it is correct to define FLOAT_MATH. Please see some supporting documentation, such as page 25 of the IQMath Quickstart guide located here: C:\ti\controlSUITE\libs\math\IQmath\v160\doc\IQMath_Quickstart.pdf

    Sean
  • Hi Sean,

    I have tested my modified code, but it is not working.
    I have found that angleComp_pu is not initialized.

    would you please let me know what initial value should be used for it ?

    Best Regards,
    Hae Ryong
  • Dear TI Team,

    Would you please take a look at my inquiry ?
    It is hard to understand the intention of THE code, so I cannot convert it to use FPU32.

    Best Regards,
    Hae Ryong