Long Timer


Closed Thread
Results 1 to 13 of 13

Thread: Long Timer

Hybrid View

  1. #1
    Join Date
    Feb 2005
    Location
    Essex, UK
    Posts
    154


    Did you find this post helpful? Yes | No

    Default

    Right cracked it, thanks very much for everones help.

    Regards,

    Steve

  2. #2
    Join Date
    Feb 2005
    Location
    Essex, UK
    Posts
    154


    Did you find this post helpful? Yes | No

    Default

    Ok, i got greedy. I have now added hours to the routine.

    However, i have done a test, setting the delay at 8hrs 45min 32 seconds
    and it triggered at 8hrs 44min 06 seconds.

    Two things really, is the the type of result expected. I know its a small margin of error, but i thought 1000ms is a 1000ms. Alternatively is there an error in the code that someone can see?
    Code:
        If HoursDelay > 0 then
        For Hours = 1 to HoursDelay
        For Minutes = 1 to 60
        For Seconds = 1 to 60
        If SW2 = 1 Then Goto main
        Toggle Red ' flashing light for reference
        Pause(1000)
        Next Seconds 
        Next Minutes
        Next Hours
        EndIF    
    
        If MinutesDelay > 0 then
        For Minutes = 1 to Minutesdelay
        For Seconds = 1 to 60
        If SW2 = 1 Then Goto main
        Toggle Red ' flashing light for reference
        Pause(1000)
        Next Seconds 
        Next Minutes
        EndIF
    
        If SecondsDelay > 0 then
        For Seconds = 1 to SecondsDelay
        If SW2 = 1 Then goto main
        Toggle Red ' flashing light for reference
        pause(1000)
        Next Seconds
        EndIF
    I thought it would be a little more accurate than that. If i set the delay at 32seconds then it triggers at 32seconds.

    There are only so many lengthy test you can do, waiting 8hrs for an event to trigger is a long time !!

    Cheers,

  3. #3
    Join Date
    Feb 2005
    Location
    Essex, UK
    Posts
    154


    Did you find this post helpful? Yes | No

    Default

    Can anyone answer the above ?

  4. #4
    Join Date
    Jul 2003
    Location
    Sweden
    Posts
    237


    Did you find this post helpful? Yes | No

    Question

    What oscillator are you using?

    Your error is 0.27%, not very good if you're using a crystal. Quite possible if using a resonator, very good if you're using internal oscillator.

    You should also ask yourself if minute or so matters over 8 hours.

    /Ingvar

  5. #5
    Join Date
    Feb 2005
    Location
    Essex, UK
    Posts
    154


    Did you find this post helpful? Yes | No

    Default

    Cheers for the reply.

    I am using a 20MHz resonator. So you reckon if i put in a Crystal instead, that should improve matters?

    I know what your saying about a minute error over 8 hours, but i just wanted it as accurate as possible. When its timing seconds only, thats fine, the error just creeps in over longer periods.

    I will get myself a 20MHz crystal and see if this changes things.

    I also really just wanted to make sure my code looks OK, there's only so many times you can tolerate waiting a long period to check for accuracy.

    Regards,

    Steve

  6. #6
    Join Date
    Jul 2003
    Location
    Sweden
    Posts
    237


    Did you find this post helpful? Yes | No

    Post

    Well ...... it's always a good start to KNOW that your oscillator is reasonable accurate. You will definatley get a more accurate source using a crystal. If it makes your timing worse, atleast you know it's in the software. Personally, i would have made this kind of application with a timer and interrupt. Not that it's absolutley necessary, i just find timers useful for timingpurposes.

Similar Threads

  1. High Resolution Timer & Speed Calculator
    By WOZZY-2010 in forum Code Examples
    Replies: 4
    Last Post: - 7th February 2010, 16:45
  2. Replies: 5
    Last Post: - 24th February 2009, 18:55
  3. Timer interrupt frequency
    By Samoele in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 17th January 2009, 23:49
  4. long countdown timer, how to save power?
    By Kamikaze47 in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 15th November 2008, 05:15
  5. Timer and long (hours) sleep period - how to?
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 8th January 2007, 07:32

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