H-Bridges, Motor Control etc.

Ok, let me get this straight.
When the polarity of a motor is inverted, it spins the other direction yes?
Then why do we use H-Bridges as opposed to two digital output pins and changing them from high to low?

Thanks for answering newbie question.

Because you need to source and sink the motor current from each pin in turn as you switch it.
Normally current is limited by a resistor on a digital output, if you were to do this driving a motor there would be two resistors in series with the motor at all times.
What you want an output to do is to switch hard between +5 and 0V normal outputs just pull up or down through a resistor.

When you work out how to do that you have a H-bridge. :slight_smile:

Hmmmk.

IC’s are making a bit more sense now, I just need to find a place in Aus that sells H-Bridges. I think I’ll just resort to it. :stuck_out_tongue:

Thanks.

Or you can build one yourself with P-Channel and N-Channel MOSFETs.
A quick google search returned this:
http://www.embeddedrelated.com/usenet/embedded/show/18373-1.php

in Australia you can buy h bridge ic’s at jacar electronics, rockby electronics in Melbourne, Alltronics to name a few. Online I choose to buy from sparkfun, eBay sometimes is ok. Hope that helps. There are other more expensive places such as RS components & digikey

Megathanks. I’ll ask the staff next time I’m at jaycar.

I thought I’d read somewhere that Jaycar didn’t stock them :\

I believe the true reason is that when you turn off a digital output, you are opening a circuit, but the motor needs to inverse the polariy instead. In other words, if you have +5v in pin 1 and the motor is conected to pin 1 and grownd, when you turn pin 1 off, you get the motor wired to grown and opened. If you replace the grownd for Arduino’s pin 2, you will get +5v in one terminal, and the circuit is opened when pin 2 is off. If you could get -5v in any terminal, it could works.
Just teoretically, I believe you can play with analog outputs: if you send a high voltage in i.e. Analog 1 and a low voltage in Analog 2, you will get a (Sorry… I have not enough english) ¿potencial diference?? between the two terminals of the motor, and you could inverse it in order to inverse the direction.

I believe you can play with analog outputs:

No the analogue outputs are in fact PWM (pulse width modulated) digital outputs.

If you used digital outputs then you are limited to 20mA motor current which is too small to drive the motor. (see the start of this thread)

But what if I say, use the digital Outputs to trigger a DPDT relay, which alternates the flow of electrons in the circuit which contains a battery and a DC motor?

Then you would be building an h-bridge using a relay:)

Cheers, I’ll draw up a circuit diagram soon and see if you guys can correct me on anything.

ps. This is an awesome forum.

EDIT:
The only DPDT relays the stores show on their websites are 12V. If I’m using the arduino’s digital outs, will that be enough to trigger them?

Probably not. The way it works is that the coil of the relay presents a given resistance, and it needs to draw a given amount of power to produce a sufficiently strong magnetic field. At a lower voltage, it needs to draw more current. If the resistance of the coil is too high, however, it will not be possible for it to draw enough current at the lower voltage. Similarily, the arduino might not be able to source enough current.

You’ll need to have the arduino drive a transistor or something similar, switching the 12v. And don’t forget the diode! :stuck_out_tongue: