Go Down

### Topic: The car not moving, but motor speed is set to max (Read 1 time)previous topic - next topic

#### yerzhik

##### Oct 17, 2012, 07:03 amLast Edit: Oct 17, 2012, 07:09 am by yerzhik Reason: 1
I have made a toy car, with arduino UNO + Bluetooth + Motor shield installed on it.
There are two DC Motors, at the front of the car and at the back.
The front motor controlls the turn of the front wheels.
Motor at the back moves the car.

Commands, such as turn right, left or go straight are sent from android through Bluetooth.
Arduino accepts it and executes the command.

At first everything works fine. The car moves fast, and performs turns fast.
But after some time the car suddenly decrease in speed, almost stops, and I hear a sound from the back motor.
It seems like it doesn't have enough power to move the car, and if I pick up the car at that moment, the motor starts moving fast as before,
but if I put the car back to the floor it doesn't move with the needed speed again.

Let me explain you the command execution algorithm,
After receiving the turn Left or Right command
Check if I am already performing the same turn,
if not, then
1. Set the back motor speed to 0
2. RUN the front motor at the needed direction (backward or forward meaning left or right)
3. Set the speed of the back motor to maximum (255)

After receiving the GO Straight command:

Check if I am already going straight, if not, then
1. Set the back motor speed to 0
2. RUN the front motor at the opposite of the current turn direction
3. Delay for some time, enought to turn the wheels straight
4. RELEASE the front motor.
5. Set the speed of the back motor to some value, less than maximum (255).

Are there any defects in this algorithm?
And what can be the cause of the problem?

I want also to mention that the car was working properly before, but with not enough speed when making turn,
so I decided to add two more batteries. After that I am facing this problems.
Previously I was using 6 AA. Now I am using 8 of them.

#### Osgeld

#1
##### Oct 17, 2012, 07:20 am
Quote
Previously I was using 6 AA. Now I am using 8 of them.

batteries in series increase voltage

batteries in parallel increase current

how do you have it set up?

#### yerzhik

#2
##### Oct 17, 2012, 08:51 am

Quote
Previously I was using 6 AA. Now I am using 8 of them.

batteries in series increase voltage

batteries in parallel increase current

how do you have it set up?

It is connected in series

#### Stealth0113

#3
##### Oct 17, 2012, 09:18 am
Just upload a sketch that only turn on/off the motor's. It seems like you have not enough power to let te motors spin. How do you feed the motor(shield)? I hope not via the 5v of the arduino because that pin doesn't have enough current.
Watch my stealth-bot @ let's make robots

#### yerzhik

#4
##### Oct 17, 2012, 12:43 pm

Just upload a sketch that only turn on/off the motor's. It seems like you have not enough power to let te motors spin. How do you feed the motor(shield)? I hope not via the 5v of the arduino because that pin doesn't have enough current.

I am supplying common power for arduino and motor shield through the motor shield.

My motors variables are:
AF_DCMotor motorBack(4, MOTOR12_64KHZ);
AF_DCMotor motorFront(1, MOTOR12_64KHZ);

The car goes only forward or stops, so for the motorBack my turn on/off motor's function is:
void SetMotorSpeed(int val) {
if (mySpeed == val)
return;
mySpeed = val;
motorBack.setSpeed(mySpeed);
motorBack.run(FORWARD);
}
passing parameter 0 to the function above makes the motor stop.

For the motorFront, which is used for making turns, there are three functions, turn left, right and straight:

void turnRight() {
if (turnState != 1) {
setMotorSpeed(0); // for motorBack
motorFront.run(FORWARD);
turnState = 1;
delay(100);
setMotorSpeed(motorTurnSpeed); // motorTurnSpeed = 255
}
}

void turnLeft() {
if (turnState != 0) {
setMotorSpeed(0); // for motorBack
motorFront.run(BACKWARD);
turnState = 0;
delay(100);
setMotorSpeed(motorTurnSpeed); // motorTurnSpeed = 255
}
}

void turnStraight(int cycle) {
if (turnState != 2) {
setMotorSpeed(0); // For back motor
if (turnState == 0) {
motorFront.run(FORWARD);
delay(cycle); // wait until wheels turn straight
motorFront.run(RELEASE);
} else if (turnState == 1) {
motorFront.run(BACKWARD);
delay(cycle); // wait until wheels turn straight
motorFront.run(RELEASE);
}

turnState = 2;
setMotorSpeed(motorStraightSpeed); // motorStraightSpeed = 200
}
}

Go Up

Please enter a valid email to subscribe