Quantcast
Channel: MCS Electronics Forum
Viewing all articles
Browse latest Browse all 20599

BASCOM-AVR : Efficient arctangent approximation : REPLY

$
0
0
Hi Folks, here is an updated version. Finally I found some time for speed up: sin_cos in under 500 cycles (@ 12 iterations) :D ...But only for avr with hardware multiplier... Thinking about the massive need of -slow- shift operations I did a research for other cordic implementations and found an article on the German site >Mikrocontroller.net< by "Gjlayde": http://www.mikrocontroller.net/articles/AVR_Arithmetik/Sinus_und_Cosinus_%28CORDIC%29 It implements a sin and cos algorithm by use of fractional integer numbers as used by the AVR assembler instruction FMUL. Based on this I exchanged the shift operations by multiplications: i.E. N*2^-2 = N*(2^14/2^16). Also I fixed the iterations as constant There are some additional possibilities for speeding up: ****For pol_to_rec and rec_to_pol it would make sense to use a Vectscale which is is not Base10 (10000) but Base2 (i.e. 16384). Think Binary :-) The division then could exchanged by shifting. ***It would save some cycles if the normal and the invers cordic would be divided in to separate routines. Need more codespace, of course. Precision: With 12 iterations there is very good performance for all angles 2°..88°, good for 1° and 89° With 14 iterations there is very good performance for all angles 1°..89°. Only 0°..1° (sine) and 89°..90° cosine is critical. This could be improved by a dynamic angscale. There is still some work to do: cordic works only from -90° to +90°, so there has to be some quadrant calculations. I definitely has to stop at that point, because I've too much work to do. Maybe some other can clean up the code and put it into a lib. Cheers.

Viewing all articles
Browse latest Browse all 20599

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>