Quick and dirty arctangent
Mike Green
Posts: 23,101
I'm starting to play with a Propellor Demo Board set on a BOE-BOT chassis with a PING bracket and HM55B compass mounted on the bracket. I seem to be having problems with downloading large Propellor programs (like with the Float32Full, Float32A, and FloatString objects), but I've come up with a little assembly routine to use the sine/cosine tables to estimate the arctangent of the -y/x value supplied by the compass. I'm sure there are all kinds of ways to improve it and I'll be working on that, but it avoids using the floating point routines. I'm attaching the archive for anyone who would like to try it or comment on it. The arctangent is monotonic over a single quadrant and I'm going to handle the signs of the sine/cosine and x/y differently so I can use a binary search over just one quadrant, then apply the signs and adjust the angle appropriately for the quadrant.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
There once was a lady named Bright
who traveled much faster than light
She departed one day in a relative way
and Returned on the Previous Night
Cheers,
Wannabe Ub3r Geek
For those interested, the whole test program is attached. It includes copies of the SPI routines from the BS2 object, a modified PING routine and a simple 3 servo driver in Spin that runs in a cog.