Blog

Hall effect controlled CDROM draw

Feb 17, 2009
Category:Arduino Electronics 

The next thing I wanted to try doing with my Aruino was driving some motors. I have got loads of old CD/DVD drives that I don't use any more and thought this would be an ideal source of motors.

The motor on its own worked reasonably well connected straight between an output pin and ground, however it wasn't particularly powerful as the output pin can only source a limited current, and I could also only turn it in one direction, without physically swapping the cables over. After a bit of research and discovered what was required to control the DC motor in both directions, and this is called a h-bridge.

I found this this schematic for a basic h-bridge made from 4 transistors. The instructions seemed pretty specific as to what transistors to use, and also showed the use of 2 NPN and 2 PNP type transistors in the diagram. I can't remember the difference between NPN and PNP, but I will be looking it up shortly, however I assumed the difference was big enough to require the use of both types to build an h-bridge.

I only had a few NPN transistors (BC109's & BC107's) available and decided to see if it would work using them, and it did, with very pleasing results. So it seems I got lucky, or it doesn't really matter what sort of transistors you use! Please let me know if you know either way ;)

An h-bridge is also available in IC form, surprisingly known as a motor driver or steper motor driver. I have ordered a L293D driver chip, that can either drive a single stepper motor, or act as a dual h-bridge and drive two DC motors.

Next I needed an input to use to decide when and in which direction to turn the motor, I decided to try out one of my new hall effect sensors and make the tray move in or out to maintain a set distance between the sensor and a magnet. The wiring of this was relatively simple, and is shown below. The Arduino code is slightly more complicated, and quite a mess at the moment to be honest, but it works. As always just give me a shout if you want to see a code behind it, hopefully I will have tidied it up a bit by then!

Image

NOTE: I think I am probably missing some flyback diodes from this circuit, but I am unsure as to where exactly to fit them, and haven't really given it much thought as nothing has blown up! (Not yet anyway!)

--- EDIT ---

Image


Right, this article shows where the diodes should go, and also looks like an excellent introduction to h-bridges. I believe most driver IC chips would have the flyback diodes built in, so again the preferred solution should you have one to hand.

Here is the latest circuit with diodes included.


Comments