Page 1 of 1

Look-up-tables.

Posted: Thu Feb 18, 2010 7:38 am
by medelec35
For my latest project I'm using four LUT's (4 x 50)
Since they are bytes, they only cover 0-255

Is there a way (without doubling quantities of LUT and using: number=LUT x 100+LUTb , e.g. I If number is 2614, then 1st LUT = 26 and second LUT=14) of using a 10bit LUT?. I need to retrieve numbers in the range of 0 to 3274
The only other way I can think of is using int arrays. Since I have made a spread sheet to create and paste LUT data directly into flowcode, I want to avoid arrays if i can.

Re: Look-up-tables.

Posted: Thu Feb 18, 2010 9:18 am
by Benj
Hello Medelec

You should be able to do something like this.

temph = LUT[pos]
templ = LUTB[pos]
intvar = (temph * 100) + templ

Re: Look-up-tables.

Posted: Thu Feb 18, 2010 10:03 am
by medelec35
Benj wrote:Hello Medelec

You should be able to do something like this.

temph = LUT[pos]
templ = LUTB[pos]
intvar = (temph * 100) + templ
Thanks for reply Ben. I was after a method which did not require doubling of LUT
is your method same as example I posted which I am trying to avoid?:
medelec35 wrote:(without doubling quantities of LUT and using: number=LUT x 100+LUTb
Am I correct in saying all LUT are 8 bit only?

Re: Look-up-tables.

Posted: Thu Feb 18, 2010 11:32 am
by Benj
Hello Medelec

Sorry I think I misread,

You can create a 16-bit LUT in Flowcode if you need to by creating a int array though as you suggested this would cause problems initialising the data.

You can also create a C code array by doing something similar to this in the supplementary code window.

int LUT[2] = {1234, 2345};

This would be stored in RAM and would have a maximum size of 128 int variables.

A ROM array can only be 8-bits max.

Re: Look-up-tables.

Posted: Thu Feb 18, 2010 12:55 pm
by medelec35
Thanks Ben. I only said avoiding arrays due to spreadsheet copy and paste. Since you have overcome that with C code, so long as don't go above max RAM capacity, your solution will best way forward!

Re: Look-up-tables.

Posted: Thu Feb 18, 2010 5:17 pm
by medelec35
Benj wrote:
You can also create a C code array by doing something similar to this in the supplementary code window.

int LUT[2] = {1234, 2345};

.
Ben Should it be:

Code: Select all

int FCV_LUT[2] = {1234, 2345};
?

Problem is I now get following error message:

Code: Select all

m:\NEW_HIGH_EFF_HR_V3_BASIC1B_EBM_Fans.c(209:223): error: too many initializers
m:\NEW_HIGH_EFF_HR_V3_BASIC1B_EBM_Fans.c(209:26): error: failed to initialize variable 'FCV_STD155_RPMF1'
m:\NEW_HIGH_EFF_HR_V3_BASIC1B_EBM_Fans.c(211:220): error: too many initializers
m:\NEW_HIGH_EFF_HR_V3_BASIC1B_EBM_Fans.c(211:26): error: failed to initialize variable 
If declared in supplementary window, does that mean if variable is added which has the same name, causes the above error?
If that is the case then that would mean assigning variable with a value or a calculation involving int variable in a C box rather then a calculation box?
Or have I got that wrong and error is for a different reason.
This is the code I used in supplementary code window:

Code: Select all

Int FCV_STD155_RPMF1[40]={807,844,880,917,954,990,1027,1060,1093,1126,1159,1192,1225,1258,1291,1324,1357,1390,1419,1442,1465,
1488,1511,1534,1557,1580,1603,1626,1649,1672,1696,1715,1734,1753,1772,1791,1810,1829,1848,1867,1886};

Re: Look-up-tables.

Posted: Fri Feb 19, 2010 4:28 pm
by medelec35
Figured out what was causing error.
too many initializers just simply mean you have more than declared number of items.
After count, I had 41 variables instead of declared 40.
Now compiles ok. Only problem is still going over memory allocation.
:cry:

Re: Look-up-tables.

Posted: Fri Feb 19, 2010 5:14 pm
by medelec35
I have had an idea. I have run out of ram for variables location. What i can do is use flowcode to write 8bit numbers to flash, then retrieve stored numbers like an array. I believe u need to use flash.h is that correct?