
Trimix Analyzer
magnus188/aegir
Open-source ESP32-P4 trimix analyzer prototype for technical diving,

This is a final project for ELEC 327. Our team members include Anthony Zhang, Bilin Yang, Brandon Sung, and Setsunna Jiang.
Elec327 finalproject is an open-source printed circuit board by azhang2718, from the azhang2718/Inverted_Pendulum repository on GitHub. It is a 2-layer board of 64.6 × 48.5 mm with 21 parts on 55 nets, routed with 223 tracks and 23 vias.
It is built around the MSPM0G3507SPTR, LM1117DT-3.3 and M20-9990246. Its parts include 10 capacitors, 6 connectors, 2 resistors and 2 ICs.
This page showcases an inverted pendulum on a cart, stabilized in real time by a custom PCB running a PID controller on a TI MSPM0G3507 as part of our final project for ELEC 327 — Junior Design Lab.
Team: Anthony Zhang · Bilin Yang · Brandon Sung · Setsuna Jiang
The inverted pendulum is a classic control-theory benchmark: a rigid rod pivots freely on top of a cart that slides along a linear rail, and the controller must drive the cart left and right fast enough to keep the rod balanced upright. The upright position is inherently unstable, so any small tilt has to be detected and corrected before gravity wins.
Our implementation reads the pendulum angle from an AS5600 magnetic encoder over I²C, runs a PID loop at 200 Hz on a custom PCB, and drives a NEMA 17 stepper through a DRV8825 to move the cart along a V-slot aluminum rail.
| Component | Part | Role |
|---|---|---|
| Microcontroller | TI MSPM0G3507 | Runs the 200 Hz PID loop |
| Angle sensor | AS5600 magnetic encoder (I²C) | Reads pendulum angle (12-bit) |
| Magnet | Diametrically magnetized, 6 mm OD | Required for AS5600 to detect rotation |
| Motor | NEMA 17 stepper | Drives the cart |
| Motor driver | DRV8825 | STEP/DIR interface, 1/8 microstepping |
| Rail | V-slot aluminum extrusion + GT2 belt | Cart travel |
| Cart | V-slot gantry plate + V-wheels | Rides the rail |
| Bearings | 625RS | Pulley + idler support |
| Endstops | Limit switches (×2) | Homing on startup |
| Power | 12 V / 5 A supply | Motor + logic rail |
| Regulator | LM1117 3.3 V LDO | Logic supply |
| Pendulum | 6 mm × 300 mm steel rod | The thing being balanced |
The full PCB design is in pcb/ as a KiCad project. Open *.kicad_pro in the KiCad project manager to view the schematic and layout
A standard PID controller on the pendulum angle:
The loop runs at 200 Hz. PID gains are stored as integers scaled by 100 so all arithmetic stays in fixed-point — no FPU needed, and the timing is deterministic.
config.hEvery tunable value in the project lives in a single header. The idea is that PID tuning is iterative — you change a number, flash, test, repeat — and having every constant in one place makes that loop fast and error-free.
Things in config.h:
KP, KI, KD — PID gains (scaled ×100)MIN_STEP_RATE, MAX_STEP_RATE — motor speed bounds (prevents stall and runaway)DEADBAND — angle window where no correction is appliedENGAGE_THRESHOLD — angle within which the controller activatesGIVE_UP_THRESHOLD — angle past which the controller disengagesINTEGRAL_CLAMP — anti-windup limit on the integral termMOTOR_DIR_SIGN — direction polarityThe angle sensor is read over I²C from the raw-angle register. The driver:
Every busy-wait loop has a timeout counter that decrements and returns an error code if it hits zero. Without these, a single bad I²C transaction could lock the entire control loop — and on a pendulum that's trying to balance, a hang means it falls instantly.
ENGAGE_THRESHOLD of verticalinc/config.h as needed and reflash to tune.| Qty | Value | Footprint | References |
|---|---|---|---|
| 3 | 10uf | Capacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolder | C2, C6, C7 |
| 2 | 100nf | Capacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolder | C9, C10 |
| 2 | M20-9990246 | 240Library:HARWIN_M20-9990246 | J4, J5 |
| 1 | 0.1uf | Capacitor_THT:CP_Radial_D5.0mm_P2.00mm | C8 |
| 1 | 0.1uf | Capacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolder | C3 |
| 1 | 0.47uf | Capacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolder | C5 |
| 1 | 100uf | Capacitor_THT:CP_Radial_D5.0mm_P2.00mm | C1 |
| 1 | 10k | Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder | R2 |
| 1 | 10nf | Capacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolder | C4 |
| 1 | 47k | Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder | R1 |
| 1 | Barrel_Jack | Connector_BarrelJack:BarrelJack_SwitchcraftConxall_RAPC10U_Horizontal | J1 |
| 1 | Conn_01x04_Pin | Connector_PinHeader_2.54mm:PinHeader_1x04_P2.54mm_Vertical | J3 |
| 1 | Conn_01x05_Pin | Connector_PinHeader_2.54mm:PinHeader_1x05_P2.54mm_Vertical | J6 |
| 1 | LM1117DT-3.3 | Package_TO_SOT_SMD:TO-252-3_TabPin2 | U2 |
| 1 | MSPM0G3507SPTR | ELEC 327:QFP50P900X900X160-48N | IC1 |
| 1 | Pololu_Breakout_DRV8825 | Module:Pololu_Breakout-16_15.2x20.3mm | A1 |
| 1 | magnetic encoder | Connector_PinHeader_2.54mm:PinHeader_1x07_P2.54mm_Vertical | J2 |
It measures 64.6 × 48.5 mm and has 2 copper layers, 1.6 mm thick.
21 parts, built around the MSPM0G3507SPTR, LM1117DT-3.3 and M20-9990246. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.
From the azhang2718/Inverted_Pendulum repository on GitHub, at the commit this page was made from: the board is PCB/elec327_finalproject.kicad_pcb and its schematic PCB/elec327_finalproject.kicad_sch. PCBKit opens the board in the browser, with nothing to install.
Its repository states no licence, so its author keeps all rights: ask azhang2718 before reusing the design.

magnus188/aegir
Open-source ESP32-P4 trimix analyzer prototype for technical diving,

botblox/SPEBlox-Module-Documentation
Design files associated with SPEBlox Module for Design Integration

nischayhegde/jetson_spi_to_can_x8_breakout
A PCB board for expanding the SPI channels on Jetson Orin nano super into 8 CANfd channels. Comes with chip select logic and jetpack drivers. Supports 1Mbit per CAN channel.

SamirChamanSerna/Scorboter-ER-5-Plus_Controller
Scorboter-ER 5 Plus Controller

stevfu/eis_capstone
Utilization of Electrochemical Impedance Spectroscopy for the Detection of Drugs

TEALab-UF/bldc_esc_pcb
This repo contains the KiCAD files of the schematic and PCB layout for the TEACar BLDC motor controller

BerkeleyBikeBuilders/TelemetryComputer
FW and HW for full suspension telemetry data logger

jkleiber/six-wheel-robot
Hardware development for a six wheel mobile robot