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.

IQmath from F28027 to F28069

Other Parts Discussed in Thread: TMS320F28027, TMS320F28069, MOTORWARE

Hello. I have working program for vector control on TMS320F28027 and i want convert all calculations on TMS320F28069.

Simple code:

Asin=_IQ19sin(_IQ19(6.28)); Acos=_IQ19cos(_IQ19(6.28)); Asqrt=_IQ19sqrt(_IQ19(4)); Ampy=_IQ19mpy(_IQ19(10),_IQ19(2)); Adiv=_IQ19div(_IQ19(10),_IQ19(2));

works on F28027 :sin(6.28)=-0.0032, Asqrt=5 etc...

but when i placed it to F28069 i was very surprised:

Asin=_IQ19sin(2*pi)=-0.7825889587

Acos=_IQ19cos(2*pi)=1.102172852

Asqrt=_IQ19sqrt(4)=-508.0003605;!!!!!

etc. Only _IQ19mpy works...

What I did wrong?My actions:

1. added iqmathlib.h

2. added "rts2800_fpu32.lib"

3. added "IQmath_fpu32.lib"

4. added "rts2800_fpu32_fast_supplement.lib"

5. 28069.cmd file:

FPUTABLES : origin = 0x3FD860, length = 0x0006A0 /* FPU Tables in Boot ROM */
IQTABLES : origin = 0x3FDF00, length = 0x000B50 /* IQ Math Tables in Boot ROM */
IQTABLES2 : origin = 0x3FEA50, length = 0x00008C /* IQ Math Tables in Boot ROM */
IQTABLES3 : origin = 0x3FEADC, length = 0x0000AA /* IQ Math Tables in Boot ROM */

/* Allocate IQ math areas: */
IQmath : > FLASHA, PAGE = 0 /* Math Code */
IQmathTables : > IQTABLES, PAGE = 0, TYPE = NOLOAD

/* Allocate FPU math areas: */
FPUmathTables : > FPUTABLES, PAGE = 0, TYPE = NOLOAD

6. in iqmathlib.h strings:

#define FLOAT_MATH 1
#define IQ_MATH 0

#ifndef MATH_TYPE
#define MATH_TYPE IQ_MATH
#endif

7. Compiler opt:

-v28 -ml -mt --cla_support=cla0 --float_support=fpu32 --vcu_support=vcu0 

  • Hi,

    IF you wish to keep the IQMath library in your project but use floating point arguments you need to set MATH_TYPE to FLOAT_MATH in the IQmathLib.h header file. If you left it to IQ_MATH, it will expect all the arguments to be fixedpoint and scaled correctly.

    By doing _IQ19sqrt(4) you are trying to do _IQ19sqrt(0x00000004), but IQ19sqrt expects its argument to be in the IQ19 format. So,
    _IQ19sqrt(_IQ19(4)) you are effectively casting the argument 4 to IQ19 i.e. 4 * 2^19 = 2097152 and then calling the IQ19sqrt() on it. If you skip the typecast you get the wrong answer.

    Similarly, _IQ19cos(_IQ19(6.28)) is actually _IQ19cos( floor(6.28 x 2^19)) or _IQ19cos(3292528).
  • but i did it 

    for example
    Asqrt=_IQ19sqrt(_IQ19(4))
    Result: -508.0003605

    i trying work with 28069 using only fixed math.

    added to iqmathlib.h

    #define   MATH_TYPE      IQ_MATH

    changed

    #define FLOAT_MATH 0 /
    #define IQ_MATH 1

    ---without changes...

    I use IQmath_fpu32.lib. May be a problem with this? I treed built with IQmath.lib, but was a lot of errors:

    file "../IQmath.lib<IQ19cos.obj>" specifies ISA revision "C2800", which Vector_28069 C/C++ Problem
    
    Description Resource Path Location Type
    file "../IQmath.lib<IQ19div.obj>" specifies ISA revision "C2800", which Vector_28069 C/C++ Problem
    
    etc

    May be i must use IQmath.lib?

  • You dont have to change the values of FLOAT_MATH and IQ_MATH, you only have to change the math type

    #define FLOAT_MATH 1
    #define IQ_MATH 0
    
    #ifndef MATH_TYPE
    #define MATH_TYPE FLOAT_MATH
    #endif

    Now, it looks like you have --fpu_support=fpu32 turned on in your project settings, which is why you are getting the error of conflicting ISAs (Instruction Set Architecture). Use IQmath_fpu32.lib instead of IQmath.lib and that error goes away, and everything should work. 

  • Let me ask the question differently. I have a project that works with a fixed point. I want to transfer the project to another controller (TMS2802x to TMS2806x). And wish he also worked with a fixed point, not floating. What steps should I make? My current actions:
    1, add IQmathlib.h
    2. add IQmath.lib
    3. change -fpu_support=softlib. Results:
    a) _IQ19sin(0.5236)=-0.9569416046, but sin(pi/6)=0.5
    b)_IQ19sqrt(5.3)=-508.0003605, but sqrt(5.3)=+2.3.What am i doing wrong?
  • Ok, do steps 1 and 2, but not 3. You want to turn off any fpu_support. If you want to work in fixed point set MATH_TYPE to IQ_MATH

  • IQmath usage problem on F28069M

     

    Now, I am working on F28069M and want to implement FOC for motor control.

    When using math functions as below, the result seems abnormal.

    Simple code:

        x2 = _IQ29(0.25*pi);                 //pi = 3.1415

        alpha = _IQ29sin(x2);

        beta = _IQ29toF(alpha);

     

    the result is below after running it:

    x2 = 421657408

    alpha = -473477883

    beta = -0.8819212

     

    Obviously the result of alpha is wrong.

    And I try function of _IQ29cos(), the result is still wrong. But other functions (such as _IQ29tan())are correct.

    Following is my setting:

     

    1. added iqmathlib.h

    2. added "rts2800_fpu32.lib"

    3. added "IQmath_fpu32.lib"

    4. added "rts2800_fpu32_fast_supplement.lib"

    5. #define MATH_TYPE IQ_MATH

    6. Compiler opt:

    -v28 -ml -mt --cla_support=cla0 --float_support=fpu32 --vcu_support=vcu0

     

    Could you help me support on this issue? Looking forward to your reply. Thank you.

  • Hi,

    It sounds like the sine table is not in the right place. Can you check the address of the IQTable in the linker command file and match them up to what is provided in the F28069 TRM

    Its in chapter 2, here is a snippet

  • Actually, since you have an instaspin part the IQTABLES are located at

       IQTABLES    : origin = 0x3FDC30, length = 0x000B50    /* IQ Math Tables in Boot ROM */
       IQTABLES2   : origin = 0x3FE780, length = 0x00008C    /* IQ Math Tables in Boot ROM */
       IQTABLES3   : origin = 0x3FE80C, length = 0x0000AA	 /* IQ Math Tables in Boot ROM */

    You can get the right linker command files from motorware (C:\ti\motorware\motorware_1_01_00_16\sw\ide\ccs\cmd\f2806x)