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 connected to each stepper motor driver. Each Arduino is given a unique ID on the optional serial network. All 127 Arduino will share the same PC COM port via the first Arduino's USB connection. An optional end-stop limit switch can calibrate the stepper's home position.
Each Arduino's firmware has a configuration for specifying the operating mode. There are four modes, SLAVE_SERIAL0, SLAVE_SERIAL1, MASTER_SERIAL0, and MASTER_FORWARDING. They are explained below, and only one of the modes can be active based on your configuration and hardware.
This mode uses a single Arduino over USB with no additional Arduinos connected to the serial network.
There is no serial network for this setting. This is for a single Arduino with one stepper.
Enable MASTER_SERIAL0 if all of these conditions are met...
- this is the only Arduino that will be connected to the PC (i.e., you only need one stepper motor)
- this Arduino is connected to the PC via the USB cable
This mode configures this Arduino as a forwarder for multiple Arduinos on the serial network. This master Arduino will be connected to the PC via the USB cable. All slave Arduinos will connect to this Arduino's Serial1 port (TX1/RX1) with diodes for each Arduino.
*Disclaimer: the serial network may not work with all Arduino. You may also not mix 5v and 3.3v Arduino on the serial network.
Enable MASTER_FORWARDING if all of these conditions are met...
- this Arduino is the master with BUS_ID 1
- this Arduino has more than 1 Serial port (i.e., it has RX1/TX1 pins)
- there are other Arduinos connected to the RX1/TX1 of this master Arduino in a serial network
*Note: If you use FORWARDING mode and receive an error about Serial1 not being defined, then this Arduino does not qualify for this mode.
This Arduino's RX0/TX0 pins are connected to a master Arduino's RX1/TX1 pins as part of the serial network.
Use SLAVE_SERIAL0 mode if all of these conditions are met...
- this Arduino is part of the serial network as a slave (it is not a master)
- this Arduino has onboard RX0/TX0 pins, and they're connected to the master Arduino's RX1/TX1 pins
- there is a diode on this Arduino's TX0 pin that is connected to the master Arduino's RX1 pin
This Arduino's RX1/TX1 pins are connected to a master Arduino's RX1/TX1 pins as part of the serial network.
Use SLAVE_SERIAL1 mode if all of these conditions are met...
- this Arduino is part of the serial network as a slave (it is not a master)
- this Arduino has onboard RX1/TX1 pins, and they're connected to the master Arduino's RX1/TX1 pins
- there is a diode on this Arduino's TX1 pin that is connected to the master Arduino's RX1 pin
*Note: If you use SLAVE_SERIAL1 mode and receive an error about Serial1 not being defined, it means this Arduino does not meet the requirements for this mode.
Serial Network (optional)
Optionally, you can connect multiple Arduinos in a serial network to share the same USB connection. This requires the first Arduino (the master) to have two serial ports. You can recognize if the first Arduino has two serial ports by the presence of the RX1 and TX1 pins.
*Note: The firmware has documentation explaining various modes for which the Arduino can be configured.
This diagram demonstrates how multiple Arduinos can be connected to Master Arduino with a diode. Ensure the diode's band is facing the correct direction. The 100k ohm resistor is used to hold the RX1 high because the diodes prevent the slave TX lines from doing so.
Select the COM port for the Arduino 1 wire serial network interface.
2) DTR Enabled
Some Arduinos require this setting enabled for communication (i.e., Leonardo, Pro Micro). If your Arduino is unresponsive when querying Ping or getting a servo position, this may need to be enabled. It is enabled by default.
3) Virtual Port Selections
Put a checkbox next to each Virtual Port 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 the stepper motor with BUS_ID 2 to position 100.
The ARC Max servo Positions number is mapped to the Max Steps value. If the ARC Max servo Position is 180 (default), and this value is set to 1500, the stepper will move 1500 steps when a position is assigned to position 180. If the servo position is assigned to 90, there would be 750. Here is the calculation for each stepper's Max Steps setting...
stepperPosition = Map(servoPosition, arcMinServoPositions, arcMaxServoPositions, 0, maxStepperPositions)
servoPosition: The position that you specify the stepper to move into.
arcMinServoPositions: The minimum servo positions for ARC, which is always 1 and can not be changed.
arcMaxServoPositions: The maximum servo positions configured for ARC. This value is default 180 but can be adjusted up to 2 billion per project. The configuration is in ARC Project Settings
maxStepperPositions: This is the value per stepper that determines the max number of steps this stepper can move.
That means the selected position will be scaled between 0 and Max Stepper Positions. The stepper is scaled between 0 and max stepper positions based on ARC's max servo positions.
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 acceleration value will cause the stepper to accelerate slower as it begins to move. -1 means not changing 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. The ControlCommand() can specify any position to become HOME (position 1). 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 connected to the Arduino 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.
Place a limit switch on the lowest position of the lever connected to the stepper motor. This switch will be used as the limit switch if configured. When calibrating, the stepper will move toward the lowest position until the limit switch is reached. Once the limit switch is reached, that will be position 1 in ARC until the power is cycled. There is no memory of the position between power cycles.
Ensure the calibration rotates your stepper in the correct direction, which will be position 1 in ARC. You may need to specify the INVERT option in the firmware if the stepper rotates in the wrong direction. The limit switch should always be at the lowest position for the stepper, which means position 1 in ARC.
Increase servo Resolution
ARC has a project-wide setting for increasing the servo resolution across all robot skills. Increasing this value will give the stepper a high resolution supported by your stepper motor.
Test Bi-direction Communication
This allows the Arduino to report the current position of the stepper during movement using the script command GetPositionRealtime(). This command will retrieve the real-time position of the stepper from the respective Arduino. The Arduino's are responsible for moving the stepper, including acceleration and speed.
The robot skill main screen has a Ping menu option to test bi-direction communication.
When the ping option is selected, a new window will open with options to ping the Arduinos and view their firmware version. Here you can choose the port for each Arduino on the serial network to verify communication and the version number.
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 (Version 20230223).zip (Updated Feb 23, 2023)
2) Uncompress the firmware to a folder and open the INO file with the Arduino editor
3) Configure the BUS_ID on the one-wire serial network in the Arduino editor 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 area can be uncommented at a time, so 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 an inverted GPIO so that HIGH becomes LOW and vice versa.
6) Ensure you have selected the correct Arduino Board that you are using
7) Program the Arduino with the edited code.
- 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. Ensure you uncommented the correct stepper driver type in the Arduino firmware before uploading it to the Arduino.
- 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.
- 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...