How do folks achieve 8 bit hpwm at low hpwm frequency?


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2009
    Posts
    653

    Default How do folks achieve 8 bit hpwm at low hpwm frequency?

    So I've put myself in a bit of a corner...I've writen a moster program that needs 8 pit pwm.

    My PIC oscillator is running at 4Mhz, so a PR2 value of 63 yields about pwm 255 values @15.7 khz....all was well until I started switching a P-chan mosfet via an n chan mosfet (I really need a hi side load switch but I don't have any & it would need a pcb rejig even if I did!), so what I'm doing is this...

    (yes I know the symbols are trannies...I was lazy - since the package pins are the same as my sot23 fets so just used them on the schematic!)


    Trouble is that 22k resistor combined with the total source/drain capacitance of the first fet Q7 ....it is essentially screwing up the square wave signal as it appears on the second fet gate. (I scoped the gate of the first fet - lovely clean square wave - scoped the gate of the second fet - it has a typical CR rise slope thing going on - it's not square anymore)...this is really screwing up the response of my load (LEDs)

    Lowering the value of the 22k resistor to 1K all but negates the problem, but 1k is lower than I really wanted to go...so my other option is to lower the hpwm frequency. But mucking about with all with Mister e's calc shows that as I take the hpwm base frequency down the hpwm resolution goes up...I don't want any more than 256 bits resolution - so what to do?

    I guess I could go with 512 bits of hpwm resolution, then multiply everything in my code by two to make it correlate with the 512 bits of hpwm (but I've 8 bit lookup tables in my code to get the leds to fade smoothly...pretty sure going this way would screw that aspect up!).

    I guess I could take the PIC oscillator down below 4Mhz too (but I've some pretty time intensive things happening in my program - not sure this would be a wise move!)

    Anyone got other ideas?
    Last edited by HankMcSpank; - 23rd October 2011 at 11:44.

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


    Did you find this post helpful? Yes | No

    Default Re: How do folks achieve 8 bit hpwm at low hpwm frequency?

    Hi Hank,
    What kind of frequency range are you looking for? You said you were doing 15kHz, how low do want to go?

    Here's two settings (~1000Hz and ~4000Hz) I arrived at which, according to PICMultiCalc should give you 8bit resolution:
    Name:  PWM.jpg
Views: 586
Size:  122.5 KB

    /Henrik.

  3. #3
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: How do folks achieve 8 bit hpwm at low hpwm frequency?

    Henrik,

    Excellent input .....I'm normally fixated on squeezing the highest frequency out of HPWM to put it above hearing range, but with this circuit this doesn't matter ...and I guess I missed the obvious in the calculator... 976Hz ought to be fine!

    You've likely saved the day!

  4. #4
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: How do folks achieve 8 bit hpwm at low hpwm frequency?

    here's the 2nd fet gate voltage now...



    Not entirely straight leading edge, but the CR slope is to all intents and purposes is all but eradicated - and it's certainly good enough for Hank!

    Thanks Henrik!
    Last edited by HankMcSpank; - 23rd October 2011 at 12:55.

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