Modbus Communication
Industrial Communication Toolbox™ supports the Modbus interface over TCP/IP or serial RTU protocols. Use the interface to communicate with Modbus servers, for tasks such as controlling a PLC, communicating with a temperature controller, controlling a stepper motor, sending data to a DSP, reading bulk memory from a PAC controller, or monitoring temperature and humidity on a Modbus probe.
Create the Modbus interface object using the modbus function,
                        and use the read, write,
                            writeRead, and maskWrite functions
                        for communication.
For an example that shows the entire workflow of reading a register from a PLC, see Read Temperature from a Remote Temperature Sensor.
The toolbox also provides a Modbus Explorer App, which offers a user interface to easily set up reads and writes, and a live plot to see the values. For information, see Use the Modbus Explorer App. For an example that shows the entire workflow of reading and writing to a PLC using the app, see Control a PLC Using the Modbus Explorer.
You can read or write data to a Modbus TCP/IP or Serial server using the Modbus client blocks in Simulink®. For an example, see Control Water pH Remotely Using Modbus Client Blocks in Simulink.
Blocks
| Modbus Client Read | Read data from Modbus server (Since R2024b) | 
| Modbus Client Write | Write data to Modbus server (Since R2024b) | 
Functions
Apps
| Modbus Explorer | Read and write to Modbus coils and registers | 
Topics
Modbus Communication Using Programmatic Workflow
- Modbus Interface Supported Features
 Use Industrial Communication Toolbox Modbus support to communicate with Modbus servers and applications over TCP/IP or Serial RTU.
- Create a Modbus Connection
 Create a Modbus object with themodbusfunction, to connect to a Modbus interface.
- Read Data from a Modbus Server
 Use themodbusobject to read coil, input, and register data from the Modbus server.
- Read Temperature from a Remote Temperature Sensor
 Read temperature and humidity measurements from a remote sensor on a PLC connected via TCP/IP.
- Write Data to a Modbus Server
 Use themodbusobject to write coil and holding register data to the Modbus server.
- Write and Read Multiple Holding Registers
 Perform a combination of one write operation and one read operation on groups of holding registers in a single Modbus transaction.
- Modify Contents of Holding Register Using Mask Write
 Apply AND and OR masks to the current contents of a holding register.
Modbus Communication Using Simulink
- Configure Modbus Client in Simulink
 Configure Modbus clients for model. (Since R2024b)
Modbus Communication Using the Modbus Explorer
- Use the Modbus Explorer App
 You can read and write to coils and registers using the Modbus Explorer app.
- Configure Connection in Modbus Explorer
 Configure communication with the device, either over TCP/IP or Serial RTU.
- Read Coils, Inputs, and Registers in Modbus Explorer
 Read coils, inputs, input registers, and holding registers, similar to the functionality of the Modbusreadfunction.
- Write to Coils and Holding Registers in Modbus Explorer
 Write to coils and holding registers, similar to the functionality of the Modbuswritefunction.
- Control a PLC Using the Modbus Explorer
 Perform reads and writes to a PLC using the Modbus Explorer.
- Generate a Script from Your Modbus Explorer Session
 Generate a MATLAB® script from your session to run at the command line.
Troubleshooting
Troubleshooting the Modbus Interface
Try these tips if you have problems using the toolbox Modbus interface. See information about Modbus supported platforms, configuration and connection, and other interface-specific tips.

