View Full Version : Look up table
revolution1737
08-02-2006, 21:15
I am programming an omnidrive system and I decided to make look up tables instead of sin and square root functions. Can somebody point me in the right direction as I have never done something like this?
I am programming an omnidrive system and I decided to make look up tables instead of sin and square root functions. Can somebody point me in the right direction as I have never done something like this?
Hi, well, basically, you would have something like:
rom const float sin[]={(here, list values of sin, from 1-90, with values separated by commas)};
and then, you would get the sin of the angle, lets say theta==20, by calling:
sin[20];
Hope this helps,
revolution1737
09-02-2006, 00:46
Thanks, thats exactly what I wanted. I only have one question. I read in a post by kevin that you could post this table in the eeprom. I was wondering if I should try to put it there or where I call my function.
Kevin Watson
09-02-2006, 00:50
I am programming an omnidrive system and I decided to make look up tables instead of sin and square root functions. Can somebody point me in the right direction as I have never done something like this?I have some code that I started last Fall that might be of some use. One application, trig_table.c/.h, is only run once to create a semi-permanent table in EEPROM. The second application, trig.c/.h, demonstrates how to lookup a value within the table. The code is designed to work with the EEPROM code on my website: http://kevin.org/frc. I haven't written the documentation yet and don't know when I'll have the time, so if you have questions, feel free to ask 'em here. You can find the code here: http://kevin.org/frc/frc_trig.zip.
-Kevin
revolution1737
09-02-2006, 01:11
Speak of the devil -- LOL :D
Thanks, you just saved me a day of programming. If it's all right I may PM you tomorrow if I come across any glitches.
Thanks
ps I was looking through the code in notepad and I see that there are 8 and 16 bit functions of sin. Are these what I call and if so do I need to call them both?
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.