Arduino RC Car Help

Hello everybody,

I am trying to run an old RC car using an arduino UNO with a L298p motor-shield and a 2.4 ghz receiver (4.5-6V). The power supply is a 9.6V 2000mAh NIMH battery pack.

The problem that I am encountering is that the car goes crazy (motors change direction rapidly...or go wide open) when a fully charged battery pack is being used. When the arduino is connected to a computer via USB everything works, and when the battery level drops to around 3/4 charge everything works.

I have tried to put 330 ohm resistors in series with the receiver's signal to the arduino. I have also put a capacitor across the power supply and across the motors being used. Neither of these seemed to make a difference. I checked the voltage on the 5v rail on the motor shield and it was reading around 6.7 V when the battery was full charged, and under 6.3 V when everything starts to work correctly. I thought maybe the receiver was getting to much voltage, so I tried powering it with a separate 4.5 V power supply. This didn't help solve the sporadic motor movement, but it did allow me to look at the raw input data from the receiver using the serial monitor. The throttle signal read between 600 and 6000, and the usually values are 1000-2000;

I don't know a whole lot about circuits, so any advice is welcome.

Is it common to have a large amount of noise in the receiver's signal that requires filtering, or is there a quick hardware fix?

Simple Arduino Program for the RC Car:

int E1 = 10;
int M1 = 12;
int E2 = 11;
int M2 = 13;
void setup() {
Serial.begin(9600);
pinMode(M1, OUTPUT);
pinMode(M2, OUTPUT);
pinMode(E1, OUTPUT);
pinMode(E2, OUTPUT);

}

void loop() {

int throttle = pulseIn(A1, HIGH); // Input from reciever for throttle control.
int RCsteerIN = pulseIn(A0, HIGH); // Input from reciever for steering control.
int rcAngle = -.0591 * RCsteerIN + 177.99; // Converts input signal to degrees.
int potIN = analogRead(A5); // Input from steering potentometer.
int potAngle = -.102 * potIN + 143.39; // Converts pot input to steering angle.
int steerWS = abs(rcAngle - potAngle) * 9; // Simple proportional controller
// Serial.print(throttle);
// Serial.print("\n");
// delay(500); // For debugging

//Throttle Control
if (throttle > 1610) { // FORWARD;

int ws = .7 * throttle - 1124.8;
if (ws > 255) {
ws = 255;
}
// Serial.print(ws);
// Serial.print("\n");
digitalWrite(M2, HIGH);
analogWrite(E2, ws);
}
else if (throttle < 1410) { // REVERSE

int ws = -.44 * throttle + 624.5;
if (ws > 255) {
ws = 255;
}
// Serial.print(ws);
// Serial.print("\n");
digitalWrite(M2, LOW);
analogWrite(E2, ws);
}
else {
int ws = 0;
analogWrite(E2, ws);
// Serial.print(ws);
// Serial.print("\n");
}

//// Steering Control
if (rcAngle - potAngle > 2) { // Turn Left
digitalWrite(M1, HIGH);
analogWrite(E1, steerWS);
}
else if (rcAngle - potAngle < -2 // Turn Right
) { // Turn Right
digitalWrite(M1, LOW);
analogWrite(E1, steerWS);
}
else {
analogWrite(E1, 0);
}
}

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Also can you please post pictures of your project so we can see your layout, and the RC car.

Thanks.. Tom.. :slight_smile:

Thanks for the heads up on how to post the code so that it is easier to read. I have tried to attached a photo of the wiring on the motor shield, but I'm not having much luck.

There isn't much to the circuit. The signal from the receiver is read on pin A0 and A1. Pin A5 is used to read the output from the potentiometer which is used to determine the steering angle. Other than that, everything else is hooked to ground or 5v pin.

Thanks again.

Hi,
If you attach the image, use REPLY rather than QUICK REPLY and I think the file needs to be less than 1M in size.
There is an attachment facility at the bottom of the screen.

You can use PAINT to resize if your file is too big, and you are using Windows.

Tom... :slight_smile:

I have attached a diagram of the wiring on the motor shield. Motor B controls the rear wheels, and motor A controls the steering.

Hi,
Where are you connecting the 9.6V to the Arduino?
It should be between gnd and Vin.
You should not measure more than 5V on the 5V pin of the controller.

The motor power supply terminal is just for the motor, it is not supplying the control circuitry.
Your shield is more than just a motor driver, look up its circuit diagram and instruction.
There is a jumper (OPT), what does it do?

Tom... :slight_smile:

I am only connecting power to the ground and Vin on the motor shield, and it is powering the rest of the Arduino. Does this mean there is a problem with the motor shield? I just attached a fully charged battery on the shield, and it is reading 11.32V at the connection and 7.3V across the ground and 5V pins on the Arduino.

When I plug the Arduino into the USB port of a computer (with the 9.6 battery pack attached) the voltage across the 5V and ground pins drop to 5.32v.

Hi,
7.3V is too high for the 5V pin, you will damage the boards if you leave it like that

Check your wiring?

Please post a picture of your project so we can see your layout.

Remove the shield and power the UNO with the battery in Vin and gnd, and measure 5V to gnd.

Tom... :slight_smile:

I have attached a photo of the wiring setup on the motor-shield. I went with this setup because I thought the RC car's original circuit board could be removed and everything could easily be attached directly to the motor-shield. I also wanted to be able to power everything (motors, Arduino, and receiver) from one battery pack.

When hooking the battery pack directly to the UNO, the voltage drop across the 5v and grn pins still reads around 7 volts. I also hooked a 9v Duracell battery to the motor-shield and directly to the Uno, and both readings across the 5V and grn pins read right under 5 volts.

I thought the L289p motor-shield would take up to 24V and allow 5V to power the Arduino. I don't know much about electrical circuits, so I may have misinterpreted the data sheet.

Is it possible that the shield has been damaged, or do I need to just use an H-bridge to power the motors?

Thanks
Justin

schem.png

Images are much easier for others to see if you embed them after you attach them. Right click on the attachment and copy the link location. Modify (not quick edit) your post, click the picture icon and past in the link. Save and viola! The image is embedded in your post.
1c46187aa086b4d9b0f5b43b5cf298e70dc6ef9f.png

Just an update on the project for anyone interested.

I thought the L289p motor-shield may have been damaged because of the 5v pins was putting out 7v, so I bought another L289p motor-shield. With the new motor-shield installed,the 5v pin was still reading about 7v. To solve the problem, I pulled the b connector bridge that allows the motor-shield to power the arduino and used a regular 9v battery to power the arduino. Everything works as it should now.

nikkolobochaser.png