Go Down

Topic: RTC time error (Read 1 time) previous topic - next topic

SparksAlot

Using a RTC (real time clock) that every once in a while returns an incorrect time.

It happens maybe once or twice a day, but when it happens it messes up my code  : (

Does anyone have any tips or tricks for this problem? Searching didn't bring up anything on this specific type of problem.

I will try to decrease the error entering my code with constrain() and >=. Trying to keep the time within proper limits based on current minute and hour. But that probably won't catch all possible errors.

I don't think averaging is a good solution. So I'm wondering if anyone has a better idea.

An example of the error would be the time samples returning like this:

(24hour clock)
14:01
14:02
2:28
14:03
14:04

The error could be the chip returning the date instead of the time, but that doesn't matter. I just want to correct the error in case of any incorrect return. (bad signal for example)


Thanks for any help  : )




James C4S

What RTC are you using?  There are quite a few out there.  How is it wired up?

If it is in fact returning the date instead of the hours and minutes, you should probably determine why that is happening.  What code you using to read it? 
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

pocketscience

Having spent some time with a few different RTC's I'm going out on a limb to state that the problem is going to be with your wiring/programming...

If you post some details we can help pinpoint that problem maybe...


Cheers,
Is life really that serious...??!

SparksAlot

I appreciate your attention to my problem  : )

But I'm really not concerned about why this is happening. I want to make the code strong enough to handle such a RTC error no matter what the reason.

Nearby motors, low clock battery, solar flares, etc. Anything could temporarily damage a result from the RTC. I want my code to be able to handle it.


To answer your questions I am using this RTC:
http://macetech.com/store/index.php?main_page=product_info&products_id=8

This is code to read the clock:
http://docs.macetech.com/doku.php/chronodot_v2.0

Wired over i2c.


So for my example problem:
14:01
14:02
2:28
14:03
14:04

I can use the constrain() function to make sure hours stay within 0-12 and minutes 0-60.

I think I would want to take 3 or 4 clock readings and toss out the odd hour and minute data. Odd in that time doesn't go backwards or skip over hours or minutes.

I'm looking for help with that please  : )







pocketscience


But I'm really not concerned about why this is happening. I want to make the code strong enough to handle such a RTC error no matter what the reason.


Hmm, really.. I'd be concerned with the "why" instead of hacking your code in one place to cover up bugs in another. Like I said I've had projects running continuously for months and never seen what you're talking about.

At which point in your code are you seeing the bad data? How far back have you tried debugging? You don't post your actual code so it's impossible to comment specifically.

You mention solar flares etc, but you have what looks like the date. For some massive external force I'd expect complete rubbish.

I still call "software bug". :)


Cheers,
Is life really that serious...??!

Go Up