OpModbus

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.

OpModbus

Block

Mask

Description

The OpModbus block allows users to define the (TCP and RTU) Modbus slave parameters that instantiate a simulated slave device. This device can be accessed through a Modbus-TCP/RTU master.

One OpModbus block has to be present for each simulated slave device. It allows exchanging data with any industrial devices through Modbus Ethernet or serial messaging. Using a standard network interface card or the standard serial port, this interface can be easily and rapidly added to any simulation model. The complete Modbus communication stack is handled by a dedicated thread running in parallel with the simulation model. The process data is exchanged with the simulation model through a shared memory where inputs/outputs are automatically mapped. The communication stack does not add then any significant or non-deterministic delay to the simulation.

Parameters

Configuration file

Name of the configuration file (opal file, .csv file or .xls file in Excel 97-2003 format)

Sample time

Specifies the sample time of the Simulink block (must be a multiple of the model sample time). Note that this is different from the internal slave cycle. This parameter specifies the execution rate of this block.



Inputs

Bits

This input will accept a vector of status that will be transferred to the simulated Modbus slave database at the rate defined in the mask. The vector order must respect the configuration file order. The status addresses are specified in the configuration file (incoming_bits section).

Input bits

This input will accept a vector of input status that will be transferred to the simulated Modbus slave database at the rate defined in the mask. The vector order must respect the configuration file order. The input status addresses are specified in the configuration file (incoming_input_bits section).

Registers

This input will accept a vector of registers that will be transferred to the simulated Modbus slave database at the rate defined in the mask. The vector order must respect the configuration file order. The register addresses are specified in the configuration file (incoming_registers section).

Input registers

This input will accept a vector of input registers that will be transferred to the simulated Modbus slave database at the rate defined in the mask. The vector order must respect the configuration file order. The input register addresses are specified in the configuration file (incoming_input_registers section).

NB

Removing the sections incoming_bits, incoming_input_bits, incoming_registers, incoming_input_registers from the configuration file will remove the associated inports of the block.



Outputs

Bits

This output is a vector of status that is transferred from the simulated Modbus slave database at the rate defined in the mask. The vector order respects the configuration file order. The status addresses are specified in the configuration file (outgoing_bits section).

Input bits

This output is a vector of input status that is transferred from the simulated Modbus slave database at the rate defined in the mask. The vector order respects the configuration file order. The input status addresses are specified in the configuration file (outgoing_input_bits section).

Registers

This output is a vector of registers that is transferred from the simulated Modbus slave database at the rate defined in the mask. The vector order respects the configuration file order. The register addresses are specified in the configuration file (outgoing_registers section).

Input registers

This output is a vector of input registers that is transferred from the simulated Modbus slave database at the rate defined in the mask. The vector order respects the configuration file order. The input register addresses are specified in the configuration file (outgoing_input_registers section).

NB

Removing the sections outgoing_bits, outgoing_input_bits, outgoing_registers, outgoing_input_registers from the configuration file will remove the associated outports of the block.



Configuration File

The configuration file can be either in the internal "opal" format (extension .opal) or in 'Comma Separated Value' (.csv) format or a .xls file in Excel 97-2003 format. Hereafter is a definition of the different configuration parameters.

Parameter

Description

Parameter

Description

name

Selected by the user, it identifies the device instance.

proto_name

Protocol name (TCP,RTU).

cpu

Specifies on which cpu core this device will run.

verbose

Provides extra information on RT-LAB Display console.

nb_bits

Number of status in the slave internal database.

nb_input_bits

Number of input status in the slave internal database.

nb_registers

Number of registers in the slave internal database.

nb_input_registers

Number of input registers in the slave internal database.

pinout

simulink block interface definition (inports/outports).

incoming_bits

Adds an inport to the block. The size of the input vector depends on the number of items in this section. Each item defines the address of the associated status.

incoming_input_bits

Adds an inport to the block. The size of the input vector depends on the number of items in this section. Each item defines the address of the associated input status.

incoming_registers

Adds an inport to the block. The size of the input vector depends on the number of items in this section. Each item defines the address of the associated register.

incoming_input_registers

Adds an inport to the block. The size of the input vector depends on the number of items in this section. Each item defines the address of the associated input register.

outgoing_bits

Adds an outport to the block. The size of the output vector depends on the number of items in this section. Each item defines the address of the associated status.

outgoing_input_bits

Adds an outport to the block. The size of the output vector depends on the number of items in this section. Each item defines the address of the associated input status.

outgoing_registers

Adds an outport to the block. The size of the output vector depends on the number of items in this section. Each item defines the address of the associated register.

outgoing_input_registers

Adds an outport to the block. The size of the output vector depends on the number of items in this section. Each item defines the address of the associated input register.

tasks

This section defines the slave cycle time.

deadline

Slave device cycle time. This parameter sets the period of the slave for processing incoming requests from the master.

TCP Specific Parameters

Description

ip

Specifies the slave's IP address.

networkInterface

Specifies the network interface to be used. (eth0 by default)

port

This section defines the network port on which the slave listens.

RTU Specific Parameters

Description

baud

Defines the baud rate. (All valid baud rates are available)

parity

Defines the parity configuration. (O=odd,E=even,N=none)

data_bits

Defines the serial data bits configuration. (8, 7)

stop_bits

Defines the stop bits configuration. (1, 1.5, 2).

device_rtu

Defines the communication port to be used. (/dev/xxx...)

slave_id

Defines the slave ID required for RTU communication.

Here is an example of the content of a '.opal' configuration file.

To simplify the usage, the configuration file can be in '.xls' format. The name of the file (including the .csv extension) must be specified in the 'Configuration file' field of the Matlab/Simulink block. Here is an example of what the .csv file must contain. This file can be found in the Modbus slave example model folder. The file template is the same if the user prefers to use a .xls configuration file in Excel 97-2003 format.

The left column items must match with the example file. Any kind of delimiters can be used between the addresses.

File Transfer

The configuration file will be automatically transferred to the target before loading the model.

Characteristics and Limitations

Protocols: Modbus TCP/RTU Slave

Supported Modbus functions:

  • Modbus function code 0x01 (read coil status)

  • Modbus function code 0x02 (read input status)

  • Modbus function code 0x03 (read holding registers)

  • Modbus function code 0x04 (read input registers)

  • Modbus function code 0x05 (force single coil)

  • Modbus function code 0x06 (preset single register)

  • Modbus function code 0x0F (force multiple coils)

  • Modbus function code 0x10 (preset multiple registers)

  • Maximum queries per second: 100

Mapping:

  • Unlimited number of coils (only limited by hardware)

  • Unlimited number of registers (only limited by hardware)

  • Unlimited number of input coils (only limited by hardware)

  • Unlimited number of input registers (only limited by hardware)

Maximum of 100 slaves in a single model

Support RT-LAB extra-high performance simulation mode (XHP)

Support multi-rate modeling

1 Matlab/Simulink block per slave

All configuration parameters are tunable without re-compilation except the Matlab/Simulink inport and outport dimensions. When a modification to the configuration file does not affect the number of input/outputs of the Matlab/Simulink block, the user only has to update the model diagram for the modification to be effective during the next model load.

Additional limitations are shown in the table below:

Direct Feedthrough

No

Discrete sample time

Yes

XHP support

Yes

Work offline

No

OPAL-RT TECHNOLOGIES, Inc. | 1751, rue Richardson, bureau 1060 | Montréal, Québec Canada H3K 1G6 | opal-rt.com | +1 514-935-2323
Follow OPAL-RT: LinkedIn | Facebook | YouTube | X/Twitter