PWM using a 16F873


Closed Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Dec 2007
    Location
    Toronto, Ontario
    Posts
    23

    Cool PWM using a 16F873

    Hello,

    I'm trying to drive two small 6v motors and want to be able to control both speed and direction independently. Currently I am running a dual H-bridge (L293) with the '873, but that only gives me direction control using four i/o lines (2 lines per motor,for/rev). Is it possible to drive these same control inputs to the L293 using PWM from the PIC ?

    thanks,

    John.

  2. #2
    Join Date
    Dec 2007
    Location
    Toronto, Ontario
    Posts
    23


    Did you find this post helpful? Yes | No

    Smile

    hmmmm......

    Does anybody have any experience with this type of motor control ? Any info would be appreciated....

    John.

  3. #3
    Join Date
    Dec 2007
    Location
    Toronto, Ontario
    Posts
    23


    Did you find this post helpful? Yes | No

    Default

    Hi again(to myself),

    I must have mistaken this forum for a place where answers are pleantifull OR this is mostly a programming based group. BUT for anyone who is interested in what I was trying to accomplish, it is possible to drive the L293 enable pins with PWM from a pic. I kinda hoped that some guru could have helped me regarding PWM frequencies and possible code EXAMPLES as I'm definately not the first to do this.
    As they say, it's easy if ya know how !

    John.

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Don't forget that you are asking Hardware related questions on a forum dedicated to a Programming Language.

    I'm sure there are people here that can answer the question, but many of them only check the forum every few days or weeks.

    It's only been 5+ hours since the first post.

    Me, I'm a software guy. Can't help.
    DT

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    I'm sure there are people here that can answer the question, but many of them only check the forum every few days or weeks.
    Not to mention that there are a lot of time zones and not everybody is on your sleep schedule.

    But like DT said, there's a lot of people around who are good with PWM'ing 2 motors bidirectionally, which without some sort of method of counting rev's or speed, good luck trying to get the thing to run straight.

    The big thing I can suggest... Get yourself 4 LEDs, wire them up in 2 pairs of opposing parallel before getting PIC driven MOSFETs connected to motors.
    That way you can play with PWM (no matter what your method, software, hardware, off-chip driven, etc), watching LED brightness, and the opposing parallel pairs of LEDs will give you a visual indication of both direction and relative speed, with practically no chance of blowing up a PIC.

  6. #6
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    Gixxer, I built this circuit some years ago. There are 2 such circuits. Each has a pwm channel connected to the "F" terminal and a couple of direction bits associated with it. The reason for 2 direction bits? They set the output to either battery or to ground state. for braking. This circuit is used with a 16F876 which has 2 pwm circuits available. The completed circuit runs 2 motors, forward and reverse with 10 bit pwm values.

    Dave Purola,
    N8NTA
    Attached Images Attached Images

  7. #7
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Gixxer View Post
    Is it possible to drive these same control inputs to the L293 using PWM from the PIC ?
    John,

    I do this all the time with the L293 - what you want to do is exactly what you are doing for direction control except use PWM on the enable lines (rather than leaving them on).

    Is that enough to get you going? (I expect to hear back from you in the next 10 minutes - we have a schedule to keep ... its 5AM here)
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  8. #8
    Join Date
    Dec 2007
    Location
    Toronto, Ontario
    Posts
    23


    Did you find this post helpful? Yes | No

    Talking

    hahaha,

    That actually cracked me up Paul. Thanks alot guys for the replies. Yesterday I was at a point in my project that you have all been I'm sure-STUCK. So you say to drive the enable pins with the PWM and continue to use my existing four control lines for direction? In other words six i/o are required from the pic. Seems like alot of io to use on motor control only, but I should be able to manage. I'm building a small tracked robot with half duplex rf tranceivers for telemetry and radio control-all digital R/C of course. It's such an involved project and I've had to break it up into sections and learn how to build it. Slowly but surely!
    So does anyone have a small snippet PWM code that may get me going ?

    thanks,

    John.

  9. #9
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Default

    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  10. #10
    Join Date
    Dec 2007
    Location
    Toronto, Ontario
    Posts
    23


    Did you find this post helpful? Yes | No

    Default

    Thanks again Paul, that appears to be exactly what I need to get started on this. I'll give it a try when I get home tomorrow and let ya know.

    John.

Similar Threads

  1. Half-bridge PWM with a 16F684 ?
    By Byte_Butcher in forum General
    Replies: 7
    Last Post: - 17th January 2010, 22:18
  2. Variable PWM PIC18F2431
    By trr1985 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 12th June 2009, 06:03
  3. PWM: Vernacular/Function (Newbee)
    By TerryN in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd July 2008, 16:58
  4. PWM setting PIC16F887
    By Gevo in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 12th June 2008, 07:24
  5. Tidying Up PWM Routine
    By Tissy in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 21st February 2005, 00:26

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts