Go Down

Topic: Importing a large lookup table (Read 2 times) previous topic - next topic

Thot

Hello,
   I need to setup a large (100 or so pairs of ints) lookup table to connect two set of numbers that are not mathematically related, i.e. One cannot be calculated from the other.
I am plannig to set up an array like this:

Code: [Select]
int table [100] [1] ;

And then fill it like this:

Code: [Select]
table [0] [0] = x0 ;
table [0] [1] = y0 ;
table [1] [0] = x1;
table [1] [1] = y1;
........................


I could easilly do it within the sketch but that would make the sketch heavy to read.
Is there a way to set up the table in a separate text file:

xo,yo
x1,y1
x2,y2
........

and then read or import it into the array?

That would have the additional advantage to be able to tweak the table without modifying verifying and re-uploading the sketch

TIA
There are three kind of people in the world: Those who can count, and those who can't

Cybernetician

Put it in Flash memory of controller
From Idea To Invention

wildbill

If you have the hardware needed to read from an SD card, it would be relatively easy to read your data from a text file at run time. Alternatively you could store it in EEPROM, but you'd have to write a program on the PC to send the data to put there, both for the initial load and when you wanted to change it. Or you could put the initialization code in another tab in the IDE to keep it segregated from your main sketch. With this last method, you would still have to reload the sketch every time you made a change. Another way would be to use the Arduino as a web client and go get the data from a web server at startup.

dhenry

Put the array itself in a .c file and declare it as extern in a .h file.

In your code, include the .h file and then include the .c file in the project.

Cybernetician

Quote
That would have the additional advantage to be able to tweak the table without modifying verifying and re-uploading the sketch


EEPROM Or SD card best options.
From Idea To Invention

Go Up