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.

Output to Serial and TCP at same time.


FredH May 31, 2012 08:52 PM

I have a CR1000 that is serially connected to an embedded XP machine that is currently reading vaules for a Met tower at one of our Wind Farms. I recently installed a NL120 onto the CR1000 so that I could get a seperate data feed over Modbus TCP/IP for a different system.

So what I need is the CR1000 to speak on both the serial port and the TCP port (using ModbusSlave over TCP) at the same time.

Below is the current configuration that is working using the serial port. I've added in the lines I think I need to get the modbusslave over tcp to work but so far no luck. Anyone know what I'm doing wrong?

-------------------------------------
'CR1000

'Declare Variables and Units
Public Batt_Volt
Public WS_ms
Public WS_ms_2
Public WS_ms_3
Public WindDir
Public WindDir_2
Public T107_C
Public WS_ms_4
Public BP_mbar
Public MTable(10)
Public modcoil(10) as boolean

Units Batt_Volt=Volts
Units WS_ms=meters/second
Units WS_ms_2=meters/second
Units WS_ms_3=meters/second
Units WindDir=degrees
Units WindDir_2=degrees
Units T107_C=Deg C
Units WS_ms_4=meters/second
Units BP_mbar=mbar

'Define Data Tables
DataTable(Ten_Min,True,-1)
DataInterval(0,10,Min,10)
Average(1,Batt_Volt,FP2,False)
Maximum(1,Batt_Volt,FP2,False,False)
Minimum(1,Batt_Volt,FP2,False,False)
StdDev(1,Batt_Volt,FP2,False)
Average(1,WS_ms,FP2,False)
Maximum(1,WS_ms,FP2,False,False)
Minimum(1,WS_ms,FP2,False,False)
StdDev(1,WS_ms,FP2,False)
Average(1,WS_ms_2,FP2,False)
Maximum(1,WS_ms_2,FP2,False,False)
Minimum(1,WS_ms_2,FP2,False,False)
StdDev(1,WS_ms_2,FP2,False)
Average(1,WS_ms_3,FP2,False)
Maximum(1,WS_ms_3,FP2,False,False)
Minimum(1,WS_ms_3,FP2,False,False)
StdDev(1,WS_ms_3,FP2,False)
Average(1,WS_ms_4,FP2,False)
Maximum(1,WS_ms_4,FP2,False,False)
Minimum(1,WS_ms_4,FP2,False,False)
StdDev(1,WS_ms_4,FP2,False)
WindVector (1,WS_ms,WindDir,FP2,False,0,0,0)
FieldNames("WS_ms_S_WVT,WindDir_D1_WVT,WindDir_SD1_WVT")
WindVector (1,WS_ms_2,WindDir_2,FP2,False,0,0,0)
FieldNames("WS_ms_2_S_WVT,WindDir_2_D1_WVT,WindDir_2_SD1_WVT")
Average(1,T107_C,FP2,False)
Maximum(1,T107_C,FP2,False,False)
Minimum(1,T107_C,FP2,False,False)
StdDev(1,T107_C,FP2,False)
Average(1,BP_mbar,FP2,False)
Maximum(1,BP_mbar,FP2,False,False)
Minimum(1,BP_mbar,FP2,False,False)
StdDev(1,BP_mbar,FP2,False)
EndTable

'Main Program
BeginProg


' This is the line I added for the NL120 connection
ModBusSlave(502,9600,1,MTable(),ModCoil())

Scan(5,Sec,1,0)
'Default Datalogger Battery Voltage measurement Batt_Volt:
Battery(Batt_Volt)
'NRG #40 Wind Speed Sensor measurements WS_ms:
PulseCount(WS_ms,1,11,0,1,0.765,0.35)
If WS_ms<0.36 Then WS_ms=0
'NRG #40 Wind Speed Sensor measurements WS_ms_2:
PulseCount(WS_ms_2,1,12,0,1,0.765,0.35)
If WS_ms_2<0.36 Then WS_ms_2=0
'NRG #40 Wind Speed Sensor measurements WS_ms_3:
PulseCount(WS_ms_3,1,13,0,1,0.765,0.35)
If WS_ms_3<0.36 Then WS_ms_3=0
'NRG #40 Wind Speed Sensor measurements WS_ms_4:
PulseCount(WS_ms_4,1,14,0,1,0.765,0.35)
If WS_ms_4<0.36 Then WS_ms_4=0
'NRG #200P Wind Direction Sensor measurements WindDir:
BrHalf(WindDir,1,mV2500,1,1,1,2500,True,0,_60Hz,360.0,0)
If WindDir>=360 Then WindDir=0
'NRG #200P Wind Direction Sensor measurements WindDir_2:
BrHalf(WindDir_2,1,mV2500,2,1,1,2500,True,0,_60Hz,360.0,0)
If WindDir_2>=360 Then WindDir_2=0
'107 Temperature Probe measurement T107_C:
Therm107(T107_C,1,3,1,0,_60Hz,1.0,0.0)
'CS100 Barometric Pressure Sensor measurement BP_mbar:
PortSet(5,1)
VoltSE(BP_mbar,1,mV2500,4,1,0,_60Hz,0.2,600.0)
BP_mbar=BP_mbar*1.0
'Call Data Tables and Store Data
CallTable(Ten_Min)


' Added the section below to populate the MTable with the values needed for the TCP connection

MTable(1) = WS_ms
MTable(2) = WS_ms_2
MTable(3) = WS_ms_3
MTable(4) = WS_ms_4
MTable(5) = WindDir
MTable(6) = T107_C
MTable(7) = BP_mbar


NextScan
EndProg

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

Any help would be appreciated.

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