Appendix B. Example Programs
B-4
B.2 PakBus® Example Programs
B.2.1 PakBus® Control CR1000 Program
During testing, it was helpful to include an
Autoru
n parameter as
a Boolean variable. It allows the user to set the
Autorun
variable
to false in the
Public
table before opening up the sampler for
servicing without having to cut power to either the datalogger or
the sampler. Also the list of
Responses
includes a string message
for numeric response code. This will allow a text message to be
returned to the user in the data table. The following program is
available for download from the PVS5120 webpages.
'PVS5120/VSC100 program communicating via PakBus
'hardware includes MD485
'this program also contains a Autorun variable that has to be true for the sampler to sample.
'If it is set to false it will disable the sampler until (for servicing...) it is set true again
'date: 2014-05-23
PreserveVariables
'Declare Public Variables
Public batt_volt 'storing datalogger battery voltage for quality control
Public sampler_PakBus_address 'The PakBus address is set or designated
'in DevConfig. The default value for the sampler is 95. If you have multiple samplers on the network they
each ‘need a unique PakBus address.
'The following two variables are used to convert the numeric response code value from the sampler to a text
'message.
Dim Response_List(9) As String
Public response_code_message As String
Public AutoRun As Boolean 'allows user to prevent the sampler from running on schedule via the connect screen
‘without removing power to the sampler or the logger
Public GetStatus As Boolean
Public Run_sampler As Boolean
Public Start_sample 'control variable ***Warning this CAN NOT be declared as a boolean even though you are
‘setting it true/false
Public Sampler_status(4)
'*** Status Values returned by the sampler once a sample is collected ****
Alias Sampler_status(1) = CurrentBottle 'Discrete distributor arm position
Alias Sampler_status(2) = SampleCount 'How many samples are currently in bottle
Alias Sampler_status(3) = ResponseCode 'Numeric Response Code
Alias Sampler_status(4) = SamplerBatt 'Sampler battery voltage (V)
'***Results returned for each communication instruction***
Public Result(3) 'does not have to be an array
'Define tables
DataTable (SamplerStat,True,1000) 'stores sampler status values
Sample (1,CurrentBottle,FP2)
Sample (1,SampleCount,FP2)
Sample (1,ResponseCode,FP2)
Sample (1,response_code_message,String)
Sample (1,SamplerBatt,FP2)
EndTable
DataTable (Errors,true,1000) 'stores the communication errors
Sample (3,Result(),FP2)
EndTable
DataTable (logger_battery,1,1000) 'stores the logger battery voltage for quality control in the case of
‘communication errors. It is only storing the 5 minute minimum reading but is measured on the scan interval
'in this case 10 seconds.
DataInterval (0,5,Min,10)
Minimum (1,batt_volt,FP2,0,False)
EndTable
NOTE
Summary of Contents for PVS5120 Series
Page 2: ......
Page 4: ......
Page 6: ......
Page 8: ......
Page 70: ...Appendix A Sample Transport Velocity A 2...
Page 78: ...Appendix B Example Programs B 8...
Page 86: ...Appendix C Monitoring Sampler Status via RS 485 C 8...
Page 96: ...Appendix G Generic Modbus Control G 4...
Page 100: ...Appendix H ISO5667 Conformity H 4...
Page 101: ......