# LCD DATE/CLOCK Forget the RTC

162

2

## Introduction: LCD DATE/CLOCK Forget the RTC

A NIST 2010 quantum logic clock based on a single aluminum ion .

In 2010 an experiment placed two aluminum-ion quantum clocks close to each other, but with the second elevated 12 in (30.5 cm) compared to the first, making the gravitational time dilation effect visible in everyday lab scales. Thus reproving Einstein's gravity theories. The clocks were reversed in positions and showed the same time offsets. NIST postdoctoral researcher James Chin-wen Chou with the worlds most precise clock, based on the vibrations of a single aluminum ion (electrically charged atom). The ion is trapped inside the metal cylinder (center right). He says 'off by 1 sec in 3.7 Billion years' ...lets wait and see!

SUPER DUPER WOW.

So by using quantum vibrations which is really fast, you think faster is better. The 328 chip in Unos is sorta fast at 16mhz. That is far faster than the typical clock (watch) crystal that is 32.768 khz. That is 500 times faster ! And the 328 has a temperature sensor to compensate the clock.

So why can't the 328 out preform a cheep watch crystal?

### Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

## Step 1: WHAT TO EXPECT

This is my second attempt to make a clock using ONLY the 328 chip. Each 328 runs at different times even though they have a 16mhz crystal. So you get poor results just counting millis(). Which runs at 1,000 hz. This makes ONE millis(1) average out to about +- 3.6 seconds per hour accurate. Arduino mills() dosen't count factional mills or use floats. This makes counting fractions of a mill impossible. So using Arduino micros() is the next choice. But using micros() runs out in just 71 minutes. (this really is NOT a problem). The problem for me is dealing with the large numbers and making repeated adjustments based on gps clocked time. Another choice is an interrupt. This counts the seconds no matter where the code is running inside the loop. This makes the 328 as good as a RTC. Even if the specks of the 'micros()' are considered, at +- 4 uS, this works out to be a 250khz clock. That is 7 times better than the 32.768khz.

So here is my Arduino lcd clock based on a 16bit timerOne interrupts using microseconds. It is not quite as good as counting aluminum ions! But it is easy and with some calibrations it can be as good as a RTC. I have made 3 versions of this clock. From connect to computer usb. To stand alone with 4 buttons. To outside gps with temperature using a HC12. This instructable will cover the first 2 clocks and I will write another 'in depth' for the HC12.

See my other instructable on HC12 range problems.

What you can expect is an easy lcd clock/date using UNO and a 16x2 lcd. I made some custom numbers for the lcd. The 'BIG numbers' library take up 3 spaces, mine just 1. The 4 button have internal pull up so the build is easy. I have a case for this and a 2 lcd and backs.

The public library here in my small town has a 3d printer anyone can use. So check out a library near you for making the lcd case.

My tests show -+ second every 24-48 hours. That is about one minute off in two months. Three or four adjustments put the clock spot on. Only off by about 12 seconds pre MONTH. Repeated attempts to 'calibrate' seams to just be chasing numbers. The one BAD feature is using ANY 'menu' resets the seconds to 00. This changes the current time. I did leave a 60sec timeout for the button press as to allow for synk with another clock.

## Step 2: THE NUTS AND BOLTS

This project is a STAND ALONE clock without RTC just a uno and lcd. The 4 buttons allow time/date set and adjust time zone and calibrate.

The 3d printer files have a one and two lcd case for other projects.

The lcd has BIG NUMBERS that take up only ONE space wide. This took me quite some time to do

The case has 8 holes for buttons for other projects.

Just connect a 5v wall wart for power.

Check your local LIBRARY for use of a 3d printer !!

## Step 3: ABOUT THE BUILD

Any Arduino boards with MEGA 328 micros should work. It needs a 16mhz crystal and must be running at that speed. A 3.3 volt at 8mhz may not work with the interrupt timing. For the enclosure case a pro-mini fits best but you may squeeze a nano in but the usb cable may be a problem. This is a Hitachi 16x2 lcd, very popular. Some cheep ones are DULL and just faint. An edge connector is needed to fit a popular I2c converter module. Only 4 wires are needed to hook up to the uno. There are many tutorials to show how to hook up the lcd without a converter module if you do not want one. For the no button clock that is all you do.

The lcd has a BIG NUMBER custom char. The big numbers take up only ONE width.

## Step 4: 4 BUTTONS and CASE

The same as above but add the 4 switches. A standard pc board 2inch x 2.5 inch is used to fit the case. Just cut in half and install the switches so the legs go left to right. If you put the switches with legs up the holes will not line up in the case. Test that they line up to the case holes BEFORE soldering. Ground the bottom legs (all) and run each top leg to a pin on the uno. See enclosed schematic. If you 3d print the case, the button part needs to be GLUED to the lcd case. It does NOT snap in like the back does. Any small self taping screws will hold the lcd in place. TOO big and you will crack the case. Hot glue stick may be the best. Before mounting the lcd...blacken the led area with black tape. Otherwise it will shine through the case. I use 2 side foam tape in 2 layers for mounting the pro mini. This tape is a bargain at 'dollar tree stores'. I use solid coated magnet wire about 26 gauge. I have a great instructable on 'a poor mans solder pot' for using this wire in hookups.

lcd problems

## Step 6: HOOKUPS

follow the schematic and wire the unit.

## Step 7: OTHER PHOTOS

good luck PLEASE see my other instructables

## Step 8: THE SKETCH

instructables won't let me download a Arduino file !!!! so I used text. You will have to copy and paste the text into a NEW arduino open file at the IDE.......SORRY

and the text files wont load either !!! and tried to paste here but jumbled it up !!

TRIED ANOTHER TEXT FORMAT ... ALL SKETCHES WORKED !!!

SO YOU CAN COPY AND PASTE 'EACH' OF THE 3 TO SEPARATE ARDUINO SKETCHES

HOPE THEY FIX THE ARDUINO SKETCH PROBLEM

The people who get paid to write code are rolling on the floor when they see my code. My sketches usually start out simple. Then I add more things to do. So the sketch gets twisted into a mess. I hope you learn from my two biggest mistakes. There should be a defined outline and goal at the start. Not add tons of stuff throughout the sketch. My worst mistake is to misuse a FUNCTION. It should be brief and return a sum, and used only when it replaces repeated lines of code throughout the sketch. delay(100) is a good example.

My use of a FUNCTION is to separate sections of the sketch. This leaves the main body easy for me to follow as well as allowing to debug separate sections just by calling the function. I think that GOTO used to do this but it has fallen from favor and NEVER gets used. Nuff said. I checked the dates and times as best as I can. The same parts of the sketch runs my 'TIME SQUARED' clocks for years. If I missed something or there is a bug please let me know. To calibrate the 'no buttons sketch' the line with 'unsigned long tSec = 1000122; ' (line 34) is what you change. The constant of 277 per second per hour is correct. But in practice I make only 2 to 8 amount changes to 'tSec' value. At 1000122 many of my clocks ran as good as a RTC. Be patient a small change of only 2-8 can become a perfect clock. The down side of any changes for either clock means that the current time WILL be altered. You will need to change to the correct current time/date.

//
// easy_one_lcd_clock_no_buttons // // arduino and lcd clock // use timerOne 16 bit timer // to calibrate this clock: // use a good seconds clock like a GPS. // use hours as baseline. Count seconds // THIS is off. If THIS is behind a GPS // GPS=00..THIS=58 SUBTRACT 277 for each // second/hours. So if slower by 2 sec in // 3 hours... (277 * 2)/3 = 184 // SUBTRACT from tSec. // if THIS is ahead GPS=00...THIS=03 // same math just ADD to tSec. // cauction, most clocks correct at 00. // 20 sec is a better timer check.

## Step 9: CASE STL Files

Here are the 3d printer case files. The keypad needs to be glued to the lcd case. The back snaps unto both the one and two lcd case front. Snap the top in first then work your way down to get a nice fit.

CHECH OUT your local LIBRARY for the use of a 3d printer.

13 1.7K
13 1.4K
255 20K