Skip to content

mtepenner/sabatier-control-loop

Repository files navigation

⚙️ Sabatier Control Loop

Description

The Sabatier Control Loop is a full-stack, automated process control system designed to manage a Sabatier reactor. The architecture spans from a bare-metal safety and actuation layer running FreeRTOS, up to an intelligent Go-based edge daemon handling state transitions and PID loops, and finally to a React/TypeScript operator dashboard for real-time monitoring and manual overrides. Additionally, a Python data historian is included to analyze historical time-series data for continuous PID tuning.

📑 Table of Contents

🚀 Features

  • Bare-Metal Safety Layer: Built with C/C++ and FreeRTOS for microcontrollers (e.g., ESP32 or Teensy). Features a critical hardware interlock that executes a hardcoded shutdown if the reactor temperature exceeds 450°C.
  • Precision Sensor & Actuator Control: Reads K-Type thermocouples via SPI and performs high-speed analog reads of chamber pressure. Controls heater bands via PWM, liquid cooling pumps, and precision solenoid valves for CO2 and H2 mass flow.
  • Intelligent Go Process Controller: A state machine manages the entire fuel production cycle, smoothly transitioning between Purge, Heat, React, Cool, and Vent phases.
  • Advanced PID Loops: Dedicated thermal and pressure PID loops balance the exothermic reaction against the heaters and match gas injection rates with exhaust flow.
  • Real-Time Operator Dashboard: A React and TypeScript UI providing an interactive Piping and Instrumentation Diagram (P&ID) schematic, real-time thermal graphs, and manual valve overrides. Data is broadcasted at 20Hz via WebSockets.
  • Data Historian & Tuning: A Python application that analyzes historical runs to suggest optimized Proportional, Integral, and Derivative (PID) coefficients.

🛠️ Technologies Used

  • Firmware: C/C++, FreeRTOS, PlatformIO
  • Edge Daemon Controller: Go, WebSockets
  • Operator Dashboard: React, TypeScript
  • Data Analysis: Python
  • Orchestration & Deployment: Docker, Docker Compose

⚙️ Installation

  1. Clone the repository:

    git clone [https://github.com/yourusername/sabatier-control-loop.git](https://github.com/yourusername/sabatier-control-loop.git)
    cd sabatier-control-loop
  2. Flash the microcontroller firmware using PlatformIO or the included Makefile:

    make flash
  3. Boot the Edge Daemon, Dashboard, and Historian using Docker Compose:

    docker-compose up -d
  4. Validate the non-firmware slices locally:

    python -m compileall data_historian/app
    cd edge_daemon && go test ./...
    cd ../operator_dashboard && npm install && npm run build

💻 Usage

  • Access the P&ID Dashboard: Open your browser and navigate to the locally hosted React application to view the interactive reactor schematic and Alert Terminal.
  • Monitor the Process State: Watch the real-time thermal graph plotting Target Temp vs. Actual Temp as the Go daemon cycles through the reaction states.
  • Tune the Controller: Utilize the Python data historian application to parse previous runs and adjust your PID coefficients for maximum efficiency.
  • Edge Daemon Endpoints: The Go controller exposes GET /health, GET /snapshot, POST /override, and WS /ws on port 8080.

📂 Project Structure

  • /firmware: C/C++ bare-metal code for reading sensors (thermocouples, pressure transducers) and driving actuators (heaters, pumps, flow controllers).
  • /edge_daemon: Go application acting as the process controller, executing the primary state machine and PID algorithms.
  • /operator_dashboard: React/TypeScript application providing the visual interface for operators.
  • /data_historian: Python service for time-series analysis and PID coefficient tuning.
  • /.github/workflows: Contains CI/CD pipelines, including unit tests for the PID math and automated firmware builds.

🤝 Contributing

Contributions are welcome. Before submitting pull requests, please ensure that you run the automated PID logic tests and verify that the critical hardware interlock logic remains intact.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

About

A complete Sabatier reactor control system featuring C/C++ safety firmware, a Go-based PID process controller daemon, and a React operator dashboard.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors