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.

GetVariables command stalls scan


Nathan Aug 31, 2017 11:12 PM

I'm trying to learn more about the GetVariables command so I can use in in my network of data loggers. I'll have one CR310-RF407 that will act as a router with 4 CR300-RF407 data loggers as leaf data loggers in the network. I would like the CR310 to collect data from sensors AND get data from the leaf data loggers, then put all data into a single table. I have included a simplified program below for the CR310-RF407 where it measures air temperature and gets the air temperature and time stamp from the 4 leaf data loggers using the GetVariables command. The program works fine...but...

PROBLEM - When I power down the leaf data loggers the CR310 stops recording all data. It is like the scan stalls until the leaf data loggers are back on. I put in a timeout of "50", which should be 0.50 sec. If the leaf data loggers (one or more) are unavailable, then I expected the timeout instruction to cause the scan to pause for 0.5 sec for each GetVariables command (there are 8 in the program) and then complete the scan. In this scenario I expected to have a 4 sec delay, or I would miss 4 seconds of data. However, when I tested this in the lab by powering down the leaf data loggers for 70 sec, I missed all 70 seconds of data on the router (i.e., data was not written to any of the tables for 70 seconds, or until the leaf data loggers were powered back on). This same problem occurs even if only one leaf data logger loses power.

Is there a way to stop this from occurring? I would like to make sure that the router data logger continues to collect and record data even when there is an interruption in the communication with one or more leaf data loggers (i.e., a leaf data logger loses power). Can someone help? Thanks!

--------------------------------

'CR300 Series

'Declare Variables and Units
Public BattV
Public PTemp_C
Public Temp_C
Public DLResp(4)
Public RemoteT(4)
Public GVPass(4)
Public TSResp(4)
Public RemoteTS(4) As String * 25
Public Tstamp As String * 25
Public GVPass2(4)

Units BattV=Volts
Units PTemp_C=Deg C
Units Temp_C=Deg C

'Define Data Tables
   DataTable(OneMin,True,-1)
   DataInterval(0,1,Min,0)
   Average(1,BattV,FP2,False)
   Average(1,PTemp_C,FP2,False)
   Average(1,Temp_C,FP2,False)
EndTable

DataTable(OneSec,True,-1)
   DataInterval(0,1,Sec,0)
   Average(1,BattV,FP2,False)
   Average(1,PTemp_C,FP2,False)
   Average(1,Temp_C,FP2,False)
EndTable

DataTable(RemoteTemp,True,-1)
   DataInterval(0,1,Min,0)
   Average(4,RemoteT(),FP2,False)
   Totalize(4,GVPass(),FP2,False)
EndTable

DataTable(RemoteTime,True,-1)
   DataInterval(0,10,Sec,0)
   Sample(1,Tstamp,String)
   Sample(4,RemoteTS(),String)
   Sample(1,Temp_C,FP2)
   Sample(4,RemoteT(),FP2)
   Totalize(4,GVPass2(),FP2,False)
EndTable

'Main Program
   BeginProg
'Main Scan
   Scan(1,Sec,1,0)
'Default CR300 Datalogger Battery Voltage measurement 'BattV'
   Battery(BattV)
'Default CR300 Datalogger Wiring Panel Temperature measurement 'PTemp_C'
   PanelTemp(PTemp_C,60)
'Type T (copper-constantan) Thermocouple measurements 'Temp_C'
   TCDiff(Temp_C,1,mv34,1,TypeT,PTemp_C,True,0,60,1,0)
'Get current time stamp
   Tstamp=Status.Timestamp(1,1)
'Call Data Tables and Store Data
   CallTable OneSec
   CallTable OneMin
'Get Variables from leaf dataloggers
   GetVariables(DLResp(1),ComRF,0,333,0,50,"Public","Temp_C",RemoteT(1),1)
   GetVariables(DLResp(2),ComRF,0,334,0,50,"Public","Temp_C",RemoteT(2),1)
   GetVariables(DLResp(3),ComRF,0,335,0,50,"Public","Temp_C",RemoteT(3),1)
   GetVariables(DLResp(4),ComRF,0,336,0,50,"Public","Temp_C",RemoteT(4),1)
'Record if GetVariable command was successful
   GVPass(1) = IIF (DLResp(1) = 0,1,0)
   GVPass(2) = IIF (DLResp(2) = 0,1,0)
   GVPass(3) = IIF (DLResp(3) = 0,1,0)
   GVPass(4) = IIF (DLResp(4) = 0,1,0)
'Call Table to store remote data
   CallTable RemoteTemp
'Get Variables from leaf dataloggers
   GetVariables(TSResp(1),ComRF,0,333,0,50,"Public","Tstamp",RemoteTS(1),1)
   GetVariables(TSResp(2),ComRF,0,334,0,50,"Public","Tstamp",RemoteTS(2),1)
   GetVariables(TSResp(3),ComRF,0,335,0,50,"Public","Tstamp",RemoteTS(3),1)
   GetVariables(TSResp(4),ComRF,0,336,0,50,"Public","Tstamp",RemoteTS(4),1)
'Record if GetVariable command was successful
   GVPass2(1) = IIF (TSResp(1) = 0,1,0)
   GVPass2(2) = IIF (TSResp(2) = 0,1,0)
   GVPass2(3) = IIF (TSResp(3) = 0,1,0)
   GVPass2(4) = IIF (TSResp(4) = 0,1,0)
'Call Table to store remote data
   CallTable RemoteTime
NextScan
EndProg


Dana Sep 1, 2017 10:10 PM

Hello Nathan,

Look at putting your GetVariables instructions in a SlowSequence scan. If the datalogger program compiles in Pipeline Mode (which is should by default, unless something in your program requires it to compile in Sequential Mode), then the datalogger's main scan will have priority. The instructions in the slow sequence will be handled during the datalogger's "down time" when it's not running the main scan. The datalogger basically runs the main scan, begins running the slow sequence, goes back to the main scan when it's time, and then goes back to finish up the slow scan it started.

The CRBasic help has additional information on using the SlowSequence scan, and also info on Pipeline Mode if you are interested. 

Best, Dana

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