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


Closed Thread
Results 1 to 28 of 28

Hybrid View

  1. #1
    Join Date
    Aug 2007
    Posts
    15


    Did you find this post helpful? Yes | No

    Default help with 18f4431 hpwm

    '************************************************* ***************
    '* Name : UNTITLED.BAS *
    '* Author : [select VIEW...EDITOR OPTIONS] *
    '* Notice : Copyright (c) 2008 [select VIEW...EDITOR OPTIONS] *
    '* : All Rights Reserved *
    '* Date : 8/2/2008 *
    '* Version : 1.0 *
    '* Notes : *
    '* : *
    '************************************************* ***************
    ' pwm out
    ansel0=%00000000
    ansel1=%00000000


    portb=%00000000 'set port as output
    trisb=%00000000 'set all portb pins as output

    pr2=155 ' set to get 4khz out
    ccp1con=%0001101 'set duty cycle ccp1con <4:5> bits
    trisc=%00000000 ' make ccp pin output by clearning trisc<2> bit
    t2con =%00000110 'turn on timer2, prescale =16
    ' set trmr2 prescale value and enable timer2 t2con
    pause 1000

    portb.6 = 1 'high output
    portb.7=1 'high output


    pause 2000
    loop:
    hpwm 0,127,10
    hpwm 1,127,100
    hpwm 2,127,10
    hpwm 3,127,10
    hpwm 4,127,100
    hpwm 5,127,10
    pause 1000
    goto loop
    end
    I'm trying to get the pwm to work but the only pin that light a led is RB2( 6 and 7 work)
    Who do I get the rest of them to work?

  2. #2
    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

  3. #3
    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

  4. #4
    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

  5. #5
    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

  6. #6
    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.

  7. #7
    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.

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