Microcontroller to control 12VDC motor via PWM

Discussion in 'Embedded Systems and Microcontrollers' started by Hurdy, Mar 18, 2007.

  1. Hurdy

    Thread Starter Senior Member

    Feb 27, 2006
    137
    0
    Hi everyone,

    I am in need of some advice on how to design a circuit to control a 12VDC motor with the use of PWM from a microcontroller.

    Basically I have a Philips (now NXP) LPC2129 and a 12VDC motor. What kind of circuitry do I need from my microcontrollers PWM output that will allow me to supply 12VDC and the necessary current to my motor?

    Would I use a high power transistor with a low base switching voltage?
    If anyone has any kind of circuit diagram for achieving this, or even a link to a diagram I would be most grateful.

    Thank you for your time,

    Rob
     
  2. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    Assuming you intend to run the motor in both directions you will need to employ an H-bridge. The H-bridge in turn will require a buffer and level shifter between each of its four legs and the four digital control lines.

    You can use two of the PWM outputs to drive the two lower legs of the h-bridge driver.

    The upper legs can be driven by simple high/low logic controls.

    The H-bridge would need to be constructed using high power mosfet. The two upper legs would use p-channel enhancement mosfets and the two lower legs would use n-channel enhancement mosfets.

    hgmjr
     
  3. Hurdy

    Thread Starter Senior Member

    Feb 27, 2006
    137
    0
    Thank you for your response hgmjr.
    Sorry I should have specified this. I only require the motor to be controlled in 1 single direction.

    From the diagram I have attached, I take it that for a single direction control I should only use Q1, Q3 and D1, D3.

    [​IMG]
     
  4. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    If you only need to drive the motor in one direction then the use of an h-bridge, while it would work, would be overkill.

    hgmjr
     
  5. Hurdy

    Thread Starter Senior Member

    Feb 27, 2006
    137
    0
    Hmmm this link is also interesting.
    Instead of using using up 4 outputs of my microcontroller, I can use some logic to reduce it to 2 outputs only using up 1 PWM.

    [​IMG]

    Though a draw back to this is it increases my circuit size and cost.
    Worth thinking about though.
     
  6. Hurdy

    Thread Starter Senior Member

    Feb 27, 2006
    137
    0
    So you're saying just use a MOSFET straight from my PWM, wire it straight to the motor with a diode for back current protection from the motors coil and directly ground the other side of the motor?

    The H-bridge may be useful.

    You see, I am doing a uni project where we have to design & construct an electric scooter control console as a group project. To my knowledge scooters do not reverse, I may be wrong though. Even if they don't, it could be a nice piece to include into our design to maybe score a few extra marks for functionality.
     
  7. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    You can use the extra logic as you have mentioned to conserve on digital IO. I looked at the datasheet for the micro you are using and I noticed that there was quite a few digital IO lines so I concluded that spending four IO lines was not a strain on your hardware.

    One thing that you will need to consider if you decide to move forward with the h-bridge is the need for a "deadtime" control. This deadtime is needed to prevent the condition in which the upper leg and the lower leg on the samea side of the h-bridge are both on at the same time. As you might imagine, this condition will lead to high current draw from your power source as well as the potential for damage to the devices themselves.

    The use of the four IO lines means that you will have software control over this deadtime interval. You will be able to shut both of the upper legs off for a very brief moment before you then turn on the upper leg that corresponds to the direction in which you want the motor to turn.

    hgmjr
     
  8. Hurdy

    Thread Starter Senior Member

    Feb 27, 2006
    137
    0
    Ah good point hgmjr. I didn't realise about that. I think if I decide to go for the H-bridge, I will control it fully from the microcontroller like you said, I can then control the 'deadtime' with software for ease of implementation.

    Thank you for the excellent advice, it is very much appreciated.

    Rob
     
  9. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    We are here to help you as you progress through the remainder of your project.

    Please be sure to return with any questions as you develop your design.

    Please include a schematic of any circuits that you are having a problem with so that we can assist you more quickly.

    Good Luck,
    hgmjr
     
  10. Hurdy

    Thread Starter Senior Member

    Feb 27, 2006
    137
    0
    Thank you, I will be sure to do so :).

    Rob
     
Loading...