Stamp II 3x Stepper Motor Rs-232 Driver

Google+ Pinterest LinkedIn Tumblr +

This application note demonstrates simple hardware and software techniques for driving and controlling 3 common four-coil stepper motors by one Stamp II board. The below text / work is a modified version of Parallax, Inc. single axis Stamp I driver. The program is adjusted to run 3 motors simultaneously on a Stamp II board. The board as been tested succesfully with stepper motors from RS (Serial no. 440-436).

Unlike ordinary dc motors, which spin freely when power is applied, steppers require that their power source be continuously pulsed in specific patterns. These patterns, or step sequences, determine the speed and direction of a stepper’s motion. For each pulse or step input, the stepper motor rotates a fixed angular increment; typically 1.8 or 7.5 degrees. The fixed stepping angle gives steppers their precision. As long as the motor’s maximum limits of speed or torque are not exceeded, the controlling program knows a stepper’s precise position at any given time. Steppers are driven by the interaction (attraction and repulsion) of magnetic fields. The driving magnetic field rotates as strategically placed coils are switched on and off. This pushes and pulls at perma-nent magnets arranged around the edge of a rotor that drives the output shaft.

Figure 2. Schematic for the serial 3x stepper motor controller.

When the on-off pattern of the magnetic fields is in the proper sequence, the stepper turns (when it’s not, the stepper sits and quivers). The most common stepper is the four-coil unipolar variety. These are called unipolar because they require only that their coils be driven on and off. Bipolar steppers require that the polarity of power to the coils be reversed. The normal stepping sequence for four-coil unipolar steppers appears in figure 3. There are other, special-purpose stepping sequences, such as half-step and wave drive, and ways to drive steppers with multi-phase analog waveforms, but this application concentrates on the normal sequence. After all, it’s the sequence for which all of the manufacturer’s specifications for torque, step angle, and speed apply.

If you run the stepping sequence in figure 3 forward, the stepper rotates clockwise; run it backward, and the stepper rotates counterclockwise. The motor’s speed depends on how fast the controller runs through the step sequence. At any time the controller can stop in mid sequence. If it leaves power to any pair of energized coils on, the motor is locked in place by their magnetic fields. This points out another stepper motor benefit: built-in brakes.

Many microprocessor stepper drivers use four output bits to generate the stepping sequence. Each bit drives a power transistor that switches on the appropriate stepper coil. The stepping sequence is stored in a lookup table and read out to the bits as required.

This design takes a slightly different approach. First, it uses only two output bits, exploiting the fact that the states of coils 1 and 4 are always the inverse of coils 2 and 3. Look at figure 3 again. Whenever coil 2 gets a 1, coil 1 gets a 0, and the same holds for coils 3 and 4. In Stamp designs, output bits are too precious to waste as simple inverters, so we give that job to two sections of the ULN2003 inverter/driver. The second difference between this and other stepper driver designs is that it calculates the stepping sequence, rather than reading it out of a table. While it’s very easy to create tables with the Stamp, the calcula-tions required to create the two-bit sequence required are very simple. And reversing the motor is easier, since it requires only a single additional program step. See the program listing in the APPENDIX below.

How it works.
The stepper controller accepts commands from a termi-nal or PC via a 38400-baud serial connection. (no parity, 8 databits and 1 stop bit). When power is first applied to the Stamp, it sends a prompt to be displayed on the terminal screen. The user types a string representing the direction (+ for forward, – for backward), number of steps, and at last step delay (in milliseconds), like this: cmd>+500 +100 -100 20 As soon as the user presses enter, return, or any non-numerical charac-ter at the end of the line, the Stamp starts the motor running. When the stepping sequence is over, the Stamp sends a new cmd> prompt to the terminal. The sample command above would take about 10 seconds (500 x 20 milliseconds). Commands entered before the prompt reap-pears are ignored.

On the hardware side, the application accepts any stepper that draws 500 mA or less per coil. In Figure 2, the schematic shows the color code for an Airpax-brand stepper, but there is no standardization among different brands. If you use another stepper, use Figure 2 and an ohmmeter to translate the color code. Connect the stepper and give it a try. If it vibrates instead of turning, you have one or more coils connected incorrectly. Patience and a little experimentation will prevail.

(1) is a RS-232 Terminal Emulator. The (2) button open / close communication for the terminal. (3) is RS-232 settings. (4) is this page. In panel (5) you can enter motor settings, such as steps per revolution and speed per step. Also incremetal steps can be entered. Note that these values are entered for each motor #. All of the settings are stored when terminating the module. The buttons in panel (6) enables you to move incremental steps according to panel (5) for each motor. (7) is statusbar for runtime messages.

APPENDIX
Use the stamp2.exe to load this program into Stamp memory! The programming RS-232 plug’s pin connections are shown in Figure 2.
Stamp II 3Mx program listing
‘Program to run 3 stepper motors
‘By F. Sigernes and D. A. Lorentzen

Share.

About Author

Leave A Reply