Documentation search search close
CONTENTS
https://www.speedgoat.com/help/slrt/page/icon_documentation.jpg
v10.0.1.x for R2026a
View other versions

Modbus TCP - Server Setup

Modbus TCP - Server Setup — Configures one Modbus TCP server node

Library

Simulink Real-Time - Speedgoat

Description

The Setup block configures one Modbus TCP server node, opens the TCP port for incoming connection requests and enables the read and write blocks to exchange data with the local Modbus data tables. Every Modbus TCP Server block in the model requires a runtime license.

Ports

Inputs

This block does not have any input ports.

Outputs
Connection Status

Number of clients connected.

Data Type: uint16

Parameters

Tab: General
Station ID

The Station ID is used to assign Setup, Read and Write blocks to a particular server node. Station IDs range between 0 to 65535 and must be unique in a model.

Local IP Address

Enter the IP address of the Modbus server. This step does not assign the IP address to an Ethernet interface. Instead, it binds the Setup block to an IP address which was previously configured in the Ethernet Configuration Tool. Refer to the Modbus usage notes for further information.

Local TCP Port

The TCP port the server listens on for connection requests from the client. The default port is 502. For a custom port address, select between the range 0 and 65535. The reserved ports should not be used. Refer to the following online documentation:

List of TCP and UDP Port Numbers

Units

Defines the IDs of the units the server node should manage in the range of 0 to 255. Each unit has its own data tables for coils, discrete inputs, holding registers and input registers. Modbus clients can address a certain unit with the unit identifier in the Modbus request frame. Typical Modbus servers that do not act as a Modbus RTU gateway have only one unit.

According to the Modbus standard, unit ID 255 means NON-SIGNIFICANT. If the unit identifier received is 255 but unit 255 is not configured in the server, the requested command is performed on the first unit specified in the Units parameter.

Default: [0] creates one unit with ID 0. Modbus requests with unit identifier 0 or 255 are passed to unit 0.

Example: [0,255] creates two units with ID 0 and 255. Modbus requests with unit identifier 0 are passed to unit 0. Modbus requests with unit identifier 255 are passed to unit 255.

Example: [0,1,2,254] creates four units with ID 0, 1, 2 and 254. Modbus requests with unit identifier 0 are passed to unit 0. Modbus requests with unit identifier 1 are passed to unit 1. Modbus requests with unit identifier 255 are passed to unit 0.

Data Table Dimensions

Defines the number of coils, discrete inputs, holding registers and input registers of each Modbus unit. The value must be an n-by-4 matrix where n is the number of Modbus units. One row represents one unit, the four columns represent the four Modbus data tables. The number of items per data table must range between 1 and 65535.

Example: [1,2,3,4;5,6,7,8] The first unit has 1 coil, 2 discrete inputs, 3 holding registers and 4 input registers. The second unit has 5 coils, 6 discrete inputs, 7 holding registers and 8 input registers.

Response Delay

Defines the number of milliseconds the server should delay a Modbus response after having received a request. The number must range between 0 (no delay) and 60000.

Swap Register Bytes

The bytes of a register must be swapped if the sender and the receiver interpret the byte order in different ways (endianness). The Speedgoat real-time target machine uses little-endian, while some clients use big-endian. If the swap option is enabled, all register values from the application context will be swapped before they are sent to the network. All register values received from the network will be swapped before they are submitted to the application context. The swap option only affects input registers and holding registers (transmitted by function codes FC3, FC4, FC5, FC6, FC16). Discrete inputs and coils are not affected. Use Byte Reversal blocks instead of enabling the global byte swapping if only single registers need to be swapped.

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.