Appendix B. Example Programs
B-7
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 minumim reading but will be measured on the scan interval
'in this case 10 seconds.
DataInterval (0,15,Min,10)
Minimum (1,batt_volt,FP2,0,False)
EndTable
'Main Program
BeginProg
'The following text is associated with the numeric response codes provided
'from the sampler after each attempted sample.
Response_List(1) = "No error"
Response_List(2) = "All samples complete"
Response_List(3) = "Low start battery (V<11.0 V)"
Response_List(4) = "Low run battery (V<10.5V)"
Response_List(5) = "Sampler vaccuum timed out, no sample detected"
Response_List(6) = "Sample overflow detected"
Response_List(7) = "No sample liquid detected"
Response_List(8) = "Arm calibration error"
Response_List(9) = "Conductivity rod and Sample tube are shorted"
MBAddress = 0 'This must also be set in Devconfig for each sampler. The address
'must be unique if you are using multiple samplers.
AutoRun=true 'initialize to True but the user can stop the sampler from sampling
'by changing it to false in the public table.
'Right now this sample program scans every 10 seconds and triggers the sampler once every 15 minutes
'Both the scan interval and the sampler time can be adjusted as needed.
Scan (10,Sec,0,0)
Battery (batt_volt)
CallTable logger_battery
If IfTime(0,15,Min) AND AutoRun=true Then 'If you are 0 seconds into the 15 minute interval and autorun is true
Run_sampler = true 'Then set "Run_sampler" flag to True
EndIf
If GetStatus=true Then 'if GetStatus is true then read control variable from the sampler (modbus device)
ModbusMaster (MbResult(1),ComSDC7,38400,MBAddress,1,Start_sample,1,1,3,100,0)
If Start_sample <> True AND MbResult(1)=0 Then 'if start_sample is NOT true and MbResult(1) = 0 then
'get the sampler status values
ModbusMaster (MbResult(3),ComSDC7,38400,MBAddress,3,Sampler_status(),23,4,3,100,0)'reading actual status values
response_code_message = Response_List(Respo1)'adjust the numeric response code the to assigned message
CallTable SamplerStat 'send the sampler status to the table
GetStatus=false
ElseIf MbResult(1)<> 0 OR MbResult(3) <> 0 Then 'else if MbResult (1) or (3) does NOT = 0 then write to
'the error table
CallTable ModbusErrors
EndIf
EndIf
If Run_sampler Then 'if Run_sampler is True then set the control variable true and set the start flag in the sampler
Start_sample = true
ModbusMaster (MbResult(2),ComSDC7,38400,MBAddress,15,Start_sample,1,1,3,100,0) 'Function 15 is setting
'the flag in the sampler
If MbResult(2)<>0 Then 'if there was an error in communicating with the sampler write to the error table
CallTable ModbusErrors
Else
GetStatus = true 'set getstatus true so on the next scan the logger knows to ask for the
'sampler_status values of the new sample.
EndIf
Run_sampler = false
EndIf
NextScan
EndProg
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: ......