Trigometric Functions

are there any libraries for mlab and control unit for trigometric functions?

that might help you

Nope. Write your own. Since calculating a Taylor/McLauren series or whatever on the fly with the PIC isn’t exactly practical there are several approaches

1.) Precomputed lookup tables. Fast to read from but eat alot of program space. If you are cramped for program space you can reduce the number of points in the table and use linear interpolation.

2.) CORDIC algorith. I’m lazy. Google it

3.)Parabolic approximation. a halfsin function can be approximated reasonably well using a parabola. All other trig functions can be derived from halfsine. This goes for lookup tables too. You only need to store half of a sin cycle

4.) calculatea series on the fly. We actually tested this and it worked reasonable well if you precomputer the factorials. I wouldn’t recommend it though. It is rather slow compared to the other approaches. We did it more to show that it could be done.

There are a few old threads on forums that discuss this topic. Again I’m lazy. Search for them yourself

Yes there are:

Even though using the taylor/McLauren Series is not that fast on a PIC, you are going to have enough power and time to run the standard C-library math functions unless you are doing a tremendous amount of processing and using all your interruputs. That and using the Math library is quick and easy. Granted, if you want to, you can use the above mentioned methoda, it just takes some work to set up. It may have just been my team, but we didn’t have any problem with lack of processing power last year.