'Campbell Scientific CR3000 Series Datalogger instructional program 'Supporting FB-HTP training, from Kansas State University and the USDA ARS 'Conducted at MAC / ALARC in Maricopa, Arizona, USA, Spring 2014 'Program prepared by Kevin Wang and Matt Conley, 3/26/2014 'This program logs the GPS cutputs from a NMEA string generator 'Comments follow the preceding apostrophe mark and explain program elements 'Comments are not executed by the logger 'Declaration of the Public Variables Public PTemp, Batt_Volt Public GPShour, GPSminute, GPSsecond Public GGAbytes, GGA_UTC_Az 'RealTime makes time variable outputs from the clock Public rtime(9)' a nine varialbe time array is created 'The Alias command assigns a descriptive name to your variable Alias rtime(1) = Year 'Logger Year Alias rtime(2) = Month 'Logger Month Alias rtime(3) = Day_of_Month 'Logger Day Alias rtime(4) = Hour 'Logger Hour Alias rtime(5) = Minute 'Logger Minute Alias rtime(6) = Second 'Logger Second Alias rtime(7) = Microseconds 'Logger Microsecond Alias rtime(8) = Day_of_Week 'Looger week day Alias rtime(9) = Day_of_Year 'Logger Julian DOY 'Constants are declared static numbers Const Local_Time_Offset = 70000 ' Universial time offset for Arizona 'The Units command assigns units to your variable data output header line #3 'Otherwise this header line will come up blank Units PTemp = Celsius 'Panel temperature of the logger Units Batt_Volt = Volts 'Logger system voltage Units Day_of_Year = Logger_DOY 'Derived from RealTime Units GPShour = GGA_GPSTime 'Derived from the GGA GPS string Units GPSminute = GGA_GPSTime 'Derived from the GGA GPS string Units GPSsecond = GGA_GPSTime 'Derived from the GGA GPS string 'The NMEA $GPGGA GPS text string is arrayed and recorded Public GGAString As String * 100 'Initial string has been striped down Public GGA_Data(15) As String 'There are 16 variables in the string Alias GGA_Data(2) = GGA_UTC 'UTC Current Time of GPS position fix - hhmmss.ss Alias GGA_Data(3) = GGA_Lat 'Latitude degrees plus minutes Alias GGA_Data(4) = GGA_NorS 'North or South Hemisphere indicator - N or S Alias GGA_Data(5) = GGA_Long 'Longitude in degrees plus minutes Alias GGA_Data(6) = GGA_EorW 'East or West indicator - E or W Alias GGA_Data(7) = GGA_Quality 'Position Fix indicator - 0=invalid, 1=GPS only, 2=DGPS Alias GGA_Data(8) = GGA_Sat 'Number of satellites used Alias GGA_Data(9) = GGA_Horiz 'Horizontal dilution of precision (HDOP) Alias GGA_Data(10) = GGA_Altitude 'Altitude relative to sea level (MSL) Alias GGA_Data(11) = GGA_Meters 'Unit of altitude, Meters Alias GGA_Data(12) = GGA_sep 'Geoidal separation Alias GGA_Data(13) = GGA_Meters2 'Unit of separation, Meters Alias GGA_Data(14) = GGA_age 'Age, in seconds, since last DGPS differential correction update Alias GGA_Data(15) = GGA_DGPSref 'DGPS reference station ID# 'Descriptive units are added to GPS variables and will show in header line #3 Units GGAString = NMEA_$GPGGA Units GGA_UTC = hhmmss.ss_hour_minute_second Units GGA_UTC_Az = hhmmss.ss Units GGA_Lat = ddmm.mm_degree_minute Units GGA_NorS = hemisphere Units GGA_Long = degrees_minutes Units GGA_EorW = hemisphere Units GGA_Quality = 1_GPS 2_DGPS Units GGA_Sat = satellites Units GGA_Horiz = HDCP Units GGA_Altitude = meters Units GGA_Meters = meters Units GGA_sep = geoidal_separation Units GGA_Meters2 = meters Units GGA_age = seconds Units GGA_DGPSref = station_ID 'NMEA String table with datalogger's panel temperature DataTable (GPS_and_Ptemp,1,-1) Sample (1,GPShour,UINT2) 'GGA derived hour of day Sample (1,GPSminute,UINT2) 'GGA derived minute of hour Sample (1,GPSsecond,UINT2) 'GGA derived second of minute Sample (1,Day_of_Year,UINT2) 'Realtime derived day of year Sample (1,PTemp,FP2)'Logger internal temperature Sample (1,Batt_Volt,FP2) 'Logger system voltage Sample (1,GGA_Lat,String) 'GGA derived positional latitude Sample (1,GGA_NorS,String) 'GGA derived North or South Sample (1,GGA_Long,String) 'GGA derived positional longitude Sample (1,GGA_EorW,String) 'GGA derived East or West Sample (1,GGA_Quality,UINT2) 'GGA derived GPS signal quality Sample (1,GGA_Sat,UINT2) 'GGA derived number of sattilites in view EndTable 'Main Program Starts here BeginProg SerialOpen(ComRS232,9600,0,0,1000) 'Baud rate for the GPS simulator, Com? Scan (1,Sec,5,0) '1Hz cycle rate RealTime(rtime) 'The RealTime time command PanelTemp (PTemp,250) 'Logger temperature command Battery (Batt_Volt) 'Logger system voltage command 'The NMEA GGA serial string is read in based on start and stop characters '36 is the ASCII character for $ '&H0D0A is the hexadecimal representation for carriage return/line feed SerialInRecord(ComRS232,GGAString,36,0,&H0D0A,GGAbytes,01) 'The RMC string is split into 13 variables based on commas SplitStr(GGA_Data(),GGAString,",",15,5) 'Convert universal time to local time GGA_UTC_Az = GGA_UTC If GGA_UTC_Az >= 70000 GGA_UTC_Az = GGA_UTC_Az - Local_Time_Offset Else GGA_UTC_Az = GGA_UTC + 24 - Local_Time_Offset EndIf 'Shift local time to account for an increase in number of digits (9 to 10) If GGA_UTC_Az >= 100000 GPShour = Mid(GGA_UTC_Az,1,2) GPSminute = Mid(GGA_UTC_Az,3,2) GPSsecond = Mid(GGA_UTC_Az,5,2) EndIf If GGA_UTC_Az < 100000 GPShour = Mid(GGA_UTC_Az,1,1) GPSminute = Mid(GGA_UTC_Az,2,2) GPSsecond = Mid(GGA_UTC_Az,4,2) EndIf 'Call the data tables to write data CallTable GPS_and_Ptemp NextScan EndProg