Hey guys, will this work?


Closed Thread
Results 1 to 27 of 27

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    To get Glitch-Free, you have to synchronize the updates with Timer2.

    The HPWM10 module does that with 10-bit resolution, and works just like the HPWM command.
    http://www.picbasic.co.uk/forum/show...7805#post37805

    But at your higher frequency, you'll still need to do it manually.
    It does show how to though.

    hth,
    DT

  2. #2
    Join Date
    Feb 2004
    Location
    Michigan, USA
    Posts
    305


    Did you find this post helpful? Yes | No

    Default

    Hi Darrel, I was just reading through that thread thinking it all looks familiar. I hadnt taken a look at your attachement yet.

    I'll have to digest in the morning. Is there a tutorial in your attachement, and will it work for 18F devices?

    I hate having one of those brains that learns by examples and questions rather than independant learning, feel so bad asking all the time. At least it usually goes in.

    I should drink more. Alcohol kills brain cells, therefore one could deduce that the slower brains cells are in contact with the alcohol longer, which would lead to them being killed off. This would leave you with only faster brain cells and thus more intelligence as the slower ones are no longer holding up your thinking. So on that thought, I'm going to the fridge to open a can of knowledge.

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


    Did you find this post helpful? Yes | No

    Default

    There's not really a tutorial.
    But there is a test program in the .zip that shows how to use it.

    The max frequency is still 32.767khz.
    And it will work with 12F's, 16F's or 18F's. As long as they have CCP modules.

    However, while you grab me one of those cans of knowledge ...

    The whole thing boils down to synchronizing the update with TMR2.
    And HPWM10 has extra code to handle different frequencies/prescaler/CCP modules, which you won't need with a constant frequency on a single CCP.

    So all you need to do with your existing code, is wait for the TMR2IF before changing the dutycycle ...
    Code:
    TMR2IF       VAR PIR1.1
    
    TMR2IF = 0
    while !TMR2IF : wend       ; let current cycle complete
    CCPR1L = duty>>2           ; MSB of duty cycle value
    CCP1CON.4=Duty.0           ; set PWM mode and store the 
    CCP1CON.5=Duty.1           ; 2 LSB of duty
    No digesting required.
    Do I get that Can of knowledge now?
    <br>
    DT

  4. #4
    Join Date
    Feb 2004
    Location
    Michigan, USA
    Posts
    305


    Did you find this post helpful? Yes | No

    Default

    Sure do.

    I'll report in the morning, its about 2am and my 18 month old is coughing himself awake as I type. I've got a feeling its going to be a long night. Poor guy, always so sick. Yay for ear tubes on Thursday.

  5. #5
    Join Date
    Feb 2004
    Location
    Michigan, USA
    Posts
    305


    Did you find this post helpful? Yes | No

    Default

    Well the little guy is sick and I got about 4 hours sleep last night.

    Havent tried this yet but I came up with this alternative and included Darrels changes.

    Code:
    START:
    ADCIN 6, CSET 'READ VALUE OF CURRENT SET POT
    ADCIN 4, CSEN   'READ VALUE OF CURRENT SENCE
    IF CSEN > CSET Then LET DUTY = DUTY - 1
    IF CSEN < CSET THEN LET DUTY = DUTY + 1
    GOSUB NewDuty                '
    PAUSE 1                         
    GOTO Start
    
    NewDuty:
            TMR2IF = 0
            while !TMR2IF : wend       ; let current cycle complete
            CCP1CON = 0  
            CCPR1L = Duty >>2   
            CCP1CON.5 = Duty.1
            CCP1CON.4 = Duty.0
            CCPCON.7 = 0
            CCPCON.6 = 0
            CCPCON.3 = 1
            CCPCON.2 = 1
            CCPCON.1 = 0
            CCPCON.0 = 0              
            RETURN

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


    Did you find this post helpful? Yes | No

    Default

    Poor little guy. :sad:

    As for the proposed additions ...
    You don't want to do that.

    The idea is to minimize the glitches, not create more.
    Leave the module in PWM mode and just change the dutycycle.
    <br>
    DT

  7. #7
    Join Date
    Feb 2004
    Location
    Michigan, USA
    Posts
    305


    Did you find this post helpful? Yes | No

    Default

    Hmm, well it dosent work. It's all over the place and then goes high and stays high. I have to power down to reset because adjusting the CSET pot does nothing to gain a recovery. Also, adc value for CSET does very little to alter the duty cycle.

    Is my thinking right here? Will this try to find the right duty cycle so CSEN = CSET?

Similar Threads

  1. PortA Doesn't Work
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 11
    Last Post: - 8th September 2015, 18:41
  2. pls help me verify my code not work, why???
    By chai98a in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 18th January 2010, 09:19
  3. Can't get POT work on P12f675 - Newbie
    By berslan in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 26th March 2008, 21:22
  4. How to set ICD-2 clone to work with PBP?
    By G-R-C in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 20th October 2006, 02:50
  5. Pin RA4 doesn't work
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 0
    Last Post: - 15th July 2004, 12:03

Members who have read this thread : 0

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