I recently purchased an Adafruit Motor shield. Hook up was very straight forward. I have several stepper motors, 6V-1A motors and 12V-0.4A motors. I am powering the shield from my benchtop power supply through the power lug. I am currently testing the 12 V motors. I have the bench supply set to 12.1 volts. The motors tend to have very little torque. I had a custom bipolar stepper driver that I put together using an L298 chip that delivered ample power and the motors had good torque through its dual H-bridge. I bought the shield in the hopes of being able to have better control over the motor through microstepping that I just did not have control over with the L298. With the AccelStepper library I was able to at least half step the motor, but I needed finer control. With the Adafruit shield in Microstep mode, the motor hardly even moves, and has almost no torque.
What might I be doing wrong?
Adafruit Motorshield V2.3 giving weak motor torque
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- Youssef_Ismail
- Posts: 118
- Joined: Fri Sep 05, 2014 12:13 am
- adafruit_support_mike
- Posts: 67485
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Adafruit Motorshield V2.3 giving weak motor torque
Does your bench PSU have a current-limiting feature? If so, check that and see if it's turned below 400mA.
The H-bridges on the Motor Shield should be good for 1.6A, which is comfortably above the limits you mentioned.
The H-bridges on the Motor Shield should be good for 1.6A, which is comfortably above the limits you mentioned.
- Youssef_Ismail
- Posts: 118
- Joined: Fri Sep 05, 2014 12:13 am
Re: Adafruit Motorshield V2.3 giving weak motor torque
I do not have the current limited on the power supply. I can limit it, but I have it unlimited so that I can actually monitor how much current my setup is pulling. With the L298 setup driven using AccelStepper and in full step mode, my 12 V 30 Ohm bipolar motor pulls 0.55A when running under load. I was expecting the same from the AF motorshiled, but when running the same motor off the shield, I only see about 0.08 A being pulled from the power supply, using the AccelStepper Library. Even using the standard AF examples only 0.15 A is being pulled. Much less than expected.
- adafruit_support_bill
- Posts: 88153
- Joined: Sat Feb 07, 2009 10:11 am
Re: Adafruit Motorshield V2.3 giving weak motor torque
Microstepping works by modulating the PWM duty cycles, so the torque will always be less than in full-step mode.
Please post photos of how you have everything connected to the shield.
Please post photos of how you have everything connected to the shield.
- Youssef_Ismail
- Posts: 118
- Joined: Fri Sep 05, 2014 12:13 am
Re: Adafruit Motorshield V2.3 giving weak motor torque
Hi Bill,
Here are some photos showing how I have the motor hooked up to the shield.
First photo is overall Second image is power connection Motor Connection
Here are some photos showing how I have the motor hooked up to the shield.
First photo is overall Second image is power connection Motor Connection
- adafruit_support_bill
- Posts: 88153
- Joined: Sat Feb 07, 2009 10:11 am
Re: Adafruit Motorshield V2.3 giving weak motor torque
What are the motor specs and how fast are you trying to step it? Please post the code you are using.
- Youssef_Ismail
- Posts: 118
- Joined: Fri Sep 05, 2014 12:13 am
Re: Adafruit Motorshield V2.3 giving weak motor torque
Motor specs:
Step angle 1.8°
Positional accuracy +/- 5%
Number of phases 2
Temperature Rise 80°C
Rotor Inertia 35 gcm^2
Dielectric strenght 500 VAC
Insulation Resistance 100 Mohm (500 VDC)
insulation class B
Weight 0.5 kg
It is a Nema 17 sized stepper with a 27:1 planetary gear head.
It has a holding torque of 26.0 Ncm
Rated at 0.4 Amps DC
Phase resistance 30 ohms
Rated at 12 V DC
with a phase inductance of 37.0 mH
Step angle 1.8°
Positional accuracy +/- 5%
Number of phases 2
Temperature Rise 80°C
Rotor Inertia 35 gcm^2
Dielectric strenght 500 VAC
Insulation Resistance 100 Mohm (500 VDC)
insulation class B
Weight 0.5 kg
It is a Nema 17 sized stepper with a 27:1 planetary gear head.
It has a holding torque of 26.0 Ncm
Rated at 0.4 Amps DC
Phase resistance 30 ohms
Rated at 12 V DC
with a phase inductance of 37.0 mH
- Youssef_Ismail
- Posts: 118
- Joined: Fri Sep 05, 2014 12:13 am
Re: Adafruit Motorshield V2.3 giving weak motor torque
Here is the code I am using.
Code: Select all
// Example6 code for Brian Schmalz's Easy Driver Example page
// http://www.schmalzhaus.com/EasyDriver/EasyDriverExamples.html
#include <AccelStepper.h>
#include <Wire.h>
#include <Adafruit_MotorShield.h>
// Define the stepper and the pins it will use
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
Adafruit_StepperMotor *motor1 = AFMS.getStepper(200, 1);
// you can change these to DOUBLE or INTERLEAVE or MICROSTEP!
void forwardstep() {
motor1->onestep(FORWARD, SINGLE);
}
void backwardstep() {
motor1->onestep(BACKWARD, SINGLE);
}
AccelStepper stepper1(forwardstep, backwardstep); // use functions to step
// Define our three input button pins
#define LEFT_PIN 2
#define STOP_PIN 3
#define RIGHT_PIN 4
// Define our analog pot input pin
#define SPEED_PIN A0
// Define our maximum and minimum speed in steps per second (scale pot to these)
#define MAX_SPEED 500
#define MIN_SPEED 0.1
double STEPS = 200;
//double gearRatio = 1.000000;
double gearRatio = 26.851240;
double rodPitch = 20.0;
double wS = 7.292116e-5;
double armLength = 16.125;
unsigned long baseTime;
void setup() {
baseTime = millis();
AFMS.begin();
// The only AccelStepper value we have to set here is the max speeed, which is higher than we'll ever go
stepper1.setMaxSpeed(500.0);
// Set up the three button inputs, with pullups
pinMode(LEFT_PIN, INPUT_PULLUP);
pinMode(STOP_PIN, INPUT_PULLUP);
pinMode(RIGHT_PIN, INPUT_PULLUP);
}
void loop() {
static float current_speed = 0.0; // Holds current motor speed in steps/second
static int analog_read_counter = 1000; // Counts down to 0 to fire analog read
static char sign = 0; // Holds -1, 1 or 0 to turn the motor on/off and control direction
static int analog_value = 0; // Holds raw analog value.
// If a switch is pushed down (low), set the sign value appropriately
/* if (digitalRead(LEFT_PIN) == 0) {
sign = 1;
}
if (digitalRead(RIGHT_PIN) == 0) {
sign = -1;
}
if (digitalRead(STOP_PIN) == 0) {
sign = 0;
}
*/
sign = 1;
// We only want to read the pot every so often (because it takes a long time we don't
// want to do it every time through the main loop).
if (analog_read_counter > 0) {
analog_read_counter--;
}
else {
analog_read_counter = 3000;
// Now read the pot (from 0 to 1023)
analog_value = analogRead(SPEED_PIN);
// Give the stepper a chance to step if it needs to
stepper1.runSpeed();
// And scale the pot's value from min to max speeds
//current_speed = sign * ((analog_value/1023.0) * (MAX_SPEED - MIN_SPEED)) + MIN_SPEED;
current_speed = STEPS * gearRatio * rodPitch * wS * armLength * cos((wS / 2.0) * double(baseTime / 1000.0));
// Update the stepper to run at this new speed
stepper1.setSpeed(current_speed);
}
// This will run the stepper at a constant speed
stepper1.runSpeed();
}
- adafruit_support_bill
- Posts: 88153
- Joined: Sat Feb 07, 2009 10:11 am
Re: Adafruit Motorshield V2.3 giving weak motor torque
Code: Select all
// you can change these to DOUBLE or INTERLEAVE or MICROSTEP!
void forwardstep() {
motor1->onestep(FORWARD, SINGLE);
}
void backwardstep() {
motor1->onestep(BACKWARD, SINGLE);
}
- Youssef_Ismail
- Posts: 118
- Joined: Fri Sep 05, 2014 12:13 am
Re: Adafruit Motorshield V2.3 giving weak motor torque
One of the reasons that I ordered the shield was to utilize the microstepping. The motor is being used to drive a barn door star tracker. The motor specs given above were for a geared stepper. I moved to the geared stepper so that I could run the stepper at a faster rate and eliminate the hard vibrations I was getting with stepping the motor at such a slow rate, it happened to cause photo blurring due to vibration. With a faster step rate on the geared motor, I eliminated that. However, I have been running into problems with the geared motor as it appears that the rate I need to run it at, seems to cause some kind of harmonic response that causes the motor to skip steps and the tracker starts to lose its tracking ability. But without a geared motor the step rate is to slow causing vibrations in the camera. I thought I would be able to circumvent this problem by being able to microstep the motor, as the pulses would come at a higher rate say in quarter step of eight step. Am I barking up the wrong tree?
- adafruit_support_bill
- Posts: 88153
- Joined: Sat Feb 07, 2009 10:11 am
Re: Adafruit Motorshield V2.3 giving weak motor torque
MICROSTEP is usually better than SINGLE, but not as much torque as INTERLEAVE or DOUBLE. INTERLEAVE may be a good compromise for you.
Harmonics can be a real problem with steppers. Changing the step rate is one approach, but even multiples of a problem step-rate (such as you get with microstepping) will still tend to excite the same resonances. It is sometimes possible to change resonance of the system by tweaking the weight distribution - although that is not always practical to do. A simpler approach is usually to decouple the motor somewhat from the structure via timing belt drives and/or vibration-absorbing motor mounts.
Harmonics can be a real problem with steppers. Changing the step rate is one approach, but even multiples of a problem step-rate (such as you get with microstepping) will still tend to excite the same resonances. It is sometimes possible to change resonance of the system by tweaking the weight distribution - although that is not always practical to do. A simpler approach is usually to decouple the motor somewhat from the structure via timing belt drives and/or vibration-absorbing motor mounts.
- Youssef_Ismail
- Posts: 118
- Joined: Fri Sep 05, 2014 12:13 am
Re: Adafruit Motorshield V2.3 giving weak motor torque
Thanks for the feedback Bill. I do have two resonance problems. One if the step rate is too slow, it causes camera shake and blurry photos. This one could be mitigated with an absorbing layer between the motor and the mounting base, maybe. Second is in the motor itself due to the step rate causing missed steps and throwing my tracking off cause streaked stars in the photos. My step rate starts off with clean steps at 126.29265 steps/sec and needs to get down to 116.627144 steps/sec by three hours in to the run. Somewhere around 124 to about 121 steps/sec, the motor starts to hum strangely and them get louder then lower harmonicly. This usuall y occurs at about 1.5 hours in to the run. Tracking drops off from here.
But we are getting off topic. All this still does not answer why the shield is not driving the motor with any decent torque, even when driving the motor slowly.
But we are getting off topic. All this still does not answer why the shield is not driving the motor with any decent torque, even when driving the motor slowly.
- adafruit_support_bill
- Posts: 88153
- Joined: Sat Feb 07, 2009 10:11 am
Re: Adafruit Motorshield V2.3 giving weak motor torque
The SINGLE step mode in the code posted is the weakest stepping mode. Both the SINGLE and MICROSTEP mode inherently have less torque because they apply less current to the coils. SINGLE energizes only one coil at a time and is the weakest stepping mode. Microstep shifts power from one coil to the other in a roughly sinusoidal pattern, so you never have full power applied to both coils at once. The DOUBLE step mode will give you the best torque because both coils are energized at all times.
Please be positive and constructive with your questions and comments.