DS1307 and DS3231 RTC’s Running Fast

Ok,

So I made a clock. A Big Clock.

(The Veroboard Construction was Version 1, that used an Atmega328 uC. What a pain! If you do not have the supporting Circuitry (i.e. the USB Interface Chip to program), it is very difficult to update the program.)

Version 2 uses a Wemos D1 Mini Module, which gives me the easy programming interface, and the ability to do NTP Time Syncs, and I can also just do program updates through the Network.

    

Basically the uC uses a RTC Module to keep track of the time, and then pushes the outputs through Shift Register LED Drivers (Max6971), which then runs Segments made out of LED Strips.

The RTC Module keeps the realtime clock running, even when power is removed to the clock itself. So that whenever the clock is turned on, it has the right time (or that is what it was supposed to be doing).

On site, the clock was only powered for about 10 – 12 hours a week, and the rest of that time it was powered off, with the RTC just keeping track of time.

The problem I was having with the clock is that it was running fast, by that I mean a minute or so fast per week!. Trying additional decoupling caps on the RTC module did not help.

I originally was using a DS1307 RTC Module,

Which is not a Temperature Compensated device, so I expected it not to be completely accurate, but not to such an extent. So I tried another one of the same modules, same result.

Ok, some more research lead me to the DS3231 RTC Module,

Temperature Compensated, Internal Crystal Oscillator, with a rated accuracy of +- 2ppm (0 to 40deg). So that should be accurate to within 1 minute a year.

Tried it, and same result. 6 Weeks, and the clock was running 6 minutes fast!

Eventually a lot of googling helped me find my problem. Here is my code :

void loop () {
 while (CurrentS==PrevS) { //HOLD UNTIL SECOND TICKS OVER
 DateTime now = rtc.now();
 CurrentS = now.second();
 ...
 } //loop

Which means that the uC continually polls the RTC, and then only once the second bit changes, does the rest of the code run. This means that it is hammering the RTC module thousands of times a second. Which the RTC module does not like, and it causes the internal registers to glitch.

All I had to do was change the way my code worked, I enabled the square wave output on the RTC, and connected that to my uC. Which now meant the uC only queried the RTC when the seconds had changed

void loop () {
 sqwstate = digitalRead(RTCsqwpin);
 // compare the buttonState to its previous state
 if (sqwstate != lastsqwstate) {
  if (sqwstate == HIGH) { // We have had a Seconds Tick
   DateTime now = rtc.now();
   Serial.print(now.hour(), DEC);
   Serial.print(':');
   Serial.print(now.minute(), DEC);
   Serial.print(':');
   Serial.print(now.second(), DEC);
   Serial.println();

DoTime();
...
}

 

And Bingo, that fixed the problem. I last set that clock on the 29 January 2017. It is now 4 April 2017, and the clock is still accurate to within 1 second. so that is a Success.

Hope this little tip can help somebody else out.

P

Superhouse.tv Clickbait Post, or End of the World

So, the other day I am going through my normal work day, when my phone makes the beeping message tone thing, to tell me that there is something important that I must look at.

It is a Tweet or Post by Jon Oxer from Superhouse.tv (an awesome Home Automation and Electronics Youtube Channel based in Australia). And the Title of the Post is “SuperHouse Vlog #50: The future of SuperHouse“.

Now, that channel had been quiet for a week or two (probably due to the holiday season), so as soon as I saw the title, my heart sank. To me that title meant the End of the World, or at least of that channel, and also the end of the inspiring content it provides.

I could barely concentrate through out the rest of the work day (and I can’t just stop and watch a 10 Minute video whenever I feel like it, ‘Ain’t nobody got time for that….’. All I could think of is how that resource is going the way of the Dodo.

Well, Eventually I got home, put my feet up, and could watch the Video…

It was not the End of the World as we know it. but instead it was………………… Well, watch the video below to see what it was.

 

Jaycar Ripping off Freetronics Products

Just came across this video from Freetronics (http://www.freetronics.com.au/)

Freetronics is a small Australian Company (Basically a one man show), that spent many days designing an Arduino Kit, complete with the Arduino, Components, Manual, Custom box and Foam.

One of their retailers, Jaycar, was selling this kit of theirs. Then all of a sudden Jon Oxer from Freetronics finds out that they (Jaycar) have now made their own branded copy of the kit, and are selling that instead. And worst of all, everything is copied almost exactly, even down to the Box, Foam, and almost Word-for-Word in the manual.

So Jaycar obviously decided that they can make more profit by cutting out the small company that did all the development. Very nice Jaycar!

So, if you can, rather buy from Freetronics.com.au instead of Jaycar. That way you can be sure that you are supporting a small business that is trying to make an income, instead of a Large Company just interested in Profits….

 

New Stuff Arriving Soon

Just a heads up, I have several videos planned, and will start shooting in the next day or 2.

I also have some things on their way from Aliexpress, that we will be looking at, taking apart, upgrading, and putting to good use.

So please remember to come back to this page now and then, or subscribe to the youtube channel ShoutingElectronics , That way you will get notified of when I stick more content up (and will also get me a few steps closer to having a shorter URL for my Youtube Channel…….

You can also hit us up on Twitter (@ShoutingElect) or Facebook (https://www.facebook.com/ShoutingElectronics/)

And Remember to check out the other Electronics Blogs I have listed, they are good, and have provided me with lots of inspiration already.

 

P