Pages: [1]   Go Down
Author Topic: The car not moving, but motor speed is set to max  (Read 1109 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: October 17, 2012, 12:09:44 am by yerzhik » Logged

SE USA
Offline Offline
Faraday Member
**
Karma: 41
Posts: 3783
@ssh0le
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Netherlands
Offline Offline
Jr. Member
**
Karma: 0
Posts: 77
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Watch my stealth-bot @ let's make robots

Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
    }
}

Logged

Pages: [1]   Go Up
Jump to: