Lookup Tables

Scope

Lookup tables, or LUTs, are numeric tables loaded into ecmc and then accessed at runtime.

Use them when:

  • an axis or encoder needs correction data
  • PLC logic needs a fixed indexed value table
  • a calibration curve should be kept outside the PLC source code

Startup Interface

Load a LUT from file with:

${SCRIPTEXEC} ${ecmccfg_DIR}loadLUTFile.cmd "FILE=./cfg/example.lut"

Optional:

  • LUT_ID: explicit LUT id

After load, the actual id is also available in ECMC_LUT_ID.

File Format

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:

  • numbers can be comma- or space-separated
  • PREC=<n> changes the read precision for the following rows
  • comments are allowed

The exact interpretation of the two columns depends on how the LUT is used. A common pattern is:

  • column 1: input/index/position
  • column 2: output/correction/value

Typical Use Cases

Encoder correction

One common use is encoder correction data, where:

  • column 1 is the measured encoder position
  • column 2 is the correction value

PLC lookup logic

LUTs can also be used directly from PLC logic through the lut_... helper functions.

That is useful when:

  • a small calibration or recipe table should be editable as data instead of PLC code
  • the same numeric table should be shared across several PLC functions

PLC Interface

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 LUTs when the data is:

  • numeric
  • relatively static
  • better maintained as a file than hard-coded in PLC expressions

Do not use LUTs as a replacement for:

  • high-rate streaming data
  • arbitrary operator-editable runtime state
  • large buffered acquisitions

For those cases, use data storage, plugins, or normal EPICS/PLC state instead.