Adafruit Motorshield V2

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
User avatar
Lakesed
 
Posts: 58
Joined: Tue Mar 11, 2014 7:30 pm

Adafruit Motorshield V2

Post by Lakesed »

I can not get the Accel_Constntspeednsketch to compile without errors. I reviewed your 08 Mar 2014 post on this subject and have loaded he Adafruit_Motorshield library as you direcdted but I still get the following error:
Accel_ConstantSpeed:36: error: 'AccelStepper' does not name a type
Accel_ConstantSpeed.ino: In function 'void setup()':
Accel_ConstantSpeed:46: error: 'Astepper1' was not declared in this scope
Accel_ConstantSpeed.ino: In function 'void loop()':
Accel_ConstantSpeed:51: error: 'Astepper1' was not declared in this scope

I am able to run the dc motor test and the servo test successfully. I am testing on two different computers with the same results.
One other problem is that when I load the sketch it tells me that he port is already in use. When I look at the port options in the IDE it does not offer any other ports. Is there any way to force the Device Manager to change the port.

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

Re: Adafruit Motorshield V2

Post by adafruit_support_bill »

'AccelStepper' does not name a type
That means that the compiler was not able to locate the AccelStepper library. The link to the library is here: https://learn.adafruit.com/adafruit-mot ... l-software
And installation instructions are here: http://learn.adafruit.com/adafruit-all- ... nstall-use
One other problem is that when I load the sketch it tells me that he port is already in use. When I look at the port options in the IDE it does not offer any other ports. Is there any way to force the Device Manager to change the port.
That can be caused by a variety of problems. Usually it means that some other program is using the port. Some older bluetooth stacks try to grab all the COM ports. What OS are you using?

User avatar
Lakesed
 
Posts: 58
Joined: Tue Mar 11, 2014 7:30 pm

Re: Adafruit Motorshield V2

Post by Lakesed »

I am using windows 7.

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

Re: Adafruit Motorshield V2

Post by adafruit_support_bill »

You can try disabling bluetooth if you have it. But that was mostly an issue with older systems. Make sure that you don't have any terminal emulators or other applications that use COM ports.

Another possibility is that the Java runtime (used by the Arduino IDE) failed to close the port. In that case, the only remedy I have found is to reboot the machine.

User avatar
Lakesed
 
Posts: 58
Joined: Tue Mar 11, 2014 7:30 pm

Re: Adafruit Motorshield V2

Post by Lakesed »

I have it running now, The last problem I had was that when I copied the AccelStepper I fail to remove the word Master from the file name and the IDE did not like that. Once I fixed the name it worked fine.
There is one more thing. On your web page that shows how to "Install Headers and Terminals" it says that" If you plan to use .AccelStepper for simultaneous control of multiple stepper motors, you will also need to download and install the AccelStepper library:" This sounded to me as if it was not necessary if running only one.
Thanks for your quick support.

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

Re: Adafruit Motorshield V2

Post by adafruit_support_bill »

Thanks for the feedback. I've clarified the wording a bit.

User avatar
Lakesed
 
Posts: 58
Joined: Tue Mar 11, 2014 7:30 pm

Re: Adafruit Motorshield V2

Post by Lakesed »

I am still trying to understand the ins and outs of the Motorshield. I have studied the PDF document, " Adafruit Motor Shield V2 for Arduino" and the method to move the stepper does not agree with the Accel-constantspeed$ sketch in the IDE examples. In the sketch the loop code shown is:
void loop()
{
Astepper1.runSpeed();
}
The PDF document gives the following method:
Then every time you want the motor to move, call the step(#steps, direction, steptype)
procedure. #steps is how many steps you'd like it to take. direction is either FORWARD or
BACKWARD and the step type is SINGLE, DOUBLE, INTERLEAVE or MICROSTEP.
"Single" means single-coil activation
"Double" means 2 coils are activated at once (for higher torque)
"Interleave" means that it alternates between single and double to get twice the resolution (but of course its half the speed).
"Microstepping" is a method where the coils are PWM'd to create smooth motion between steps.
There is tons of information about the pros and cons of these different stepping methods in resources page.
Thanks

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

Re: Adafruit Motorshield V2

Post by adafruit_support_bill »

The AccelStepper library is not the same thing as the Adafruit Motorshied Library documented in the tutorial. AccelStepper is a 3rd party library that layers over the Adafruit Library to provide acceleration and concurrent operation features. It calls the functions in the Adafruit Library to actually move the motors.

User avatar
Lakesed
 
Posts: 58
Joined: Tue Mar 11, 2014 7:30 pm

Re: Adafruit Motorshield V2

Post by Lakesed »

I am looking for more documentation on how to code the software to make the stepper run forward, reverse, move a specific steps, accelerate etc from a keypad input. Also,the loop function in the two examples, Accel_constantspeed and Accel_multistepper in the IDE do not match what is shown in the PDF document, " Adafruit Motor Shield V2 for Arduino". Can you point me toward more information.
Thanks

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

Re: Adafruit Motorshield V2

Post by adafruit_support_bill »

The PDF document is for the Adafruit library. The AccelStepper people have documentation for their library here: http://www.airspayce.com/mikem/arduino/AccelStepper/

User avatar
Lakesed
 
Posts: 58
Joined: Tue Mar 11, 2014 7:30 pm

Re: Adafruit Motorshield V2

Post by Lakesed »

I am getting errors when uploading a motor shield sketch. I have run this sketch successfully on this machine in the past. I am running Windows 7. I am using a Lenardo board.

Code: Select all

// ConstantSpeed.pde
// -*- mode: C++ -*-
//
// Shows how to run AccelStepper in the simplest,
// fixed speed mode with no accelerations
// Requires the Adafruit_Motorshield v2 library 
//   https://github.com/adafruit/Adafruit_Motor_Shield_V2_Library
// And AccelStepper with AFMotor support 
//   https://github.com/adafruit/AccelStepper
// This tutorial is for Adafruit Motorshield v2 only!
// Will not work with v1 shields
#include <AccelStepper.h>
#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_PWMServoDriver.h"
// Create the motor shield object with the default I2C address
Adafruit_MotorShield AFMS = Adafruit_MotorShield(); 
// Or, create it with a different I2C address (say for stacking)
// Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x61); 
// Connect a stepper motor with 200 steps per revolution (1.8 degree)
// to motor port #2 (M3 and M4)
Adafruit_StepperMotor *myStepper1 = AFMS.getStepper(200, 2);
// you can change these to DOUBLE or INTERLEAVE or MICROSTEP!
void backwardstep1() {  
  myStepper1->onestep(BACKWARD, SINGLE);
}
void forwardstep1() {  
  myStepper1->onestep(FORWARD, SINGLE);
}
AccelStepper Astepper1(backwardstep1,forwardstep1); // use functions to step
void setup()
{  
   Serial.begin(9600);           // set up Serial library at 9600 bps
   Serial.println("Stepper test!");
    AFMS.begin();  // create with the default frequency 1.6KHz
  //AFMS.begin(1000);  // OR with a different frequency, say 1KHz
  Astepper1.setSpeed(50);	
}
void loop()
{  
   Astepper1.runSpeed();
}
*******************************************************************
I get error:
Binary sketch size: 12,182 bytes (of a 28,672 byte maximum)
Found programmer: Id = "B×7 "; type =
Software Version = .; Hardware Version = .
avrdude: error: buffered memory access not supported. Maybe it isn't
Last edited by adafruit_support_bill on Tue May 20, 2014 7:53 pm, edited 1 time in total.
Reason: please use the code button when submitting code. press [Code], then paste your code between the [code] [/code] tags.

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

Re: Adafruit Motorshield V2

Post by adafruit_support_bill »

Found programmer: Id = "B×7 "; type =
Software Version = .; Hardware Version = .
It looks like the bootloader on your Arduino is speaking gibberish. Are you sure you have the right board type selected in Tools->Board?

User avatar
CW1
 
Posts: 4
Joined: Wed Feb 04, 2015 5:12 pm

Re: Adafruit Motorshield V2

Post by CW1 »

There certainly is a rich history of requests and suggestions on running a stepper motor with accel/decel while using the Adafruit Motorshield V2. But after a lot of trials (I may be my own worst enemy!), I only seem to achieve partial success on one or other individual feature.
My project is to run a repeating "trapezoidal" speed profile on a stepper motor. Stepper motor runs at speed 1 for given number of microsteps, then ramps to speed 2 in a given number of microsteps, then runs speed 2 for a given number of microsteps, then ramps back to speed 1 in a given number of microsteps. Steps or elapsed times are interchangeable. Repeat sequence endlessly.
At this point, I am not sure if the Motor Shield + AccelStepper can do this.
Can you suggest/point to links where something like this happens? And if your reaction is to tell me to go back and read up on C++ to make a custom library, that would fine too. At least I'd know.
Aswy01

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

Re: Adafruit Motorshield V2

Post by adafruit_support_bill »

I don't use AccelStepper much. But that is the kind of thing it is designed to do. You might post your question over at AyrSpace, the authors of the AccelStepper Library.
http://www.airspayce.com/airspayce/prod ... -software/

Although trapezoidal velocity profiles are a step up from an instantaneous start/stop. There is still the 'jerk' at both ends of each ramp. The RepRap Wiki discusses some more advanced acceleration profiles to minimize jerk: http://reprap.org/wiki/Firmware/Linear_Acceleration.

User avatar
CW1
 
Posts: 4
Joined: Wed Feb 04, 2015 5:12 pm

Re: Adafruit Motorshield V2

Post by CW1 »

Thanks Bill. Will follow your suggestions.
Your comment on avoiding jerk is great. But first, I have to crawl successfully, then it will be time to address a smooth walking profile!

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

Return to “Other Arduino products from Adafruit”