How sagar280190/ball-balancing-pid-system works
What this project is (type + purpose)
From the file tree + README, this is a hardware-in-the-loop control system (mechatronics project) for a ball-balancing platform driven by a PID controller.
It is not a typical “web app” architecture; the “system” spans:
• PC-side Python (likely UI + serial protocol + PID logic and/or setpoints/telemetry)
• Arduino firmware controlling 3 servos (platform actuation)
• Physical plant (ball + plate mechanism)
Arduino side (embedded / real-time actuator control)
• ArduinoCodes/arduino3servoTest/arduino3servoTest.ino
• Represents firmware: servo control, reading commands from serial, writing servo PWM, possibly sending telemetry back.
PC side (control + UI + experiments)
• pythonCodes/interface.py
• Likely operator UI + serial communication with Arduino + control loop orchestration (PID update rate, setpoint selection, plotting).
• pythonCodes/data.txt
• Likely parameters (PID gains, calibration constants, offsets).
• pythonCodes/README.txt
Math / helper scripts (offline computation / calibration)
• additional codes/programmeIntermediare.py
• additional codes/solveEquation.py
• These look like engineering tools used to derive geometry, mapping, or calibration (e.g., servo angle ↔ plate tilt).
Documentation / assets
• TM 2.pdf, images/*, License.txt
• As “Documentation” (optional), not part of runtime architecture.
PC Container: Python Control & UI
• UI layer (buttons/sliders/plots)
• Control loop (PID computation)
• Serial protocol (encode/decode)
• Config/Calibration loader (data.txt)
Microcontroller Container: Arduino Firmware
• Modules inside:
• Serial command parser
• Servo kinematics mapping (if implemented there)
• Servo driver (PWM)
• Safety (limits, neutral positions)
Sensor Container (if separate hardware/software)
• If it’s a camera, include:
• Camera device
• Vision algorithm (could be Python/OpenCV; not in repo, but you must represent it if it exists in the real system)
• There is no Arduino PID file shown; the Arduino sketch name says “servo test.”
• Therefore, default assumption: PID is in Python (or at least orchestrated from Python), and Arduino is an actuator endpoint.
PC/Python components
• pythonCodes/interface.py
• “UI + Control Loop Coordinator”
• “Serial Client”
• “Parameter management”
• pythonCodes/data.txt
• “Configuration: PID gains, calibration constants”
Offline tools
• additional codes/solveEquation.py
• “Calibration/math solver (offline)”
• additional codes/programmeIntermediare.py
• “Intermediate computation / mapping tool”
Arduino components
• ArduinoCodes/arduino3servoTest/arduino3servoTest.ino
• “Serial command receiver”
• “Servo output module”
• “Servo channel 1/2/3”
Architectural patterns to explicitly highlight (because they matter here)
• Closed-loop feedback control (PID): setpoint → error → controller → actuator → plant → sensor → measurement.
• Hardware abstraction boundary: PC logic vs microcontroller real-time actuation.
• Calibration pipeline: offline math scripts → constants → runtime config (data.txt) → controller/firmware.
• Signal type (e.g., “(x,y) position”, “servo angles”, “PWM”)
• Rate/latency constraints (e.g., 30 Hz camera, 50–100 Hz control loop, serial baud rate)
• Units (degrees, mm, normalized [-1,1])
• Failure modes (optional but valuable): dropped serial frames, sensor noise, servo saturation.
What to be explicit about given this repo’s gaps
• A “Ball position measurement” component anyway.
• It as External / Not in repo unless you confirm it exists elsewhere.