Arduino NTP Server

Andrew Rodland

YAPC::NA 2012

Madison, WI

June 12, 2012

Here It Is…

So what is it?

Why did I do it?

GPS Is a Time Source?

Uses of Precision Time

The Main Board

Freetronics EtherMega

The GPS Module

USGlobalSat EM-318-02

The LCD

CrystalFontz CFA-634

Timers

AVR timer/counter registers can be configured to:

Input Capture is Awesome

Timekeeping

Timekeeping (cont.)

Digital Frequency Synthesis

Digital Frequency Synthesis

Digital Frequency Synthesis

If we add or subtract 1 tick to every timer interrupt, that’s:

Not a fine enough adjustment!

Digital Frequency Synthesis

Instead, adjust the timer in units of 1/2048 tick per interrupt

Digital Frequency Synthesis

Digital Frequency Synthesis (Example)

Digital Frequency Synthesis

So how do we figure out how fast to run the timer to keep it in sync with the signal from the GPS?

Frequency Locked Loop (FLL)

Phase Locked Loop (PLL)

NTP

NTP (cont.)

Delay = (t4 – t1) – (t3 – t2)

NTP (cont.)

The Code

The Simulator

The Modules

GPS Notes

Ethernet Notes

Temperature Probe Notes

Performance

Performance (cont.)

Name/IP Address            NP  NR  Span  Frequency  Freq Skew  Offset  Std Dev
==============================================================================
spectre                     5   4   86m     -0.013      0.063  -2091ns    23us
arduino                    42  24   972     -0.712      0.012    -25ms  6302ns
goron                       5   4   452     -0.545      1.109   +545us    26us

Crystal Methods

The Next Version

The Next Version

Wrap-up

Questions / Code Tour

http://git.cleverdomain.org/arduino/