Do I need a Real Time Clock?

Hi everyone,

I'm still very new to Arduino, but I am already working on a project. The problem I've encountered is that I need to count down the time precisely (down to milliseconds) while controlling some external hardware, like servos. Is it achievable with the bulit-in clock or do I need to mount a separate RTC?

Filip

You haven't really given enough information to tell. Put some numbers on your timing requirements. The word "precisely" is useless without a number to tell the precision expected. Do you want 1ms over a 10 hour measurement (0.028ppm)? Or 1 ms over a 1 second measurement (1000ppm)?

I need something like 1 ms over 5 minutes

FilipS:
I need something like 1 ms over 5 minutes

Then yes, you'll probably want an RTC.

Ok, added to my shopping list :slight_smile: Thanks for help

1 millisecond in 5 minutes is 3 parts per million accuracy.

If you plan on timing to milliseconds, an RTC probably won't be useful, because the commonly available ones keep time in seconds. If you are timing in seconds, then the DS3231 is good to 3.5 PPM. The DS1307 is not.

It would be much easier to use an Arduino with an accurate crystal (3 PPM or better), but you may have a hard time finding one.

Here's an RTC with millisecond resolution. The fact that most Arduino users don't have the need is hardly any indication that it doesn't exist.

Delta_G:
Here's an RTC with millisecond resolution. The fact that most Arduino users don't have the need is hardly any indication that it doesn't exist.

http://www.ti.com/lit/ug/sprufo7/sprufo7.pdf

Actually, its unit is not a millisecond but rather 1/1024 second. They admit as much in the docs.

odometer:
Actually, its unit is not a millisecond but rather 1/1024 second. They admit as much in the docs.

Ok, even better than millisecond resolution then. The point is that you can get milliseconds using it.

The fact that most Arduino users don't have the need is hardly any indication that it doesn't exist.

What an odd statement to make!

BTW what algorithm do you use for getting millisecond ticks out of a clock that ticks every ~0.9766 ms? Just curious.

Hi,
What is the application that needs that precision over 5minutes?

  1. Are you doing timing comparisons between items and comparing them to each other?
    OR
  2. Are you doing timing comparisons between items and comparing them data from another timing source?

If 1) then use the internal millis() function, as you are comparing the times with the same timing unit.

If 2) then you will need an external reference.

You may need to take temperature stability into consideration if you are concerned with milliseconds.

Tom.. :slight_smile:

Servos also take time to respond to any control direction.

jremington:
What an odd statement to make!

BTW what algorithm do you use for getting millisecond ticks out of a clock that ticks every ~0.9766 ms? Just curious.

I don't need millisecond ticks for 5 minutes. It's 5120 ticks. He asked to be within a millisecond. He will be.

Delta_G:
I don't need millisecond ticks for 5 minutes. It's 5120 ticks. He asked to be within a millisecond. He will be.

Exactly, as long as you know a "tick" is 0.9766ms, you will always be within a millisecond when you convert "ticks" to real time.

Algorithm
RealTime = ticks * (realtime for tick)
RealTime = ticks * 0.9766ms
Tom... :slight_smile:

FilipS:
Hi everyone,

I'm still very new to Arduino, but I am already working on a project. The problem I've encountered is that I need to count down the time precisely (down to milliseconds) while controlling some external hardware, like servos. Is it achievable with the bulit-in clock or do I need to mount a separate RTC?

Filip

What exactly is your project intended to accomplish?

You could use an RTC to keep time down to seconds, then time each second using Arduino's millis() or micros() function. The duration will only be 1 second, so the drift will be minimal (typically <1ms.)