Updating HPWM frequently, safe?


Closed Thread
Results 1 to 40 of 79

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    in my code just remove the following line
    Code:
    CCP1CON = PWM_OFF
    and also that one
    Code:
    CCP1CON = CCP1CON | PWM_ON
    In darrel's include, comment out line 160
    Code:
    MOVE?CB  0, CCP1CON
    At least, it work here.. thanks to my scope

    Now the history don't tell if this will work with ALL PIC #, and with ALL silicone release. Time will tell.
    Last edited by mister_e; - 7th May 2007 at 04:11.
    Steve

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

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


    Did you find this post helpful? Yes | No

    Smile

    You are a genius Mister_e. Wish I was as smart.

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


    Did you find this post helpful? Yes | No

    Default

    Don't give up, maybe one day you'll be. Then i could hire you
    Steve

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

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


    Did you find this post helpful? Yes | No

    Post

    Great thread this.
    Last edited by T.Jackson; - 7th May 2007 at 07:32.

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


    Did you find this post helpful? Yes | No

    Default

    O.K. i'll stop here... at least by respect to our members and readers, and because it's not a chit-chat area.
    Last edited by mister_e; - 7th May 2007 at 05:55.
    Steve

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

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    ...deleted...for obvious reasons
    Last edited by skimask; - 7th May 2007 at 05:59.

  7. #7
    Join Date
    Feb 2005
    Posts
    130


    Did you find this post helpful? Yes | No

    Default

    I removed that line from Darrel code and its clearly more stable now, but it still flickers at the lower range of the pot... very strange...

    I just modified the code I posted to write to eeprom the lowest pot setting where its stable, the read value was from $007B to $007C but I recorded a couple of $007F and $0068 after 125 readings/writes, my guess for these oscillations was someting in the write cycle because after I stopped reading the led went to steady again, I wish I had a scope...

    modified code:
    Code:
    if calibrapin=1 then
    if conta < 250 then
     write conta, pote.byte1
     write conta+1, pote.byte0
     conta=conta+2
    endif
    endif

    Pablo

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


    Did you find this post helpful? Yes | No

    Default

    Strange indeed.

    Well, I've made the changes Steve found and posted it at the same link.

    I won't get my scope back till wednesday. (should have waited)
    But I'll sure have a good look at it then.
    <br>
    DT

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


    Did you find this post helpful? Yes | No

    Default

    mmm, could be a noisy pot as well... using your code and on many low-value ADC.. they are all stable.. no noise, no frlicker.

    what happen if you stick a 0.1 uF in parallel with your POT wiper?

    Any 0.1uF + 10uF capacitor close to your PIC?
    Steve

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

  10. #10
    Join Date
    Feb 2005
    Posts
    130


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    mmm, could be a noisy pot as well... using your code and on many low-value ADC.. they are all stable.. no noise, no frlicker.

    what happen if you stick a 0.1 uF in parallel with your POT wiper?

    Any 0.1uF + 10uF capacitor close to your PIC?
    I just tried with a 20 turn 10k linear pot and its the same, once I reach the lower duty cycles the led flickers.
    The difference is clearly visible with the multiturn pot, once you go below a certain level it flickers, move the other way a little bit and the flicker goes away

    Reading in the flicker position I get this range: from $00BB to $00BF and spurious $009F , $00B4, $00C6, $00E3 at random places
    Reading in the steady position I get this range: $00CD to $00CF and no spurious readings

    I only read 125 word values into the device own eeprom.
    Again Im using a li-ion battery for powering the circuit (3.65v)

    Weird isnt it? even weirder is that sometimes when I write the values to eeprom the written values are steady (also visually) but only when writting...

    Just in case here is the code I used:
    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
    calibraled  var gpio.5
    calibrapin  var gpio.4
    conta       var byte
    
    gpio=0
    conta=0
    frequency=1000
    pause 50    ' coffee break
    
    loop:
    
        adcin 1, pote
        if pote>1000 then pote=1000
        
    if calibrapin=1 then
    if conta < 250 then
     write conta, pote.byte1
     write conta+1, pote.byte0
     conta=conta+2
    endif
    endif
    
    @ HPWM10  1, _pote, _Frequency
    pause 10
    
    goto loop
    end

    Pablo

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


    Did you find this post helpful? Yes | No

    Default

    O.K. i have to go out. I had the same code, and i didn't have any problem...

    when i'll be back, i'll use a lower voltage AND use HighBrightness LEDs.

    Wish i could see the same thing....

    Still thinking there's an hardware problem...
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    Pablo,

    Good new, Bad news.

    I finally found my 12F683 and gave it a go.
    I've completely duplicated your problem. Blinking and all.

    For some reason it only does it on the 683.
    Every other chip I tried seems to work fine.

    And the bad news is, I haven't found out why yet. (Operative word, Yet)
    It appears to be with the A/D, the readings are all over the place at low voltage input.

    I still have many things to try, but just wanted you to know you're not crazy.
    And, I WILL find it. (unless somebody beats me to it)
    <br>
    DT

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


    Did you find this post helpful? Yes | No

    Question HPWM10 Question

    Hi, Darrel,

    I just try tu make HPWM10 work aboard a 12F683 ...

    and get the following Message ( MPASM compiler ) :

    Error[108] C:\PROGRAM FILES\MICROCHIP\MPLAB IDE\PROJETS\SPEEDCOMM.ASM 185 : Illegal character (1)

    the illegal character is ... the PWM Channel !!!

    @ HPWM10 1, _DutyCycle, _Frequency

    I used the example " straight out of the box ...

    do you have any idea ???

    Alain
    ************************************************** ***********************
    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 " !!!
    *****************************************

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


    Did you find this post helpful? Yes | No

    Lightbulb THE Idea

    re,

    The idea is : change "HPWM10.pbp" into "HPWM.bas", for the include command.

    Alain
    ************************************************** ***********************
    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 " !!!
    *****************************************

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Error[108] C:\PROGRAM FILES\MICROCHIP\MPLAB IDE\PROJETS\SPEEDCOMM.ASM 185 : Illegal character (1)
    There had to be more errors than that.
    The others might have had more clues, but it appears that PBP couldn't find the file.

    Are you saying that you renamed it to HPWM.bas but still had INCLUDE "HPWM10.pbp"?

    confused.
    <br>
    DT

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


    Did you find this post helpful? Yes | No

    Talking

    Quote Originally Posted by Darrel Taylor View Post
    There had to be more errors than that.
    The others might have had more clues, but it appears that PBP couldn't find the file.

    Are you saying that you renamed it to HPWM.bas but still had INCLUDE "HPWM10.pbp"?

    confused.
    <br>
    Hi, Darrel,

    Hoooo ... bad evening ! was HPWM10.pbp into HPWM10.bas.

    the goal was to transform a R/C pulse into a corresponding 10 bits PWM @ 10 kHz ... and drive a "Diesel engine" sound machine.

    Have a nice week end.

    Alain
    ************************************************** ***********************
    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 " !!!
    *****************************************

  17. #17
    Join Date
    Jan 2006
    Location
    Slovenia EU
    Posts
    32


    Did you find this post helpful? Yes | No

    Default 10 bit HPWM command on both CCP modules

    Hello,

    I would have two different frequency on CCP1 and CCP2 pin the first is 100HZ and second is 20Khz-40KHz. I use 1MHz quartz for clock and HPWM10 command from D.T. I use PIC16F876.
    I have on both CCP pin HPWM10 command with frequency 100hz and different duty. This working ok. When changed frequency on CCP1 to 1KHz then is frequency on both pin unchanged and very unstable
    When change one HPWM10 command to normal 8 bit HPWM then stay result unchanged.
    what I did wrong?

    here is first part of my program:




    INCLUDE "ALLDIGITAL.pbp"

    Cifra var byte
    Cifra1 var byte
    Maska1 var byte
    Maska2 var byte
    W var byte
    i var byte
    time var byte
    PR var byte
    VU var word
    VD var word
    Duty VAR word
    Duty1 VAR word
    FREQUENCY var word
    FREQUENCY1 var word

    LED var PORTC.4
    LEDDis1 var PORTA.0
    LEDDis2 var PORTA.1
    tipka1 var porta.2
    tipka2 var porta.3
    tipka3 var porta.4
    BUZ var porta.5
    enable1 var portc.0
    b0 var byte
    b1 var byte
    b2 var byte
    b3 var byte
    impulz var WORD
    minuta var byte
    key var byte
    pavza var word

    bp var byte

    TRISA=%11111100
    TRISB=%00000000
    TRISC=%00000000


    clear
    include "HPWM10.pbp"
    LOW PORTC.1
    LOW PORTC.2
    PWM_ON CON %00001100
    PWM_OFF CON 0
    time=6
    FREQUENCY=93 '
    FREQUENCY1=1000
    low led
    gosub zvok
    eeprom 0,[31]
    eeprom 2,[55]
    high enable1
    high led
    pause 100
    low led




    INTCON = %00100000
    OPTION_REG = %10001000

    On Interrupt Goto ISR
    INTCON = %10100000
    w=0


    Main:

    gosub tipka
    gosub timing
    read 0,b2
    gosub tpwm
    @ HPWM10 2,_IMPULZ,_FREQUENCY
    read 2,b0
    gosub ppwm
    @ HPWM10 1,_duty,_FREQUENCY1
    Gosub Priprava
    goto Main

    ppwm: b1=b0-50
    lookup2 b1,[100,200,300,400,500,600,700,800,900,1000],duty
    return

    tpwm: b3=b2-30
    lookup b3,[0,31,16,6,21,46],duty1
    return

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


    Did you find this post helpful? Yes | No

    Default

    With 16F876's, both CCP modules use the same Timer in PWM mode (TMR2).
    If you change the frequency of one, the other one changes too.

    With a 4 Mhz crystal, the minimum HPWM frequency is 245 Hz.
    Since you are using a 1 Mhz crystal, you can get down to 62 Hz, but you have to specify the frequency as if it were running at 4 Mhz.

    If you want 100 Hz, then specify 400 Hz in the HPWM10 command.
    93 is way below the minimum.
    <br>
    DT

  19. #19
    Join Date
    Jan 2006
    Location
    Slovenia EU
    Posts
    32


    Did you find this post helpful? Yes | No

    Default

    Frequency of 100 Hz is not a problem. In the case that I use PIC16F886 asking whether the command HPWM10 set timer TMR1 and TMR2 for each channel?
    Can you write the registry settings for the PIC16F886?

    tnx
    Samo

Similar Threads

  1. need help on hpwm
    By helmut in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th August 2007, 16:49
  2. HPWM of the port of two HPWM
    By ja2rqk in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 25th April 2007, 16:05
  3. sound command & music
    By trying in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 26th May 2006, 15: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, 04:50
  5. 3 HPWM channels
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 4th April 2006, 03: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