1

I'm making a stopwatch that will measure time between two points.

I want that stopwatch to have a millisecond accuracy.

After the start when someone touch the pad it will show like the time of the touch (15.359) 15 seconds and 359 millis.

I have an arduino uno board. Everywhere I read it says that millis its not reliable, and in a feel tests it seems not very accurate. Also a lot of places say to use a RTC, but every RTC I found and read about it seem to use only second and not milliseconds. Others say to use a 32 KHz crystal, but I'm not sure if it will fix this. Could anyone give some ideas?

The Arduino will only record time, only that, start and get time and subtract and write on the serial and end.

Thanks! update 1: thanks Mattia for the edit.

update2 : I was making some math, and if the device is on for 8 hours, and i want millisecond precision i need something like 30ppb right? Would this do the job? http://www.digikey.com/product-detail/en/abracon-llc/AOCJYR-12.800MHZ-M5649LF/535-12624-1-ND/4989030

  • Use a precision oscillator (possibly temperature compensated), then measure its time. You can find even 5ppm oscillators, which means that you can have an accuracy of one millisecond for times less than 200 seconds.. – frarugi87 May 13 '16 at 13:18
  • Some RTC can also output a frequency. E.g. the DS3231 can output a 1Hz, 1.024kHz, 4.096kHz, 8.192kHz square wave. This frequency is quite precise, as it's temperature compensated. You could use it, and count the number of pulses between the two touches. Might I ask what you are using to detect a touch? I hope you are not using CapSense for this. – Gerben May 13 '16 at 13:40
  • Theres a touchpad, that when someone touch theres a contact similar to a button, i just read LOW or HIGH on arduino to know if someone touchs it. I'll read about count the pulses. thanks – Eduardo Estevão May 13 '16 at 13:47
  • For a ms in 8 hours, I get ~ 1 part in 30 million: (8hrs * 3600 sec/hr * 1000 ms/sec = 28,800,00 ms). – JRobert May 13 '16 at 20:27
  • Yes! 28,800,800! But i have to multiply over the 20/1.000.000.000 in this case from the crystal right? to know the precision? because i dont found any 1/30ppm crystal, neither 0.33ppm. I'm probably messing up everything, first time working with this math. – Eduardo Estevão May 13 '16 at 21:14
1

The resonator on the Arduino Uno is better than the internal oscillator of the Atmega328p, but still not very precise. Therefore, for accurate measurements, you need to use a better quality crystal. For instance @ 16 MHz. Once you set the correct prescaler in the Arduino, this should give you accurate millis() - as long as the crystal that you're using is accurate.

  • Do you know or have any material for implemente the crystal on arduino? i'll also look more for it. thanks – Eduardo Estevão May 13 '16 at 13:25
  • Here's a starting point: google.com?q=Temperature+Compensated+Crystal+Oscillator+16+mhz – Dampmaskin May 13 '16 at 13:34
  • From what I read, Eduardo isn't using the internal oscillator. He says he's using an Arduino Uno, that already has an external crystal. – Gerben May 13 '16 at 13:35
  • You are right, my bad. I have corrected my answer. The 16 MHz external oscillator of the Uno is probably miles ahead of the internal 8Mhz oscillator in the Atmega. Still, it's a relatively cheap resonator. I reckon that replacing it with a high quality oscillator can increase the precision by many orders of magnitude without breaking the bank. See this thread for a comparison: forum.arduino.cc/index.php?topic=60662.0 – Dampmaskin May 13 '16 at 13:44
  • I'm even considering get an expensive (until 30$ maybe) crystal to get a better precision. There a good "brand" or any that you or anybody vouch for? – Eduardo Estevão May 13 '16 at 13:49

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.