Pi Train
We have an old Lionel train that we’ve kept around it the hopes of fixing it up one day. The last time my son and I were playing with it, the motor stopped working. I promised to fix it and get it running again.
Stepper Motor Engine
Servos operate on PWM signals. pigpio seemed a natural choice to generate PWM signals from my Pi. The Servo Pulse Generator seemed like a good starting point until I realized only certain servos can rotate continuously (with a bit of hacking).
I instead shifted to a stepper motor, in particular a 28BYJ-48 that I had laying around. This tutorial by Ben Akrin got me going, though when I wrote and built the script on the Pi, nothing happened. After a bit of minor debugging I figured I could re-write it in C++ (which had worked before). Soon, the stepper motor was stepping. I set it to what I thought was a “medium” speed, which ended up being slow. I could hear the internals buzzing in a way that did not sound sustainable. It also got hot. I don’t think the 28BYJ-48 is the right motor choice.
I pushed ahead with the 28BYJ-48, and purchased a set of gears and pulleys from Amazon to transfer the power from the stepper motor to the primary train gear. There were two problems. First, the inner diameter of the small gear did not match the outer diameter of the gear axle. Every attempt at mounting this centered proved futile. Second, getting the pulleys tight would have put too much force on the train gear axle.
I decided to clean by workbench, and go back to the drawing board.