Pages: [1]   Go Down
Author Topic: Assigning 3 Stepper Motors to the Arduino Uno  (Read 1195 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all, I'm currently doing a project involving running 3 stepper motors using an Arduino Uno. To do this I'm using three easy drivers and a breadboard. http://www.schmalzhaus.com/EasyDriver/Examples/EasyDriverExamples.html if you look at this link and scroll down to example 4 it is an identical setup to this but I am using an additional easy driver and an additional stepper motor.
My question is this, which pins should I assign the third stepper/easy driver to? Since the two ground ports are taken by the other two steppers.
Thank you.
Logged

Southeast US
Offline Offline
God Member
*****
Karma: 15
Posts: 683
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ground is ground (Generally), so you can easily expand the port out by just connecting to one of the other ground wires.  However, I would look into good grounding practices, especially when motors are involved, since they tend to be high current noise sources, and thus irritating. 
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, I'll try that, cheers. So say I was to assign it to the ground on the top left of the board in the picture on the previous link. When I defined the steppers at the start what would I write?
i.e.
AccelStepper stepper1(1, 9, smiley-cool;
AccelStepper stepper2(1, 7, 6);
AccelStepper stepper3(?, 5, 4);
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Any ideas anyone?!

Logged

Grand Rapids, MI, USA
Offline Offline
Sr. Member
****
Karma: 10
Posts: 282
Yes, I remember
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have done a few projects with the easy driver.  I have tried to use the AccelStepper library too, but ended up doing my own controller for various reasons. 

First, lets double check your connections.  You should have the four motor wires from each motor going to the four motor outputs on each EasyDriver.  Your stepper voltage supply coming in should go to M+ on all of the drivers, and the ground from this supply should go to one of the ground pins on each EasyDriver.

Now for the control, each EasyDriver needs a step wire, a direction wire, and a ground wire.  The ground should tie from the EasyDriver ground to the Arduino ground to make sure they are tied together.  The step and direction lines are the only ones which have to go to the digital pins on the Arduino, and they can go to any of them.

Now in the code you should understand what the line you listed is doing.  It is a constructor that makes a new AccelStepper instance.  The first parameter sets the mode of operation.  In your case this is with an external driver and will always be a 1.  The second parameter is the step pin number, so just put in the pin number of the digital pin connected to the step input on the associated EasyDriver.  Similarly, the third parameter is the direction pin, so assign it to the pin number you used. 
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I see, thanks alot that's cleared things up. Out of interest why did you opt out of the AccelStepper library?
Logged

Grand Rapids, MI, USA
Offline Offline
Sr. Member
****
Karma: 10
Posts: 282
Yes, I remember
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In our application (robotic arm) we decided not to use any acceleration in order to get faster response time (acceleration by its very nature slows response).  I should say acceleration as opposed to near instantaneous rotational velocity changes.  (Yes I know that the latter actually has more acceleration, but lets just go with it.) 

The library works fine with instantaneous changes, but it looses some of its value.  Because I was teaching a few high school students how to write the program it was simpler to teach them how to toggle a pair of digital pins that teach them the entire concept of classes and constructors. It also gave us more visibility into what was happening. 
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In our application (robotic arm) we decided not to use any acceleration in order to get faster response time (acceleration by its very nature slows response).

That doesn't sound right. If you don't accelerate the stepper then your top speed is limited to how fast the stepper can jump to from a standing start. If you control the acceleration then you get the same acceleration performance available from a standing start but you can then continue up to a higher maximum speed. If you don't control the acceleration then you won't achieve the maximum speed potential of the motor.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Grand Rapids, MI, USA
Offline Offline
Sr. Member
****
Karma: 10
Posts: 282
Yes, I remember
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I knew I should have explained that more.  We were using a joystick for proportional control, so you could always back off when the motor started skipping steps.
Logged

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have discovered you only need a few steps with a small mass, at a slower speed, to achieve the top speed on my cheap Ebay motors.  This is not the case with a large mass like a full sized DSLR.  Either way it can be easily done manually without a library.
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I just found out, that you cannot run more steppers at the same time with the standard Arduino library.
To make it work, I removed the while loop and all lines with "steps_left" from the "Stepper::step function in "stepper.cpp" and uses the "step" function only with (1) or (-1) argument.
For the time being, I use 2x analog joysticks, proportionally changing the "setSpeed" function for testing 4 steppers, 2-wire control.
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I just found out, that you cannot run more steppers at the same time with the standard Arduino library.

I don't know what causes that restriction, but assuming you're right, it may be that the AccelStepper library doesn't have that restriction.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

BCC AZ USA
Offline Offline
Edison Member
*
Karma: 38
Posts: 1335
It gets hot so it must be working
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

PeterH is right.  The stepper library that comes with the IDE will support only one motor.  Use AccelStepper for multiple motors. 
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank a lot for mentioning the "AccelStepper" library.
Logged

BCC AZ USA
Offline Offline
Edison Member
*
Karma: 38
Posts: 1335
It gets hot so it must be working
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry.
Logged

Pages: [1]   Go Up
Jump to: