Converting milliseconds to frequency


Results 1 to 23 of 23

Threaded View

  1. #1
    Join Date
    Aug 2007
    Posts
    23

    Question Converting milliseconds to frequency

    I have code written to measure the time period of a square waveform using pulsin . I measure the low time and the high time and add them together and send it to an LCD. It is quite accurate (comparing to scope) and the refresh time is fast as the frequency varies. Knowing that frequency is 1/time, how can one go about doing the math in PBP to calculate the frequency of this waveform? Thanks.

    This is either very easy or a bigger problem than it seems.

    Here is the main loop: I found that I needed to do the 4/5ths thing to get the time more accurate.


    loop: pulsin PORTA.1,0,x
    x = x / 100

    pulsin PORTA.1,1,y
    y = y / 100

    z = x + y
    z = z * 4
    z = z / 5

    LCDOUT $fe, $C0
    LCDOUT " "
    LCDOUT $fe, $C0
    LCDOUT #z

    Goto loop
    Last edited by chips123; - 1st September 2007 at 01:47. Reason: More information

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. HPWM10 Frequency Updating
    By duncan303 in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 19th January 2008, 12:30
  3. How do I convert an internal variable into frequency
    By schlaray in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 13th February 2007, 07:26
  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 : 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