Go Down

Topic: RC Car steering motor will turn right but not left (Read 2682 times) previous topic - next topic

chr1112

Feb 17, 2012, 03:27 pm Last Edit: Feb 17, 2012, 03:52 pm by AWOL Reason: 1
This is my first post so please bear with me...

I'm modding an RC car using an H-bridge on my Arduino Uno.it has two motors. The rear for propulsion and the front is for steering. the rear wheels work perfectly moving forward and backward as designed (Thanks to your tutorial section for all of your help). The front steering is where my problem comes in. They turn right when appropriate, but I get no response when asked to turn left. The steering motor has only two wires and appears to work on a spring basis. When you give a positive current to one side they turn right, when you reverse the current they turn left. When there is no current they spring to the center position. I tested it with a regular 3v DC batter and they turn perfectly. However when connected through the H Bridge they do not turn left, but do turn right perfectly. I check the current coming out of the leads from the H Bridge and as designed provide a positive current when asked and a negative current when asked. What am I doing wrong? Why don't they turn left?

I have the Hbridge connected to an external power supply of 9.6 volts. So i can get the car to go forward, reverse, right, but not left.... What am I missing here?

Thank you in advance for all of your help.

Sincerely,
Carlos

Here is my code:
*******************************************
/
Code: [Select]
/R.E.M.O. Sketch v 1.2
int moveMotor;
const int motor1Pin = 3; // H-Bridge Leg 1
const int motor2Pin = 4; // H-Bridge leg 2
const int enablePin = 9; //H-Bridge enable pin
const int turn1Pin = 5; // H-Bridge leg 4A
const int turn2Pin = 6; // H-Bridge leg 3A

void setup()  {
 pinMode(motor1Pin, OUTPUT); //Power to wheels back
 pinMode(motor2Pin, OUTPUT); //Power to wheels back2
 pinMode(enablePin, OUTPUT);
 pinMode(turn1Pin, OUTPUT); //Turning wheels
 pinMode(turn2Pin, OUTPUT); //Turning wheels2
 digitalWrite(enablePin, HIGH);
 Serial.begin(115200);
 Serial.println("Remote Exploratory Mobile Unit 1.2");
 Serial.println("by CHR1112");
 Serial.println();
}

void loop() {
 if (Serial.available() > 0){
   moveMotor = Serial.read(); // take signal from keyboard.
   //ASCII codes: "f" = 102, "b"=98, "l"=108, "r"=114
   if (moveMotor == 102) {
     //forward motion by the letter 'f'
     analogWrite(motor1Pin, 120);
     digitalWrite(motor2Pin, HIGH);
   }
   
   else if (moveMotor == 98) {
     //backward motion by the letter 'b'
     analogWrite(motor1Pin, 120);
     digitalWrite(motor2Pin, LOW);
   }
  else if (moveMotor == 114) {
     //  right turn by the letter 'r'
     analogWrite(turn1Pin, 90);
     analogWrite(motor1Pin, 120);
     digitalWrite(turn2Pin, HIGH);
     digitalWrite(motor2Pin, HIGH);
   }
   else if (moveMotor == 108) {
     //left turn by the letter 'l'
     analogWrite(turn1Pin, 90);
     analogWrite(motor1Pin, 120);
     digitalWrite(turn2Pin, LOW);
     digitalWrite(motor2Pin, HIGH);
   }
   else {
     //stop everything.
     digitalWrite (motor1Pin, LOW);
     digitalWrite (motor2Pin, LOW);
     digitalWrite (turn1Pin, LOW);
     digitalWrite (turn2Pin, LOW);
   }
 }
}


Moderator edit: CODE TAGS
**********************************************************  

cr0sh

Why are you using analogWrite() with the "turn" motor (h-bridge)? Since it sounds like the system doesn't have proportional turn capability, you should just need to use digitalWrite() to send HIGH and LOW values to the steering h-bridge (the drive motor is a different thing; you probably want speed control there).

BTW - you might want to post more about the circuit and car - pictures and schematics are very helpful; also - what "tutorial" are you speaking of?

Finally - have you measured the current consumption of the steering actuator, and how it compares steering "left" vs "right" - as well as whether the h-bridge can source the current needed. Which h-bridge are you using? It is possible that you might have blown half the h-bridge (while not the other half) if you were trying to drive a load too large for it...
I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

chr1112

Thanks for getting back to me with great points.
-With respect to why I used analogWrite was to avoid giving it too much voltage and blowing the H Bridge. So since I was able to turn the motor left and right with just 2 D batteries(3 volts), I adjusted the voltage from the H Bride to around three volts. as time went on I've been trying higher and lower, but no difference in effect.
-I would love to just use High and Low digitalWrite. It would make it simpler.
-When I made references to the tutorials it was with respect to the world of knowledge I've gained so far. I would never have gotten anywhere close to here without this forum. I was generalizing about the value of the tutorials in this realm.
-As for blowing the H Bridge, that is a possibility. I wouldn't know how to test to see if If did blow it. Is there a direction you can point me in to find that out? Other than what I described in my original post about setting my multimeter to the leads coming out of the H-Bridge and getting a good positive current when asked to go left and then a negative current when asked to go right. Again I do not believe I blew the bridge because of my multimeter readings and the fact that the rest of the unit works perfectly. Forward, reverse, and right, just not left.

The H-Bridge I am using is Sparkfun's H Bridge motor driver 1A  SKU: COM 00315, SN754410

Asfar as measuring the "current consumption of the steering actuator", I'm afraid my lack of experience is hurting me here. How would I go about finding out how to do that?

Pictures, I'll take some tonight and post.

Thanks alot for your help and pointers cr0sh!...anything or direction you could point me in is greatly appreciated.

cr0sh


Thanks for getting back to me with great points.
-With respect to why I used analogWrite was to avoid giving it too much voltage and blowing the H Bridge. So since I was able to turn the motor left and right with just 2 D batteries(3 volts), I adjusted the voltage from the H Bride to around three volts. as time went on I've been trying higher and lower, but no difference in effect.


Ok - so you're saying you are using PWM to in effect get an average voltage lower than your source battery voltage (which is?)...?

I really wouldn't worry about blowing the h-bridge - the SN754410 is an L293 equivalent (http://www.ti.com/lit/ds/symlink/sn754410.pdf - Remember, datasheets are your friends!), and is ok up to 36 volts (unless your battery is larger?).

Of course, if the original vehicle used only 3 volts to switch the steering, then you should stay within that range (and the same for your drive motor as well).


-I would love to just use High and Low digitalWrite. It would make it simpler.


It might be possible that in some manner the PWM isn't allow full current to flow via the h-bridge; what you might do is ditch the bridge, and instead use a couple of SPDT relays (which you could control using digitalWrite).


-When I made references to the tutorials it was with respect to the world of knowledge I've gained so far. I would never have gotten anywhere close to here without this forum. I was generalizing about the value of the tutorials in this realm.


Ok - regarding the above, then, you should be able to find a tutorial on how to control a relay with the Arduino (you'll need a couple of transistors, a couple diodes, and a couple resistors as well); connect the center "arm" of each relay to one end of the coil, then connect the "Open" contacts of each relay to ground, and "Closed" contacts of each relay to positive voltage. Set one HIGH and one LOW to change the direction of the current (and thus steering). Note that this is a simple form of an h-bridge (but no PWM control).


-As for blowing the H Bridge, that is a possibility. I wouldn't know how to test to see if If did blow it. Is there a direction you can point me in to find that out? Other than what I described in my original post about setting my multimeter to the leads coming out of the H-Bridge and getting a good positive current when asked to go left and then a negative current when asked to go right. Again I do not believe I blew the bridge because of my multimeter readings and the fact that the rest of the unit works perfectly. Forward, reverse, and right, just not left.


Well - there's a couple of ways I can think of:

1. If you are using the same bridge for both fwd/rev and left/right - then swap the wires around (so that left/right connect to what was fwd/rev); and switch your pins on the Arduino (in code -or- physically; but NOT both). If the code works the same, its probably not the h-bridge. If you lose another function (or suddenly you can't go fwd or rev) - then the bridge is bad (or you have blown another half of the bridge - oops!).

2. Less destructive than the above would be to put your meter leads in place of the steering leads, and set your meter to read voltage; if you actuate left vs right, you should see +V vs -V on the meter; if on commanding "left" - you see 0 volts instead of voltage, then the h-bridge is blown.

3. Another method would be to drop your PWM further (so you only see 1-2 volts on the output), and connect a two-pin bi-color LED across the output pins of the h-bridge; when you command it to go one direction vs. the other, the color should change (if it doesn't light in one direction or the other, then the h-bridge is blown - but make sure your LED works, first).


The H-Bridge I am using is Sparkfun's H Bridge motor driver 1A  SKU: COM 00315, SN754410

Asfar as measuring the "current consumption of the steering actuator", I'm afraid my lack of experience is hurting me here. How would I go about finding out how to do that?


Using your 3 volt battery that you original were playing with, hook the lead from the actuator to the positive lead on your meter. Hook the negative lead on the meter to the positive of the battery. Set you meter to read CURRENT (this is VERY important - or you could blow your meter - set it to read at least 1 amp). Then hook the negative of the battery up to the other terminal on the actuator. It should actuate (one direction or the other) and you can read the current on the meter (don't leave it in the "energized" state for long - a second or two, max).

If this current read is greater than about 500 mA or so, then likely the h-bridge is going into over-current shutdown (though why this would occur for only one direction, I don't know).


Pictures, I'll take some tonight and post.

Thanks alot for your help and pointers cr0sh!...anything or direction you could point me in is greatly appreciated.


Good luck, I hope my suggestions help... :)
I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

to start with you have only one enable pin int in your code so only one side of the h bridge is turned on also
the rest of the code seems broken in the ide nothing but errors when i attempt to upload
this what i get when attempting upload
  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.
Arduino: 1.0.6 (Windows 7), Board: "Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega328"
sketch_jan27a:1: error: expected constructor, destructor, or type conversion before '.' token
sketch_jan27a.ino: In function 'void loop()':
sketch_jan27a:24: error: 'moveMotor' was not declared in this scope

MarkT

Sounds like you aren't providing nearly enough drive to the motor and its barely able to
move, just happens to turn one way but not the other due to differences in friction.

Using a darlington motor driver with a low voltage supply is never satisfactory, you can
lose perhaps 2.5 to 3V in the driver alone...
[ I won't respond to messages, use the forum please ]

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy