Friday, June 14, 2013

Stepper motors

Shortly after messing with LEDs, I started into motors.  Partly, I felt we'd need to know this for the Maker Faire project, and partly I wanted to work with steppers, because I'd done this in college but hadn't really understood them all that well then, and wanted to try again.

Project 1 was to run a stepper motor.  For this, I built up two H bridges, one based on the SN754410NE chip, and then the other on the L293DNE.  Both are referenced at http://arduino.cc/en/Reference/StepperBipolarCircuit

I'd gotten some kinda cheesy steppers and some good steppers at Halted.  The nice one is a Teco DSH40EX24A.  5.1V, 1A, 1.8-degree steps, hefty.


The cheesy one was a paddle stepper with a brass pinion on it, and it only did 7.5-degree steps.


Once I had the bridge and the wiring figured out, I needed a power supply.  I had read online (fortunately, I did the reading first) that you should not run a motor directly from the Arduino due to the current drawn by the motor.  Driving that much current from the Arduino could cause damage to the pin.  So instead, I got an old Seasonic ATX motherboard power supply working, and used its power to drive the motors.  Still, that would require a common ground wire between the systems, so much time was spent learning about circuit isolation.

I followed the Stepper and AccelStepper code in the Arduino libraries.  They were fun, but I didn't stay with them, opting instead to write my own control code.  The Stepper code makes non-atomic calls to individual pins, and that means that at some transition points in the code, you end up with three pins on instead of two, when doing full steps.  It's brief, but the purist in me says that you should just have two on, the other two off, and that's it.  The AccelStepper code was good, but by the time I started using it, I needed feedback control (i.e., hit hard limit = do not step any more).  So I rolled my own code that would set up the on/off bit values for each of the four control wires, and pushed the values over to the shift register, and then used the shift registers' atomic function for transferring data to the control wires.  And with that, I had full steps working.

Merit badges:
- Figure out the wiring of a stepper motor
- Build your own H-bridge
- Figure out how to trick an ATX motherboard power supply into thinking it's enabled so that it turns on.
- Use the Stepper library- Use the AccelStepper library
- Write code to drive multiple bits of a shift register at once, while preserving its original values in the other unaffected bits.
- Learn how optosensors work for circuit isolation

At this point in the process, I didn't know much of anything about chopping circuits, power resistors, current measurement, or microstepping (even half-stepping).

No comments:

Post a Comment