How sverdfisk/wind-turbine-rpm-estimation-software works
Purpose and System Boundary
This repository is a wind-turbine RPM monitoring prototype built around a Sony IMX385LQR image sensor, a custom Raspberry Pi 5 carrier PCB, Linux sensor integration, and Python video analysis. Its three usable subsystems are intentionally separable: hardware design, Pi-side sensor driver/control, and RPM estimation software.
Hardware Design
The custom four-layer IMX385 board provides sensor interfacing, power regulation, analog/digital circuitry, and output connectivity for a Raspberry Pi 5 installation.
• Altium project and PCB layout: altium_files/IMX385/IMX385_Final.PrjPcb, altium_files/IMX385/IMX_PCB.PcbDoc
• Power domains and sequencing-related schematics: altium_files/IMX385/IMX_Power Regulation.SchDoc, altium_files/IMX385/IMX_1.2V Digital Power Supply.SchDoc, altium_files/IMX385/IMX_3.3 V Analog Power Supply.SchDoc
• Interface and sensor-support circuits: altium_files/IMX385/IMX_Digital Interface Circuit.SchDoc, altium_files/IMX385/IMX_Analog Interface Circuit.SchDoc, altium_files/IMX385/IMX_Supporting Circuits.SchDoc
Manufacturing outputs, including BOM, placement data, DRC report, Gerbers, and ODB package, are under altium_files/IMX385/Project Outputs for IMX385_Final/.
Raspberry Pi Sensor Enablement
The driver/ subsystem targets Raspberry Pi 5/Linux and bridges the custom IMX385 hardware into the platform’s camera stack.
• Kernel sensor driver: driver/imx385.c
• Device-tree overlay defining hardware integration: driver/imx385-overlay.dts
• Build/load support and boot configuration: driver/compile.sh, driver/Makefile, driver/config.txt
The V4L2 capture pipeline is an explicit external boundary: this repository does not fully configure frame acquisition or encoding. It supplies the driver pieces so sensor pixel data can reach the Pi, while deployment must establish an appropriate capture/format pipeline.
Hardware Control and Image Path
GPIO scripts implement strict sensor power/enable sequencing and peripheral image controls:
• Sensor startup/shutdown: driver/imx-on.py, driver/imx-off.py
• IR-cut filter control: driver/filter-on.py, driver/filter-off.py
• Sensor configuration: driver/imxconfig.sh
A physical sequencing connection from the PCB SEQ test point to a Pi GPIO is required; default assumptions are embedded in driver/imx-on.py. Once enabled and captured through V4L2 or another source, frames become the input boundary for the Python RPM software.
RPM Application Entry Points
The Python application accepts either a camera/video feed and a generated JSON configuration.
• Main operational entry point: software/main.py
• Interactive configuration producer: software/config_generator.py
• Configuration template: software/config/config_template.json
Testing mode displays/prints detection output; deployment mode continuously processes the feed and appends newly computed estimates to runs/out.csv. The feed location is provided by the config’s target field rather than hardwired to the custom sensor.
Vision-to-RPM Processing
RPM estimation is organized under software/rpm/:
• Optical-flow motion extraction: software/rpm/opticalflow.py
• BPM/RPM cascade and calculation: software/rpm/bpm_cascade.py, software/rpm/calculate_rpm.py
• Feed abstraction: software/rpm/feed/feed.py
Control flow is: config → open target video/camera feed → frame-by-frame vision processing → motion/BPM inference → RPM calculation → console visualization or deployment CSV output. software/rpm/utils.py supports the processing pipeline.
Runtime and Dependencies
The application is Python-based and uses Conda environment definitions at software/environment.yml and root environment.yml. Hardware operation requires Raspberry Pi 5, Linux kernel/module and device-tree support, GPIO access, the custom IMX385 PCB, and a separately configured V4L2-compatible capture path.
Main entry points: IMX385_Final.PrjPcb Altium PCB project · imx385.c IMX385 kernel driver · main.py RPM application · feed.py Video/camera feed
Components 20
Custom IMX385 Hardware
Four-layer Raspberry Pi 5 carrier and sensor board.
- Altium PCB project
altium_files/IMX385/IMX385_Final.PrjPcb - Four-layer PCB layout
altium_files/IMX385/IMX_PCB.PcbDoc - Power domains & sequencing · Regulation, digital, and analog supply circuits.
altium_files/IMX385/IMX_Power Regulation.SchDoc - Sensor interface circuits · Analog, digital, and support circuitry for the IMX385.
altium_files/IMX385/IMX_Digital Interface Circuit.SchDoc - IMX385 carrier board · Connects the IMX385 sensor and sequencing signal to the Pi.
- Manufacturing outputs · BOM, placement, DRC, Gerbers, and ODB outputs.
Pi Sensor Enablement
Linux integration and GPIO control on Raspberry Pi 5.
- Device-tree overlay
driver/imx385-overlay.dts - IMX385 kernel driver
driver/imx385.c - Driver build & boot setup · Builds and loads the module and supplies boot configuration.
driver/compile.sh - GPIO sensor controls · Startup/shutdown, IR-cut filter, and sensor configuration scripts.
driver/imx-on.py - V4L2 capture pipeline · Deployment supplies capture, format, and encoding setup.
RPM Application
Python configuration and video-based RPM estimation.
- Config generator
software/config_generator.py - Config template
software/config/config_template.json - RPM application · Runs testing display or continuous deployment processing.
software/main.py - Video/camera feed · Opens the target configured by the JSON input.
software/rpm/feed/feed.py - Optical-flow extraction
software/rpm/opticalflow.py - Motion/BPM inference
software/rpm/bpm_cascade.py - RPM calculation
software/rpm/calculate_rpm.py - Console or CSV output · Deployment appends new estimates to runs/out.csv.
- Conda environment
software/environment.yml
Connections 22
- Altium PCB project → Four-layer PCB layout: contains layout
- Altium PCB project → Power domains & sequencing: includes
- Altium PCB project → Sensor interface circuits: includes
- Altium PCB project → Manufacturing outputs: produces
- Four-layer PCB layout → IMX385 carrier board: implements
- Power domains & sequencing → IMX385 carrier board: powers and sequences
- Sensor interface circuits → IMX385 carrier board: interfaces
- IMX385 carrier board → Device-tree overlay: hardware described by
- IMX385 carrier board → GPIO sensor controls: SEQ GPIO and controls
- Device-tree overlay → IMX385 kernel driver: binds
- Driver build & boot setup → IMX385 kernel driver: builds and loads
- GPIO sensor controls → IMX385 kernel driver: enables sensor before capture
- IMX385 kernel driver → V4L2 capture pipeline: exposes pixel data
- Config template → Config generator: seeds
- Config generator → RPM application: generates config for
- Conda environment → RPM application: provides dependencies
- V4L2 capture pipeline → Video/camera feed: captured frames
- RPM application → Video/camera feed: opens configured target
- Video/camera feed → Optical-flow extraction: frames
- Optical-flow extraction → Motion/BPM inference: motion signal
- Motion/BPM inference → RPM calculation: BPM estimate
- RPM calculation → Console or CSV output: estimate