Arduino Forum

Using Arduino => Motors, Mechanics, and Power => Topic started by: Robin2 on Dec 10, 2014, 09:46 pm

Title: Stepper Motor Basics
Post by: Robin2 on Dec 10, 2014, 09:46 pm
Introduction
===========
I find myself repeatedly typing similar replies to similar questions about the basics of stepper motors and I thought it would be useful to write this note as it will be a little more comprehensive than any individual reply.

The information is presented under several different headings and there is quite a bit of overlap and cross-referencing of ideas so I suggest that you should read all of the note at least once. I think it would be possible to miss some important info if you only read the bit that immediately interests you.

Throughout this note I have referenced Pololu products. I have no connection with the company apart from being a satisfied user of their A4988 stepper driver boards.

This note is intended to provide guidance for the Arduino user who is new to stepper motors. It is not intended to be an expert dissertation on the subject.

Please be aware that this text continues into the next Post

Types of stepper motor
======================
Broadly speaking there are two types of stepper motor - unipolar and bipolar.

Bipolar motors have 4 wires connecting to the two separate coils inside the motor - one pair for each coil.

There are also two types of unipolar motor - those with 5 wires and those with 6 wires.

The 6-wire motors can also be referred to as hybrid motors. They are similar to the 4-wire bipolar motors and just have an extra wire connected to the centre of each of the coils. If you want to use a 6-wire motor in bipolar mode just ignore the wires that connect to the centres of the coils.

The 5-wire motors cannot be driven by a driver designed for a bipolar motor. An example of a 5-wire motor is the small 28BYJ-48 motor which can be seen in many Arduino projects and usually uses a ULN2003 chip as its driver.

This note only relates to bipolar motors and does NOT apply to 5-wire motors or the ULN2003 driver.


Motor Specifications
====================
Datasheets normally quote the coil current, coil resistance, nominal voltage and holding torque and steps per revolution. For example, for this motor (http://www.pololu.com/product/1209) the values are 1 Amp, 2.7 Ohms, 2.7volts, 1.4Kg-cm and 200 steps/rev.

The nominal voltage is irrelevant for all practical purposes. The important figure is the rated current.

The rated current is normally the current per-coil and when currents are quoted for stepper motor driver boards that is normally also a per-coil figure.

The holding torque is the torque available to resist rotation while the motor is stationary. The available torque will decline as speed increases.

Some manufactures provide graphs showing how the torque varies with speed.


Operating Voltage
=================
Stepper motors are very different from regular DC motors.

With a DC motor you control the current in order to control the speed of the motor. The usual way to control the current is to vary the voltage - perhaps using the Arduino analogWrite() function to control a Pulse Width Modulated power supply to the motor.

Stepper motors pretty much draw their full current all the time, even when they are stationary - that is how they resist being moved from their present position. This means they are very inefficient.

For all practical purposes the nominal voltage of a stepper motor is irrelevant. It is the voltage which would drive the rated current through the coil when the motor is stationary based on Ohms law e.g. 2.7v = 1A * 2.7 Ohms. However, as soon as the motor starts moving the combination of the inductance of the coils and the back-emf generated by the movement will prevent the nominal voltage from producing the rated current.

For this reason stepper motors are normally driven with a much higher voltage. This, in turn, means that a specialized stepper motor driver board is needed which can limit the current to whatever the motor can take. If the current is not limited the high voltage would quickly destroy the motor.


Stepper Motor Driver Boards
===========================
These are specialized components designed to control stepper motors conveniently and efficiently. The Pololu A4988 (http://www.pololu.com/product/1182) is a typical example that is often used with Arduinos.

Generally speaking specialized stepper motor driver boards only require two connections (plus GND) to the Arduino for step and direction signals.

Normally specialized stepper motor driver boards have the ability to limit the current in the motor which allows them to drive the motor with a high voltage (up to 35v for the Pololu A4988) for better high speed performance.

And they all usually have the ability to do microstepping. The Pololu A4988 can do 1/2, 1/4, 1/8 and 1/16 microsteps. It defaults to full steps. I believe the BigEasydriver (https://www.sparkfun.com/products/11876) which uses the same A4988 chip defaults to 1/16 microstepping mode.


H-bridge driver - e.g. LN298
============================
These can be made to control a stepper motor but they are a very poor choice - mainly because they have no method for limiting the current and therefore cannot use high voltages. They are also more trouble to connect to an Arduino (they require more pins) and more trouble to control with an Arduino (more calculations for the Arduino to do).


Choosing a motor and motor driver
=================================
First choose the motor

The important specification is the torque of the motor. Generally speaking the holding torque is quoted. For the motor I linked to above it is 1.4Kg-cm. The available useful torque will decline as the speed increases and at no-load maximum speed it will be zero. Some (probably the more expensive) motor manufactures provide graphs showing how the torque varies with speed.

To figure out what motor you need you will have to measure or estimate the torque required. It would be a good idea to choose a motor with a good margin of surplus torque.

It is not too difficult to make a rough measurement of the torque required but it is beyond the scope of this note.
Edit 17 Feb 2015    See Reply #29 (http://forum.arduino.cc/index.php?topic=284828.msg2097150#msg2097150) for a suggestion

Then choose the stepper motor driver

When you have selected a motor and know what current it requires you can choose a stepper motor driver that can comfortably supply the required current.

You should be aware that the economical single-chip stepper drivers (such as the A4988 and the DRV8825) can only supply about 2 amps. If your motor requires more than that, you will need to get one of the more expensive commercial stepper drivers. However the working principle will be practically identical to the A4988.


NEMA 17 and 23
==============
These standards only define the size of the front face of the motor and the location and size of the mounting screw holes. They say nothing about the power of the motor. The 17 is an abbreviation of 1.7 inches.

...... continued in next Post

...R

Title: Re: Stepper Motor Basics
Post by: Robin2 on Dec 10, 2014, 09:47 pm
continued from previous Post ....

Microsteps
==========
Most (but certainly not all) stepper motors do 200 full steps per revolution. By appropriately managing the current in the coils it is possible to make the motor move in smaller steps. The Pololu A4988 can make the motor move in 1/16th steps - or 3,200 steps per revolution.

The main advantage of microstepping is to reduce the roughness of the motion. The only fully accurate positions are the full-step positions. The motor will not be able to hold a stationary position at one of the intermediate positions with the same position accuracy or with the same holding torque as at the full step positions.

Generally speaking when high speeds are required full steps should be used.

It is possible with most drivers including the Pololu A4988 to use the Arduino program to change the microstep setting. This would require additional connections between the driver and the Arduino.


Stepper Motor Speed
===================
By comparison with regular DC motors stepper motors are very slow devices.

Typical speeds might be 1000 to 4000 steps per second and for a 200 step motor that would represent 5 to 20 rps (300 to 1200 rpm).

Generally speaking the motors with low coil resistance and high currents (and low nominal voltages) will be most suitable for higher speeds. A high voltage will also be needed for high speed.


Acceleration
============
If the stepper motor is required to move a heavy load it will normally be necessary to start the movement slowly (as with any motor) and accelerate to the desired speed and, equally, to decelerate when it is necessary to stop.

This is quite different from a DC motor which will accelerate and decelerate automatically.

If you try to start or stop a stepper motor too quickly it will simply skip steps with no damage to motor. However The Arduino has no means to know whether or how many steps have been missed and all of the position control will be lost.

For this reason, in particular, it is essential to choose a motor with sufficient torque for the job and to use acceleration and deceleration when necessary.


Position Feedback
=================
Stepper motors do not have the ability to tell the Arduino what position they are at, nor do they have the ability (like a servo) to go to a particular position. All they can do is move N steps from where they are now.

If it is essential to have position feedback a rotary encoder can be attached to the motor shaft - but that is beyond the scope of this essay.


Initial Position
================
When it starts up the Arduino has no means of knowing where the stepper motor is positioned - for example somebody might have moved it manually when the power was off.

The usual way to establish a datum for counting steps is with a limit switch. At startup the Arduino will move the motor until it triggers the switch. The Arduino will then regard that step position as step zero for the purpose of future position keeping.


Arduino Libraries
=================
When using an Arduino with a specialized stepper motor driver board such as the Pololu A4988 there is little to be gained from using an Arduino library unless you need the acceleration feature of the AccelStepper (http://www.airspayce.com/mikem/arduino/AccelStepper/) library.


Demonstration Arduino code
==========================
The code in my simple stepper demo (http://forum.arduino.cc/index.php?topic=277692.0) is intended as a first step to getting your motor working. It also shows how easy it is to control a motor without a library when a specialized stepper motor driver such as the Pololu A4988 i8s used.


Wiring connections for a stepper motor
======================================
The code in my simple stepper demo assumes that the motor is connected as shown in the wiring diagrams on the Pololu A4988 web page.


Arduino Pulse Width Modulation (PWM)
====================================
Arduino PWM using analogWrite() has nothing to do with controlling stepper motors. To control a stepper motor though a specialized stepper motor driver the Arduino just needs to provide step and direction signals using digitalWrite().

PWM may be used within the stepper motor driver to limit the current in the motor coils but this process is invisible to the Arduino user.

....END

...R

Edit 01 Jan 2014 to change "proper" to "specialized"
Title: Re: Stepper Motor Basics
Post by: daniellyall on Dec 11, 2014, 11:37 am
bang on

good start for nobs
Title: Re: Stepper Motor Basics
Post by: Cactusface on Dec 11, 2014, 12:25 pm
Hi Robin,
               Thanks that was very useful! I have had a little play with some old salveged steppers (EX printer, etc) and hope one day to build a bot using them for accurate movement and perhaps drawing, etc or as I suggested to someone the other day a Pantagraph? or drawing machine!!  I have used the good old ULN28003, but the new A4988 type of modules make it a lot easier with only two signals STEP & DIR. Fixing wheels on a 5mm shaft can be tricky....

Regards

Mel.
Title: Re: Stepper Motor Basics
Post by: dave-in-nj on Dec 11, 2014, 01:22 pm
"The nominal voltage is irrelevant for all practical purposes. The important figure is the rated current. "


I disagree with this statement.  the manufacture offers data for the end user to use for calculations.  this statement is akin to saying that resistor wattage is irrelevant for all practical purposes in data circuits.


the stepper motor is a coil, the coil has inductance.  what you can do with a coil is very much based on manufacture. ergo the manufacture offers test data.  the motor power supply calculation requires you know the motor voltage, then allows for the inductive reactance.  


a motor has two major causes of heating, copper losses and iron losses.  copper losses are from power flowing through the motor.  iron losses are from the eddy currents and hysteresis heating.  


every motor has a maximum voltage rating.  it is a disservice to dismiss a part of the calculations without describing why.


I offer white papers from a stepper motor designer.  probably one of the foremost authorities on stepper motors.  


You would do well to read and understand how a stepper motor uses voltage and power and why they are so important to understand, especially if you want to post as a source of teaching for others.


http://www.geckodrive.com/app-notes.html



he has a simple writing style and except for a few spelling errors (ration instead of ratio) he is very readable.


Title: Re: Stepper Motor Basics
Post by: JimFlounders on Dec 11, 2014, 02:13 pm
Good stuff.
Thanks
Title: Re: Stepper Motor Basics
Post by: Robin2 on Dec 11, 2014, 02:26 pm
every motor has a maximum voltage rating.  it is a disservice to dismiss a part of the calculations without describing why.
I make no apology for keeping my material simple. And I did say "for all practical purposes" - meaning for all practical purposes for the people for whom the note is written.

The important point is that when the datasheet says 2.7v it does not mean that is the maximum you can use, nor even that it is close to ideal.

If you can give me one or two sentences that will enhance the text without confusing newcomers I will certainly consider including them. That is the purpose of asking for comments.

...R
Title: Re: Stepper Motor Basics
Post by: nilton61 on Dec 11, 2014, 05:12 pm
What is of interest in motor voltage is that it leads to a maximum value of the power supply
Quote
32 * VL = VMAX
The reason for this is iron losses (eddy currents) heating up the motor. But, this is almost academical since most stepper motors i encountered have motor voltages over 1,5V and supplies over 45V are seldom used. Also most drivers set the upper voltage limit at 35V which is safe for almost all motors.

Ecellent text, and really needed. What could be added is that power supplies should be unregulated with a filter/reservoir capacitor with a value of:
Quote
(80,000 * I) / V = C(uF)
Title: Re: Stepper Motor Basics
Post by: Robin2 on Dec 11, 2014, 06:15 pm
Ecellent text, and really needed. What could be added is that power supplies should be unregulated with a filter/reservoir capacitor with a value of:
Thank you (and everyone else) for the kind words.

I have noted your very useful views about power supplies elsewhere but I don't feel competent to write a text about it myself. Perhaps you could find the time to write a few sentences which can either stand here as a separate post or I might incorporate it into my text.

My own experience is that a computer power supply (18v or so) and a large 12v lead-acid battery work fine. I haven't tried an unregulated supply myself to see if it would be better.

And I don't want to discourage or prevent newcomers from using a satisfactory power supply that they happen to have, even if it is sub-optimal.

...R
Title: Re: Stepper Motor Basics
Post by: nilton61 on Dec 11, 2014, 07:36 pm
The reason for advocating unregulated supplies is that regulated ones more often than not have quite small reservoir/filter caps. This has two negative effects

So the main issue is having large enough caps which should be stated.
Title: Re: Stepper Motor Basics
Post by: Robin2 on Dec 11, 2014, 08:22 pm
So the main issue is having large enough caps which should be stated.
I've been thinking some more about the possibility of a text about power supplies and the problem is that I keep running into more questions which leads me to think that it needs an entire Thread of its own.

For example does the piece I have quoted mean that it is a good idea to attach a very large capacitor to a regulated power supply as well as to an unregulated supply?

And, to confirm my understanding, I have 3 motors that each have a coil current of 0.33 A. That would mean 0.99A for all  3 - say 1.5A to give a margin. And, supposing they are powered at 20v your formula would be
     80,000 * 1.5  / 20 which gives a capacitor value of 6,000 microFarads.

And without intending the least disrespect to your knowledge I have not yet got any sense of how much difference it would make to have an unregulated rather than a regulated power supply with the same voltage assuming both can deliver enough amps.

...R
Title: Re: Stepper Motor Basics
Post by: daniellyall on Dec 12, 2014, 12:45 am
just a note on my router I have 1400w 16 amp 80vdc power supply's the motors don't get hot at all I can push them to 150vdc then they will get hot.

having a decent stepper driver takes care of its motors.

robin it would be a good idea to add in the steeps need to work out what size stepper a person would need to get
Title: Re: Stepper Motor Basics
Post by: Robin2 on Dec 12, 2014, 11:13 am
robin it would be a good idea to add in the steeps need to work out what size stepper a person would need to get
I thought about that. But it can get very complex - especially if you try to keep it simple. So much depends on the reader's level of knowledge. That's why I just left it at "To figure out what motor you need you will have to measure or estimate the torque required ..... It is not too difficult to make a rough measurement of the torque required but it is beyond the scope of this note.".

If you have time to submit a suggested text I would really appreciate it.


...R
Title: Re: Stepper Motor Basics
Post by: dave-in-nj on Dec 12, 2014, 12:46 pm
just a note on my router I have 1400w 16 amp 80vdc power supply's the motors don't get hot at all I can push them to 150vdc then they will get hot.

having a decent stepper driver takes care of its motors.

robin it would be a good idea to add in the steeps need to work out what size stepper a person would need to get
I believe that the purpose of this thread is to hand-hold a newbie and get them past the common problems.  As Robin2 stated, this thread addresses the repeated problems newbies encounter.
It is a superficial introduction, touching only on the needed parts, but considering the limited space and the capacity of the newbie to grasp the concepts, it is at exactly the right level.  a good idea and pretty well executed.

Title: Re: Stepper Motor Basics
Post by: dave-in-nj on Dec 12, 2014, 01:04 pm
And without intending the least disrespect to your knowledge I have not yet got any sense of how much difference it would make to have an unregulated rather than a regulated power supply with the same voltage assuming both can deliver enough amps.

...R

I believe the whole concept of this thread is to get the NEWBIE to connect a stepper and make it move.
that said, almost any power supply will work for this purpose.  and old brick that has the current, an old PC power supply. whatever.   I am content on building my own, but IMHO building a power supply is about 5 steps down the road, and does not belong at this level.
suffice it to say that to get started, a power supply that has enough current should be good enough to use to get the motors moving and it is is an old PC power supply with 12 volts or one from an old laptop, it does not matter in order to get that motor spinning.  once you have gotten the motor to spin and step forward and back and things look good, it would be desirable to try to improve the performance by either building or buying a power supply that is selected for the application.
as a note, the back EMF being delivered to the power supply from coil-A will be immediately send to coil-B and not stored.  for that reason, the regulated power supply will often work fine.  in addition, many regulated power supplies are designed to handle the higher voltage.  lastly, I sincerely believe that AT THIS LEVEL, no newbie will be running high power, high current motors under a load with sufficient deceleration as to create enough back EMF to be of any concern.
Title: Re: Stepper Motor Basics
Post by: dave-in-nj on Dec 12, 2014, 01:24 pm
I think that generally speaking, this is a good start.  It is apparent that the writer does not like the L298 boards that so many newbies have and ask about.   I would offer that more technical discussion would be called for.  It appears to me that the section about them is dismissive.

the L298 does have sense resistors to limit current, check the data sheet.

IMHO, it would be appropriate to remove the writers (negative) evaluation of the board and be more technical.

the L298 is a full or half step driver that can power a stepper.  it takes 4 pins from the Arduino and is used on a bi-polar motor.  running a full step at slow speed will have the motor appear to jump and shake.  a half step will remove much of the apparent motor movement.   The cost of the L298 is comparable to the A4988.  in the opinion of the writer the A4988 is a much better choice. 

a micro-stepper breaks each step by sending each of the two coils some energy.     if you think of it as taking the power and one coil gets 90% and the other gets 10%, then 80/20, 70/30... and so on, you can see that the movement will be much more fluid.  this is most apparent at reduced speeds.

at higher speeds the micro-stepping actually takes more time and can become a problem.    at this introductory level, we do not need to address these things, but only bring them to your attention.  This is mentioned because you will find both the jumpy movement at low speeds with a full step driver and a limit to high speed when using a high number of micro-steps,.
Title: Re: Stepper Motor Basics
Post by: dave-in-nj on Dec 12, 2014, 01:27 pm
motor speed :

a DC motor delivers full power and full torque at high speeds.  as the speed is reduced, the power drops off.
a stepper delivers maximum power at it's lowest speeds and as speed increases, power drops off.
each type of motor has applications that they are best suited for.
Title: Re: Stepper Motor Basics
Post by: nilton61 on Dec 12, 2014, 02:43 pm
motor speed :

a DC motor delivers full power and full torque at high speeds.  as the speed is reduced, the power drops off.
a stepper delivers maximum power at it's lowest speeds and as speed increases, power drops off.
each type of motor has applications that they are best suited for.
Not quite correct.

It seems that a similar text on rotating machinery is also needed
Title: Re: Stepper Motor Basics
Post by: Robin2 on Dec 12, 2014, 02:50 pm
but considering the limited space and the capacity of the newbie to grasp the concepts, it is at exactly the right level.  a good idea and pretty well executed.
It is apparent that the writer does not like the L298 boards that so many newbies have and ask about.   I would offer that more technical discussion would be called for.  It appears to me that the section about them is dismissive.
....SNIP....
IMHO, it would be appropriate to remove the writers (negative) evaluation of the board and be more technical.
I find it very difficult to reconcile these quotes from 2 different posts?

I agree I am dismissive about L298 drivers. Compared to using a proper stepper motor driver board they are the equivalent of painting the outside of a house with a 25mm paint brush.

...R
Title: Re: Stepper Motor Basics
Post by: daniellyall on Dec 13, 2014, 02:34 am
L298 are only good for new bees who don't know any better they are a pain

to drive a stepper so it does not over heat it and do stupid things it needs a proper stepper driver like a A4988 or equivalent, steppers are holding torque to its curve drop off nothing else

1. working out what size stepper to get is what's the amount of torque will it need for the load it needs to move.

2. what is the amount of current needed to drive said stepper for load being moved.

3. what is the max current that the said stepper be needing to be driven at the speed required up to the top of its curve

4. then you get a stepper driver that can handle said amount of current plus a bit extra for back emf.

5. A power supply that can produce the amount of current needed under its max load.

also some one say what a stepper they are using gets, it`s is a good thing to have in any discussion as if someone work out they need a power supply and driver of simmaler size they can ask that person what is there set up, I use big and small steppers.

in a discussion I have had I asked people who have the same size stepper as the machine I have (was meant to have) what there set up was people with same size machine and smaller said they had no problems with there steppers what where the same as mine so what was wrong with my set up. simple answer miss labled steppers.

if I did not ask what peoples set ups where I probley would not have worked out the stepper where miss labled.
so anything in a discussion about correct set ups of stepper, power supply's and drives can`t be bad if a person does not under stand they can just ask.
Title: Re: Stepper Motor Basics
Post by: Robin2 on Dec 13, 2014, 08:56 am
@daniellall, I'm not sure if your Reply #19 is partly a response to my Reply #12.

I think I have covered your points 1-4 in my original text.

I haven't covered power supplies (point 5) - apart from the question of voltage. I assume the user is sensible enough to use a power supply with sufficient amps. That aspect is not specific to stepper motors.

@nilton61 and others have added useful posts about power supplies.

...R
Title: Re: Stepper Motor Basics
Post by: daniellyall on Dec 13, 2014, 11:21 am
yes it is, its as simple as I can put it.

its the way I work it out

its in 5 lines with all the correct words that anyone can find with Google or I could have just said read this
http://www.geckodrive.com/app-notes.html

that has all what is need to know
Title: Re: Stepper Motor Basics
Post by: neksmerj on Dec 13, 2014, 11:53 am
Robin2,

A really well written, concise tutorial for the benefit of all us novices.

Ken
Title: Re: Stepper Motor Basics
Post by: weldsmith on Dec 13, 2014, 09:36 pm
Robin2,

Very nice, I am not a newbie to stepper motors, and you pulled me in. I read the whole thing!

A person certainly would not get the performance they need in many cases if they stuck to the rated voltages. The availability and price of stepper drives have drastically improved in the recent years. These new cheaper drives control the amps by your setting and then chops the voltages as needed. This generally gives you more speed and torque. The newbie has a lot less to worry about these days.
Title: Re: Stepper Motor Basics
Post by: o_lampe on Dec 16, 2014, 10:47 am
Well written tutorial Robin!

I'm just missing a more detailed description, how to connect a unknown stepper to a driver board.

Describe how a ohm-meter can be used to find out which are the ends/centers of a coil and if it makes a difference which way you connect a coil to the driver. A newbee might be confused which coil is A or B and which end of the coil is A1 or A2.

Title: Re: Stepper Motor Basics
Post by: Robin2 on Dec 16, 2014, 09:14 pm
I'm just missing a more detailed description, how to connect a unknown stepper to a driver board.
I guess that's why I didn't write it   :)

Quote
Describe how a ohm-meter can be used to find out which are the ends/centers of a coil and if it makes a difference which way you connect a coil to the driver. A newbee might be confused which coil is A or B and which end of the coil is A1 or A2,
Can you post a few sentences that may be suitable to incorporate in the text?

I don't actually know if it matters which end is A1 - I don't think it does.

...R
Title: Re: Stepper Motor Basics
Post by: daniellyall on Dec 17, 2014, 09:51 am
as far as what I have done it does not matter what end is A+ or A- as long As B+ and B- are the same order as A+ and A- flipping A+ A- B+ B- just changes direction.
Title: Re: Stepper Motor Basics
Post by: dave-in-nj on Dec 26, 2014, 02:19 pm

Quote
These can be made to control a stepper motor but they are a very poor choice - mainly because they have no method for limiting the current and therefore cannot use high voltages.
reading the data sheet is in order.
the L298 certainly does have limiting resistors and many of the available boards on the market have them out to pins.   the vast majority of the super-cheap e-bay ones are set for full power,




.
Title: Re: Stepper Motor Basics
Post by: daniellyall on Dec 27, 2014, 02:27 am
reading the data sheet is in order.
the L298 certainly does have limiting resistors and many of the available boards on the market have them out to pins.   the vast majority of the super-cheap e-bay ones are set for full power,




.
you have all ready said most of that

the l298 are a poor choice for controlling stepper 4 wires, proper stepper driver 2 wires which one is better 4 wires or 2
Title: Re: Stepper Motor Basics
Post by: Robin2 on Feb 17, 2015, 04:57 pm
A simple method to get a rough measurement of the required torque.

Attach some sort of wheel or drum to the shaft that the stepper motor will be required to turn. Wrap some strong thread or fine string around the drum and suspend a small plastic beaker from it. This will obviously only work if the shaft is horizontal.

Add coins to the beaker until the weight is just sufficient to make the drum rotate. Weigh the beaker with the coins in it.

Measure the diameter of the drum where the thread is wrapped and calculate the radius. Suppose the radius in 2cm and the weight is 100grams. Then the torque is 200gm-cm.

Repeat the measurement several times and take an average. Choose a motor with perhaps twice that amount of torque to provide a good safety margin.

...R
Title: Re: Stepper Motor Basics
Post by: MarkT on Feb 17, 2015, 09:09 pm
It might be more than twice I fear.  This article might be helpful, explaining torque v. speed curves:  http://www.orientalmotor.com/technology/articles/article-speed-torque-curves-for-step-motors.html (http://www.orientalmotor.com/technology/articles/article-speed-torque-curves-for-step-motors.html)

So with your load torque measurement taken, look at the graphs for the motor in question
and be prepared to also add in a safety margin on top of that...
Title: Re: Stepper Motor Basics
Post by: Robin2 on Feb 17, 2015, 10:28 pm
Thanks for adding that Mark. It looks like it has a lot of useful data.

...R
Title: Re: Stepper Motor Basics
Post by: polymorph on Feb 18, 2015, 12:04 am
Quote
the L298 does have sense resistors to limit current, check the data sheet.
It is more correct to say that the L298 has a place to add sense resistors to enable external ICs to measure and limit current. The L298 has no mechanism to limit current.

In fact, it can be used with the L297 to make a chopper stepper driver.

(http://i.stack.imgur.com/aKyKm.jpg)

The advantage to this over the A4988 is slightly increased current (rated at 2A, but you can fit a big heat sink), and increased working voltage at 46V max. The saturation voltage is rather high, due to the use of bipolar transistors. On the order of up to 4.9V total (both opposite legs of an H bridge) at 2A. Plus the voltage drop across the sense resistor.

So I don't recommend it.
Title: Re: Stepper Motor Basics
Post by: 1:1 on Feb 18, 2015, 03:08 pm
A simple method to get a rough measurement of the required torque.

Attach some sort of wheel or drum to the shaft that the stepper motor will be required to turn. Wrap some strong thread or fine string around the drum and suspend a small plastic beaker from it. This will obviously only work if the shaft is horizontal.

Add coins to the beaker until the weight is just sufficient to make the drum rotate. Weigh the beaker with the coins in it.

Measure the diameter of the drum where the thread is wrapped and calculate the radius. Suppose the radius in 2cm and the weight is 100grams. Then the torque is 200gm-cm.

Repeat the measurement several times and take an average. Choose a motor with perhaps twice that amount of torque to provide a good safety margin.

...R
I know it's meant for newbies - but maybe supply a link to more text that describes rotational inertia and static/dynamic friction?

Non-linearities such as static friction and backlash/dead zones for that matter can give you all sorts of headaches if you're not aware of them.

Rotational inertia also, ponderous (massive, but well lubricated) equipment will eventually get going with twice the torque rating of whatever it took to break the static friction, but you're still left with a very slow system. You might want 100 times more...   I guess steppers are by their nature speed restricted at the lower end (compared to DC/AC servos which have different limiting characteristics) - maybe the discussion is outside of your defined  context.
Title: Re: Stepper Motor Basics
Post by: Robin2 on Feb 18, 2015, 06:49 pm
I know it's meant for newbies - but maybe supply a link to more text that describes rotational inertia and static/dynamic friction?
I would be happy to do so. Have you any suggestions, or perhaps you could write a few lines yourself?

...R
Title: Re: Stepper Motor Basics
Post by: 1:1 on Feb 19, 2015, 12:12 am
I would be happy to do so. Have you any suggestions, or perhaps you could write a few lines yourself?

...R
heh - a few lines!  Sheesh, once I started I couldn't stop ...  :smiley-mr-green:

I thought it would be useful to provide some additional advice for getting a reasonable estimate of the torque required to get something moving.

A torque is a force applied with a lever arm. In the example in Reply #29 the "lever arm" is the radius of the drum and the force is the weight hanging from the thread. The system will feel exactly the same effect with a stepper at the same rating.

Don't skip the step of using a drum or something round, using a ruler might seem like a nice idea but it will give you erroneous results as it creates it's own torque and the torque will decrease as it rotates past horizontal - by using round lever arm with string it cancels out its own effects and keeps the force vertical at all times (you can point this out once you've attracting interest in your peers and people will think you're very clever).

By doubling the rating you're going to be sure you can get the system at least moving. However there are some effects and considerations that might mean you want to go a lot higher than this, and a small chance lower.

Firstly, there are non-linearaties such as backlash, and 'stiction' (static friction). Might sound technical, but they're things you're no doubt aware of from using everyday mechanical objects. Notice how sometimes things are hard to move initially but once you get them going, they're good? Or sometimes when you turn a knob in the other direction the system doesn't change directions immediately because there is some slack in the mechanism? Well that's stiction and backlash respectively. Why mention them? Well, if you measure your torque and don't take account of them, you could under or over-estimate your rating, although it's not perfect try to make sure your system is in the state that it will be under normal operation, sometimes if a something sits for a long time, dry lubrication, thermal expansion/contraction can cause stiction effects, maybe you want to predict that it'll be there under normal operation and account for it, maybe you know that your system will be warmed up and can ignore it. Backlash is harder to account for, but know that in 99%+ cases it'll only get worse. If you cant eliminate it before measuring torque at least consider the implications, there is a small possibility you could underestimate the torque required.

Another effect that isn't so related to the initial torque measurement but certainly effects your system, is the rotational inertia of the mechanism. Twice the torque might get something moving - i.e. you will get your velocity eventually - but did you get that velocity fast enough? i.e. acceleration…  Especially relevant if you're wanting to change directions quickly. Think of a bicycle wheel, ever changed a tyre and spun the wheels in your hands to play with the gyro effect? Well, it's not quite the gyro effect I'm talking about (although that certainly is interesting stuff), but what you may have noticed is that the effect is larger when the tyre is on compared to off, that is because the wheel has a higher 'moment of inertia'.

There is more mass, 'at a distance' - sound familiar?

Yes, just like torque!

You may have also noticed it was harder to start and stop spinning? (i.e. it took longer). This is the effect a stepper will have to deal with also. Double rating might not cut it ;)

That being said, for many applications in the world of hobby/arduino/desktop robotics, inertia analysis is overkill as the parts you're moving will likely be mated with over-spec steppers from word go and friction might be the over-ruling factor anyway. But it's nice to get an initial appreciation of it's effects.

As a final word, keep in mind you experience torque, inertia, friction and backlash in the world around you often (steering wheels, can openers, bicycles, door handles etc.) - if all this sounded too technical then just let your intuition guide you.

(edited after a few suggestions from Robin)
Title: Re: Stepper Motor Basics
Post by: marco1990 on Feb 19, 2015, 12:29 pm
Hi Robin,
I use your code for driving my stepper motor. I attached here:


byte directionPin = 2;
byte stepPin = 3;
int numberOfSteps = 2000;
//int pulseWidthMicros = 20; // microseconds
int millisbetweenSteps = 25; // milliseconds

void setup() {
 
  Serial.begin(9600);
  Serial.println("Starting StepperTest");
 
  delay(2000);
 
  pinMode(directionPin, OUTPUT);
  pinMode(stepPin, OUTPUT);
 
  digitalWrite(directionPin, HIGH);
  for(int n = 0; n < numberOfSteps; n++) {
    digitalWrite(stepPin, HIGH);
   // delayMicroseconds(pulseWidthMicros);
    digitalWrite(stepPin, LOW);
   
    delay(millisbetweenSteps);
   
  }
 
  delay(3000);
 

  digitalWrite(directionPin, LOW);
  for(int n = 0; n < numberOfSteps; n++) {
    digitalWrite(stepPin, HIGH);
   // delayMicroseconds(pulseWidthMicros);
    digitalWrite(stepPin, LOW);    delay(millisbetweenSteps);
   }
}

   

void loop() {
}
   
My problem is to obtain the angular velocity of the shaft. If my millisbetweenSteps are 25 is correct to take the frequency equal to: f = 1/0.0025 Hz?

Thank you so much Robin
Title: Re: Stepper Motor Basics
Post by: ShapeShifter on Feb 19, 2015, 01:42 pm
If my millisbetweenSteps are 25 is correct to take the frequency equal to: f = 1/0.0025 Hz?
You've slipped the decimal point one place f = 1 / 0.025 or 40 Hz.

That's the step frequency. The revolutions per second is the steps per second, divided by the steps per revolution: Assuming 200 steps per revolution, that is 40 / 200 or 0.2 revolutions per second. Divide that by 60 and you get revolutions per minute or 0.00333 RPM.

To get angular velocity (degrees per second) take revolutions per second, and multiply by 360 degrees per revolution. So, with 25 ms between steps, and 200 steps per revolution, that gives 72 degrees per second.

Title: Re: Stepper Motor Basics
Post by: Robin2 on Feb 19, 2015, 02:22 pm
Thank you so much Robin
Don't waste time double posting. I already answered your question here (http://forum.arduino.cc/index.php?topic=299230.msg2100885#msg2100885).

...R
Title: Re: Stepper Motor Basics
Post by: Robin2 on Feb 19, 2015, 03:10 pm
Sheesh, once I started I couldn't stop ... 
Thanks very much. I sent you a couple of PMs so as not to confuse stuff here

...R
Title: Re: Stepper Motor Basics
Post by: 1:1 on Feb 19, 2015, 11:49 pm
Thanks very much. I sent you a couple of PMs so as not to confuse stuff here

...R
Maybe once it's all settled - start a new post, than ask a mod to lock and sticky it ?
Title: Re: Stepper Motor Basics
Post by: CoffeeMan on Feb 20, 2015, 10:51 pm
Hi everyone,

First of all thank you for being such a community.  I started working on a project that will need an arduino and so i thought i would try to figure it out myself. Seeing how much is posted here, I don't feel entirely alone on this quest.

To make this project work I bought:
- Arduino Uno
- a 5.5A/4.6Nm stepper motor
- a Power Microstep Driver (with a range of 3.8 - 8.0A)
- and finally a PSu with a max output of 24VDC & 6.25A

I keep running into the same problem - every time i run a script and initiate it on the hardware, the stepper makes a single step, then the red Alert light on the Driver pops on.

I have tried a number of skripts, redoing the wire configuration, & messing with the SW switches.  I can't think of how to tackle this problem - has anybody else ran into this?

Any advice will be EXTREMELY appreciated.

Thanks Again!
Title: Re: Stepper Motor Basics
Post by: polymorph on Feb 20, 2015, 11:07 pm
Coffeeman, you need to start your own thread.
Title: Re: Stepper Motor Basics
Post by: Robin2 on Feb 21, 2015, 11:35 am
Agree with @polymorph.
It would be a big help if others would NOT respond to @Coffeeman here as it will just confuse the purpose of this Thread.

...R
Title: Re: Stepper Motor Basics
Post by: CoffeeMan on Feb 22, 2015, 10:49 am
Will do. thanks
Title: Re: Stepper Motor Basics
Post by: MarkT on Mar 03, 2015, 02:09 am
Slight correction needed:

Quote
With a DC motor you control the current in order to control the speed of the motor. The usual way to control the current is to vary the voltage - perhaps using the Arduino analogWrite() function to control a Pulse Width Modulated power supply to the motor.
For PMDC (permanent magnet DC) motors the _voltage_ controls the speed, the current
is proportional to the torque.  You can use voltage control or current control, for speed and
torque drive respectively.  This is true of BLDCs too.
Title: avrdude error
Post by: 18omkar on Jun 22, 2015, 11:05 pm
Hey Hi
I used your given code for checking stepper but repeatedly getting this error:

avrdude: verification error, first mismatch at byte 0x016c
         0x00 != 0x80
avrdude: verification error; content mismatch

I have checked my board as Mega 2560, serial communication port, drivers, connections etc.
All looks perfect.

I have connected via reprap Pololu Shield RAMPS 1.4

Please help me how to resolve this error.
Title: Re: Stepper Motor Basics
Post by: Robin2 on Jun 23, 2015, 09:00 am
This is the first time anyone has reported that sort of problem. I think it is an uploading problem rather than a problem with compiling my code - but I am not an expert on AVRDUDE.

Post the actual code you are trying to use

Are you able to upload other programs to your Mega ?

...R
Title: Re: Stepper Motor Basics
Post by: ShapeShifter on Jun 23, 2015, 04:27 pm
I agree, it sounds like a problem with the development environment, not the sketch. Try loading a different sketch: if that also has a problem, then it's definitely an environment problem. A better place to find an answer would be in the Installation & Troubleshooting (http://forum.arduino.cc/index.php?board=2.0) forum.
Title: Re: Stepper Motor Basics
Post by: nilton61 on Aug 26, 2015, 11:10 am
The Leadshine drives (http://www.leadshine.com/producttypes.aspx?type=products&category=stepper-products&producttype=stepper-drives) are very competent drivers but they are quite costly, several 100$ depending on model. The question is if you not are better off getting a servo drive instead when spending that kind of money.
Title: Re: Stepper Motor Basics
Post by: Isabelle_VP on Oct 02, 2015, 10:41 am
Hello Robin2,

Thank a lot to have written those both wonderful posts ! It explains very well and easily!
Thanks also to have answered yesterday to my posts !  
Title: Re: Stepper Motor Basics
Post by: Marciokoko on Feb 07, 2016, 02:36 pm
Great thread.  I'm a newbie.  I would suggest 2 things:

1.  Get rid of the power talk posts and include it as links (as you did with measuring torque).  As mentioned, we are interested in making the stepper move.

2.  Can you make this and many other topics in this forum into stickies?  I feel there are lots of common n00b issues that could be dealt with if stickies were available.

Thanks robin2!
Title: Re: Stepper Motor Basics
Post by: Robin2 on Feb 07, 2016, 06:05 pm
Great thread.  I'm a newbie.  I would suggest 2 things:

1.  Get rid of the power talk posts and include it as links (as you did with measuring torque).  As mentioned, we are interested in making the stepper move.

2.  Can you make this and many other topics in this forum into stickies?  I feel there are lots of common n00b issues that could be dealt with if stickies were available.
Thank you for your kind words.

I don't know which Posts you refer to in 1.
The only reason the Torque stuff is in a link is because it was an afterthought :)

Item 2 is not a matter for me. There are already stickies in some Forum sections - but not this Thread. Too many stickies can be as big a problem as too few.

...R