PIC 18F1330 HPWM problem - Page 4


+ Reply to Thread
Page 4 of 4 FirstFirst ... 234
Results 46 to 50 of 50

Thread: PIC 18F1330 HPWM problem128 days old

  1. #46
    Junior Member david's Avatar
    Join Date
    Jan 2019
    Posts
    64
    Thumbs Up
    Received: 3
    Given: 1
    Total Downloaded
    173.19 MB

    0 Not allowed!

    Default Re: Proton PC PWM library for devices 18F1230, 18F1330, 18F2331, 18F2431, 18F4331, 18

    Hi Archie,
    This is probably an overkill for your application but I have used the 16F1783 for precision PWM applications as it contains 2x 16 bit programmable switchmode controllers. (along with 12 bit ADC, 8 bit DAC, op-amps, comparators). Once set up the PSMCs are just the same as the familiar PWMs but use 16 bit registers for both duty cycle and period. The duty cycle can be pre-calculated then you just send PSMC2CON.6=1 'update duty cycle.
    The PWM can be clocked via its own internal PWM clock at up to 64MHz so even when using full 16 bit resolution the carrier rate is just under 1kHz so still makes for easy low pass filtering.

    Cheers,
    David

Attention

This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

The advertisements we display are relevant to this web site and your browsing history

Please consider supporting us by disabling your ad blocker.


Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

If you can, please report issues in the forum area WebSite / Forum Issues


Thank you for your attention.

  • #47
    Junior Member capitainehaddock's Avatar
    Join Date
    Oct 2019
    Posts
    27
    Thumbs Up
    Received: 0
    Given: 0
    Total Downloaded
    87.74 MB

    0 Not allowed!

    Default Re: Proton PC PWM library for devices 18F1230, 18F1330, 18F2331, 18F2431, 18F4331, 18

    Hi David
    Thanks
    But my only target was less ambitious..
    i wanted only have a ~5 mV resolution instead of ~20 mV
    with a PWM output to an analog voltmeter 0-5 Volts.
    As it seemed too complicated for me, after ~1 month of searching around,
    I now decide to abandon idea of 10 bit PWM, and stay with my working 8 bit system.

    I received some help here, thanks to all, but, as not expert enough, i was not able to
    write a working code with what i received.

    Best regards

    Archi

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #48
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,501
    Thumbs Up
    Received: 74
    Given: 31
    Total Downloaded
    6.55 GB

    0 Not allowed!

    Default Re: PIC 18F1330 HPWM problem

    Quote Originally Posted by capitainehaddock View Post
    thanks for care Joseph
    but
    on your last code, i dont see how to exit value to PWM....
    i am an old beginner...
    best regards
    Archi
    This will alter your PWM: -

    Code:
    CCPR2L = Temp_PWR
    As I understand it PER_Lin is your PWM value.
    So here you have to change your value PER_Lin: -

    Code:
    '\ 
    ' \
    '  \   ALTER YOUR PER_Lin HERE !!
    '  /
    ' /
    '/
    Regards

    Joseph

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #49
    Junior Member JonW's Avatar
    Join Date
    Dec 2019
    Posts
    13
    Thumbs Up
    Received: 1
    Given: 0
    Total Downloaded
    154.49 MB

    0 Not allowed!

    Default Re: PIC 18F1330 HPWM problem

    PWM is fairly straight forward to setup manually without using the compiler commands. See my calcs for the PIC18F24Q10 PWM CALCS.zip
    This is for the PIC18F24Q10 and every device varies. in this instance i am using a 64MHz clock and want to run with 10-bit resolution at the highest possible frequency. This allows easy filtering via RC. If you need a higher drive voltage/current you can easily buffer this with a suitable non-inverting opamp, if you need gain then its easy to add and you can add a capacitor in the feedback path to cut off the PWM frequency and lower the output impedance. The TLV314 from TI is a good part providing good drive close to the VDD/VSS Rails.

    The next step is to set up the device, here are the timers and PWM registers.

    Code:
    ; TIMER SETUP        T0CON0 =    000000     ; TIMER0 on, 8-Bit and 1:1 Post 
            T0CON1 =    011011     ; CLOCK SOURCE = fOSC/4, SYNC, 1:2048 PRESCALAR (32mS per rollover)
            T2CON  =    000000     ; Timer on prescaler and postscaler 0
            T4CON  =    000000     ; Timer on prescaler and postscaler 0 
            T2HLT =     100000     ; Free Run Timer, prescaler and CLK Syncro
            T4HLT =     100000     ; Free Run Timer, prescaler And CLK Syncro        
            T2CLKCON =  000001     ; Fosc/4
            T4CLKCON =  000001     ; Fosc/4   
            T2PR     =  111111     ; Set Timer period PWM to 62.5kHz   
            T4PR     =  111111     ; Set Timer period PWM to 62.5kHz               
    ; PWM SETUP
            CCPTMRS =   111001     ; PWM4/3 = TMR6.  CCP2 = TMR4, CCP1 = TMR2      
            CCPR1L  =   011111     ; SET DUTY to 0
            CCPR2H  =   000000     ; SET DUYT to 0
            CCPR2L  =   011111     ; SET DUTY to 0
            CCPR2H  =   000000     ; SET DUYT to 0     
            CCP1CAP =   000001     ; CCP1 = CCP1 PIN
            CCP2CAP =   000010     ; CCP2 = CCP2 PIN        
            CCP1CON =   001100     ; PWM enabled, PWM Mode, right justified   
            CCP2CON =   001100     ; PWM enabled, PWM Mode, right justified



    if you have PPS then these along with the port setup and peripheral disable registers need to be manipulated. Pay attention to the timers that the PWM requires and the depending on synchronisation, you need to enable in a certain sequence.

    Once setup and running the duty is very easy to manipulate writing directly to the CCPRXX duty registers.

    I would advise trying to set up the chip manually without using the compiler built in PWM functions. This way you will understand how the registers are manipulated and the hardware on chip works. In any case if you get the PWM running with the compiler then just manipulate the duty registers directly.

    Code:
    '*************************************************************************************
    ' 
    ' Name:                                 "SET_TX_DUTY"
    ' Passes:    None
    ' Returns:   None
    ' Description           UPDATED PWM DUTY CYCLE REGISTERS
    '*************************************************************************************
    SET_TX_DUTY:
            If TX_DUTY < 100 Then
                TX_DUTY = 100
                Return
            EndIf
            If TX_DUTY >1000 Then
                TX_DUTY = 1000
                Return
            EndIf
            CCPR1L = TX_DUTY.LowByte
            CCPR1H = TX_DUTY.HighByte 
            Return

    Hope this helps

    Jon
    Last edited by JonW; 18th December 2019 at 19:19.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #50
    Junior Member capitainehaddock's Avatar
    Join Date
    Oct 2019
    Posts
    27
    Thumbs Up
    Received: 0
    Given: 0
    Total Downloaded
    87.74 MB

    0 Not allowed!

    Default Re: PIC 18F1330 HPWM problem

    Hi John
    Thanks, but for me subject is CLOSED.
    As i already wrote, i am not skilled enough, dont get enough simple useful help adapted to MY case, and stay with my working 8 bit PWM.
    Merry Xmas and Happy new year to all into this forum
    Archi
    Click image for larger version

Name:	anim_papy.gif
Views:	1
Size:	48.7 KB
ID:	3864

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

    Thread Information

    Users Browsing this Thread

    There are currently 1 users browsing this thread. (0 members and 1 guests)

       

    Similar Threads

    1. PIC with upto 8 (alt.) HPWM channels extra
      By Henk57 in forum The Lounge
      Replies: 9
      Last Post: 6th December 2015, 11:28
    2. 18F2420 -> 18F1330 UART problem
      By xldaedalus in forum Proton Plus Compiler v3
      Replies: 0
      Last Post: 28th May 2009, 23:23
    3. [SOLVED !] problem with hpwm
      By Dphil7532 in forum Proton Plus Compiler v3
      Replies: 10
      Last Post: 1st March 2007, 22:51
    4. HPWM problem
      By joesaliba in forum Proton Plus Compiler v3
      Replies: 7
      Last Post: 26th November 2006, 05:07
    5. Smalist PIC with HPWM
      By PAKirk in forum The Lounge
      Replies: 6
      Last Post: 15th August 2005, 16:31

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts