ARC Pro

Upgrade to ARC Pro

Harnessing the power of ARC Pro, your robot can be more than just a simple automated machine.

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


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.
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. 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.
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.zip (Updated April 20, 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.


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

ARC Pro

Upgrade to ARC Pro

Become a Synthiam ARC Pro subscriber to unleash the power of easy and powerful robot programming

PRO
Synthiam
#12  
v5 

- 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
Canada
#13  
Wow,   Very nice.  Can’t wait to implement it.  

Thanks DJ!
PRO
Synthiam
#14  
You bet! I ordered a 5 pack of 5v stepper motors with drivers from Amazon to test with. They arrived yesterday so I was able to try it out. 

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.
PRO
USA
#15   — Edited
I got it going in one direction also

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
PRO
Synthiam
#16  
On my stepper driver, i used this configuration and it worked for the correct direction

Code:


// Uncomment these lines if using a stepper driver in FULL4WIRE means a 4 wire stepper (4 pins required).
#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);
PRO
USA
#17   — Edited
I did that before, I said it works but still goes one-way, horizontal, vertical, continuous servo all do the same thing
PRO
Synthiam
#18   — Edited
You can’t use continuous servo with this stepper motor. Because they’re not the same thing. You’d have to read how a servo works to understand. Click on the word servo here to read more. 

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.
PRO
USA
#19   — Edited
** I figured it out now it goes both directions with the horizontal, vertical, continuous servo controls

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,
PRO
Canada
#20   — Edited
So a bipolar stepper usually has 4 wires with two coils to create the magnetic force for the stepping action. It will alternate the magnetism in the coils to create a cogging (aka stepping) movement. Using an ohmmeter you can find which 2 wires are connected together to form one coil. The resistance will be very low ohms, it can almost look like a short between the wires that form one of the coils. You'll want to connect one coil to one of the channels of an H-bridge or motor driver, just as you would for a DC motor, you'll just need the second channel to drive the other coil to be able to get movement.

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.

User-inserted image
PRO
USA
#21   — Edited
I tested a Bipolar Stepper, NEMA 17 with L298N H-Bridge with the same code, it worked ok, I can go forward and reverse now


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
#22  
Just wondering if it would be possible/easier to use a stepper motor driver (for many different size steppers) and the EZbs could supply step and direction with 2 outputs which I think it could handle. This would bypass arduino. It would probably require a new skill, but in that skill you could have acceleration etc that you could edit. If you could get that working with Blockly I would be a big fan. I still believe in the Kiss method and be able program it quickly in minutes rather than days.
PRO
Canada
#23  
Hello @Automation Man, check out my post with YouTube video above. You can do some simple scripting to make it happen. It’s not efficient use of an EZ-B but it’s possible! You’ll need 4 outputs to control 2 channels of an H-Bridge.
#24   — Edited
Thanks for the input Jeremie but it's not quite what I'm talking about. Here is a typical stepper motor driver
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.
PRO
Canada
#25  
Whoops, I was mistaken, the post I was referring to was here.

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.
#26  
I'm not trying to reinvent the wheel this was just an alternative- and as you mentioned it would be for slower speeds. I will try to get this new skill working with the arduinos also. Seems like there may still be a few bugs for forward and reverse that may need to be worked out.
PRO
Synthiam
#27  
There’s no bugs in this robot skill. Any issues with forward and reverse is due to incorrect wiring - that’s a user error not the robot skill.
#28  
Ok good to know, as I was skimming thought I read that EZang only got it working one direction. Will be implementing this skill in the near future.
PRO
Synthiam
#29  
That’s correct, at first he got it working in only one direction. Once he fixed the wiring, he got it working correctly.:)
PRO
USA
#30   — Edited
Correct, if you read all the posts, I did get them moving forward and reverse

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.
#31   — Edited
v6

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