PID Motor Control System
C Programming, Embedded Systems, Motor Control, PID Control, Signal Processing, SPI, UART, PWM
Developed a closed-loop motor control system using a PIC32 microcontroller and a brushed DC motor with encoder feedback. Implemented real-time current and position control loops, trajectory tracking, and a full UART-based client interface with MATLAB.
This system featured a real-time dual-loop control structure with a 200 Hz position control loop and a 5 kHz current control loop. PWM signals were generated at 20 kHz for smooth actuation. The motor controller supported five operational modes—IDLE, PWM, ITEST, HOLD, and TRACK—providing a flexible control scheme. A MATLAB-based client interface enabled serial communication for configuration and data visualization, allowing for real-time plotting of both current and position tracking performance.
The system demonstrated accurate trajectory tracking and fast response using tuned PID gains. Both step and cubic reference trajectories were executed successfully with plotted tracking results. A built-in error metric (average position error) was used to tune gains interactively.
Through this project, I gained hands-on experience implementing dual-loop control in embedded systems and integrating peripherals like ADC and SPI for real-time sensor feedback. I also learned how to use UART-based debugging with MATLAB for client control, and the importance of a modular code structure with properly timed interrupts. These insights proved essential for building scalable and responsive embedded applications.
I can currently working on the project background for this project and, but the GitHub code for this project can be found here
If you'd like to learn more about this project or its implementation, contact me here.