30 minute timer


Closed Thread
Results 1 to 5 of 5

Thread: 30 minute timer

  1. #1
    Join Date
    Sep 2005
    Posts
    10

    Default 30 minute timer

    I have an application that needs to output a Lo bit after the ADCIN (10bit) sees a full 1023 count for a continuous 30 minites.

    I know what I have to do, but don't know exactly how to code it in PICBASIC Pro. Can anyone steer me in the right direction?

    I'm using a PIC16F877A and a 4Mhz clock.

    I will be keeping track of the TMR1IF with interrupts off (TMR1IE=0). With a 16 bit counter and 4Mhz clock, 4 the clk to instruction cycle divider, and 8 the maximum timer prescaler value, the maximum timer1 rollover time is (65536*4*8/4e106)= 524ms

    If I keep track of the TMR1IF with a counter loaded to a value of rollovers equal to 30 min (in the above example that would be 30*60/.524 = 3435)

    If the ADC routine sees a value of less than 1023 it loads the timeout of 3435.
    Every time throught the program loop, TMR1IF flag is checked. If it is set it is cleared and the counter decremented. When the counter gets to 0 the Lo bit is output to an analog switch.

  2. #2
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    Hi O2,

    Why don't you consider Darrel Taylor's Elapsed Timer program? It can be preset through your code to what ever amount of time you need.

    Just goto the Code Examples section and look for it.

    HTH,

    BobK

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


    Did you find this post helpful? Yes | No

    Lightbulb

    Hi,

    A simple way could be to count how many times you have read "1023" and reset the counter if other reading ... there might be something like a timed loop in your program ...

    from your TMR1 example ...

    IF counter > 3435 then AUTO_DESTRUCT_LAUNCHED ...

    "on interrupt" might be more than enough to flag the TMR1 Overflows and increment counter ...

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

  4. #4
    Join Date
    Sep 2005
    Posts
    10


    Did you find this post helpful? Yes | No

    Default 30 minute timer

    Haven't had too much response from my question. I have just about conquered it and will post the code when I'm done. In the meantime, if there are any ideas wihout interrupts, (since I'm using DIV32), please post.

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by O2_Guy View Post
    if there are any ideas wihout interrupts, (since I'm using DIV32), please post.
    What's the problem with using interrupts and DIV32? The manual tells you how to avoid problems with that.

Similar Threads

  1. Help me with interupt
    By azmax100 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 3rd February 2009, 00:17
  2. Timer interrupt frequency
    By Samoele in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 17th January 2009, 23:49
  3. 1 minute 30 seconds
    By Leonardo in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 28th November 2008, 15:51
  4. Alarms with Mel's "Olympic Timer" based timer - how to?
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 20th June 2007, 22:09
  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