Right cracked it, thanks very much for everones help.
Regards,
Steve
Right cracked it, thanks very much for everones help.
Regards,
Steve
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?
I thought it would be a little more accurate than that. If i set the delay at 32seconds then it triggers at 32seconds.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
There are only so many lengthy test you can do, waiting 8hrs for an event to trigger is a long time !!
Cheers,
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
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
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.
Bookmarks