Go Down

Topic: DC motor control using H-Bridge (Read 12 times) previous topic - next topic

Giles Whitaker

Hi...I've just joined this forum and I'm excited to be doing some "physical computing"....

I've just been setting up a circuit to control a motor with an H-Bridge, following the tutorial here:

ITP Physical Computing H-Bridge (you'll have to google this to find it as I can't post a link in my first post on the forum)

I'm not a student in this course - just found these useful tutorials while surfing. I set it all up, and everything works as expected, but now I would like to know how to change the power supply to use a battery pack with 3 AA batteries in rather than the 5V from the arduino (which runs the motor fine). I have the battery pack, and have soldered the two wires onto it...but now I have a + and a - wire and I don't know how to replace the motor power supply with these...as the H-Bridge only seems to take one power supply connector...

I'm sure the answer is obvious to seasoned arduino-ers.... any help would be appreciated....

gbulmer

#1
Apr 16, 2010, 07:42 am Last Edit: Apr 17, 2010, 01:05 am by gbulmer Reason: 1
Assuming you mean http://itp.nyu.edu/physcomp/Labs/DCMotorControl

and you are using an L293D or a SN75440, then as you might see on the schematic, pin 8 is intended to connect to a motor power.
Connect the + of your batteries to this.
Connect - of your batteries to ground (and stay connected to the Arduino's ground).

3 AA batteries are on the edge of what will work. The L293D likes at least 4.5V, and 3 AA are only 4.5. I don't think it will fail until the batteries start to go flat, and possibly at first when the motor starts.
[edit]Doh! Meant to say possibly (now changed), but originally wrote probably.[/edit]

HTH
GB

Giles Whitaker

That worked perfectly, thanks....

Yes, the link was http://itp.nyu.edu/physcomp/Labs/DCMotorControl, a really well put-together tutorial for this -everything is clearly illustrated. The H-Bridge chip I have is an L293NE - worked fine with the 3xAA batteries. But I'm going to put this circuit into an RC car that uses 4xAA now, anyway.....

Thanks again for your help, much appreciated.

gbulmer

Quote
worked fine with the 3xAA batteries


Excellent!

I try to alert folks to possible problems. I try to be quite conservative with other peoples stuff, so it's good to know it worked fine.

Is the plan to power the H-Bridge and Arduino from 4 AA batteries?

GB

cr0sh

#4
Apr 17, 2010, 01:29 am Last Edit: Apr 17, 2010, 01:30 am by keeper63@cox.net Reason: 1
Quote
3 AA are only 4.5


gbulmer, just so Giles isn't confused:

3 AA cells hooked in series will give you 4.5 VDC if the cells are "non-rechargeables" (generally alkaline or carbon cells). Most rechargeables output only 1.2 VDC per cell - so 3 would give you 3.6 volts, which may be too low, if you were to use, say NiMH cells instead of alkalines.

But good news! While the 4 cells in your R/C car with alkalines will be outputing 6 volts, with rechargeables you should see 4.8 volts, which is close to the 4.5 you were seeing before with the 3 cell pack.

Even so, you would do well to look into modifying your circuit and/or the R/C car to use a 7.2 or 9.6 VDC racing pack, then route this voltage to the external voltage jack on the Arduino (or if you are doing standalone, use a regulator for 5 VDC), and then a separate regulator for the bridge and/or motors it is driving. That way you aren't running up against any limits or possible sagging of voltages as the motors kick in which could cause spurious resets (or possibly worse) of the Arduino.

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

gbulmer

cr0sh - Thank you.

Another point worth noting is 6V isn't enough to reliably power an Arduino through it's DC socket, but too high to drive the Arduino directly through it's header.

Also 4.8V is okay if there is no electrical noise, but electric motors generate electrical noise.

So follow cr0sh's suggestion, or use a second battery (e.g. 9V, or something over 7V) to power the Arduino through its DC socket. The Arduino usually uses much less than a 100mA, so a small battery would be fine.

GB

Giles Whitaker

Thanks again for your advice...it's going well but I ran into a problem....

I'm using the 4xAA batteries to power the motors in the RC car - that's actually just the batteries that the car originally runs on in the battery compartment at the bottom. The Arduino itself is being powered by a 9V battery.

I just cut out the circuit board in the car and kept the wires which ran to the two motors and the battery compartment for attaching to my own circuit+arduino.

The RC car has 2 DC motors - one for driving, one for steering. I set up the H-Bridge to control both the motors, and uploaded some simple programs that I wrote - like just moving forward while turning right for 2 seconds, then moving backwards while turning left for 2 seconds, etc. This all worked fine. I found that using the PWM for analogWrite at a value of 150 was fine for the steering motor.

I also have another little circuit board which I had set up with four photoresistors - pointing north, south, east and west. I wrote a program using serial to check that it worked.... the program returns 0, 1, 2 or 3...indicating whether the strongest light is to the front, back, left, or right. This worked fine.

I connected this circuit to the car  drawing the 5V from the "power rail" I had set up on the breadboard (from the arduino 5V) with the H-Bridge chip in it, and wrote a program to make the car move in different ways depending on the light direction. Basically, the car tries to turn and move towards the light. It worked, but the car just moves in jerks - stops and starts. The power light and little LED13 light on the arduino keep blinking, so it is obviously being overloaded. I tried reducing the 4 resistors on my photodetector array from 1K down to 220 ohms but it didn't help.

I don't really understand why the microcontroller is getting overloaded.... it worked fine with the two motors controlled through the H-Bridge, but adding the photodetector array seems to make it draw too much current now..??

gbulmer

That's puzzling. So everything works fine without the photoresistors?

Would you be willing to try a different tack, and use the Arduino as a debugging tool?

Disconnect the H-Bridge, and modify the program to write the analogRead values for the photoresistors up the Serial port to the host PC.
Then, with the vehicle jacked-up off the ground (so it doesn't pull anything loose), reconnect the H-Bridge, and see what is happening to the printed sensor values. Set the baud rate as high as it will go (e.g. 115200)

Are the sensor values distinctly different with the H-Bridge connected? If it's hard to see, ignore three sensors (i.e. comment out the analogReads and Serial.prints) and track one sensor, which will be 4 times the previous sample rate, which should be faster than noise from the cars motor, and different to the PWM signal.

HTH
GB

Giles Whitaker

OK...I will try that soon. One thing I noticed is that when the vehicle is off the ground, the wheels spin normally without resetting the arduino. It does all the stuff it is supposed to do in response to the light directions. When you put it down on the ground it starts resetting. This implies there is some blow-back current from the motors when there is loading on them (non-technical terms - I don't know the right ones). But I thought the H-Bridge was supposed to isolate the arduino from the motors which have their own separate power supply? Anyway, I'll try what you suggested and report back later.

gbulmer

#9
Apr 18, 2010, 11:46 pm Last Edit: Apr 18, 2010, 11:48 pm by gbulmer Reason: 1
It does sound like there is something wrong.  :-/

There'd be some protection by putting resistors on the Arduino pins to H-bridge connections.
Maybe something at 270 ohms or bigger (L293D are pretty good so I think upto 1K would be okay).

Also, if you have an oscilloscope or good meter, have a look at the power supplies. It may be the batteries are a bit flat, and when you're drawing significant current (to move the model) it is dropping low. Then the motor might be sucking power from the logic supply, ooops!

HTH
GB



Giles Whitaker

Duh!!  :-[

I had the (-) power lead from the RC battery pack (4xAA) connected to the Arduino 5V rather than to the ground. Because on one side of my breadboard the (+) and (-) on the long rails are one way around, and on the other, the other way. So I must have just put it into the wrong one....

All working fine now... well, I guess I learned to go over all the connections and check them carefully. And I'm glad I got onto the forum and met the "Arduino community". Thanks again for your help.

Now I just need to refine my program, which doesn't work that well (sort of works).

Go Up