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.

How to use the sine table located in the IQMathTable?

Other Parts Discussed in Thread: CONTROLSUITE

Hello Guys,

Is there an example program in control suite that shows how to use the sine table from IQ Math Table?

What is the return type of this sine table? Is it the Global IQ or IQ30?

Please let me know.

  • Hi Prakash,

    The sine table is Q30. Its meant to be used by the IQNsin() in the IQMath Library in controlsuite. There are examples on using the library in there,

    C:\ti\controlSUITE\libs\math\IQmath\v160\examples
  • Hi Vishal,
    Thanks for the reply. So are you telling me that I cannot use the IQsinTable directly? I got the following code(somewhere in the net) and it worked, but I don't know if it is right to do so. Please check it and let me know.

    // In global section I declared this line :
    extern _iq IQsinTable[];

    // In main function I called the table as follows:
    iq_angle = _IQ(PI*0.5); // angle = 90 degree
    int_angle = _IQint(_IQmpy(iq_angle,_IQ(81.487331))); // 360 degree = 512(total number of entries in sin table),
    // from that I calculate the value for 90 degree
    x1 = _IQ30toIQ(IQsinTable[int_angle]); // changing from _IQ30 to global IQ

    and it works perfectly.

    Edit 1 : Also I would like to know how many execution cycles does the  _IQsinTable[] code need?

  • Hi Prakash,

    The above implementation is correct.

    Prakash Kumar Thulasi Kumar said:
    Edit 1 : Also I would like to know how many execution cycles does the  _IQsinTable[] code need?

    This you can calculate by yourself by toggling GPIO or Profile clock.

  • Hi Prakash,

    The table is basically 512 values of sine over 2*pi. If you are calculating sin(x), where x is some integer multiple of 2*pi/512 you get an exact value. the problem is when you dont have an integer multiple. Then you have to find the closes table value and then calculate the residual portion to get the correct value and that is what the IQNsin() does.