caclutate angle without using math.h lib functions

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

I am not sure if this is the place to post this question so let me know if I need to post it somewhere else.  I am interfacing an accelerometer with an 8k PSoC1 via i2c.  I need to cacluate a specific angle from the accelerometer data without using the <math.h> library.  I know the value of two sides and could use arctan to get that angle but when i include <math.h> I run out fo code space.  Is this a possibility?  If so how can I do this?

   


Thanks...

0 Likes
3 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

There are some approximations using pure integer arithmetic. have a look here, you can extract the sources from the pdf

   

   

http://www.freescale.com/files/sensors/doc/app_note/AN4248.pdf

   

 

Happy coding

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Some other possibilties -

   

 

   

    

   

          http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=3&ved=0CDkQFjAC&url=http%3A%2F%2Fwww.ga...

   

 

   

    

   

          http://www.dsprelated.com/showmessage/21872/1.php

   

 

   

Cordic and Chebychev also popular.

   

 

   

    

   

          http://www.mathworks.com/products/demos/fixedpt/arctangent/fixpt_atan2_demo.html

   

 

   

    

   

          http://emesystems.com/BS2mathC.htm

   

 

   

    

   

          http://www.numericana.com/answer/functions.htm#cheb

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

 this may help as well

   

http://www.ganssle.com/approx/approx.pdf

0 Likes