Transport — Physical transport layer for device communication
character vector | string
Physical transport layer for device communication, specified as a
character vector or string. Specify transport type as the first argument
when you create the modbus object. You must set the
transport type as either 'tcpip' or
'serialrtu' to designate the protocol you want to
use.
Example:m = modbus('tcpip',
'192.168.2.1')
Data Types:char
DeviceAddress — IP address or host name of MODBUS server
character vector | string
IP address or host name of MODBUS server, specified as a character
vector or string. If transport is TCP/IP, it is required as the second
argument during object creation.
Example:m = modbus('tcpip',
'192.168.2.1')
Data Types:char
Port — Remote port used by MODBUS server
502 (default) | double
Remote port used by MODBUS server, specified as a double. Optional as
a third argument during object creation if transport is TCP/IP. The
default of 502 is used if none is specified.
Example:m =
modbus('tcpip','192.168.2.1',308)
Data Types:double
'Port' — Serial port MODBUS server is connected to
character vector | string
Serial port MODBUS server is connected to, e.g.
'COM1', specified as a character vector or
string. If transport is Serial RTU, it is required as the second
argument during object creation.
Example:m =
modbus('serialrtu','COM3')
Data Types:char
Name-Value Pair Arguments
Specify optional
comma-separated pairs of Name,Value arguments. Name is
the argument name and Value is the corresponding value.
Name must appear inside quotes. You can specify several name and value
pair arguments in any order as
Name1,Value1,...,NameN,ValueN.Example:m =
modbus('serialrtu','COM3','Timeout',20)
There are a number of name-value pairs that can be used when you create the
modbus object, including the two shown here. Some can
only be used with either TCP/IP or Serial RTU, and some can be used with both
transport types. For a list of all the properties and how to set them both
during and after object creation, see Configure Properties for MODBUS Communication.
'Timeout' — Maximum time in seconds to wait for a response from the MODBUS server
10 (default) | double
Maximum time in seconds to wait for a response from the MODBUS
server, specified as the comma-separated pair consisting of
'Timeout' and a positive value of type
double. The default is 10.
You can change the value either during object creation or after you
create the object.
Example:m =
modbus('serialrtu','COM3','Timeout',20)
Data Types:double
'NumRetries' — Number of retries to perform if there is no reply from the server after a timeout
double
Number of retries to perform if there is no reply from the server
after a timeout, specified as the comma-separated pair consisting of
'NumRetries' and a positive value of type
double. If using the Serial RTU transport,
the message is resent. If using the TCP/IP transport, the connection
is closed and reopened. You can change the value either during
object creation, or after you create the object.
Example:m =
modbus('serialrtu','COM3','NumRetries',5)
Data Types:double