In an exam today I was asked to design 2 circuits that would keep an output turned on for 10 minutes. I used a 555 Timer and a PIC, but neither are the best solution if the time delay needs to increase. So what other options are there for creating long time delays, many hours/days of timing to a few milliseconds accuracy(1000's of a second)?
-
\$\begingroup\$ can you define what you mean by accurate? \$\endgroup\$– KortukCommented May 18, 2011 at 19:09
-
\$\begingroup\$ @Kortuk edited question. \$\endgroup\$– DeanCommented May 18, 2011 at 19:18
-
1\$\begingroup\$ A great example of this is the Apollo laser ranging experiments. They are trying to get ~mm accuracy out of a 384'400km measurement by keeping time over about 2.5 seconds, corresponding to ~7ps single-shot resolution. I'm not sure how they're doing it, but hopefully statistically (characterize over many measurements), 'cause 7ps ain't much! \$\endgroup\$– tybluCommented Oct 3, 2011 at 2:15
-
\$\begingroup\$ @Dean Can i know the problems you faced while designing the circuit using 555 timer. I also want to design a circuit which would keep the output turned on for ten minutes. When I worked with it I got an error in the output time which might be due to the tolerances of resistors and capacitors. So I am wondering if i will be able to replace the normal resistor and capacitor with precision ones. \$\endgroup\$– JasserCommented Mar 22, 2015 at 9:02
-
\$\begingroup\$ Are we facing with any other problem other than that. @Dean \$\endgroup\$– JasserCommented Mar 22, 2015 at 9:03
4 Answers
The best option for long time delays are Microcontrollers. The are simple, inexpensive, and relatively easy to use. Doing millisecond accuracy over days is easy.
The only trick to doing a multi-day timer is that you need to use two timers: a hardware timer and a software timer. For example: Set the hardware timer to generate an IRQ every 1.0 mS. In the ISR (interrupt service routine) increment a 32-bit counter on each IRQ. So when this software counter gets to 1000 then 1 second has gone by. Doing this will mean that the 32-bit counter will roll over at about 49.7 days.
You can go longer than 49.7 days if you use a larger counter, like 48 or 64 bits.
The accuracy of this system will depend on the accuracy of the clock used for the microcontroller. Most quartz crystal oscillators are good to about 100 ppm (parts per million), although 20 ppm crystals are readily available. More accurate than 20 ppm is doable, but the cost goes up and the availability of parts goes down.
-
\$\begingroup\$ If you don't have a microcontroller that can do 64 bit numbers, then you can always use multiple 16 or 32 bit counters to get the same result. \$\endgroup\$– DaveCommented May 19, 2011 at 3:59
-
7\$\begingroup\$ "millisecond accuracy over days" would mean about 10 ppb = 0.01 ppm. \$\endgroup\$– starblueCommented May 19, 2011 at 5:44
-
\$\begingroup\$ with any microcontroller you can daisy chain the adders and make the counter width as wide as you like, say a 256 bit or 512 bit millisecond counter for example. (know the accuracy of your clock source though and how that affects the accuracy of your time measurement over long periods) \$\endgroup\$ Commented May 22, 2011 at 14:40
-
1\$\begingroup\$ You're more detailed about resolution than accuracy. Dean needs an accuracy at least 2 orders of magnitude better than 20 ppm, but you don't say how to achieve this. \$\endgroup\$– stevenvhCommented Jul 30, 2011 at 15:36
The microcontroller is the way to go. Quartz crystals are known for their accuracy, but even that is relative. Standard crystals are 100 ppm, you pay extra for 20 ppm. 100 ppm doesn't sound too bad, but it's only 0.01%, and may give you an error of up to 8 seconds a day, or more than 4 minutes(!) per month. Even the 20 ppm results in an error of 2 seconds per day.
The solution for timing long periods is to synchronize your timer to a high precision clock. DCF77 (Europe) and WWVB (North America) send a pulse every second, a timing derived from an atomic clock. You could count these second pulses for timing the longer periods and for sub-second timing rely on the crystal.
edit
The picture shows a DCF77 receiver module by Conrad:
-
1\$\begingroup\$ +1 you simply NEED an external reference to an atomic clock in order to have accuracy long-term. Oscillators drift by one or two PPM throughout the day; even if it was just calibrated you won't be able to keep 10 PPB accuracy for more than half an hour. \$\endgroup\$– ajs410Commented May 23, 2011 at 16:38
Accuracy requires stability and calibration.
Typically, you'll start out with a crystal that is already calibrated to a some degree of accuracy, with a known stability characteristic. You then have to ensure that the accuracy and stability errors will meet your performance requirements.
With a 100ppm device, you get up to roughly 5 minutes of drift per month.
If you read various datasheets on battery-backed RTC's, they all will emphasize the need to choose a clock source that is stable over temperature, age, and voltage; and for long-term accuracy, the completed system should be calibrated to a know reference time source and adjusted -- many RTC's have a "trim" register that lets you add/subtract a few "ticks" over a period of time to adjust for the small variations between units. You can use this technique with a MCU as well.
Separately, if your accuracy resolution is measured in terms of seconds, over a very long period of time, you can get reliable 60 Hz from the power line. (Wikipedia) - just make sure there's a secondary counter to handle blackouts.
EDIT --
BTW, I thought I recently saw a news article about NIST having developed a super-stable transportable atomic clock that sat inside the rear cargo space of a minivan; but I couldn't find it. But during that process, I came across this interesting "atomic clock" that was recently announced.
EDIT --
Ah, I found the article about a portable super-stable laser that would be used for a portable atomic clock! This is not very practical for the most of us, but I thought it was an interesting piece.
-
\$\begingroup\$ @ToyBuilder, often the easiest way to make ultra high resolution time clocks is counting frequency from the mains voltage. Very easy, source is given, you just have to count. \$\endgroup\$– KortukCommented May 19, 2011 at 0:21
-
\$\begingroup\$ @Kortuk - from what I interpreted from Wikipedia, however, it appears that they target for 60 Hz, but may be off by a few seconds on any given day. That doesn't sound like a truly great "ultra high resolution"... \$\endgroup\$ Commented May 19, 2011 at 8:58
-
1\$\begingroup\$ That chip-scale atomic clock looks really cool. There are definitely uses for such precision. If one could get such precision in a cheap low-power device (dreaming, I know) one could greatly improve the network efficiency and reduce the network acquisition time of things like cell phones. Though actually what I'd like to see would be a standard time signal that would be broadcast nationwide using repeaters (perhaps piggy-backing on cell-phone equipment). WWV is slow, and reception is spotty at most times of day. If a communications device could power on and... \$\endgroup\$– supercatCommented May 19, 2011 at 15:21
-
1\$\begingroup\$ ...within a second (and without using too much energy) be able to know within 10ms or so what time the device it wanted to communicate with would think it was, that would make it much easier for low-power devices to maintain occasional communication. \$\endgroup\$– supercatCommented May 19, 2011 at 15:22
-
2\$\begingroup\$ @0xakhil - It can vary by a few milliseconds per day, but they synchronize it every 24 hours to an atomic clock (imagine if two power generation stations were out of sync...). For long-term timing (on the order of years), I don't think there are any other mechanisms that approach power line clocking for prevention of long-term drift. \$\endgroup\$ Commented May 23, 2011 at 3:39
GPS Disciplined Oscillators are the standard technique to generate a highly accurate timing reference. The GPS Timing receivers output a 1 pulse per second that's jitters short term 30 to 50 nSec, and long term is as accurate as a bunch of Cesium atomic clocks can be. This is used in a PLL to correct a high frequency crystal oscillator, which is then used as a frequency reference.
For example take a look at the Trimble Thunderbold E
http://www.trimble.com/timing/thunderbolt-e.aspx?dtID=features
Cell phone base stations are already referenced to a GPS receiver, and so are accurate to a fraction of a PPM in their transmitted frequency.