Skip to content

lsinfo3/energy_measurement_tinkerforge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MTET – Measurement Timing Evaluation Toolkit

MTET is a Typer-based CLI tool for orchestrating measurement runs, capturing data from multiple sources, and performing evaluations.
Each measurement source runs in its own multiprocessing.Process, writing results into a synchronized run directory.


Features

  • Multi-process capture for measurements and reference signals
  • Tinkerforge Voltage/Current Bricklet V2 for current/voltage monitoring
  • SerialProcess for reference markers (start/stop signals)
  • PPK2 (Nordic Power Profiler Kit 2) for high-precision reference measurements
  • Saleae Logic Analyzer for digital reference/trigger signals
  • Consolidated output:
    • Feather chunks per process
    • meta.json configuration
    • CSV/Parquet files for evaluation

Project Structure (relevant parts)

scripts/
  mtet.py                       # CLI entrypoint (Typer App)
  mtet/
    list.py                     # "list" subcommands (enums)
    run.py                      # "run" subcommands (start processes)
    eval.py                     # "eval" subcommands (evaluation)
    dut.py                      # DUT-specific helper commands
  tools/
    helpers.py                  # Helper functions
    final_eval.py               # Final evaluation across runs
    tf_plot_data.py             # Plot helper for TF data
    tf_run_eval.py              # TF run evaluation
    processes/
      TinkerForgeProcess.py         # Bricklet V2 current/voltage
      SerialProcess.py              # Reference via UART
      PPK2MeasurementProcess.py     # Nordic Power Profiler Kit 2
      SaleaeLogicMeasurementProcess.py # Saleae Logic Analyzer

Processes

1. TinkerForgeProcess

File: scripts/tools/processes/TinkerForgeProcess.py

  • Connects to Tinkerforge Brick Daemon (localhost:4223)
  • Configurable: Averaging, Conversion Time, Interval, UID
  • Writes Feather chunks + meta.json
  • Provides primary current/voltage measurement

2. SerialProcess

File: scripts/tools/processes/SerialProcess.py

  • Opens a serial port (e.g., /dev/ttyUSB0)
  • Reads time-critical DUT markers/trigger signals (start/stop events)
  • Stores values in Feather format (serial_measurements.feather)
  • Provides reference time base for aligning measurements

3. PPK2MeasurementProcess

File: scripts/tools/processes/PPK2MeasurementProcess.py

  • Interfaces with the Nordic Power Profiler Kit 2 (PPK2)
  • Captures high-resolution current measurements
  • Outputs Feather + metadata
  • Acts as reference measurement to validate Tinkerforge results

4. SaleaeLogicMeasurementProcess

File: scripts/tools/processes/SaleaeLogicMeasurementProcess.py

  • Uses Saleae Logic API (local Saleae server) for digital capture
  • Records DUT reference signals or trigger patterns
  • Writes saleae_logic.feather
  • Enables temporal synchronization of DUT activity with measurement data

Installation

cd praktium-measurement-evaluation
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt

Requirements:

  • Python ≥ 3.10
  • Brick Daemon (for Tinkerforge)
  • Drivers/tools for PPK2, Saleae, serial device

CLI – Usage

Entrypoint

python scripts/mtet.py --help

Subcommands

Commands:
  list   List available options (enums)
  run    Start capture processes
  eval   Evaluate captured data
  dut    DUT-specific helper commands

list – available options

# Averaging enums
python scripts/mtet.py list AVG

# Conversion time enums
python scripts/mtet.py list T

run – start measurement

Multiple processes can run simultaneously. Example identifiers:

  • 1 = TinkerForgeProcess
  • 2 = SerialProcess
  • 3 = PPK2MeasurementProcess
  • 4 = SaleaeLogicMeasurementProcess

Example: run all processes together

# Bricklet UID
TF_UID=21hK

# Create run folder
mkdir -p ./runs/run_2025-08-29

# Start all processes (TF + Serial + PPK2 + Saleae)
python scripts/mtet.py run all   ./runs/run_2025-08-29   --tf-avg 0   --tf-ct 4   --tf-interval 0.0022   --tf-uid "$TF_UID"   --serial /dev/ttyUSB0   --ppk2 auto   --saleae localhost:10429

Parameters:

  • --tf-uid <STRING> Bricklet V2 UID
  • --tf-avg <INT> Averaging (enum value, see list AVG)
  • --tf-ct <INT> Conversion time (enum value, see list T)
  • --tf-interval <FLOAT> Measurement interval in seconds
  • --serial <DEVICE> Serial device (e.g., /dev/ttyUSB0)
  • --ppk2 <MODE> PPK2 connection (e.g., auto or device path)
  • --saleae <HOST:PORT> Saleae Logic server (default: localhost:10429)

Output:
Each process writes to the shared run directory (meta.json, Feather chunks).


eval – evaluation

  • Per-process data:
python scripts/mtet.py eval tf-data ./runs/run_2025-08-29
python scripts/mtet.py eval serial ./runs/run_2025-08-29
python scripts/mtet.py eval ppk2 ./runs/run_2025-08-29
python scripts/mtet.py eval saleae ./runs/run_2025-08-29
  • Final evaluation (combined):
python scripts/mtet.py eval final ./runs/run_2025-08-29

The helper scripts (tools/tf_run_eval.py, tools/tf_plot_data.py, tools/final_eval.py) generate CSV/Parquet and plots, aligning signals from all sources.


Best Practices

  • Always run all reference processes for robust timing.
  • Use PPK2 to validate Tinkerforge readings.
  • Use Saleae to correlate DUT activity with power consumption.
  • SerialProcess provides reproducible timing markers.

Troubleshooting

  • UID not found (Tinkerforge): Brick Daemon running? Correct UID?
  • PPK2 errors: Device permissions? nrf-ppk drivers installed?
  • Saleae errors: Saleae Logic software running? Remote API enabled?
  • Serial errors: Correct port? Access rights?

Saleae Logic 2

Saleae Logic needs to run in the background!

Headless start (see: here):

sudo xvfb-run /home/info-ls3/measurement-timing-evaluation/software/Logic-2.4.22-linux-x64.AppImage --no-sandbox --automation

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •