Quote:
|
Originally Posted by cibressus53
are there any libraries for mlab and control unit for trigometric functions?
|
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