Adafruit Motorshield V2 instantiating

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
Techniker2013
 
Posts: 2
Joined: Mon Oct 28, 2013 8:45 am

Adafruit Motorshield V2 instantiating

Post by Techniker2013 »

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
Adafruit Motorshield V2
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

#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();
}

User avatar
adafruit_support_bill
 
Posts: 88141
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit Motorshield V2 instantiating

Post by adafruit_support_bill »

AF_Motor is the library for the older motor shield. For the V2 shield you need the V2 library.
https://github.com/adafruit/Adafruit_Mo ... V2_Library

Also, make sure you are using the Adafruit-modified version of AccelStepper.
https://github.com/adafruit/AccelStepper

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

Re: Adafruit Motorshield V2 instantiating

Post by Techniker2013 »

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

User avatar
adafruit_support_bill
 
Posts: 88141
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit Motorshield V2 instantiating

Post by adafruit_support_bill »

It may be a few revs behind the current release, but the API should be basically the same. The .h file is the ultimate reference.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”