# Very accurate Stopwatch

How accurate can i make a stopwatch?
I will measure 1/100 sec or better 1/1000sec over some Houres.
I think with the internal clock i become deviations by some seconds.

You can make it as accurate as the crystal. I don't know the spec of the crystal used but most are something like 30 ppm that is 30 parts per million. So in a million seconds you could be up to 30 seconds out.

But it also Influenz by temprature.

But it also Influenz by temprature.

Spelling, too. No wonder your clock isn't very accurate.

ripper121:
But it also Influenz by temprature.

That is true, although there are ways to mitigate that effect (Google temperature compensated crystal oscillator).

Not sure what the exact accuracy requirement is, but if I interpret "1/1000sec over some Hours" to mean that accuracy of one millisecond per day is required, then that is on the order of 10 ppb (parts per billion) which gets into the realm of specialized frequency standard equipment. There are relatively inexpensive rubidium standards available on the surplus market these days.

I have made arduino equivalents with better 16 MHz crystals that do not deviate over the course of a day.

I use simple counters for each digit to track MM:SS:TH while only display MM:SS.
(vs using modulo to divide the count up or something)
Could display more, didn't have a need.
(following not compiled, but gives you the idea of what's needed)

``````void loop(){
currentTime = micros();  // currentTime, previousTime, duration all unsigned long, rest are bytes
if ( (currentTime - previousTime)>=duration){
previousTime = previousTime + duration;  // duration = 1000uS = 0.001S
thousands = thousands+1;
if (thousands == 10){
thousands = 0;
hundreds = hundreds+1;
if (hundreds ==10){
hundreds = 0;
tenths = tenths+1;
if (tenths == 10){
tenths = 0;
onesSeconds = onesSeconds+1;
if (onesSeconds == 10):
onesSeconds = 0;
tensSeconds = tensSeconds+1
if (tensSeconds == 6){
tensSeconds = 0;
oneMinutes = onesMinutes+1;
if (onesMinutes ==10){
oneMinutes = 0;
tensMinutes = tensMinutes+1;
if (tensMinutes == 6){
tensMinutes = 0;
onesHours = onesHours+1;
if (onesHours == 10){
onesHours = 0;
tensHours = tensHours+1;
if (tensHours == 2 && onesHours == 4){  // or use 12
onesHours = 0;
tensHours = 0;
} // 12-24 hour reset
} // onesHours rollover
} // tensMinutes rollover
} // onesMinutes rollover
} //tensSeconds rollover
} // onesSeconds rollover
} // tenths rollover
} // hundreds rollover
} // thousands rollover
Serial.print(hundred);  // set Serial.begin(115200);  very fast.  Or send this info to an LED display for example
Serial.print(tenths);
Serial.print(":");
Serial.print(onesSeconds);
Serial.print(tensSeconds);
Serial.print(":");
Serial.print(onesMinutes);
Serial.print(tensMinutes);
Serial.print(":");
Serial.print(onesHours);
Serial.println(tensHours);
} // time check
} // end loop
``````

And add code to read pushbuttons, to freeze the time display, reset the time, etc.

I have made arduino equivalents with better 16 MHz crystals that do not deviate over the course of a day.

Yes but the OP needs to be specific about the accuracy requirement. If it really is milliseconds over some number of hours, a 10 ppm crystal isn't good enough, by about three orders of magnitude. I have to wonder though if the requirement isn't really to have resolution to milliseconds, and accuracy of 10-20 ppm in which case such a solution should be fine.

+/-10 Frequency Stability - +/-10 Frequency Tolerance is the best you can do thru hole at 16 MHz
Can only improve slightly to +/-9 & +/-10 going to surface mount

Part like DS3234, SPI interface with internal oscillator, can do a l ittle better
? Accuracy ±2ppm from 0°C to +40°C
? Accuracy ±3.5ppm from -40°C to +85°C
but you only get 1 second updates, any interpolation down to 0.001 second is prone to the same inaccuracy of the Arduino clock.