0

Stepper with Motor Shield v2.3 sounds like chewing glass :0
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Stepper with Motor Shield v2.3 sounds like chewing glass :0

by ben_cowden on Thu Mar 25, 2021 8:33 pm

I have a Nema 17 bipolar stepper connected to an Adafruit Motor shield. I'm running tests to see if I can get it to sound at all acceptable (it's for a display feature), but I have been unable to make it sound like anything but crunching glass. Well, microstepping sounds decent, but moves at a snail's pace. Any help would be much appreciated.

The motor specs:
200 steps (1.8deg)
1.5a current/phase
1.5ohm phase resistance

Powered by 12V 3A battery.

Connected to Metro M0 board, which is powered via USB

Here's the test code I'm using (drives the motor a bit one way, then reverses it until it hits a limit switch):
Code: Select all | TOGGLE FULL SIZE
#include <Wire.h>
#include <Adafruit_MotorShield.h>

Adafruit_MotorShield AFMStop = Adafruit_MotorShield(0x61); //right jumpers soldered
Adafruit_MotorShield AFMSbot = Adafruit_MotorShield(0x60); //bottom board with stacking headers

Adafruit_StepperMotor *myMotor1 = AFMSbot.getStepper(200, 1); //this is the bourbon motor

#define limit1 13 //Pin8 connected to the limit switch activate for limit switch
#define limit2 9 //Pin9 connected to the limit switch activate for limit switch
#define fill 5 //Pin5 connected to homing and bitters-fill
#define pourbutton 4 //Pin 4 connected to pour button
#define estop 6 //Pin 6 connected to e-stop button

int buttonState = 0;  //variable for reading the pour button
int estopState = 0;  //variable for reading the e-stop button
int steps1;           // Variable for pot1 reading

void setup() {
  Serial.begin(9600); // initialize serial communication at 9600 bits per second
  //while (!Serial);    //only begins after serial monitor is opened
  Serial.println("Weeee! let's go!"); 
  delay(100);
 
  Serial.println("Begin talking to the bottom board"); 
  AFMSbot.begin();

  Serial.println("Begin talking to the top board"); 
  AFMStop.begin();// create with the default frequency 1.6KHz
   
  myMotor1->release(); //release the motors so they don't have to maintain position

   Serial.println("waiting for homing button"); 
  // Homing procedure at startup:
 while  (digitalRead(fill) == LOW) { //if the fill button is NOT pressed
    Serial.println("matteru...");   
    delay(100);
 }

   bourbonHome();
   steps1=0;  // Reset position variable to zero


void loop(){
  // read the state of the pour button:
buttonState = digitalRead(pourbutton);

if (digitalRead(pourbutton) == HIGH) { //if the pour button is pressed
    steps1 = map(analogRead(A0), 1, 1023, 50, 1200);
    Serial.print("Bourbon pot = ");
    Serial.println(steps1);
    delay (500);

  myMotor1->setSpeed(100); 
  for (int i=0; i<steps1; i++) {
    myMotor1->step(1, FORWARD, SINGLE);
    if  (digitalRead(estop) == HIGH) { //if the e-stop button is pressed
      bourbonHome();
    }
  }
  while (digitalRead(limit2) == LOW) {  // Do this until the switch is activated   
      myMotor1->step(1, BACKWARD, SINGLE);
   }
  while (digitalRead(limit2) == HIGH) { // Do this until the switch is not activated
      myMotor1->step(1, FORWARD, SINGLE);
  }
  for (int i=0; i<steps1; i++) {
    myMotor1->step(1, FORWARD, DOUBLE);
    if  (digitalRead(estop) == HIGH) { //if the e-stop button is pressed
      bourbonHome();
    }
  }
  while (digitalRead(limit2) == LOW) {  // Do this until the switch is activated   
      myMotor1->step(1, BACKWARD, DOUBLE);
   }
  while (digitalRead(limit2) == HIGH) { // Do this until the switch is not activated
      myMotor1->step(1, FORWARD, DOUBLE);
  }
  for (int i=0; i<steps1; i++) {
    myMotor1->step(1, FORWARD, INTERLEAVE);
    if  (digitalRead(estop) == HIGH) { //if the e-stop button is pressed
      bourbonHome();
    }
  }
  while (digitalRead(limit2) == LOW) {  // Do this until the switch is activated   
      myMotor1->step(1, BACKWARD, INTERLEAVE);
   }
  while (digitalRead(limit2) == HIGH) { // Do this until the switch is not activated
      myMotor1->step(1, FORWARD, INTERLEAVE);
  }
  for (int i=0; i<steps1; i++) {
    myMotor1->step(1, FORWARD, MICROSTEP);
    if  (digitalRead(estop) == HIGH) { //if the e-stop button is pressed
      bourbonHome();
    }
  }
  while (digitalRead(limit2) == LOW) {  // Do this until the switch is activated   
      myMotor1->step(1, BACKWARD, MICROSTEP);
   }
  while (digitalRead(limit2) == HIGH) { // Do this until the switch is not activated
      myMotor1->step(1, FORWARD, MICROSTEP);
  } 
  myMotor1->setSpeed(200); 
  for (int i=0; i<steps1; i++) {
    myMotor1->step(1, FORWARD, SINGLE);
    if  (digitalRead(estop) == HIGH) { //if the e-stop button is pressed
      bourbonHome();
    }
  }
  while (digitalRead(limit2) == LOW) {  // Do this until the switch is activated   
      myMotor1->step(1, BACKWARD, SINGLE);
   }
  while (digitalRead(limit2) == HIGH) { // Do this until the switch is not activated
      myMotor1->step(1, FORWARD, SINGLE);
  }
  for (int i=0; i<steps1; i++) {
    myMotor1->step(1, FORWARD, DOUBLE);
    if  (digitalRead(estop) == HIGH) { //if the e-stop button is pressed
      bourbonHome();
    }
  }
  while (digitalRead(limit2) == LOW) {  // Do this until the switch is activated   
      myMotor1->step(1, BACKWARD, DOUBLE);
   }
  while (digitalRead(limit2) == HIGH) { // Do this until the switch is not activated
      myMotor1->step(1, FORWARD, DOUBLE);
  }
  for (int i=0; i<steps1; i++) {
    myMotor1->step(1, FORWARD, INTERLEAVE);
    if  (digitalRead(estop) == HIGH) { //if the e-stop button is pressed
      bourbonHome();
    }
  }
  while (digitalRead(limit2) == LOW) {  // Do this until the switch is activated   
      myMotor1->step(1, BACKWARD, INTERLEAVE);
   }
  while (digitalRead(limit2) == HIGH) { // Do this until the switch is not activated
      myMotor1->step(1, FORWARD, INTERLEAVE);
  }
    for (int i=0; i<steps1; i++) {
    myMotor1->step(1, FORWARD, MICROSTEP);
    if  (digitalRead(estop) == HIGH) { //if the e-stop button is pressed
      bourbonHome();
    }
  }
  while (digitalRead(limit2) == LOW) {  // Do this until the switch is activated   
      myMotor1->step(1, BACKWARD, MICROSTEP);
   }
  while (digitalRead(limit2) == HIGH) { // Do this until the switch is not activated
      myMotor1->step(1, FORWARD, MICROSTEP);
  }
}
}

void bourbonHome()
{
  while (digitalRead(limit2) == LOW) {  // Do this until the switch is activated   
      myMotor1->step(1, BACKWARD, DOUBLE);
   }
  while (digitalRead(limit2) == HIGH) { // Do this until the switch is not activated
      myMotor1->step(1, FORWARD, INTERLEAVE);
  }
  myMotor1->release();
  steps1=0;  // Reset position variable to zero  myMotor1->release();
}

ben_cowden
 
Posts: 23
Joined: Fri Jun 26, 2015 11:38 am

Re: Stepper with Motor Shield v2.3 sounds like chewing glass

by adafruit_support_bill on Fri Mar 26, 2021 6:21 am

The motor specs:
200 steps (1.8deg)
1.5a current/phase
1.5ohm phase resistance

Powered by 12V 3A battery.

That motor is not compatible with the shield. Powered with 12v through the shield it will try to pull 8A/phase (16A total).
Based on the specs, the motor appears to have been designed for use with a current limiting "chopper" type driver.

https://learn.adafruit.com/all-about-st ... he-stepper

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

Re: Stepper with Motor Shield v2.3 sounds like chewing glass

by ben_cowden on Fri Mar 26, 2021 7:50 am

Thanks Bill!
Could you point to a motor with ideal specs for the shield?
Or some specific numbers to look for?

I'll be honest, I haven't been able to figure out what numbers from a motor's specifications plug in, or how, to the formulas on the tutorial you link to.
If I had a positive example, like "this motor is perfect for the shield," that would be enormously helpful.

Thanks!

ben_cowden
 
Posts: 23
Joined: Fri Jun 26, 2015 11:38 am

Re: Stepper with Motor Shield v2.3 sounds like chewing glass

by adafruit_support_bill on Fri Mar 26, 2021 8:27 am

Yes. Motor specs can be confusing. And some vendors post incomplete specs which can be downright misleading at times.

For use with the shield, motors with a phase resistance of 10 ohms or higher are safe to use with up to a 12v supply.

The #324 motors in the shop have a phase resistance of 35 ohms and work well with the shield - unfortunately they are out of stock at the moment: https://www.adafruit.com/product/324

Sparkfun carries a similar model which will also work well: https://www.sparkfun.com/products/9238

And Amazon has this one: https://www.amazon.com/STEPPERONLINE-17 ... ef=sr_1_10

Note that we have seen mis-labeled motors from Amazon. If you order from there, it would be smart to check the resistance across the coils to see that they match the specs.

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

Re: Stepper with Motor Shield v2.3 sounds like chewing glass

by ben_cowden on Fri Mar 26, 2021 8:53 am

Thanks so much, Bill!
I believe I understand it now.
Really, this is so helpful.

(this part is more for my own future reference, and for others):

My motor, plugged into Ohm's Law, looks like this:
12V power supply, 1.5ohm resistance; 12v / 1.5ohm = 8amps :$
Since the shield can only provide 1.2A constant current, 8a is a no-go

The #324 stepper Bill linked to looks like this:
12V power, 35ohm resistance; 12V / 35ohm = 0.34A :)

Brilliant, now hopefully I can buy better steppers!

ben_cowden
 
Posts: 23
Joined: Fri Jun 26, 2015 11:38 am

Please be positive and constructive with your questions and comments.