Tuesday, 10 January 2012

Simple Bipolar Stepper Motor Drivers

Today I've been making some stepper motor drivers for a mini PCB mill that I want to make some time in the future. It would of cause be much easier to go out and buy some off-the-shelf drivers - but no where near as fun.

So these are the spec's I decided that I would build towards:
  • Current limited bipolar driver
  • Capable of running a 1.2A motor
  • Microstepping if possible
  • Motor voltage 24v-36v
  • Cost £5-10
A quick search on Farnell shows the Allegro A3982 driver chip not only will meet the requirements, but is also in very good supply. Lovely. The only down side is that the chip will only do 1/2 microstepping. 

Another driver of interest I came across was the A3967. It only outputs 750ma, but it microsteps to 1/8, for the same price as the A3982.

The A3982 will output 2A @ 35v, so I think that's our chip.

The control pins

Enable: Sets the state of the chip, enabled or disabled. When pulled low, the device is enabled. With pulled logic high, the device turns off all outputs and the chip is disabled. In this design there is a pull-up resistor connected so as to set the default state to disabled.

Reset: Resets the chip to it's default. Pulled low to perform a reset. A pullup resistor is added to stop the driver floating into reset mode.

MS1: Microstepping select - only 2 levels of microstepping are avialable on this particular chip, none and 1/2 stepping. A pulldown resistor is added to make it default to no microstepping. The pin is pulled high to enable 1/2 stepping.

Direction: Sets the rotation direction. When pulled low rotation is clockwise. When high, anticlockwise.

Step: When the pin state transitions from low to high a step is performed. No action is taken on a high-to-low transition. A pulldown resistor is connected to this pin.


The current is set using a function of the current sense resistors, and the voltage at Vref. Vref has a maximum voltage of 4v so to keep things nice and simple I'm going to just pop in a simple voltage divider from the +5v logic supply. The function for the calculation of the current limiting is as follows:

Imax = Vref / ( 8 * Isense)

One important factor in this will be the power dispensation of the current sense resistor Isense. We could pop a large high wattage resistor on here but that would not be ideal. We will try and pop a very low resistance precision resistor in here. Using a 0.074ohm resistor would dispel 0.7155w, so a 1W 0.047ohm resistor would be prefect here.

One very important thing to note here is that the tracks of the PCB will add their own resistance. We will try and place the Isense resistors close to the chip, using nice wide tracks so as to reduce this as much as possible. We will also need to make sure this part of the copper PCB is tinned so as to stop the oxidation of the copper.

Feeding our known values into the equation above we can calculate that our upper limit of 1.5A is achieved with a Vref of 0.564v, and to reduce the current limit, we need to reduce the Vref. We need to create a variable voltage divider that will give a maximum reading of 0.564v on the Vref pin.

With a value for R3 of 1k ohm we can hard set the maximum configurable current of the system by assigning R4 a value of 27ohm and adding a series variable resistor of 100ohm. The total resistance of the 2 resistors will vary from 27ohm to 127ohm. This will give a lower current bound of around 0.35A.

Working towards the maximum ratings of the driver board (35v 1.5A - 52.5W) we can say the value for the Isense resistor can be 0.047ohm with a reference voltage of 2.4v. The motors that I have kicking around have a resistance of 3.4ohm, so there will be a total resistance of 3.447ohm from the motor supply. So the power dispensation of the Isense resistor would be 0.72W. So 1W 0R047 precision resistors will be perfect for the job.

So here's the schematic I came up with:

The interfacing to the chip is done through a 2*3 header. This provides an interface for chip reset, enable, microstep, direction & step. Nice big screw terminals for the power input (motor voltage & logic supply) and motor outputs.

I decided to have these boards made up properly. I have used BatchPCB before and was very happy with the quality and price. They charge $2.50 per square inch for 2-sided boards, and I managed to get the layout down to 1*1.5 inch, so the boards are down to $3.75 a unit.

Here's the layout:

And the top and bottom renders:



The boards turned up in around 2 weeks. I ordered 8 units, they delivered 16. I figure that they use up any excess space on the panel with whatever fits (same thing happened last time I ordered from them), nice little surprise.

Here's the assembled board:

Once assembled I whacked on the power, a small motor and an Arduino to give it a little logic. Up and running well.

Here's the video of it running:


All in all I'm pretty happy with the A3982 driver from Allegro. With the small motor running at 10W the driver didn't seem to get hot at all. I would recommend them to anyone.

If you want to order one of these boards you can get them from BatchPCB for $3.70 here.

Tuesday, 22 November 2011


A little update, the display board  is now assembled and tested - all seems to be good (bar some sketchy soldering). 

Just finished the drilling for my new 6 digit VFD tube clock. More to follow once the driver board and assembly is done.

Sunday, 30 October 2011

Drawdio Plus!

I'm sure most of you already know what a Drawdio is (originalanother). We have used them a few times before for soldering workshops. They always go down well as they are pretty fun little things.

After (another) late nights etching and drilling earlier this year i decided I was getting pretty bored of hand making the PCB's each time so I thought it might be a pretty cleaver idea to have a batch of boards printed up. I didn't really want to just completely copy the originals, for a couple of reasons. More on that below.

So here's what I came up with...

In principal, it's much the same as the original versions of the Drawdio. Notable changes (from the Ladyada design) are the replacement of the tlc551 with an na555n chip, the addition of a line out (so it can be plugged into things) and replacement of the AAA battery with 2 CR2032 coin cells.

The board has been given some nice curvy dimensions, the ones at the top having been specifically made to accommodate the speakers obtained for the kits. The CR2032's are attached at the bottom of the PCB, and do take up quite a lot of real estate - but are pretty light.

And if you've got some skills, the speaker can be directly attached to the PCB by soldering through the big pads on the top. Whilst helping people solder these up at the Brighton Mini Maker Faire it did however become fairly obvious that it wasn't a very good idea to recommend that people do this if they haven't soldered before. The plastic casing of the speaker was completely fine, but the glue that held the small PCB on to the speaker had a tendency to melt and snap the tiny wires in the speaker.

For anyone who wants to have a go at making one themselves, the schematic above is the current version. Complete kits are available using the links below. Postage is to UK & EU only (using EU option). Proceeds go to help BuildBrighton Hackspace!

Kit contents
Zip tie
Copper Tape
Drawing pin
CR2032 Batteries

Tuesday, 31 May 2011

Noise Toys

This bank holiday Monday we ran an exciting workshop, 'Noise Toys' followed by an evening of Chip Tunes at the Pop Up Playgroup (Hectors House) in Brighton. Lots of fun, but a lot of prep work went in to making the kits for everyone. But that's boring... here are some pictures:

Copper board etching away some lovely 'Mini Space Rocker' PCB's in ferric chloride

5 of the 7 panels of 'Drawdio' kits being cut out

Kits being put together and packed ready for the workshop

The full box of kits: Drawdio's, Space Rockers & Space Rocker cap kits

Chris explaining cool nerdy tech to people

The workshop in progress