measure the xtal


Closed Thread
Results 1 to 12 of 12
  1. #1
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302

    Default measure the xtal

    I want to use timer0 in order to see in the LCD the frequency of crystal (internal clock). Or external on RA4
    But I do not know how I begin.
    I want use it , for measure xtal.

    Code:
        ' 16F877A
        
       	DEFINE LCD_DREG	PORTD	      ' Selection of the port D
        DEFINE LCD_DBIT 4	          ' Selection one RD4 with RD7
        DEFINE LCD_RSREG PORTD	      ' RS on port D
        DEFINE LCD_RSBIT 2	          
        DEFINE LCD_EREG	PORTD         ' E on port D
        DEFINE LCD_EBIT 3	         
        DEFINE LCD_BITS 4		      ' Mode 4 bits
        DEFINE LCD_LINES 2	          ' 2 lines
          
        DEFINE OSC 4
           
        OPTION_REG = %00001000  
        
    start:
    
        LCDOUT $FE,1,#TMR0
        
        goto start
    Last edited by savnik; - 7th June 2007 at 16:08.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    To measure something, anything, you have to have an accurate timebase. To measure the internal clock of the PIC, using that same internal clock as your timebase as you've shown in your brief example, doesn't work.
    Do you have an o'scope?

  3. #3
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    To measure something, anything, you have to have an accurate timebase. To measure the internal clock of the PIC, using that same internal clock as your timebase as you've shown in your brief example, doesn't work.
    Do you have an o'scope?
    Yes i have.
    Or how to measure a xtal on RA4;
    I want to measure the frequency of a oscillator with xtal or from a signal connecting to RA4
    Last edited by savnik; - 7th June 2007 at 16:13.

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by savnik View Post
    Yes i have.
    Or how to measure a xtal on RA4;
    I want to measure the frequency of a xtal or from a signal connecting to RA4
    So you want to make a frequency counter then...not measure the internal frequency of your PIC...

  5. #5
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    So you want to make a frequency counter then...not measure the internal frequency of your PIC...
    Yes.I want to measure the frequency of a oscillator with xtal or from a signal.

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by savnik View Post
    Yes.I want to measure the frequency of a oscillator with xtal or from a signal.
    One of the easiest ways I can think of off the top of my head...

    Use PBP's COUNT command...

    But that's only good up to about 125Khz when the PIC is running at 20Mhz.

    So, you could 'pre-divide' (like the various prescaler/postscalers inside the PIC) the incoming signal using a divide-by-x chip, like maybe a 74193 or something similar.

    Feed the input signal into the 74193, take the output from the 74193's Qd output, which will be a divide-by-16 output, and will effectively increase PBP's COUNT commands range up to about 2Mhz (with a decrease in resolution of course).

    Cascade 2 of the 74193's back-to-back, and you should be able to measure signals up to about 32Mhz (which is the effective limit of the 74LS193), using PBP's COUNT command.

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


    Did you find this post helpful? Yes | No

    Thumbs up Simple ...

    Hi, Savnik

    An easy solution is to use an external RC circuit and use ... RCTime ( 16 Bits result ...) !!!

    calibrate RCTime ( low drift components !!! ) with a Known Freq XTal ...

    With another XTal The Result will be proportionnal to the XTal Freq change ...

    That's all, Folks !!!

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

  8. #8
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Hi, Savnik
    An easy solution is to use an external RC circuit and use ... RCTime ( 16 Bits result ...) !!!
    calibrate RCTime ( low drift components !!! ) with a Known Freq XTal ...
    With another XTal The Result will be proportionnal to the XTal Freq change ...
    That's all, Folks !!!
    Alain
    Won't the output from RCTime be a logarithmic response, in other highly non-linear? You'd probably have to do some serious math to get accurate results.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Won't the output from RCTime be a logarithmic response, in other highly non-linear? You'd probably have to do some serious math to get accurate results.
    Hi, Skimask

    you Just forgot The XTal range won't be from zero to infinite ... 1 to 20 ... may be.

    But, as always, I'm not so sure of what our friend intends to do ...

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

  10. #10
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    But, as always, I'm not so sure of what our friend intends to do ...
    I have done a frequency meter with prescaler (256) from 10-1400Mhz.
    I did it with pbp(tmr0) and asm.
    But now i want to make a frequency meter from 0 -10 Mhz with only pbp.

  11. #11
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by savnik View Post
    I have done a frequency meter with prescaler (256) from 10-1400Mhz.
    I did it with pbp(tmr0) and asm.
    But now i want to make a frequency meter from 0 -10 Mhz with only pbp.
    Well, I gave you an idea that I thought was fairly good...whether you use it or not is up to you...either run with it or don't...

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


    Did you find this post helpful? Yes | No

    Wink Problem explained = half solved ...

    Hi, Skimask

    I'm out on this one ...

    I thought at first Savnik wanted to build some kind of XTal "identifying Gizmo" ...

    For a Freq meter, I never found simpler than The µChip AN 50 Mhz freq meter :

    1 16F84
    1 74HC 132
    1 Input Fet
    1 LCD ...

    rather simple. But works fine. ASM program ...of course.


    links to clones :

    http://www.sixca.com/eng/articles/fc50/index.html

    Note their PCB is to re-design ... too close layers in the P.A. section ... I couldn't measure over 7-8 MhZ with their design.

    Got 50+ Mhz with a re-design of PCB ...

    and :

    http://www.sprut.de/electronic/pic/p...quenz/freq.htm


    Also simplified ...

    http://l.lefebvre.free.fr/freq/freq_01.html

    And the last one :

    http://www.artra-qrp.com/fp50/fp50.html



    Alain
    Last edited by Acetronics2; - 8th June 2007 at 10:32.
    ************************************************** ***********************
    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 " !!!
    *****************************************

Similar Threads

  1. 16F877A with 20MHz XTAL not working?
    By ustredna in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 19th August 2011, 15:04
  2. Xtal speed vs PIC power
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 4th January 2010, 19:55
  3. Using CCP1 and CCP2 to measure instant fuel consumption
    By srspinho in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 20th September 2008, 15:50
  4. How can I measure Duty cycle ?
    By MaxiBoost in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 28th December 2006, 15:02
  5. using internal xtal
    By jojokatada in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd April 2005, 16:25

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