View unanswered posts | View active topics It is currently Tue Sep 25, 2018 9:15 pm



Reply to topic  [ 3 posts ] 
 Use GPS as Network Time Protocol Source for Utilite-A How To 
Author Message

Joined: Mon Jan 09, 2012 3:16 am
Posts: 351
Post Use GPS as Network Time Protocol Source for Utilite-A How To
I imagine that for most of the time, the majority of Utilites are connected to networks which provide internet connectivity. Accordingly,most Utilite's have access to a range of NTP servers which facilitate system clock initialization and synchronization. However, how does one set and maintain accurate system time in the mobile role or in remote areas where internet access is not available ?

One solution is to use a simple GPS receiver as an NTP source. Here's how.

1. Hardware needed.
A. Utilite
B. GPS receiver (serial or USB interface) (Pulse Per Second Output for
high accuracy) (I am using GlobalSat BU-353)

Attachment:
BU_353.jpg
BU_353.jpg [ 13.15 KiB | Viewed 4798 times ]



2. Packages needed.
A. ntp
B. ntpdate
C. gpsd
D. gpsd-clients
E. python-gps

3. Setup and configuration.
A. Connect gps to Utilite
B. Navigate to /dev directory and find GPS port (my case port = ttyUSB0)
C. Connect to GPS using a terminal program such as minicom. Look for NMEA
output from GPS - will resemble the following:

$GPGGA,020834.000,3027.3429,N,09101.4821,W,1,07,1.1,13.7,M,-25.9,M,,0000*5E
$GPGSA,A,3,32,31,01,14,20,16,23,,,,,,2.0,1.1,1.7*35
$GPRMC,020834.000,A,3027.3429,N,09101.4821,W,0.14,326.64,181213,,,A*75
$GPGGA,020835.000,3027.3427,N,09101.4822,W,1,07,1.1,13.4,M,-25.9,M,,0000*51
$GPGSA,A,3,32,31,01,14,20,16,23,,,,,,2.0,1.1,1.7*35
$GPRMC,020835.000,A,3027.3427,N,09101.4822,W,0.79,188.87,181213,,,A*79


D. Configure gpsd using: sudo dpkg-reconfigure gpsd as follows:
I. Start gpsd automatically? yes
II. Handle gps receivers automatically? yes
III.Device gps receiver is attached to: /dev/ttyUSB0 in my case
Iv. Options to gpsd: -b --n
v. gpsd control socket path: /var/run/gpsd.sock

E. Run cgps to confirm operation of gpsd. Pay special attention to the parameter Time Offset. It is typically less than 1. If it is a huge number, there is a problem.
Attachment:
cgps.png
cgps.png [ 79.12 KiB | Viewed 4804 times ]


F.Using an editor such as nano, edit the NTP configuration file /etc/ntp.conf as follows:

i. For a non Pulse Per Second GPS receiver add the lines:

# gps ntp
server 127.127.28.0 minpoll 4 maxpoll 4
fudge 127.127.28.0 time1 0.183 refid NMEA


ii. For a Pulse Per Second GPS receiver add the lines:

# gps ntp
server 127.127.28.0 minpoll 4 maxpoll 4
fudge 127.127.28.0 time1 0.183 refid NMEA
server 127.127.28.1 minpoll 4 maxpoll 4 prefer
fudge 127.127.28.1 refid pps


G. Execute the following commands as su:

I. killall -9 gpsd ntpd
ii. ntpd -gN
iii. gpsd -b -n /dev/ttyUSB0
iv. cgps

H. If cgps returns active, normal output then querry ntp using ntpq -p
You should get a listing similar to:

Attachment:
ntpq -p.png
ntpq -p.png [ 42.57 KiB | Viewed 4801 times ]


The line

SHM(0) .NMEA. 0 l 15 16 377 0.000 -16.884 2.868

indicates the GPS is providing time data to the NTP dameon.

A few notes:

1. Shortly after bootup, Utilite uses ntpdate to initially set the system clock. Thereafter, the ntp dameon keeps the clock synchronized to ntp servers including your GPS. Unfortunately, ntpdate will not accept time data from a gps - it only uses ntp servers. Therefore, if you operating where internet service is unavailable, you must manually set the clock to within 4 hours of actual time after bootup. After you initially set the linux system clock, the ntp dameon takes over and uses the GPS time to synchronize the system clock. Please note that if your initial time setting is 4 hours or more different from the actual time, the ntp dameon will not correct the linux system clock to GPS time. The initial setting must be less than 4 hours different form the actual time.

A program called gpsdate is available which will take GPS time and accomplish the initial setting of the clock at boot. Gpsdate basically replaces ntpdate.

See: http://lists.nongnu.org/archive/html/gp ... 00004.html

2. Utilite must be connected to a LAN in order for the GPS to function as a time source. If Utilite is not connected to a LAN, the ntp dameon will not run. Therefore, mobile or remote operation will require that a rudimentary network be available.

3. This process can be a bit quirky at times. Don't give up if at first you don't succeed.


Further reading:

http://www.catb.org/gpsd/gpsd-time-service-howto.html

http://www.rjsystems.nl/en/2100-ntpd-ga ... c-gpsd.php

http://blog.retep.org/2012/06/18/gettin ... pberry-pi/

http://linlog.blogspot.com/2009/07/sync ... pspps.html


Wed Dec 18, 2013 2:15 am
Profile

Joined: Mon Jan 09, 2012 3:16 am
Posts: 351
Post Re: Use GPS as Network Time Protocol Source for Utilite-A Ho
Utilite Can Function as an NTP Server for Your Network

Once your GPS and NTP are cooperating, you can setup Utilite as an NTP server for your network. Here's how:

1. Using an editor such as nano, make the following changes to the file /etc/ntp.conf

A. Comment out the line
restrict 192.168.123.0 mask 255.255.255.0 notrust
by adding a # in front.

It should now be
# restrict 192.168.123.0 mask 255.255.255.0 notrust

B. Add the line
restrict 192.168.1.0 mask 255.255.255.0 nomodify




2. Restart gpsd and ntpd as follows:

A. killall -9 gpsd ntpd
B. ntpd -gN
C. gpsd -b -n /dev/ttyUSB0
D. cgps


Utilite is now configured to act as a NTP time server for all computers on the 192.168.1.0 subnet.

The IP address of my Utilite is 192.168.1.135
Here is an example of a Windows XP laptop using Utilite as a NTP server where the only NTP time source available is the GPS connected to Utilite.


Attachments:
ntpq -p 2.png
ntpq -p 2.png [ 23.6 KiB | Viewed 4768 times ]
Win XP Time.JPG
Win XP Time.JPG [ 30.19 KiB | Viewed 4770 times ]
Thu Dec 19, 2013 3:16 am
Profile

Joined: Wed Jun 25, 2014 8:04 am
Posts: 1
Post Re: Use GPS as Network Time Protocol Source for Utilite-A Ho
I've been working on a similar GPS clock project using a Utilite value, GPS timing receiver and connecting a serial LED display. I have had some issues getting the latest version of NTP, 4.2.7, working correctly with the SHM software interface. Older versions of NTP up to 4.2.4 appear fine. Is the SHM interface broken in the latest NTP release? Has anyone else had similar issues with the latest NTP server software?
Evan
http://www.timetools.co.uk/catalogue/gps-clock/


Wed Jun 25, 2014 8:15 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.