Stepper Motors with...
 
Notifications
Clear all

Stepper Motors with Arduino - Controlling Bipolar & Unipolar stepper motors


DroneBot Workshop
(@dronebot-workshop)
Workshop Guru Admin
Joined: 3 years ago
Posts: 1094
Topic starter  

Learn how to use stepper motors with the Arduino.

Full Article with Code at https://dbot.ws/stepper

Today we will be working with stepper motors, a versatile yet often misunderstood electromechanical component used in a variety of devices.

After examining how stepper motors work and what the difference is between a “Bipolar” and “Unipolar” stepper is I will show you how three methods of controlling a stepper motor with an Arduino:

1 - A common 28YBJ-48 Unipolar Stepper with a ULN2003 driver board. These inexpensive stepper and driver combinations are very common and are available on eBay, Amazon, and probably in your local electronics store. I’ll show you two different ways to use these with two different Arduino libraries.

2 - A NEMA 17 Bipolar stepper motor with an L298N dual H-Bridge driver board. We’ve used the L298N driver board in another video to control a pair of brushed DC motors but it also makes a good driver for a bipolar stepper motor.

3 - The same NEMA 17 Bipolar stepper motor controlled by an A4988 stepper driver. This common driver board is used in many 3D printers and CNC machines and simplifies the control of one or several stepper motors with an Arduino.

I’ll also discuss concepts like microstepping and I will show you how to understand some of the many parameters that are included on stepper motor specification sheets.

If you’d like to jump ahead to a particular section in the video here is the table of contents:

00:00 - Introduction
01:34 - Stepper Motor Theory
04:21 - Bipolar vs Unipolar Steppers
08:18 - Common Stepper Specifications
11:32 - NEMA motor sizes
13:41 - 28YBJ-48 Unipolar Stepper with ULN2003
28:16 - NEMA 17 Bipolar with L298N
36:41 - NEMA 17 Bipolar with A4988

As always you can get all of the code I use in this video by visiting the DroneBot Workshop website and looking at the article at https://dbot.ws/stepper. You’ll find code listings and hookup diagrams and well as a convenient ZIP file containing all of the Arduino sketches.

Hopefully, this video will inspire you to start using stepper motors in your own designs.

Now let's get stepping!

"Never trust a computer you can’t throw out a window." — Steve Wozniak


Quote
azflyer
(@azflyer)
Active Member
Joined: 2 years ago
Posts: 6
 

Hi every one,

I am not very good at using a forum.  My question is how can I add a reverse switch to this sketch.  Also how would I know if some one have replied and where can I see the response.

Thanks every one

 


ReplyQuote
Inq
 Inq
(@inq)
Estimable Member
Joined: 2 months ago
Posts: 213
 

As usual... another excellent lecture.  One thing though, the professor didn't notice my raised hand. 🖐️ 😉 

I'm starting my background understanding research for my project and have two three five(ok...) eight questions.  They reproduce if I have too much time on my hands.

  1. (38:20) About the 100 μF capacitor.  Is this used because of the A4988 specifically, or drivers in general, or something else in general?  
  2. Can someone explain its purpose in air-head* terms?
  3. I'm going to be using TMC2209 Trinamic drivers.  Do I need to use the capacitor?
  4. And if all drivers need it, why don't they just put it on the boards?
  5. If I use the Serial interface instead of the pulse method, does that make a difference?
  6. (46:30) About tuning the A4988 for maximum current capability of the stepper motor.  BTW - When I needed to tune a couple of A4988's in the past, all I found were the voltage-calculate-trust method videos.  This was a breath of fresh air that makes far more intuitive sense to me.
  7. I understand that the TMC2209 can adjust this maximum current setting via coding and the Serial interface.  I also am lead to believe that I can get the current (time) value of the current (I=V/r) via coding and the Serial interface.  Can I punt using the volt meter and do a set/read loop and calibrate it via the Sketch?
  8. Will the TMC2209 driver keep this setting non-volatile?  Or... do I need to either store this setting OR perform the calibration on Sketch boot?

I think... that will cover the Inquisition... for now.

* derogatory term used on college engineering campus to identify Aerospace Engineers.  I'm better now, my hair turned grey.

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, Access Point Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


ReplyQuote
Ron
 Ron
(@zander)
Noble Member
Joined: 1 year ago
Posts: 1832
 

@azflyer Subscribe will get you an email notification

It is considered poor judgement to traverse a chasm in 2 leaps.


ReplyQuote
Will
 Will
(@will)
Noble Member
Joined: 11 months ago
Posts: 1764
 
Posted by: @inq

As usual... another excellent lecture.  One thing though, the professor didn't notice my raised hand. 🖐️ 😉 

I'm starting my background understanding research for my project and have two three five(ok...) eight questions.  They reproduce if I have too much time on my hands.

If you take off your wrist watch you won't have time on your hands and more 🙂

  1. (38:20) About the 100 μF capacitor.  Is this used because of the A4988 specifically, or drivers in general, or something else in general?  

c) something in general

  1. Can someone explain its purpose in air-head* terms?

I'll try. Its purpose is to store some charge locally so that if whatever is driving the driver gets busy and voltage drops, the capacitor becomes a local supply to stabilize the power and keep the driver going.

  1. I'm going to be using TMC2209 Trinamic drivers.  Do I need to use the capacitor?

It's safer to use one, but it depends on your circuit(s).

  1. And if all drivers need it, why don't they just put it on the boards?

Because the manufacturers have cut back on crystal balls for economic reasons. They don't know how likely it is that your project will be overloaded or stressed to the point where a capacitor is required, nor to the extent possible. So they leave that to you. Besides it'd cost them another $.02 to add it in 🙂

Sorry, I don't know anything about TMC2209s so I can't answer the rest of the questions you've posed.

I think... that will cover the Inquisition... for now.

I have to confess that I wasn't expecting the Spanish Inquisition 🙂 🙂

I was kidnapped by mimes.
They did unspeakable things to me.


ReplyQuote
Ron
 Ron
(@zander)
Noble Member
Joined: 1 year ago
Posts: 1832
 

@will You were expecting some other inquisition?

It is considered poor judgement to traverse a chasm in 2 leaps.


ReplyQuote
Will
 Will
(@will)
Noble Member
Joined: 11 months ago
Posts: 1764
 

@zander 

Nobody expects the Spanish Inquisition (It's from old Monty Python shows 🙂

I was kidnapped by mimes.
They did unspeakable things to me.


ReplyQuote
Ron
 Ron
(@zander)
Noble Member
Joined: 1 year ago
Posts: 1832
 

@will Yes, another reminder of how slow and old my brain is getting. BIG fan, have most of their DVD's if not all. Also have Faulty Towers, and at one time had a towel and room key.

It is considered poor judgement to traverse a chasm in 2 leaps.


ReplyQuote
Inq
 Inq
(@inq)
Estimable Member
Joined: 2 months ago
Posts: 213
 
"If you know 4 or more languages, you're gifted.  3 and you're average.  2 - You're handicapped.  1 - You must be American."
 
I must be OK, I know:  C, C++, C#, Basic, Fortran, multiple dialects of Assembler, Pascal, Delphi, Java, JavaScript.
 
But don't know no Spanish.  (sic)

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, Access Point Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


ReplyQuote