Verilog · Altera DE2-115 · Nios II · PID

Floaty McFloatFace

A closed-loop PID on an FPGA holding a steel ball in mid-air: an electromagnet above, an inductive sensor below, and a VGA trace of the setpoint.

A steel ball held in the air beneath an electromagnet
The ball, levitating. Photograph from the project write-up.

Can you build a sufficiently quick enough control system that can levitate a ball, any ball by pulling it just enough using an electromagnet? A TI LDC1000 inductive sensor underneath reports where the ball is — nonlinearly, because it is measuring metal through inductance and not elevation. And an Altera DE2-115 does the sampling, filtering and PID arithmetic on the sensor’s own sample clock, holding the ball at a setpoint by changing the duty cycle of an electro-magnet.

Doing it in hardware buys two things a microcontroller would not give us: the PID runs at the edge of every sensor sample, and the PWM frequency stays steady while the duty cycle moves, because the calculation never gets in the way of the output. The Nios II does the jobs that want a CPU instead — drawing sensor value and duty cycle on a VGA screen, and letting the PID constants change over serial without any recompile.

The sensor talked SPI, and we cheated politely: rather than configuring the LDC1000’s many registers from scratch, we sniffed the transaction already running between the chip and its own evaluation board. Fewer pins, fewer headaches, and test points that TI had helpfully left out for exactly this.

Built with Ryan Land and Nathan Spallone for ECE 5760 at Cornell.