Hi everyone,

for my projekt at the technikal college I need to work with arduino and I have some troubles with it. I want to use the following componets to drive 2 stepper motors:

Arduino Uno
2x pd2-013-42 bipolar stepper motors

I found an example for using 2 stepper motors and I tried to use it for my projekt, but sadly it didn´t worked as I thought it would.
The sketch I used is the AFMotor_MultiStepper with Accelstepper and AFMotor library, if I understand it right, it should make an objekt that the AccelStepper can use.

My problem at the moment is, that I don´t know if my code is wrong or if something else doesn´t work as I intended it would.
So far i could run it with the normal Stepper library to let it turn clock- and counterclockwhise, but I couldn´t figure out why it doesn´t work with this sketch.
The motor doesn´t take much current only about 0.05 A but it should take about 0.6 A, so no motorcoil is powered.
I´m new to Arduino and any kind of help would be appritiated.

Here is the code I used:

Code: Select all | TOGGLE FULL SIZE
#include <AccelStepper.h>
#include <AFMotor.h>

// Objekt mit (200 Schritten, an Port 1) z.B.
AF_Stepper motor1(200, 1);
AF_Stepper motor2(200, 2);

// SINGLE (eine Spule), DOUBLE (zwei Spulen), INTERLEAVE (wechsel zwischen SINGEL u. DOUBLE)
//für doppelte Auflösung aber halbe Geschwindigkeit, MICROSTEP (mit PWM (Pulsweitenmodulation) für ruhige Bewegung des Motors)
// Methoden für Vorwärts und Rückwärtsbewegung der Motoren
void forwardstep1() {
motor1.onestep(FORWARD, DOUBLE);
}
void backwardstep1() {
motor1.onestep(BACKWARD, DOUBLE);
}
void forwardstep2() {
motor2.onestep(FORWARD, DOUBLE);
}
void backwardstep2() {
motor2.onestep(BACKWARD, DOUBLE);
}
// Motor Ports nutzbar für Accelstepper machen
AccelStepper stepper1(forwardstep1, backwardstep1);
AccelStepper stepper2(forwardstep2, backwardstep2);

void setup()

stepper1.setMaxSpeed(20.0);
stepper1.setAcceleration(10.0);
}

void loop()
{
stepper1.run();
}
Techniker2013

Posts: 2
Joined: Mon Oct 28, 2013 8:45 am
Location: Germany

AF_Motor is the library for the older motor shield. For the V2 shield you need the V2 library.

Also, make sure you are using the Adafruit-modified version of AccelStepper.

Posts: 52094
Joined: Sat Feb 07, 2009 10:11 am

Thank you for the help, i used the wrong library like you said.
Could you send me a link for the modified version of the Accelstepper reference, or does it have the same programming commands, like the common one?

Yours sincerely, Techniker2013
Techniker2013

Posts: 2
Joined: Mon Oct 28, 2013 8:45 am
Location: Germany