PULSIN for frequency meter?


Closed Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Dec 2007
    Location
    Sweden
    Posts
    73

    Smile PULSIN for frequency meter?

    Hi guys,

    I am thinking about how to add a frequency display to my function generator project. The required range is 1 Hz to 100 kHz and if possible with a 1 Hz resolution. The source is square wave TTL level 50% duty.
    And now the question; is this achievable using a 16FXXX device and the PBP PULSIN command?

    Thanks!

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


    Did you find this post helpful? Yes | No

    Question

    Hi,

    BPB calculates with 16 Bits ... Ok ???

    100 000 Hz @ 1 bit resolution need ???


    That's it ...

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

  3. #3
    Join Date
    Nov 2005
    Posts
    36


    Did you find this post helpful? Yes | No

    Default

    why do not use the timer ?
    For low frequency is more accurate measure the period.
    Regards

  4. #4
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    If using the PIC as the frequency generator, wouldn't it be simpler to calculate the frequency rather than measure it?

  5. #5
    Join Date
    Dec 2007
    Location
    Sweden
    Posts
    73


    Did you find this post helpful? Yes | No

    Default

    Alain> I don’t follow your discussion, sorry.

    GioppY> Could you give more detail please?

    Dave> I guess I was unclear about the use of the PIC, the PIC is not involved in the generator part.

    Thanks!

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


    Did you find this post helpful? Yes | No

    Default

    Check you PIC datasheet, some have built-in counter. This allow you to use them to count the incoming pulses for a x sampling time.

    A while back i've made this one
    http://www.picbasic.co.uk/forum/showthread.php?t=1044

    Maybe this could be handy for you. It use TIMER0
    Last edited by mister_e; - 10th November 2008 at 17:23.
    Steve

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

  7. #7
    Join Date
    Dec 2007
    Location
    Sweden
    Posts
    73


    Did you find this post helpful? Yes | No

    Default

    So, what you mean is that the PULSIN command is not the way to go then?

    Thanks.

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


    Did you find this post helpful? Yes | No

    Lightbulb

    And now the question; is this achievable using a 16FXXX device and the PBP PULSIN command?
    a 16F device running @ 20 Mhz max... so PULSIN will give you 2µs per count.

    PBP 16F compiler uses 16 bits ... so, 65535 counts at a maximum


    Pulsin will give you a valid result from 1 to 65535 unit +/- 1 count.

    @ 50% duty cycle your period can be ... 4 to 131070 µs +/- 4µs


    a 16F device running @ 4Mhz ... so PULSIN will give you 10µs per count.

    PBP 16F compiler uses 16 bits ... so, 65535 counts at a maximum


    Pulsin will give you a valid result from 1 to 65535 unit +/- 1 count.

    @ 50% duty cycle your period can be ... 20 to 655350 µs +/- 20µs



    from that you can understand what precision and resolution you can get with the PULSIN command.

    That's quite simple ...

    Alain

    PS: Gioppy gave you ... half of the answer !!! LOL
    Last edited by Acetronics2; - 10th November 2008 at 17:54.
    ************************************************** ***********************
    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 " !!!
    *****************************************

  9. #9
    Join Date
    Nov 2005
    Posts
    36


    Did you find this post helpful? Yes | No

    Default

    Have a look here:
    http://www.picbasic.co.uk/forum/show...69&postcount=4
    You can use this code to measure the frequency with timer1. This open the timer1 gate for exactly 1 sec. (@4MHz); so you can get a resolution of +- 1Hz. The result return in 2 words Hicntr and Locntr. Obviously you need a routine that convert the 32 bit to decimal.
    With a bit less accuracy can be done in pbp.
    http://www.picbasic.co.uk/forum/showthread.php?t=7828
    Not very easy, but works fine.

    Regards
    Gianni

  10. #10
    Join Date
    Dec 2007
    Location
    Sweden
    Posts
    73


    Did you find this post helpful? Yes | No

    Smile

    Thanks Guys, I think I have enough to read up on for now! I’ll let you know how it develops.

    All the best!

Similar Threads

  1. Replies: 17
    Last Post: - 12th April 2014, 02:17
  2. Better understanding PULSIN
    By Wirecut in forum mel PIC BASIC
    Replies: 12
    Last Post: - 29th June 2008, 10:17
  3. Funny PULSIN values: what is going on???
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 30th April 2008, 08:02
  4. Pulsin 16F819 problem
    By rekcahlaer in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 11th April 2007, 13:52
  5. PULSIN and RCTIME
    By Dwayne in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 4th November 2004, 14:45

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