HPWM at very low frequency


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 2006
    Posts
    747

    Default HPWM at very low frequency

    Hi,
    The very short program works but the frequency output is extremely variable from 500Hz to 2Khz. The program should max at 512Hz..
    Also the output is very noisy, any recommendation on the output ? extra capacitor ?

    Code:
    '//////////////////////////////////////////////////////////////////////////////////
    '// 555 simulator using PIC16F88
    '// Variable frequency, fixed Dutycycle
    '//////////////////////////////////////////////////////////////////////////////////
    
    
    '/////////////////////////
    '// Define section //
    '/////////////////////////
    
    
    INCLUDE "modedefs.bas"
    OSCCON = %01110000 '8 Mhz
    DEFINE OSC 8
    ANSEL = 0
    CMCON = 7
    
    DEFINE CCP1_REG PORTB 'Define output port of pulses out
    DEFINE CCP1_BIT 0 'Define output port of pulses out
    
    Define ADC_BITS 10 ' Set number of bits in result
    Define ADC_CLOCK 3 ' Set clock source (3=rc)
    Define ADC_SAMPLEUS 50 ' Set sampling time in uSec
    
    TRISA = %11111111 ' Set PORTA to all input
    TRISB = %00000000 ' Set PORTB to all output
    
    voltage_check var word
    Frequency var word
    
    Mainloop:
    
    ADCON0.2 = 1 'Start Conversion max 1024
    ADCIN 3, voltage_check 'analog pin 1 get the 10 bit result  Check the battery voltage on pin PORTA.3
    Frequency = voltage_check /2  'max 512Hz
    
    HPWM 1,126,Frequency
    
    goto Mainloop
    END

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    This has the ADC turned off.
    ANSEL = 0
    Try
    ANSEL = %00001000
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Hi, Dave

    did you notice the generator will only output 489 to 512 Hz ???

    ... RTFM ???

    Yes Ken, you should read your manual, HPWM section ( or the Pic Datasheet ! )

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

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    did you notice the generator will only output 489 to 512 Hz ???
    Yup, and the OP said it was going from 500 to... So that part sounds about right. Does he want something slower?
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    Argrr, ya, I read the text but I skipped the table, But I need lower frequency then 489Hz, Actually I need between 10 to 300Hz, I think I am better off with what I am using now, a 555 timer.

    K

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    Argrr, ya, I read the text but I skipped the table, But I need lower frequency then 489Hz, Actually I need between 10 to 300Hz, I think I am better off with what I am using now, a 555 timer.

    K
    you can use a PIC, but with " soft " PWM generation ...

    Also have a look to what the CCP module can do for you ... more than generating PWM.

    in Compare mode, for example ... you easily can reach 2Hz ...

    a Timer1 Overflow interrupt also will work fine ...

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

  7. #7
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default Re: HPWM at very low frequency

    HI,
    I read page 83 concerning compare mode... still have no idea how you could get 2hz .
    The manual says even in PWM mode we cant get lower then 5ms long witch is about 200hz...

    K

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