Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Look up table (http://www.chiefdelphi.com/forums/showthread.php?t=43585)

revolution1737 08-02-2006 21:15

Look up table
 
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?

DanDon 08-02-2006 21:25

Re: Look up table
 
Quote:

Originally Posted by revolution1737
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:

Code:

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:

Code:

sin[20];
Hope this helps,

revolution1737 09-02-2006 00:46

Re: Look up table
 
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

Re: Look up table
 
Quote:

Originally Posted by revolution1737
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

Re: Look up table
 
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?


All times are GMT -5. The time now is 01:36.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi