Skip to the content
PCBKitNew board
2 layers64.6 × 48.5 mmElec327 finalproject, the printed circuit board in 3D

Elec327 finalproject

azhang2718/Inverted_Pendulum

This is a final project for ELEC 327. Our team members include Anthony Zhang, Bilin Yang, Brandon Sung, and Setsunna Jiang.

Size
64.6 × 48.5 mm
Copper layers
2
Thickness
1.6 mm
Parts
21
Nets
55
Pads
118
Tracks, vias
223, 23
Routed
Yes
KiCad
KiCad 9.0 (file 20241229)
Created
5 May 2026
Updated
11 May 2026

Overview

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.

Main components

3

README

README.md

Inverted Pendulum Control System

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


Overview

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.


Hardware

ComponentPartRole
MicrocontrollerTI MSPM0G3507Runs the 200 Hz PID loop
Angle sensorAS5600 magnetic encoder (I²C)Reads pendulum angle (12-bit)
MagnetDiametrically magnetized, 6 mm ODRequired for AS5600 to detect rotation
MotorNEMA 17 stepperDrives the cart
Motor driverDRV8825STEP/DIR interface, 1/8 microstepping
RailV-slot aluminum extrusion + GT2 beltCart travel
CartV-slot gantry plate + V-wheelsRides the rail
Bearings625RSPulley + idler support
EndstopsLimit switches (×2)Homing on startup
Power12 V / 5 A supplyMotor + logic rail
RegulatorLM1117 3.3 V LDOLogic supply
Pendulum6 mm × 300 mm steel rodThe 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


Software

Control loop

A standard PID controller on the pendulum angle:

  • P — proportional response to current tilt
  • I — corrects for slow drift / sensor offset
  • D — damps oscillation by reacting to angular velocity

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.h

Every 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 applied
  • ENGAGE_THRESHOLD — angle within which the controller activates
  • GIVE_UP_THRESHOLD — angle past which the controller disengages
  • INTEGRAL_CLAMP — anti-windup limit on the integral term
  • MOTOR_DIR_SIGN — direction polarity

I²C driver (AS5600)

The angle sensor is read over I²C from the raw-angle register. The driver:

  1. Waits for the bus to be idle
  2. Flushes the TX FIFO
  3. Writes the target register address
  4. Reads back two bytes → 12-bit angle

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.

Startup sequence

  1. Init peripherals (I²C, timers, GPIO)
  2. Home the cart against the limit switches and zero the step counter
  3. Move cart to center of the rail
  4. Wait until the pendulum is within ENGAGE_THRESHOLD of vertical
  5. Enable PID loop

Building & Flashing

  1. Install Code Composer Studio (or use the TI Arm Clang toolchain directly).
  2. Open the firmware project, build, and flash via the SWD header on the PCB.
  3. Adjust values in inc/config.h as needed and reflash to tune.

Parts

21
QtyValueFootprintReferences
310ufCapacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolderC2, C6, C7
2100nfCapacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolderC9, C10
2M20-9990246240Library:HARWIN_M20-9990246J4, J5
10.1ufCapacitor_THT:CP_Radial_D5.0mm_P2.00mmC8
10.1ufCapacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolderC3
10.47ufCapacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolderC5
1100ufCapacitor_THT:CP_Radial_D5.0mm_P2.00mmC1
110kResistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolderR2
110nfCapacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolderC4
147kResistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolderR1
1Barrel_JackConnector_BarrelJack:BarrelJack_SwitchcraftConxall_RAPC10U_HorizontalJ1
1Conn_01x04_PinConnector_PinHeader_2.54mm:PinHeader_1x04_P2.54mm_VerticalJ3
1Conn_01x05_PinConnector_PinHeader_2.54mm:PinHeader_1x05_P2.54mm_VerticalJ6
1LM1117DT-3.3Package_TO_SOT_SMD:TO-252-3_TabPin2U2
1MSPM0G3507SPTRELEC 327:QFP50P900X900X160-48NIC1
1Pololu_Breakout_DRV8825Module:Pololu_Breakout-16_15.2x20.3mmA1
1magnetic encoderConnector_PinHeader_2.54mm:PinHeader_1x07_P2.54mm_VerticalJ2

Questions

How big is the Elec327 finalproject PCB?

It measures 64.6 × 48.5 mm and has 2 copper layers, 1.6 mm thick.

What parts does the Elec327 finalproject use?

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.

Where can I download the Elec327 finalproject KiCad files?

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.

Can I use the Elec327 finalproject design in my own project?

Its repository states no licence, so its author keeps all rights: ask azhang2718 before reusing the design.

Similar boards

  • 4 layers46.4 × 99.8 mmTrimix Analyzer, the printed circuit board in 3D

    Trimix Analyzer

    magnus188/aegir

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

    171 parts14
  • 4 layers65 × 39.1 mmBB SPEM A-1 Breakout, the printed circuit board in 3D

    BB SPEM A-1 Breakout

    botblox/SPEBlox-Module-Documentation

    Design files associated with SPEBlox Module for Design Integration

    17 parts2MIT
  • 4 layers81 × 80 mmBreakout, the printed circuit board in 3D

    Breakout

    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.

    145 parts1
  • 2 layers106.7 × 38.1 mmScorbot Simple Breakout Board, the printed circuit board in 3D

    Scorbot Simple Breakout Board

    SamirChamanSerna/Scorboter-ER-5-Plus_Controller

    Scorboter-ER 5 Plus Controller

    15 parts1AGPL-3.0
  • 2 layers102 × 45 mmHELPStat V2, the printed circuit board in 3D

    HELPStat V2

    stevfu/eis_capstone

    Utilization of Electrochemical Impedance Spectroscopy for the Detection of Drugs

    51 parts1MIT
  • 4 layers120.1 × 59.2 mmTEACar motor controller, the printed circuit board in 3D

    TEACar motor controller

    TEALab-UF/bldc_esc_pcb

    This repo contains the KiCAD files of the schematic and PCB layout for the TEACar BLDC motor controller

    145 parts1
  • 2 layers25.7 × 44.8 mmTelemetryComputer, the printed circuit board in 3D

    TelemetryComputer

    BerkeleyBikeBuilders/TelemetryComputer

    FW and HW for full suspension telemetry data logger

    23 partsApache-2.0
  • 2 layers26.7 × 21.6 mmUsb webcam interface, the printed circuit board in 3D

    Usb webcam interface

    jkleiber/six-wheel-robot

    Hardware development for a six wheel mobile robot

    3 parts