At a glance
- Closed-loop wheel-speed control built entirely from op-amps and encoders, with no microcontroller in the loop.
- Derived the loop from the motor parameters, verified it in SIMetrix, and sized the integrator for a damping ratio of about 0.7, confirmed on the scope.
- Measured speed tracked the reference to within 0.04 V across 1.7–7.3 V; encoder-counted moves stopped within about a centimeter.
Overview
A robot car built over the semester in ECEN 2270, CU Boulder's Electronics Design Lab, with a four-person team. The core of the project was closed-loop wheel-speed control, built as analog circuits: encoders measure how fast each wheel is turning, and an op-amp feedback loop adjusts the motor drive to hold the speed an Arduino commands.
Speed control loop
Each side of the car has its own analog speed loop, built up over the semester from discrete parts. The controller is analog: there is no microcontroller in the loop, and the control law is an op-amp circuit. A monostable turns every encoder edge into a fixed 240 µs pulse, so its average voltage is proportional to wheel speed and reaches 5 V at the motor's top encoder rate of about 2.6 kHz. One op-amp subtracts that speed voltage from the reference, a second integrates the error, and the result sets the drive voltage through a MOSFET direction switch and a transistor H-bridge on a soldered driver board.
Integral-only control is enough here because the motor adds a pole of its own, so the closed loop behaves as a second-order system whose damping is set by the integrator's RC time constant. We derived it from the motor parameters, checked it in SIMetrix simulation, then built it. The final 500 kΩ and 0.5 µF give a damping ratio of about 0.7, and the measured step response showed the slight overshoot that predicts. The whole loop runs from one 8 V supply, with a 4 V virtual ground so the op-amps can swing both ways around the reference.
With the loop closed, measured speed tracked the reference to within 0.04 V from 1.7 V to 7.3 V, with no steady-state error. The Arduino sets each side's reference from a PWM pin through an RC low-pass filter. Matching the two sides took tuning: at first the car drifted left within a foot, and adding 330 Ω to the right side's speed-sensor timing resistor brought the two encoders within 2% of each other from 2 V up, so the car drove straight.


Position control
With speed regulated, the Arduino counts encoder pulses on interrupts to drive set distances and turn set angles. Comparators shift the 8 V encoder signals down to logic level first. At 960 pulses per wheel turn and a 3.25 cm wheel radius, each pulse is about 0.2 mm of travel. Each move cuts power a calibrated number of pulses early and applies a 110 ms reverse pulse as a brake, which brought straight-line stops to within about a centimeter of the target.
The difference showed in a return-to-start test: drive 2 ft, turn 180°, drive back and turn again. Timed moves ended about 3 inches from the start on every run, while the encoder-counted version came back closer and more consistently. The same code also drove a multi-leg path of straights and 90° turns around a floor grid.