Clock / timing project

I need some advice on [u]where to start[/u] . The project is in three parts. N.B all devices must be battery operated.

  1. 24 hour clock displaying time to the seconds. with ability to store current time to the 100th of second by the push of a button ability to recall store times ( possible with a sequence number preceding the time) (can limit number stored to 200). [ future enhancement to be able to print out or transfer stored times]

  2. Same feature as above unit but with the ability to enable a 120 second or 60 second count down display .. the trigger for this will be when the clock gets to the start of the next minute. [ countdown display to have 6 leds (5 red one green ) that come on on the last 5 seconds green comes on when clock gets to zero.

  3. Same clock features as the first clock but instead of the push button it is triggered by a beam (laser) or a wifi link to the beam .

cheers footloose

Well I'd start with part 1 naturally ;)

OK, my first question is what accuracy of timekeeping do you want? (in ppm, seconds/day or whatever).

Secondly have you some idea of what kind of display, how big a unit, how long it has to run from on battery power, budget constraints?

For battery power I'd suggest a 2 or 4 line LCD display isn't a bad option. If you can spend a bit more money I've used the TextStar LCD display module a few times, its dead easy to use (but no backlight) http://www.coolcomponents.co.uk/catalog/textstar-serial-display-p-428.html

For wall-clock levels of accuracy the simplest step is to get an Arduino with a proper quartz crystal oscillator, rather than a ceramic resonator (I've has to resolder my Uno to do this, alas). I think the Leonardo is guaranteed to have crystal, but not sure any others these days have (some of the better clones might - check out seeedstudios)

For really good time accuracy the Chronodot is something I've seen used, less than 1 minute a year drift. Otherwise there are various other less accurate RTC boards usually using the DS1307.

For 200 timestamps you'll be able to store that in 4 or 5 bytes each (depending on whether the year matters), or perhaps 8 bytes in a less complressed form - so 1.6kB of storage - that might be cramped on the Uno.

Thanks MarkT Your ideas are along the same lines as mine from my research.

I was going to start with the Leonardo and use the Chronodot RTC to provide the accuracy. A 4 line lcd ( must have backlight) sounds perfect.

Now where can I find information on have to make a push button store the current instance of time and/or another button how to recall it.

I think the hardest part of the project is how to start the 60 second count down on the top of the next minute.

cheers

Now where can I find information on have to make a push button store the current instance of time and/or another button how to recall it.

I'd start with an example project: push a button and change the state of a led. This brings in a few key concepts: pushbutton debounce, pullup resistors, state-based programming vs. sequential programming.

Next step is to write and read data in/out of EEPROM. Like: in the previous sketch substitute "led on" with "write millis() to eeprom", and "led off" with "read back previous saved millis() and print it via Serial".

Next step is print the saved millis() on the LCD.

Next step is make the sketch manage not just one but N saved millis() values.

Next step is substitute millis() value with the data provided by a real rtc clock.

And so on...

My 2 cents.

:)

You will need to read the SQW output of the RTC to provide a reference for the start of each second - then use the difference between the value of millis() now and when the last SQW edge came in - that provides the fine timings. And of course you must read the RTC on the SQW edge in order to have a seconds reading that matches that particular edge. This implies reading the RTC every second using an interrupt routine that also records the value of millis().

Then in the code you just take a copy of the RTC's time value and subtract the recorded millis() from current millis() value.

You can also shutdown just leaving the RTC running, when start back up just have to wait for next SQW signal (once a second) to be ready to take time readings again.

My stopwatch class might be helpful - http://www.arduino.cc/playground/Code/StopWatchClass -

Thanks Rob I'll look at the stopwatch library. my basic requirement here is now a bit clearer. need to capture the milli seconds after each second once the hold button is pressed ie this timer would start counting up on the zero transition of the second or the SWQ trigger , if unless interupted by the hold button, it would reset and start again on the next second. thus showing how far into the second it got before button was pressed.

Things starting to move along , have got basic Ardunio work with RTC and can store and display time onto 16x2 LCD. tring to improve the drift on DS1307 ( there cheap, tring to keep the overall costs down to a minimum).

trying to improve the drift on DS1307

you could adjust the time read from the device with a predetermined drift and adjust the DS1307 e.g. once per hour. You can keep the drift in a float variable and adjust only the whole seconds.

:o Finally had some have found some time to update this post. First of all thanks to all who have contributed in some way to getting this project of the drawing board. What we have so far: (I will get photos up soon) two styles of LED seven segment display clocks. 1. (Check Control IN clock) one has just time HH:MM:SS 2. (Start Line) other has an extra set of 6 8x8 LED dot matrix that show last 5 seconds count down and warning messages. Both these clock have RTC DS3231 to hold time and GPS unit to sync time during setup The Start line clock also has a RF 900MHz tranceiver to act as a remote control unit.

  1. Stage Finish Line detector and clock. This clock has GPS, RTC, RF rxtx, SD and 20x4 LCD display It can be operating in auto mode or manual. Essentially in auto mode it use a remote thru beam sensor to detect the car going past and cause the clock to register the time, to the thousanth of a second. Manual mode use a switch on the unit. It will display the last three time but also store each time to SD card for later retrivial. The time is relayed to the stop control version of this clock for the official the write down. Have been trialing them in the forest for a year now, ironing out the bugs.

..to be continued soon