Author Topic: Controlling Servos vs Steppers  (Read 1762 times)

0 Members and 1 Guest are viewing this topic.

Offline YoukaiTopic starter

  • Regular Contributor
  • *
  • Posts: 227
  • Country: us
Controlling Servos vs Steppers
« on: February 15, 2023, 10:46:55 pm »
I'm working on a project where I was planning on using 6-ish servos and/or stepper motors at the same time and I need to be able to control them each independently.

With servos I can get a 16 channel PWM driver to control the servos and save pins on my Arduino. Can you do the same/similar with Steppers? I haven't used them before so I don't know much about how they work/how to use them. I do see that you need 4 pins on your microcontroller to run them though, that seems like it would eat through your available pins pretty quickly.
 

Online brucehoult

  • Super Contributor
  • ***
  • Posts: 4455
  • Country: nz
Re: Controlling Servos vs Steppers
« Reply #1 on: February 15, 2023, 11:34:52 pm »
Stepper control is far more precise than servo. You can not only control position extremely accurately, but also speed and acceleration of movement. Servos only have position, with the control of speed and acceleration of movement between positions completely up to the servo itself. On the other hand, with steppers you HAVE to program ramp up and down of movement speed yourself.

Steppers only really need 2 pins each from the microcontroller: clock&direction, or maybe up&down that you pulse when required. You need to send high power to the stepper, so you need some kind of external power driver anyway, so it might as well be an H-bridge that expands clock&direction to the actual signals the stepper needs. Depending on the performance requirements you could use standard output expansion techniques such as (possibly chained) shift registers.

Servos only need a low power timing pulse, and have the necessary high power drivers internally.
 

Offline jmelson

  • Super Contributor
  • ***
  • Posts: 2822
  • Country: us
Re: Controlling Servos vs Steppers
« Reply #2 on: February 15, 2023, 11:45:44 pm »
Stepper control is far more precise than servo. You can not only control position extremely accurately, but also speed and acceleration of movement. Servos only have position, with the control of speed and acceleration of movement between positions completely up to the servo itself. On the other hand, with steppers you HAVE to program ramp up and down of movement speed yourself.
  If you are talking about RC servos, then what you say is true.  However, there are precision servos used in CNC machines that can be WAY more precise than RC servos.  Fanuc makes encoders that read shaft position at 1 million counts/rev, for instance.
Jon
 

Online brucehoult

  • Super Contributor
  • ***
  • Posts: 4455
  • Country: nz
Re: Controlling Servos vs Steppers
« Reply #3 on: February 16, 2023, 12:22:56 am »
Stepper control is far more precise than servo. You can not only control position extremely accurately, but also speed and acceleration of movement. Servos only have position, with the control of speed and acceleration of movement between positions completely up to the servo itself. On the other hand, with steppers you HAVE to program ramp up and down of movement speed yourself.
  If you are talking about RC servos, then what you say is true.  However, there are precision servos used in CNC machines that can be WAY more precise than RC servos.  Fanuc makes encoders that read shaft position at 1 million counts/rev, for instance.
Jon

How is the desired position transmitted to them? I'd assume by some digital binary means -- maybe even some subset of G-code -- and not trying to resolve a million different values accurately from a 1-2 ms pulse? (i.e. 1 ns resolution)

The OP did specify his servos are controlled by PWM.
 
The following users thanked this post: thm_w

Offline thm_w

  • Super Contributor
  • ***
  • Posts: 7067
  • Country: ca
  • Non-expert
Re: Controlling Servos vs Steppers
« Reply #4 on: February 16, 2023, 01:08:31 am »
CNC servo motors can be controlled with basic step/direction (differential for these higher encoder counts), or ethernet, USB, RS485, etc. If you don't care about high positional resolution, you can multiply the step count in the driver config (eg 16x), to reduce the step frequency.
But yeah OP is clearly talking about hobby servos.

Youkai: you'd need to decide which motor type is better for you mechanically. Does the shaft need to turn multiple times? What positional accuracy is required? What torque?
Describing what you're actually doing with them would help.
Either one can be driven from an arduino.
Profile -> Modify profile -> Look and Layout ->  Don't show users' signatures
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6830
  • Country: fi
    • My home page and email address
Re: Controlling Servos vs Steppers
« Reply #5 on: February 16, 2023, 01:17:32 am »
I normally use bipolar stepper motors and a separate stepper motor driver that takes in just two signals, STEP and DIR, based on for example STSPIN220, DRV8834, A4988, et cetera.  A4988 are the cheapest, as you can get them off eBay at ~ 1 USD apiece, but they need at least 8V for the stepper motor supply.

These step/dir drivers can handle different ranges of motor power supply voltages (A4988: 8-35V, STSPIN220: 2-10V, DRV8834: 3-10V, DRV8825: 8.2-45V), and they limit the current, typically set using a small potentiometer on the board.  Stepper motors don't really have a specific voltage at all, they're rated for some range of drive currents instead.

Depending on the stepper motor, they take anywhere between 8 and 400 steps to complete a full turn; it is specific for each stepper.  Some steppers, like 28BYJ-48, have a built-in gearbox, so their output takes even more steps (64 to 2048, depending on the gearbox).

Microstepping is when the driver chip does not do a full step on each rising edge of the STEP signal, but divides the step into smaller increments (almost always some power of two, like 2, 4, 16, 32, 64, 128, 256).  It yields smoother motion, but again, you need more STEP pulses for a full turn the higher microstepping you use.

If you don't need a very specific movements (exact number of steps), you can use a PWM output (like those used with servos), except that it is the frequency, not the duty cycle, that determines the stepper speed.

Also, with steppers, you usually want end stop switches in the mechanism, so the microcontroller knows when to stop.  This is particularly important if you use threaded shafts and linear motion; by itself, a stepper will not know when to stop (unlike a servo), and will try to break itself.

You can find a lot of Arduino examples and tutorials by searching for "stepper" "A4988" for example, for that specific stepper driver.



A common one is the ubiquitous 28BYJ-48 unipolar stepper motor with various gear reductions.  The output shaft that pokes out takes 64 to 4096 steps to do a full turn, depending on the gearing in it.  While it is an unipolar stepper (which is why it can be driven using ULN2003A), it can be driven using a bipolar driver as well.  (If you cut the one trace on the tiny board, you can actually convert it to a bipolar stepper, but it isn't necessary.)  A typical one needs 2038 steps for a full revolution (32 steps per revolution for the stepper itself, and a 1:63.68395 gearing), and can do about 100 steps per second, or about 3 FPS; ten times that for short intervals but not for continuous operation.  Make sure your stepper does not overheat.

The smaller the current limit that achieves the movement you need, the better, of course – less heat and so on.  The maximum coil current for 28BYJ-48's is about 120mA, but many run them at something like 50mA just fine.

Pololu STSPIN220 and DRV8834 and their clones would be best suited for this.  To set the current limit, you'd set the driver to full stepping.  The target stepper must be connected, but you put a multimeter in ampere/current mode in series between one of the driver outputs and the corresponding stepper phase.  When enabled, the driver energises both coils to about 70% of maximum (sqrt(1/2)), so you turn the small pot until the current reads about 70% of your desired maximum.  For example, for 100mA, you turn it so you see 70mA through the multimeter.  (Remember, this is just half the total, so the total current draw per stepper is twice that, plus a bit for the driver.)

If only one of your steppers needs to be energised (rotating or holding its position) at a time, then you can wire all drivers to the same STEP and DIR pins on your microcontroller, but use a separate /ENABLE pin for each driver.

For best results, experiment.  I like to always get at least two of each stepper I test, just in case I burn one.  When I get similar ones from different sources, I use a multimeter the resistances between stepper phases match, and that they need the same number of steps for a full rotation.

The cheap SG90 micro servos I have (with transparent blue chassis), ubiquitous in Arduino projects, have about 20 oz-in of torque at 5V.
A 6001HB hobby servo has 93 oz-in of torque at 6V (using an one inch liftarm, can lift 93 ounces; using an 93" liftarm, can lift one ounce).
28BYJ-48 with the above gearing (see e.g. solarbotics) and limited to 140mA per coil (100mA reading in the multimeter), has about 11 oz-in of torque.

You can find steppers with a threaded shaft by searching for "stepper" "linear" at eBay, Amazon, AliExpress etc.  I recommend you get one with the nut also provided, because the thread may not be standard at all.  They vary from automatic lens adjusters (cylindrical, 4mm or 5/32" in diameter, maybe 12mm or 1/2" tall since the smallest ones have a gearbox too to get sufficient torque) up to NEMA 23 that weigh a kilogram or two, and are used in CNC machines and such.

The sturdiest stepper I have is a 270 oz·in NEMA23 stepper connected to a 80:1 NMRV worm gearbox.  Basically, the output shaft should have something like 120 Nm (17000 oz·in or 90 ft·lb) of torque, if it does not break first (it's cheap aluminium job).  (Antenna elevator for an Alaskan Arrow II for a friend.)
« Last Edit: February 16, 2023, 01:27:37 am by Nominal Animal »
 

Offline YoukaiTopic starter

  • Regular Contributor
  • *
  • Posts: 227
  • Country: us
Re: Controlling Servos vs Steppers
« Reply #6 on: February 16, 2023, 02:41:30 am »
The use case here is that I need to have approx 200g of 3d printed parts moved linearly and held in place against gravity. I have my parts mounted on a printed scissor jack.

My initial plan was to use a HS-311 to move them and that works just fine. 180 degrees of rotation with an appropriately long arm gives me the travel I need. That servo is kind of large for my project though so I wanted to try using an HS-55 that I have laying around. I think my part may be pushing the limits of the ability for the HS-55. In a different thread someone mentioned using a small stepper motor and a threaded rod as a linear actuator. Then I saw how many wires you need to control them and considering I need 6 of these in my project I'm concerned about having enough IO pins. I plan to use a sparkfun pro micro or similar as the micro-controller.
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6830
  • Country: fi
    • My home page and email address
Re: Controlling Servos vs Steppers
« Reply #7 on: February 16, 2023, 04:13:05 am »
I guessed, as that was me!  Yep, a servo makes more sense, I agree with Benta in that other thread.

I've used the pro micro clones (ATmega32U4), but they're a bit difficult to find now unless you already have them.  (In the Arduino environment, they use the Leonardo bootloader (and Leonardo also uses an ATmega32U4), so basically you tell the IDE to target Arduino Leonardo, but use the pro micro pinout.)

For servos, you can always use a PCA9685-based expander (see e.g. the guide for the Adafruit one – they all work similarly) so you only need I²C (SCL and SDA pins from your microcontroller) to the PCA9685 expander, and can use basically any MCU you like.

Note that you'll want to provide 5V to the servos; you supply that using the center power pins on the PCA9685.
Depending on which MCU you use, the I/O voltage level may be 5V (AVRs) or 3.3V (ARMs, RISC-Vs, ESP32s etc).  You connect that I/O pin voltage level to the VCC (and MCU GND to GND) on the short edge of the PCA9685.

For example, for a wearable, I personally might pick something like Olimex ESP32-C3, the programmer, and a suitable size lipo battery (for powering the ESP32-C3 only), and a separate USB power bank to power the servos, because the Olimex one supports battery operation so it would be easiest to power, and is well supported in Arduino, PlatformIO, EspressIF, and not too expensive (for me here in Europe).  If I were in USA or Asia or Australia, I'd see what is available, look at projects others have made with it already, and then decide.  Raspberry Pi Pico aka RP2040? ESP32C3? Seeeduino XIAO? CH32V003? ESP32C3-Mini? (Not an exhaustive list, just examples!)
Pick one that suits your needs and preferences best.
 
The following users thanked this post: Youkai

Online DavidKo

  • Frequent Contributor
  • **
  • Posts: 307
  • Country: cz
Re: Controlling Servos vs Steppers
« Reply #8 on: February 16, 2023, 01:15:56 pm »
My own interpretation:

stepper - type of the motor. You send the steps to it and it can do it. Without any feedback you do not know its exact position => you need referencing and hope that it will not slip.

servo - it is a system from motor and feedback. It use some motivation force (for example a stepper motor, hydro motor, etc.) and the position is given by the feedback (from simple pot in RC servo to high accuracy measurement devices). Servo "knows" its position in any given time, resp. goes to the given position independently on the motor.
 

Offline EPAIII

  • Super Contributor
  • ***
  • Posts: 1151
  • Country: us
Re: Controlling Servos vs Steppers
« Reply #9 on: February 16, 2023, 09:18:40 pm »
Yes, steppers only need two pins from your processor. There are any number of stepper driver boards available on the web. And most of them only have two inputs. You can buy a stepper control board cheaper than making one.

As for the differences, the biggest one is open loop vs. closed loop. A stepper may be easy to control, but there is no inherent feedback telling the controller if it actually moved to the desired position. And steppers are notorious for missing steps when the load becomes too large or they are told to move too fast.

A servo, on the other hand, does inherently use feedback so the controller does know if it has accomplished the move completely or not. A servo can keep trying until the desired movement is accomplished. And there are many forms of servo control. Things like speed and acceleration can be controlled. One popular method of servo control is called PID for Proportional, Integral, Derivative control. It combines these three modes of control, each with their own gain controls, to optimize the response of a control. It does, however, require feedback from the motor or load being driven. How fast is it turning? How many turns has it made? Has the load been moved to a new position? Etc. Feedback! Closed loop!

https://en.wikipedia.org/wiki/PID_controller

This PID control method can be implemented in any controller and it is even used for stepper controls where the stepper becomes the motor in a servo loop. So stepper and servo can even be combined, often yielding the advantages of both.

One more point. I have worked with precise positioning controls. You can not categorically state that one is more precise than the other. I have seen systems where steppers, with gearing, can really get down to very small increments of distance or angle. On the other hand I have seen systems where digital techniques were used in a rough positioning servo loop and then an analog servo loop was used for the final, precise positioning.

The degree of precision depends on the system design and not just the choice of servo vs. stepper. And Bruce seems to be speaking about only one type of servo. But there are many.



Stepper control is far more precise than servo. You can not only control position extremely accurately, but also speed and acceleration of movement. Servos only have position, with the control of speed and acceleration of movement between positions completely up to the servo itself. On the other hand, with steppers you HAVE to program ramp up and down of movement speed yourself.

Steppers only really need 2 pins each from the microcontroller: clock&direction, or maybe up&down that you pulse when required. You need to send high power to the stepper, so you need some kind of external power driver anyway, so it might as well be an H-bridge that expands clock&direction to the actual signals the stepper needs. Depending on the performance requirements you could use standard output expansion techniques such as (possibly chained) shift registers.

Servos only need a low power timing pulse, and have the necessary high power drivers internally.
Paul A.  -   SE Texas
And if you look REAL close at an analog signal,
You will find that it has discrete steps.
 

Online Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3819
  • Country: nl
Re: Controlling Servos vs Steppers
« Reply #10 on: February 17, 2023, 12:24:07 am »
TL:DR.

Another option is to use "S-Bus" servo's. I bought a few "Corona SB-3019" digital servo's before looking closely at the S-bus protocol. I was a bit disappointed that it only sends a 10 bit position signal over the bus wire. On the positive side, you can control multiple servo's with a single pin, they are also compatible with the PWM servo's and they have an STM32 inside, so you can do quite fancy things with them.

When I bought them I assumed that the S-Bus was a more elaborate bus for communicating with servo's, a bit similar to the Dynamixel servo's.

The Dynamixel Servo's are another step up (both in price and performance). With these you can set PID parameters though a shared digital interface and also read back parameters such as motor power and temperature. The budget variants have a potentiometer, while the higher performance types have a Hall encoder and are capable of continuous rotation and tracking position over multiple revolutions.
Dynamixel has a pretty wide range, from small hobby servo's t industrial types in the 4 digit price class. There are also several clones of these servo's for a lower price and quality.

For stepper motors, there are several bus based systems, both RS485 and CAN, and from open source projects to readily built up PCB's. Some magic keywords to find more info: AnanasStepper, Mechaduino, BigTreeTech, MakerBase.
 

Online brucehoult

  • Super Contributor
  • ***
  • Posts: 4455
  • Country: nz
Re: Controlling Servos vs Steppers
« Reply #11 on: February 17, 2023, 12:35:48 am »
The degree of precision depends on the system design and not just the choice of servo vs. stepper. And Bruce seems to be speaking about only one type of servo. But there are many.

I was talking about the kind of servo that uses PWM to control it, as the OP specified.

I've implemented and tuned PID control many times, including of my home heating system, using turning a 2400W electric oil column heater (with thermal constant of around 10 minutes) on and off (potentially) every 30 seconds or so, achieving room temperature control (as measured by an exponential averaging of a thermistor reading) of 0.02C is reasonably steady conditions, and maximum error of about 0.2 C from transients such as someone boiling a kettle or starting/stopping using the stove/oven (i.e. more precise than an IR sensor, though more localised). A change in commanded room temperature generally took about 20 minutes to settle to the new value for reasonable changes (up to a couple of degrees).
 

Offline jmelson

  • Super Contributor
  • ***
  • Posts: 2822
  • Country: us
Re: Controlling Servos vs Steppers
« Reply #12 on: February 17, 2023, 02:42:38 am »
Stepper control is far more precise than servo. You can not only control position extremely accurately, but also speed and acceleration of movement. Servos only have position, with the control of speed and acceleration of movement between positions completely up to the servo itself. On the other hand, with steppers you HAVE to program ramp up and down of movement speed yourself.
  If you are talking about RC servos, then what you say is true.  However, there are precision servos used in CNC machines that can be WAY more precise than RC servos.  Fanuc makes encoders that read shaft position at 1 million counts/rev, for instance.
Jon

How is the desired position transmitted to them? I'd assume by some digital binary means -- maybe even some subset of G-code -- and not trying to resolve a million different values accurately from a 1-2 ms pulse? (i.e. 1 ns resolution)

The OP did specify his servos are controlled by PWM.
Well, the old traditional velocity servo had the CNC control send an analog velocity command to the servo amp, and the amp compared velocity from a DC tachometer or derived from the encoder to the commanded velocity, and adjusted the power to the motor.  The CNC control read the encoder position and computed a velocity command to send to the servo amp.
Newer systems use all sorts of means, often digital, to send velocity commands to the servo drive.  No, there are no 1-2 ms pulses.  The Fanuc encoders send absolute position 8000 times a second.  My analog servo system on my milling machine updates the velocity comand 1000 times a second.
I do make a PWM servo system that creates a PWM signal at 50 KHz (20 us repetition) and has resolution of 800 counts of a 40 MHz clock, so that's resolution of 25 ns.
Jon
 

Online mikerj

  • Super Contributor
  • ***
  • Posts: 3317
  • Country: gb
Re: Controlling Servos vs Steppers
« Reply #13 on: February 17, 2023, 02:45:22 pm »
If you want to use steppers an obvious off the self solution would be one of the cheap 3D printer control boards (e.g. BIGTREETECH Octopus can support up to 8 stepper drivers) and either treat it as a peripheral for your Arduino (the boards have UART connections for control) or you may be able to move your entire application into the processor on the 3D printer board.  As a peripheral you can use the standard open source Marlin firmware and control the steppers using Gcode or you could implement your own protocol if this doesn't suit you.
 

Offline TomKatt

  • Frequent Contributor
  • **
  • Posts: 529
  • Country: us
Re: Controlling Servos vs Steppers
« Reply #14 on: February 17, 2023, 05:00:25 pm »
If you want to use steppers an obvious off the self solution would be one of the cheap 3D printer control boards (e.g. BIGTREETECH Octopus can support up to 8 stepper drivers) and either treat it as a peripheral for your Arduino (the boards have UART connections for control) or you may be able to move your entire application into the processor on the 3D printer board.  As a peripheral you can use the standard open source Marlin firmware and control the steppers using Gcode or you could implement your own protocol if this doesn't suit you.
The size and power of the stepper motors used will likely dictate that.  I do a lot with small steppers (<= NEMA 17) and it's cheap and easy to use one of those stepper 'hat' or 'shield' type boards for Ardino etc that use the common little A4988 or DRV8825 modules.  They work great for low power projects and can be had for next to nothing off eBay etc.

https://www.amazon.com/Organizer-Expansion-Stepper-Heatsink-Arduino/dp/B07TT3C3HB

Several Species of Small Furry Animals Gathered Together in a Cave and Grooving with a PICt
 

Offline BeBuLamar

  • Super Contributor
  • ***
  • Posts: 1349
  • Country: us
Re: Controlling Servos vs Steppers
« Reply #15 on: February 17, 2023, 05:58:39 pm »
The servo is more accurate but a lot more difficult to control it. Stepper is a lot easier.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf