Project Goal
|
|
In this project a simple DCF77 receiver in addition with
a level converter and some kind of software should be used to
get a perfect timebase in a network.
|
What you need: Hardware
|

|
DCF77 receiver from Conrad
Orderno: 641138
Price (at December 2000): 10,21 Euro, (in April 2006: 9,95 Euro) |

|
RS232 adapter cable |

|
short cable with 4 wires |

|
a few devices (resistors, transistors, see below) |
|
| |
|
|
Level converter TTL/OpenCollector to RS232/V24
|
Schematics as Postscript
Schematics as Acrobat PDF
|
Schematic Descripton
|
|
The DCF77 receiver is a very low power device. The type mentioned
above also supports supply voltages up to 15V. This makes it easy to
supply it from the RS232 serial lines. But it only outputs the received
DCF77 signal as a raw open collector signal. That's why we need the
level converter.
|
|
On the right side of schematic's pages you will find the connector
to the PC. As its TxD line does nothing in this application it still
remains on logically "1" all the time, e.g. on RS232 -3...-15V, and
give us a perfect negative power supply. We also need a positive
power supply, that we can get from DTR or RTS signal.
|
|
C1 and C2 backup the power supply, D1 and D2 are for protection
against reverse polarity. Q1 and Q2 drive the signal lines with
RS232/V24 levels in PC direction to transmitt the raw DCF77 signal.
Q3 shifts a ground biased signal to the larger supply band.
|
|
The left side shows connection to the DCF77 receiver. Only four lines
are required. Do not mistake /DCF and DCF as this will
shorten the level converter. I think it will not destroy anything,
but it will confuse you, because you will not receive anything. And
perhaps you will search for this mistake in the software or the DCF77
receiver for a long time...
|
LED D3 should help to adjust the DCF77 antenna. If its adjustment is
correct, the LED will blink as the DCF77 signal. It will flash 59
times per minute, then follows a one second pause and so on.
If you take a closer look you will notice that the flashing
takes more or less time. For a DCF77 "0" it flashes 100ms, for a
DCF77 "1" it flashes 200ms. The 59 digits per minute encodes the
current time and date.
|
If you are going to make your serial cable by your own, you connect
whatever you want. This includes your decision to connect RTS or
DTR for the positive power supply. This is important, as it will
be one configure setting for the NTP later on (refer mode
option for the server keyword).
In my environment I'm using the RS232 cable of an old and broken serial
mouse. Within this cable only the signals RxD, TxD, RTS and ground
are connected. So my level converter will be supplied by TxD (negative)
and RTS (positive).
|
Signal description
|
|
Here you can see the signal characteristics of the shown circuit.
The rising edges are not vertical drawn, because they are realised
through pull up resistors. Only the falling edges are driven
actively as DCF and /DCF are open collector signals.
|
|
As shown here, we will receive two information per second from
the DCF receiver: The start of each second and a bit in the length
of the signal. A 100ms length signal is a "0", a 200ms length
is a "1".
|
|
Typically we must measure the length of the signal to get its
bit value. But here is a better trick with less overhead: This
application interprets the incoming bit stream as simple
asychronisly serial protocoll with 50Bd. It depends on the
length of each signal what kind of data will be received at
the PC side. It will result in specific patterns the parser
mentioned below can interpret.
|
|
That's why we ony need the TTL to RS232/V24 level converter
in this application. The rest will be done in software.
|
| |
|
|
Assembling
|
|
Do you have an old serial mouse at home and no
more cheese to feed it? It's time to throw it away - but keep the cable!
At least you can use it to connect simple terminals or - like in this case -
to gain access to the current time.
|
|
The cable has a professionally molded connector so it looks quite good!
Another nice feature is the 4 pin female connector. Just use a 4 pin header
(100mil) and you are fine.
|
| |
|
|
Well, this part is not very important. Due to the very low bandwidth
requirements (10 Hz) you can use any cable, if it only has at least 4
wires. I am using a spare extension cable for telco equipment.
|
| |
|
|
|
Maybe this part will be the hardest: Soldering the small board. Also
I'm sure there would be a better placement to avoid any wired link. But
it's so small - so who cares. Within 30 minutes you are able to create a
fine electronic board.
|
| |
|
|
If you do not make any mistake while you solder, this piece of electronic
should work the first time you connect it. I made a mistake (missing
wired link), so my LED never flashed. And I turned and turned my antenna
in all directions, trying to receive something. While I did so, the NTP
process showed on the screen, that it got first DCF77 pulses and tried to
sync in. Stupid to observe only the LED and never the screen...
|
|
And now hiding it in a nice case and everything is perfect!
|
| |
|
|
As I was tired with the dangling antenna I glued it into a plastic
package (I am really glad about hot-melt adhesive...) Allright, the
transparent package displays my nonprofessional work, but it was at hand
and it does its job.
|
| |
|
|
|
The last questions was, how to adjust the antenna. It was solved by
an old (and unused) desk light from IKEA. The spacer to avoid burning
anything with the hot bulb looked like it was waiting for a job like this.
Once adjusted, never touched again.
|
| |
|
|
Software
|
ntp package 4.2
|
|
How to bring it onto your host system is up to you. I'am using a
Linux from Scratch System,
so I had to build it from sources by my own.
|
I built a minimalistic package, enabling only things I really need. I
do not use external NTP servers from the net, only my local time sources.
- --disable-debugging
Eliminates dozens of text output
- --disable-all-clocks
As it says: It disables all clock drivers (most of them you never have
seen before!)
- --enable-LOCAL-CLOCK
After disabling all clock drivers, this again enables one we will need:
The local clock driver (system time)
- --enable-RAWDCF
This again enables an RS232 based clock driver for a raw DCF77 signal.
|
$ ./configure --prefix=/usr --bindir=/usr/sbin --sysconfdir=/etc --disable-debugging
--disable-all-clocks --enable-LOCAL-CLOCK --enable-RAWDCF
$ make
$ make install |
|
Configure the NTP service
|
|
The NTP process reads its configuration from /etc/ntp.conf
(on my system). To configure it to use the DCF77 driver it needs the
following additional "server" line:
|
server 127.127.8.0 mode 16 prefer |
|
|
Meaning: The special IP address starting with "127.127" means
ntp should use one of its internal time source drivers. The appended
".8" means, ntp should use the internal parse driver type and the
trailing ".0" is an index, i.e. ntp supports up to three time
sources for this driver type (as ".0", ".1" and ".2").
|
|
With the mode you select one of two possible hardware connections
and their power supply. It depends on your signal converter and how to
supply it. My signal converter is powered from RTS (positive supply) so I
need mode 16. If you supply your converter by DTR (positive supply)
you need mode 14 instead.
|
|
prefer means what it says: This time source is the preferred one.
|
|
To let ntp know the current time when there is bad or no radio reception
you should also add the local system time to be one of the possible time
sources:
|
|
|
When you start the ntp service, the Raw-DCF driver opens /dev/refclock-0
to get the raw DCF data. The -0 part depends on the given index number
in the server line in /etc/ntp.conf.
To gain access to the right serial port create a symbolic link to it to
make the ntp service happy. On my host the signal converter is connected to
/dev/ttyS1 and I used a:
|
$ ln -s /dev/ttyS1 /dev/reflock-0 |
|
|
to let the NTP service find the right device.
Note: If you are running udev (with dev/ as a tempfs directory) you must
recreate this link on every system start!
Or add the following udev rule and let udev itself creating this link:
|
KERNEL=="ttyS1", SYMLINK+="refclock-0" |
|
|
That's all. In my little network it runs since April 2006 and provides me
with the correct time.
|
|
Update 2010-01-01:
This device is now retired, replaced by my USB based DCF77 receiver you
can find here.
|