RTC with milliseconds - Page 1
Forum section: electronics / projects

author: DavidDLC
author_rank: Frequent Contributor
timestamp: July 19, 2012, 10:08:40 pm
content: Does anybody know a Real Time Clock with milliseconds resolution ?If not, a cheap solution to accurate generate milliseconds ?David.

author: David_AVD
author_rank: Super Contributor
timestamp: July 19, 2012, 10:17:12 pm
content: If you can't find an RTC with milliseconds, maybe use the one second interrupt some of them have to reset a separate (free running) milliseconds counter?Maybe expand on your application a little so we know what you're trying to do.

author: Short Circuit
author_rank: Frequent Contributor
timestamp: July 19, 2012, 10:38:09 pm
content: Typically, I use STM32 these days, these have a systick counter, which counts at CPU clock.So I would set up a seconds interrupt from the RTC and snapshot the current Systick. Otherevents which need the msec time could use a combination of the RTC and Systick.Or another hardware timer could be used, which is to be sync'ed on the same secondsinterrupt, after which the hw timer can create the msec interrupts.Or the Systick could be programmed to msec rate, and the RTC only be used for retrieving the'real' time after reset, after which real time is counter by Systick alone.Ok, these, and most other solutions require some sort of microcontroller, but you probably need thatanyway since there is not much use for a RTC time if there's no way of retrieving/storing it somehow/somewhere.

author: MikeK
author_rank: Super Contributor
timestamp: July 20, 2012, 01:18:05 am
content: Define "accurate". I've run RTC's using a PIC's timer and a standard crystal (watch xtal not needed) and gotten within 1 second per day (assuming little temp change).

author: DavidDLC
author_rank: Frequent Contributor
timestamp: July 20, 2012, 04:32:32 pm
content: For camera application, we have a two stages push button, I need to measure the elapsed time between the focus and capture events.I will like to have the accuracy of any standard RTCDavid.

author: Rufus
author_rank: Super Contributor
timestamp: July 20, 2012, 04:48:25 pm
content: Quote from: DavidDLC on July 20, 2012, 04:32:32 pmNothing to do with time of day then so not something you should be calling a clock?Measuring the time difference between two pulse edges is a standard function of frequency counter/timer test equipment. For a one off I suggest buying something, possibly 2nd hand.Easy enough to do with a scope also.Almost any microprocessor can measure time differences with ms resolution, getting fancier processors with input capture/compare peripherals can measure time differences with 10s of ns resolution. Accuracy as good as the crystal oscillator used for the processor clock.

author: DavidDLC
author_rank: Frequent Contributor
timestamp: July 20, 2012, 05:20:36 pm
content: Thanks for your response Rufus, I forgot to mention this will be a standalone project with no instrumentation involved.This time I want to use something more precise than a microcontroller to measure the time, that is way I was asking for an RTC or similar source.David.

author: bilko
author_rank: Frequent Contributor
timestamp: July 20, 2012, 05:36:02 pm
content: You could use GPS for absolute time and the 1PPS output into the micro for timing your events

author: Short Circuit
author_rank: Frequent Contributor
timestamp: July 20, 2012, 05:51:00 pm
content: An RTC is as accurate as it's crystal. So is the crystal-based oscillator on a microcontroller.(not the internal oscillator, nor resonator based; those are rather inaccurate)In other words, both are equally accurate.Or inaccurate, depending on the design.

author: SeanB
author_rank: Super Contributor
timestamp: July 20, 2012, 06:28:04 pm
content: So basically any microcontroller with a high speed timer will do, as long as you can have more than 16 bits of timer, and a variable prescaler to give an input frequency of 1mHz to it, with it being started and stopped by inputs on separate pins.This is likely a portion of code that will have to be written in assembler, so as to get each part of the loops to be a constant number of clock cycles and as short as possible.

author: gxti
author_rank: Frequent Contributor
timestamp: July 20, 2012, 07:59:26 pm
content: Most microcontrollers that I've looked at have some sort of "input capture" facility as part of their larger timer peripherals. These can be used to automatically save a timestamp when a logic input goes high (or low) and fire an interrupt. This gets you accuracy to within one cycle, which for example on a 10MHz crystal is 0.1 microseconds.If you just want milliseconds, you don't even need input capture -- just have one timer, and when the pins you are interested in change, have your interrupt routine or polling loop save the timer value.As "Short Circuit" says, a microcontroller's timer works exactly like a RTC's timer in that it's just counting cycles of a crystal oscillator and there's no difference in accuracy. Buying a separate part isn't going to do any good.

author: d15ea5e
author_rank: Newbie
timestamp: July 20, 2012, 10:03:18 pm
content: Take a look at Microchip RTCC products. Quick view at datasheet of MCP79510 shows that is supports time accuracy of 0.01 sec (including alarm). Is that enough? If not RTCC can output clock (4094Hz for example), which you can count using uC.Link:http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en556366