Updating HPWM frequently, safe?


Closed Thread
Results 1 to 40 of 79

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    The µChip section Skimask pointed at shows " PMW module *might* be disabled before changing the dutycycle ". I read some Other Pics Datasheets and this GREY section didn't appear elsewhere ...
    And I just downloaded the latest/greatest 12F683 datasheet and it DOESN'T have that statement in there. What's up with that?

    µChip clearly says : Changing the dutycycle while PWM running (and only dutycycle is enough ) will produce unwanted effects ...
    The only way I see to keep ( is it really necessary ??? Good Q.) a "neat" PWM output would be to switch between HPWM, to the last produced fixed freq. and duty, soft PWM ... while disabling CCP, changing Dutycycle and re-enabling the CCP.
    Couldn't you update the duty cycle right after T2 has overflowed? As long as the duty cycle wasn't too low or too high, wouldn't this almost eliminate all false glitches?

    Back to our Friend Skimask ... I really do not know ... if he really doesn't know the "what is wrong".
    I got a good handle on "what's wrong" 'cause I ran into the same problem with my multi-channel software PWM program I wrote to run a bunch of lights awhile back. And my fix for the problem was to only update the PWM duty cycle for each channel in between cycles, so basically, I ended up with PWM that couldn't do 100% duty cycle, but only about 0%-95% duty cycle. The extra 5% at the top end was used to update the software registers.

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink

    Hi, Skimask

    Q1) Here is an excerpt ( joined ) ... Peu found it also ... If not in the latest datasheets, might we think the new devices have been modified ???

    Q2) I must experiment ... T2 overflow is to try ... Honestly, I would use a SMD 16F628,648,88 or ??, instead, if size is a really a problem ( LOL !!! )

    R3) It's the most logical solution ...

    Regards
    Alain
    Attached Images Attached Images
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Feb 2005
    Posts
    130


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Hi, Skimask

    Q1) Here is an excerpt ( joined ) ... Peu found it also ... If not in the latest datasheets, might we think the new devices have been modified ???
    Its indeed modified...!! I just redownloaded the datasheet and the PWM section is more complete now.

    check both versions here: http://peu.net/temp/pic12f683_OLD_vs_NEW.zip

    Q2) I must experiment ... T2 overflow is to try ... Honestly, I would use a SMD 16F628,648,88 or ??, instead, if size is a really a problem ( LOL !!! )
    Well, in my case I have very low space, all my pcb is a 18mm diameter board...

    Here is my code, I tidied / commented it so its more readable: http://peu.net/temp/pwm-adc

    Thanks!

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


    Did you find this post helpful? Yes | No

    Default

    And, You're all correct!

    Well, except for that part about me being wrong

    After my last post, I started working on an example for Pablo. It's kind of grown along the way, and is now a candidate for replacement of the HPWM command. IMHO

    It pretty much encompasses everything you guys talked about while I was doing it. Plus maybe a bit more.

    It's an Include file that gives 1 new command...
    Code:
    @  HPWM10  1, _DutyCycle, _Frequency
    It works the same way as the PBP HPWM command, except that it uses 10-bit resolution, works with all CCP modules CCP1-CCP5, And is "Glitch-Free" when changing Frequency or DutyCycle.

    Well, at least that's what it's supposed to do. Seems to work pretty good here, but I've only had a day to play with it.

    It uses about 250 more words than HPWM, so I don't know how good it will be for a 12F683. But it definately will fit, if the rest of the program isn't too big.

    If anyone has any problems, I'd appreciate a "Heads Up".

    http://www.pbpgroup.com/files/HPWM10.zip
    <br>
    DT

  5. #5
    Join Date
    Feb 2005
    Posts
    130


    Did you find this post helpful? Yes | No

    Default

    OMG

    Im "digesting" the code, just tried it and it compiles to 409words, compact enough for a 12f683

    Thanks!!!

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor
    Seems to work pretty good here, but I've only had a day to play with it.
    One day to do all that? Wow, some 'over a month TicTacToe brain challenged programmer' will be impressed
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    Join Date
    Feb 2005
    Posts
    130


    Did you find this post helpful? Yes | No

    Default

    I just tested it using this code:

    Code:
    '       Pic Configuration
    @ device pic12f683,INTRC_OSC_NOCLKOUT , wdt_on, mclr_off, protect_off        
    
    '       Hardware configuration
    
    '       I/Os
    TRISIO = %00010010      ' pin1 is ADC , pin4 is the calibration button
    
    '       ADC's
    ANSEL = %00000010  
    DEFINE ADC_BITS 10      ' ADCIN resolution  (Bits)
    DEFINE ADC_CLOCK 1      ' ADC clock source  (Fosc/8)
    DEFINE ADC_SAMPLEUS 11  ' ADC sampling time (uSec)                      
    ADCON0.7 = 1            ' Right justified results
    
    '       Comparator
    'CMCON0 = %00000111     ' Disable comparator
    'VRCON  = %00000000     ' disable
    cmcon0 = %00001110      ' Multiplexed Input with Internal Reference CIS=1
    vrcon  = %10001010      ' set vref=2.25v (from 4v input) 
    
    include "HPWM10.pbp"
    
    ' definitions
    pote 		var word
    Frequency   var word  ' edited after original post per Darrel suggestion
    calibraled  var gpio.5
    
    gpio=0
    frequency=1000
    pause 50    ' coffee break
    
    for pote=1 to 1023 
    
    @ HPWM10  1, _pote, _Frequency
    pause 10
    
    'gosub flashled
    
    next pote
    end
    
    flashled:
    high calibraled     ' I use this to visually count each loop step
    pause 50
    low calibraled      ' by using it I saw that my switcher starts to 
    pause 50            ' work at hpwm=4, less than that is too low
    high calibraled
    pause 50
    low calibraled
    pause 50
    high calibraled
    pause 50
    low calibraled
    pause 700
    return
    Comments:

    I used the flashing led routine to know when my switcher started to work, it started at hpwm=4 which is great, the power led is very dim at this value.

    then I removed the flashing routine and something was too fast, because my switcher was off. So I added a little pause in there and it was solved, tried 1, 5 and settled in 10ms where it started to work again.

    This is great!, now I will test it with adcin

    pablo
    Last edited by peu; - 7th May 2007 at 01:43.

  8. #8
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Post

    Quote Originally Posted by mister_e View Post
    One day to do all that? Wow, some 'over a month TicTacToe brain challenged programmer' will be impressed
    Yes, Mister_e, very impressive indeed.

Similar Threads

  1. need help on hpwm
    By helmut in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th August 2007, 15:49
  2. HPWM of the port of two HPWM
    By ja2rqk in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 25th April 2007, 15:05
  3. sound command & music
    By trying in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 26th May 2006, 14:14
  4. HPWM and A to D interaction question 18F252
    By tcbcats in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 10th May 2006, 03:50
  5. 3 HPWM channels
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 4th April 2006, 02:43

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