interrupt timer???


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Sep 2010
    Posts
    8

    Default interrupt timer???

    hi all, i am a newbie for picbasic, have a question regarding to my final year project, hope the pros can help me =)

    the question is : is it posible to run 2 routine at the same time ?

    basically i want a routine to measure the time between my sensor interrupt, and another routine running a series of LED, the process are as below:


    interupt : sensor pass thru <--- when sensor pass thru then interrupt jump to here
    off all led
    timer1 stop and save the value
    timer1 start count the time between the sensor pass thru

    led1 on
    pause 1000
    led2 on
    pause 1000
    led3 on
    pause 1000
    led4 on
    pause 1000

    from the process above, the timer1 is counting the value, and the leds is still on at the same time.

    is the process above posible? can anyone give me the clue or code related? =)

    thank you very much =)
    Last edited by reik6149; - 11th September 2010 at 06:31.

  2. #2
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Welcome to the forum reik6149. You can run multiple interrupts at the same time, making it appear as the chip is doing multiple things at once.

    The easiest way to get started in interrupts, is to use DT_INTS or instant interrupts. This is an include file that simplifies the use of interrupts. It can be found here: http://darreltaylor.com/DT_INTS-14/intro.html
    You will notice a hello world, a blinky, and an elapsed timer. And also a combine all three. This is similar to what you are doing. Get comfortable setting all three of these, then see if you can figure out what you want your project to do.
    http://www.scalerobotics.com

  3. #3
    Join Date
    Sep 2010
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    thx for scalerobotics's kindly reply =)

    by the way,after i read thru the website,i still cant get the point. Perhaps i do not have the basic knowledge about something like option_reg or t1con. i think i have to read the basic 1st.
    =(

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    ASM interrupts are good, Darrel's instantaneous ones are best...

    But for starters look at ON INTERRUPT in the PBP manual and INTCON in the chips data sheet.

    BTW, what chip are you playing with?
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Sep 2010
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    sorry guys, im really cant understand what darrel did, from this page http://darreltaylor.com/DT_INTS-14/elapsed.html

    how the program know when start button is interrupted??

    in wat condition the program will

    gosub starttime and gosub resettime??

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


    Did you find this post helpful? Yes | No

    Default

    Hi, reik

    Your scenario reminds me a "Thunderstrike distance measurer" ... ( sorry for the Tool name ... I am French ... )

    so, if I understand it right ... the time between two interrupts could be many seconds ... ( 4 in your example ).

    Consider a Pic Timer itself ( Timer1 ...i.e.) can count up to 0.52s @ 4Mhz clock ... so, you have to use an extra counter that will count Timer 1 Overflows.

    your time will be ( 0.52s x nb of overflows ) + ( Timer1 x 8µs )
    distance will be ... 330 ( or SQR ( 1.3*287*(Temp+273.15)) ... x count (s)

    see Here for Timer calculations help :
    http://pictimer.picbingo.com/index.php

    BUT, you first have to open your pic datasheet to learn about the Timer modules and CCP module ( capture mode ) use.

    Darrel's Interrupts just are the easy tool to drive the interrupts ... but it is you to configure what happens during the interrupts ...

    The process is the same for pulse duration measuring, Rpm meters, shotshells speed measuring ...

    Just need to know the maximum time between interrupts ...

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

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