This project implements a comprehensive bioreactor control system with multiple interacting control loops, data management, and safety features.
- Measurement frequency: 1 second
- Control action: Every 2 minutes
- Trigger: 0.2 pH below setpoint
- Interfaces: Acid/base pump
- Database logging for additions
- Measurement frequency: 1 second
- Control action: Every 30 seconds
- Cascading control:
- Stirrer speed adjustment
- Gas flow rate adjustment
- Configurable cascade priority
- Measurement frequency: 1 second
- Control action: Every 10-30 seconds (configurable)
- Advanced PID control implementation:
- 12-bit PWM resolution (0-4095)
- 1 kHz PWM frequency
- Heater control via MOSFET on pin PB10
- Multi-sensor temperature monitoring:
- pH probe temperature sensor
- DO probe temperature sensor
- Intelligent averaging of valid readings
- Fallback mechanisms:
- Continues with single sensor if one fails
- Maintains last known temperature if both fail
- Safety features integrated with SafetyManager
- Interfaces: PWM-controlled heating jacket
- Measurement frequency: 1 second
- Control action: Every 5-10 seconds
- Interfaces: Backpressure controller, gas mixing system
- Measurement frequency: 5 seconds
- Control action: Every 30 seconds
- Coordinates with DO control
- Interfaces: DO control, pressure control
- Measurement frequency: 1 minute
- Control action: Every 5-15 minutes
- Adaptive feed profiles based on:
- Growth phase
- Metabolic demand
- Interfaces: Peristaltic pumps, biomass monitoring
- Measurement frequency: 1 minute
- Control action: Every 15-30 minutes
- Modes: Continuous or semi-continuous
- Interfaces: Harvest pump, biomass monitoring
- Measurement frequency: 1 second
- Control action: Every 30 seconds
- Adaptive control based on:
- DO levels
- Shear sensitivity
- Interfaces: DO control, biomass monitoring
- Logging frequency: 1 second
- Pipeline: Microcontroller → MQTT → Python script → Database
- MQTT topics organized by sensor/control system
- Standardized JSON data format
- Time-series database (InfluxDB)
- Data retention policies
- SQL database backup integration
- Optimized time-based queries
- Update frequency: 5-10 seconds (configurable)
- Real-time sensor data integration
- Predictive modeling
- Bi-directional system communication
- Update frequency: 5 seconds
- Features:
- Real-time visualization
- Setpoint management
- PID tuning
- Control timing adjustments
- Alarm configuration
- Min/max value settings
- Web-based remote access
- Continuous monitoring (1 second)
- 5-second alarm confirmation
- Notification system: Email/SMS
- Emergency shutdown protocols
- Predictive alarm triggering via digital twin
-
Implement pH sensor reading function
- Hardware: Atlas Scientific pH sensor
- Interface: I2C
- Function:
readPHSensor()
inph_controller.h
-
Implement DO sensor reading function
- Hardware: PreSens DO sensor
- Interface: RS485
- Function:
readDOSensor()
indo_controller.h
-
Implement temperature sensor reading
- Hardware: PT100 RTD sensors
- Interface: ADC
- Function:
readTemperatureSensor()
intemperature_controller.h
-
Implement pressure sensor reading
- Hardware: Honeywell pressure transducer
- Interface: Analog
- Function:
readPressureSensor()
inpressure_controller.h
-
Implement acid/base pump control
- Hardware: Peristaltic pumps
- Interface: PWM
- Function:
actuatePump()
inph_controller.h
-
Implement stirrer speed control
- Hardware: BLDC motor
- Interface: PWM + Encoder
- Function:
adjustStirrerSpeed()
indo_controller.h
-
Implement gas flow control
- Hardware: Mass flow controllers
- Interface: RS485
- Function:
adjustGasFlow()
indo_controller.h
-
Implement heating jacket control
- Hardware: Heating element
- Interface: SSR
- Function:
adjustHeatingJacket()
intemperature_controller.h
- Set up Mosquitto MQTT broker
sudo apt-get install mosquitto mosquitto-clients sudo systemctl enable mosquitto
- Configure MQTT credentials in
mqtt_handler.h
const char* MQTT_SERVER = "your-broker-ip"; const char* MQTT_USER = "your-username"; const char* MQTT_PASSWORD = "your-password";
- Set up MQTT topics structure
bioreactor/ ├── data/ │ ├── ph │ ├── do │ ├── temperature │ └── pressure └── control/ ├── setpoints └── commands
- Install InfluxDB
curl -s https://repos.influxdata.com/influxdb.key | sudo apt-key add - echo "deb https://repos.influxdata.com/debian stable main" | sudo tee /etc/apt/sources.list.d/influxdb.list sudo apt-get update && sudo apt-get install influxdb sudo systemctl enable influxdb
- Create database and user
CREATE DATABASE bioreactor CREATE USER "bioreactor" WITH PASSWORD 'your-password' GRANT ALL ON "bioreactor" TO "bioreactor"
- Configure retention policies
CREATE RETENTION POLICY "raw_data" ON "bioreactor" DURATION 7d REPLICATION 1 DEFAULT CREATE RETENTION POLICY "aggregated" ON "bioreactor" DURATION 52w REPLICATION 1
- Update credentials in
database_manager.h
-
Create responsive dashboard layout
- Main display panel
- Control panel
- Alarm panel
- Trends panel
-
Implement real-time data visualization
- Use Chart.js for trend plots
- Create gauge displays for current values
- Add alarm indicators
-
Add control interface
- Setpoint adjustment forms
- PID tuning interface
- Mode selection (Manual/Auto)
- Emergency stop button
-
Implement user authentication
- Login system
- Role-based access control
- Audit logging
-
Create calibration procedures
- pH sensor calibration
- DO sensor calibration
- Temperature sensor calibration
- Pressure sensor calibration
-
Implement automated testing
- Unit tests for control algorithms
- Integration tests for communication
- System tests for safety features
-
Enhanced Temperature Sensing
- Integrated temperature readings from both pH and DO probes
- Smart averaging system for reliable temperature data
- Automatic sensor validity checking
-
PWM Heater Control
- Implemented on SAMD51 pin PB10 (pin 32)
- 12-bit resolution for precise control (4096 steps)
- 1 kHz switching frequency for efficient heating
- MOSFET-based power control
-
Control Architecture
- PID control with configurable parameters
- Adjustable control interval (10-30 seconds)
- Integrated with central SensorManager
- Safety system integration
-
System Integration
- Unified through ControllerManager
- Automatic sensor data handling
- Seamless integration with existing control systems
- Real-time monitoring and adjustment capabilities
- Handles sensor interfaces (RS485, PT100s)
- Controls stepper motors
- Manages PWM outputs
- Communicates with RP2040 via SPI
- Ethernet connectivity
- Web server
- MicroSD card logging
- MQTT client for data transmission
pcb_control_system/
├── samd51/ # SAMD51 firmware
│ ├── src/ # Source files
│ │ ├── controllers/ # Control system implementations
│ │ ├── sensors/ # Sensor interfaces
│ │ └── safety/ # Safety and alarm systems
│ ├── include/ # Header files
│ └── platformio.ini # PlatformIO configuration
├── rp2040/ # RP2040 firmware
│ ├── src/ # Source files
│ │ ├── network/ # Network communication
│ │ ├── data/ # Data management
│ │ └── web/ # Web interface
│ ├── include/ # Header files
│ └── platformio.ini # PlatformIO configuration
└── README.md # This file
This project uses PlatformIO for build management. To build:
- Install PlatformIO
- Navigate to either samd51/ or rp2040/ directory
- Run
pio run
to build - Run
pio run -t upload
to flash
- Arduino core for SAMD51
- PID control library
- Sensor libraries (specified in platformio.ini)
- Arduino core for RP2040
- Ethernet library
- SD card library
- MQTT client library
- Web server library
- Set up the hardware connections according to the PCB documentation
- Configure the network settings in the RP2040 firmware
- Set up the MQTT broker and database system
- Flash both microcontrollers
- Access the web interface for system configuration and monitoring
Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.