Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Microcontroller for DC Motor Controller

  1. Feb 11, 2009 #1
    Hello, I am designing and eventually constructing a high current DC motor controller to be used in an electric vehicle for a senior design class. Right now I am at the stage of selecting the PWM source for the MOSFET drivers. A team member wants to use dedicated PWM TTL chips, I wish to use a microcontroller. Although a microcontroller is more costly and adds complexity, it has more capabilities.

    I am hoping there is someone here who can help me out with some pros and cons of both, which you would use or have used etc.
  2. jcsd
  3. Feb 11, 2009 #2
    What are the features you think you'll need or want with your motor controller?
  4. Feb 11, 2009 #3


    User Avatar
    Science Advisor

    Well, how would you generate and vary the PWM in the first place? Input with pre-generated PWM (from a microcontroller or PC)? Drive with digital input? Serial control? Analog comparator using a ramp? IF YOU HAVE EXPERIENCE with the micro in question, it's often the easiest way to go. May even be easier than any of the other methods if you have no experience with either of these routes.
  5. Feb 11, 2009 #4
    I would go with a microcontroller. For the extra $2 its more than worth it over using 555/or similar timers with the analog circuitry to control them. Most micros have dedicated hardware routines for running for outputting PWMs which can be very easily and directly controlled which is what you want. I take it your going to be going with the classic H-bridge design?
  6. Feb 11, 2009 #5
    I will be using an H bridge design. I am looking for the basics: forward, reverse, regen braking in both directions, and speed and torque measurement to be outputted to a display. I was thinking of using a dsPIC, but I want something with higher level programming, but I am not sure what is out there. MSP430? something C-like.

    The dsPIC offers 4 or 8 PWM outputs, duty cycle controlled by comparing a reference voltage.
  7. Feb 11, 2009 #6


    User Avatar
    Science Advisor

    There are C compilers available for the entire Microchip line. But they were designed by EEs to be programmed by EEs (i.e. in assembly) Their architecture is not really meant for high-level programming (this might be different for PIC32, but I'm less familiar with their offerings these days than I used to be). Most of the C compilers cost a few hundred bucks, but the official Microchip one can be "student evaluated" with optimizations that expire after three or so months. I don't believe that any of these are perfectly ANSI C compliant.

    On the other hand, ATMEL was designed from the get-go to be a high-level language microcontroller (lots of instructions, memory access modes, deep stack, etc.) The (arguably) best compiler happens to be the free implementation of GCC (WinAVR). Programming it is a bit harder, but the plain-jane programmer (the AVR-ISP mkii) is pretty cheap, even if it doesn't give emulation / stepping functionality, and requires the use of the ISP port.

    Different beasts, but low-level work seems to be less and less popular these days (probably because everything is so fast, anyways).
  8. Feb 12, 2009 #7
    I appreciate all of the replies. I am going to check out the AVR. It sounds like its right up my alley.
  9. Feb 12, 2009 #8
    Have you considered things like ramp up (would it be okay if someone goes from 0 to full speed in an instant?), torque limiting (allow fast acceleration only if a preset torque isn't exceeded.) and stall protection (what would you do if the motor stalled?).

    Don't forget that all of the functions you mention and that I mentioned can be done with op amps, in fact that's the way it was done before microcomputers. Believe it or not, some of these things are actually more easily done analog.
  10. Feb 12, 2009 #9
    I am interested in ramp acceleration. As for torque limiting and stall protection, those are things I am unfamiliar with and haven't considered. This controller must have full protection from almost everything that can happen when driving an electric vehicle, so I would like to select one that isn't going to come up short down the road.
  11. Feb 12, 2009 #10
    Stall protection can be solved by using a fuse in series with your motor. Torque limiting is a very complex thing to do and I suggest that you don't deal with it.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook