DC Motor Control - How and what

Discussion in 'Embedded Systems and Microcontrollers' started by mwh624, Mar 29, 2011.

  1. mwh624

    Thread Starter New Member

    Nov 6, 2009
    28
    0
    Hi all,
    Here's my situation.
    In it's simplest form I am wanting to drive a 12V DC gear motor that will pull 1.5-2 amps. Once I hit the "on" button, I want the motor to run for 5 sec....stop for 5 sec....reverse for 5 sec.....stop for 5 sec... and repeat (5 sec is somewhat arbitrary).

    From browsing the forum for the past day, this seams like it shouldn't be a problem, however, it also seems like there are a million ways to do it. There is just so much info out there, I'm kind of getting lost.

    From what I've gathered I need 2 signals, call them A & B. I should be able to set things up to where if A=High & B=High, motor turns clockwise. A=High &B=Low, motor turns left and A=Low & B=Low motor off.

    Now here is where my total lack of product knowledge comes in. A popular option seems to be a PIC and an H-Bridge. Using google, I find H-Bridge Chips and I like the idea of using as many integrated parts as possible, i.e. use an H-Bridge chip rather than making the circuit if possible. However, I'm not sure if they make heavy duty enough chips to drive a motor that will pull 1.5-2 Amps.

    So this is where I ask for advice. I'm planning on getting a PICkit2 or 3 for the programming. With that knowledge, what micro controller would you start with, and how would you build the system. Heck, maybe I'm over complicating things and I can get away with a simple logic circuit, I just don't know enough about what's out there.

    Thanks for taking the time to read, I appreciate your help.

    -Matt
     
  2. mwh624

    Thread Starter New Member

    Nov 6, 2009
    28
    0
    just to note,
    I do have some experience in bread boarding and have done come C programming
     
  3. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    It can be done easily enough with a 555 timer and a binary counter chip. The first column is direction and the second is the enable of the H-Bridge.
    I think 4 bit binary counters are common so you would use the 3rd bit (not shown) to reset the sequence.
    I'd do it with a PIC but just because I already have the programmer.
    00
    01 =1
    10 =2
    11 =3
     
  4. mwh624

    Thread Starter New Member

    Nov 6, 2009
    28
    0
    thanks for the reply.
    I'll try to see what I can find on 555 timers.
    Thanks
     
  5. mjhilger

    Member

    Feb 28, 2011
    119
    16
    You can use a 555, but a microcontroller will provide you ultimate flexibility for change in the future. And, while it is way overkill, I really like the PIC18xxx controllers. A PIC18f4525-I/P (dip 40 pin)will cost you around $5 from newark or one of the other suppliers. It has a built in OSC so no crystal required. Once programmed the only thing it needs is power. You can use an H bridge if you want, but you can get away with a relay (DPDT) which reverses polarity of the motor connections and a HEXFET to switch power. You'll need a small transistor to drive the relay coil 2n2222, 2n7000, or another HEXFET and a reverse diode across the coil to limit the voltage spike when you turn off the current to the relay coil. By using a HEXFET to control the power, you could eventually PWM the power and control the motor speed (you will need to choose the right pin off the micro to be able to do this in the future). So with this setup I could see your total parts list being
    power supply
    micro
    relay
    HEXFET IRF530 for power
    2n7000 (fet) or 2n2222 (bipolar transistor) for relay
    1n4001 or 1n4004 for relay
    bypass cap for micro power
    pushbutton and resistor
    depending on your power supply (probably good to have motor on different supply) you might need a voltage regulator or zener
    With minor programming, you can do your 5 second or 5 day, lots of possibilities.

    IDE and C compiler for project are available free from microchip site
     
  6. mwh624

    Thread Starter New Member

    Nov 6, 2009
    28
    0
    Thanks mjhilger for the suggestion.

    As far as this HEXFET IRF530 goes. Is this similar to just a simple SPST relay?

    The signal from my controller to the HEXFET would decide whether the motor is on or off and the signal to the DPDT relay determines clockwise or counter clockwise rotation. Am I following correctly?

    Thanks for the help
     
  7. mjhilger

    Member

    Feb 28, 2011
    119
    16
    Yes, you have it correct. The DPDT relay, you can use the commons in each pole either for power or motor connection. Lets say you connect +power to Com pole 1 and -power to com pole 2. You would cross connect NC of pole 1 to NO of pole 2 - this would be the + to your motor (we will assume that normal +and - is cw). And NC of pole 2 is connected to NO of pole 1 which would connect to your motor -. So relay disengaged is CW, engaged is CCW. And if you use the HEXFET between the relay and ground; Drain to COM pole 2 and Source - ground (you of course would not connect a wire from - power to the relay in this case), then a digital signal to the gate of the HEXFET and you are off. The digital signal is not a large enough voltage to fully turn on the HEXFET, but depending on your motor, it will conduct with an approximate resistance of .4 ohms or so. So if your motor requirements are not large it will work great. And later, when you want, you set up the PWM (driving the HEXFET gate) and you can modulate the duty cycle to slow the motor down. But, I think you get the idea. You could add a transistor between the micro and the HEXFET gate to translate the voltage if yo want to fully turn on the transistor. If you motor is small, it really will not make a difference. Either way, you should calculate (or measure) the voltage drop and current through the thing to determine if you need a heat sink (1W or less, don't worry). It is probably a little more effort than using the 555's, but the trade off in function and experience would be well worth it, if you have the time.
    I was looking at the Pickit3 and it describes that it can program all of the PIC's you would be interested in, but looks like you need a board with the socket, I didn't see the one with the 40 pin ZIF. But I didn't spend too long there. I have a couple of different programmers, one is the MACH X from CCS ($200). I bought the CCS C complier back in 98' or so. Then I also have a BP Microsystems programmer that can program them, probably not what you want ($2000), it is a commercial programmer can program many, many things.

    Using a PIC would be a lot more fun, if you are looking at modifying it and as part of a learning experience. Either way, have fun.
     
  8. mjhilger

    Member

    Feb 28, 2011
    119
    16
    Like this:
     
  9. mwh624

    Thread Starter New Member

    Nov 6, 2009
    28
    0
    many thanks for your input.
    I think I need to go spend a few hours on the micro site to learn what controller will work well and be easy to program.

    One quick question. Instead of an IRF530, could I just use an additional relay?
     
  10. mjhilger

    Member

    Feb 28, 2011
    119
    16
    You sure can use a relay in place of the IRF530N. But I'm not sure it gains you anything; well I take that back, it will provide full power to the motor. I'd be curious to see if it made much difference in the motor torque or speed. Also, sorry, the ones I use are IRL530N (logic level switching) http://www.irf.com/product-info/datasheets/data/irl530n.pdf . Sorry for the mixup, they are pretty cheap (Newark $1.81), but so is a relay. If you are going to use a second relay, SGTWookie, had a good drawing using 2 relays to power motors for an AUV in another thread. Those relays were SPDT might save you a couple of cents if you want to go that way. You will need a transistor to energize the relay either way 2N2222 or similar or I really like the 2N7000 (FET), no base loading.
     
Loading...