Documentation Home Page RT-LAB Home Page
Pour la documentation en FRANÇAIS, utilisez l'outil de traduction de votre navigateur Chrome, Edge ou Safari. Voir un exemple.

Modbus Master

Description

The Modbus Master driver allows the simulator to communicate with one or many types of equipment configured with a Modbus slave interface. The simulator connects with the slave and sends commands to read/write data points. The Modbus Master interface can operate over TCP/IP using an Ethernet physical link or over RTU using a serial link. It is the user's responsibility to select the communication protocol that matches the slave equipment configuration.

Standard coils and register operations are supported. In RTU mode, it is also possible to connect multiple slaves using the same physical port if a multi-drop RS-485 topology is used.

See additional details in the Configuration and Connections sections.

Supported Features

The following is a list of the features supported by the driver:

  • Standard operations:

    • Read coils (0x01)

    • Read discrete inputs (0x02)

    • Read holding registers (0x03)

    • Read input registers (0x04)

    • Write a single coil (0x05)

    • Write a single register (0x06)

    • Write multiple coils (0x0F)

    • Write multiple registers (0x10)

  • TCP and RTU modes

  • Allows connection with multiple slaves

  • Configurable TCP port when operating over TCP mode

  • Configurable serial port parameters when operating over RTU mode

  • Supports reconnection with slave device(s) if a connection is lost

Configuration

The driver is entirely configurable via the RT-LAB interface. Users can add, delete and duplicate Modbus slave devices and the operations that the simulator (operating as Modbus Master) performs on each of them.

General Configuration

The first parameters to be configured are found below:

  • Use an RT core for asynchronous computation: If set to "true", the driver reserves a real-time CPU core for its communication system and is able to handle a bigger amount of data. If set to "false", the communication system defaults to core 0.

  • Verbose: If enabled, additional information is displayed during the loading of the model.

Slave(s) Configuration

By default, the driver is configured with one master that can connect to the Modbus TCP slave of the example project.

Adding a connection to another Modbus slave is done through the RT-LAB interface.

Each master device has multiple parameters:

  • Mode: Select "TCP" or "RTU" depending on how the Modbus slave device is configured to communicate.

  • TCP specific parameters:

NIC name: The desired network interface name. The proper interface name should be selected based on the information given by the Linux command "ifconfig". If a Modbus master is running on the same machine as the Modbus slave, the loopback network interface must be used ('lo'). If the driver is running on Windows this field will be ignored.

                       IP address: The IP address of the remote Modbus slave device. If a Modbus master is running on the same machine as the Modbus slave, the loopback IP address must be used (127.0.0.1).

TCP port: Select the TCP port on which the Modbus slave device is configured to listen on.

  • RTU specific parameters:

Modbus ID: ID of the Modbus slave device. In RTU mode, many slaves can be connected to the same physical serial link. Each Modbus slave must be configured with a unique identification number.

Serial port: Name of the serial interface to be used. The default serial interface name of the first port on a SuperMicro motherboard is "ttyS0". 

Serial baudrate: Speed at which Modbus RTU slave is configured to communicate.

Serial data bits: Number of data bits the Modbus RTU slave is configured to communicate.

Serial stop bits: Number of stop bits the Modbus RTU slave is configured to communicate.

Serial parity: Parity at which the Modbus RTU slave is configured to communicate.

  • Cycle rate (ms) Defines the rate, in milliseconds, at which the Modbus master performs all the configured read and write operations.

Operations

For each configured Modbus slave instance, read and write operations must be configured. All the configured operations will be executed in a loop.

Each operation requires the following parameters to be configured:

Name

Name that will be used to identify the signal associated with the read/write operation in the configuration panel.

Operation type

Type of operation to perform. See the list of supported operations in the "Supported features" section.

Operation code

Read-only field that gives the hexadecimal code of the configured Modbus operation.

Start address

Address where the read/write operation begins.

Item number

Number of coils/registers to be read/written.

Interpreted as

Coils:

Bit

Registers:

unsigned 16-bit integers (UINT16),

signed 16-bit integers (INT16),  

unsigned 32-bit integers (UINT32),

signed 32-bit integers (INT32) and

float 32-bit (FLOAT32)

Triggered Operation

Trigger read/write for non-cyclic operation.

Connections

Once the driver has been configured as desired and associated with the proper model subsystem, the user will have to connect points in the model to points in the driver by using the designated RT-LAB GUI. This connection panel will show all the driver's and model's connectable points, once the model has been compiled. It is also possible to make connections to LabVIEW panels.

The example model provided with RT-LAB is already packaged with connections between the driver and the model. It can be used as an example to understand how the connections between the model and the driver should be done.

The connection points are classified in the following categories:

  • Coils

  • Discrete Inputs

  • Registers

  • Holding Registers

  • Input Registers

Under each category, the configured operations will show-up with the names that have been given by the user, in the driver configuration GUI. If the icon is blue, it is a read operation. The signal will be read from the slave and returned to the simulation. It means this signal needs to be connected to an OpInput block of the Simulink model.

If the icon is red, it is a write operation. The signal will be written to the slave. It means this signal needs to be connected to an Output block of the Simulink model.

An additional 'Connected' connection point is available and can be used in the model to indicate if the Modbus slave is connected or not.

If an operation is configured to read/write more than one item, a vectorized connection will be available.

If 'Triggered Operation' is enabled for a given operation, a connection will be available to allow the user to control the time and frequency where the read/write operation will be executed. The user will be required to connect an opOutput block and manage the trigger. A transition from 0 to 1 on the triggered port will execute the configured operation. However, it will not be executed if there is no other transition from 0 to 1 on the connected triggered port.

Limitations

The following is a list of the limitations of the driver:

  • Modbus ASCII is not supported.

  • An OP3310 RS-232/422/485 PCIe serial card is needed in case it is required to communicate with multiple slaves on the same physical bus in RTU mode.

OPAL-RT TECHNOLOGIES, Inc. | 1751, rue Richardson, bureau 1060 | Montréal, Québec Canada H3K 1G6 | opal-rt.com | +1 514-935-2323