#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    2
    Rep Power
    0

    PWM in microchip C


    Hi, I'm currently trying to control the speed of DC motors using PWM from PIC18F8722 using microchip C. I'm completely lost on this and could anyone explain how this can be done? If you could put an example program that would be much appreciated! The clock frequency is 10Mhz if that helps!
  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,413
    Rep Power
    1871
    Well this took about 5 seconds to find.
    http://www.microchip.com/pagehandler...ol/motortypes/
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    2
    Rep Power
    0
    Thanks mate! But do you know where I can get details on the programming part of it?
  6. #4
  7. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,413
    Rep Power
    1871
    > Yesterday, 06:23 PM salem
    > Yesterday, 08:19 PM Chuck123
    Mmm, it took less than 2 hours for you to reply.

    I wonder how long you actually took to hit the reply with your Pavlovian "feed me" response.

    Because if you're too lazy to even manage to see "Brushed DC Motor Control Application Notes and Software" on the link I posted, let alone click on it and do some investigation for yourself, then programming is not for you and embedded programming definitely isn't for you.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  8. #5
  9. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,117
    Rep Power
    1803
    The answer to almost any question is already out there, and finding it is generally much more efficient and accurate than asking it.

    In general for the "how do I program the XXX on processor YYY?" kind of question I would Google "YYY XXX application note", or even search Microchip's site directly (although Google is often better at indexing a site than the site itslef).

    In this case:

    "PIC18 PWM application note"

    will get you exactly what you need.


    Remember a few things:

    • The greater the mark:space ratio the faster the motor will run.
    • A brushed DC motor will have a distinct "dead-band" - a M:S ratio below which it will not move, and will just get warm.
    • If the frequency is too low, it will be audible as a hum or whine when applied to the motor.
    • A brushed motor is an inductive load, If the frequency is too high you will get little or no power.
    • The higher the frequency the fewer "speed steps" are available.
    • Do not connect the motor directly to the chip!

IMN logo majestic logo threadwatch logo seochat tools logo