Upgrade to ARC Pro
Harnessing the power of ARC Pro, your robot can be more than just a simple automated machine.
Control up to 127 stepper motors as servos with speed and acceleration.
How to add the Stepper Servo robot skill
- Load the most recent release of ARC (Get ARC).
- Press the Project tab from the top menu bar in ARC.
- Press Add Robot Skill from the button ribbon bar in ARC.
- Choose the Servo category tab.
- Press the Stepper Servo icon to add the robot skill to your project.
Don't have a robot yet?
Follow the Getting Started Guide to build a robot and use the Stepper Servo robot skill.
How to use the Stepper Servo robot skill
Control up to 127 stepper motors as servos with any stepper motor driver or motor type. This robot skill requires a low cost and small profile Arduino to be connected to each stepper motor driver. Each Arduino is given a unique ID on the one-wire serial network. All 127 Arduino will share the same one wire serial network. An optional end stop limit switch can be used to calibrate the stepper's home position.Here is an example configuration using a network of 2 wire directional stepper drivers. Each Arduino BUS_ID can be a different type of stepper motor driver; they do not need to be the same. For example, BUS_ID #1 can be a two-wire directional stepper motor driver, and BUS_ID #2 can be a four-wire stepper motor driver.

Configuration

1) Port
Select the COM port for the Arduino 1 wire serial network interface.
2) Virtual Port Selections
Put a checkbox next to each Virtual Port that you wish to bind to the stepper motors. For example, BUS_ID 1 is V1. And BUS_ID 5 is V5, etc. Any commands to move the Vx port will be sent to the respective stepper motor with the matching BUS_ID. Sending a Servo.setPosition(v2, 100) will move stepper motor with BUS_ID 2 to position 100.
3) Max Positions
This is the maximum number of "ticks" or positions for all stepper motors on the network. For example, 1024 may provide 180 degrees of resolution, whereas 2048 will provide 360 degrees of resolution. This is based on gearing and stepper resolution. Changing this value will increase or decrease the amount of resolution the steppers will have.
*Note: Use the ARC project properties menu to increase the global servo resolution of the project to compliment the higher stepper resolution.
Advanced servo Features
This supports the advanced options of servos for Speed and Acceleration settings. The stepper motors will speed up and slow down between their source and destination positions by configuring the acceleration option in ARC's advanced servo settings.
When editing a robot skill for the servo configuration, the Advanced button will allow specifying the Speed and Acceleration. You may also use the respective JavaScript, Python, and EZ-Script commands for specifying the speed and acceleration programmatically.

A lower value of acceleration will cause the stepper to accelerate slower as it begins to move. -1 means do not change by maintaining the current setting, and 0 means no acceleration.

Home Position
The HOME position is servo position 1 in ARC. By default, the position on power-on will be servo position 1. You can specify any position to become HOME (position 1) with the control command. This robot skill has a ControlCommand() for setting the HOME position to calibrate the stepper motor positions. Additionally, you can use an end stop limit switch to calibrate the stepper into the home (position 1).
Endstop Limit Switch
This robot skill supports an optional limit switch for calibrating the position of the stepper motor. When the switch is closed to GND, that will configure the stepper to be servo position 1 in ARC. The Arduino firmware can be edited to include the option of auto-calibrating when power is applied. Otherwise, you can programmatically enable calibration with the control command.
Increase servo Resolution
ARC has a project-wide setting for increasing the servo resolution across all robot skills. Increasing this value will provide the stepper with a high resolution supported by your stepper motor.

Arduino Firmware
The Arduino code must be downloaded from here and programmed onto each Arduino. The recommended Arduino for this usage would be small and affordable, such as a Pro Micro, Micro, Nano, or ATTiny. These are all very low-cost devices that are small and do not take up much space.
1) Download Arduino Firmware from here: Stepper_Servo.zip (Updated April 20, 2022)
2) Uncompress the firmware to a folder and open the INO file with the Arduino editor

3) In the Arduino editor, configure the BUS_ID on the one-wire serial network for this instance. It can be a number between 1 and 127. This number will correspond with the respective Virtual servo Port in ARC. Each Arduino/Stepper will have a unique ID.

4) In the Arduino editor, configure the type of stepper driver that you will have connected to the Arduino. There are multiple types of stepper drivers to be supported, including two-wires, three-wire, four wires, etc. Uncomment the section of the kind you will use with this Arduino. Only one section can be uncommented at a time, so ensure you comment out another section if editing a previous configuration.

5) In the Arduino editor, you can configure control line wires from the Arduino to the Stepper Driver if they need to be inverted. This is only if the stepper driver requires inverted GPIO so that HIGH becomes LOW and vice versa.

6) Program the Arduino with the edited code.
1 Wire Serial Network
The Arduinos connect through a one-wire serial network. That can be from a USB <-> UART adapter or the USB from the first Arduino.
1) USB <-> UART Adapter
Connect the TX of the USB UART adapter to the RX0 pins of all Arduinos. Ensure the GND from the USB UART adapter is connected to the Arduinos.
2) USB Arduino
Arduinos have USB connections for programming. When the Arduino's USB is connected to the PC, it will become a COM port. With this configuration, you only require one Arduino connected to the PC via USB, and all other Arduinos will connect their RX0 pin to the first Arduino's RX0 pin. All Arduino's on the one-wire serial network will have their RX0 and GND pins connected. They all receive the same packets with this configuration, but they will only process the packets that match their unique BUS_ID.
Troubleshooting
- Ensure you have the latest Arduino firmware installed on your Arduino(s)
- Ensure you have the latest Stepper servo robot skill installed in ARC
- Ensure you have the latest ARC installed (Early Access edition is recommended)
- The stepper driver needs to be connected to the Arduino I/O pins. Ensure the pins are connected and specified in the Arduino firmware
- A common GND is necessary across all electronic devices. Ensure the stepper motor driver, stepper motor, Arduino, and PC have a common ground. The Arduino will be grounded to the PC if connected via a USB cable.
- Make sure you uncommented the correct stepper driver type in the Arduino firmware before uploading it to the Arduino
- The configured BUS_ID on the Arduino must match the selected checkboxes in the Robot Skill's configuration screen
Remember, the BUS_ID will match ARC's Virtual servo (Vx) ports. So BUS_ID 1 will match V1 in ARC. BUS_ID 2 will match V2 in ARC, and so on...
- updated with a new arduino firmware
- allows specifying the max positions for the stepper to rotate (read manual above)
- tested and confirmed to work great
Thanks DJ!
the one trouble I ran into was the wiring for the hbridge. There wasn’t a clear example of what order to connect the pins for the driver to arduino. I gather it has something to do with the way the coils are connected in the motor, but not sure on how to identify the order.
If someone with more stepper experience knows, maybe they’ll chime in. But I ended up trying a few combinations until I got it working. For a while the stepper would only go one direction and never reverse.
saw this on another code site
// Create Instance of Stepper Class
// Specify Pins used for motor coils
// The pins used are 8,9,10,11
// Connected to L298N Motor Driver In1, In2, In3, In4
// Pins entered in sequence 1-2-3-4 for proper step sequencing
Code:
any regular servo control will work. If your stepper is moving only in one direction, it’s the wiring or arduino ports misconfigured. You’ll have to read what I wrote above about that. Meaning, you have to know your configuration and stepper motor wiring. Theres nothing I can directly help with because there’s a million possible configurations and types.
I tried each one of the controls
On my 28BYJ-48 Unipolar Stepper with ULN2003 motor driver
The 28BYJ-48 Unipolar stepper motor has a "step sequence" as: 1-3-2-4 or In the code I used 2-4-3-5
in the code it was
#define STEPPER1_WIRE1 2
#define STEPPER1_WIRE2 4
#define STEPPER1_WIRE3 3
#define STEPPER1_WIRE4 5
AccelStepper stepper1(AccelStepper::FULL4WIRE, STEPPER1_WIRE1, STEPPER1_WIRE2, STEPPER1_WIRE3, STEPPER1_WIRE4);
Here is my connection, it works both directions
I n1 = 2 pin
I n2 = 3 pin
I n3 = 4 pin
I n4 = 5 pin
*Note: The sequence for a Bipolar Stepper, NEMA 17 with L298N H-Bridge is 1-2-3-4, a step instance with this in mind.
I will test later,
Thanks,
A unipolar stepper will usually have 5 or 6 wires and are a bit harder to figure out the wiring because they have center taps coming off the coils. The center tap wire will be half the resistance of the full coil. You can treat unipolar steppers like bipolar steppers by ignoring the center tap wires.
I raised the #define ACCELERATION 100 to 200, it spins better
My other Arduino has different code for a Bipolar Stepper, NEMA 17 with L298N H-Bridge starting with #include <Stepper.h> not AccelStepper.h
STEPPERONLINE CNC Digital Stepper Motor Driver 2.4-7.2A 18-80VAC or 36-110VDC for Nema 34 and 42 Motor on Amazon. I will do some experiments and get it working with an EZ-B. It will take 4 wires though, pulse direction, enable and ground. A simple way is to send out a steady stream of pulses and a more involved way is to have the pulses go up exponentially for acceleration, deceleration. This could be done with algebraic expressions in blockly. I wouldn't mind being a part of the one selling that skill.
Yeah, the driver you are referring to seems straightforward. You may not be able to get high speeds from it but simple operation with Blockly (or other) scripting seems reasonable enough.
both the Bipolar Stepper, NEMA 17 with L298N H-Bridge and the 28BYJ-48 Unipolar Stepper with ULN2003 motor driver
the wiring - "step sequence" in the code was the problem at first
My 28BYJ-48 Unipolar stepper motor has a "step sequence" as: 1-3-2-4 or In the code I used 2-4-3-5
in the code it was
#define STEPPER1_WIRE1 2
#define STEPPER1_WIRE2 4
#define STEPPER1_WIRE3 3
#define STEPPER1_WIRE4 5
AccelStepper stepper1(AccelStepper::FULL4WIRE, STEPPER1_WIRE1, STEPPER1_WIRE2, STEPPER1_WIRE3, STEPPER1_WIRE4);
Here is my connection, it works both directions
I n1 = 2 pin
I n2 = 3 pin
I n3 = 4 pin
I n4 = 5 pin
*Note: The step sequence for a Bipolar Stepper, NEMA 17 with L298N H-Bridge is 1-2-3-4, a step instance with this in mind.
- updated the robot skill and firmware
- the firmware update is required if you wish to use the end stop limit switch calibration
The optional end stop limit switch calibration is documented in the manual above and within the Arduino firmware file. The end stop limit switch allows the stepper to rotate toward a direction until a limit switch is reached. This will set the stepper to servo position 1 in ARC.
The end stop limit switch calibration can be configured to execute after power-on automatically or programmatically using the ARC controlcommand.