Campbell Scientific NL120 NL120 Ethernet Module - Page 12

Communicating over TCP/IP

Page 12 highlights

NL120 Ethernet Module 6.1 Communicating over TCP/IP Once the datalogger, the NL120, and LoggerNet have been set up as described in Sections 4.1, Physical Set-up, and 4.2, Communicating via Ethernet, communication is possible over TCP/IP. This includes program send and data collection. These are straightforward operations and are accomplished through LoggerNet's Connect screen. For more information, see the LoggerNet manual. Data callback and datalogger-to-datalogger communications are also possible over TCP/IP, as well as the creation of simple HTML pages to view datalogger variables using a web browser. 6.1.1 Data Callback The following program is an example of doing data callback over TCP/IP. It first checks to see if a port to the LoggerNet Server already exists. (The LoggerNet Server is assumed to be at the default PakBus Address, 4094.) If not, a socket to LoggerNet is opened using the TCPOpen() instruction. The SendVariables() instruction is then used to send data. PROGRAM 'CR1000 'IP_Callback.cr1 'LoggerNet server Pak Bus Address assumed = 4094 'PC IP address assumed = 192.168.7.231 'LoggerNet IPPort "IP Port Used for Call-Back" = 6785 'LoggerNet IPPort "Call-Back Enabled" is checked 'LoggerNet CR1000 "Call-Back Enabled" is checked 'LoggerNet PakBusPort "PakBus Port Always Open" is checked 'IP Call-back using auto-discover (-1) neighbor in SetVariables Public PanelTemperature, BatteryVoltage, Result1, dummy1 Dim Socket as LONG DataTable (CLBK1,1,1000) DataInterval (0,0,Sec,10) Sample (1,PanelTemperature,FP2) Sample (1,BatteryVoltage,FP2) EndTable BeginProg Scan (5,Sec,6,0) PanelTemp (PanelTemperature,250) Battery (BatteryVoltage) If not Route(4094) then Socket = TCPOpen ("192.168.7.231",6785,0) SendVariables (Result1,Socket,-1,4094,0000,100,"Public","Callback",dummy1,1) CallTable CLBK1 NextScan EndProg 6

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20

NL120 Ethernet Module
6.1
Communicating over TCP/IP
Once the datalogger, the NL120, and LoggerNet have been set up as described
in Sections 4.1,
Physical Set-up
, and 4.2,
Communicating via Ethernet
,
communication is possible over TCP/IP.
This includes program send and data
collection.
These are straightforward operations and are accomplished through
LoggerNet’s Connect screen.
For more information, see the LoggerNet
manual.
Data callback and datalogger-to-datalogger communications are also possible
over TCP/IP, as well as the creation of simple HTML pages to view datalogger
variables using a web browser.
6.1.1 Data Callback
The following program is an example of doing data callback over TCP/IP.
It
first checks to see if a port to the LoggerNet Server already exists.
(The
LoggerNet Server is assumed to be at the default PakBus Address, 4094.)
If
not, a socket to LoggerNet is opened using the
TCPOpen()
instruction.
The
SendVariables()
instruction is then used to send data.
PROGRAM
'CR1000
'IP_Callback.cr1
'LoggerNet server Pak Bus Address
assumed = 4094
'PC IP address assumed = 192.168.7.231
'LoggerNet IPPort "IP Port Used for Call-Back" = 6785
'LoggerNet IPPort "Call-Back Enabled" is checked
'LoggerNet CR1000 "Call-Back Enabled" is checked
'LoggerNet PakBusPort "PakBus Port Always Open" is checked
'IP Call-back using auto-discover (-1) neighbor in SetVariables
Public PanelTemperature, BatteryVoltage, Result1, dummy1
Dim Socket as LONG
DataTable (CLBK1,1,1000)
DataInterval (0,0,Sec,10)
Sample (1,PanelTemperature,FP2)
Sample (1,BatteryVoltage,FP2)
EndTable
BeginProg
Scan (5,Sec,6,0)
PanelTemp (PanelTemperature,250)
Battery (BatteryVoltage)
If not Route(4094) then Socket = TCPOpen ("192.168.7.231",6785,0)
SendVariables (Result1,Socket,-1,4094,0000,100,"Public","Callback",dummy1,1)
CallTable CLBK1
NextScan
EndProg
6