Pages: [1]   Go Down
Author Topic: Very simple lcd clock to test the internal clock accuracy (no RTC)  (Read 1675 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I needed to check the accuracy of the internal clock of Arduino for another project, so I wrote this code. Only Time and LiquidCrystal libraries are included. Not that fancy but the accuracy turned out to be fine. Error<1 min for a day. With addition of a few buttons, you can set the time. Yet I am not sure if powering the board with USB or 9V battery would change the accuracy or not. I would appreciate any comments on that.

Cheers,
Bb


Code:
#include <Time.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

//set the current time here
int s=30;
int h=0;
int m=5;

void setup(){
  lcd.begin (16,2);
  delay(500); 
  lcd.clear();
  lcd.print("Current Time:");
  lcd.setCursor(0,1); 
}

void clc(){
  lcd.clear();
  lcd.home();
  lcd.print("Current Time:");
  lcd.setCursor(0,1);
}

void loop(){
 
  lcd.setCursor(0,1);
  while(millis()%1000 != 0);
  s +=1;
  if(s==60){ s=0; m +=1;}
  if(m==60){ m=0; h +=1;clc();}
  if(h==24){h=1;}
 
  lcd.print(int(h/10));
  lcd.print(h%10);
  lcd.print(":");
  lcd.print(int(m/10));
  lcd.print(m%10);
  lcd.print(":");
  lcd.print(int(s/10));
  lcd.print(s%10);
}


* lcdclock.jpg (235.56 KB, 1024x682 - viewed 82 times.)
Logged

0
Offline Offline
Faraday Member
**
Karma: 23
Posts: 3470
20 LEDs are enough
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The clock accuracy is almost completely independent of the power. I have investigated this quite a lot. If you need better accuracy the best way is to use a external time signal like GPS or DCF77 or whatever else is available in your country. If you need an internal clock DS3232 is a superior RTC chip.

You can find my clock investigations here:
http://blog.blinkenlight.net/experiments/measurements/crystal-deviations/
http://blog.blinkenlight.net/experiments/measurements/crystal-deviations-2/
http://blog.blinkenlight.net/2013/01/01/dcf77-project-part-1-get-ready-for-the-real-thing/
Logged

Check out my experiments http://blog.blinkenlight.net

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can calibrate your internal clock using GPS within minutes of effort.  Once you adjust the frequency in software it is very accurate until you make a significant change in temperature.
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

0
Offline Offline
Faraday Member
**
Karma: 23
Posts: 3470
20 LEDs are enough
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Depending on the crystall cut the impact of temperature may be 2ppm / Fahrenheit or more. A typcial reason for a "significant change" in temperature is switching on or off. With other words: unless you have temperature control GPS calibration will not help to much.
Logged

Check out my experiments http://blog.blinkenlight.net

Pages: [1]   Go Up
Jump to: