Campbell Scientific NL120 NL120 Ethernet Module - Page 18

TCP ModBus

Page 18 highlights

NL120 Ethernet Module 6.6.2 Serial Output The TCPOpen() instruction must be used first to open up a TCP socket. An example of this instruction is shown below. The first parameter in TCPOpen() is the IP address to open a socket to. The second parameter is the port number to be used. The third parameter is buffer size. The TCPOpen() instruction returns the socket number of the open connection or '0' if it cannot open a connection. socket = TCPOpen("192.168.7.85",6784,100) Once a socket has been opened with the TCPOpen() instruction, serial data may be sent out with a SerialOut() instruction. An example of this instruction is shown below. The first parameter is the socket returned by the TCPOpen() instruction. The second parameter is the variable to be sent out. The third parameter is the wait string. The last parameter is the total number of times the datalogger should attempt to send the variable. For more information on this instruction, see the CRBasic Editor Help. result = SerialOut(socket,sent,"",0,100) 6.7 TCP ModBus With an NL120 attached, the datalogger can be set up as a TCP ModBus Master or Slave device. For information on configuring the datalogger as a TCP ModBus Master or Slave, see the ModBus section of the datalogger manual. 6.8 DHCP The IP address of the datalogger may be obtained through DHCP, if a DHCP server is available. The DHCP address will be automatically assigned if there is a DHCP server available and no static IP address has been entered. The IP address should be available a few minutes after the datalogger has been powered up with the NL120 attached and Ethernet cable plugged in. The IP address can be found with Device Configuration Utility's Settings tab under TCP/IP info. It can also be found using a CR1000KD attached to the datalogger. Go to Configure, Settings | Settings, scroll down to IP Status and press the right arrow. An IP address obtained through DHCP is not static but is leased for a period of time set by the network administrator. The address may change, if the datalogger is powered down. 6.9 DNS The datalogger provides a DNS client that can query a DNS server to resolve a fully qualified domain name. When a DNS server is available, domain names can be used in place of the IP address in the datalogger instructions. 12

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

NL120 Ethernet Module
6.6.2 Serial Output
The
TCPOpen()
instruction must be used first to open up a TCP socket.
An
example of this instruction is shown below.
The first parameter in
TCPOpen()
is the IP address to open a socket to.
The second parameter is the port number
to be used.
The third parameter is buffer size. The
TCPOpen()
instruction
returns the socket number of the open connection or ‘0’ if it cannot open a
connection.
socket =
TCPOpen(
“192.168.7.85”,6784,100
)
Once a socket has been opened with the
TCPOpen()
instruction, serial data
may be sent out with a
SerialOut()
instruction.
An example of this instruction
is shown below.
The first parameter is the socket returned by the
TCPOpen()
instruction.
The second parameter is the variable to be sent out.
The third
parameter is the wait string.
The last parameter is the total number of times the
datalogger should attempt to send the variable.
For more information on this
instruction, see the CRBasic Editor Help.
result
=
SerialOut(
socket,sent,"",0,100
)
6.7
TCP ModBus
With an NL120 attached, the datalogger can be set up as a TCP ModBus
Master or Slave device.
For information on configuring the datalogger as a
TCP ModBus Master or Slave, see the ModBus section of the datalogger
manual.
6.8
DHCP
The IP address of the datalogger may be obtained through DHCP, if a DHCP
server is available.
The DHCP address will be automatically assigned if there
is a DHCP server available and no static IP address has been entered.
The IP
address should be available a few minutes after the datalogger has been
powered up with the NL120 attached and Ethernet cable plugged in.
The IP
address can be found with Device Configuration Utility’s Settings tab under
TCP/IP info.
It can also be found using a CR1000KD attached to the
datalogger.
Go to Configure, Settings | Settings, scroll down to IP Status and
press the right arrow.
An IP address obtained through DHCP is not static but is leased for a period of
time set by the network administrator.
The address may change, if the
datalogger is powered down.
6.9
DNS
The datalogger provides a DNS client that can query a DNS server to resolve a
fully qualified domain name.
When a DNS server is available, domain names
can be used in place of the IP address in the datalogger instructions.
12