• Not Answered

sine function with ezdsp f28335

hi all,

i am newbie in dsp,i use ezdsp 28335.
i have few questions.
the first question:

I use ezdsp f28335 floating point to controll AC motor.so i want to use the sine function
defined in "math.h".i have included "the math.h" but the ccs 3.3 says:

......
<Linking>

 undefined  first referenced
  symbol        in file
 ---------  ----------------
 _Cos       D:\\Programme\\MyProjects\\RL_3phase\\Debug\\park_sinus.obj
 _Sin       D:\\Programme\\MyProjects\\RL_3phase\\Debug\\park_sinus.obj
 _park_calc D:\\Programme\\MyProjects\\RL_3phase\\Debug\\RL_3phase.obj
.....

what should i do?should i use sine lookup table?which way is better?

the second question:
like matlab operation, when i delare variable so :     float32 : a,x,y,z;

then can i do without IQmath so ??:                             z = a*x + y; also like in matlab?

the third question:
what does the rts2800_fpu32_eh library do?

 

thanks!:):):)

 

11 Replies

  • tequila

    hi all,

    i am newbie in dsp,i use ezdsp 28335.
    i have few questions.
    the first question:

    I use ezdsp f28335 floating point to controll AC motor.so i want to use the sine function
    defined in "math.h".i have included "the math.h" but the ccs 3.3 says:

    ......
    <Linking>

     undefined  first referenced
      symbol        in file
     ---------  ----------------
     _Cos       D:\\Programme\\MyProjects\\RL_3phase\\Debug\\park_sinus.obj
     _Sin       D:\\Programme\\MyProjects\\RL_3phase\\Debug\\park_sinus.obj
     _park_calc D:\\Programme\\MyProjects\\RL_3phase\\Debug\\RL_3phase.obj
    .....

    what should i do?should i use sine lookup table?which way is better?

    This looks as if you have declared Cos() and Sin() (with capital first letter) and park_calc() but haven't defined them.

    I'd suggest using the functions cos() and sin() from the standard library. They are declared in math.h.

    With an FPU available I woudn't want to use a lookup table.

    tequila

    the second question:
    like matlab operation, when i delare variable so :     float32 : a,x,y,z;

    then can i do without IQmath so ??:                             z = a*x + y; also like in matlab?

    I don't know whether I understand your question...

    The following can be done in C:

    float a, x, y, z;

    /* initilize a, x, y, z with meaningful values */

    z = a*x + y;

    Of course, a, x, y, z are scalars while in matlab vectors or matrices are possible.

    tequila
    the third question:
    what does the rts2800_fpu32_eh library do?

    That's the standard library (which contains, among other things, the implementation of sin() and cos()).

    I don't know, what _eh stands for (in my application I use rts2800_fpu32).

     

    Johannes

     

  • In reply to Johannes L.:

    thanks Johannes :-)

    Johannes

    This looks as if you have declared Cos() and Sin() (with capital first letter) and park_calc() but haven't defined them.

    I'd suggest using the functions cos() and sin() from the standard library. They are declared in math.h.

    With an FPU available I woudn't want to use a lookup table.

    yes i want to use functions cos() and sin() from the standard library too,but how? so i have configured in project-option:

    linker:

    -x -i"C:\CCStudio_v3.3\C2000\cgtools\lib"

    -l"rts2800_fpu32.lib"

    compiler:

    -i"E:\Programme\MyProjects\RL_3phase\DSP2833x_headers\include"

    -i"E:\Programme\MyProjects\RL_3phase\DSP2833x_common\include"

    -i"C:\CCStudio_v3.3\C2400\cgtools\include"  /* math.h in this*/

    and in prroject management window : in "labraries" folder i have added" rts2800_fpu32.lib".

    but ccs says the same error message :(

    Johannes

    I don't know whether I understand your question...

    The following can be done in C:

    float a, x, y, z;

    /* initilize a, x, y, z with meaningful values */

    z = a*x + y;

    i think with ploating point DSP can i use oparations such as multiplication, addition,division..without IQmath library?

    tequila

     

  • In reply to tequila:

    tequila
    -x -i"C:\CCStudio_v3.3\C2000\cgtools\lib"

    tequila
    -i"C:\CCStudio_v3.3\C2400\cgtools\include"  /* math.h in this*/

    I'm not sure about this but I think your include search path and link libraries should match, i.e. use the C2000 one (C2400 is not a floating point DSC).  Also note that if you upgrade the code generation tool in another directory, you should point to that directory instead.  The path in your example is for the default code generation tools location.

    I myself installed the newest code generation tools version in C:\CCStudio_v3.3\C2000\v5.1.2 (instead of the default location of c:\program files\... because CCS export to makefile does not like spaces in the path).

     

    FYI, I found out in SPRUEO2A that the difference between the rts2800_fpu32.lib and rts2800_fpu32_eh.lib is that the _eh version includes exception handling code for C++ exceptions.  I think that if you do not use throw, catch, you do not require to use the _eh library.

    Regards,

     

  • In reply to HTrudel:

    thanks u,

    i have upgraded to Code Generation Tools 5.1.0 but not better.

    linker:

    -x -i"C:\Programme\C2000 Code Generation Tools 5.1.0\lib"

    -l"rts2800_fpu32.lib"

    compiler

    -i"H:\Hoang\DSP\MyProjects\RL_3phase\DSP2833x_headers\include"

    -i"H:\Hoang\DSP\MyProjects\RL_3phase\DSP2833x_common\include"

    -i"C:\Programme\C2000 Code Generation Tools 5.1.0\include"  /*math.h in this*/

    in source code: ipark_sinus.c

    #include "ipark_sinus.h"
    #include <math.h>

    void ipark_sim_calc(IPARK_SIM *v)
    {   
          v->Alpha = v->Ds*Cos(v->Angle) - v->Qs*Sin(v->Angle);     /* line 13 in warning message*/
         v->Beta = v->Qs*Cos(v->Angle) + v->Ds*Sin(v->Angle); 
    }

    but the same error:

    ccs says:

    ..................................

      "ipark_sinus.c", line 13: warning: function declared implicitly

    [Linking...] "C:\Programme\C2000 Code Generation Tools 5.1.0\bin\cl2000" -@"Debug.lkf"
    <Linking>

     undefined first referenced                                            
      symbol       in file                                                 
     --------- ----------------                                            
     _Cos      H:\\Hoang\\DSP\\MyProjects\\RL_3phase\\Debug\\ipark_sinus.obj
     _Sin      H:\\Hoang\\DSP\\MyProjects\\RL_3phase\\Debug\\ipark_sinus.obj

    error: unresolved symbols remain
    error: errors encountered during linking; "./Debug/RL_3phase.out" not built

  • In reply to tequila:

    tequila

    void ipark_sim_calc(IPARK_SIM *v)
    {   
          v->Alpha = v->Ds*Cos(v->Angle) - v->Qs*Sin(v->Angle);     /* line 13 in warning message*/
         v->Beta = v->Qs*Cos(v->Angle) + v->Ds*Sin(v->Angle); 
    }

     

    I thought it was clear from my first reply that the standard library Sine and Cosine functions are spelled sin() and cos() with a lower case first letter.

    Johannes

     

  • In reply to tequila:

    I dont know anything about what you're trying to compute it looks like a park function.  So you should take a look at how TI do it in SPRC178 (http://focus.ti.com/docs/toolsw/folders/print/sprc178.html).

    Install the code at the default location, then take a look at the code located in this folder:  C:\tidcs\DMC\c28\v32x\lib\dmclib\cfloat\src (if you installed at the default location).  The cfloat directory contains all the floating point versions of standard motor control functions and should compile and work fine with the F28335.

    Documentation is also included in the following directory C:\tidcs\DMC\c28\v32x\lib\doc.

    BTW, the error message you get means your ipark_sinus.obj file make a reference to a _Cos (or _Sin) function that is not linked to your project.  Either you need to add the source file which contains the cos and sinus function to your project or link to a library that contains them.  The functions sin and cos contained in rts2800_fpu32.lib are respectively called sin() and cos().  The c language is CaSe SeNsItIvE ;)

    Hope this helps...

    Regards,

  • In reply to HTrudel:

    oh noooooooo mannnnn:D::D:D:D

     

    jappp,  that was my stupid mistake[:'(]

    thank  u  very much :-)

  • In reply to Johannes L.:

    Hi,

    I've downloaded the function generator library nut don't really know how to use it with the code composer. I'm trying to generate a sine-triangle pwm but stuck with the coding. Are there any sample codes available for doing this? Can you suggest an algorithm that i can follow to get this  done?

    Here's what i'm trying to do:

    How can i implement this with my dsp (im using the ezdsp tms320f28335) ?

     

     

     

  • In reply to HTrudel:

    Hi all,

    I tried using the sine function with F28335, and the result is not what I'm expecting. I have included the rts2800_fpu32.lib, and math.h in the project, but still not working. Any suggestions?

    Thanks,

    Tim

  • In reply to Shoaib Hussain:

    I think use for this case, a sine function of "math.h" and HRPwm module, (Example Sine = 60hz, Pwm to 40khz fixed) when you have a request of interrup of pwm you can read a value of sine signal, and this value is the duty cycle of pwm signal.  Sorry by my english... i'm spanish...