Skip to content

Commit

Permalink
Backport GPS from v2.01 for CR1000X (fixes #13)
Browse files Browse the repository at this point in the history
Default max allowed clock drift increased 0 to 1 ms.
After GPS is ready, lat/long is used to override user-defined settings.
Height compensation code not backported since such changes
are not backward compatible with user-defined settings.
  • Loading branch information
patricktokeeffe committed Mar 12, 2024
1 parent fb82edd commit 1e5ba0d
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 31 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ Significant realignment means users will need to modify current deployments to c
* **All sensor input locations were reverted to match EasyFlux-DL base code. This highly substantial change affects most sensors.**
As a result of limited input locations, the 034B cup-and-vane anemometer and NR01 component radiometer are mutually exclusive by default (to use both, specify different input channels).
* All hard-coded numbers for computations are changed from integer to float.
* Support for GPS receiver updated to emulate CR6 or CR1000X program version:
* Menu options and public variable names are updated.
* Default maximum clock drift set to 1.0 millisecond.
* GPS latitude & longitude is updated as GPS fix improves and, once locked, is used instead of user-defined values.
* Subroutine `FootprintCharacteristics_KormannMeixner`:
* Incorporates thermal stratification as a function of stability from eqns (11) and (32) in *Kormann and Meixner (2001)*.
* Modifies fourth footprint integration segment to increase integration interval by factor of 2.5 (4→10 x aerodynamic height)
Expand All @@ -45,6 +49,7 @@ Significant realignment means users will need to modify current deployments to c
* Eliminate compiler warning about unused Topp equation function if not using Decagon 5TM sensors. Fixes [#4]
* Fix *Time_Series* table to log alternate CO2 density derived from sonic temperature when using IRGASON (not just EC150). Fixes [#7]
* Fix intermediate processing of energy balance SWC sensors and clean-up related code for profile sensors. Fixes [#3], [#8] and [#9]
* Use non-zero default max clock drift. Fixes [#13]

### Removed

Expand All @@ -55,6 +60,7 @@ Significant realignment means users will need to modify current deployments to c
[#7]: https://github.com/wsular/EasyFlux-DL-CR3000/issues/7
[#8]: https://github.com/wsular/EasyFlux-DL-CR3000/issues/8
[#9]: https://github.com/wsular/EasyFlux-DL-CR3000/issues/9
[#13]: https://github.com/wsular/EasyFlux-DL-CR3000/issues/13


## [ProgSig 40826] 2018-11-29
Expand Down
2 changes: 1 addition & 1 deletion doc/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ Field names in data output tables contain a numeric index ranging from 1 to \{qt
### 3.1.13 GPS Receiver (new section)

A GPS receiver is optional but will keep the datalogger clock synchronized to GPS time.
If the datalogger clock drifts from the GPS time, then it will be resynchronized.
If the datalogger clock drifts from the GPS time by more than `MAX_CLOCK_DRIFT` (default: 1 ms), then it will be resynchronized.
The default wiring for the GPS receiver is shown in Table 3.13.

> **NOTE**<br/>Units with serial numbers greater than 1A4189318 have a 3 V PPS output signal
Expand Down
70 changes: 40 additions & 30 deletions src/EasyFlux-DL.cr3
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ Const SENSOR_DOOR = FALSE 'Unique: reed switch enclosure
Const SENSOR_TS45 = FALSE 'Unique: MorningStar TriStar TS-45 charge controller

'adjust to reflect reality
Const UTC_OFFSET = -8 'Unique: local time offset from UTC, in hours
Const NMBR_SHFP = 4 'Unique: number of HFP01 or HFP01SC sensors to measure (Maximum is 4)
Const NMBR_TCAV = 2 'Unique: number of TCAV (Maximum is 2)
Const NMBR_CS6xx = 2 'Unique: number of CS616, CS650, CS655, TDR-315 or 5TM sensors (Maximum is 2)
Expand Down Expand Up @@ -576,9 +577,7 @@ Const o34B_WS_OFFSET = 0.28 'Unique: offset for wind speed
#If (SENSOR_GPS16X) Then

Const GPS16X_COM = Com4 'Serial port for GPS16X

Const UTC_OFFSET = -8 'Unique: local time offset from UTC, in hours
Const MAX_CLOCK_DRIFT = 0 'max clock drift permitted before setting clock, in msec
Const MAX_CLOCK_DRIFT = 1.0 'max clock drift permitted before setting clock, in msec

'*** Beginning of GPS16X wiring ***
'C7 pulse-per-second (PPS) output (gray)
Expand Down Expand Up @@ -697,10 +696,10 @@ Units thick_abv_SHFP = m
Dim stn_conf_array_prev(NMBR_STN_VAR) 'Hold previous station parameters to check for new user-entered values

'After user input, used to assign a sign to latitude and longitude
Const Hemisphere_North = 1
Const Hemisphere_South = -1
Const Hemisphere_East = 1
Const Hemisphere_West = -1
Const NORTH = 1
Const SOUTH = -1
Const EAST = 1
Const WEST = -1

'Used to assign a value for surface_type
Const CROP = 1
Expand Down Expand Up @@ -2092,41 +2091,42 @@ EndTable
#If (SENSOR_GPS16X) Then

'*** Beginning of GPS receiver constants and variables ***
Dim nmea_sentence(2) As String * 90

Dim nmea_sentence(2) As String * 100 'Hold NMEA sentences: nmea_sentence(1) for GPRMC and nmea_sentence(2) for GPGGA.
Public gps_data(15)
Alias gps_data(1) = latitude_deg 'Degrees latitude (+ = East; - = West)
Alias gps_data(2) = latitude_min 'Decimal minutes latitude
Alias gps_data(3) = longitude_deg 'Degress longitude (+ = East; - = West)
Alias gps_data(4) = longitude_min 'Decimal minutes longitude
Alias gps_data(1) = latitude_GPS_deg 'Degrees latitude (+ = East; - = West)
Alias gps_data(2) = latitude_GPS_min 'Decimal minutes latitude
Alias gps_data(3) = longitude_GPS_deg 'Degress longitude (+ = East; - = West)
Alias gps_data(4) = longitude_GPS_min 'Decimal 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(10) = altitude_GPS 'Antenna altitude
Alias gps_data(11) = pps 'Elapsed ms since last pulse per second (PPS) from GPS
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
Alias gps_data(15) = nmbr_clock_change 'Number of times the clock was changed
Units latitude_deg = degreesN
Units latitude_min = minutesN
Units longitude_deg = degreesE
Units longitude_min = minutesE
Units latitude_GPS_deg = degrees
Units latitude_GPS_min = minutes
Units longitude_GPS_deg = degrees
Units longitude_GPS_min = minutes
Units speed = m/s
Units course = degreesEofN
Units magnetic_variation = degreesEofN
Units fix_quality = unitless
Units nmbr_satellites = unitless
Units altitude = m
Units altitude_GPS = m
Units pps = ms
Units dt_since_gprmc = s
Units gps_ready = unitless
Units max_clock_change = ms
Units nmbr_clock_change = occurrences

Dim gps_ready_best As Long
'*** End of GPS receiver constants and variables ***
#EndIf
#EndIf '(SENSOR_GPS16X)
#If (SENSOR_DOOR) Then

'*** Beginning of door switch constants and variables ***
Expand Down Expand Up @@ -2246,11 +2246,11 @@ DisplayMenu ("System Control", TRUE)

MenuItem ("Sonic Azmth", sonic_azimuth)
MenuItem ("Latitude", latitude)
MenuItem ("Hemisph_Eq", hemisphere_NS)
MenuPick (Hemisphere_North, Hemisphere_South)
MenuItem ("Hemisph_NS", hemisphere_NS)
MenuPick (NORTH, SOUTH)
MenuItem ("Longitude", longitude)
MenuItem ("Hemisph_Me", hemisphere_EW)
MenuPick (Hemisphere_East, Hemisphere_West)
MenuItem ("Hemisph_EW", hemisphere_EW)
MenuPick (EAST, WEST)

SubMenu ("Planar Fit Alpha")
MenuItem ("<=60 or >=300", alpha_PF_60_300) 'Angle in sonic coordinate system
Expand Down Expand Up @@ -4778,6 +4778,11 @@ BeginProg

'*************************** SCAN LOOP **************************************************
Scan (SCAN_INTERVAL, mSec, SCAN_BUFFER_SIZE, 0)
#If (SENSOR_GPS16X) Then
'*** GPS16X measurements
GPS (latitude_GPS_deg, GPS16X_COM, UTC_OFFSET*3600, MAX_CLOCK_DRIFT, nmea_sentence(1))
#EndIf

'Datalogger panel temperature
PanelTemp (panel_tmpr, 250)

Expand Down Expand Up @@ -6145,10 +6150,15 @@ BeginProg
#EndIf

#If (SENSOR_GPS16X) Then

'*** Beginning of GPS16X-HVS measurements ***
GPS (gps_data(1),GPS16X_COM,UTC_OFFSET*3600,MAX_CLOCK_DRIFT,nmea_sentence(1))
'*** End of GPS16X-HVS measurements ***
'Correct input values of latitude and longitude using GPS data
If (gps_ready > gps_ready_best) Then
latitude = latitude_GPS_deg + latitude_GPS_min/60
hemisphere_NS = SGN (latitude_GPS_deg)*1
longitude = longitude_GPS_deg + longitude_GPS_min/60
hemisphere_EW = SGN (longitude_GPS_deg)*1

gps_ready_best = gps_ready
EndIf
#EndIf

'*** Beginning of updating files of station variables and planar fit angles ***
Expand All @@ -6160,13 +6170,13 @@ BeginProg
Select Case stn_var_check_count
'Update geo-coordinates
Case 2, 3, 4, 5
If (hemisphere_NS = Hemisphere_North) Then
If (hemisphere_NS = NORTH) Then
latitude = ABS(latitude)
Else
latitude = - ABS(latitude)
EndIf

If (hemisphere_EW = Hemisphere_East) Then
If (hemisphere_EW = EAST) Then
longitude = ABS(longitude)
Else
longitude = -ABS(longitude)
Expand Down

0 comments on commit 1e5ba0d

Please sign in to comment.