Care to step with me a moment? For I have stepped upon a splendid stepper driver for the stepping connoisseur!

In this project I’ve built a MegunoLink interface panel to move a linear stage with a stepper motor. I used an X-NUCLEO-IHM03A1 shield to drive the motor and an Arduino Uno to run the show.

X-NUCLEO-IHM03A1 and linear actuator with MegunoLink interface

I wanted to move the stage quickly so I got the largest stepper I could find from Open Builds and a grunty X-NUCLEO-IHM03A1 stepper driver shield to run it. It works with the Arduino Uno, drives motors up to 10A and has a load of features for around $11 from Digikey. The NUCLEO stepper driver is quite a bargain!

I couldn’t find an Arduino library for the X-NUCLEO-IHM03A1 shield, but the L6470 stepper driver is quite similar. So I was able to adapt SparkFun’s AutoDriver library to work with the Nucleo shield and the powerSTEP01 Arduino library was born.

Since the powerSTEP01 and SparkFun’s AutoDriver library are so similar, the MegunoLink interface panel I built should work with SparkFun’s AutoDriver board with only with minimal changes. Post a message in our forum if you’ve any trouble getting it going.

Read-on to learn about the interface panel I built to test the driver and control the stage from MegunoLink and the library itself!

Built with MegunoLink

The desktop stepper driver control interface was made using MegunoLink, our companion software for Arduino Developers.

MegunoLink lets you visualize serial data with graphs and tables, and quickly build user interfaces for your Arduino projects.

Download MegunoLink and give it a go for your next project!

The X-NUCLEO-IHM03A1: a super stepper shield

X-NUCLEO-IHM03A1 powerStep

An X-NUCLEO-IHM03A1 high power stepper driver board (right) next to SparkFun’s Uno compatible RedBoard (left)

There are 3 common ways to control stepper motors from an Arduino:

  1. Direct drive of the stepper coils. Cheapest hardware, but hardest to program. You have to turn each coil on and off at just the right time to make the motor work.
  2. Step/direction control. Easiest to program for simple control; you just supply step and direction signals. Harder to get smooth acceleration and motion going though.
  3. Separate microcontroller to look after the stepper. The microcontroller smoothly speeds up and slows down the motor and keeps track of its position. We just send it commands like take 1000 steps.

The X-NUCLEO-IHM03A1 high power stepper driver shield fits option 3.

The SPI interface on the X-NUCLEO-IHM03A1 board lets the NUCLEO’s micro handle the motor while the Arduino is busy doing other things. For example, the Arduino can tell the NUCLEO to move the motor 3,100 steps. Then get on with processing serial commands, making sensor measurements or controlling a LED strip. The NUCLEO will take care of starting the motor, counting each step and stopping the motor when it gets to the right place.

So although its a little harder to make it take a single step with the X-NUCLEO-IHM03A1 than the other options, it is hardly any more difficult to have it accelerate smoothly to a constant speed, run for 2,000 steps then slow to a gentle stop.

This makes the NUCLEO an asynchronous driver because the program on the Arduino can tell the stepper micro to do something then go off and do its own thing. The other options normally require the Arduino program to run in step with the motor.

You could use the X-NUCLEO-IHM03A1 for nearly anything with a stepper motor in it. It supports:

  • large motors up to 10A, 50V
  • 1/128 microstepping
  • automatic acceleration and deceleration
  • digital power control
  • over-current, over-temperature, under-voltage protection

The boards can even be stacked to control many stepper motors from a single Arduino. What more could you want?

In this case I’m using it atop a SparkFun RedBoard to drive the NEMA23 stepper motor on our linear actuator from OpenBuilds C-Beam™.

The MegunoLink Stepper Driver Interface Panel

Screenshot of the MegunoLink Stepper Control Interface powerSTEP01 variant

The MegunoLink Stepper Control Interface for the powerSTEP01

I built a MegunoLink stepper interface panel and matching Arduino sketch for this project. So you can control the motor manually and try out different configurations without having to write any code.

Clicking buttons in the interface panel sends serial commands to the Arduino sketch. The Arduino talks to the X-NUCLEO-IHM03A1 to carry out these commands.

Building interfaces in MegunoLink is as simple as dropping controls into the designer and assigning the serial command you’d like sent. For detailed guides on MegunoLink interfaces, check out the following links:

Build an interface panel for your Arduino sketch

I’ve used MegunoLink’s expressions to automatically convert between millimeters and steps of motion. The conversion factor is set in the “General Configuration” section. And it is applied in each message sent to the Arduino. For example, the motor position is set with the command:
!SetPos [nudSetPositionSteps.Value*nudStepsMM.Value]\r\n

The 8 mm lead on the lead screw of the OpenBuilds C-Beam™ Linear Actuator run by a 1.8° step motor at 1/128 microsteps gives: (360°/1.8°) * 128 microsteps / 8 mm = 3200 microsteps/mm. This value is stored in the nudStepsMM number control and its value used in the expression above (nudStepsMM.Value).

powerSTEP01 Arduino Library

The powerSTEP01 Arduino library is based on SparkFun’s AutoDriver library for the L6470, another stepper driver that uses SPI commands. With a maximum drive current of 3A, the L6470 is more suitable for smaller stepper motors than the X-NUCLEO-IHM03A1.

X-NUCLEO-IHM03A1 and AutoDriver boards

An X-NUCLEO-IHM03A1 stepper driver board next to a SparkFun AutoDriver

Changes to the AutoDriver Library

The main changes made to the library to suit the powerSTEP01 rather than the L6470 were the length of some registers, and a different method of setting of the slew rate.

I also had to change the over-current implementation. The NUCLEO board has a voltage-limit (?!!) for over-current protection while the L6470 has a current setting.

To get an approximate setting for the voltage-limit setting on the NUCLEO board you can use this equation:
over-current limit [A] = ((OCThreshold + 1)*31.25mV/RDSon)*(KVAL/255)

where:

  • RDSon is the drain-source resistance of the motor drivers FETs. It is between 16 to 23 mOhm according to the NUCLEO’s datasheet
  • KVAL is the power level you set in the later motor configuration section

X-NUCLEO-IHM03A1 powerSTEP01 Library Functions

I’ve kept the function names the same in the powerSTEP01 library as the the AutoDriver library wherever possible. The two libraries are pretty much interchangeable with only minor changes needed to switch between the two. This will make it easier to write Arduino programs that will work with either stepper driver.

More details, including data types, can be found in the main library header file powerSTEP01ArduinoLibrary.h. Here is a list of the motor movement functions that the library implements:

Command Parameters Action
run() direction, speed Runs continuously at the specified speed in the specified direction until given a stop command
move() direction, distance Moves the specified relative distance in the specified direction and stops
goTo() position Moves to the specified absolute position via the shortest direction
goToDir() direction, position Moves to the specified absolute position via the specified direction
goUntil() action, direction, speed Runs continuously at the specified speed in the specified direction until the limit switch is triggered, can set home position
releasesSw() action, direction Runs continuously at a low speed in the specified direction until the limit switch is released

Several commands are available for stopping the motor as shown in the table below. softStop() is good for non-emergency stops while hardHiZ() is great at stopping everything if things go wrong; it instantly shuts off power to the motor.

powerSTEP01 Arduino library functions to stop the stepper motor:

Command Parameters Action
softStop() none Decelerates and holds the motor stationary
hardStop() none Immediately holds the motor stationary
softHiZ() none Decelerates and cuts power to the motor
hardHiZ() none Immediately cuts power to the motor

Configuring the Motor

X-NUCLEO-IHM03A1 powerSTEP01 configuration

The powerSTEP01 configuration group of the MegunoLink Stepper Control Interface

If you’re using a different motor to the one in the store bought OpenBuilds C-Beam™ Linear Actuator then you’ll first need to configure the running and holding power levels to avoid damaging or underutilising your motor.

I recommend lowering the holding power and clicking “Soft Stop” to energize the motor. Then you can increase the power level slowly while monitoring the motor temperature without having to make the motor move all the time.

If you want as much torque or speed as you can, find the point where the motor doesn’t get ‘too hot’ over time and use this as your running power. I typically consider ‘too hot’ to be a bit less that ‘too hot touch’ to but find whatever point you’re comfortable with. Set the final value of the holding power as however much you need, if there’s no forces the motor is holding against when resting then a half or a quarter of the running power should be fine.

If you’re happy with lower torque and speed then go low. You’ll have less noise, less chance of blowing your motor, and a lower power bill.

Set an over-current threshold as instructed in the interface for peace of mind and protection against shorts. If you don’t care for that kind of thing then set it to the maximum value to effectively disable over-current protection.

X-NUCLEO-IHM03A1 powerSTEP01 Library Example

A example sketch named powerSTEP01SimpleTest.ino is included in the powerSTEP01 library.

This simple example illustrates configuration of the library, in the setup function and runs the motor back and forwards 2,000 steps each way, in the loop function.

Hardware

X-NUCLEO-IHM03A1

The X-NUCLEO-IHM03A1 by STMicroelectronics is available from several electronics distributors as detailed on its ST product page. As of writing those operating worldwide include STMicroelectronics X-NUCLEO-IHM03A1 at Digi-Key for USD$10.64 and STMicroelectronics X-NUCLEO-IHM03A1 at Mouser Electronics for USD$15.76.

You should be able to use the interface and matching Arduino sketch with the SparkFun AutoDriver – Stepper Motor Driver (v13) with little difficulty. Just change the library in the sketch to the SparkFun AutoDriver library, change the over-current threshold slider in the interface to have a maximum value of 15 rather than 31 and change the slew-rate constant in the setup of the sketch. I think that should do it, compare the datasheets and examples if you have trouble.

Power Supply

You’ll need to find a power supply suitable for your motor to connect to the X-NUCLEO-IHM03A1. An old laptop power supply may be a good option if you find one with an output voltage in the range of your motor and not above the 50V of the board. The current is controlled by the powerSTEP01 so a power supply with an output current higher than the motor needs should be fine.

OpenBuilds C-Beam™ Linear Actuator

The C-Beam™ Linear Actuator used in this project is an open source design anyone can build themselves if they want. Those people a wanting a more convenient option can buy all the parts in a C-Beam™ Linear Actuator Bundle from the OpenBuilds Parts Store in one of three lengths, either with or without the NEMA 23 Stepper Motor also available separately.

OpenBuilds linear actuator

A store bought OpenBuilds C-Beam™ Linear Actuator with added limit switch

Stepper Interface Panel Software

To use the stepper interface panel to drive a stepper motor you’re going to need a bunch of software:

  • Arduino IDE: the Arduino software
  • MegunoLink: our Arduino companion software that hosts the interface panel
  • MegunoLink Arduino library: a standard Arduino library that includes support for handling serial commands, saving data to the eeprom and plotting data with MegunoLink
  • powerSTEP01 Arduino library: the library, described above, that interfaces to the X-NUCLEO-IHM03A1 stepper driver. This library includes the
    MegunolinkdriverInterface powerSTEP-1 sketch, the Arduino sketch that MegunoLink uses to control the stepper motor from the interface panel.

powerSTEP01 Arduino Library

You can find the stepper control library on GitHub: powerSTEP01 Arduino Library on GitHub.

Download the library and install it into a folder named powerSTEP01/ in the libraries folder of your Arduino installation. After you restart the IDE, the powerSTEP01 library will be available to your program.

Open the Arduino sketch which communicates with MegunoLink from the Arduino IDE’s File→Examples menu. The example is named MegunolinkDriverInterface_powerSTEP-1_.

You’ll need to install MegunoLink’s Arduino library before you’ll be able to compile the sketch. This library is most easily installed by setting up MegunoLink’s Arduino integration. The powerSTEP01 interface panel uses MegunoLink’s Arduino library to:

  1. Process serial commands sent from MegunoLink using the Serial Command Handler library.
  2. Save stepper configuration into the Arduino EEPROM using the EEPROM data library

Once you have all the libraries installed, compile the sketch and upload it onto your Arduino.

MegunoLink

The MegunoLink interface shown in this article is included in the powerSTEP01 Arduino library. After you install the library, you’ll find the MegunoLink project in the libraries/powerSTEP01/examples/MegunolinkDriverInterface_powerSTEP-1_/ folder of your Arduino installation.

If you don’t already have MegunoLink, you can download a free-trial.

Open the demo project in MegunoLink then, select the COM port of your Arduino board and hit connect to enable the interface.

In the interface panel it you can access nearly all the functions to control the stepper motor and some shortcuts for moving the motor fixed amounts and homing.

How to connect the interface to the driver board controller

Conclusion

Hey, we reached the end! If you enjoyed this article on the X-NUCLEO-IHM03A1 stepper driver, give us a like on Facebook.

Post a comment below and tell us how you’re using stepper motors in your projects. If you’d like some help getting the stepper going in your project, head on over to the forums.

And don’t forget to subscribe if you’d like to hear about more snazzy Arduino projects.

Subscribe for MegunoLink and Arduino Tips, Tricks and Projects
Recommended Posts
Showing 2 comments
  • Cyril
    Reply

    I have to say, that was some very useful info 🙂 I have a hard time finding anything about the powerstep chip, and still am a bit of a beginner with motor control.

    I am planning to build a force feedback rig, and was wondering if this board could be used. The main difference between this usage and the usual stepper usage is that in an FFB rig, the motor mostly never moves; it is mainly used to create torque to oppose the user’s own force. It does sometimes move, but mostly at a quarter turn.

    I have read that when the motor is stalled, i could approximate torque control = current control, and it seems this board can do current control.

    Now the motor of choice is a 2 phase stepper, each phase having a 6A current rating, 0.55ohm, and 8.4mH inductance, and i have a 24V 20A capable power supply that i plan to use.

    Do you think this board could be used to control this motor with that kind of usage ? I did read it can do 10A per phase so the current could be fine, but again i am a bit of a newbie in motor control. I plan to use a smaller motor first since that one is expensive, i’d rather fry a cheap one if something bad happens !

    Thanks a lot, your input is appreciated 🙂

Leave a Comment

Start typing and press Enter to search