DCF77 USB Interface

I tried to connect a reichelt usb module to a linux machine running a simple interface with one opamp for rs232 conversion. That worked on a test machine but not on the server i tried it for. I dont know why but i assume the serial interface in the server had some problems with the 50 baud used by ntp.

After that i found a working dcf77 software for an atmega cpu on Ulrichs Page. I tried his software on a stk500 board and it worked fine. To connect it to ntp, i modified the software to send data supported by ntp. I used the Meinberg Protocol that was simple and supported by ntp.

The Software will wait for a valid dcf signal before the first time packet will be sent to ntp. After that, up to 4 failed dcf signals will not interrupt sending of valid time packets. In the meantime the clock will run internally in the avr. In case more than 4 invalid dcf time date was received, the failure will be reported to ntp.

Of cause, there will be some delay between the beginning of a second and the time ntp will receive the packet. They are:

3. could be reduced if the result package would be build in the 1 second interrupt routine



Hardware

The hardware is really simple, one atmega8 running at 4.194304 or 16 MHz (both frequencies allow a 1 second interrupt using the 16 bit timer) and a ft232bm to handle the usb stuff.

The ft232 is supported by current linux usb stacks (i'm using fedora core 4)



Schematic



Download

Schematic, Board (Eagle) and Source

Configuring NTP

First you have to create a link to the ttyUSB device because ntp wants to see /dev/refclock-n where n is a number beginning with 0.

Connect the dcf77usb interface and you will see something like

Sep 1 20:27:48 lnx kernel: ftdi_sio 1-1:1.0: FTDI FT232BM Compatible converter detected
Sep 1 20:27:48 lnx kernel: usb 1-1: FTDI FT232BM Compatible converter now attached to ttyUSB0
Sep 1 20:27:48 lnx kernel: usbcore: registered new driver ftdi_sio
Sep 1 20:27:48 lnx kernel: drivers/usb/serial/ftdi_sio.c: v1.4.2:USB FTDI Serial Converters Driver

As you can see, the new device is ttyUSB0, so

ln -sf /dev/ttyUSB0 /dev/refclock-0

will create the needed link. On newer systems where /dev is a filesystem maintained by the kernel, the link has to be created on system start. I have added the ln into the /etc/rc.d/rc.local on my fc4 system. (May be that would also work via some Linux USB Magic but i'm not aware of)

Next you need to change your /etc/ntp.conf, add the following lines

server 127.127.8.0 mode 2 prefer burst minpoll 4 maxpoll 4
fudge 127.127.8.0 stratum 1

I added the burst, minpoll and maxpoll to decrease the time until ntp is synced

You can check it with ntpq:

ntpq> pe
remote refid st t when poll reach delay offset jitter
==============================================================================
LOCAL(0) LOCAL(0) 10 l 18 64 377 0.000 0.000 0.001
*GENERIC(2) GENERIC(2) 1 l - 16 377 0.000 -1.331 11.247

and check the dcf clock:

ntpq> as

ind assID status conf reach auth condition last_event cnt
===========================================================
1 29748 9014 yes yes none reject reachable 1
2 29749 9624 yes yes none sys.peer reachable 2

ntpq> cv 29749
assID=29749 status=0000 clk_okay, last_clk_okay,
device="Meinberg DCF77 C51 or compatible",
timecode="\x02D:01.09.05;T:4;U:21.20.23; S \x03", poll=1033, noreply=0,
badformat=0, baddata=0, fudgetime1=10.000, fudgetime2=0.000, stratum=1,
refid=DCFa, flags=0,
refclock_time="c6c1d2f7.00000000 Thu, Sep 1 2005 19:20:23.000",
refclock_status="DST; TIME CODE; (LEAP INDICATION)",
refclock_format="Meinberg Standard",
refclock_states="*NOMINAL: 00:47:31 (100.00%); running time: 00:47:31"


last change Sep 1, 2005 Armin. Impressum