voelker 10 Posted December 13, 2011 Share Posted December 13, 2011 Hi all, for one of my project i need to use sin, cos, sqrt, atan2 functions from the math library. When i'am using atan2 function, everything goes fine, but when i try to use sin, cos or sqrt, the compiler says it cannot allocate the bss segement (ram). Does any of you know an alternative to the math library with a small footprint ? I have implemented sin, cos and sqrt my way, but cos and sin seems to suffer from precision problems (taylors series). Thanks Quote Link to post Share on other sites
bluehash 1,581 Posted December 13, 2011 Share Posted December 13, 2011 There is an optimized sine code in the StellarisWare library. Look in the /Utils folder. There will be a sine.c file Quote Link to post Share on other sites
voelker 10 Posted December 13, 2011 Author Share Posted December 13, 2011 Thanks for the link, i'am gonna check it. i'am using these functions to cimpute distance between too set of gps coordinates. The distance computation is fine for long distance but for short distance, the function underestimate the distance. For example for a 8.6km distance i get 5.6km. The point is that for a short distance like 600m i get 480m ... it seems that the error is not linear or happens for some specific values. This precision is sufficient for my application but i'd like to understand the problem. Quote Link to post Share on other sites
rockets4kids 204 Posted December 14, 2011 Share Posted December 14, 2011 Are you looking for a small RAM footprint, ROM, footprint, or CPU cycle footprint? Just how much precision do you need? In resource-limited MCUs, table-based lookups and approximation are commonly used to meet precision requirements with minimal resources. Quote Link to post Share on other sites
voelker 10 Posted December 14, 2011 Author Share Posted December 14, 2011 Hi, i have more cpu cycles and rom space than i need, so i'am looking for something that fits the value line ram. Quote Link to post Share on other sites
voelker 10 Posted December 14, 2011 Author Share Posted December 14, 2011 i found my problem, and the problem is ... me ! I used haversine function on angle in degree decimal-minute while it should take angle in decimal degree ... Everything is working fine and my implementation gives an error of ~10m compared to an implementation using math.h with double type. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.