Modbus - Client Transceiver
Modbus - Client Transceiver — Reads/writes data
from/to the input/output port of the block
Library
Simulink Real-Time - Speedgoat

Description
This block is used to exchange data with the remote Modbus TCP Server. Your model
can contain multiple Modbus TCP Client Transceiver blocks for each Modbus Connection
in your target machine.
Ports
Inputs
-
Tx
Array of length Quantity that
includes the values to be sent to the Modbus
Server for the data range specified by the Index and Quantity parameters. The data type depends on the
selected function code.
For Coils and Discrete Inputs, the input port is a vector of
the BOOLEAN data type where the length of the vector is defined
by the Quantity parameter. Each
BOOLEAN element of the vector represents one bit.
For Holding Registers and Input Registers, the input port is a
vector of the UINT16 data type where the length of the vector is
defined by the Quantity
parameter. Each UINT16 element of the vector represents one
word/register.
Use Byte Pack blocks to convert signed values or floating-point
numbers. You can pack one double value to a vector of type uint16 and
length 4.
-
ENA
Boolean input to allow the user to manage the handling of Modbus
requests to the defined Modbus Server. This input is only active if the
Manage Requests checkbox is enabled.
Send a boolean value of 1 to enable sending or 0 to disable the sending
of Modbus requests. If the sending is stopped, the Transceiver will
still be able to receive data and update its output port.
Outputs
-
Rx
Array of length Quantity that
includes the values received from the Modbus
Server for the data range specified by the Index and Quantity parameters. The data type depends on the
selected function code.
For Coils and Discrete Inputs, the output port is a vector of
the BOOLEAN data type where the length of the vector is defined
by the Quantity parameter. Each
BOOLEAN element of the vector represents one bit.
For Holding Registers and Input Registers, the output port is
a vector of the UINT16 data type where the length of the vector
is defined by the Quantity
parameter. Each UINT16 element of the vector represents one
word/register.
Use Byte Unpack blocks to convert to signed values or floating-point
numbers. You can unpack a vector of type uint16 and length 4 to one
double value.
Parameters
-
Client Station ID
Apply the Client Station ID of the corresponding Setup block. Must
range between 0 and 65535.
-
Connection ID
Apply the Connection ID of the corresponding Connection block. Must
range between 0 and 65535.
-
Remote Server Unit ID
Typical Modbus Servers that do not act as a Modbus RTU gateway have
only one unit. If the Modbus Server is accessed through a bridge or
gateway, then it can contain multiple units. The Unit ID is necessary to
identify the units. Check the official
Implementation Guide for more information
about this topic.
Apply the Unit ID to address the remote Unit in the Modbus TCP Server.
You can assign multiple Transceiver blocks the same Modbus Unit ID. Must
range between 0 and 255.
According to the Modbus standard, unit ID 255 means NON-SIGNIFICANT.
When addressing a Speedgoat Modbus Server and the unit identifier is set
to 255 but unit 255 is not configured in the server itself, the
requested command is performed on the first unit specified in the server
configuration.
-
Function Code
Select the Modbus Function Code you want to use for your
communication. The options are:
FC1 (Read Multiple Coils)
The output will be an array of booleans.
FC2 (Read Multiple Discrete Inputs)
The output will be an array of booleans.
FC3 (Read Multiple Holding Registers)
The output will be an array of uint16.
FC4 (Read Multiple Input Registers)
The output will be an array of uint16.
FC5 (Write Single Coil)
The input will be a single uint16.
FC6 (Write Single Holding Register)
The input will be a single uint16.
FC15 (Write Multiple Coils)
The input will be an array of uint16.
FC16 (Write Multiple Holding Registers)
The input will be an array of uint16.
Refer to the Modbus usage notes
for further information about function codes.
-
Data Index
The first index of the data range you want to send or receive. Must
range between 0 and 65535.
For Coils and Discrete Inputs, the parameter defines the start
bit.
For Holding Registers and Input Registers, the value defines
the start word.
-
Data Quantity
The length of the data range you want to send or receive. Index + Quantity must not exceed 65536.
-
Polling Interval
The polling interval is the time interval between sending Modbus
requests to the server. Must range between 0 and 7,200,000 milliseconds,
which corresponds to a maximum of 2 hours. The default value is 50
ms.
-
Manage Requests
Tick this checkbox if you want to control sending Modbus requests.
This activates the ENA input port of
the Transceiver block. If the sending is stopped, the Transceiver will
still be able to receive data and update its output port.
-
Update on Change
Tick this checkbox if you want to send Modbus requests only when the
data on the TX port has changed. This
behavior is only available if function codes FC5, FC6, FC15 or FC16 are
selected. Additionally, the Manage
Requests functionality is disabled while using Update on Change. The Polling Interval is still used as a "minimal" sending
interval. To send as fast as possible set the Polling Interval to 1 ms.
-
Sample Time
Defines the base sample time at which this driver block gets its sample hit. This
parameter can also be set to -1 for inherited
sample time. The units are in seconds.