Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

SDI12 Concurrent Measurements


JohnTr Aug 1, 2011 04:54 PM

I have my SDI12Recorder(...) in a For...Next loop that will increment through the sensor addresses found in a previously run subroutine. For testing purposes I have 4 sensors (ECI crossion monitors) connected to CR800. When I issue the C! command only the first loop is of the For...Next is executed and then the scan is repeated starting the For...Next all over. If I issue a V! command the For...Next operates correctly.

Why is this not working for concurrent measurements?

Program is below:

'Set mode of operation; Pipeline is default
PipeLineMode

'Declare Constants
' set ECI Sensor Scan parameters
Const SensorInterval = 20 'Scan frequency value
Const SensorUnits =3 'Scan frequency units: 1=msec, 2=sec, 3=min, 4=hr, 5=day
Const SensorBuffer = 3 'Scan Buffers to use: 1, 2, >-3
Const SensorCount = 0 'Number of scans: 0 = infinite

' set SDI12 Communications parameters
Const SDICPort = 3 'SDI Control Port on Datalogger
Const SDIMult = 1 'SDI Multiplier, multiply resutls by 1
Const SDIOffset = 0 'SDI Offset, add 0 to results

' Public Variables, available outside this program/subroutine
Public ECIResponse(10,9) 'Array to store response for up to 10 addresses (NETCON limit),
' Sensor address, 9 data elements from each sensor.
'Declare Local Variables
Dim ECIAddr(10) As String *2 'Array to record active addresses. Will fill table ECIAddrTable. Will be used
' in full program for R/T control of SDIResponse(...) statements
Dim ECIAddrList(62,2) As String *2 'Array containing all possible ECI addresses A-Z, a-z, 0-9

Dim ECIVBang As String *2="V!" 'Set V!, ECI command Verification which returns test values
Dim ECICBang As String *2="C!" 'Set C!, ECI command Concurrent Measurement
Dim I, J As Long 'R/T program control variable
Dim AddrCounter As Long 'R/T variable to keep track of how many address are active, 0-10
Dim SDICommand As String 'Sets up ECI SDI12 command variable to a string
'V0.1 Code commented out
'Dim Temp(9)
'V0.1 end 'Intermediate storage for sensor measurement

'Define DataTable
'These tables are for debugging only and will be removed in the release version....
DataTable (ECIAddrTable,True,-1) 'Output table for debugging sniffer program. Stores 0-10 address strings
Sample (10,ECIAddr(),String) 'Record 7 ECI values into the table in 4 byte floating point
EndTable
DataTable (ECIAddrListTable,True,-1) 'table is for debugging only
Sample(124,ECIAddrList(),String)
EndTable
DataTable(ECIResponseTable,True,-1) 'sensor response table
Sample(90,ECIResponse(),FP2)
EndTable

'+++++++++++++++++++++++++++++++ Subroutines +++++++++++++++++++++++++++++++++++++++
'
'Network Sniffer(Addr(),Counter) ------------------------------------------------------------------
Sub NetworkSniffer(Addr(10) As String,Counter As Long, AddrList(62,2) As String *2)
'This program will detect the address of all the ECI sensors attached to the NetCom
'via CR800 SDI12 port 3. Maximum of 10 addresses limited by NetCom capacity
'Addr() contains all found address up to 10, string
'Counter = total addresses found, 0-10 integer
'
'Start Preamble for Network Sniffer
'====================================================================================

' SDI Parameters
Const NSSDICPort = 3 'SDI Control Port on Datalogger
Const NSSDIMult = 1 'SDI Multiplier, multiply resutls by 1
Const NSSDIOffset = 0 'SDI Offset, add 0 to results

'Local Variables
'V0.1
' Dim AddrList(62,2) As String *2
'V0.1 end
Dim K As Long
Dim ASCIIstring As String *62 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
Dim aBang As String *1="!" 'Set a!, ECI command Acknowledge Active which returns the address

'End Preamble for Network Sniffer
'====================================================================================
' Start Network Sniffer Program
'This loop will fill array AddrList with ASCII values.
'K is the position of the ASCII charater in ASCIIstring
K=0
For K = 1 To 62
AddrList(K,1) = CHR(ASCII(ASCIIstring(1,1,K))) 'store the kth character in the (kth,1) elememt
AddrList(K,2) = CHR(0) 'store NULL in the (kth,2) element
Next
'This loop will initialize the ECI found address array with NULL
K = 0
For K= 1 To 10
Addr(I) = CHR(0)
Next
'Scan Loop
'Initialize R/T variables
K=0
Counter = 0
For K = 1 To 62
'send ECI Acknowledge Active command to address list array column 1
'record Acknowkedge Active response, the address, in address list array column 2
SDI12Recorder (AddrList(K,2),NSSDICPort,AddrList(K,1),aBang,NSSDIMult,NSSDIOffset)
If AddrList(K,2) <> "NAN" Then 'if an address was found....
Counter=Counter + 1 'increment the addresscounter, yes we found one more
Addr(Counter) = AddrList(K,2) 'and store the found address in ECIAddr()
If Counter=10 Then Exit For 'if 10 addresses (the maximum) have been found stop looking
EndIf
Next
'if you got to here and K NE 62, keep looking for addresses
EndSub

'End Network Sniffer Subroutine -----------------------------------------------------------------
'++++++++++++++++++++++++++++++ End Subroutines ++++++++++++++++++++++++++++++++++++
'End Preamble
'====================================================================================
'Start Program
BeginProg
'
'============================================= ECI Sensor Measurement ================================================
'Scan Loop
'initialize R/T variabled

I=0 : J=0
SDICommand=ECICBang
'Scan Loop
Scan(SensorInterval,SensorUnits,SensorBuffer,SensorCount)
'this loop will step through all the local ECI sensors found in the NetworkSniffer
'detect all available ECI sensor addresses
Call NetworkSniffer(ECIAddr(),AddrCounter,ECIAddrList())
For I = 1 To AddrCounter 'AdddCounter = count of all found addresses
If AddrCounter = 0 Then Exit 'no addresses were found so exit the loop
'
'SDICommand = C!
'
SDI12Recorder (ECIResponse(I,1),SDICPort,ECIAddr(I),SDICommand,SDIMult,SDIOffset)
Next
CallTable (ECIAddrTable) 'Output ECI active addresses on this local network
CallTable(ECIAddrListTable) 'For program Debugging
CallTable(ECIResponseTable)
NextScan
'End Scan Loop
'============================================= End ECI Sensor Measurement ============================================

EndProg


Sam Aug 2, 2011 12:17 AM

JohnTr,

It might be helpful if you could capture the traffic between your logger and the sensors. Make sure you have the latest OS loaded. Open a terminal session with the logger, probably on the RS-232 or CS I/O port, and press enter repeatedly to get the CR1000 prompt. Then use W to 'watch' the SDI-12 port of interest. Make sure that the logger is transmitting and the sensor is responding as expected.


JohnTr Aug 2, 2011 02:06 PM

Sam,

I have a Digital Phosphor Oscilloscope connected to the SDI output and can monitor the traffic between the CR800 and sensors. With this 'scope I can see the bus data in waveform and ASCII. With the current configuration of program all of the connected sensor addresses are being detected in a For...Next loop using a! command; but when we get to the For...Next loop using C! only the first address is sent with a response from the addressed sensor. Eventually we receive databack from the addressed sensor and the scan loop starts over.

If I replace the FOR...Next with 4 SDI12Recorder(...) statements using C!, concurrent measurement, all 4 addresses acknolowedge in sequence with the address, time to response, and number of fields. After an appropriate delay the sensors all send back data.The sensors that we are using all respond with a 660 sec ttt value which is normal for these sensors.

OS Version: CR800.Std.08
OS Date: 090604
OS Signature: 58368


jra Aug 2, 2011 02:37 PM

JohnTr,

The Concurrent measurement command is different than other SDI commands in that the datalogger has to execute it twice some time apart. The caveat is that it has to execute the exact same line of code twice. So, putting the C! command in a loop changing the address is going to cause that one line of code to change and therefore abort any previous command from that line.

In short, as you found out, take the C! out of the loop and it'll work as expected.

Regards,
Janet


JohnTr Aug 2, 2011 03:41 PM

Thankyou. That explanation makes sense. I have modified the design to use If...Then...Else statements for address detection in the Scan Loop. This works well.

Thx for your help.

Log in or register to post/reply in the forum.