Component: Lookup tables (Storage)
Author | Matrix Ltd |
Version | 1.7 |
Category | Storage |
Contents
Lookup tables component
A lookup-table component allowing an easy way to place arrays of static data into ROM memory. The LUT data is accessed directly allowing very low overhead when collecting the data.
Detailed description
No detailed description exists yet for this component
Component Source Code
Please click here for the component source code: [../../componentsource/FC_Comp_Source_ FC_Comp_Source_]
Component Source Code
Please click here for the component source code: [../../componentsource/FC_Comp_Source_LUT.fcfx FC_Comp_Source_LUT.fcfx]
Component Source Code
Please click here for the component source code: [../../componentsource/FC_Comp_Source_LUT.fcfx FC_Comp_Source_LUT.fcfx]
Examples
A look up table component is useful when including data into a program which may not be linear and therefore hard to calculate.
One example of this is a sine wave or working out a temperature based on the resistance of a thermistor.
For a simple example lets say we want to store a sine wave on board the microcontroller.
First of all we use Excel to generate the data for a sine wave to do this we work out the angles in degrees we want to reproduce, then convert the degrees to radians and then generate the Sine wave for the angle. the angle returned will be between -1 and 1 so we need to convert this to fit into the microcontroller's memory. The most efficient way is to store the value as a byte which means scaling up the output to 0 - 255 and removing the real portion of the number to give integer values.
Then using the file -> Save as menu in Excel we can export the data as a raw .CSV file.
The line in the CSV file we are interested in is the Integer Offset Data. We can then copy and paste this data into the integer property of the look up table component.
In this example Flowcode file we display the LUT data onto a graphical LCD display
LUT
Here is what you should expect to see on the glcd after running the simulation.
Downloadable macro reference
![]() |
GetFloats |
Gets the float LUT | |
![]() |
Dest |
![]() |
Return |
![]() |
GenerateCache |
Generates the C code for the arrays so it does not need to be done at compile time | |
![]() |
Return |
![]() |
GetIntCount |
Gets the number of int LUT entries | |
![]() |
Return |
![]() |
ClearInts |
Clear all int LUT values | |
![]() |
Return |
![]() |
GetFloatCount |
Gets the number of float LUT entries | |
![]() |
Return |
![]() |
GetIntBits |
Gets the number of bits-per-int in the LUT | |
![]() |
Return |
![]() |
SetIntBits |
Sets the size of an int LUT entry | |
![]() |
Bits |
![]() |
Return |
![]() |
GetFloatBits |
Gets the number of bits-per-float in the LUT | |
![]() |
Return |
![]() |
ClearFloats |
Clear all float LUT values | |
![]() |
Return |
![]() |
GetFloat |
Gets a float from the LUT | |
![]() |
Index |
![]() |
Return |
![]() |
GetInts |
Gets the int LUT | |
![]() |
Dest |
![]() |
Return |
![]() |
GetLUTCount |
Gets the number of individual data entries stored in the LUT. | |
![]() |
Return |
![]() |
GetInt |
Gets an integer from the LUT | |
![]() |
Index |
![]() |
Return |
![]() |
SetFloatBits |
Sets the size of a float LUT entry | |
![]() |
Bits |
![]() |
Return |
![]() |
AddInt |
Int to add to the int array | |
![]() |
Value |
Int to add to the int array | |
![]() |
Return |
![]() |
AddFloat |
Add a float to the floating point LUT | |
![]() |
Value |
Floating point values | |
![]() |
Return |