Timer1 - frequency measurement


Closed Thread
Results 1 to 16 of 16
  1. #1
    Join Date
    Jul 2007
    Posts
    38

    Default Timer1 - frequency measurement

    Hi,

    Has anyone got a sample program showing how to measure the frequency of an input, i want to measure the frequency of a transmitter.

    i'm using a pic16f870, i've been reading the information on timer1 but i don't totally understand how to accomplish what i need.

    Thanks

    Dan

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by -Dan- View Post
    Hi,
    Has anyone got a sample program showing how to measure the frequency of an input, i want to measure the frequency of a transmitter.
    i'm using a pic16f870, i've been reading the information on timer1 but i don't totally understand how to accomplish what i need.
    Thanks
    Dan
    Straight from the manual...
    COUNT Pin,Period,Var
    Count the number of pulses that occur on Pin during the Period and
    stores the result in Var. Pin is automatically made an input. Pin may
    be a constant, 0-15, or a variable that contains a number 0-15 (e.g. B0)
    or a pin name (e.g. PORTA.0).................
    But seriously, what frequency range are you planning on counting?

  3. #3
    Join Date
    Jul 2007
    Posts
    38


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Straight from the manual...

    But seriously, what frequency range are you planning on counting?

    I considered using count, but i do not no its limitations what will it count up to?.

    I want to measure in the 88-200mhz range, i doubt the pic can support this kind of range so i have got an external prescaler which will divide by 256 or 64.

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by -Dan- View Post
    I considered using count, but i do not no its limitations what will it count up to?.
    COUNT Pin,Period,Var
    Count the number of pulses that occur on Pin during the Period and
    stores the result in Var. Pin is automatically made an input.........
    Does that give you a clue as to the answer?

    so i have got an external prescaler which will divide by 256 or 64.
    You're going to divide RF using an 'external prescaler'?
    Good luck with that...

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


    Did you find this post helpful? Yes | No

    Default

    Hi, Dan

    The Web is full of Ham Freqmeters ...

    "Google is you friend."

    EPE's last edition show a nice 50 Mhz one ... w/o prescaler.
    µChip ANs show the original idea for those ones.

    just yours to choose which one !!!

    Alain
    Last edited by Acetronics2; - 27th October 2008 at 17:14.
    ************************************************** ***********************
    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 " !!!
    *****************************************

  6. #6
    Join Date
    Jul 2007
    Posts
    38


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Does that give you a clue as to the answer?


    You're going to divide RF using an 'external prescaler'?
    Good luck with that...
    See the below image

    http://hem.passagen.se/communication/pic/fct_sch.gif

    this is a project i found that does what i wanted, but it does not explain the programming side of capturing the frequency, which i want to understand.

    I only want to learn lol

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


    Did you find this post helpful? Yes | No

    Talking

    Looking at this ...pic. I do think PbP has not its place inside the 870 !!!

    125 Khz * 256 = ... 32 Mhz

    Alain
    Last edited by Acetronics2; - 27th October 2008 at 17:33.
    ************************************************** ***********************
    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

    That link doesn't work so good for me...might for some, not for me at the moment...

    COUNT Pin,Period,Var
    Count the number of pulses that occur on Pin during the Period and
    stores the result in Var. Pin is automatically made an input.........
    So what did you get out of this?

  9. #9
    Join Date
    Jul 2007
    Posts
    38


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Looking at this ...pic. I do think PbP has not its place inside the 870 !!!

    125 Khz * 256 = ... 32 Mhz

    Alain
    What do you mean?

    and the 125khz is that the maximum frequency the 16f870 can capture?

  10. #10
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Timer1 can work with some pretty quick external input clocks. Check the electrical specs
    section TIMER0 AND TIMER1 EXTERNAL CLOCK REQUIREMENTS.

    Look at the specs for T1CKI High Time, T1CKI Low Time, and T1CKI Input Period.

    With a pickup coil tuned to the frequency you're measuring, and the /64 output, it should
    be pretty simple to measure your freq range.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  11. #11
    Join Date
    Jul 2007
    Posts
    38


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce View Post
    Timer1 can work with some pretty quick external input clocks. Check the electrical specs
    section TIMER0 AND TIMER1 EXTERNAL CLOCK REQUIREMENTS.

    Look at the specs for T1CKI High Time, T1CKI Low Time, and T1CKI Input Period.

    With a pickup coil tuned to the frequency you're measuring, and the /64 output, it should
    be pretty simple to measure your freq range.
    Hi Bruce,

    I've read that, but i don't totally understand it, thats why i wanted some help in getting started, i no timer1 would do what i need, but i don't no how to control timer1, i've never written a program that uses it.

  12. #12
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Visit the given link, schematic and code available.


    http://digilander.libero.it/alfred73/eprojects.htm#1300 Mhz Frequencymeter with prescale

    Al.

  13. #13
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    I've read that, but i don't totally understand it
    Which part are you having trouble with? I'll be happy to explain it.

    thats why i wanted some help in getting started, i no timer1 would do what i need, but i don't no how to control timer1
    T1CON on the 16F870 only has 6-bits that control the timer. Let me know what you don't understand that's in the data sheet, and I'll do my best to explain it. It would help if you tried a few code examples, and indicated which part you're having trouble with.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  14. #14
    Join Date
    Jul 2007
    Posts
    38


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce View Post
    Which part are you having trouble with? I'll be happy to explain it.



    T1CON on the 16F870 only has 6-bits that control the timer. Let me know what you don't understand that's in the data sheet, and I'll do my best to explain it. It would help if you tried a few code examples, and indicated which part you're having trouble with.
    I don't understand how i work out, what the maximum frequency timer1 could capture from that data

  15. #15
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    The datasheet shows T1CKI High Time min is 30nS for asynch mode with a prescaler of 1:1.

    T1CKI Low Time is 30nS. And T1CKI minimum Input Period is 60nS.

    So 1/60nS = the max input clock frequency it could handle. With your max freq at 200MHz
    divided by 64, you should be well below the max clock input limit.

    Look for AN592. Microchip shows an example using an old PIC1C5x with Timer0 that counts
    up to 50MHz.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  16. #16
    Join Date
    Jul 2007
    Posts
    38


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce View Post
    The datasheet shows T1CKI High Time min is 30nS for asynch mode with a prescaler of 1:1.

    T1CKI Low Time is 30nS. And T1CKI minimum Input Period is 60nS.

    So 1/60nS = the max input clock frequency it could handle. With your max freq at 200MHz
    divided by 64, you should be well below the max clock input limit.

    Look for AN592. Microchip shows an example using an old PIC1C5x with Timer0that counts
    up to 50MHz.
    Is there any examples written in picbasic pro, that you know of.

Similar Threads

  1. Help with TIMER1 + SLEEP
    By Yodoad in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 22nd May 2009, 15:07
  2. Advice on frequency measurement to 30MHz
    By Andy Wood in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 27th March 2009, 04:23
  3. inaccurate frequency using TMR1 PI18F452
    By nkarpovich in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 14th October 2006, 16:22
  4. frequency measurement
    By big-x in forum General
    Replies: 2
    Last Post: - 25th November 2005, 00:53
  5. Timer1 and Interupt wierdness
    By mind in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 23rd August 2005, 01:24

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