Mar 5, 2012 #1 D doucheful80 Junior Member level 1 Joined Dec 14, 2011 Messages 15 Helped 0 Reputation 0 Reaction score 0 Trophy points 1,281 Activity points 1,414 Hi, Is there an assembly code for arctan..or tan-1 that can be used in PIC18F4520 or others. Im doing a robot that follow an x,y coordinate..so i need to calculate the angle from the input x,y to turn the robot's wheels Thanks a lot!
Hi, Is there an assembly code for arctan..or tan-1 that can be used in PIC18F4520 or others. Im doing a robot that follow an x,y coordinate..so i need to calculate the angle from the input x,y to turn the robot's wheels Thanks a lot!
Mar 6, 2012 #2 D doraemon Super Moderator Staff member Joined Jun 21, 2009 Messages 1,257 Helped 292 Reputation 592 Reaction score 305 Trophy points 1,363 Location Japan Activity points 12,979 Hello! Don't compute! Use a lookup table. It's faster and accurate enough for that kind of application. Dora.
Hello! Don't compute! Use a lookup table. It's faster and accurate enough for that kind of application. Dora.
Mar 7, 2012 #3 bigdogguru Administrator Joined Mar 12, 2010 Messages 9,821 Helped 2,350 Reputation 4,694 Reaction score 2,272 Trophy points 1,413 Location Southwest, USA Activity points 62,383 I would agree with Dora. A lookup table is usually preferable to calculating an inverse trigonometric or transcendental function on the fly. The following a discussion of lookup tables in PIC Assembly: Lookup Table faster? However, if you absolutely must calculate arcTAN on the fly, the a CORDIC Algorithm would probably be my recommendation. Arctan(x) using CORDIC You might also find the following algorithm of interest: XY vector to integer degree fast algorithm BigDog
I would agree with Dora. A lookup table is usually preferable to calculating an inverse trigonometric or transcendental function on the fly. The following a discussion of lookup tables in PIC Assembly: Lookup Table faster? However, if you absolutely must calculate arcTAN on the fly, the a CORDIC Algorithm would probably be my recommendation. Arctan(x) using CORDIC You might also find the following algorithm of interest: XY vector to integer degree fast algorithm BigDog