« Your one and only Plushy | Main | NYC Photobloggers »

November 02, 2005

Motor Lab

Controlling high-current devices from a microcontroller
All about motors
DC Motors
Stepper Motors

The Lab.
DC Motor Control Using an H-Bridge


More of my notes on motors, relay, transistors.

To reverse a DC motor, you need to be able to reverse the direction of the current in the motor. The easiest way to do this is using an H-bridge circuit. With any H-bridge, you will have certain elements:

  • Pins for logic input

  • Pins for Supply voltage

  • Pins for Logic voltage

  • Pins for Supply output

  • Pins for ground

  • I have to admit, I thought I'd have a pretty solid idea of running the motor since i had experienc with making our mid-term that used fans. WRONG. The H-bridge was hard to control as well. The circuit was correct but the motor would not change directions. I hooked up all the wires according to the schematic, programmed and found out the code on Tom's site is a little from from the wiring diamgram. Here's the code that I used for my circuit.Download file
    I also put 2 different LEDs on the pins that connected to the H bridge to confirm that the pins were doing the HIGH and LOW accordingly. However, I saw the LEDs blinking at times and they did not alternate as they were supposed to...

    After reading the lab more carefully, I found out that most motors take a great deal more current than a microprocessor, and hence, need their own supply. I attached a new breadboard for the motor to get its power from, sharing the common ground with the microcontroller.

    IMG_0167.JPG
    IMG_0168.JPG

    Using the transistor was little more easy. Just that the connections got a bit confusing. The important part is that the motor has its external power going to its power pin and that they all share a common ground. The diode should have its white stripe pointing towards the collector.

    IMG_0171.JPG
    IMG_0170.JPG
    IMG_0174.JPG

    I also tried using the pot to control the speed of the motor, instead of the "enable" connection that goes into the first pin of the H-bridge. I don't know if this is possible. Or even safe but the motor did slow down and speed up accordingly. Was I just lucky?

    IMG_0169.JPG


    Posted by min at November 2, 2005 10:09 PM

    Comments