0

starter pack for NEMA 17 stepper motor
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: starter pack for NEMA 17 stepper motor

by BABOafrica on Tue Dec 29, 2015 9:35 am

Several months ago, I managed to download the library for using the Adafruit MotorShield and run the test for a stepper motor. Since purchacing my arduino, shield and stepper motor, that is all I have managed to do.

For reasons I cannot understand—no matter how many times I read thru your learning packages and try to follow them—I cannot even repeat what I once managed to do, i.e., run the stepper test for the Motorshield.

The stepper test is located here:

Joe Babendreier > Documents > Arduino > libraries > Adafruit_MotorShield > examples > StepperTest

When I load this sketch, something funny seems to happen with the utility:

#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_PWMServoDriver.h"

Just seeing the quotation marks (instead of < >), I suppose it will fail to compile.

Sure enough, when I compile, I get the error message:

Arduino: 1.6.5 (Windows 8.1), Board: "Arduino/Genuino Uno"

Using library Wire in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire C:\Users\FRJOE~1\AppData\Local\Temp\build1223468069993803526.tmp\Adafruit_MotorShield.cpp -o C:\Users\FRJOE~1\AppData\Local\Temp\build1223468069993803526.tmp\Adafruit_MotorShield.cpp.o
In file included from C:\Users\FRJOE~1\AppData\Local\Temp\build1223468069993803526.tmp\Adafruit_MotorShield.cpp:24:0:
C:\Users\FRJOE~1\AppData\Local\Temp\build1223468069993803526.tmp\Adafruit_MotorShield.h:22:45: fatal error: utility/Adafruit_PWMServoDriver.h: No such file or directory
#include "utility/Adafruit_PWMServoDriver.h"
^
compilation terminated.
Error compiling.

****************************************

The utility directory exists and it has two files:

utility/Adafruit_PWMServoDriver.ccp
utility/Adafruit_PWMServoDriver.h


The directory is located here:

Joe Babendreier > Documents > Arduino > libraries > Adafruit_MotorShield > utility

What am I doing wrong?

Joe


PS In case it is of any interest:

I’m using a DELL laptop with Windows 8. When I first used the Arduino library I was using an old desktop that I don't have any more. I copied the files from my old computer into my laptop.

The Arduino library copied into my laptop includes examples.

The examples seem to compile perfectly. (I assume they would work on an Arduino if I had the board set up correctly for each example.)

For instance, the following compiles with no problem:

This PC > OS(C:) > Program Files (x86) > Arduino > libraries > Stepper > examples > stepper_oneRevolution

I want to run a stepper motor at a certain rpm. You suggested I used the following code:

void setup()
{
AFMS.begin();
myMotor->setSpeed(10); // 10 rpm
}

void loop()
{
motor->step(1, FORWARD, DOUBLE);
}

I created a new Arduino sketch by copying this code exactly into a blank sketch.

I named the sketch “stepper_rpm_control_10rpm” and I put the sketch into the following folder:

This PC > OS(C:) > Program Files (x86) > Arduino > libraries > Stepper > stepper_rpm_control_10rpm

I can open the Arduino program and the code appears on the screen as expected. But it will not compile.

I get this error message:

Arduino: 1.6.5 (Windows 8.1), Board: "Arduino/Genuino Uno"

stepper_rpm_control_10rpm.ino: In function 'void setup()':
stepper_rpm_control_10rpm:3: error: 'AFMS' was not declared in this scope
stepper_rpm_control_10rpm:4: error: 'myMotor' was not declared in this scope
stepper_rpm_control_10rpm.ino: In function 'void loop()':
stepper_rpm_control_10rpm:9: error: 'motor' was not declared in this scope
stepper_rpm_control_10rpm:9: error: 'FORWARD' was not declared in this scope
stepper_rpm_control_10rpm:9: error: 'DOUBLE' was not declared in this scope
'AFMS' was not declared in this scope

Not sure what to do.

Any advice greatly appreciated.

BABOafrica
 
Posts: 13
Joined: Fri Oct 09, 2015 6:14 am

Re: starter pack for NEMA 17 stepper motor

by adafruit_support_bill on Tue Dec 29, 2015 10:16 am

Code: Select all | TOGGLE FULL SIZE
void setup()
{
AFMS.begin();
myMotor->setSpeed(10); // 10 rpm
}

void loop()
{
motor->step(1, FORWARD, DOUBLE);
}


That is not a complete program. You need to include the libraries and declare an instance of the shield and the motor. before you can start controlling them.

Code: Select all | TOGGLE FULL SIZE

#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 *myMotor = AFMS.getStepper(200, 2);


I named the sketch “stepper_rpm_control_10rpm” and I put the sketch into the following folder:

This PC > OS(C:) > Program Files (x86) > Arduino > libraries > Stepper > stepper_rpm_control_10rpm

Your sketches should not be stored in the Arduino install tree. Sketches should be saved in your sketchbook folder.
https://learn.adafruit.com/adafruit-all ... der-inside

adafruit_support_bill
 
Posts: 81576
Joined: Sat Feb 07, 2009 10:11 am

Re: starter pack for NEMA 17 stepper motor

by BABOafrica on Wed Dec 30, 2015 3:20 am

Many thanks for your advice.

I must have messed something up when I copied from one computer to another.

So I started from scratch and downloaded everything new.

I was able to get the StepperTest to compile and, with a slight modification, to get that modification to compile.

So, many thanks for your help.

Joe

BABOafrica
 
Posts: 13
Joined: Fri Oct 09, 2015 6:14 am

Re: starter pack for NEMA 17 stepper motor

by adafruit_support_bill on Wed Dec 30, 2015 8:12 am

The IDE is pretty fussy about how things are set up. Misplaced or duplicate libraries cause all sorts of problems.

adafruit_support_bill
 
Posts: 81576
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.