For an XY-table, we need 3 controls: a motor for the X axis, a motor for the Y-axis, and a servo for the Z-axis. Controlling a servo with an Arduino is very easy, just tie the servo’s + to the Arduino’s 5V pin, the 0 to the ground pin, and the input to any PWM pin on the Arduino. The stepper motors are a different story: they need controlling logic to make sure that the motor magnets are turned on and off in the right sequence and at the required speed.
There are plenty of motor control boards around for Arduino that allow controlling many motors at the same time, but they cost as much as the Arduino itself or more, and all the advanced capabilities they offer are not really required for this project. This consideration, combined with the fact that I was interested to play around with the motor control, made me decide to attempt to make a simple controller shield myself.
The stepper motors I had for this project are Ming Jong ST-35 type motors. They are unipolar 4-phase motors. Details can be found on this page: dimensions, wiring, energizing sequence, and electrical specifications.
|Ming Jong ST-35 stepper motor|
Being 4-phase motors, driving two of them directly from the Arduino will require 8 digital pins. This is because the phase magnets will be driven directly from the pins. The wiring diagram of the motor shows that we have two times two magnets, that have a common pole: orange-red is a phase magnet, and pink-red is the other phase magnet that shares the red pole. This means that we can turn on or off a magnet with only one pin: we keep the common tied to + (or gnd), and keep the default state for the pin at the same level as the common pole (+ or gnd). The default state of the magnet is ‘off’. By changing the state of the pin, we can turn the magnet on.
The Arduino can drive about 20mA per output pin, which is not enough for the motors: the smallest version of the motors is rated at 40mA, whereas the ones I have are rated for 60mA. That means that for each output pin, we have to amplify the signal using a transistor.
The figure above shows the schematic; it has 3 blocks really: 2 blocks with 4 current amplifier circuits each, and a very simple block to route the 3 servo signals (+, gnd and PWM) to a single connector. For good measure, I decided to break out the Arduino’s reset pin as well, since the Arduino will be sitting upside-down on the shield and its own reset button will be unreachable. Component values are very simple:
- All resistors are 220 ohms
- All diodes are 1N4003
- All transistors are 2N3904
- The voltage regulator is a 7808; it should be the 1A version; the 100mA version does not deliver enough current to power the Arduino when it is not connected to a USB bus.
The pictures below show the finished board, with and without its Arduino plugged in. The motor connectors are 2x 3-pin connectors; the servo connector is another 3-pin connector.
This isn't going to in a beauty contest, but it works and is reliable
|Shield with Arduino installed and motor connected||Close-up|