Precise Time: from CPU clocks to hacking the...
Transcript of Precise Time: from CPU clocks to hacking the...
Precise Time: from CPU clocks Precise Time: from CPU clocks to hacking the Universeto hacking the Universe
Tom Van BaakFOSDEM’15
Brussels, 1 February 2015
v1.7
tvb FOSDEM 2015 2
Outline
• Part 1 – computers and timekeeping• Part 2 – time and frequency• Part 3 – amateur timekeeping• Part 4 – powers of ten• Part 5 – kids, clocks, and relativity
tvb FOSDEM 2015 3
1. computers and timekeeping
• A long ago:– computers were calculators, not clocks– time was for people, not programs, and– it came from astronomers, not atoms
• Photos/influences from the early days:– first leap second, 1972– my first 3 computers– a CPU test program that deeply affected me
tvb FOSDEM 2015 4
1972 computer: NCR 200
tvb FOSDEM 2015 5
1974 computer: GE 635
tvb FOSDEM 2015 6
1976 computer: Honeywell 6620
tvb FOSDEM 2015 7
Instruction timings (GE 636)• computers, clocks, precision, accuracy, measurement
tvb FOSDEM 2015 8
1980 timekeeping was simple
• UNIX timekeeping (System-III, PDP11/34)– time(), sleep(), (gtime: stime: alarm:)
tvb FOSDEM 2015 9
2015 timekeeping is complex
• clock(), gettimeofday(), TIME-TAI, TIME-UTC, TIME-MONOTONIC, TIME-THREAD, TIME-PROCESS, TIME-DURATION, tv_sec, tv_usec, tv_nsec, POSIX, TOY, TAI, TAI64, leap second, ISO 8601, granularity, resolution, drift, precision, jitter, adjtime(), NTP, PTP, QueryPerformanceCounter, RDTSC
tvb FOSDEM 2015 10
Engineers get timekeeping
• Software and hardware timing:– kHz, MHz, GHz (rate, speed, frequency)– ms, µs, ns, ps (duration, period, time interval)– time_t, tv_sec, tv_usec, tv_nsec, ticks, jiffy– disk storage: data rates, latency– network communication speeds, ping times– cpu instruction times, cache misses, OOE– video frames, USB packets, SPI, I2C
• Makefiles, databases, synchronization
tvb FOSDEM 2015 11
2. time and frequency
• What is time?– so obvious we don’t usually ask– so mysterious we don’t actually know
• Some cute (but circular) definitions…– “Time is what clocks measure”– “Space is what prevents everything from
being in the same place”– “Time is what prevents everything from
happening at once”
tvb FOSDEM 2015 12
Basics: time, time interval
• Seems like two kinds of time?– date & time, time-of-day, when (earth)– duration, time interval, how long (timer)
• Time interval: time(A) to time(B)– distance “space interval”: point(A) to point(B)
• Time-of-day = time interval: then to now– people simply agree on “then” (aka epoch)– 1 AD, 1858-11-17, 1970-01-01, 1980-01-06
tvb FOSDEM 2015 13
Basics: frequency, clock
• Frequency = periodic events over time– count the events (e.g., 51.0 cycles)– measure elapsed time (e.g., 1.004 seconds)
• Units: “per second”, 1/second, s-1, Hz– frequency is a ratio (as length, mass, etc.)– period = 1 / frequency (20 ms : 50 Hz)
• Clock = frequency plus counter– analog (hands) or digital (symbols)
tvb FOSDEM 2015 14
Chronometer adjust (time, rate)
tvb FOSDEM 2015 15
Frequency adjust
tvb FOSDEM 2015 16
Time adjust (20 ns)
tvb FOSDEM 2015 17
What (where) time is it?
tvb FOSDEM 2015 18
Basics: clock comparison
• Compare clock time– difference: (t1–t0) seconds, ms, µs, ns, ps
• Compare clock frequency– ratio: (f1/f0) or relative (f1-f0)/f0 [unit-less]– measure slow time drift between clocks
• No two clocks are identical!– are you looking close enough?– or, are you waiting long enough?
tvb FOSDEM 2015 19
Astronomy and clocks
• Earth/sun orbit is a clock (unit: year)– 365.24219265 d/y (ratio)
• Moon/earth orbit is a clock (unit: month*)– 27.321662 d/m (ratio)
• Earth rotation is a clock (unit: day)– 86400.002117 s/d (ratio) today*
• Pulsar 1937+21 is a clock (unit: blink)– 0.0015578065 s = 641.92825 Hz
tvb FOSDEM 2015 20
Basics: clock stability
• Don’t care about time (can set)• Don’t care about frequency (can adjust)• We care about consistency of frequency
– stability, or instability (lower is better)– a standard deviation* called sigma
• Stability is measured by sampling– the sampling time interval is called tau
• Allan deviation, log-log sigma(tau) plot
tvb FOSDEM 2015 21
Basics: summary
• Time• Time interval• Frequency• Clocks• Clock comparison• Offsets/adjustments, time & frequency • Frequency Stability• Time Accuracy
tvb FOSDEM 2015 22
3. amateur timekeeping
• Two kinds of clocks(1) My own clock; with precise oscillator
– wide variety of DIY clock projects– set once, then occasionally compare
(2) My own clock; but “borrow” the time– radio clocks (WWVB, DCF77, GPS)– power line (50/60 Hz mains) wall clocks– network clocks (telephone, cellular, NTP)
tvb FOSDEM 2015 23
A DIY quartz analog/LED clock
tvb FOSDEM 2015 24
How to keep time?
• “Timebase” required (quartz oscillator)– how accurate is it?– how to measure it?
• Use frequency counter– how accurate is it?– how to measure it?
tvb FOSDEM 2015 25
Accuracy
• 0.01/10.00 MHz = 0.1% (~86 sec/day)• 0.0001/10 = 10 ppm (~0.8 sec/day)
tvb FOSDEM 2015 26
More accuracy
• Better timekeeping needs better timebase– better measurement requires better counter– better counter requires better reference
• What does it mean to “keep” time?– who’s time are we actually keeping?– WWVB, DCF77, NTP, Loran-C, GPS time– what is UTC; how good are atomic clocks?
• This time stuff is all so interesting
tvb FOSDEM 2015 27
The quest for better oscillators
tvb FOSDEM 2015 28
The quest for more digits
tvb FOSDEM 2015 29
Slippery slope
• More oscillators, more test equipment– quartz, rubidium, cesium standards– microseconds, nanoseconds, picoseconds
• Most modern technology depends on:– precise time synchronization– stable frequency references
• Books, articles, op/svc manuals, HPJ– danger: catch the “time bug”
tvb FOSDEM 2015 30
Home time & frequency lab
tvb FOSDEM 2015 31
Museum of hp clocks
tvb FOSDEM 2015 32
HP quartz
105B 107BR 106B 104AR 103AR 101A 100ER
tvb FOSDEM 2015 33
HP clocks
HP01 571B 5321 117A 114BR 115BR 113AR
tvb FOSDEM 2015 34
HP cesium & rubidium
5071A 5065A 5062c 5061B 5061A 5060A
tvb FOSDEM 2015 35
Vintage hp 5061A (eBay)
tvb FOSDEM 2015 36
FYI: cesium (caesium)
• Cesium atomic clocks are not radioactive• They use a natural, stable Cs133 atom, not
the scary man-made radioisotope Cs137
• Analogy: C12 vs. C14
• K39 vs. K40 (banana)• “hyperfine transition”
9,192,631,770 Hz• Solid / liquid [28 °C]
tvb FOSDEM 2015 37
First radioactive cesium clock!
tvb FOSDEM 2015 38
What is the best clock?
• Quartz: inaccurate and drifts• Rubidium vapor: more stable but still drifts• Cesium beam: better still and no drift• Hydrogen maser: most stable, small drift• UTC is “average” of 364 clocks [w1412]• Exotic ion, “fountain”, optical clocks• No one best clock, no perfect time
tvb FOSDEM 2015 39
“Keeps perfect time”
• quartz • art deco
tvb FOSDEM 2015 40
Which watch is best?
• You go shopping for watches at lunch…
tvb FOSDEM 2015 41
Which clock do you want?
• Checking each day, at precisely noon:• (a) (b) (c) (d)• 12:00:00 12:01:30 12:03:30 12:06:11• 12:00:00 12:01:40 12:03:25 12:07:22• 12:00:00 12:01:20 12:03:30 12:08:33• 12:00:00 12:01:10 12:03:35 12:09:44• 12:00:00 12:01:40 12:03:30 12:10:55• Which one do you want to buy?
tvb FOSDEM 2015 42
Which clock do you want?
• Answer:– (a) is probably a stopped watch– (b) is most accurate, but more variable– (c) is less accurate, but less variable– (d) is least accurate, but very stable
• Watch (d) is exactly 1:11 fast per 24h– regulate (or simply apply a math correction)
and then you have the best watch
tvb FOSDEM 2015 43
Best wristwatch
tvb FOSDEM 2015 44
4. powers of ten
• Any periodic event is can be a clock– not all clocks are super accurate
• How regular the occurrence determines:– how good or bad the clock is
• How continuous the events determines:– how reliable the clock is
• The range of accuracy/stability is huge!– all you have to do is measure it
tvb FOSDEM 2015 45
“Powers of Ten” – inspiration
• Mr Charles and Ms Ray Eames (1977)– “the effect of adding another zero”
tvb FOSDEM 2015 46
Fractional units
• 1 second / day = ~1.2 × 10-5
• 3 seconds / month = 10-6 = 1 ppm• 1 second / month = ~3.8 × 10-7
• 1 second / year = ~3.2 × 10-8
• 1 ms [millisecond] / day = ~10-8
• 1 µs [microsecond] / day = ~10-11
• 1 ns [nanosecond] / day = ~10-14
• 1 sec / 3 000 000 years = ~10-14
tvb FOSDEM 2015 47
10-0 drip, drip• Leak in ceiling• 0.57 s … 9.9 s• 1.7 Hz … 0.1 Hz
tvb FOSDEM 2015 48
10-1 heart beat• 10-1, 0.1, 10%• The original ‘1 PPS’• Sometimes 2x, even 3x• Much higher stability at night• < 10% accuracy possible
tvb FOSDEM 2015 49
10-1 heart beat• 12 h frequency plot (evening/night)• ADEV floor is 10-1 from 101 to 104 s!
tvb FOSDEM 2015 50
10-2 tuning fork oscillator• 0.01, 1%• General Radio Type 213
Audio Oscillator• 1 ‘kc’; f = ~992.8 Hz• ±1.3 mHz (60 x 1 s)• Accuracy < 1%• Count those 9’s• ADEV is 10-6…10-4
tvb FOSDEM 2015 51
10-2 tuning fork oscillator• plots
tvb FOSDEM 2015 52
10-3 precision tuning fork• 0.001, 0.1%, 1 ms/s• General Radio Type 813
single vacuum tube• 1 ‘kc’ tuning fork• f = ~999.4 Hz• ±400 µHz (60 x 1 s)• Accuracy < 0.1%• ADEV is 10-7…10-4
tvb FOSDEM 2015 53
10-3 precision tuning fork• plots
tvb FOSDEM 2015 54
10-4 mechanical oscillator• 0.01%, 100 ppm• Mechanical oscillator
transistorized• “Four 9’s”
tvb FOSDEM 2015 55
10-5 mains (line frequency)• 0.001%, 10 ppm• 50/60± Hz
tvb FOSDEM 2015 56
10-5 mains (line frequency)• plots
tvb FOSDEM 2015 57
10-6 quartz watch (RC)• 0.0001%, 1 ppm, 1 µs/s• +160 ms/d = +1.85 ppm
tvb FOSDEM 2015 58
10-6 quartz watch (RC)• Nightly WWVB radio sync (60 kHz)• Look closely at 01:30 AM PST• +1h +30m +15s• Plot of 9 days• Rate variations• Sync variations
tvb FOSDEM 2015 59
10-7 chronometer• 0.1 ppm• Rated ¼ sec/day deviation
tvb FOSDEM 2015 60
10-7 chronometer• ~55 hour runtime• 200 ms phase residuals• ADEV 610-7
tvb FOSDEM 2015 61
10-7 chronometer• From 1940’s USN manual…• Phase
– Dial error• Frequency
– Daily rate• Drift
– Deviation in rate
tvb FOSDEM 2015 62
10-8 pendulum clock• 0.01 ppm, 10 ppb
10 ns/s, 864 µs/d• Shortt,
Riefler,Fedchenko,Littlemore’
• T ≈ 2π√(L/g)
tvb FOSDEM 2015 63
10-8 pendulum clock• plots
tvb FOSDEM 2015 64
10-8 pendulum clock• Fedchenko AChF-3 clock (Nov 1969)
tvb FOSDEM 2015 65
10-9 earth• 0.001 ppm• Slow by ~2 ms per day• Also somewhat irregular• ADEV 10-8 ~ 10-9
• Limited by core, weather, climate• Lunar/solar tides, periodic variations• Tidal friction, long-term drift
tvb FOSDEM 2015 66
10-9 earth (40y of data)• plots
tvb FOSDEM 2015 67
10-9 earth clock• Long-term plot (300 years)• Length of day (LOD) is 86,400 seconds ±
a few milliseconds
tvb FOSDEM 2015 68
10-9 earth clock• Short-term plot (3 recent years)• LOD is about 86,400.002 seconds
tvb FOSDEM 2015 69
10-9 earth clock
tvb FOSDEM 2015 70
10-9 earth frequency standard• Suggested improvements:
– Thoroughly clean, and dry with cloth– Remove surrounding gas and water vapor– Wait for core to cool before use– Re-align axis of rotation (wobbling)– Keep away from nearby moon (tides)– Keep away from sun (tempco)– Re-adjust rate (avoid leap seconds)
tvb FOSDEM 2015 71
10-10 ocxo• 0.1 ppb, 100 ps/s, 8.64 µs/d• 10-10…10-13 short• 510-10/d drift
tvb FOSDEM 2015 72
10-11 good ocxo• 0.01 ppb, 10 ps/s, 864 ns/d (~1 µs/d)• 10-11…10-13 short• ~10-11/d drift
tvb FOSDEM 2015 73
10-12 excellent ocxo• 1 ppt, 1 ps/s, 86.4 ns/d (~100 ns/d)• ~10-13 short/mid• ~310-12/d drift
tvb FOSDEM 2015 74
10-13 hp 106B quartz• Best hp quartz• ~410-13/d drift
tvb FOSDEM 2015 75
10-13 rubidium• 8.64 ns/d (~10 ns/d)• ~10-13 mid-term• ~110-11/m drift
tvb FOSDEM 2015 76
10-14 cesium• 864 ps/d (~1 ns/d)• ~10-13 mid-term• ~110-14 @ 1 day
tvb FOSDEM 2015 77
10-14 more cesium• 10-14 not!• Cesium clocks differ by 2x – 50x• Vintage 5060A
tvb FOSDEM 2015 78
10-14 another cesium• Not even close to 10-14 @ 1 day • FTS 4010• Portable clock
tvb FOSDEM 2015 79
10-15 hp 5071A cesium• High-performance model• Pair ~210-14 at a day• Flicker floor ~510-15 in weeks
tvb FOSDEM 2015 80
10-16 active H-maser• 8.64 ps/d• Under 110-15 @1d• Most stable
tvb FOSDEM 2015 81
Summary – powers of ten
• 17 orders of magnitude– from a billion times
worse than earth– to a billion times
better than earth
tvb FOSDEM 2015 82
5. kids, clocks, and relativity
• What to do with atomic clock hobby?• Einstein said time itself is not fixed
– S.R. predicts higher speed slows time– G.R. predicts stronger gravity slows time
• Is this only abstract theory in textbooks?– fast moving rocket ships and aging twins– objects getting too close to black holes
• Can this be tested for real on earth?
tvb FOSDEM 2015 83
Relativity at home
• We have many atomic clocks at home• No planes or rockets (high speed)• But we have mountains (high altitude)
From NPL website
tvb FOSDEM 2015 84
Big idea
• Take our 3 kids withportable cesium clockshigh up Mt Rainier
• See if Einstein wasright about gravityand time
• See if clocks reallyrun faster up there
tvb FOSDEM 2015 85
Einstein and 2005
• 100th anniversary of relativity: books, magazines, radio, TV, web sites, “Physics Year”, lectures…
tvb FOSDEM 2015 86
Louis Essen (UK) and 2005
• 50th anniversary of cesium clock (NPL)• “famous for a second” 9 192 631 770 Hz
tvb FOSDEM 2015 87
Project GRE²AT
• General Relativity Einstein/Essen Anniversary Test (2005)– 100th anniversary (Einstein) theory of relativity– 50th anniversary (Essen) first cesium clock
• Combine atomic clock hobby, physics, history, technology, math, computers, children, car trip, vacation, and family fun
tvb FOSDEM 2015 88
Clock equations
• To a first approximation, small v, small h• Kinematic: fk ½v2c2 (redshift)
• Gravitation: fg ghc2 (blueshift)
• Sagnac: ts R2cos2()• c2
• Net freq f fk fg• Total time T fT ts
– these corrections are usually infinitesimal– 1/c2 ≈ 1.1×10-17 = 0.000000000000000011
tvb FOSDEM 2015 89
Magnify the effect
• Go as highas possible
• Stay as longas possible
• Measure asprecisely aspossible
Cartoon by Dusan PetricicScientific American column Wonders by Philip and Phyllis Morrison
http://www.sciam.com/1998/0298issue/0298wonders.html
tvb FOSDEM 2015 90
Time dilation calculation
• Turn infinitesimal into measurable• Frequency change f/f gh/c2
f/f 1.09×10-16 s/s/meter• But if you go up 1 km instead of 1 m, then
f/f = 1.1×10-13 = 0.11 ps/s• And if you stay up there 24 hours, then
T = f/f 86400 s = 9.5×10-9 s = 9.5 ns• Gravitational time dilation 10 ns/day/km
tvb FOSDEM 2015 91
The GREAT trip, day 1
• Carrying clock downstairs. Limited time; car is a mess, but it works.
tvb FOSDEM 2015 92
The GREAT trip, day 1
• Clocks in the middle, batteries (200 kg) on the floor, and instrumentation in the front.
tvb FOSDEM 2015 93
The GREAT trip, day 1
• Kids in the back. Dad making final clock BNC connections; Mom says goodbye.
tvb FOSDEM 2015 94
The GREAT trip, day 1
• Detail of TIC’s and laptop in front seat and clocks in middle seat. 23:33:48 UTC
tvb FOSDEM 2015 95
The GREAT trip, day 1
• Final gas stop and evening arrival at Rainier National Park.
tvb FOSDEM 2015 96
The GREAT trip, day 2
• Paradise Inn is at 5400 ft (~1650 m) elevation. Large parking lot to hide in.
tvb FOSDEM 2015 97
The GREAT trip, day 2
• Classic old Northwest inn; you should visit sometime.
tvb FOSDEM 2015 98
The GREAT trip, day 2
• Wonderful hiking trails and climbing. Lucky to have clear weather.
tvb FOSDEM 2015 99
The GREAT trip, day 2
• Avoid a ticket and move the car again. Ouch, running low in fuel. Now what.
tvb FOSDEM 2015 100
The GREAT trip, day 3
• Got gas at 6 AM. Used 15.78 gal in 34 h = 0.46 gph; ~2h/gal, so about 1 ns/gal.
tvb FOSDEM 2015 101
The GREAT trip, day 3
• More hiking, exploring, playing. It’s a fun place for a while.
tvb FOSDEM 2015 102
The GREAT trip, day 3
• 42 hours is up; time to leave. We’re all tired. Can this really work? Go home.
tvb FOSDEM 2015 103
The GREAT trip
• Home clock and mountain clock elevations (1650 m − 310 m = +1340 m)
tvb FOSDEM 2015 104
Back home, re-measure clocks
• Results are unknowable until the return(1) Did we see any time dilation?
– requires before/after time-rate comparison– comparison against stable “house” clock
(2) Did the results match prediction?– requires record of altitude and duration– used Garmin GPS NMEA log– approx +1340 m for 42 hours (integrate)
tvb FOSDEM 2015 105
Elevation and predicted dilation
tvb FOSDEM 2015 106
Clock results (measured)
• Red20.3 ns
tvb FOSDEM 2015 107
Mean clock results
• Mean23.2 ns
• ±4 ns• Predict
22.4 ns
tvb FOSDEM 2015 108
3-hat, residuals (home)
• Csi – Csj via lab reference
tvb FOSDEM 2015 109
3-hat, residuals (away)
• Csi – Csj via mutual-comparisons
tvb FOSDEM 2015 110
3-hat, residuals (combined)
• Csi – Csj
tvb FOSDEM 2015 111
GRE²AT experiment worked
• Gravitational time dilation is real!– we came back 22 ns older (wife −= 22 ns)– hacked hidden secret of the universe– ”relativity is now child’s play”
• Unexpected press– Physics Today, WIRED magazine
• No perfect clock, no perfect time– even atomic clocks are gravimeters
tvb FOSDEM 2015 112
Thanks for your time
• Poul-Henning Kamp, FOSDEM / Gerry Demaret, time-nuts mailing list
• Contact: [email protected]• Web: www.LeapSecond.com