Stepper Servo

by Synthian Inc.

Control up to 127 stepper motors as servos with speed and acceleration.

How to add the Stepper Servo robot skill

  1. Load the most recent release of ARC (Get ARC).
  2. Press the Project tab from the top menu bar in ARC.
  3. Press Add Robot Skill from the button ribbon bar in ARC.
  4. Choose the Servo category tab.
  5. 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 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.

Operating Modes

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
User-inserted image

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.

User-inserted image

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

User-inserted image

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.

User-inserted image

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.
User-inserted image


User-inserted image

1) Port
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. 

Max Steps
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.

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 determining the speed and acceleration programmatically.
User-inserted image

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.
User-inserted image

Home Position

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.
User-inserted image

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.
User-inserted image

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.
User-inserted image

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 (Version 20230223).zip (Updated Feb 23, 2023)

2) Uncompress the firmware to a folder and open the INO file with the Arduino editor
User-inserted image

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.
User-inserted image

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.
User-inserted image

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. 
User-inserted image

6) Ensure you have selected the correct Arduino Board that you are using
User-inserted image

7) Program the Arduino with the edited code.
User-inserted image


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


Upgrade to ARC Pro

ARC Early Access will give you immediate updates and new features needed to unleash your robot's potential!

Once you have high standards like you do it is very hard to go backwards and try to use other peoples code. As a guy that used to work for me mentioned "You're trying to make chicken salad out of chicken sh t. For now the code is working adequate for the rotation that I am using (less than 20). Thanks again
Just an update-finally figured out a way to have motor travel full length of a 20" ball screw. I now remember how steppers have low torque compared to permanent magnet motors. For me If I'm not using Nema 34s then I'm just going to disappointed in the results. Accuracy that's what I'm looking for and they have it.
   Whenever you have time to modify or rewrite the code some things I've noticed. The project max positions when using steppers-- what's the use it just complicates things. If it's possible to have the max positions listed right there in the virtual list and that's it that would be great. Example I have one 20" ball screw which needs 64k position but my other motors need 8k.If I make project max pos 64k then all the other motors are scaled. If you want to go 64k just put in 64k well it doesn't go 64k only 32k. If you try to combine the 180 position servos with the 64k max it barely moves. If it's possible to have the virtual separate from D1... servos would be a big help. A simple goal would be to put in a value of 10k and it moves 10k put in a value of 63k and it moves 63k. I forsee many projects with this skill. Thanks again
#304   — Edited
Each stepper has its range in the robot skill - I think you forgot that setting. The stepper only gets the range specified in the robot skill configuration. Stepper on v1 can have a range of 1500 steps. Stepper on v2 can have a range of 234232352 steps. Stepper v3 can have a range of 5 steps. You decide per stepper. 

The servo position range in ARC results in the resolution between the range of each stepper.

User-inserted image
#305   — Edited
I only wish that were the case but I did remember that and do set each one individually but the project max positions seems to take over. If that was your original intention for stepper max to be the max, then great because that exactly what is preferred. The project max positions seems to be overriding it and then it get divided by the stepper max positions.
I did some more experimenting and it confirmed what I was talking about.The project max positions does play a part in how much movement the ballscrew will travel. A possible way to change this could be an added line in code  something like this. If V3 max positions (set in the skill) is less than project max positions then use skill max positions in the equation. Example Project max 64k, skill V3 max positions 16k, Low amount 1, High amount 16k. It should go 16k steps but it doesn't it only goes 16/64=.25  1/4 of 16k=4k steps. But if skill max pos<project max=use skill max in equation. The result would move 16k steps. This could be a checkbox in the skill itself to use an equation like this.
#307   — Edited
Have the 5 motors dancing now and doing some experimenting, had a question. What is the proper javascript format to home a typical virtual V5 etc?
#308   — Edited
Trying to use Auto Position for movement and it is taking about 15 seconds to send out a movement of 1 to 1000 which usually takes 1 second. Have tried to change the steps to 1 in Auto Position but it does not help. Makes the Auto Position basically unusable. I don't like being on the forefront because it make me look like the bad guy but all I'm doing is pointing things out.
Something to consider on the next update is to have the Virtual ports on the software start at 1 rather than center point. Example-If you are using 65k for max the software will startup at 32,500 and your steppers will be off the races. Maybe just a questionnaire of where you would like it to start while setting up the virtual port would take care of it.
A simple way to verify what I'm saying is to have it in frames of Auto Position and and have realtime update with a few Virtual ports and it will be very obvious how slow the virtual ports move. It would help a lot if this was working properly.
#311   — Edited
Maybe you didn't know this from reading the ARC manual, but you can right-click in the stepper box and manually enter a value with the keyboard. You do not need to drag 65,000 of them.

Regarding your message about setting Auto Position to 1 and claiming it took a long time is correct. that would be the absolute slowest you could make it move. 1 is the smallest positive integer value in mathematics. To move something by Step 1, would be like counting by 1 (i.e. 1, 2, 3, 4, 5). If you set Steps to 10, you'd be counting by 10's, and that would be faster. If you used Step 100, you'd be counting by 100's, and that would be even faster. 

The delay is delay between steps. So if you have a value of 1 in delay, that would be fast. But if you have a value of 1000 in delay, that would be very slow because it would pause 1000 ms per step. You have to tune these values.
Ok, on the right click and have been doing that. On the steps I must have misinterpreted it and that may be the problem. The delay I had correct. Will retry and hopefully takes care of it, which would be really nice. Thanks
Ahh that was it. I interpreted it as 5 would take 5 steps to get there and 1 would take 1 step to get there, my bad. It's so nice to have Auto Position working again!!
It's getting fun now. I'm pretty sure you'd get a kick out the various things that I'm working on.  
Thanks again,
Oh i'd love to see! Create a new general post to show your stuff off:D I bet everyone is wondering
All in due time. The automated lathe which I made from scratch worked very well,User-inserted image

is looking a bit primitive to me now. There is always a first phase which works out the bugs and does the proof of concept. I am building revised versions of the many different machines/robots etc. with upgraded bearings, motors
to handle heavier loads and very little backlash. You would have a field day programming them, but first they need to get built. Here is the final product picture with 850 tapered Ipe spindles. I don't know why it keeps rotating the picture.
Personally one of the cool machines that I recently made was a 17' gantry with 360 degree rotatable saw with 10" blade and it can go on a 45 degree angle. Well I build all different types of stairs and they need stringers. They have a rise and a run at very precise angles say 36.33 and 53.67 so I plunged the saw but that only cuts part of it so it had to go a very specific vector with the saw at a specific angle to finish the cut,... that one was pretty cool, onto the next one.
Holy moly that is real wild to see! Thank you for sharing! It must have been a lot of work. You're very talented! It's funny how the image is sideways - makes it look like an MC Escher sketch lol
#319   — Edited

Thanks, appreciate it. Here is a little more eye candy which that my son and I did.
User-inserted image

Each tread is independant and does not touch any other tread, they are all just connected to the wall. The belly spindles offer no support.
@automation man Incredible work. Amazed to see the floating stairs in the last picture. Beautiful.
Thanks Fxrtst, we all have things that we do to make a living.