Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Synchronizing time by GPS


SxD Mar 29, 2022 06:21 PM

Hi,

We are testing a GPS device to update the time of the cr1000 datalogger.

This device is based on a U-BLOX brand module that offers the NMEA protocol through the serial interface and a PPS output for high time synchronization accuracy.

For our tests, we are using a simple program that is the example presented in CRBASIC Help.

'Program the GPS16-HVS to use 38.4 kbaud, no parity, 8 data bits, and 1 stop bit
PipeLineMode

Const LOCAL_TIME_OFFSET = -3 'Local time offset relative to UTC time
Dim nmea_sentence(2) As String * 100

Public gps_data(15)
Alias gps_data(1) = latitude_a 'Degrees latitude (+ = North; - = South)
Alias gps_data(2) = latitude_b 'Minutes latitude
Alias gps_data(3) = longitude_a 'Degress longitude (+ = East; - = West)
Alias gps_data(4) = longitude_b 'Minutes longitude
Alias gps_data(5) = speed 'Speed
Alias gps_data(6) = course 'Course over ground
Alias gps_data(7) = magnetic_variation 'Magnetic variation from true north (+ =
'East; - = West)
Alias gps_data(8) = fix_quality 'GPS fix quality: 0 = invalid, 1 = GPS, 2 =
'differential GPS, 6 = estimated
Alias gps_data(9) = nmbr_satellites 'Number of satellites used for fix
Alias gps_data(10) = altitude 'Antenna altitude
Alias gps_data(11) = pps 'usec into sec of system clock when PPS
'rising edge occurs, typically 990,000 once
'synced
Alias gps_data(12) = dt_since_gprmc 'Time since last GPRMC string, normally less
'than 1 second
Alias gps_data(13) = gps_ready 'Counts from 0 to 10, 10 = ready
Alias gps_data(14) = max_clock_change 'Maximum value the clock was changed in msec
Alias gps_data(15) = nmbr_clock_change 'Number of times the clock was changed

'Define Units to be used in data file header
Units latitude_a = degrees
Units latitude_b = minutes
Units longitude_a = degrees
Units longitude_b = minutes
Units speed = knots
Units course = degrees
Units magnetic_variation = unitless
Units fix_quality = unitless
Units nmbr_satellites = unitless
Units altitude = m
Units pps = ms
Units dt_since_gprmc = s
Units gps_ready = unitless
Units max_clock_change = ms
Units nmbr_clock_change = samples

BeginProg
'Use SetStatus prior to scan if baud rate needs to be changed for device
Scan (1,Sec,0,0)
GPS (latitude_a,Com4,LOCAL_TIME_OFFSET*3600,500,nmea_sentence(1))
NextScan
EndProg

Unfortunately it is not working and we are not understanding what is happening. The GPS is sending the NMEA sentences $GPGGA and $GPRMC, the serial communication is configured at a speed of 38400 and the PPS output has a period of 1000ms(1Hz) and a pulse width of 100ms. The datalogger is receiving and recognizing the two NMEA sentences.

Most of the time, the pps variable gives us a value of 'NAN'.

Here comes my first question, what does a "Not A Number" value in the pps variable mean? Would it be too high or too negative? I would like to understand this to know where is the problem.

After some time, which is not regular, there is a synchronization of the datalogger time, but I cannot understand when this happens and how.

Then we did another test, we modified the program to:

GPS (latitude_a,-Com4,LOCAL_TIME_OFFSET*3600,500,nmea_sentence(1))

So, in this way the datalogger will only use the NMEA sentences. In this test, the datalogger identifies that it has the wrong time and starts counting the gps_ready variable  and in the pps variable the values vary from 10,000 to 990,000 and when the gps_ready variable reaches the count 10, and there would be an update of the time, the pps variable displays the value of 'NAN'. With this, the time synchronization does not happen and the count of gps_ready variable is restarted, but the synchronization never happens because on the tenth count of the pps variable, again it becomes 'NAN' and this is in an infinite loop.  

Could someone help me understand what is going on? I believe it is a problem related to the GPS device but I am not able to prove to UBLOX that their device is not correct.

BR.


JDavis Mar 30, 2022 08:32 PM

The PPS pulse might not be getting the voltage high enough. The C channeles on a CR1000 use these voltages for input as found on the specification sheet:

INPUT STATE: high 3.8 to 16 V; low -8.0 to 1.2 V

Be sure the CR1000 has at least OS version 32.0 on it.


JDavis Mar 30, 2022 08:37 PM

Also use the terminal of the datalogger to watch that the GPRMC strings are coming from the GPS 1 second apart. If too many NMEA messages are enabled on a GPS, messages will be further than 1 second apart.

https://www.campbellsci.com/videos/sdi12-sensors-watch-or-sniffer-mode


SxD Mar 31, 2022 11:54 AM

This post is under review.

Log in or register to post/reply in the forum.