Motor–Generator Control Bench
A personal project to learn control properly: a DC motor coupled to a generator, with switchable resistive loads as known disturbances, to compare PI, PI with a Kalman filter, and LQR with Kalman load feedforward. The simulator is done; the hardware is being wired.
- control loop on an ESP32
- 200 Hz
- control loop on an ESP32
- controllers compared on the same load step
- 3
- controllers compared on the same load step
- no hardware numbers yet, by design
- Sim only
- no hardware numbers yet, by design
Why
The hexapod showed me that I could tune a system by hand but could not explain why it worked, and control was my weakest area at university. This bench is how I am closing that gap, together with Steve Brunton's Control Bootcamp and MIT 6.241J Dynamic Systems and Control.
Research question
When the load switches, how much of the improvement comes from filtering the measurements, and how much from estimating the load and feeding it forward?
Setup
- A 12 V geared DC drive motor coupled shaft to shaft to a generator through a flexible coupling
- Zero to three switchable 10 Ω resistors as the generator's load: known, repeatable disturbances
- An ESP32 running the loop at 200 Hz, with an STM32 Nucleo-G474RE on the bench as well
- Controllers: PI; PI with a Kalman filter; LQR with a Kalman filter and feedforward of the estimated load

Simulator
A local web app models the bench and its 1,320-count encoder, stores every run in SQLite, and exports in the firmware's CSV format, so the analysis scripts will run unchanged on real data. It comes with a 21-page guide to the physics and each controller. In simulation the improvement came mainly from the load feedforward, not from the filter alone.
Status and limits
The simulation uses placeholder plant parameters, so its numbers are a hypothesis, not a result. Next: wire the current and speed sensing, log everything on one clock, identify the plant from step and load tests, then run the same three controllers on the bench and compare the speed dip and recovery time with the simulation. I will report hardware numbers only after the bench has run them.
The interactive loop on this site's homepage is a toy version of the same idea.