A PID Ball Balance - My Return to 'Making'
- Patrick Ferrell

- Mar 9, 2020
- 3 min read
After leaving my last job as a makerspace specialist for the local public library system, I pretty much gave up coding, stopped messing about with digital fabrication, and hung up my soldering iron. While I did keep up with some woodworking for beekeeping projects, I didn't consider myself a 'maker' anymore. But over the past months, the urge to start blinking LEDs and spin motors has been creeping up and finally, I couldn't ignore it - I needed a project.
I found inspiration from a video by Electronoobs - a PID-controlled ping pong ball balance. It looked about the right level of complexity, there were some modifications I could incorporate and it would make for a nice educational piece when finished. And so I started.
Electronoobs shared the STL files from his project, but I wanted to make it my own. I haven't used a professional CAD program in a while and wanted to get started quickly, so I went with what I knew - TinkerCAD, even though it would be challenging for some of the more complex geometries of the tabs holding the wooden rails together. Fortunately, the servo motor mount and the IR sensor model were already available as STL models and I didn't need to recreate them. I also wanted to laser-cut some parts for a control panel, so I turned to Inkscape to generate the required SVG file.
When it was time to make the parts, I made reservations at the makerspaces at the Harris County Public Library where I used to work. It was strange to be a patron using the tools rather than the supervisor, but the nerves wore off quickly and the parts came out fine. (It's always a little amazing to me when the finished parts match up with the CAD drawings.)
While I was waiting on some of the electronic parts to come in, I went ahead a wrote the code for the Arduino. It wasn't that complicated - especially since there are convenient libraries available for all of the main components - the servo, IR sensor and LED strip. The PID control algorithm used is pretty basic, so even that didn't take much work. I was pleased to see that I could still program (simple) Arduino sketches.
When I had finally gathered all of the electronic parts from my parts bins or from Sparkfun and Adafruit orders, I got to work assembling and soldering. It's clear that my eyesight has worsened in the past couple of years, and glasses and a well-lit workspace are no longer optional for detailed work. I will probably need to invest in a lighted magnifier if I plan to keep this up.

At last, it was time for it all to come together. The code required a couple of tweaks, but overall it was tight. I never drew out a wiring schematic, but I knew in my head how it was supposed to work. I tried making a Fritzing drawing to document the design, but it didn't look much cleaner than the jumble of wires on the bench, even though I had simplified the schematic for clarity.

Fortunately, the diagram in my head worked, and the final project came together to work nicely. I had considered making a second version that was slightly longer, used a distance sensor with better resolution (perhaps the Adafruit VL53L0X), and replace the manual control board (which I like) with a GUI that can display the actual PID constants and other values as they are modified in real-time. But I think I'm done with this project for now - I've learned a lot and gotten some of my maker-confidence back. However, my itch for 'making' hasn't gone away and more projects are calling me.














Comments