Electronic – Is the lookup table with 50,000 entries too big for MCU memory (dsPIC33EP256MC506)

microchipmicrocontrollerpic

I want to implement a 2-input 1-output fuzzy logic controller using lookup table on the dsPIC33EP256MC506 microcontroller. I am comparing the lookup table and actual fuzzy logic controller side by side in Simulink. In order to minimize the error between the lookup table and actual controller, I am having to generate a huge table, having around 50,000 entries. The input 1 range is -5000 to 5000, input 2 range is -1000 to 1000 and output range is -9999 to 9999. I am using Simulink code generation.

I went over the datasheet's memory section, but still need some expert guidance in relating the lookup table size to the program memory size.
My questions are: how can I find out if this lookup table will fit into the program memory? How can I estimate the approximate size of the lookup table? What are key things to look for in datasheet or the lookup table from practical implementation viewpoint?

Best Answer

You say your lookup table will contain 50000 elements and each element will have the range of -9999 to 9999. That means each element will need 16 bits (= 2 bytes) of memory. So the whole LUT will need 50000 x 2 bytes = 100000 bytes = aprox. 97.6 Kbytes.

Your microcontroller has 256 Kbytes of Flash memory and 32 Kbytes of RAM. So your program/Flash memory would be enough for the LUT. To place the table in program memory you need to declare it as const: const int16_t LUT[] = { ... };