Multi slow speed PWM


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    willem's Avatar
    willem Guest

    Question Multi slow speed PWM

    Dear readers,
    I wonder if it's possible within Darrel Taylor's very nice program Multi_SPWM to set the PWM value more accurate, let's say by using a 10 bit value.
    Because there is quite a lot assembly code I didn't manage to find out myself..
    Any hint where to modify (if possible at all...) are kindly appreciated!

    Within my application I need to control 5 different LED light sources independent and quite precise. (using the very nice Zetex ZXLD1350 LED driver).

    The PWM frequency has to be 200Hz (5ms period) and the puls widht should be controllable from 0 up to about 1ms in 10us steps. So the current 8 bit PWM value supported by Multi_SPWM.pbp works basicly fine but is not sufficient....
    I'm planning to run on 20MHz PIC16F628..

    TNX for you advice

    Willem

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


    Did you find this post helpful? Yes | No

    Default

    Hi willem,

    That's asking a little too much from a PIC.

    For 200hz, with 10-bit resolution, it would require 204,800 interrupts per second.

    Running at 20mhz, the PIC can execute 5,000,000 instructions per second, which leaves 24 instructions per interrupt. That's not even enough to save/restore the Context for the interrupts, let alone turn things on and off accordingly.

    Sorry!
    <br>
    DT

  3. #3
    willem's Avatar
    willem Guest


    Did you find this post helpful? Yes | No

    Default

    Hi Darrel,
    Great to have your reply that quick!!

    Ok for reaching the limits of the PIC for a 200Hz / 10bit res. PWM.

    If I lower the frequency, this should give some "space"?

    I found some (promising..?) info (see below) concerning the PWM module running in 10 bit resolution and would like to "play around" based on your Multi_SPWM finding out where it "ends".....

    Any suggestions where to start, or is it in your opinion still a too busy task for a PIC and do I have definitively look around for an other solution?

    Again thanks for your advise!!

    Greetings,
    Willem

    ************************************************** ******

    On the 16Cxx parts with built-in PWM generators, how do I use 10-bit resolution instead of eight-bit?
    Think of the PWM as always using 10-bit mode internally, with a period of four times the 8-bit number in the period register, a duty-cycle of four times the 8-bit number in the duty-cycle register plus the two-bit number in CCPx X and CCPxY, and a basic time-unit of Tosc. That is, if you're using a 4 MHz oscillator, with the period register set to 100, the period will be 4 * 100 oscillator periods (4 * 100 * 0.25 microseconds), or 100 microseconds. If the duty-cycle register is set to 25 and CCPxX and CCPxY are both "0", the duty cycle will be 4 * 25 + 0 oscillator periods ([4 * 25 + 0] * 0.25 microseconds), or 25 microseconds.
    CCPxX and CCPxY contain the two lowest-order bits of the 10-bit duty-cycle register. When you use "8-bit" mode, you're just setting those two low-order bits to "00", which effectively sets the PWM duty cycle to four times the number in the duty-cycle register. To use 10-bit mode, just put the low 2 bits of your desired duty-cycle in CCPxX and CCPxY, with the upper eight bits in the duty-cycle register.
    ************************************************** *****

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


    Did you find this post helpful? Yes | No

    Default

    Sure, you could use the CCP modules. But you'd need to run the pic at 4mhz to get it down to a minimum frequency of 245hz. And then you would only have 2 channels. So it would take 3 PICs to get all 5 channels.

    You could use 12F683's that have one CCP module each. Used along with timer1 they can produce 16-bit PWM. But it would take 5 - 12F683's to get your required 5 PWM's.

    You might take a look at the PIC18F4331.

    It has 4-14bit pwm's and 2 normal CCP modules. The chip is supported by PBP, but the 14-bit PWM modules are not. So you would need to manipulate the registers manualy. But at least you could get all 5 PWM's from the same chip.

    DT

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


    Did you find this post helpful? Yes | No

    Default

    Another good chip is the 18F6720 which has 5 CCP modules

    DT

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Darrel.. FYI, Microchip says...Please consider using device PIC18F6722

    Nice PIC so far... probably enough to fade 5 leds and 2-3 other task
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Multi Slow speed PWM and Instant Interrupts
    By DaveC3 in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 2nd November 2010, 12:50
  2. Variable PWM PIC18F2431
    By trr1985 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 12th June 2009, 06:03
  3. 16-48 pin Multi slow PWM
    By krohtech in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 28th March 2009, 03:28
  4. DT's Slow PWM
    By fbraun in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 27th June 2008, 15:50
  5. Replies: 14
    Last Post: - 26th September 2007, 05:41

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