Frequency mesure


Closed Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2009
    Location
    LECCE - ITALY
    Posts
    7

    Default Frequency mesure

    Hi,
    I need to read on a port of pic 18f2620 e frequency and period signal (square wave) from 0 to 200 hz.
    Can Someone suggest me a little program in pbp?

    Thankyou

  2. #2
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: Frequency mesure

    You can get the period and frequency by

    DEFINE PULSIN_MAX 32767 ; Don't let the sum overflow
    ...
    pulsin pin,0,LowPeriod
    pulsin pin,1,HighPeriod

    if !LowPeriod or !HighPeriod then goto NoInput

    TotalPeriod = LowPeriod + HighPeriod

    a= 1000
    b = 100

    c = a*b

    frequency = div32 TotalPeriod ; divide 100,000 by the Period
    ...

    NoInput:
    HSEROUT [CR,LF,"No Input"]
    ...



    You may have to change some of the values, depending on your OSC, since the PULSIN resolution depends on the OSC frequency. Also, there is a lower limit to the frequency you can measure. At 4Mhz, you can go down to 1.52 Hz.
    Charles Linquist

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