does anybody know the trigonometry code? is there a math.h file in mplab?

im not sure but did you try
at the top

Yes, there is a math.h. However, use it with caution, the RC is notorious for bogging down on complex mathematics, especially floating point operations. A good workaround is the trig lookup tables in stored in the microcontroller’s eeprom, which Kevin Watson has already written code to do. (linked to here)

the only problem is that kevin’s code only does sine and cosine. we need inverse tangent, though. any suggestions? and does anyone have the functions created to do this?

there used to be some code floating around for it that was develop by a team a few years back to be able to do floating point math…kinda…ill see if i can find it again, or maybe some nice person will post a link

[EDIT] found it [/EDIT]

hope it helps…i don’t like to mess with trig on this hardware, but this made life a little easier…

thank you thank you thank you…thats EXACTLY whal i was looking for!!!

You can also approximation trig functions using a finite number of terms from the Taylor series.

For instance, arctan(x) is approximately equal to X - X^3/3 + X^5/5 - X^7/7
When -1<X<1

I’m not a coder, so I don’t know what you’re trying to do, but from what I do understand about code, a Taylor series approximation should be fairly easy to implement.

Just to elaborate for those who haven’t had second semester Calculus (BC Calc), a Taylor series is a mathematical construct that consists of a sequence of terms (often infinitely long), the sum of which approaches, know as converging at, a value equal to the value of the function used to generate the series. Taylor series are “centered” at a value and the points for which they converge to the correct number surround this value, in the above example, the series is centered at x=0 and the Taylor series converges from -1<x<1. Anyway, Taylor series allow you to use relatively simple polynomials to calculate rather difficult problems, like sin(.3245212432) to almost degree of accuracy that you desire, simply by varying the number of terms. This is actually how your calculator calculates trig functions, as it is rather hard to do straight up.