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.

CCS/TMS320F28379S: C2000 Position Manager SinCos Library

Part Number: TMS320F28379S

Tool/software: Code Composer Studio

Hi,

i´m using Position Manager SinCos Library on TMS320F28379S with Float Math option. When i watch the defined SINCOS data structure from the PM Sincos library (mySincos) i get some variables in the structure which have the value Nan "Not a Number"? And some others are marked with (DEN).

Have you an idea, where this problem can come from? The qep stucture is counting an also the ftheta is counting when i rotate the motor shaft.

  • Hi,

    The sincos library uses IQ math to manipulate fixed-point data. You have to build it with the IQ math library in IQ_MATH mode. The variables above which show as either de-normalized or NaN are all _IQ15 variables. They need to have that format rather than float. The "itheta" result will also be wrong.

    Can you re-build your project with the MATH_TYPE set to IQ_MATH?

    Regards,

    Richard
  • Hi Richard,

    we are using FLOAT like in the example IDDK_PM_Servo_F2837x-v2 and have already some own code using FLAOT.

    Would the SinCos library give the right value on the variable "ftheta" with acitve FLOAT?

    Regards,
    Stefan
  • Hi Stefan,

    Unfortunately not. The sincos library relies on IQ15 to format some of the variables. There is an integer part of the result derived from counting complete sincos cycles, and a fractional part computed from the sin/cos ratio. The integer part will be taken from the QEP when the shaft speed is high to ensure no cycles are missed, so it must be an integer. These occupy the I & Q parts of "itheta" respectively. The floating point "ftheta" is an IQ15 to float conversion of "itheta".

    Sorry, but I think you will have to use IQ_MATH to get the sincos part working.

    Regards,

    Richard
  • Hi Richard,

    would it work if i use datatype long in the SINCOS datastructure for these variables (e.g. sinoffs, cosoffs, singain, ...) and use FLAOT_MATH in the IQmathLib.h?
    The PM_sincos.lib is already precompiled with IQ_MATH, or?

    In general can is use the position manager library use with set FLAOT_MATH in the IQmathLib.h?

    Regards,
    Stefan
  • Hi Stefan,

    As soon as you define MATH_TYPE as FLOAT_MATH the IQmath library functions are no longer accessible to the code. For example, an _IQ15mpy would be replaced with a floating point multiplication, producing a floating point result, so the code won't work. Those IQ functions are needed to maintain the right numeric format and they're used throughout the sincos library code.

    I appreciate the problem, but I'm not seeing an easy solution at the moment.

    Regards,

    Richard
  • Hi Richard,

    ok i understand. But can you tell me if the endat22 library from the position manager library will run with IQ_Math?

    Thank you, regards
    Stefan
  • Stefan,

    endat22 library is float type, not using IQ math.

    -Bharathi

  • Hi Barathi, Hi Richard,

    we have one project and want to use SinCos library, Endat library and resolver library.
    How can we handel this in our software? What is the right value to IQmathLib.h, IQ_MATH or FLOAT?

    Regards,
    Stefan
  • Hi Stefan,

    The EnDat library is float only - no reference to IQmath is necessary. The resolver library is supplied in both fixed point (IQmath) and floating point forms, so if you use the latter, again no reference to IQmath is required.

    In this way, only the sincos library need refer to IQmath and you can stay with the MATH_TYPE = IQ_MATH setting it requires.

    Would this work?

    Regards,

    Richard
  • Thank you, now its all clear to me.