|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Lookup table generation tool
EDIT: I had earlier attached a .xls file, but I just tried to open it and got garbly-gook. Here it is zipped up; this should work better. Also, In the example I've attached, it's just a linear transformation (y=x) and is basically useless as is. But you can change the spreadsheet formulas to generate whatever lookup table you like.
If you've been generating lookup tables for your program, you know that it's not much fun to have to manually type all of the raw values into your code. I generate all of my lookup tables in Excel, and I wrote this Excel macro to export the data to a text file so that it's much easier to just cut and paste the lookup table declarations from the text file into the C code. Enable macros when you open up the .xls file, and use the Excel spreadsheet/math functions to create your lookup table. Then just specify the filename and hit the Export button. If you want to customize the VBA code for the macro, from Excel just go to View-Toolbars-Visual Basic and then click on the Visual Basic Editor button. The VBA code is pretty self-explanatory. Maybe this will save you a few minutes of tedious typing... EDIT: I had earlier attached a .xls file, but I just tried to open it and got garbly-gook. Here it is zipped up; this should work better. Also, In the example I've attached, it's just a linear transformation (y=x) and is basically useless as is. But you can change the spreadsheet formulas to generate whatever lookup table you like. Last edited by WillyC : 30-01-2004 at 17:06. Reason: .xls file viewing problem |
|
#2
|
||||
|
||||
|
Re: Lookup table generation tool
If you use a lot of values it can be easy to write a PERL script to generate the c file for you.
|
|
#3
|
||||
|
||||
|
Re: Lookup table generation tool
Quote:
|
|
#4
|
||||
|
||||
|
Re: Lookup table generation tool
Well, you can plot graphs of your data in Perl, you just have to know what you are doing
Besides, who doesn't love a command line? Well, to do it in Perl is rather easy, and very customizable ... I'm sure ya'll can figure it out! Here's an example, sans formatting (e.g., float lookup_table[], etc.).Code:
use warnings;
use strict;
use Math::Trig;
open (OUT, ">your_file.txt") or die "No go!";
for (0..90) {
print OUT sin($_); print OUT ", " unless $_ == 89;
}
Last edited by mtrawls : 31-01-2004 at 20:37. |
|
#5
|
||||
|
||||
|
Re: Lookup table generation tool
Hey ... I like this!
Beware though ... you may need to manually remove decimal values from the generated tables. Also, you need to ensure that the values that you generate are under 256 (unless you change how the array is defined.) |
|
#6
|
||||
|
||||
|
Re: Lookup table generation tool
Quote:
Thanks Kevin, hopefully it helps. I like excel because you can change formatting, copy formulas etc really easily. I have set both of the data columns to show 0 decimal places, so you shouldn't have to manually edit any numbers. You can also use the Round() worksheet function to specify how many decimal places to use. |
|
#7
|
||||
|
||||
|
Re: Lookup table generation tool
Quote:
|
|
#8
|
||||
|
||||
|
Re: Lookup table generation tool
Quote:
|
|
#9
|
||||
|
||||
|
Re: Lookup table generation tool
Quote:
|
|
#10
|
|||
|
|||
|
Re: Lookup table generation tool
i cant get this to work. I input all the values i want.. then click on export. It brings up vb code windows. It also gives me a error that says macros cannot be used in this project. I have tried everything i know about excel (very little) to get this to work. What should i do?
|
|
#11
|
||||
|
||||
|
Re: Lookup table generation tool
Quote:
Excel has a security setting that disables all macros, and I think this is the problem. Within Excel, go to Tools > Macro > Secuity and set the check box to 'Medium'. Then close Excel and re-open it. Now it should prompt you and you should select 'Enable Macros'. That should do it. If not let me know... ![]() |
|
#12
|
|||
|
|||
|
Re: Lookup table generation tool
ok i've gotten this to work.. but how exactly would i use this in my code?
|
|
#13
|
||||
|
||||
|
Re: Lookup table generation tool
Quote:
Anyway, hopefully you can find a use for it and it saves you some time. Cheers, |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Your favorite/most useful tool? | f22flyboy | General Forum | 154 | 13-03-2011 00:51 |