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