TI中文支持网
TI专业的中文技术问题咨询交流网站

请问一下关于 TMS320F240 DSP-Solution for HighResolution Position with Sin/CosEncoders 文档反正切表问题

你好 请问一下   这个文档的第 37页开始 Q15_ATAN.INC 文档里面的 反正切表的生成方法  我想改一个 Q10格式的 

user6485843:

我不太明白 这个表是怎么生成的   方便告诉我嘛 谢谢

Susan Yang:

我会在确认后给您回复,谢谢

Susan Yang:

回复 user6485843:

请您参考下面链接内的回复

e2e.ti.com/…/3530527

thank you for your interest in the Application Report SPRA496.

I wrote the Assembly code only for Q15 fractional numbers. The function "int q15p_atan(int)" returns the angle scaled by PI in the range from 0 to PI/4. Hence the return value 0x000 = 0.0 (Q15) equals 0 degree and 0x2000 = 0.25 (Q15) equals PI/4 (45 degree). The Q15 gives the highest possible resolution, as also the input argument is scaled as Q15 from 0 to 0x7FFF (0.999).

Unfortunately I won't be able to rewrite the TMS320F240 Assembly code to Q10 format anymore.

However you may change yourself. Then you may consider the product shift mode SPM.

The code I used is written for SPM=1 (see assembly instruction) to handle Q15xQ15=Q30. With the automatic product shift mode (SPM 1) the product is automatically left shifted by 1 bit = Q31 so the resulting Q15 number is in the upper 16-bit of the 32-bit ACC (store ACCH).

When you go for Q10 then a multiplication product gives you Q10xQ10=Q20. To get a Q10 equivalent result in the upper 16-bit of the ACC you need an product shift mode by 11. I think SPM 11 is not supported by the F240 DSP core, but please check. Another option to get a Q10 results: You can instead right shift the 32-bit intermediate results by 10 so the Q10 scaled product is in the lower 16-bit of the ACC. In that case SPM needs to be 0. But please be aware you may get overflow as Q10xQ10 can exceed the Q10 range of +/-32.0.

Susan Yang:

回复 user6485843:

若是您有更进一步的问题,请在之前的英文贴内继续跟帖回复

e2e.ti.com/…/3530527

user6485843:

回复 Susan Yang:

Hello:
Thank you for your answers,
1 >.
I don't know if that's right
The 0-0.99 Q15 format corresponds to 0-32768
The 0-0.25 Q15 format corresponds to the 0-pi / 4-> 0-8192 45 degree subdivision into 128 pieces
45/128 = 0.3515625 degree
table degree[129] =
{0,0.3515625,…..44.6484375,45
}
2 >.
Here is SPRA496 document Q15_ATAN
table[129]={0,81,163,244,326,407,489,570,651,732,813,894,975,1056,1136,1217,1297,1377,1457,1537,1617,1696,1775,1854,1933,2012,2090,2168,2246,2324,2401,2478,2555,2632,2708,2784,2860,2935,3010,3085,3159,3233,3307,3380,3453,3526,3599,3670,3742,3813,3884,3955,4025,4095,4164,4233,4302,4370,4438,4505,4572,4639,4705,4771,4836,4901,4966,5030,5094,5157,5220,5282,5344,5406,5467,5528,5589,5649,5708,5768,5826,5885,5943,6000,6058,6114,6171,6227,6282,6337,6392,6446,6500,6554,6607,6660,6712,6764,6815,6867,6917,6968,7018,7068,7117,7166,7214,7262,7310,7358,7405,7451,7498,7544,7589,7635,7679,7724,7768,7812,7856,7899,7942,7984,8026,8068,8110,8151,8192,
}
I don't understand table[1] = 81?table[1] = 163 ?
table[127] = 8151?
What is the generation pattern of the above table elements?
How is this part of the value generated

thank you

Susan Yang:

回复 user6485843:

已经在下面链接内回复了,您可以跟踪一下

e2e.ti.com/…/3532481

Susan Yang:

回复 user6485843:

the atan(x), where x can be from 0 to 1.0, is a nonlinear function and as as such the lookup table is nonlinear too. The lookup table is basically an 8-bit approximation of the atan(x) function. The argument x is right shifted to get an 8-bit equivalent pointer to the corresponding approximate angle value in the lookup table.

Example:

atan(0): 0 is converted to 0 and points to the first element in the lookup table: 0

atan(1.0): 1.0 is converted to 128 and points to the last (129) element in the lookup table: 8192=0.25 Q15 (equals PI*0.25=45deg)

atan(0.5): 0.5 is converted to 64 and points to the 65 element in the lookup table: 4836=0.149 Q15 (equals P*0.1475= 26.56deg)

atan(0.25): 0.25 is converted to 32 and points to the 33 element in the lookup table: 2555=0.077 Q15 (equals P*0.077= 14.03deg)

and so on.

赞(0)
未经允许不得转载:TI中文支持网 » 请问一下关于 TMS320F240 DSP-Solution for HighResolution Position with Sin/CosEncoders 文档反正切表问题
分享到: 更多 (0)