Frequency Generator


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2008
    Posts
    2

    Smile Frequency Generator

    Hello, my english is not so good but I will try to post for the first time....
    I am trying to make a very stabile frequency generator from 10 Hz to 100 Hz
    and in increments of maximum 0.1 Hz but 0.05 Hz would be great.
    My first idea was to use the 16F872 and it's HPWM output witch
    is from about 1200Hz to 32767 Hz , and divide the output by 300 [lot's of D-Flip Flops].
    The problem is that the PWM output is working in increments of about 100 Hz,
    and 100 Hz / 300 = 0.3Hz resolution......no good.
    Is there a way to get a better resolution by using Asembler, or is using the DDS like
    AD9833 or AD9850 my only option?

    The mesurements from very good frequency meter taken from the HPWM output are :
    .....
    9708 Hz
    9803 Hz
    9900 Hz
    10000 Hz
    10100 Hz
    10203 Hz
    10308 Hz
    10415 Hz
    10526 Hz
    10638 Hz
    .....

    and the code is:
    ---------------------------------------------------------
    device=16F872
    DECLARE XTAL=4
    CONFIG xt_OSC , WDT_OFF , PWRTE_ON , BODEN_ON , LVP_OFF , WRTE_OFF , CP_OFF , DEBUG_OFF
    DECLARE BOOTLOADER = OFF
    DECLARE PORTB_PULLUPS = OFF ' Disable PORTB pullup resistors
    DECLARE WATCHDOG = ON
    DECLARE REMARKS ON
    DECLARE ICD = OFF

    DECLARE LCD_DTPIN = PORTA.0
    DECLARE LCD_RSPIN = PORTA.5
    DECLARE LCD_ENPIN = PORTa.4
    DECLARE LCD_INTERFACE = 4 ' 4-bit Interface
    DECLARE LCD_LINES = 2
    ALL_DIGITAL = TRUE

    SYMBOL PressUp = PORTB.7
    SYMBOL PressDOWN = PORTB.6

    DIM freq AS word
    Dim freq_OUT as word
    dim freq_in_END as word

    DECLARE CCP1_PIN PORTC.2 ' Select HPWM port and bit for CCP1

    'debounce
    DIM UP AS BYTE '
    DIM DN AS BYTE '

    UP = 0
    DN = 0

    freq_in_END=10000
    freq_OUT = 10000
    freq=10000

    TRISA = %00000000
    TRISB = %11000000
    TRISC = %00000000


    HELLO: PRINT AT 1,1,"Freq. generator"
    DELAYMS 1000
    CLS


    BEGINING:
    Button PressUp,1,255,0,UP,1,A_freq_UP
    Button PressDOWN,1,255,0,DN,1,A_freq_DOWN

    If freq > freq_in_END then
    freq_OUT = freq-1

    endif

    If freq < freq_in_END then
    freq_OUT = freq+1

    endif


    HPWM 1,127,freq_OUT

    PRINT AT 1,1,"Freq. is:",dec freq,"Hz"
    delayms 100

    freq = freq_OUT

    GOTO BEGINING


    A_freq_UP: freq_in_END = freq+10
    GOTO BEGINING
    A_freq_DOWN: freq_in_END = freq-10
    GOTO BEGINING


    END
    ---------------------------------------------------------
    Thank You

    ExYu

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


    Did you find this post helpful? Yes | No

    Default

    ExYu,

    It looks like you are using Proton.

    The forum for that compiler is at ...
    http://www.picbasic.org/forum/

    This forum is for PicBasic Pro from meLabs.

    .
    DT

  3. #3
    Join Date
    Jan 2008
    Posts
    2


    Did you find this post helpful? Yes | No

    Default

    Ops...
    Sory, and thank you

    ExYu

Similar Threads

  1. HPWM command and oscillator frequency
    By RussMartin in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 8th March 2009, 22:41
  2. Timer interrupt frequency
    By Samoele in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 17th January 2009, 23:49
  3. HPWM10 Frequency Updating
    By duncan303 in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 19th January 2008, 12:30
  4. inaccurate frequency using TMR1 PI18F452
    By nkarpovich in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 14th October 2006, 16:22
  5. frequency measurement
    By big-x in forum General
    Replies: 2
    Last Post: - 25th November 2005, 00:53

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