John_Lintern
Joined: 30 Sep 2004 Posts: 14
|
Newbie needs help to make a lookup table |
Posted: Mon Nov 29, 2004 9:51 am |
|
|
I need to use a lookup table of some sort but I have no idea how to do it !
I need a value to be looked up from two variables, 'Throttle Position' and 'RPM'.
Both these variables are 8-bit integers ranging from 0 to 255.
The lookup value will also be an 8-bit integer ranging from 0 to 255.
So I need to create a MAP, just like the fuel and ignition MAPS used in engine management control units.
If I used a lookup table for every value of the two inputs I would have a table of 65,025 bytes ! (255*255)
So I have reduced this by using a resolution of 5 for the 'Throttle Position' and a resolution of 4 for the 'RPM', this gives me a table of 3,328 bytes (52*64).
i.e.
0 4 8 12 16 20 24 28 32 ......252
5
10
15
20
25
...
...
...
255
The values of the lookup table will probably be stored in an external eeprom at a later date.
But for now, what is the best way for me to create a lookup table ?
Can I use something like...
BYTE CONST SINE_WAVE[200,100] = {
128,132,136,139,143,147,150,154,158,161,165,169,172,176,179,
182,186,189,192,195,199,202,204,207,210,213,215,218,220,223,
225,227,229,231,233,235,237,238,240,241,242,243,244,245,246,
247,247,247,248,248,248,248,248,247,247,247,246,245,244,243,
242,241,240,238,237,235,233,231,229,227,225,223,220,218,215,
213,210,207,204,202,199,195,192,189,186,182,179,176,172,169,
165,161,158,154,150,147,143,139,136,132,128,124,120,117,113,
109,106,102,98,95,91,87,84,80,77,74,70,67,64,61,57,54,52,49,
46,43,41,38,36,33,31,29,27,25,23,21,19,18,16,15,14,13,12,11,
10,9,9,9,8,8,8,8,8,9,9,9,10,11,12,13,14,15,16,18,19,21,23,
25,27,29,31,33,36,38,41,43,46,49,52,54,57,61,64,67,70,74,77,
80,84,87,91,95,98,102,106,109,113,117,120,124};
I tried to compile my program with this code inserted but it came up with an error.
It highlighted the 200 (in the line BYTE CONST SINE_WAVE[200,100]) and said 'Expecting a ]'.
Can anyone offer some help ?
PS. I am using a PIC16C74B |
|