CLUTGen, a flexible ADC LUT generator for embedded systems.
Project description
CLUTGen — Zephyr Module
CLUTGen automates the creation of Look-Up Tables for embedded systems, converting raw ADC readings into calibrated physical units such as temperature, pressure, or distance.
This branch packages CLUTGen as a Zephyr module. LUT generation runs at configure time and produces a pair of .c/.h files that are automatically included in the application build.
For standalone CLI usage, see the main branch.
Requirements
- Python 3.10+
numpy,matplotlib
Integration
Declare the module in your workspace manifest:
# west.yml
- name: clutgen
url: https://github.com/wkhadgar/clutgen
revision: zephyr
path: modules/clutgen
Update your west workspace and install Python dependencies into the west venv:
west update
west packages pip --install
Then, in your application CMakeLists.txt, provide the paths to your calibration TOML files:
clutgen_add_luts(
TOMLS
${CMAKE_CURRENT_SOURCE_DIR}/calibration/temperature.toml
${CMAKE_CURRENT_SOURCE_DIR}/calibration/pressure.toml
)
clutgen_add_luts accepts the following parameters:
| Parameter | Required | Default | Description |
|---|---|---|---|
TOMLS |
Yes | — | One or more paths to .toml calibration config files |
NAME |
No | lookup_tables |
Base name for the generated .c/.h files |
TARGET |
No | app |
CMake target to attach the generated sources to |
Example with all parameters:
clutgen_add_luts(
NAME sensor_luts
TARGET app
TOMLS
${CMAKE_CURRENT_SOURCE_DIR}/calibration/temperature.toml
${CMAKE_CURRENT_SOURCE_DIR}/calibration/pressure.toml
)
LUT generation runs automatically when CMake configures the project. The generated files are placed in the build directory and linked into the application automatically.
Generated LUTs are accessible through the output header:
#include "lookup_tables.h" /* or your custom NAME.h */
Each configured sensor produces an array named <n>_lut, where n is the name field defined in its TOML:
int val = temp_sensor_lut[adc_reading];
Preview
west build -t clutgen_preview
Generates preview plots for each configured sensor, overlaying the calibration data points against the generated LUT curve.
TOML Configuration
Each sensor requires a TOML configuration file and a CSV with its calibration samples.
CSV schema:
raw,calibration
Where raw is the ADC reading and calibration is the expected output value at that reading.
TOML schema:
name = "temp_sensor" # C identifier — used as <n>_lut in generated code
description = "ambient temperature" # Used in Doxygen comments and plot titles
table_resolution_bits = 12 # ADC resolution in bits (e.g., 12 → 4096 entries)
lut_type = "int16_t" # C type for the generated array
samples_csv = "./data/temperature_samples.csv" # Relative to this file, or absolute
# Optional
interpolation = "polynomial" # Overrides the default interpolation method for this LUT
preview = true # Overrides the preview flag for this LUT
Interpolation Methods
| Value | Description |
|---|---|
linear |
Linear interpolation between calibration points. Default. |
splines |
Cubic spline interpolation; smooth transitions between points. |
polynomial |
Best-fit polynomial up to degree 7; prone to oscillation with sparse data. |
piecewise |
Zero-order hold; constant value between points, step-like output. |
idw |
Inverse Distance Weighting; weighted average of all known points. |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file clutgen-0.1.4.tar.gz.
File metadata
- Download URL: clutgen-0.1.4.tar.gz
- Upload date:
- Size: 14.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc93e5d2978761dd933346136569e47b88b4eb54e0dea0924762b87f49e72ac7
|
|
| MD5 |
27431ea3f1d09b01b1002a710e3e802f
|
|
| BLAKE2b-256 |
dae27f13758dabe710a4dc3eb82e714f9a09c3416b120cfef324304e923bf233
|
File details
Details for the file clutgen-0.1.4-py3-none-any.whl.
File metadata
- Download URL: clutgen-0.1.4-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85917ae04bc87ff685ce380462d1777a5cc5f38ac64b7fab90ff636592c9af60
|
|
| MD5 |
edd455861b1c46ad04170c28a6cd8113
|
|
| BLAKE2b-256 |
15a45cd7656d7c09abef5e61c566891d1c61939cbc233371c604a35c6278323b
|