Updating HPWM frequently, safe?


Closed Thread
Results 1 to 40 of 79

Hybrid View

  1. #1
    Join Date
    Feb 2005
    Posts
    130

    Default Updating HPWM frequently, safe?

    How often is safe to update the HPWM duty cycle when running a 12f683 at 4mhz?

    I see that doing it constantly confuses the uC, so whats the safe "wait period" ?

    Thanks!

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by peu View Post
    How often is safe to update the HPWM duty cycle when running a 12f683 at 4mhz?

    I see that doing it constantly confuses the uC, so whats the safe "wait period" ?

    Thanks!
    What do you mean by 'safe' and 'confuses the uC'?

  3. #3
    Join Date
    Feb 2005
    Posts
    130


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    What do you mean by 'safe' and 'confuses the uC'?
    Hi Skimask,

    I mean if I update the HPWM inside the main loop of a program, is it safe to update it every time the loop loops?

    From my experimentation (Im controlling LED brightness using this hpwm) if I do this the LED flickers.

    On the contrary, if I create a 3 lines new program with just one HPWM line and a loop:gotoloop, the LED does not flicker at all, its stable as it should be.

    thanks

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by peu View Post
    Hi Skimask,
    I mean if I update the HPWM inside the main loop of a program, is it safe to update it every time the loop loops?
    From my experimentation (Im controlling LED brightness using this hpwm) if I do this the LED flickers.
    On the contrary, if I create a 3 lines new program with just one HPWM line and a loop:gotoloop, the LED does not flicker at all, its stable as it should be.
    thanks
    PIC12F683 datasheet, Section 11.3.3

  5. #5
    Join Date
    Feb 2005
    Posts
    130


    Did you find this post helpful? Yes | No

    Default

    here is the gist of the code im running:

    @ device pic12f683,INTRC_OSC_NOCLKOUT , wdt_on, mclr_off, protect_off
    DEFINE OSC 4
    DEFINE ADC_BITS 10
    DEFINE ADC_SAMPLEUS 50

    ANSEL = %00000010 ' GPIO.1 A/D in, rest digital
    TRISIO = %00010010 ' GPIO.1 lectura AD,
    cmcon0 = %00000100 ' AD via gpio1 and internal reference
    vrcon = %10001010 ' set vref=2.25v

    .
    .
    .

    loop:
    oldpote=pote
    ADCIN 1, pote ' (0-65535)

    if oldpote <> pote then
    hpwm 1,inverduty,frecu 'these values are calculated in other section

    endif
    goto loop

    maybe the problem is that im using ADC and HPWM simultaneously?

    I don't undertand what you implied by reading that section of the DS.

    Thanks!
    Last edited by peu; - 5th May 2007 at 23:04.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by peu View Post
    .... I don't undertand what you implied by reading that section of the DS. ...
    That's just his little way of saying "I don't Know, go read the datasheet or something."<hr>

    When an HPWM command executes, it treats it like it's the First time, and sets up every register needed to run PWM with the CCP module.

    Changing CCP and TMR2 registers while the CCP is running PWM will cause "false pulses", Cycle Resets or elongation.

    It would be nice if there was an HPWM_UPDATE command that only changed the dutycycle, without messing with the other registers. But there isn't.

    If you need a totally "Glitch Free" PWM signal, then you'll have to modify the dutycycle manually. You can still use HPWM to set everything up. And then just modify the dutycycle later, after the PWM is running.

    If you haven't already, you should get a copy of mister_e's PicMultiCalc.exe

    It'll help figure out what values to use for the dutycycles.
    http://www.mister-e.org/pages/utilitiespag.html

    HTH,
    DT

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 : 1

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