View Full Version : Trigometric Functions
cibressus53
25-10-2004, 20:15
are there any libraries for mlab and control unit for trigometric functions?
Tom Bottiglieri
25-10-2004, 20:19
http://www.chiefdelphi.com/forums/showthread.php?t=26644
that might help you
Rickertsen2
25-10-2004, 20:27
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
Joe Ross
25-10-2004, 21:03
Nope. Write your own.
Yes there are: http://www.chiefdelphi.com/forums/showthread.php?threadid=26644
Anthony Kesich
25-10-2004, 21:49
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
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.
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.