Updating HPWM frequently, safe?


Closed Thread
Results 1 to 40 of 79

Hybrid View

  1. #1
    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

  2. #2
    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.

  3. #3
    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

  4. #4
    Join Date
    Feb 2005
    Posts
    130


    Did you find this post helpful? Yes | No

    Thumbs up

    Quote Originally Posted by Darrel Taylor View Post
    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>
    As I see it its only good news Thanks for all your efforts!!!

    I can't help with your code, is way beyond my actual knowledge, I hope to catch up with it in the future!

    Now I patiently wait


    Pablo

  5. #5
    Join Date
    Feb 2005
    Posts
    130


    Did you find this post helpful? Yes | No

    Default

    An EE friend of mine (Thanks Doug) told me a new possibility about the cause of the problem:

    What if reading the ADC so often does not give it enough time to handle the low voltage values?

    (more discussions via chat with my friend)

    He points out something interesting, the test program initializes the ADC using:

    DEFINE ADC_BITS 10 ' ADCIN resolution (Bits)
    DEFINE ADC_CLOCK 1 ' ADC clock source (Fosc/8)
    DEFINE ADC_SAMPLEUS 11 ' ADC sampling time (uSec)

    But reading the pic basic manual we have:

    ADC_SAMPLEUS is the number of microseconds the program waits
    between setting the Channel and starting the analog to digital
    conversion. This is the sampling time. The minimum number of
    microseconds usable is determined by the minimum time for PAUSEUS.
    See it’s section for this information.
    and the PAUSEUS section says:
    For 4mhz Minimum Delay is 24us
    So, the initial theory appears to be right, I don't have the protoboard here now, but I will check this tomorrow.


    Pablo

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


    Did you find this post helpful? Yes | No

    Default

    I tried every AD oscillator / Sample time possible, and it made no difference.
    Even with the A/D input tied directly to ground, it was getting crazy readings between 0 and 20.

    After I tried it with a 12F675 (without the CCP) and got the same results,
    I finally figured out that I had removed the big cap on the power lines on this protoboard.
    Probably needed it for something else. Doh!

    After putting a 100uf cap across the power supply, everything calmed down again.
    It's still not perfect, but I think that has alot to do with the breadboard.

    So then to really stabilize things I added an averaging routine, and I think that's about as close as we're going to get.

    First make sure you have enough capacitance on your power lines (I think mister_e already suggested that).

    Then add this to the bottom of the program
    Code:
    ' -=-=-=-=-=-=  Average Analog values -=-=-=-=-=-=-=-=-=-=
    Avg       VAR WORD
    AvgCount  CON 16
    spread    CON 20
    
    Average:    ' Smooth data
        IF ABS (pote - Avg) > spread then
            Avg = pote
        else
            Avg = (Avg*(AvgCount-1)+pote)/AvgCount 
            pote = Avg                               
        endif
    Return
    And also, just after the ADCIN statement, add this
    Code:
        gosub Average
    HTH,
    DT

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


    Did you find this post helpful? Yes | No

    Default

    it's getting interesting... i have everything on hand, will do some test here.

    Sorry, i was suppose to do it yesterday
    Steve

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

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