Hi,
I'm using Adafruit Motor Shield V2 for Arduino (http://learn.adafruit.com/adafruit-moto ... -dc-motors) to run my DC motor (http://www.pololu.com/product/1103) which consumes a 5000 mA in the Stall position @ 12V. The motor shield I have can supply 1.2 A maximum for each port and that not enough to run my DC motor with load on it. Therefore, how can I make my motor shield supply 5ooo mA? What should I do?
On the other hand, I'm trying to control the motion of the DC motor using Arduino code, but what I noticed that the revolutions proportionally increase with the speed and vice versa!! Do have any idea why this is happening?
Thanks
Adafruit Motor Shield V2 for Arduino and DC motor
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
-
- Posts: 6
- Joined: Sun Dec 22, 2013 11:59 pm
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: Adafruit Motor Shield V2 for Arduino and DC motor
The motor spec says 300mA free-run (no load) and 5000mA stall (shaft locked). 99% of normal motor operation is somewhere in between those extremes.
There are a a couple things you can do to run this motor using the shield:
1 - Don't let it stall - I have run this same motor on a V2 shield with no issues. But I never load it heavily, so it doesn't stall.
2 - Run at a lower voltage - I know these motors run pretty well at 9v. I expect they would run as low as 6v. At 6v, your effective stall current would be 2500mA. That is less than the 3000mA peak rating for the shield.
Of course these options do not let you run the motor at its maximum power output (typically about halfway between free-run and stall current at the rated voltage). If that is important, you need to look at other options.
If direction control is not required (i.e. you do not need to reverse the direction of rotation) you can drive it directly with a N-Channel power MOSFET directly from a PWM pin. http://www.adafruit.com/products/355
If you do need direction control, you should probably be looking at a driver capable of higher current. Pololu has a nice selection.
There are a a couple things you can do to run this motor using the shield:
1 - Don't let it stall - I have run this same motor on a V2 shield with no issues. But I never load it heavily, so it doesn't stall.
2 - Run at a lower voltage - I know these motors run pretty well at 9v. I expect they would run as low as 6v. At 6v, your effective stall current would be 2500mA. That is less than the 3000mA peak rating for the shield.
Of course these options do not let you run the motor at its maximum power output (typically about halfway between free-run and stall current at the rated voltage). If that is important, you need to look at other options.
If direction control is not required (i.e. you do not need to reverse the direction of rotation) you can drive it directly with a N-Channel power MOSFET directly from a PWM pin. http://www.adafruit.com/products/355
If you do need direction control, you should probably be looking at a driver capable of higher current. Pololu has a nice selection.
Not sure I understand the question. If by speed you mean RPM, then it is proportional by definition.I noticed that the revolutions proportionally increase with the speed and vice versa!! Do have any idea why this is happening?
-
- Posts: 6
- Joined: Sun Dec 22, 2013 11:59 pm
DC Motor Position control with Arduino (PID) and Adafruit mo
Hi,
Thanks for the feedback. In my project, I'm using Arduino UNO and Adafruit motor shield (http://www.adafruit.com/products/1438#Learn) and gearing brush DC motor (http://www.pololu.com/product/1103/specs). I was trying to do a position control of my DC motor without using encoder which is already attached to the motor, but controlling it via Arduino code as it appears in the attached code. however, I couldn't achieve the required motion of the DC motor which is (Raising from 0 to 90 degrees, holding , and lowering back from 90 to 0 degrees, for 5 seconds for each stage).
The question, should I use the encoder with PID control to achieve this exact motion? or can I do that with just the arduino code? In case I need to include the encoder, What do I need to integrate PID control into my project?
Also, when I tried to drive the motor in low speed, the torque dropped down. The faster you drive the DC the higher the torque and the higher the current consumption.
My goal is to drive the DC motor at low speed without loosing torque and in the specific motion as mentioned above.
Thank you for the support
Thanks for the feedback. In my project, I'm using Arduino UNO and Adafruit motor shield (http://www.adafruit.com/products/1438#Learn) and gearing brush DC motor (http://www.pololu.com/product/1103/specs). I was trying to do a position control of my DC motor without using encoder which is already attached to the motor, but controlling it via Arduino code as it appears in the attached code. however, I couldn't achieve the required motion of the DC motor which is (Raising from 0 to 90 degrees, holding , and lowering back from 90 to 0 degrees, for 5 seconds for each stage).
The question, should I use the encoder with PID control to achieve this exact motion? or can I do that with just the arduino code? In case I need to include the encoder, What do I need to integrate PID control into my project?
Also, when I tried to drive the motor in low speed, the torque dropped down. The faster you drive the DC the higher the torque and the higher the current consumption.
My goal is to drive the DC motor at low speed without loosing torque and in the specific motion as mentioned above.
Thank you for the support
Code: Select all
#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);
// Select which 'port' M1, M2, M3 or M4. In this case, M1
Adafruit_DCMotor *myMotor = AFMS.getMotor(1);
// You can also make another motor on port M2
//Adafruit_DCMotor *myOtherMotor = AFMS.getMotor(2);
void setup() {
AFMS.begin(); // create with the default frequency 1.6KHz
//AFMS.begin(1000); // OR with a different frequency, say 1KHz
void loop() {
myMotor->run(FORWARD);
myMotor->setSpeed(20);
delay(1000);
myMotor->run(BACKWARD);
myMotor->setSpeed(20);
delay(1000);
myMotor->run(RELEASE);
delay(5000);
}]
Last edited by adafruit_support_bill on Wed Mar 12, 2014 7:00 am, edited 1 time in total.
Reason: Please use the 'code' button when submitting code - click 'code' and paste your code between the tags.
Reason: Please use the 'code' button when submitting code - click 'code' and paste your code between the tags.
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: Adafruit Motor Shield V2 for Arduino and DC motor
If you need to achieve precise positioning, you will need some form of feedback. Encoders are one way, simple limit switches are another.The question, should I use the encoder with PID control to achieve this exact motion? or can I do that with just the arduino code? In case I need to include the encoder, What do I need to integrate PID control into my project?
With either encoder or limit switches, you can do simple on/off control. In other words, you just run until you reach the desired position then stop the motor. Of course, real-world physics doesn't allow you to stop instantaneously, so there will be a bit of overshoot. This can be mitigated by slowing things down and/or allowing for some overshoot in your code and/or limit switch placement.
If you need smooth control and precise positioning, the Encoder/PID solution is a better way to go. This will reduce the speed of the motor as it approaches the limit and minimize the overshoot. Both PID and Encoder libraries are available at the Arduino Playground
http://playground.arduino.cc/Main/Rotar ... yBA7fldV8E
http://playground.arduino.cc/Code/PIDLi ... yBBDvldV8E
Pololu should be able to help you with documentation for hooking up the encoders in their motors. For a nice introduction to the PID, see Brett Beauregard's series here: http://brettbeauregard.com/blog/2011/04 ... roduction/
Since most encoders are quadrature-type encoders, they do not report absolute position, only relative rotation. For this reason, you may need to augment your encoders with one or more limit switches to establish a 'home' position for the encoder.
Low torque at low speeds is a characteristic of brushed DC motors. If you want better low-speed torque, you should consider stepper motors. It is also much simpler to achieve precise open-loop positioning with a stepper motor. With sufficient motor torque, no encoders or PIDs are required.
-
- Posts: 6
- Joined: Sun Dec 22, 2013 11:59 pm
Re: Adafruit Motor Shield V2 for Arduino and DC motor
Hi,
As I said before that I'm running DC motor using Arduino Uno and Adafruit motorshield, and I'm using PID control from Arduino library (http://playground.arduino.cc/Code/PIDLibaryBasicExample) to control the position of my DC motor.
I don't know how to integrate the two codes together, the Arduino code for PID and Arduino code to run my DC motor. Should I put them together in one code or run them separately?
This is my code
Thanks for the support
As I said before that I'm running DC motor using Arduino Uno and Adafruit motorshield, and I'm using PID control from Arduino library (http://playground.arduino.cc/Code/PIDLibaryBasicExample) to control the position of my DC motor.
I don't know how to integrate the two codes together, the Arduino code for PID and Arduino code to run my DC motor. Should I put them together in one code or run them separately?
This is my code
Code: Select all
/*
For use with the Adafruit Motor Shield v2
----> http://www.adafruit.com/products/1438
*/
#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);
// Select which 'port' M1, M2, M3 or M4. In this case, M1
Adafruit_DCMotor *myMotor = AFMS.getMotor(1);
// You can also make another motor on port M2
//Adafruit_DCMotor *myOtherMotor = AFMS.getMotor(2);
void setup() {
AFMS.begin(); // create with the default frequency 1.6KHz
//AFMS.begin(1000); // OR with a different frequency, say 1KHz
}
void loop() {
myMotor->run(FORWARD);
myMotor->setSpeed(50);
delay(5000);
myMotor->run(RELEASE);
delay(5000);
myMotor->run(BACKWARD);
myMotor->setSpeed(50);
delay(5000);
myMotor->run(RELEASE);
delay(5000);
}
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: Adafruit Motor Shield V2 for Arduino and DC motor
To control your motor speed with a PID, you need some form of feedback as explained in my previous post. What are you using for feedback?
-
- Posts: 6
- Joined: Sun Dec 22, 2013 11:59 pm
Re: Adafruit Motor Shield V2 for Arduino and DC motor
I'm using encoder for feedback (http://www.pololu.com/product/1443).
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: Adafruit Motor Shield V2 for Arduino and DC motor
The first thing you need to do is get the encoder working so that you can know the position of your motor shaft. There is a tutorial here on the Arduino Playground:
http://playground.arduino.cc/Main/Rotar ... yTBuvldV8E
Once you have a working encoder, you can use that as input to the PID:
http://playground.arduino.cc/Main/Rotar ... yTBuvldV8E
Once you have a working encoder, you can use that as input to the PID:
Please be positive and constructive with your questions and comments.