Lookup tables, or LUTs, are numeric tables loaded into ecmc and then accessed at runtime.
Use them when:
Load a LUT from file with:
${SCRIPTEXEC} ${ecmccfg_DIR}loadLUTFile.cmd "FILE=./cfg/example.lut"
Optional:
LUT_ID: explicit LUT idAfter load, the actual id is also available in ECMC_LUT_ID.
The LUT file is a plain text file with two numeric columns.
Example:
# Encoder correction example
PREC=5
-10 -10.12345
0 0.12345
10 10.12345
PREC=6
12.67898 12.345679
Notes:
PREC=<n> changes the read precision for the following rowsThe exact interpretation of the two columns depends on how the LUT is used. A common pattern is:
One common use is encoder correction data, where:
LUTs can also be used directly from PLC logic through the lut_... helper functions.
That is useful when:
cpp_logic modules can read the same loaded LUT objects through
ecmcCpp::lutGetValue(...) from ecmcCppLogic.hpp.
Example:
double value = 0.0;
if (ecmcCpp::lutExists(0)) {
value = ecmcCpp::lutGetValue(0, index);
}
The first argument is the LUT id. The second argument is the input/index value.
The helper returns 0.0 if the LUT id is out of range or if the LUT object has
not been loaded. Use ecmcCpp::lutExists(...) to test whether an optional LUT
has been loaded without logging an error. See C++ Logic Helpers
for the cpp-logic helper reference.
The PLC function library provides lut_... helper functions.
A typical pattern is:
value = lut_get_value(0,index);
Use PLC functions for the full lut_... reference.
Use ecmcCpp::lutExists(lutId) and ecmcCpp::lutGetValue(lutId, index) from
ecmcCppLogic.hpp.
Use LUTs when the data is:
Do not use LUTs as a replacement for:
For those cases, use data storage, plugins, or normal EPICS/PLC state instead.