Sunday, May 6, 2012
First off, I had to see if it would even work. I built a prototype out of acrylic with a rail from an old printer, a couple of little steppers and an Adafruit motor shield. Using a couple of nested loops, I was able to draw all kinds of spiral and geometric patterns on a pvc tube. Here's the code:
I learned a lot. First of which was that none of it could be used on the big machine. The Adafruit motor shield is a great little device and a wonderful learning tool, but it will only handle little motors (600mA). It also has its own Arduino libraries with step, speed and direction commands, that don't translate to bigger drivers that have step and direction inputs. That being said, for small projects, it's a very cool device -- if you're working with motors with Arduino, absolutely get one.
The next thing I learned was what odd devices stepper motors are, and how inconsistent the available data seems until you understand how they work. I'd salvaged steppers out of several old printers, but was never able to make them work. They would miss steps, rattle back and forth, get hot and smell bad. And I was mystified why, when if lucky enough to find a motor with an actual datasheet, it would say something like "2.6 v, 3.4Ohms", but the power supply in the printer it came out of would be putting out 36v, 42v or some other crazy voltage. Huh? (anyone that actually knows something about this may be rolling your eyes right now, but this was all new to me.) I wish I'd found this simple explanation -- it would have saved me lots of time: Stepper motor specs typically give resistance and current values. Voltage, if given, is to calculate current. As long as the current is kept at or below that value, the voltage can increase. A lot. (eye-rollers: please correct me if I got that all wrong, I'm still working on it...) In fact it's assumed that steppers will run at many times the spec'ed voltage. For instance, the steppers I ended up using are rated at 3A, .92Ohms. That comes out to 2.76v. Seems low, right? It is, my power supply puts out 40v, but the driver restricts current to the rated 3A.
The Adafruit motor shield doesn't have current limiting, so you need to use motors that pull less than 600mA. The little NEMA 17 motors at Sparkfun and Adafruit are great for this.