← All projects

FPGA PID Robot

A robot that holds an exact distance from a moving wall, with the PID loop running on FPGA fabric.

LabVIEW FPGA block diagram, ultrasonic distance measurement feeding the PID loop
LabVIEW FPGA block diagram, ultrasonic distance measurement feeding the PID loop
Status
complete
When
Feb - May 2026
Course
BME, 4th semester
Worked?
Yes, live demo

Role BME coursework. I wrote the FPGA sensor and motor drivers, the PID loop and the front panel.

A closed-loop PID controller built directly on the FPGA half of an NI myRIO. It reads an ultrasonic sensor and drives two steppers so the robot holds a distance you set from a wall, even when the wall moves. LabVIEW, down to the fixed-point maths.

The task

Take a pre-built robot with an ultrasonic sensor and two stepper motors, and make it hold a precise distance from a wall, including a moving one. The catch: the control loop had to live on the FPGA half of an NI myRIO, not on the processor.

Why that is harder than it sounds

FPGA fabric has no native division, so the PID maths had to be built in fixed-point by hand. There were no ready-made blocks for either end of the chain either, so I wrote those too: the ultrasonic sensor’s trigger and echo timing, and the step and direction pulse generation for the drivers, both clocked on the fabric.

The real-time side hosts a deliberately minimal panel: setpoint, gains, a live distance plot and a stop button.

Result

It worked, live, and re-converged whenever the wall moved. First real contact with FPGA development, and a good lesson in how different programming feels when your code is gates and clock ticks instead of instructions.

More

01 photos