Category: hobbies

Stepper motor controller

Stepper motors are easier to control than servos, but they typically produce lower power. A number of people have built stepper motor run CNC projects, so for small or mid-size CNC control they work.

I have three bipolar stepper motors, but seven 6-wire unipolar steppers plus other unipolar steppers with other wire counts so it makes sense to design a unipolar stepper controller.

A unipolar stepper has three coils all of which get driven in the same direction by PWM signals amplified and isolated by a driver circuit. Because the drive current is always in the same direction an H-bridge is not required, rather a simpler driver can be used.

The simplest way to drive the stepper is to activate each coil in turn slowly enough that the motor has time to move a step before the next step is given. A smoother and more power efficient method called microstepping uses PWM to transition gradually from one step to the next (Microchip App Note). This requires four signals from the PIC to the driver. The PIC18F4x31 chips can output 8 PWM signals and so could drive two motors.

An intelligent driver with integrated stepping like the Allegro SLA7070MR ($7) at only requires a direction and step signal. A PIC16F88 has 16 IO lines, enough to drive 4+ unipolar steppers, and PIC18 or PIC30 can run 4+ unipolar steppers plus has PWM lines to drive additional hobby servos. The PIC18 can have a USB interface and so could run a CNC by itself.

A more robust stepper controller interfaced to an SLA70xx driver would have a RESET pin, a common one running to all the drivers, and M0 line monitoring the each stepper, and shared M1 and M2 lines running to all the drivers, so three common lines, and three per driver, so fifteen for four motors. Then figure each axis would have a pair of end stop switches, so four input lines for those, and one input line for a big STOP button. So altogether 20 IO lines for four axis control.

Two IO lines are required for USB. The PIC18F46K20 ($3), a 40-pin DIP, has 36 IO lines, four of which can be PWM and several A/D input lines. This PIC could run four axes and have separate lines for USB, in circuit programming, and still have lines available to run PWM hobby servos, input temperature, etc.

Some CNC setups have centering switches, so that could be useful. Other CNC systems use the axis end stop switch to find their initial position.

Stepper and servo motor control

So I have a box of motors scavenged from old electronic equipment. The first step was figuring out what I have.

I have four identical Pittman servo motors with attached optical encoders. They have two leads for motor control and four leads for the encoders, Vc, Gnd, quadrature A & B signals. So these motors need a sophisticated servo driver that can do PID (Proportional, Integral, Derivative) control. Basically the controller senses motor movement and direction by counting encoder tick marks and then juices the motor in the desired direction using a PWM (Pulse Width Modulation) applied driver voltage.

It’s common to run the these servos with PIC18 chips ($4.50). They have a built in quadrature encoder reader and can be programed to do PID.

Then the low power PWN signal gets run through a power driver like the L298 ($2.60). Here’s a well-documented L298 project. The L298 can driver two servo motors. A LMD18200 H-bridge ($12.50) is another power driver option, used in the Jeffery Kerr boards. Here’s a project using a PIC16 and the LMD18200 driver. The Allegro A3953 is another driver option.

Typically one PIC16 or PIC18 would control each servo motor. The recent dsPIC33 chips ($3.00) have dual encoders and should be able to run two servos. These chips came out in 2008 so I haven’t found any projects on the web describing dual servo projects.

The PIC18 and dsPIC33s are available as DIPs or as SMDs. They can interface to a computer through USB and so can be controlled directly, though connecting them to a programmable controller, a PIC, a BASIC stamp, an Arduino, etc is more common.

Hobby servos are much easier to drive and a single PIC18 can drive several, six to eight depending on the chip variation. Typically a hobby servo would not need a driver as the PWM is its control signal.

SpokePOV!

I put my spokePOV back on my bike now that it is getting dark early. Here are a few photos:

spokePOV biohazard
spokePOV ghost
spokePOV star

Maybe I’ll try something animated next…