speedometer without timer1


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default Re: speedometer without timer1

    could you do a "pulse-in" once or twice a second with a limit of 1/4 or 1/3 second so program continues, that uses a 10 micro-sec resolution and 16 bit count, all in basic ?

    don
    Amgen Marine

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


    Did you find this post helpful? Yes | No

    Default Re: speedometer without timer1

    Pulsin has an inherent problem that the duty cycle has to be constant, and often it is not. A cycle is both a "low" time plus a "high" time. It is also a blocking command. While you can do a

    PULSIN pin,0,lowtime
    PULSIN pin,1,hightime

    Period = lowtime + hightime

    Speed (or RPM, etc) = constant/Period

    To get the correct period even if the duty cycle varies somewhat, you should know that PULSIN can't read the hightime immediately following the lowtime.
    It reads the lowtime, misses the next hightime, skips the following lowtime, and then reads the hightime.

    If your sensor puts out a good clean signal, then the PULSIN method is the easiest. But also remember, that at very slow speeds, your code will be sitting around for a long time waiting for the next transition.


    The good thing about my routine is that it runs in the background and averages over the sample period (I usually use about 0.5 sec), so the results are very stable, even with noisy inputs.

    And... There is nothing that keeps you from writing your ISR in PBP. Use Darrel Taylor's Instant Interrupts.

    Just -

    read the port bit on a timer interrupt
    compare it with the last read of that bit
    if it has changed, increment a counter
    do the above for a fixed amount of time
    read the counter.
    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