TX321 program converted to TX325 program (CR1000, CR3000, CR800-series)
Use the latest operating system for your data logger, 32.06 or later. Do not run a program that changes the Platform ID repetitively. Doing so can lead to failure of the EEPROM from excessive write cycles. If your program must use different Platform IDs at different times, the newer data loggers (CR6, CR300 series, CR350 series, CR1000X) support this.
This appendix discusses modifying a program for a CR3000, CR1000, or CR800-series data logger to use a TX325 instead of a TX321. It also discusses the TX325 features and commands that are not supported in the older data loggers and the interfaces required to connect the TX325 to an older data logger.
Some TX325 features and commands are not supported in the older data logger operating system (OS) because of memory size limitations of older data loggers.
The TX321 had a CS I/O interface, so the commands (GOESData) output data to the CS I/O port. The TX325 only has an RS-232 port, so the new commands that were added use the RS-232 interface on the data logger. This means that it will not be possible to connect to the RS-232 with LoggerNet, and another interface will need to be used for that. Campbell Scientific recommends using an SC32B, and connect the computer RS-232 (or USB to RS-232 adapter) to the SC32B and to the data logger CS I/O. Additionally, if the data logger has an Ethernet interface, the data logger may use an IP link to connect to the computer. An RS-232 interface is require If the data logger OS need to be updated.
The TX325 uses different CRBasic commands from the TX321. Often, the commands are similar, but not all functions are available. It is highly recommended to download the example program available at www.campbellsci.com/downloads/tx325-example-program-cr3000-cr1000-cr800 . This appendix provides the changes that need to be made to a data logger program that allows it to use a TX325 instead of the TX321. It is important to copy/paste or work from the online example, only using this appendix as a guide.
When using a TX321, the configuration parameters for the GOES radio may have been set either using the Device Configuration Utility software, or by using the GOESSetup()
CRBasic instruction. A Device Configuration page is not available for the TX325 when it is connected to an older data logger. With an older data logger, the configuration parameters for the GOES radio must be set programmatically using the EnviroSatRandomSetup
and EnviroSatSTSetup
commands. The following are the three methods available for adding it to a program:
-
The
EnviroSatRandomSetup
andEnviroSatSTSetup
commands can be coded with the arguments directly in the program, which is convenient when the user has only one station. -
The configuration settings can be listed in a
ConstTable
, which allows them to be configured by changing the site specific settings from a template file that is used at multiple sites. Once the BooleanApplyAndRestart
is set to true, those changed constants will be applied and the program recompiled. If an archived copy of the program is kept that is running (and we recommend that you do), you will need to download it using File Control or do a Backup Datalogger (using the Device Configuration Utility software) and save it so that you know which site it applies to. -
A file can declare and define the configuration variables and can include the measurement algorithms. The advantage to this is that as the measurements evolve, the same template file can more likely be used at multiple sites, since it does not include site specific parameters. If the program attempts to be compiled without finding the file, the compile will fail, since the variables used in the
EnviroSatRandomSetup
andEnviroSatSTSetup
commands won't be found.
The following is an example of an include file named IncludeFile.CR1. It can have any suffix such as .CR8 or .text. It will simply require changing the filter in the file selector for the file to Send in File Control.
'GOES configuration settings for MySite
Const
dcp_platform_id As Long
= &h01234567
Const
rt_baud_rate = 300
Const
rt_channel = 195
Const
rt_count = 2 'we can only send two messages max in a 2 minute RT interval.
'We can send more if our RT interval is larger.
Const
rt_interval As String
= "00_02_00"
Const
st_baud_rate = 300
Const
st_channel = 195
Const
st_interval As String
= "00_01_00_00"
Const
st_message_window_size As Long = 10
Const
st_offset As String = "00_45_50"
Use File Control to send it to the CPU drive. Uncheck Run Now and Run On Power-up, as it will not compile.
In the main file, add the following line before the BeginProg command:
Include "CPU:IncludeFile.CR1"
Send the main file. It should pull in IncludeFile.CR1 and compile without error.
The TX325 status is sent as an array of 37 values. Allocate and set aliases as follows or similarly:
Public
tx_325_status(37) As Long
Alias
tx_325_status(1) = status_result
'0 = success, -1 = timout, -2 = no SOH character returned, -3 = bad checksum
'-10 = no CTS asserted
Public
tx_325_status_results As String
* 30
Alias
tx_325_status(2) = time_status
'&h00 = completed OK, &h0A = time-of-day clock not loaded yet.
Public
tx_325_time_status As String
* 50
Alias
tx_325_status(3) = reported_year 'current year.
Alias
tx_325_status(4) = julian_day 'current day into the year
Public
reported_month As Long
Public
reported_day As Long
Alias
tx_325_status(5) = reported_hour
Alias
tx_325_status(6) = reported_minute
Alias
tx_325_status(7) = reported_second
Alias
tx_325_status(8) = reported_tenths_of_a_second
Alias
tx_325_status(9) = reported_radio_id_decimal
Alias
tx_325_status(10) = radio_firmware_build_time
Alias
tx_325_status(11) = radio_firmware_build_date
Alias
tx_325_status(12) = radio_battery_voltage
Alias
tx_325_status(13) = radio_temperature
Alias
tx_325_status(14) = radio_battery_voltage_before_last_tx
Alias
tx_325_status(15) = radio_temperature_before_last_tx
Alias
tx_325_status(16) = radio_battery_during_last_tx
Alias
tx_325_status(17) = latitude_deg
Alias
tx_325_status(18) = latitude_min
Alias
tx_325_status(19) = latitude_direction
Alias
tx_325_status(20) = longitude_deg
Alias
tx_325_status(21) = longitude_min
Alias
tx_325_status(22) = longitude_direction
Alias
tx_325_status(23) = altitude 'reported in meters
Alias
tx_325_status(24) = year_of_last_gps_fix
Alias
tx_325_status(25) = julian_day_of_last_gps_fix
Alias
tx_325_status(26) = hour_of_last_gps_fix
Alias
tx_325_status(27) = minute_of_last_gps_fix
Alias
tx_325_status(28) = second_of_last_gps_fix
Alias
tx_325_status(29) = number_of_missed_gps_fixes
Alias
tx_325_status(30) = year_of_last_missed_gps_fix_attempt
Alias
tx_325_status(31) = julian_day_of_last_missed_gps_fix_att
Alias
tx_325_status(32) = hour_of_last_missed_gps_fix_attempt
Alias
tx_325_status(33) = minute_of_last_missed_gps_fix_attempt
Alias
tx_325_status(34) = second_of_last_missed_gps_fix_attempt
Alias
tx_325_status(35) = radio_gps_health
Alias
tx_325_status(36) = radio_failsafe_status
Alias
tx_325_status(37) = duration_of_last_radio_transmission
Commands used with the TX321 were named similar to
The similar, but not equivalent, command that has been added to operating systems for the older data loggers is: GOESStatus
(GOES_RCode1(1), 2)
.EnviroSatStatus
(tx_325_status)
Return values and their meanings may differ or be in different units or formats.
Code similar to the following may be appropriate for retrieving status and interpreting it:
Sub
GetTX325_StatusAndProcess 'This section of CRBasic code polls the TX325 radio and 'converts some diagnostic data into human readable values.
EnviroSatStatus
(tx_325_status)
If
(status_result = 0) Then
tx_325_status_results = "Success."
ElseIf
(status_result = -1) Then
tx_325_status_results = "Timed Out."
ElseIf
(status_result = -2) Then
tx_325_status_results = "No SOH character returned."
ElseIf
(status_result = -3) Then
tx_325_status_results = "Bad Checksum."
ElseIf
(status_result = -10) Then
tx_325_status_results = "No CTS Asserted."
EndIf
If
(time_status = &h00) Then
tx_325_time_status = "Completed OK."
ElseIf
(time_status = &h0A) Then
tx_325_time_status = "Time-of-day clock not loaded yet."
EndIf
'everything done from here is to help make things human readable
If
(status_result = 0) Then
Sprintf
(reported_radio_id_hex, "%08s"
, Hex (reported_radio_id_decimal))
'ensures we always have 8 characters shown
reported_latitude_direction_letter = CHR (latitude_direction)
reported_longitude_direction_letter = CHR (longitude_direction)
Else
reported_radio_id_hex = Hex ( 0 )
EndIf
If
(status_result = 0) Then
ConvertDayOfYear
(julian_day, reported_year, reported_month, reported_day)
current_tx325_time = reported_month & "/"
& reported_day & "/"
& _
reported_year & " "
& reported_hour & ":"
& reported_minute & _
":"
& reported_second & ":"
& reported_tenths_of_a_second
Else
current_tx325_time = "1/0/1992 0:0:0:0"
EndIf
If
(StrComp (current_tx325_time, "1/0/1992 0:0:0:0") = 0) Then
current_tx325_time = "No 3D GPS fix yet or radio is offline!"
EndIf
If
(status_result = 0) Then
year_of_last_gps_fix = year_of_last_gps_fix + 1992
ConvertDayOfYear
(julian_day_of_last_gps_fix, year_of_last_gps_fix, _
month_of_last_gps _fix,_ day_of_last_gps_fix)
last_gps_fix_time = month_of_last_gps_fix & "/"
& day_of_last_gps_fix & _
"/"
& year_of_last_gps_fix & " "
& hour_of_last_gps_fix & ":"
& _
minute_of_last_gps_fix & ":"
& second_of_last_gps_fix
Else
last_gps_fix_time = "1/0/1992 0:0:0"
EndIf
If
(StrComp (last_gps_fix_time, "1/0/1992 0:0:0") = 0) Then
last_gps_fix_time = "No 3D GPS fix yet or radio is offline!"
EndIf
If
(status_result = 0) Then
year_of_last_missed_gps_fix_attempt = year_of_last_missed_gps_fix_attempt + 1992
ConvertDayOfYear
(julian_day_of_last_missed_gps_fix_att,year_of_last_missed_gps_fix_attempt, _
month_of_last_missed_gps_attempt, day_of_last_missed_gps_attempt)
last_missed_gps_fix_attempt = month_of_last_missed_gps_attempt & "/"
& _
day_of_last_missed_gps_attempt & "/"
& year_of_last_missed_gps_fix_attempt _
& " "
& hour_of_last_missed_gps_fix_attempt & ":" & _
minute_of_last_missed_gps_fix_attempt & ":"
& _
second_of_last_missed_gps_fix_attempt
Else
last_missed_gps_fix_attempt = "1/0/1992 0:0:0"
EndIf
If
((StrComp (last_missed_gps_fix_attempt, "1/0/1992 0:0:0"
) = 0) _
AND
(status_result = 0)) Then
last_missed_gps_fix_attempt = "No misses so far!"
Else
last_missed_gps_fix_attempt = "Logger did not receive report from GOES radio."
EndIf
If
((Hex (radio_gps_health) = &h00) AND
(status_result = 0)) Then
gps_health = "Have valid GPS position fix."
ElseIf
(status_result <> 0) Then
gps_health = "No fix, radio is offline!"
ElseIf
(Hex (radio_gps_health) = &h01) Then
gps_health = "No fix, no GPS Satellites in view."
ElseIf
(Hex (radio_gps_health) = &h08) Then
gps_health = "No fix, 0 usable GPS satellites in view."
ElseIf
(Hex (radio_gps_health) = &h09) Then
gps_health = "No fix, 1 usable GPS satellites in view."
ElseIf
(Hex (radio_gps_health) = &h0A) Then
gps_health = "No fix, 2 usable GPS satellites in view."
ElseIf
(Hex (radio_gps_health) = &h0B) Then
gps_health = "No fix, 3 usable GPS satellites in view."
EndIf
If
((radio_failsafe_status = 0) AND
(status_result = 0)) Then
failsafe_status = "TX325 is idle."
ElseIf
((radio_failsafe_status = 1) AND
(status_result = 0)) Then
failsafe_status = "Transmit in progress."
ElseIf
((radio_failsafe_status = 2) AND
(status_result = 0)) Then
failsafe_status = "Post-transmitfailsafe wait in progress."
ElseIf
(status_result <> 0) Then
failsafe_status = "Logger did not receive report from GOES radio."
EndIf
'rt_tx_data_result_code = -99
If
(st_tx_data_result_code = -99) Then
self_timed_transmission_status = "Logger has not tried to send self-timed data."
ElseIf
(st_tx_data_result_code = 0) Then
self_timed_transmission_status = "Successful EnviroSatData execution for self-timed."
ElseIf
(st_tx_data_result_code = -11) Then
self_timed_transmission_status = "Buffer control error."
ElseIf
(st_tx_data_result_code = -16) Then
self_timed_transmission_status = "Illegal data format sent to the TX325."
ElseIf
(st_tx_data_result_code = -17) Then
self_timed_transmission_status = "Data format 0 or 1, but table not FP2 or ASCII."
ElseIf
(st_tx_data_result_code = -22) Then
self_timed_transmission_status = "TX325 not setup correctly by logger."
EndIf
If
(rt_tx_data_result_code = -99) Then
random_transmission_status = "Logger has not tried to send Random data."
ElseIf
(rt_tx_data_result_code = 0) Then
random_transmission_status = "Successful EnviroSatData execution for Random."
ElseIf
(rt_tx_data_result_code = -11) Then
random_transmission_status = "There was a buffer control error."
ElseIf
(rt_tx_data_result_code = -16) Then
random_transmission_status = "Illegal data format was sent to the TX325."
ElseIf
(rt_tx_data_result_code = -17) Then
random_transmission_status = "Data format 0 or 1, but table not FP2 or ASCII."
ElseIf
(rt_tx_data_result_code = -22) Then
random_transmission_status = "TX325 was not setup correctly by the data logger."
EndIf
'convert millivolts to volts
current_radio_battery_voltage = radio_battery_voltage * .001
current_radio_battery_during_last_tx = radio_battery_during_last_tx * .001
current_battery_voltage_before_last_tx = radio_battery_voltage_before_last_tx * .001
If
(status_result <> 0) Then
Erase (tx_325_status())
EndSub
Because of priority and available memory, some status reports that were available on the TX321 may not be available from the commands implemented for the TX325 in the OS update for the older data loggers. These include (but may not be limited to): ForwardPower
, ReflectPower
, GPS_Acq_Time
, and Osc_Drift
.
When using the older data logger operating systems the status is only available as a response from the EnviroSatStatus
command. Campbell Scientific recommends calling EnviroSatStatus
when current information is needed. The following program exerts does this adding a trigger when the command is used to set the data logger clock:
' Run following commands everyday at 12 hours and 13 minutes.
If
(Time_733m_24h OR set_clock_from_GPS) Then
set_clock_from_GPS = False
' Obtain GPS time
.
Call
GetTX325_StatusAndProcess
' Ensure the GOES GPS command executed successfully
If
(tx_325_status_results = "Success."
_
AND
tx_325_time_status = "Completed OK."
)
Then
GOES_Time(1) = reported_year
GOES_Time(2) = reported_month
GOES_Time(3) = reported_day
GOES_Time(4) = reported_hour
GOES_Time(5) = reported_minute
GOES_Time(6) = reported_second
GOES_Time(7) = reported_tenths_of_a_second * 100000 'tenths to microsec
EndIf
' Ensure the returned time is valid.
If
(GOES_Time(4) >= 0 AND
GOES_Time(4) < 24 AND
GOES_Time(5) >= 0 _
AND
GOES_Time(5) < 60 AND
GOES_Time(6) >= 0 AND
GOES_Time(6) < 60)
Then
' Set the data logger clock to match the GPS time
.
ClockSet
(GOES_Time(1))
Setting the data logger clock to match the GPS time can also be accomplished by adding the status values to the Numeric Display in LoggerNet and toggling set_clock_from_GPS to True.
Save this Numeric Display configuration by clicking Numeric Display > Options…> Setup> Save config. By saving the configuration, users can easily access it at a field site to determine if the TX325 is operating as expected.
Setting the data logger clock is required to determine the Month and Day of the Month. The status array includes the Day of the Year, which must be converted. The conversion will depend on if it is a Leap Year.
The previous code calls the following subroutine:
'This subroutine converts day of year (DOY) to months and years
Sub
ConvertDayOfYear (_day_of_year As Long, _year As Long, _month As Long, _day As Long)
Dim
leap_year As Boolean
If
(_year MOD 4 = 0) Then 'If the year is divisible by 4
leap_year = TRUE
If
(_year MOD 100 = 0) AND (_year MOD 400 <> 0) Then
'centuries are not leap years unless they are also divisible by 400
'see https://docs.microsoft.com/en-us/office/troubleshoot/excel/determine-a-leap-year
leap_year = FALSE
EndIf
Else
leap_year = FALSE
EndIf
If
leap_year = FALSE Then
'Is the month January
If
_day_of_year <= 31 Then
_month = 1 : _day = _day_of_year
'Is the month February
ElseIf
_day_of_year > 31 AND
_day_of_year <= 59 Then
_month = 2 : _day = _day_of_year - 31
'Is the month March
ElseIf
_day_of_year > 59 AND
_day_of_year <= 90 Then
_month = 3 : _day = _day_of_year - 59
'Is the month April
ElseIf
_day_of_year > 90 AND
_day_of_year <= 120 Then
_month = 4 : _day = _day_of_year - 90
'Is the month May
ElseIf
_day_of_year > 120 AND
_day_of_year <= 151 Then
_month = 5 : _day = _day_of_year - 120
'Is the month June
ElseIf
_day_of_year > 151 AND
_day_of_year <= 181 Then
_month = 6 : _day = _day_of_year - 151
'Is the month July
ElseIf
_day_of_year > 181 AND
_day_of_year <= 212 Then
_month = 7 : _day = _day_of_year -181
'Is the month August
ElseIf
_day_of_year > 212 AND
_day_of_year <=243 Then
_month = 8 : _day = _day_of_year - 212
'Is the month September
ElseIf
_day_of_year > 243 AND
_day_of_year <= 273 Then
_month = 9 : _day = _day_of_year - 243
'Is the month October
ElseIf
_day_of_year > 273 AND
_day_of_year <= 304 Then
_month = 10 : _day = _day_of_year - 273
'Is the month November
ElseIf
_day_of_year > 304 AND
_day_of_year <= 334 Then
month = 11 : _day = _day_of_year - 304
'Is the month December
ElseIf
_day_of_year > 334 Then
_month = 12 : _day = _day_of_year - 334
EndIf
ElseIf
leap_year = TRUE Then
'Are we in the month of January
'Is the month January
If
_day_of_year <= 31 Then
_month = 1 : _day = _day_of_year
'Is the month February
ElseIf
_day_of_year > 31 AND
_day_of_year <= 60 Then
_month = 2 : _day = _day_of_year - 31
'Is the month March
ElseIf
_day_of_year > 60 AND
_day_of_year <= 91 Then
_month = 3 : _day = _day_of_year - 60
'Is the month April
ElseIf
_day_of_year > 91 AND
_day_of_year <= 121 Then
_month = 4 : _day = _day_of_year - 91
'Is the month May
ElseIf
_day_of_year > 121 AND
_day_of_year <= 152 Then
_month = 5 : _day = _day_of_year - 121
'Is the month June
ElseIf
_day_of_year > 152 AND
_day_of_year <= 182 Then
_month = 6 : _day = _day_of_year - 152
'Is the month July
ElseIf
_day_of_year > 182 AND
_day_of_year <= 213 Then
_month = 7 : _day = _day_of_year -182
'Is the month August
ElseIf
_day_of_year > 213 AND
_day_of_year <=244 Then
_month = 8 : _day = _day_of_year - 213
'Is the month September
ElseIf
_day_of_year > 244 AND
_day_of_year <= 274 Then
_month = 9 : _day = _day_of_year - 244
'Is the month October
ElseIf
_day_of_year > 274 AND
_day_of_year <= 305 Then
_month = 10 : _day = _day_of_year - 274
'Is the month November
ElseIf
_day_of_year > 305 AND
_day_of_year <= 335 Then
month = 11 : _day = _day_of_year - 305
'Is the month December
ElseIf
_day_of_year > 335 Then
_month = 12 : _day = _day_of_year - 335
EndIf
EndIf
EndSub
Transmitting data
To edit the old program to transmit data, replace the GOESData()
CRBasic instruction with the EnviroSatData()
instruction. Refer to the CRBasic Editor help to determine the changes that need to be made to the parameters.
The GOESData()
, GOESGPS()
, GOESSetup()
, and GOESStatus()
CRBasic instructions are not compatible with the TX325. Replace these instructions with the EnviroSat()
instructions for the required functionality.
Connection to the data logger RS-232 with LoggerNet
Once a program has been run that sends data to the TX325 through the RS-232 port, the RS-232 port will remain configured at 9600 baud, even after a power cycle. To use the RS-232 interface for LoggerNet at its normal baud rate, do the following:
-
Connect the SC32B to the data logger CS I/O port.
-
Connect to the data logger with the Device Configuration Utility software.
-
Select the File Control tab, select the running program, then click Stop. Backup the data logger if desired.
-
Select Deployment> Com Ports Settings > ComPort RS-232.
-
Set the Baud Rate to 115200 Auto, then click Apply.
CAUTION:Do not run the program again until the RS-232 port is no longer needed.
-
Connect to the data logger RS-232 port from the computer running LoggerNet.
CAUTION:Do not use the SC32B.
-
Load an OS or other desired task.
After loading and running the program using the RS-232 port to transfer data to a TX325, it will again be set to 9600 baud and will not be able to reliably communicate with LoggerNet until the program has stopped from running. When sending a large file like the OS, it will transfer much faster at 115200 rather than 9600 baud.