Get elapsed time while TIMER samples pulses


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2007
    Posts
    65

    Wink Get elapsed time while TIMER samples pulses

    hi fellows,
    this is a shorter and clearer way to expose my question:

    Does any Interrupt or Timer variable let me capture elapsed time ?
    [modified code taken from mister_e post]
    Code:
    Start: 
        TMR1L=0                  ' Clear Counter
        TMR1H=0                  ' Clear Counter      
                                 ' 
        TMR1ON=1             ' START counter
          ...DO_THINGS       ' <----Do other things in unknown time while counting in background
          ...FOR..NEXT...LCDOUT.... ' ....things happen
          hserout pulseRATE 
        TMR1ON=0                 ' STOP counter
                                 '
        CounterA.HIGHBYTE=TMR1H  ' Get results                          
        CounterA.LOWBYTE=TMR1L   ' 
    
        LapTIME = ELAPSED_TIME   ' Get ms <---- Something like this is what I wish... does it exist?
        'so I can do the following:
        pulseRATE = CounterA / LapTIME '  this would be heaven... :) [pseudocode]
        'pulseRATE is the pulse rate in this cycle.
        '
        '  Blah blah blah
        '
    goto start

    The idea is to handle a sort of variable (LapTIME) that handles the elapsed time(ms) while TMR1ON=1 (between START and STOP). to make accurate calculations like pulse rate, speed.. (for quadrature encoders)

    well, that is it
    thanks for your time
    regards,

    RodSTAR
    Last edited by RodSTAR; - 16th October 2007 at 05:14.

  2. #2
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    >>to make accurate calculations like pulse rate

    Many PICs have capture modules that capture the time between incoming rising (or falling) pulse edges. Look at the datasheet for your PIC and see if it has this capability. These modules are relatively easy to setup (and work great).
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  3. #3
    Join Date
    May 2007
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    Paul, I'll have a look for that at the datasheet.
    By the way I plan to use a 16F628A. Im my desktop I have 8 16F628A's, some 16F876A, 16F877A, 18F252, 18F4550, 18F4685, 12F509, and planning to get a 18F4431 or 2431, which have hardware built-in QEI pins (Quadrature Encoder Interface), 8 14-bit PWM modules (thru RB & RD ports), I know those monsters are made for what I need, but I think there's still a chance with theese theese brave warriors and polular PIC16F628A's.

    Thank you Paul,

    Watching datasheet,
    RodSTAR

  4. #4
    Join Date
    May 2007
    Posts
    65


    Did you find this post helpful? Yes | No

    Default possible solution

    now I am self suggesting,
    maybe is it possible to use different timers?
    for example
    1)start TMR0 to measure time
    2)start TMR1 to count pulses
    3)process other things while TMR0 and TMR1 measure in background..
    4)stop TMR0 to measure time
    5)stop TMR1 to count pulses
    6)get measured time from TMR0
    7)get counted pulses from TMR1

    maybe an advanced user may help me

  5. #5
    Join Date
    Jan 2009
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    rodstar,do u has code for your solution..

Similar Threads

  1. Elapsed Timer Demo
    By Darrel Taylor in forum Code Examples
    Replies: 111
    Last Post: - 29th October 2012, 17:39
  2. Totally Baffled with Elapsed Timer
    By CocaColaKid in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th June 2008, 21:01
  3. Count pulses between VARIABLE TIME
    By RodSTAR in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th October 2007, 12:44
  4. Timing input pulses and re-outputting them
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 28th February 2007, 01:50
  5. Timer in real time
    By martarse in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 29th July 2005, 14: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