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.

Using GPS to set clock once per day


Anton Apr 9, 2020 05:45 PM

The documentation is not really clear on the inner workings of the GPS function. 

I would like to adjust my logger (CR6) clock once per day based on the GPS (no PPS).  What are the possibilities for achieving that goal?


Sam Apr 11, 2020 05:53 PM

Thanks for the question, Anton.

The trick is to negate the COM port selection.

ComPort (Communication Port)

The ComPort parameter is the control port pair to which the GPS device is attached. Rx is used to read in the NMEA sentences and Tx is used to monitor the PPS from the GPS. COMC1 is the only Comport that supports a PPS signal. Negate the ComPort parameter to program the datalogger to use NMEA sentences for time-syncing rather than the PPS line input (see Remarks above). Valid options are:

  • COMC1 C1/C2 (only comport that supports PPS signal)
  • -COMC1 to -COMC7 (negated comport for NMEA sentences time-syncing)
  • -COMRS232 (negated comport for NMEA sentence time-syncing)

This instruction defaults to a baud rate of 38,400 bps. If the GPS device requires a different baud rate, use the SetStatus instruction in the program to override the default.

'Program the GPS16-HVS to use 38.4 kbaud, no parity, 8 data bits, and 1 stop bit
'CONTROL PORTS
'C8   GPS16-HVS RS-232 TxD (green)
'G    GPS16-HVS power control (black)
'POWER OUT
'12V  GPS16-HVS power (red)
'G    GPS16-HVS power and RS-232 signal reference (orange)

Const LOCAL_TIME_OFFSET = -6           'Local time offset relative to UTC time
Const MAX_TIME_DIFF_ALLOWED = 1000     'Maximum difference allowed before setting clock, milliseconds

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

Public PTemp, Batt_volt

DataTable (Test,1,-1)
  DataInterval (0,15,Sec,10)
  Minimum (1,Batt_volt,FP2,False,False)
  Sample (1,PTemp,FP2)
EndTable

BeginProg
  Scan (1,Sec,0,0)
    PanelTemp (PTemp,15000)
    Battery (Batt_volt)
    CallTable Test

    If IfTime (0,1,Day) Then
      'sync time with GPS
      'negating COM port, means use only NMEA string parsing for sync
      GPS (gps_data,-ComC7,LOCAL_TIME_OFFSET*3600,1000,nmea_sentence(1))
    EndIf

  NextScan
EndProg


 


Anton Apr 14, 2020 12:21 PM

Doe this work?  The documentation suggests that GPS needs to be called at least 10 times.

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