Low frequency PWM


Closed Thread
Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: Low frequency PWM

    I can tolerate variation in the absolute frequency (say 112 +/- 12 or even a little more) as long as the on / off ratio is stable. I have flexibility in the resolution too - I've been targetting 11 (ish) ratio positions including 0%, 10%, 20%, ... 100%. I need full off and full on.

    Polling TMR2 is an interesting idea I have not explored - I'll play with that for a bit and see where I get to. Thanks for a new lead!

  2. #2
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Low frequency PWM

    Using the polling method the "stability" will be dependent on the duration of the main loop.

    Absolute on and off is easy, set or clear the output

    if you use a PR value so TMR2IF sets 10 times per period, you can use a counter to decide when to turn the output on/off

    Again accuracy will depend on loop duration, but running at 8Mhz will more then likely be plenty fast enough to give you a barely noticable error.

    Ok some math and assumptions:

    lets assume you have 1000 ASM lines to process for each loop. That would take .5msec.
    If you output is 100 Hz, thats 10 msec. So with these numbers, I guess you could be off by 5% on the duty cycle. Hmmm... Not so good. But 1000 lines is HUGE. Also you could check the count in 5 evenly spaced places throughout your main, then the possible error would only be 1%. In case I have stated this wrong, I mean to say 10% duty could be 11%, or 90% could be 91%. So I guess I don't mean duty cycle % error, I really mean the time it takes to get to the next counter check.

    Hopefully I have not confused you or anyone else too badly.

    If you need utmost accuracy, use interupts
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

Members who have read this thread : 1

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