Difference between revisions of "Component: Lookup tables (Storage)"
(XML import BR) |
(XML import) |
||
Line 7: | Line 7: | ||
|- | |- | ||
| width="20%" style="color: gray;" | Version | | width="20%" style="color: gray;" | Version | ||
− | | 1. | + | | 1.5 (Release) |
|- | |- | ||
| width="20%" style="color: gray;" | Category | | width="20%" style="color: gray;" | Category |
Revision as of 10:31, 9 May 2018
Author | Matrix Ltd |
Version | 1.5 (Release) |
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.
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
GetFloat
Gets a float from the LUT
Parameters
- UINT Index
Return value
GetInt
Gets an integer from the LUT
Parameters
- UINT Index
Return value
Simulation macro reference
GetFloats
Gets the float LUT
Parameters
- FLOAT Dest
Return value
- This call does not return a value
GenerateCache
Generates the C code for the arrays so it does not need to be done at compile time
Parameters
- This macro has no parameters
Return value
- This call does not return a value
GetIntCount
Gets the number of int LUT entries
Parameters
- This macro has no parameters
Return value
ClearInts
Clear all int LUT values
Parameters
- This macro has no parameters
Return value
- This call does not return a value
GetFloatCount
Gets the number of float LUT entries
Parameters
- This macro has no parameters
Return value
GetIntBits
Gets the number of bits-per-int in the LUT
Parameters
- This macro has no parameters
Return value
SetIntBits
Sets the size of an int LUT entry
Parameters
- BYTE Bits
Return value
- This call does not return a value
GetFloatBits
Gets the number of bits-per-float in the LUT
Parameters
- This macro has no parameters
Return value
ClearFloats
Clear all float LUT values
Parameters
- This macro has no parameters
Return value
- This call does not return a value
GetInts
Gets the int LUT
Parameters
- ULONG Dest
Return value
- This call does not return a value
SetFloatBits
Sets the size of a float LUT entry
Parameters
- BYTE Bits
Return value
- This call does not return a value
AddInt
Int to add to the int array
Parameters
- ULONG Value
- Int to add to the int array
Return value
- This call does not return a value
AddFloat
Add a float to the floating point LUT
Parameters
- FLOAT Value
- Floating point values
Return value
- This call does not return a value
Property reference
Storage Type
This property is of type Fixed list of ints and can be referenced with the variable name StorageType.
Controls the data type stored by the component.
Storage Sign
This property is of type Fixed list of ints and can be referenced with the variable name Sign.
Controls if the integer numbers are allowed to be negative.
Unsigned = Numbers are positive only.
Signed = Numbers can be positive and negative.
Integers
This property is of type Multiple lines of text and can be referenced with the variable name intfixed.
Comma seperated integer data which is used to create the C code which is inserted into the ROM.
Embed Into C
This property is of type True or false and can be referenced with the variable name EmbedIntoC.
Flag to decide if code should be generated to C or not
If this is false then the LUT is simulation only