Skip to main content

CLUTGen, a flexible ADC LUT generator for embedded systems.

Project description


C Lookup Table (LUT) Generator

CLUTGen automates the creation of Look-Up Tables for embedded systems, specifically for converting raw ADC (Analog-to-Digital Converter) readings into calibrated physical units (like temperature, pressure, or distance).

Features

  • Curve Fitting: Automatically find your fit from many algorithms.
    • Linear Interpolation
    • Cubic Splines
    • Polynomial Interpolation (up to 7th degree)
    • Piecewise Interpolation
    • Inverse Distance Weighting
  • Visual Preview: Generates plots to compare calibration data against the calculated LUT.
  • C Code Generation: Outputs production-ready .c and .h files with Doxygen-style comments.

Requirements

  • Python 3.10+
  • numpy, matplotlib

Usage

# From the root of the repository
pip install .
# Generate LUTs with cubic splines fit for every configuration toml in the given paths.
clutgen -s -i ./examples/calibration/*.toml ./examples/temperature_copy.toml

YAML Configuration Template

Create a CSV file mapping your POIs with the given schema, where raw is the measured ADC raw value, and calibration is the desired output for the LUT at that given raw value:

raw,calibration

With your table done, create a configuration TOML, e.g.:

# temperature.toml

name = "temp_sensor"                  # Used for variable names (e.g., temp_sensor_lut)
description = "ambient temperature"   # Used for documentation and plot titles
table_resolution_bits = 12            # Resolution (e.g., 12 bits = 4096 entries)
lut_type = "int16_t"                  # C type (int8_t, uint16_t, etc.)
 
samples_csv = "./data/temperature_samples.csv" # Path to CSV/Excel with 'raw' and 'calibration' columns. Path is global or relative to this file.
interpolation = "polynomial" # Optional, forces a given interpolation method to this LUT.

Currently available interpolation methods are:

Interpolation Argument Description
linear Connects points with straight lines; assumes a constant slope between data points.
splines Uses smooth, low-degree curves (like cubics) to join points without sharp transitions.
polynomial Fits a single high-degree equation to the data; good for global trends but prone to oscillations.
piecewise Functions as a zero-order hold (ZOH); it holds the value of a point constant until the next one is reached, resulting in a step-like sequence.
idw Inverse Distance Weighting; calculates unknown values based on the weighted average of nearby known points.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

clutgen-0.1.0.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

clutgen-0.1.0-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file clutgen-0.1.0.tar.gz.

File metadata

  • Download URL: clutgen-0.1.0.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for clutgen-0.1.0.tar.gz
Algorithm Hash digest
SHA256 adb06f1f9df4e1c94ad4bc1e7636c09e41b73595db25b92e615c1a5a7933ec5f
MD5 423f3e62801c19053f04dd405bf7e391
BLAKE2b-256 318793c7e51113ee564b14b8e6f476861942e9d5ba52c558fbc2e489dd2a567b

See more details on using hashes here.

File details

Details for the file clutgen-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: clutgen-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for clutgen-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a1cb34ec497214238d37bffb34af504ed30b7f568d55840d87b3e2ba2e621490
MD5 73174a73d57ae9b8dd313db379ec3042
BLAKE2b-256 be5da73e6f6502f774afec1aae1766d340f837e3eeae75041b5db5f9a6f4577d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page