GPS

Set the time using a GPS receiver


In WinScan:
Press the "Set GPS Time" button
(or chose the "Time - Set Time by GPS receiver" menu item )

The GPS_Form will be shown.

Check the Settings first
GPS Settings

then:
Press "GetGPSTime" to get the time form
your GPS receiver
Check the time and the offset and the status
Some messages may be shown
Then you may set your System timer "Set System-Timer"
and your WinScan Timer and the Frequency "Set Win ScanTimer and Frequency"
(or only your WinScan Timer )

or : Press "Auto: Get GPS-Time, Set Timers"
(At GPS Settings, the Settings in the Auto section must be set )
the program try's to get a valid time and will set the timers after the conditions form the GPS Settings are fulfilled.
It may take some time, to stop, press "ESC / Stop".



Details:


I used a Garmin 18 LVC device to test the program.
Wiring: compare Technical Specifications of your receiver.
Other GPS receivers will need different wiring !
Power Source: In-Plug power supply, 4.5 V DC

Wiring of the Garmin 18 LVC:

GPS receiver DB9 Serial Connector power supply
(Female Pin Contacts)
Vin + 4.5 V DC
Ground Pin 5 Ground
TXT Pin 2 Data in
RCV Pin 3 Data out
PPS Pin 8 CTS
The pulse per second (PPS) may be connected to CTS or to DSR
First start the computer then plug in the receiver to the COM port.
(elsewhere the receiver may be detected as a mouse and will click on everything on the desktop! (or check the documentation how to fix this ) )
Check the Settings
of the Operation System
for the Com port:
Baud 4800
DataBits 8
Parity no
StopBits 1
FlowControl Hardware
(this should work)

I am using COM2
Settings up the GPS receiver:
Using the Garmin Sensor Configuration
Software:
(snsrcfg.exe)
Contents - NEMA Sentence Selection:
 	Check GPRMC  to get time and date
                         and  GPGSA  ( and may be GPGSV  also)  to
                                        get the number of sats used
	    ( it should also work using GPGGA or GPGLL or GPZDA
                       instead of GPRMC to get time )
		using GPZDA you will get not receiver warning
     		  if the Data is not valid.
	The program try's to find one of the following sentences
                  to get the time in this order:
		GPRMC, GPGGA, GPGLL, GPZDA
	GPGGA and GPGLL have no information related to the date,
	  in that case the current date will be used.
                don't check to many sentences
	as the data should be transmitted in less then 0.7 sec
	or set the  Baud rate to more than 4800 Baud
Sensor Configuration:
      Check Pulse Per Second
       Baud Rat: 4800 ( or a higher value, if you checked many NEMA sentences )
Comm - Setup:
     Baud Rate: 4800  (or auto to test baud rate)
 Com port: COM2  (or the port you are using)
Then use Connect and then Send Configuration To GPS
after that: Disconnect

Then start WinScan:
( The system timer should be set to an estimated time before
you start WinScan)
Press the "Set GPS Time" button
(or chose the  "Time - Set Time by GPS receiver" menu item )

At the GPS_Form press the "Settings" button
 At the GPS SettingsForm fill in:
	COM Port: The COM Port you are using (1 or 2 or... )
	Baud:  4800  (the baud rate, on which your GPS receiver is working)
	PPS: CTS  ( or the Pin at which you connected your PPS )
		only tested using CTS
		DSR should also work
		Ring may only work using Windows XP (not tested)
		RXCHAR only if no PPS is available, is send later, not exact
	Seconds to get time:   about 21 or more, waits for PPS 21 times
	System timer minutes ahead UT: difference UT to local time of the system timer
				(System Time   - UT ) , is set by WinScan, can not be changed
			WinScan's intern timer  should be always use UT
	additional Offset: should be 0.0
			only if you are sure that an offset must be added
			(for example RXCHAR may be read out 0.036sec after PPS, then offset
				will be 0.036 )
			the offset is added when setting the timers, so
			 comparing GPS time and WinScan time or System time
			this offset should be shown.
In the GPS_Form press:
    "GetGPSTime ! "
Check the Status ListBox
	The program will wait for a COM event, like CTS caused by PPS
	If no PPS is available, a time out message is shown. (It may take some
		time, until the GPS receiver sends the first PPS)
	If an COM event is recognized, a message is shown.
	The Time and the frequency of the CPU will be calculated.
	Check the offset in the Status ListBox
.

	Then press "Set System Timer" and "Set WinScan timer and frequency"
	You may save the Status ListBox or clear it.
	Other buttons will show time or offset.

or : Press "Auto: Get GPS-Time, Set Timers"
	   (At GPS Settings, the Settings in the Auto section must be set )
	the program try's to get a valid time and will set the timers
	after  the conditions form the GPS Settings are fulfilled.
	It may take some time, to stop, press "ESC / Stop".

Check also: Number of digits of seconds, stored in fits file header
	At the WinScan Form press: Settings - Information's
	At the Settings_Information's  Form  you may set:
		Digits Seconds in Date Time Fits Header to 3 (default is 2)
		( only for: FastScan, Standard, Speckle, SubArray)
		(Drift Scan images will always use 2 Digits)

Errors:
	Time Out, no Com Event
		 Stopped
	Error -1
		  No PPS is detected.
		Check:    Is the GPS receiver connected to the computer?
			 Check the Settings in the GPS SettingsForm.
			 Do the GPS receiver sends a PPS signal?
			It may take some time until the GPS receiver sends a PPS signal.
			You may check, if the GPS receiver works at all, using RXCHAR(not exact)
			      GPS SettingsForm - PPS: RXCHAR
			You may reset the GPS receiver, for example by unplugging the power source.
			You may use an other program to check the GPS receiver
			The GPS receiver may need to be set up using the Sensor Configuration Software
		Is the PPS wire connected to CTR or to DSR ?
		Is CTR or DSC selected at   GPS SettingsForm - PPS
		Has the GPS receiver has a free view to the sky (no trees, no buildings)?

            There are only random characters shown in the status ListBox (instead of NEMA sentence):
	                	Only front of the first NEMA sentence: May have been in the buffer of the serial
		                	port, does not matter, is ignored by the program.
                	No valid sentences:
	               Is the correct Baud Rate selected? (GPS SettingsForm, Baud Rate)
			This Baud Rate can be tested using the Sensor Configuration Software
				Com Setup:  auto
		                The Baud Rate can be changed by  the Sensor Configuration Software
		The receiver may be reset.

	There is a huge offset calculated:
		Don't set the System Timer or the WinScan Timer.
		Try again. Chose an other NEMA sentence using the Sensor Configuration Software.
		Don't  check to many sentences, use a higher baud rate.

	There is an offset of one second ( if you are sure, that the System Timer
                                        or the WinScan timer is at the exact time)
		  Has the GPS receiver has a free view to the sky (no trees, no buildings)?
		  The GPS receiver may need to be reset.
		  Check the GPGSV data, there should be used >=3 sats, signal level of
			>= 3 sats should  be > 40 (better 50).
		  Check the GPGSA data, PRN's used in solution: 3 or more should be different
			from 0.
		  Check the Other: GPRMC (or GPGGA or GPGLL):
			Data status or Data Quality: Should be OK.
		   There will be shown a message regarded to the Data status and the
			number of sats used, after pressing "Get GPS-Time "
		You may check the GPS receiver by an SNTP time server (if internet is available)
			Start WinScan, Set the timer using "Set time by sntp"
			Get the time from the GPS receiver and check the offset.
			(or set the system timer by an SNTP time server using the operation
			  system or a separate program, then start WinScan ,
			 then get the GPS-Time and compare the offset to the system timer)


If you want to use the intern interpreter or scripting to get GPS Time:
	(check WinScanScript Help )
ChangeGPSSettings  Port  Baud  PPS_Kind  WaitSeconds  MinutesAheadUT  AddOffset
	Port  ComPort, 1 or 2 or ...
	Baud 4800
	PPS_Kind  1 = CTR, 2 = DSR, 3 = Ring, 4 = RLSD, 5 = RXChar. should be CTR
	WaitSeconds  about 9 or more
	MinutesAheadUT only to set the system timer, MinutesAheadUT of the system timer
	AddOffset  should be 0.0
     better change settings by starting the program before and using the GPS_Settings Form

GetGPSTime
	Get the GPS Time, call first
	returns 0 if success
SetWinScanTimerAndFRQ
	Set the WinScan Timer to  GPSTime  and the frequency of the CPU
SetWinScanTimer
	Set the WinScan Timer to  GPSTime
SetSystemTime
	Set the system Timer  to  GPSTime
GetGPSOffsetWinScan
                returns offset:  GPSTime - WinScanTime may be called
			after GetGPSTime and before SetWinScanTimerAndFRQ
		                 	to check for errors