Sunday, 15 April 2012

Big Fat Motors!

Well, I've been waiting for ages for some sabre tooth motor controllers and they've still not arrived in the post, but I do have some very chunky motors sitting here:

Chunky Motor
Rather than wait for ages for them, I've decided to build my own very simple motor controllers with a bit of help from this tutorial. After experimenting with the example for a bit I end up with this circuit to drive my 2 motors:

Arduino controlling 2 motors, powered off 4.5v battery.
Different power sources (Arduino and battery) are connected to same GND

If you ignore the capacitors and diodes for the moment, all you have here is 2 motors connected to a 4.5v battery via the 2N7052 transistors. These transistors only allow current to flow if they receive a signal from the Arduino.via one of the GPIO Pins (with a couple of 10k resistors to minimize current flow).

The capacitors and diodes are there to protect the circuit against some annoying properties of motors. The spinning motor creates noise, and (as I understand it), the capacitor absorbs spikes by acting as a cushion, and the diode prevents current reversal by acting as a valve. That's my understanding though - might find out I'm wrong a few posts later :)

Here's my circuitry as it stands with the motors now hooked up to the rest of the circuitry:

Motors connected to arduino via motor controllers

This close up shows 1 of the motor controllers on the bread board

Motor Controller Closeup
Only tiny prob with this photo is that I originally used the wrong capacitor, so you should see a much smaller (probably rectangular) one there. Things all worked though as that circuit is just for protection really - I should think the circuit would run with neither, it just wouldn't live as long!

I now send alternate HIGH/LOW signals to the motor pins once per second and watch as the motors turn on and off, however this isn't too interesting, so I add some wheels to the motors - big, chunky wheels :)

I get the wheels turning alternately and it looks great and Dave sees it and makes an impressed noise which is always a good sign. Next I experiment with getting the left one to run more slowly by sending it a square wave (i.e. pulses of current) rather than a solid signal. This definitely works, but as I'm running the motors at significantly below power already (they're 12-18V motors), any significant drop in current just stops them running. This technique'll be much more effective when there's a higher voltage going in.

As a quick test to prove the point of the transistors, I hook up an ammeter - first in series with the Arduino and transistor, then later in series with the motor and battery. Ideally what we should see is the Arduino having to provide a very low current in order to allow a lot of current to flow from battery to motor.

On the left you see the reading coming out of the Ardiuno - a tiny 0.35mA - well within Arduino operating range. However on the right you see our 4.5V batteries pumping out 156mA of current, which will probably be closer to 1A by the time we've got full power batteries and proper motor controllers in - I'm starting to see why they recommend cut off switches!

So that's the lot for motors - all fun and games. Here's a final video of it in action responding to sensor input and turning motors. Blogger seems to have been having issues with it lately, so if the vid doesn't work check it out on you tube here:

Blog is almost caught up with real world now! Next one will be about my prototype dual axis sensor platform


No comments:

Post a Comment