Hwpw


+ Reply to Thread
Results 1 to 20 of 20

Thread: Hwpw

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,705


    Did you find this post helpful? Yes | No

    Default Re: Hwpw

    a pic18f26k22 can have 5 different pwm streams with 3 different frequencies all with individual duty cycles, old clunker chips like 16f876a are much less capable of course

    here is 3 streams 3 frequencies
    i find the hpwm command pretty inflexible and seldom use it [the clock defines are not correct in mho] , pwm is not difficult to setup manually



    Code:
    '****************************************************************
    '*  Name    : PWM demo.pbp                                      *
    '*  Author  :  Richard                                          *
    '*  Notice  :                                                   *
    '*          :                                                   *
    '*  Date    : 21/12/2024                                        *
    '*  Version : 1.0                                               *
    '*  Notes   : TMR2 CCP4 10K, TMR4 CCP5 12.5K,  TMR6 CCP1 8K     *
    '*          :18f26k22 @64Mhz                                    *
    '****************************************************************
    
    
    
    
    #CONFIG
      CONFIG  FOSC = INTIO67
      CONFIG  PLLCFG = ON
      CONFIG  PRICLKEN = ON
      CONFIG  FCMEN = OFF
      CONFIG  IESO = OFF
      CONFIG  PWRTEN = ON
      CONFIG  BOREN = SBORDIS
      CONFIG  BORV = 190
      CONFIG  WDTEN = ON
      CONFIG  WDTPS = 32768
      CONFIG  CCP2MX = PORTC1
      CONFIG  PBADEN = OFF
      CONFIG  CCP3MX = PORTB5                                
      CONFIG  T3CMX = PORTC0
      CONFIG  HFOFST = ON
      CONFIG  P2BMX = PORTB5
      CONFIG  MCLRE = EXTMCLR
      CONFIG  STVREN = ON
      CONFIG  LVP = OFF
      CONFIG  XINST = OFF
      CONFIG  DEBUG = OFF
      CONFIG  CP0 = OFF
      CONFIG  CP1 = OFF
      CONFIG  CP2 = OFF
      CONFIG  CP3 = OFF
      CONFIG  CPB = OFF
      CONFIG  CPD = OFF
      CONFIG  WRT0 = OFF
      CONFIG  WRT1 = OFF
      CONFIG  WRT2 = OFF
      CONFIG  WRT3 = OFF
      CONFIG  WRTC = OFF
      CONFIG  WRTB = OFF
      CONFIG  WRTD = OFF
      CONFIG  EBTR0 = OFF
      CONFIG  EBTR1 = OFF
      CONFIG  EBTR2 = OFF
      CONFIG  EBTR3 = OFF
      CONFIG  EBTRB = OFF
    #ENDCONFIG  
        DEFINE OSC 64
        ANSELB=0
        ANSELC=0
        ANSELA=0
        trisa=% 11101111
        trisb=% 11111110
        trisc=% 11111001
        OSCCON=$70
        OSCTUNE.6=1
        
        T2CON=6         ;PRESCALE 16 TMR ON
        T4CON=6         ;PRESCALE 16 TMR ON
        T6CON=6         ;PRESCALE 16 TMR ON
        PR2=$63         ;10 KHZ
        PR4=$4F         ;12.5 KHZ
        PR6=$7C         ;8 KHZ
        CCP4CON = $0C   ;PWM MODE + DUTY LSB 2 BITS
        CCPR4L  = $32   ;DUTY MSB 8 BITS    
        CCP5CON = $0C   ;PWM MODE + DUTY LSB 2 BITS
        CCPR5L  = $27   ;DUTY MSB 8 BITS
        CCP1CON = $0C   ;PWM MODE + DUTY LSB 2 BITS
        CCPR1L  = $3E   ;DUTY MSB 8 BITS    
        CCPTMRS1  = 4   ;TMR2 CCP4, TMR4 CCP5
        CCPTMRS0  = 2   ;TMR6 CCP1 
    
    
    main:
    goto main
    Warning I'm not a teacher

  2. #2
    Join Date
    Aug 2009
    Location
    Paso Robles California
    Posts
    167


    Did you find this post helpful? Yes | No

    Default Re: HWPW


    I ran your program and according to the scope they all are running the same freq. with different pulse width


  3. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    2,705


    Did you find this post helpful? Yes | No

    Default Re: Hwpw

    I ran your program and according to the scope they all are running the same freq. with different pulse width
    not really they all are running the same pulse width with different freq.
    Attached Images Attached Images   
    Warning I'm not a teacher

  4. #4
    Join Date
    Aug 2009
    Location
    Paso Robles California
    Posts
    167


    Did you find this post helpful? Yes | No

    Default Re: Hwpw

    Well, I don't know what to say. I get all the same frequency with different pulse width.
    Even the program shows different pulse width.
    I even went back to the pick basic plus and i'm running for with four different timers, and they all run the same frequency, and if you set it for a different frequency, they shut down pulse width, I can control

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    2,705


    Did you find this post helpful? Yes | No

    Default Re: Hwpw

    Even the program shows different pulse width.
    what do you mean ,that makes little sense


    Well, I don't know what to say. I get all the same frequency with different pulse width.
    my code works perfectly on the simulator and the actual hardware
    post your code and schematic .
    Warning I'm not a teacher

  6. #6
    Join Date
    Aug 2009
    Location
    Paso Robles California
    Posts
    167


    Did you find this post helpful? Yes | No

    Default Re: Hwpw

    I ran the code that you posted.

  7. #7
    Join Date
    Aug 2009
    Location
    Paso Robles California
    Posts
    167


    Did you find this post helpful? Yes | No

    Default Re: Hwpw

    Walking and talking on the phone does not work well.
    I ran your program my scope has measure function all 3 channels showed the same frequency. But the duty cycle was the only difference. I used pbp setting ccp1, ccp2, ccp3 and ccp5 port c1, c2, and port b0, b5 there is also no control of individual frequency only duty cycle

Members who have read this thread : 14

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