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
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.