using the pwm's in pic18f2431-2331-4331-4431


Closed Thread
Results 1 to 28 of 28

Hybrid View

  1. #1
    Join Date
    May 2007
    Location
    Area 71
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Read Darrel comment above.
    You have to setup manually, or you can use 2 CCP HPWM only with PBP

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


    Did you find this post helpful? Yes | No

    Default

    On these chips, I defer to Bruce's experience. (See post #4)

    Bruce,

    Is there really 2 normal CCP's and 4 other PWM's on these chips? Total of 6?
    Or am I looking at the datasheet wrong?
    The GIF image in post #4 shows 6 traces, but the program doesn't ues CCPCON?.

    Haven't used one yet.
    <br>
    DT

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    DT,

    The 28-pin version has 6 power control pwm outputs, and 2 standard CCP pwm outputs
    for a total of 8. The 40-pin has 8 power control pwm outputs and the 2 standard CCP.

    The only thing I don't like is they use the CCP1 & CCP2 pwm outputs as power control
    pwm fault inputs.

    You should grab a couple samples. The motion feedback module on these is awesome.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

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


    Did you find this post helpful? Yes | No

    Default

    WOW, that's a tough read.

    But after a few hrs in the datasheet. Yeah, these are cool.

    Got the (IC) Input Capture block: Very cool.
    The (QEI) Quadrature Encoder Interface: OK sorta cool.
    And up to 4 14-bit PWM's. (4 additional complimentary outputs) Not usable with CCP's at the same time.
    Not as cool as I expected.

    Still worth further investigation.
    Samples on order. Thanks Bruce.
    <br>
    DT

  5. #5
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default

    How about a 28-pin PIC24FJxxGA002. 5 independent input capture AND 5 independent PWM's/OC (up to 16-bit resolution and 500kHZ). About $2 each (depending on flash from 16-64kB, 4kB or 8kB RAM). Plus lots of other stuff like 2 UART's, built-in RTCC, 2 SPI, 2 I2C, etc. Plus you can select which pins you want to use for most of the peripherals.

  6. #6
    Join Date
    Aug 2007
    Posts
    15


    Did you find this post helpful? Yes | No

    Default mystified

    Thanks did not know that ccp and pwm0-5 are not the same pins that helped now how about setuo for timer 2.

  7. #7
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    If you're using HPWM you don't need to mess with Timer2. It's automatically handled
    for you.

    If you plan to setup hardware PWM manually, these calcs should help.
    Code:
    PR2=(Fosc/(4*PS*Freq))-1
    TMR2 Prescaler = 1 PR2 = (8MHz/(4*1*12,000)) = (8MHz/48,000)-1 PR2 = 165.666
    TMR2 Prescaler = 4 PR2 = (8MHz/(4*4*12,000)) = (8MHz/192,000)-1 PR2 = 40.666
    TMR2 Prescaler = 16 PR2 = (8MHz/(4*16*12,000))-1 = (8MHz/768,000))-1 PR2 = 9.416
    
    CCPR1L:CCP1CON<5:4>=(PR2+1)*4*Duty%
    (165+1)*4*0.5 = 332
    (40+1)*4*0.5 = 82
    (9+1)*4*0.5 = 20
    
    To load the duty cycle registers just place the value calculated in a word, and
    do something like this;
    
    Duty = 332              ' Roughly 50% duty cycle
    CCP1CON.4 = Duty.0	' Setup 10-bit duty cycle as
    CCP1CON.5 = Duty.1	' a 10-bit word
    CCPR1L = Duty >> 2
    Search here for HPWM and you'll find a boat-load more examples.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Members who have read this thread : 2

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