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
What precision?
Integer or floating point or fixed point?
Optimize for speed or for footprint?
hi,
Precision: 0.0001.
fixed point.
optimize for speed.
Well, I dont know exactly about the precision but it should be like that. Can you pla guide me? i just want to know how to implement the sine or cosine table.
vivek
Is that the precision of the result, or the input to the table?
Do you want a pure table lookup, or can you interpolate between table entries?
Remember that a sinusoid is symmetrical - so you only need a quarter-cycle's worth of values in your table...
Actually, with a bit of extra work, 45 degrees is enough because of the symmetry between x and y :)
Anyway, if you select 91 entries between 0 and 90 degrees with each value scaled * 16384, you will get the following results:
If you do a direct lookup, truncating the angle to a whole degree, your worst error would be 0.0175.
If your angle is in 0.01 degree steps, and you do linear interpolation between two entries, i.e.
prox = ((100 - frac) * lut[angle] + (frac * lut[angle+1])) / (100 * 16384.);
then your greatest error would be about 0.000097. That is 10 times your requirement.
Without knowing the resolution of your angles and the real importance of your precision, I don't know if it would be advisable to create a larger LUT.
Just a note - if you do need fractional angles, then it is better to make that scaling factor 2^n. Using angle steps 1/2, 1/4, 1/8, ... degrees allows you to use shift instead of division.
hi
Well you are right. I need accuracy about 2 decimal after the point. Did anyone have idea about how to implement?
this table is for optimization of speed. So i think i need to look pure lookup table for cosine function.
What do you mean by "Need accuracy about 2 decimal after the point"?
Do you have an angle in degrees and the angle having two decimals, i.e. 0.00 to 359.99 degrees?
Or is your requirements that the answer from the sin lookup must be -1.00 to 1.00 with a maximum error of +/- 0.005?
I not only have an idea, I also suggested a specific solution. If you want maximum speed, i.e. single lookup without interpolation, you need a denser LUT than I suggested.
If you use linear interpolation, you can decrease the density of the LUT and for example store a lookup value for every 5 degrees.
My requirement is the sine angle is in degrees i.e. 0.00 degree to 359.99 degree
View all questions in Keil forum