ARC Pro

Upgrade to ARC Pro

Experience early access to the latest features and updates. You'll have everything that is needed to unleash your robot's potential.

Thumbnail

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

Arduino Connections


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 UART will first Arduino's UART pins.

There are two methods of connecting the Arduinos drivers to the PC. One way uses only the RX lines, which only receive positions to move the stepper motors. The other method uses both the RX and TX lines, which allows bi-directional communication for features such as retrieving the current position of the stepper during movement.

1 Wire Serial Network (RX only)
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 TX0 pin. Remember, all Arduinos also need to have their GND pins connected. All Arduino will receive the duplicate packets with this configuration, but they will only process the packets that match their unique BUS_ID.

Here is an example diagram 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. 
User-inserted image



2 Wire Serial Network (RX and TX)
This connection method allows bi-directional communication for retrieving the position of the stepper while moving. This is done using the getPositionRealtime() command for the current scripting environment.

You only require one Arduino connected to the PC via USB; the first Arduino will connect its TX0 pin to the RX0 pin of all other Arduinos. In addition, the RX0 pin of the first Arduino will be connected to the TX0 pin of all other Arduinos. Remember, all Arduinos also need to have their GND pins connected. All Arduino will receive the duplicate packets with this configuration, but they will only process the packets that match their unique BUS_ID.

User-inserted image




Configuration


User-inserted image



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 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 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 single (one) 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. 

Make sure 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 is rotating 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



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 (October 6, 2022).zip (Updated October 6, 2022)

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


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.
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 section can be uncommented at a time, so ensure you 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 inverted GPIO so that HIGH becomes LOW and vice versa. 
User-inserted image


6) Program the Arduino with the edited code.


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

ARC Pro

Upgrade to ARC Pro

Synthiam ARC Pro is a cool new tool that will help unleash your creativity with programming robots in just seconds!

#67  
Ahh sweet that's the answer I was looking for, thanks DJ. I hooked it up with the Arduino micro and it is now working. @ SMiller after looking over your schematic and understanding it yours should work also.
#68  
Some quick observations- I looked for a variable in the variable list for Acceleration so that we could change it on the fly rather than get back into the Arduino software each time and could not find anything, maybe you have made one can you point me to it. Different motors will need different acceleration. Where in the code is this located?
The resolution index is not really resolution (which it has plenty of). It is more in line with amount of rotation, as you change this amount  it is changing degrees of rotation. How many actual pulses is it putting out per degree? 
If we know this amount then we will know how far it will rotate. Where in the code is this located? This one would also be nice to have as a global variable.
Thanks again,
Don
#71  
DJ Have another question I hope you can answer.  It refers to the following statement in the instructions:

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.

In my build I have a 6V 60A DC power supply and for the my 5V devices I have a 5V buck converter that powers my Lattepanda and also the powered USB hub that is connected to the Lattepanda.  To power the planned stepper motors I will be connecting a 12V boost converter to the 6V power supply.  So here's my question.  If the first Arduino BUS1 is connected with a USB from the USB hub connected to the Lattepanda for BUS2 Arduino where does the power need to come from?  The same 5V buck converter the hub and the Lattepanda is connected to?

Because all the power in being supplied by the 6V power supply would all the grounds be considered common?  Meaning the 12V Boost and the 5V Buck grounds and the power supplies ground are common?

I was planning to power the Arduino's with 5V mini buck converters on each motor being powered by the 12V feed from the 12V boost converter.  This all depends on determining a common ground based on the statement above.
PRO
Synthiam
#72  
All power sources in electronics need to have a common ground. That’s the reference of 0 volts. Without it there’s no way to see voltages. Connect all gnds of all power sources
#73  
So then because everything is connected to the 6V power supply GND as the starting point you are saying this means everything is on the same ground no matter if it goes through a booster or a buck converter if I understand you correctly.
PRO
Synthiam
#74  
All gnds have to be connected for all power sources. Not sure how else I can say that haha
#75  
In Blockly how would you move the stepper since it is a virtual port. Will you need to make up a different Move servo DO,0 etc or maybe modify existing one to handle virtual as well as the typical?
PRO
Synthiam
#76  
Vx virtual servos are not included in blockly. We'll have to add them in a future release. We have a released scheduled for between the 5th and 7th, so I'll try and sneak it into that one.
#78  
Is there a variable built in that we can use to count the pulses of pin 2 and then also subtract as needed with direction pin 3.  I tried to do it with Blockly and the adc but the cycle time is too slow to keep with the pulses. It worked but did not catch them all. This variable would be very helpful in many ways. It would always know where you are and if you want to clear it to start something new, just clear it. I suppose rather than pin 2 and 3 it would need to be pulses and direction for a specific Bus address (diff motor). Maybe add this variable in the same area as virtual stepper motor advanced area.
#79   — Edited
The hardware that controls the stepper motor is an Arduino, which is not part of the PC that runs ARC. The Arduino has the step count, not the PC. It is not possible for a variable as they are separate pieces of hardware. Therefore, we commend using a potentiometer or encoder for the output position.

A potentiometer is the easiest solution, as it would connect to an EZB ADC port. The ADC value can then be used as a position. This can be combined with an existing ADC robot skill available here: https://synthiam.com/Support/Skills/Servo/PWM-Servo-Feedback-ADC?id=18047
#80  
ok understand and will implement the feedback, thanks
PRO
Synthiam
#81  
I was talking to the guys and they feel there’s a way we can extract the position if both the rx and tx were connected. This allows the controllers to transmit their position when requested with a command. 

i looked into it and I agree it is possible. It’ll operate the same as the robot skill I shared above. 

we’re gonna look into it further and see what we can do. Stay tuned
#82  
Ahh, I think that would be a big find if you can pull it off.
#83  
Whenever you get time to make the virtual port I think it can actually be different from the PWM integer degree because it is serial and not hindered by the 9us separation that is needed with PWM. It should be able to go into the 1/1000 or even more because it is microsteps, this will add a lot of precision to everything (30.652 degrees)
PRO
Synthiam
#84   — Edited
#85   — Edited
Updated version 7

- Includes support for a bi-directional connection method that allows querying the stepper positions during movement. See the manual above for wiring

- Additional debugging messages added

- Requires updated firmware for October 5th, 2022 or newer
#86   — Edited
Great update! One more item to consider is to make it continuous rotation with a simple click in a checkbox. Thanks again, 
Don