stepper: arduino driven motor

So, first step (excuse the pun) is to get the arduino to drive a stepper motor. ultimately there will obviously be two (one for the altitude axis, the other for the azimuth).

i got both these steppers from Active Robots – don’t be put off by the name, it’s a decent shop. They are Sanyo Denki 103H546-0440. For further details see the datasheet. there’s no space here to run through the operation of a stepper motor, but there are plenty of guides around. wikipedia is as good as any.

now time to wire it up. this was my first set-up:

The two small chips running in parallel are ULN2003A Darlington Arrays (£0.76 each at Maplins, order code AD93B). I needed two in parallel because the stepper motor draws 1 amp per phase but the ULN2003A can only handle 500mA.

So, the second wiring was as follows – just one darlington array (a ULN2083 – see the uploaded datasheet) but again with each input /output running in parallel (same 500mA restriction per channel):

This is my attempt at a schematic – it was ‘after the event’ and may be completely wrong! If anyone wants to amend it, the ‘eagle schematic file’ is here.

The sketch I tested this set up with is below. The important bit is to get the wiring in the correct order. Here the pins on the arduino fire as follows: 2, 4, 3, 5 (not 2,3,4,5). From the three pictures above, you can see that those pins are wired as follows: 2 (blue), 3 (yellow), 4 (green) and 5, (red). That means that the coils on the stepper motor are excited in the following order: Blue, Orange (wired to Arduino as Green), Yellow, Red.

/*
* Stepper Test for Mount
*
* very minor hacking from the arduino example sketch.
* see also here:
* http://www.arduino.cc/en/Reference/Stepper
*/

// include the stepper motor library
#include <Stepper.h>

// Defines the number of steps as 200
#define STEPS 200

// create an instance of the stepper class, specifying
// the number of steps of the motor and the pins it’s
// attached to
Stepper stepper(STEPS, 2, 4, 3, 5);

void setup()  // the initial setup
{
// set the speed of the motor to 30 RPMs
stepper.setSpeed(10);
}

void loop() // the main loop
{
// step 100 steps
stepper.step(100);

// wait 2 seconds
delay(2000);
}

That’s it. Worked like a dream.

Ben

post a comment...

you must be logged in to post a comment.