I am trying to control the speed of two dc gearbox motors that I'm controlling with the adafruit motor shield v1 and accompanying library, but noticed that when I set the speed to lower numbers, the motors stop working.
They make a noise, but seem to have trouble turning.
The minimum speed I can use before the motor stops is different depending on the voltage, and varies slightly depending on the motor. Usually it's somewhere in the range of 30 - 70.
My questions are the following:
Why is this happening?
Is this normal or expected with these kinds of motors?
Can I control motor speed more precisely, so that it works at lower speeds? If so, how?
Also, more generally, how can I account for the eventual load of the robot when choosing which motors to use?
For reference, this is the kind of motor I'm referring to:
Although I don't think the problem is my code, here it is anyway:
#include <AFMotor.h> // adafruit motor library for motor shield v1
// set up motors via motor shield with af library
AF_DCMotor rightMotor(2);
AF_DCMotor leftMotor(1);
int delayTime = 1000;
void setup() {
Serial.begin(9600);
Serial.println("Motor test!");
rightMotor.setSpeed(30);
leftMotor.setSpeed(30);
}
void loop() {
Serial.println("right motor forward");
rightMotor.run(FORWARD);
delay(delayTime);
Serial.println("right motor backward");
rightMotor.run(BACKWARD);
delay(delayTime);
Serial.println("right motor stop");
rightMotor.run(RELEASE);
delay(delayTime);
Serial.println("left motor forward");
leftMotor.run(FORWARD);
delay(delayTime);
Serial.println("left motor backward");
leftMotor.run(BACKWARD);
delay(delayTime);
Serial.println("left motor stop");
leftMotor.run(RELEASE);
delay(delayTime);
}
Those motors are termed "hobby motors", and are not very efficient and as you have found, not very consistent in performance.
They are built for a price.
The main reason you cannot get very slow speed is because of FRICTION in the motor, you need to provide a certain amount of energy to just turn the motor shaft.
The number of magnetic poles in the motor also effects smooth and reliable starting.
So if I needed a motor that can start more smoothly and reliably, then I would need to find one that's got more magnetic poles? Does this also affect the minimum speed that the motor will turn at?
For context: I am trying to build a little bot that follows a line, but have found that with these motors, that I need to set quite a high speed in order to just get the bot moving.
After overcoming the initial intertia of standing still + the weight of the bot + the friction of the motors and the floor on the wheels, the bot then speeds up until it reaches the speed I set (logically).
But this speed ends up being so fast that it makes it difficult for the two IR sensors I'm using to detect the black line. The bot ends up flying past it before it can correct course.
So my reasoning (as a noob ) is that I can approach it from two main angles:
Slow the bot down to give the sensors more time to sense the line and changes in IR light, and,
Add a third IR sensor between the current two IR sensors, spread the sensors out more, and use a thicker line.
I'm sure there are other ways to correct for this in the code, like maybe adding an encoder to help check speed and then to slow down once the speed has been reached, but I'm trying to keep it simple for now and just understand how to get the best out of the components and otherwise which components are better for this job before I try to get fancy.
That driver wastes a lot of voltage, 2 - 4 volt. Add that to the motor voltage and supply that voltage. Or.... use a modrn MOSFET transistor based driver.