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.

Need help with GetDataRecord to transmit data from Slave CR1000 to Base CR1000


Maestropolo Mar 30, 2013 01:15 PM

Hi everybody,
I have developed these programs to trasnfer data from a slave station to a base station. My setup is as follows:
Slave(CR1000+RF450)---->Base(CR1000+RF450)--->Satellite Transmitter.
I have had some successes with the transmission only when the slave station program is compiled after the base station program was compiled but it is a pain for me to go to the slave station and not sure I obtained the right data from the slave. I suspect that the 32768 added to the table number does not consider the difference in table sizes or the table named Fondwa is not recognized as the first table in the slave station datalogger even though it is declared first as the GetDataRecord instruction said it.
Can you, guys, help me out?

Base Station Program:
'CR1000
'Created by Paul Celicourt

SequentialMode
Public BC_Rec_No
Public BC_Last_Rec_No
Public FD_Rec_No
Public FD_Last_Rec_No
Public FD_Dataout
Public BC_Dataout

'Local Table Variables Declaration
Public Rain_inch
Public Air_TC
Public R_H
Public Slr_W
Public Slr_MJ
Public WindS_ms
Public Wind_Dir
Public PA_uS
Public V_W
Public Batt_V

'Remote Table Variables Declaration
Public Rain_in
Public AirTC
Public RH
Public VW
Public SlrW
Public SlrMJ
Public WS_ms
Public WindDir
Public BattV
Public Result

'Modbus Related Variables declaration
Public RxResponse As Boolean
Public ModBusSource(22)

'Local Table Units Declaration
Units PA_uS=uSec
Units Rain_inch=inch
Units Air_TC=Deg C
Units R_H=%
Units Slr_W=W/m^2
Units Slr_MJ=MJ/m^2
Units WindS_ms=meters/second
Units Wind_Dir=degrees
Units Batt_V=Volts
Units V_W=%

'Remote Table Units Declaration
Units Rain_in=inch
Units AirTC=Deg C
Units RH=%
Units SlrW=W/m^2
Units SlrMJ=MJ/m^2
Units WS_ms=meters/second
Units WindDir=degrees
Units BattV=Volts
Units VW=%

'Define Local Data Tables
DataTable(Beloc,True,-1)
DataInterval(0,1,Hr,10)
Average(1,V_W,FP2,False)
Maximum(1,R_H,FP2,False,True)
Average(1,Air_TC,FP2,False)
Average(1,Slr_W,FP2,False)
Totalize(1,Slr_MJ,IEEE4,False)
Totalize(1,Rain_inch,FP2,False)
Average(1,WindS_ms,FP2,False)
WindVector (1,WindS_ms,Wind_Dir,FP2,False,0,0,0)
FieldNames("WS_ms_S_WVT,Wind_Dir_D1_WVT,Wind_Dir_SD1_WVT")
Average(1,Batt_V,FP2,False)
EndTable

DataTable(Beloc5Mn,True,-1)
DataInterval(0,5,Min,10)
Totalize(1,Rain_inch,FP2,False)
Average(1,WindS_ms,FP2,False)
Sample(1,Wind_Dir,FP2)
EndTable

'Add data to Beloc ModBus Source
Sub AssignData
BC_Rec_No=Beloc.Record(1,1) 'Get the current record number,
BC_Dataout=BC_Rec_No>BC_Last_Rec_No 'compare current record number to last record number
If BC_Dataout Then 'If Rec_No is greater than Last_Rec_No
ModBusSource(1)=Beloc.TimeStamp(0,1)
ModBusSource(2)=Beloc.R_H_Max(1,1)
ModBusSource(3)=Beloc.Air_TC_Avg(1,1)
ModBusSource(4)=Beloc.Slr_W_Avg(1,1)
ModBusSource(5)=Beloc.Slr_MJ_TOT(1,1)
ModBusSource(6)=Beloc.WindS_ms_Avg(1,1)
ModBusSource(7)=Beloc.Wind_Dir_D1_WVT (1,1)
ModBusSource(8)=Beloc.Rain_inch_TOT(1,1)
ModBusSource(9)=Beloc.Batt_V_AVG(1,1)
ModBusSource(10)=Beloc.V_W_AVG(1,1)
BC_Last_Rec_No=BC_Rec_No
EndIf
Exit Sub
EndSub

'Main Program
BeginProg
FD_Last_Rec_No=0
BC_Last_Rec_No=0
Scan(5,Sec,1,0)
'Volumetric water content measurements
CS616(PA_uS,1,1,1,1,1,0)
V_W=-0.0663+(-0.0063*PA_uS)+(0.0007*PA_uS^2)
'TB4/TB4MM Rain Gauge measurement Rain_in
PulseCount(Rain_inch,1,1,2,0,0.01,0)
'HMP50 Temperature & Relative Humidity Sensor measurements AirTC and RH
VoltSe(Air_TC,1,mV2500,1,0,0,_60Hz,0.1,-40)
VoltSe(R_H,1,mV2500,2,0,0,_60Hz,0.1,0)
If (R_H>100) AND (R_H<108) Then R_H=100
'CS300 Pyranometer measurements SlrMJ and SlrW
VoltSe(Slr_W,1,mV250,3,1,0,_60Hz,1,0)
If Slr_W<0 Then Slr_W=0
Slr_MJ=Slr_W*2.5E-05
Slr_W=Slr_W*5
Battery(Batt_V)
'034A/034B Wind Speed & Direction Sensor measurements WS_ms and WindDir
PulseCount(WindS_ms,1,2,2,1,0.799,0.2811)
If WindS_ms=0.2811 Then WindS_ms=0
BrHalf(Wind_Dir,1,mV2500,4,1,1,2500,True,0,_60Hz,720,0)
If Wind_Dir>=360 Then Wind_Dir=0
'Call Data Tables and Store Data
CallTable(Beloc)
CallTable(Beloc5Mn)
Call AssignData
NextScan

SlowSequence
'Define Remote Data Tables
DataTable(Fondwa,True,-1)
DataInterval(0,1,Hr,10)
Totalize(1,Rain_in,FP2,False)
FieldNames("FD_Rain_in_TOT")
Average(1,AirTC,FP2,False)
FieldNames("FD_AirTC_AVG")
Maximum(1,RH,FP2,False,True)
FieldNames("FD_RH_MAX,FD_RH_TMx")
Average(1,VW,FP2,False)
FieldNames("FD_VW_AVG")
Average(1,SlrW,FP2,False)
FieldNames("FD_SlrW_AVG")
Totalize(1,SlrMJ,IEEE4,False)
FieldNames("FD_SlrMJ_TOT")
Average(1,WS_ms,FP2,False)
FieldNames("FD_WS_ms_AVG")
WindVector (1,WS_ms,WindDir,FP2,False,0,0,0)
FieldNames("FD_WS_ms_S_WVT,FD_WindDir_D1_WVT,FD_WindDir_SD1_WVT")
Average(1,BattV,FP2,False)
EndTable

Scan(15,Sec,1,0)
If Result = -22 Then SerialFlush(ComSDC7)
GetDataRecord (Result,ComSDC7,0,3,0,6000,10,132768,Fondwa,1)
FD_Rec_No=Fondwa.Record(1,1) 'Get the current record number,
FD_Dataout=FD_Rec_No>FD_Last_Rec_No 'If Rec_No is greater than Last_Rec_No
If FD_Dataout Then
ModBusSource(13)=Fondwa.TimeStamp(0,1)
ModBusSource(14)=Fondwa.BattV_AVG(1,1)
ModBusSource(15)=Fondwa.FD_RH_Max(1,1)
ModBusSource(16)=Fondwa.FD_AirTC_Avg(1,1)
ModBusSource(17)=Fondwa.FD_SlrW_Avg(1,1)
ModBusSource(18)=Fondwa.FD_SlrMJ_TOT(1,1)
ModBusSource(19)=Fondwa.FD_Rain_in_TOT(1,1)
ModBusSource(20)=Fondwa.FD_WS_ms_Avg(1,1)
ModBusSource(21)=Fondwa.FD_WindDir_D1_WVT (1,1)
ModBusSource(22)=Fondwa.FD_VW_AVG (1,1)
FD_Last_Rec_No=FD_Rec_No
EndIf
NextScan

SlowSequence
Scan(5,Min,1,0)
If TimeIntoInterval(10,20,Min) Then
ModBusSlave (ComRS232,19200,1001,ModBusSource(1),RxResponse,2)
EndIf
NextScan
EndProg


Slave Station Program
'CR1000
'Created by Paul Celicourt

'Declare Variables and Units
Dim i
'Declare Variables and Units
Public Rain_in
Public AirTC
Public RH
Public VW
Public SlrW
Public SlrMJ
Public WS_ms
Public WindDir
Public Soil_Moist(3)
Public BattV

Units Rain_in=inch
Units AirTC=Deg C
Units RH=%
Units SlrW=W/m^2
Units SlrMJ=MJ/m^2
Units WS_ms=meters/second
Units WindDir=degrees
Units BattV=Volts
Units VW=%

'Define Data Tables
DataTable(Fondwa,True,-1)
DataInterval(0,1,Hr,10)
Totalize(1,Rain_in,FP2,False)
FieldNames("FD_Rain_in_TOT")
Average(1,AirTC,FP2,False)
FieldNames("FD_AirTC_AVG")
Maximum(1,RH,FP2,False,True)
FieldNames("FD_RH_MAX,FD_RH_TMx")
Average(1,VW,FP2,False)
FieldNames("FD_VW_AVG")
Average(1,SlrW,FP2,False)
FieldNames("FD_SlrW_AVG")
Totalize(1,SlrMJ,IEEE4,False)
FieldNames("FD_SlrMJ_TOT")
Average(1,WS_ms,FP2,False)
FieldNames("FD_WS_ms_AVG")
WindVector (1,WS_ms,WindDir,FP2,False,0,0,0)
FieldNames("FD_WS_ms_S_WVT,FD_WindDir_D1_WVT,FD_WindDir_SD1_WVT")
Average(1,BattV,FP2,False)
EndTable

DataTable(Fondwa5Mn,True,-1)
DataInterval(0,5,Min,10)
Totalize(1,Rain_in,FP2,False)
Average(1,WS_ms,FP2,False)
Sample(1,WindDir,FP2)
EndTable

DataTable(ETo,True,-1)
DataInterval(0,1,Hr,10)
ETsz(AirTC,RH,WS_ms,SlrMJ,72.62,18.49,10,2.5,0,FP2,False)
FieldNames("ETos,Rso")

EndTable

'Main Program
BeginProg
Scan(5,Sec,1,0)
'Default Datalogger Battery Voltage measurement BattV
Battery(BattV)
'TB4/TB4MM Rain Gauge measurement Rain_in
PulseCount(Rain_in,1,1,2,0,0.01,0)
'HMP50 Temperature & Relative Humidity Sensor measurements AirTC and RH
VoltSE(AirTC,1,mV2500,1,0,0,_60Hz,0.1,-40)
VoltSE(RH,1,mV2500,2,0,0,_60Hz,0.1,0)
If (RH>100) And (RH<108) Then RH=100
'CS300 Pyranometer measurements SlrMJ and SlrkW
VoltSe(SlrW,1,mV250,4,1,0,_60Hz,1,0)
If SlrW<0 Then SlrW=0
SlrMJ=SlrW*2.5E-05
SlrW=SlrW*5
'034A/034B Wind Speed & Direction Sensor measurements WS_ms and WindDir
PulseCount(WS_ms,1,2,2,1,0.799,0.2811)
If WS_ms=0.2811 Then WS_ms=0
BrHalf(WindDir,1,mV2500,4,1,1,2500,True,0,_60Hz,720,0)
If WindDir>=360 Then WindDir=0
'CS616 Water Content Reflectometer measurements VW and PA_uS
PortSet(1,1)
For i=1 To 3
SDI12Recorder (Soil_Moist(1),1,0,"M!",1.0,0)
If Soil_Moist(1)<>NAN Then ExitFor
Next i
PortSet(1,0)
VW=Soil_Moist(1)
'Call Data Tables and Store Data
CallTable(Fondwa)
CallTable(Fondwa5Mn)
CallTable(ETo)
NextScan
EndProg

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