This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Look up Table for XC164CS

hello everyone,

I just want to know if someone has any idea about look up table technique for sine or cosine function using keil simulator. I need to implement it in to my progam. I just want some basic idea. or if someone has good material then let me know.

I am using fixed point dsp Xc164Cs

thank you
Vivek

Parents
  • Time to implement. Generate a table with the sin() value between 0, 5, 10, ... 90 degrees scaled with 16384. In total 19 entries.

    Write code to detect what quadrant you are in - needed for adjusting the sign of the result.

    Convert your angle to a value between 0 and 90 degrees (taking into account negative angles or angles above 360 degrees).

    Split angle into an integer part (selects the first entry of the LUT) and a fractional part.

    Use the example source line I showed to perform a linear interpolation.

    Return result (but remember that it is scaled by a factor 16384).

    But as I mentioned, using integer algorithms, it is a bit bad to having 0.01 degree resolution to the angle. It is better to have 1/128 degree steps, letting the angle [0..369) be represented by an integer 0..46079, i.e. 128*0 .. 128*360-1.

Reply
  • Time to implement. Generate a table with the sin() value between 0, 5, 10, ... 90 degrees scaled with 16384. In total 19 entries.

    Write code to detect what quadrant you are in - needed for adjusting the sign of the result.

    Convert your angle to a value between 0 and 90 degrees (taking into account negative angles or angles above 360 degrees).

    Split angle into an integer part (selects the first entry of the LUT) and a fractional part.

    Use the example source line I showed to perform a linear interpolation.

    Return result (but remember that it is scaled by a factor 16384).

    But as I mentioned, using integer algorithms, it is a bit bad to having 0.01 degree resolution to the angle. It is better to have 1/128 degree steps, letting the angle [0..369) be represented by an integer 0..46079, i.e. 128*0 .. 128*360-1.

Children
No data