TIMELINE Issue
Ok I created a timeline for a STOP WATCH screen I created, so when I click START the STOP WATCH fires off
It starts at 0 and end at 10 seconds.
So I captured the start time of the timeline and the end time just before the KILL and I expected 10 seconds but the result is -- 14 seconds
//*************************************************************************
Line 23 2022-10-14 (22:49:26.908):: START STOP_WATCH TIME TimeStr =22:49:45
Line 24 2022-10-14 (22:49:26.909):: END STOP WATCH TIME =22:49:59
//*************************************************************************
As the timeline gets called every 1/100 of a seconds, I add 1 to the green highlighted area on attachment represents 1/100 of a second. When this reaches 100 I add 1 to the bigger box above. So in pic I have 10 so it was called 1000 times and I expected the overall time lapse to be10 seconds .
But as shown above it is 14 seconds. Well this makes my Stop watch useless as I want 10 seconds.
I am not sure why this is happeneing.
//*************************************************************************
My controller is a 3100 so the processor should be fine. I also tested this on a 4100 with same results.
Could it be I set up the timeline incorrectly?
//*************************************************************************
TIMELINE Setup
LONG TimeArrayStopWatch[] = {10}; //runs every 1/100 OF A SECOND
if(TIMELINE_ACTIVE(TL_StopWatch) == 0)
{
TIMELINE_CREATE(TL_StopWatch, TimeArrayStopWatch, 1, TIMELINE_ABSOLUTE, TIMELINE_REPEAT);
}
//*************************************************************************
Also here is a snapshot of when the timeline shows 7 seconds and 8 seconds - note 2 seconds elapse and it should be 1.
Line 59 2022-10-14 (21:26:36.758):: I AM A STOPWATCH
Line 60 2022-10-14 (21:26:36.759):: NOW PRINT OUT nMainTimerSlot =7
Line 61 2022-10-14 (21:26:36.760):: STOP WATCH -- TIME =21:31:45
Line 62 2022-10-14 (21:26:38.291):: ----------------------------------------------
Line 63 2022-10-14 (21:26:38.292):: I AM A STOPWATCH
Line 64 2022-10-14 (21:26:38.293):: NOW PRINT OUT nMainTimerSlot =8
Line 65 2022-10-14 (21:26:38.294):: STOP WATCH -- TIME =21:31:47
Comments
I don't think I ever used a timeline with such a short time. So I never tested it, but I do know from other control systems that exact timing can be difficult. Although the timeline probably runs as a separate thread, it still is a single core processor that needs to do other things as well, making for slight deviations of the time. With a timeline of a second, I never noticed any appreciable deviation, but with 10mS that could be different.
Also how do you calculate the cumulative time? what type of variable holds that?
If you could share the source code (PM) I could run it on my test systems to see what happens. kinda curious about that.
Normally I run my Timelines for 1 minute or 1 second but this is first time I used 10 or 1/100 of a second
The reason I used 1/100 of a second was:
I set the calling of the timeline for 10ms which is 1/100 of a second because I wanted to show the sub-seconds in the green area I highlighted above. So i would see that area go from 1-100 very fast and when it hits 100 I add 1 to the bigger box above it. If you look at any stopwatch it shows milliseconds or fractions of a second as part of the count - look at the iPhone stop watch or countdown.
I have2 modes:
-- STOPWATCH
Ok now the good news - I ran both STOP WATCH and COUNTDOWN modes and it seems to work -- using a 10 second test.
also ran a 1 min countdown also worked
see log below
so I guess I am good but baffled why it now works!!!
//**************************************************************************
COUNTDOWN MODE
10 second
Line 175 2022-10-15 (13:28:44.051):: KILL TL_StopWatch TEST countdown
Line 176 2022-10-15 (13:28:44.051):: START COUNT_DOWN TIME TimeStr =13:29:06
Line 177 2022-10-15 (13:28:44.051):: END COUNT_DOWN TIME =13:29:16
//**********************************************************************************************
1 minute count down
Line 877 2022-10-15 (15:41:59.874):: START COUNT_DOWN TIME TimeStr =15:41:31
Line 878 2022-10-15 (15:41:59.875):: END COUNT_DOWN TIME =15:42:32
STOP WATCH MODE
10 second Stopwatch
Line 273 2022-10-15 (13:29:53.422):: KILL TL_StopWatch TEST 10 SECONDS
Line 274 2022-10-15 (13:29:53.427):: START STOP_WATCH TIME TimeStr =13:30:16
Line 275 2022-10-15 (13:29:53.427):: END STOP WATCH TIME =13:30:26