spacerDoing it Better

After I chewed through the reference design by MicroChip (MC) I began to understand where the previous designs had fallen short.

In each design there was a disconnect between the PIC, which generated stepping patterns, and the driver chips which created current. The MC design rolls the stepping function and the current chopping into one chip, a dsPIC33. This allows the dsPIC to take a more holistic approach to current control.

At very low speeds, a stepper motor takes discrete steps from one angular position to another. It comes to a complete stop between steps. But like any 'springy' system, the rotor will have a tendency to wobble around the new position, until it finally comes to rest.

The MC design uses a PI (proportional Integral) controller to set the current. The controller is tuned so that the rotor eases into it's new position rather than snapping into it. This greatly reduces the wobbling.

As the motor speed increases we reach a situation where the motor is commanded to a new position while its rotor is still mid wobble. The behaviour of the motor will depend on whether the rotor is moving toward or away from the target position when the next step command arrives. This can lead to erratic behaviour at certain speeds (resonance).

Because the MC design eliminates most of the wobbling, resonance effects are practically eliminated as well.

Once we reach speeds where the rotor never comes to a rest between steps, the stepper motor starts to behave like a synchronous motor. At this stage, the timing of the current peaks in the coils is crucial. This is a complicated situation. The coil inductance makes it progressively harder to push the required current through the coils as the speed increases. This also means that the current peak lags behind the commanded value. Eventually the current 'pushes' come too late and the motor goes erratic and stalls.

In addition to the motor coil inductance there is an effect known as back EMF. The spinning motor acts as a generator that creates a voltage that opposes the applied voltage. While the inductance effects can be seen in a motor that has its rotor locked into position, the back EMF only occurs when the motor is spinning. This back EMF distorts the current peaks being generated in the coils and can cause the motor to stall.

The PI controller in the MC design can react to growing EMF as speeds increase and adjust its behaviour. At sufficiently high speeds, the back EMF actually becomes helpful and reinforces the driving current. MC offers a test board that you can buy and play with.

So with great anticipation I set out to build my interpretation of their design. Instead of discrete MOSFETs to build the power section, I decided to use the venerable L298 since I had a tube full of them and the 2A current limit was sufficient for the motors I planned to use. Also I split their reference design in half. I removed the USB support which was integrated because I planned to add that back in via a future project.

Prototype dsPIC33 controller |
Prototype dsPIC33 stepper motor driver

The prototype was created using the toner transfer method. The dangling wires are test points. The design is double sided so it was a bit tricky. There were a significant number of vias that I had to manually bridge using short pieces of wire. Note the patch panel in the center of the board. This exists because I was having trouble routing all the required lines.

This was also my first foray into surface mount. I decided to stick to the larger 1206 sized passives and the SOIC-28 for the dsPIC. Once the design proved its worth I put extra effort into the routing and came up with a PCB that required no patching.

PCB manufactured by Gold PheonixI created gerber files from the design using dipTrace and sent them off to Gold Pheonix in China. A little under two weeks later I received a small bundle of 19 boards that looked like this.

Since then I've populated 9 of these boards and they all work beautifully. I have three of these running my 2nd CNC. The axis zip along at 45 inches/min (or 13.5 revs/sec). At 24V they can hit 18 revs/sec but don't have quite enough torque left to work reliably so I backed them off.

Four more are destined for my next 'secret' project. And I've reserved a couple for further software development and experimentation.

Next Section: Building the Board