motor shield v2 loud and rpm does not control speed

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
mromero
 
Posts: 94
Joined: Fri Mar 18, 2016 12:10 pm

motor shield v2 loud and rpm does not control speed

Post by mromero »

I am trying to make a syringe pump that will sample( pull a plunger) at 10 ml /min.

Hardware:
1. Arduino uno R3, your motor shield v2
2 your Stepper motor - NEMA-17 size -1.8 degre, 200 steps/rev, 12V 350mA
3 power is provide from a 12V 2 amp power adapter through the DC barrel jack
4 60cc syringe. Barrel lenght for the 50 ml volume is 75mm
5 threaded rod pitch is 1.25 mm/Rev

I have used another companies motor shield in the past for this pump and worked great but your shield would allow for a more secure installation and save me buying two different products to achieve the same thing. I was trying to use your a variation of your Stepper Test program to see if i could control the motor.

Based on my calculations:
A. Syringe_mL/Step= (Syringe_vol_mL/Syringe_Barrel_Lenght)*(thread_rod_Pitch_mm/Rev*Rev/200step)
Syringe_mL/Step= 0.004166667 cc/step

B. Speed in RPM= Rev/min (wanted speed in ml/min)* (steps/ml)*(Rev/200steps)
12 RPM

C. Steps for req volume
50ml= "=50ml*(1/.00417 ml/step)"
12000 steps

I have tried running the program as Microstep for the accuracy but cant seem to get an RPM that will work and there does not seem to be any logic to how the RPM correlates to the speed the syringe moves. In the end decided to use Double Coil with a variety of RPM's since the calculated RPM did not seem to work.
I annotated the code for the RPM, speed ml/min, volume cc for what i got.
// 12 rpm at double coil only 30 sec for 10cc;
// 06 rpm at double coil only 11 sec for 10cc;
// 25 rpm at double coil only 40 sec for 10cc;
// 35 rpm at double coil only 30 sec for 10cc;
// 28 rpm at double coil only 35 sec for 10cc;
// 20 rpm at double coil only 46 sec for 10cc;
// 18 rpm at double coil only 10 sec for 10cc;
// 20 rpm at microsteps over60 sec for 6cc;
// 50 rpm at microsteps 60 sec for 2cc cc;
// 5 rpm at microsteps 60 sec for 2c cc; not moving
// 10 rpm at microsteps 60 sec for 1ccc cc;
// 100 rpm at microsteps 60 sec for 4 cc;
// 200 rpm at microsteps 60 sec for 2 cc;
// 255 rpm at microsteps 60 sec for 2 cc; didnt move
// 5 rpm at microsteps 60 sec for 2 cc; didnt move
// 5 rpm double coil steps 60 sec for 15cc;
// 10 rpm double coil steps 35 sec for 10cc;
// 3 rpm double coil steps 13 sec sec for 10cc;

Is this board not able to produce accurate speed? can someone catch what i may be doing wrong? thanks
Below is the code:

Code: Select all

/*
This is a test sketch for the Adafruit assembled Motor Shield for Arduino v2
It won't work with v1.x motor shields! Only for the v2's with built in PWM
control

For use with the Adafruit Motor Shield v2
---->  http://www.adafruit.com/products/1438

Prelim program to set calculations of  RPM needed for  10ml min flow and 50cc volume collection

*/


#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);// for out 200 step per rev this stays at 200


void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps
  while (!Serial);
  Serial.println("Stepper test!");

  if (!AFMS.begin()) {         // create with the default frequency 1.6KHz
  // if (!AFMS.begin(1000)) {  // OR with a different frequency, say 1KHz
    Serial.println("Could not find Motor Shield. Check wiring.");
    while (1);
  }
  Serial.println("Motor Shield found.");
//note with usb motor moves slower than with than with the DC barrel as it has less power... make sure speed measure is done with the barrel 12V 2Ampp
//note per PDF setSpeed is a value between 0 and 255
  myMotor->setSpeed(3);  //  12 rpm  at double coil only 30 sec for 10cc;
                          //  06 rpm  at double coil only 11 sec for 10cc;
                          //  25 rpm  at double coil only 40 sec for 10cc;
                          //  35 rpm  at double coil only 30 sec for 10cc;
                          //  28 rpm  at double coil only 35 sec for 10cc;
                          //  20 rpm  at double coil only 46 sec for 10cc;
                          //  18 rpm  at double coil only 10 sec for 10cc;
                          //  20 rpm  at microsteps over60 sec for 6cc;
                          //  50 rpm  at microsteps  60 sec for 2cc cc;
                          //  5 rpm  at microsteps  60 sec for 2c cc; not moving
                           // 10 rpm  at microsteps 60 sec for 1ccc cc; 
                          //  100 rpm  at microsteps  60 sec for 4 cc; 
                          //  200 rpm  at microsteps  60 sec for 2 cc; 
                          //  255 rpm  at microsteps  60 sec for 2 cc; didnt move
                         //    5 rpm  at microsteps  60 sec for 2 cc; didnt move 
                         //    5 rpm double coil steps 60  sec for 15cc;
                          //  10 rpm double coil steps 35  sec for 10cc;
                           //  3 rpm double coil steps 13 sec  sec for 10cc;
}

                        
void loop() {
  

//  Serial.println("Single coil steps");  //noisy
//  delay(1000);
//  myMotor->step(11990, BACKWARD, SINGLE);//11990 for 50cc;5882 for 10cc (these values were miscalculated)
//  delay(500);
//  myMotor->step(11990, FORWARD, SINGLE);//push syringe
//  delay(2000);
//------------------
//
  Serial.println("Double coil steps");
  delay(2000);
  myMotor->step(12000,BACKWARD, DOUBLE);// 
  delay(500);
  myMotor->step(12000, FORWARD, DOUBLE);
  delay(2000);
//--------------------------
//
//  Serial.println("Interleave coil steps");// did only 20 cc
//  delay(2000);
//  myMotor->step(11990, BACKWARD, INTERLEAVE);
//  delay(500);
//  myMotor->step(11990, FORWARD, INTERLEAVE);
//  delay(2000);
//---------------------------
//  Serial.println("Microstep steps");// 
//  delay(2000);
//  myMotor->step(12000, BACKWARD, MICROSTEP);
//  delay(500);
//  myMotor->step(12000, FORWARD, MICROSTEP);// orig this was half steps of  single coil so i half the steps for full syring
//  delay(2000);
////  


}

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

Re: motor shield v2 loud and rpm does not control speed

Post by adafruit_support_bill »

The stepper speed in the library is not particularly accurate since it does not account for i2c communication overhead with the shield. And that varies per processor. The AccelStepper library uses millis() for step timing and will produce more accurate speeds.
// 255 rpm at microsteps 60 sec for 2 cc; didnt move
Microstep mode is the weakest of the stepping modes and is not capable of high speeds.

User avatar
mromero
 
Posts: 94
Joined: Fri Mar 18, 2016 12:10 pm

Re: motor shield v2 loud and rpm does not control speed

Post by mromero »

Accel Step library? there was no reference to this in the documentation could you point me to where i could get sample code for the Accel Step library usage in the motor shield v2?


User avatar
mromero
 
Posts: 94
Joined: Fri Mar 18, 2016 12:10 pm

Re: motor shield v2 loud and rpm does not control speed

Post by mromero »

I appreciate your reply.

I have followed the links you send and still cant figure out how to use the AccelStepper library millis() for step timing.

I have a few questions about the Accel_Constant Speed example:

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 <Adafruit_MotorShield.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 forwardstep1() {
  myStepper1->onestep(FORWARD, SINGLE);
}
void backwardstep1() {
  myStepper1->onestep(BACKWARD, SINGLE);
}

AccelStepper Astepper1(forwardstep1, backwardstep1); // construct to call your own forwardstep and backwardstep

void setup()
{
   Serial.begin(9600);           // set up Serial library at 9600 bps
   Serial.println("Stepper test!");

  if (!AFMS.begin()) {         // create with the default frequency 1.6KHz
  // if (!AFMS.begin(1000)) {  // OR with a different frequency, say 1KHz
    Serial.println("Could not find Motor Shield. Check wiring.");
    while (1);
  }
  Serial.println("Motor Shield found.");

  Astepper1.setSpeed(50);//50steps per sec more than 1000steps per second unreliable
}

void loop()
{
   Astepper1.runSpeed()// motor moves at 1 step per sec clockwise
}

1. where are you calling the clockwise(ie forward) rotation of the motor. the void loop* only references runSpeed. If i wanted it to move counter clockwise how would i change this code?

2. im assuming that since you specify: AFMS.getStepper(200, 2) that a full 360 degree Revolution is equivalent to 200 steps

3. If i want the motor to rotate backwards 12,000 steps at a speed of 40 steps /sec


I tried using:

Code: Select all

void loop()
{
 // moveTo(12000); // position in steps  to move to  + CW;-CCW
 runSpeedToPosition(12000);
 // Astepper1.setSpeed(50);// needs to be after moveTo as that function recalculates speed
//  Astepper1.runSpeed()// motor moves at 1 step per sec clockwise
}
but could not compile kept getting 'runSpeedToPosition' was not declared in this scope

any help would be welcomed
thanks

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

Re: motor shield v2 loud and rpm does not control speed

Post by adafruit_support_bill »

I have followed the links you send and still cant figure out how to use the AccelStepper library millis() for step timing.
millis() based timing is built into the library. You program the speed, acceleration and position and the library will handle the timing.
1. where are you calling the clockwise(ie forward) rotation of the motor.
The library defaults to 'clockwise'. To reverse it you can call moveTo() with a negative position value.
https://www.airspayce.com/mikem/arduino ... 5810ec9736
2. im assuming that since you specify: AFMS.getStepper(200, 2) that a full 360 degree Revolution is equivalent to 200 steps
Correct,
3. If i want the motor to rotate backwards 12,000 steps at a speed of 40 steps /sec

Code: Select all

  Astepper1.moveTo(-12000);
  Astepper1.setSpeed(40);
kept getting 'runSpeedToPosition' was not declared in this scope
C++ is an object oriented language. You need to specify which object instance you are calling the function on:

Code: Select all

  Astepper1.runSpeedToPosition();

User avatar
mromero
 
Posts: 94
Joined: Fri Mar 18, 2016 12:10 pm

Re: motor shield v2 loud and rpm does not control speed

Post by mromero »

thanks for the help

attempt 1:

Code: Select all

// -*- 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 <Adafruit_MotorShield.h>


//user defined values
 int FinalPosition=12000;

// 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 forwardstep1() {
  myStepper1->onestep(FORWARD, SINGLE);
}
void backwardstep1() {
  myStepper1->onestep(BACKWARD, SINGLE);
}

AccelStepper Astepper1(forwardstep1, backwardstep1); // construct to call your own forwardstep and backwardstep




void setup()
{
   Serial.begin(9600);           // set up Serial library at 9600 bps
   Serial.println("Stepper test!");

  if (!AFMS.begin()) {         // create with the default frequency 1.6KHz
  // if (!AFMS.begin(1000)) {  // OR with a different frequency, say 1KHz
    Serial.println("Could not find Motor Shield. Check wiring.");
    while (1);
  }
  Serial.println("Motor Shield found.");


  
  Astepper1.setSpeed(40); //40steps per sec more than 1000steps per second unreliable
}


void loop()
{

  Astepper1.runSpeedToPosition(FinalPosition);
}

caused error:
exit status 1
no matching function for call to 'AccelStepper::runSpeedToPosition(int&)'


attempt 2:

[code// -*- 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_Mo ... 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 <Adafruit_MotorShield.h>


//user defined values
int FinalPosition=12000;

// 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 forwardstep1() {
myStepper1->onestep(FORWARD, SINGLE);
}
void backwardstep1() {
myStepper1->onestep(BACKWARD, SINGLE);
}

AccelStepper Astepper1(forwardstep1, backwardstep1); // construct to call your own forwardstep and backwardstep




void setup()
{
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Stepper test!");

if (!AFMS.begin()) { // create with the default frequency 1.6KHz
// if (!AFMS.begin(1000)) { // OR with a different frequency, say 1KHz
Serial.println("Could not find Motor Shield. Check wiring.");
while (1);
}
Serial.println("Motor Shield found.");



Astepper1.setSpeed(40); //40steps per sec more than 1000steps per second unreliable
}


void loop()
{

Astepper1.moveTo(-12000);
Astepper1.setSpeed(40);
}][/code]


no error but nothing happens?

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

Re: motor shield v2 loud and rpm does not control speed

Post by adafruit_support_bill »

no matching function for call to 'AccelStepper::runSpeedToPosition(int&)'
That function takes no arguments.
https://www.airspayce.com/mikem/arduino ... 5b9c34f301

You use moveTo to tell it where to go.
Use setSpeed to tell it how fast.
Then call runSpeedToPosition in your loop so it can make the motor(s) step at the appropriate times.

User avatar
mromero
 
Posts: 94
Joined: Fri Mar 18, 2016 12:10 pm

Re: motor shield v2 loud and rpm does not control speed

Post by mromero »

I think i figured it out.

This seems to work but it seems to speed up as it starts and slow down as it ends is there a way to keep the whole movement at constant speed?

Code: Select all

// -*- 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 <Adafruit_MotorShield.h>


//user defined values
 int FinalPosition=12000;

// 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 forwardstep1() {
  myStepper1->onestep(FORWARD, SINGLE);
}
void backwardstep1() {
  myStepper1->onestep(BACKWARD, SINGLE);
}

AccelStepper Astepper1(forwardstep1, backwardstep1); // construct to call your own forwardstep and backwardstep




void setup()
{
   Serial.begin(9600);           // set up Serial library at 9600 bps
   Serial.println("Stepper test!");

  if (!AFMS.begin()) {         // create with the default frequency 1.6KHz
  // if (!AFMS.begin(1000)) {  // OR with a different frequency, say 1KHz
    Serial.println("Could not find Motor Shield. Check wiring.");
    while (1);
  }
  Serial.println("Motor Shield found.");


  
  Astepper1.setSpeed(40); //40steps per sec more than 1000steps per second unreliable
}


void loop()
{

  Astepper1.moveTo(-12000);// ccw if + ccw
  Astepper1.runToPosition();// works
}

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

Re: motor shield v2 loud and rpm does not control speed

Post by adafruit_support_bill »

The "accel" in "accelstepper" refers to acceleration. Motion control systems typically use smooth acceleration/deceleration curves rather than abrupt starts and stops. If you want to have abrupt starts and stops, use runSpeedToPosition instead of runToPosition.

https://www.airspayce.com/mikem/arduino ... 5b9c34f301

User avatar
mromero
 
Posts: 94
Joined: Fri Mar 18, 2016 12:10 pm

Re: motor shield v2 loud and rpm does not control speed

Post by mromero »

I am trying to build a syringe pump and it requires constants speed of 10 cc/min which based on the syringe volume and the pitch of the threaded rod calculates to 48 steps/sec. To test i have been timing the time to move 10 cc which should be 2882 steps. As you can see in the code i tried 3 ways.

I need the constant speed but for some reason the motor only moves at 1 step /sec rather than 48step/ sec i need?

Code: Select all

#include <AccelStepper.h>
#include <Adafruit_MotorShield.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 forwardstep1() {
  myStepper1->onestep(FORWARD, SINGLE);
}
void backwardstep1() {
  myStepper1->onestep(BACKWARD, SINGLE);
}

AccelStepper Astepper1(forwardstep1, backwardstep1); // construct to call your own forwardstep and backwardstep


void setup()
{
   Serial.begin(9600);           // set up Serial library at 9600 bps
   Serial.println("Stepper test!");

  if (!AFMS.begin()) {         // create with the default frequency 1.6KHz
  // if (!AFMS.begin(1000)) {  // OR with a different frequency, say 1KHz
    Serial.println("Could not find Motor Shield. Check wiring.");
    while (1);
  }
  Serial.println("Motor Shield found.");
  
  Astepper1.setSpeed(48); //40steps new syringe per sec more than 1000steps per second unreliable
}


void loop()
{
 //------ attempt 1:  takes longer than 1 min to traverse 10cc
//  Astepper1.moveTo(-2882);// ccw pull if + ccw push note12,000 is cc's;2400 steps=10ml
//  Astepper1.runToPosition();// works moves with accel and decel
  //accel and decel but still takes longer than 10 ml in 60sec

//----------attempt2:   movement is const at 1 step per sec
//   Astepper1.moveTo(-2882);
//   Astepper1.setSpeed(48);// needed for the runSpeedtoPosition() command
//   Astepper1.runSpeedToPosition();

//------------attemp3:  also moves at const speed 1 step per sec
    Astepper1.moveTo(-2882);
    Astepper1.runSpeedToPosition();
    Astepper1.setSpeed(48);// needed for the runSpeedtoPosition() command

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

Re: motor shield v2 loud and rpm does not control speed

Post by adafruit_support_bill »

I can only guess since you have not posted complete code. Most likely there is something in your loop that is slowing things down.

User avatar
mromero
 
Posts: 94
Joined: Fri Mar 18, 2016 12:10 pm

Re: motor shield v2 loud and rpm does not control speed

Post by mromero »

Code: Select all

#include <AccelStepper.h>
#include <Adafruit_MotorShield.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 forwardstep1() {
  myStepper1->onestep(FORWARD, SINGLE);
}
void backwardstep1() {
  myStepper1->onestep(BACKWARD, SINGLE);
}

AccelStepper Astepper1(forwardstep1, backwardstep1); // construct to call your own forwardstep and backwardstep


void setup()
{
   Serial.begin(9600);           // set up Serial library at 9600 bps
   Serial.println("Stepper test!");

  if (!AFMS.begin()) {         // create with the default frequency 1.6KHz
  // if (!AFMS.begin(1000)) {  // OR with a different frequency, say 1KHz
    Serial.println("Could not find Motor Shield. Check wiring.");
    while (1);
  }
  Serial.println("Motor Shield found.");
  
  Astepper1.setSpeed(48); //40steps new syringe per sec more than 1000steps per second unreliable
}


void loop()
{
 //------ attempt 1:  takes longer than 1 min to traverse 10cc
//  Astepper1.moveTo(-2882);// ccw pull if + ccw push note12,000 is cc's;2400 steps=10ml
//  Astepper1.runToPosition();// works moves with accel and decel
  //accel and decel but still takes longer than 10 ml in 60sec

//----------attempt2:   movement is const at 1 step per sec
//   Astepper1.moveTo(-2882);
//   Astepper1.setSpeed(48);// needed for the runSpeedtoPosition() command
//   Astepper1.runSpeedToPosition();

//------------attemp3:  also moves at const speed 1 step per sec
//    Astepper1.moveTo(-2882);
//    Astepper1.runSpeedToPosition();
//    Astepper1.setSpeed(48);// needed for the runSpeedtoPosition() command
//----------attemp 4: 
Astepper1.moveTo(-2882);
Astepper1.runSpeedToPosition();
}

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

Re: motor shield v2 loud and rpm does not control speed

Post by adafruit_support_bill »

Calling moveTo repeatedly is not necessary and may be causing your timing problem. I'm not familiar with the code behind it, but the Ayrspayce documentation for moveTo says:

https://www.airspayce.com/mikem/arduino ... 5810ec9736
Caution: moveTo() also recalculates the speed for the next step. If you are trying to use constant speed movements, you should call setSpeed() after calling moveTo().

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

Return to “Arduino Shields from Adafruit”