How sefu202/pren-firmware works
PREN-Firmware is STM32 firmware for an object-placement machine, controlled over Ethernet by a Python client. The workflow is: client commands cross the TCP protocol boundary, update the process image, and drive axis or actuator state; the firmware loop samples safety inputs and hardware state, updates motion and outputs, and exposes status for client polling. The README documents additional motion, safety, and indicator capabilities. Some internal communication and peripheral links are based on the documented architecture and tree; unsampled wiring is omitted.
Main entry points: application.cpp Main Control Loop · LinearAxis.cpp Linear Axes · ProcessImage.cpp Process Image · ProtocolServer.cpp Protocol Server
Components 19
Runtime Control
- Firmware Entry
Core/Src/main.c - Main Control Loop
Core/Src/application.cpp - Process Image
Core/Src/ProcessImage/ProcessImage.cpp
Network Interface
- Python Control Unit
Core/Src/Comm/ControlUnit.py - Protocol Server
Core/Src/Comm/ProtocolServer.cpp - Binary Protocol
Core/Src/Comm/Protocol.cpp - TCP Server
Core/Src/Comm/TcpServer.cpp
Motion System
- Linear Axes
Core/Src/LinearAxis/LinearAxis.cpp - Motion Ramp
Core/Src/LinearAxis/LinearAxisRamp.cpp - Motion Timer
Core/Src/LinearAxis/MotionTimer.cpp - Stepper Drivers
Core/Src/Stepper/Stepper.cpp
Machine I/O
- Input Debounce
Core/Src/Util/Debounce.cpp - Edge Detection
Core/Src/Util/EdgePos.cpp - Vacuum Actuator
Core/Src/Actuators/Vacuum.cpp - Confetti Cannon
Core/Src/Actuators/ConfettiCannon.cpp - LED Indicators
Core/Src/Actuators/LedFlash.cpp - Software PWM
Core/Src/Util/SoftPWM.cpp
Other components
- Machine Operator
- Machine Hardware
Connections 27
- Machine Operator → Python Control Unit: operates
- Python Control Unit → TCP Server: sends commands
- TCP Server → Protocol Server: receives data
- Protocol Server → Binary Protocol: decodes messages
- Protocol Server → Process Image: reads and writes
- Process Image → Protocol Server: provides status
- Firmware Entry → Main Control Loop: starts loop
- Main Control Loop → Protocol Server: updates server
- Main Control Loop → Process Image: updates state
- Main Control Loop → Input Debounce: filters inputs
- Main Control Loop → Linear Axes: updates axes
- Main Control Loop → Vacuum Actuator: updates vacuum
- Main Control Loop → Confetti Cannon: updates cannon
- Main Control Loop → LED Indicators: updates indicators
- Process Image → Linear Axes: sets targets
- Process Image → Stepper Drivers: sets rotation
- Linear Axes → Stepper Drivers: queues steps
- Linear Axes → Motion Ramp: sets speed
- Linear Axes → Motion Timer: requests timing
- Linear Axes → Edge Detection: detects switch edges
- Main Control Loop → Software PWM: controls PWM
- Vacuum Actuator → Machine Hardware: drives pump and valve
- Confetti Cannon → Machine Hardware: fires cannon
- Stepper Drivers → Machine Hardware: drives motors
- Input Debounce → Machine Hardware: samples switches
- LED Indicators → Machine Hardware: drives LEDs
- Software PWM → Machine Hardware: modulates outputs