Clock hangs after 25 days

More
1 year 4 months ago #7511 by Ian
I finally found the problem that caused the clock display to get stuck after 25 days or so.

It was caused by the internal millis() counter overflowing.

V46 of the software solves it!

Please Log in or Create an account to join the conversation.

More
1 year 4 months ago #7512 by Stackerlee
Splendid!
So around 25 days it was?
Seems to fit my observations.
I see you've done numerous changes in the code.
Will take a look in a while.

Please Log in or Create an account to join the conversation.

More
1 year 4 months ago - 1 year 3 months ago #7519 by Ian
A quick explanation of the failure mode.

I was reading millis() as a signed long value, but really it is an unsigned value.

After 2^31 milliseconds (=24days 10.5 hours or so) it rolls over to -2^31, a large negative number.

There is a function which knows the end time of the "temporary display" mode (date, LDR reading etc) which is usually set for 5 seconds in the future when you press the button. This is initialised to 0 and then moves forward each time you use temporary display mode. When time moves on, the check "millis < tempdisplayend" becomes false and the display reverts to normal time mode.

When we roll over, millis suddenly becomes much smaller than tempdisplayend, so the display gets stuck in temp mode.

Changes:

all refrerences to time variables are now unsigned long
When we finish temp display mode, we set the tempdisplayend time to 0

I also made some little changes to the backlight cycling code to make the cycles give stronger primary shades.
Last Edit: 1 year 3 months ago by Ian. Reason: clarity

Please Log in or Create an account to join the conversation.

More
1 year 1 month ago - 1 year 1 month ago #7740 by Ian
A quick update. We're better, but not good.

Now it hangs after 50 days. Back to the drawing board...
Last Edit: 1 year 1 month ago by Ian.

Please Log in or Create an account to join the conversation.

More
9 months 3 weeks ago #7931 by konradp
Hi Ian,
Is this still a issue?, does it mean that all clocks will hang after 50 days, is there a fix in sight?

Please Log in or Create an account to join the conversation.

More
9 months 2 weeks ago #7945 by Ian
It should be solved in V48+

We used to set an "end time" of the date display by using millis() + displaytime * 1000, but now we just put the number of seconds to display for in a variable and count it down until it reaches 0.

Please Log in or Create an account to join the conversation.

More
5 months 1 week ago #8182 by Stackerlee
Hello
I have one clock (V49) which has frozen after around 50 days. Can't say the exact number of days but it's close to 50. It's done it twice now (in about 100 days), so there seems to be a pattern.
After a restart it's ok again.

Please Log in or Create an account to join the conversation.

More
4 months 2 weeks ago #8234 by Ian
Hmm, I don't know how that could be. Things in V49 are done in a totally different way, and there should be no effect on rollover. Let me break out the instrumented version of the code again and have another look at it.

Please Log in or Create an account to join the conversation.

More
1 month 3 weeks ago #8605 by Stackerlee
This happened again with latest firmware MCU and ESP8266.
The clock looks like this:
streamable.com/ru4xt
This is after 51 days.
So something is still wrong.
After a reboot all is fine again.

Regards, David

Please Log in or Create an account to join the conversation.

More
1 month 1 week ago #8627 by Ian
Wow, trickiest bug ever... I'm starting to take it personally.

By the way, want to say how you made those separators? They look like fuse cases, but I can't really work out what is in them.

Regards

Ian

Please Log in or Create an account to join the conversation.

Moderators: AccutronTy_EeberfestIan
Time to create page: 0.040 seconds

Search

Tube Suppliers

Go to top
JSN Boot template designed by JoomlaShine.com