LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Linux Answers > Hardware
User Name
Password

Notices


By AwesomeMachine at 2006-10-08 17:23
The Garmin 18 LVC is one of the slickest devices to use as a very accurate clock. It costs about $85 USA, It is a snap to configure, but Garmin makes it difficult to use these devices as reference clocks because they refuse to connect the PPS signal wire on any of their prewired versions. The bare wire Garmin 18 LVC is the only variation of the Garmin 18 line which has PPS (pulse per second) capability. This post uses Fedora Core 5 because ntp is already patched with the gps NMEA driver patch in FC5. If you want to run a time server I recommend FC5.

Buy only the 'Garmin 18 LVC' model, which is an OEM unit. The fattest black and red wires are for power. You strip those and connect them to the red and black leads from a USB cable that is bare wire on one end. You can make your own. Just chop a USB cable in half, and use the half that plugs into the PC chassis. That's the part you solder on to the Garmin 18 power leads.

The rest of the wiring is according to http://lists.ntp.isc.org/pipermail/q...er/007878.html
The pin numbers are printed on the connector, really tiny. If you are looking at the holes in the female connector, with the row of 5 pins up, pin 1 is on the right of the 5 pins. Moving to the left are pins 2, 3, 4, and 5, like this: 54321. The other 4 pins you don't use.

pin signal colour
----------------------
1 PPS yellow
2 TX white
3 RX green
5 GND black


When you flip the serial connector over to solder the leads, pin 1 jumps to the far left, if the row of 5 pins is on top. You might want to buy a few extra female DB-9 serial connectors, and tin the leads on the Garmin 18 LVC before you try to put them in the little soldering holes. Use about a 75 watt iron, with some flux core solder, the smallest diameter you can get. When you solder you need to get the metal you are soldering together hot enough to melt solder. You don't melt the solder on the metal to be bonded. You place the soldering iron tip against the soldering hole in the DB-9 connector and touch the solder to the metal soldering hole on the connector. When the solder melts the connector is hot enough to bond with solder. For a soldering vise I use a pliers with a rubber band around the handles. Close everything up, turn the computer off, plug the serial connector in the PC chassis, plug the power cable into a USB port. It doesn't matter if it is USB 1.1 or USB 2.0. And, BTW, the Garmin 18 uses 5volt power. Put the GPS unit where it can see some of the sky, and turn on the computer. Leave it for a few minutes so it can get a fix on some GPS satellites, and get the PPS going accurately.

Make this entry in /etc/ntp.conf, or install ntp and then do it:

Code:
# NMEA Clock using Garmin GPS
server 127.127.20.0 mode 1 version 4 prefer
fudge 127.127.20.0 refid PPS flag2 1 flag3 1 time1 0.000 stratum 1
And, add some pool servers:

Code:
server 0.pool.ntp.org
server 1.pool.ntp.org
server 2.pool.ntp.org
Then, make a softlink to /dev/ttyS0:

As root:

Code:
cd /dev
ln -s ttyS0 gps0
Restart ntpd:

Code:
cd /etc/init.d
./ntpd restart
Issue the following command:

Code:
/usr/sbin/ntpq   -c rv -p
And you should see something at least remotely similar to this:

Code:
[beauregard@localhost dev]$ /usr/sbin/ntpq -c rv -p
assID=0 status=0664 leap_none, sync_ntp, 6 events, event_peer/strat_chg,
version="ntpd 4.2.0a@1.1196-r Thu Feb 23 04:42:00 EST 2006 (1)"?,
processor="i686", system="Linux/2.6.15-prep", leap=00, stratum=2,
precision=-19, rootdelay=53.232, rootdispersion=17.616, peer=30724,
refid=198.60.22.240,
reftime=c8b22fb4.7e62aa19  Wed, Sep 13 2006  2:20:20.493, poll=7,
clock=0xc8b230f4.3e0daa0c, state=4, offset=-0.032, frequency=32.430,
noise=55.505, jitter=17.416, stability=35.939
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*clock.xmission. .GPS.            1 u   65  128  377   53.232   -5.005   3.045
+ntp1.esat.net   .GPS.            1 u   54  128  377  151.988   13.474   2.517
+192.245.169.15  .PPS.            1 u    4  128  377  150.841   -2.230   2.866
xGPS_NMEA(0)     GPS_NMEA(0)      1 l   58   64  377    0.000  -181.46   2.304
But, the specs should be a little more respectable because mine can only see 1/10 of the sky. This clock configuration, if it can see 1/3 of the sky, is accurate to 15 microseconds every second. When the system clock is off by an entire second, ntp will set the clock to the accurate time, using the GPS. It took me two hours to do this, so I hope many people; who want accurate time can easily build a stratum 1 time server. Or for accurate time on a network this clock can be used as a primary ntp source. Reference clocks sell for $5,000.00 on up, until now that is. Now they're $85.00. So, buy a few for your friends, and wire them up.

Up to this point we are using the $GPGGA string from the GPS unit to get the time. There is a way to use the PPS pulse from the gps to keep even more accurate time. A gps system in NMEA mode outputs lines of text you can see in a terminal program, such as minicom. If you get minicom, install it, and type:

Code:
minicom
CTRL a
z
a menu will pop up, and you can set what serial port to use, among other things. You want settings:

Code:
4800 8 - N - 1
and the com port your gps is connected to, which is probably:

ttyS0

It is ttyS0 or ttyS1

You don't want minicom to initialize the gps, so after you have it configured you always launch it with:

Code:
minicom -o
and it will not send an initialization string, used for a modem, to the gps. The gps doesn't really care, but it might mess something up if you keep doing it without theoswitch. When you want to quit minicom:

Code:
CTRL a
z
q
If you get minicom configured correctly you will scrolling lines of gps output going pretty fast. Now you should read the classic page by Philip M. White here: http://time.qnan.org/#hardware . That's QNAN.org, not QUAN.org. There is some rough explanation on that page of how to use the LinuxPPS kernel patch. I use pristine kernel sources from kernel.org because the Fedora kernel source wouldn't patch. PPS means pulse per second, I think. The rise of the PPS signal on the Garmin 18 is the exact second, withing 1 microsecond, or millionth of a second. So, bookmark this page, read Philip White's page, and then come back here.

Once you get the proper version kernel source from kernel.org, put the compressed file in the directory with all you other kernel sources, which is usually:

Code:
/usr/src
But, it can also be:

Code:
/home/sam/rpmbuild/BUILD/kernel-2.6.xy
In the case of Redhat or Fedora Core 5. Expand the compressed kernel sources, and copy the LinuxPPS patch you got from Philip White's page to the resulting directory. Apply the patch with:
Code:
patch -p1 -i <ntp-pps-rc7.diff>
The patch should not cause problems. What is going to cause problems is getting a .config file. The FC5 config files in /boot will not work because Fedora applies so many patches to the kernel the config file contains things that aren't in Kconfig of the pristine kernel sources. The 2.6.15 config file in Debian Etch worked for me. You simply copy the file that begins with config-2.6.15 from /boot to the new kernel sources directory as .config and run:

Code:
make xconfig
From the new kernel sources directory. If xconfig complains about Kconfig, just edit out the parts of Kconfig it doesn't like. You have to configure everything under PPS, and 8250/16550 serial port support as a module, or dot, not a check mark. If you compile the serial drivers with a check mark, or as part of the kernel, they will load before pps_core, which needs to load first in order for this to work. These configuration options must have dots next to them. In the processor section of the xconfig program there are 3 numbers: 100, 250, 1000. Down the list a ways. You want 100. 1000 does not make the machine go faster, in fact, 1000 gives a big performance hit, and the major linux distros all have it set there. That setting is why linux gets slower and slower with new versions. I compliment Fedora for setting this at 250, which isn't too bad. But, for timing with PPS you want 100. Anyone who is compiling a kernel for a desktop system does not want 1000. Once you are done configuring the kernel, and don't touch anything if you don't know what it is, you issue the following commands:

Code:
make all
This will take between 20 minutes and 4 hours. The rest goes pretty fast. As root:

Code:
make modules_install
/sbin/depmod
make install
After make install there is a command that is put on the screen, which begins with sh. Highlight that with the mouse, and use the copy function from the edit menu, and then paste, enter. This will make initrd, configure grub, and install the kernel and System.mapin/boot. Now you can boot with the new kernel.

FC5 ntp has NMEA support built in. You just:

Code:
yum install ntp
Edit /etc/ntp.conf adding these lines and commenting out the previous NMEA server and fudge lines:

Code:
# LinuxPPS: GPS + PPS (original)
#server 127.127.20.0 minpoll 4 prefer
#fudge 127.127.20.0 mode 1 flag3 1 flag2 0
Copy the following text into a text editor:

Code:
#!/bin/bash

#script to set up LinuxPPS on ntp NMEA driver
#
#ntp dies when restarted if it is running when gps0 is linked up to ttyS0 
#so stop ntpd first

/etc/init.d/./ntpd stop

#load PPS and 8250 serial modules

/sbin/modprobe pps_core
/sbin/modprobe serial_core
/sbin/modprobe 8250

#softlink to ttyS0 needed by ntp NMEA driver
#this must be gps0, and must be linked after 
#/sbin/modprobe serial_core

ln -s /dev/ttyS0 /dev/gps0

#start ntpd daemon
#PPS will be read from gps

/etc/init.d/./ntpd start
And don't run the script more than once per boot, or you will load the modules multiple times. Copy:

Code:
# LinuxPPS: GPS + PPS
server 127.127.20.0 minpoll 4 prefer
fudge 127.127.20.0 flag3 1 flag2 0
into /etc/ntp.conf, and save the file. With the script you copied above:

Code:
chmod a+x <script-name>
cp <script-name> /usr/bin/<script-name>
Read Philip Whites excellent paper: http://time.qnan.org/#hardware to learn what your outputs from should be if the kernel modules load correctly, and ntp is truly receiving the PPS signal from the gps device. For the rest of this tutorial, use Philip Whites excellent paper. Now you have a stratum 1 time server, and you can join the pool. Plus, your computer clock will always tell the correct time, even if you lose internet for a while. To make this paper a little expandable into the future, as of 9/17/06, gpsd was nearing the point it would read and output PPS from a gps. Gpsd might be a simpler better choice in the future. It certainly is less complicated than patching the kernel. Gpsd uses localhost:2947.

by lore on Thu, 2007-08-16 07:32
Hi
After reading this tutorial and the Philip M. White page I was wondering wheter is possible to use shmpps together with another NMEA driver different from LinuxPPS, because the shmpps solution is much more easier than recompile your kernel adding patches and so.
My question is: You Know about any drivers that allows me to use the NMEA output of my GPS alltogether with my PPS output managed by SHMPPS??
Thanks in advance
Lore


  



All times are GMT -5. The time now is 05:55 AM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration