Software PWM Problems


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    If you *REALLY* need smooth PWM out of your chip, it is possible.

    One approach would be to set up a hardware timer to give you a constant period (say 100uSec), and then use an interleave-type A/D routine. You could do the conversions (and the math) on consecutive timer rollovers.

    Using this technique you could get 8 bits of resolution and 0 to 100% duty cycle at 40Hz. Not great, but possibly usable.
    Charles Linquist

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default

    Hi,
    (OK, just an idea here - worth a try)
    With the AD result set to 8 bits your result will vary from 0 to 255. Try changing the line:
    Code:
    i = 256 - adval
    to
    Code:
    i = 255 - adval
    and see what happends. Even at full scale (adval=255) your i variable will be 10 if you subtract adval from 256. You will probably still get short glitches but hopefully you will end up closer to what you want.

    /Henrik Olsson.

Similar Threads

  1. Software PWM
    By muqasim in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 18th December 2009, 14:21
  2. Software PWM using Timer1
    By muqasim in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 18th December 2009, 11:49
  3. Variable PWM PIC18F2431
    By trr1985 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 12th June 2009, 06:03
  4. 2 PWM in 16F690 problems
    By ciendavila in forum mel PIC BASIC
    Replies: 9
    Last Post: - 27th April 2008, 09:03
  5. Variable PWM on 2 Channels using software.
    By Tissy in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 23rd September 2006, 01:34

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