avr ntp clock.

Posted on Feb 5, 2014

The Network Time Protocol (NTP) has revolutionized the world. Suddenly one could have anywhere in the world accurate time and date. NTP is a simple UDP based protocol and can be implemented in a Microcontroller. So far we have only implemented UDP and TCP servers. A clock needs however to be a client. This is something new. A server just answers t

avr ntp clock.
Click here to download the full size of the above Circuit.

o incoming IP packets it is therefore a bit easier to implement. However NTP is a short packet and it is therefore possible to add a NTP client to the existing network stack. We can therefore build a clock which has not only a LCD display but also a build-in webserver. This can then be used to configure the clock or see the current time. The NTP protocol is described in RFC958. Essentially it is just a 64 bit time-stamp. 32 bits of this time-stamp are the seconds in UTC (=GMT Greenwich mean time) since since Jan. 1st 1900. The other 32 bits are fractions of a second. In other words NTP can be very very accurate. For our purposes it is however enough if we just evaluate the seconds. The AVR NTP clock synchronizes at startup with a NTP server and uses then a timer interrupt to maintain time locally. Every hour it tries then to synchronize again. If your DSL router is however off during the night then it`s not a problem. The clock just continues. We use the on board crystal to maintain the clock locally. This will minimize the drift even if no Internet connection was possible for a couple of days. A clock is essentially just a counter. Since NTP is already a 32-bit "counter" we just take a 32bit variable and increment it. That is: the initial setting of the counter comes via NTP and then we just count up every second. If you had already a look at the code you might have noticed that the included README file says that one needs...

Leave Comment

characters left:

Related Circuits

  • New Circuits



    Popular Circuits

    Lead Acid Battery Charger with LED indicator
    Electromyogram Monitor
    contruction of personal Radar System using PIC MIcrocontroller PIC18f452
    Computer Microphone Circuit
    diy dye laser
    Float Charger For NiMH Cells