Configure a Connection in the Modbus Explorer

The first step in using the Modbus Explorer to communicate with a PLC or other Modbus device is to configure the communication with the device, either over TCP/IP or Serial RTU.

Communicate Over TCP/IP

  1. Open the Modbus Explorer. On the MATLAB Apps tab, under Test & Measurement, select Modbus Explorer.

  2. Choose your communication interface in the Modbus Explorer by clicking Device then Modbus TCP/IP.

  3. On the Configure tab, configure the connection to your device by setting the following TCP/IP communication parameters in the toolstrip:

    Device Address: IP address of Modbus server, for example 192.168.2.20. This parameter is required to make the connection.
    Port: Remote port used by Modbus server. The default is 502. Change it if using a different port number.
    Timeout: Maximum time in seconds to wait for a response from the Modbus server, specified as a positive value. The default is 3. You can edit the value to increase or decrease the timeout. Note that the default when using the Timeout property programmatically is 10 seconds. If your device requires more than the default of 3 seconds in the app, increase the value.
    Byte Order: Byte order of values written to or read from 16-bit registers. The default is Big Endian, as specified by the Modbus standard. If your device requires Little Endian, change the value in the drop-down.
    Word Order: Word order for register reads and writes that span multiple 16-bit registers. The default is Big Endian, and it is device-specific. If your device requires Little Endian, change the value in the drop-down.
  4. Configure the reading of data from your device by setting the following read parameters in the toolstrip:

    Server ID: Address of the server to send the read command to. If you do not specify a Server ID, the default of 1 is used. Valid values are 1-247.
    Register Type: Target type to read. You can perform a Modbus read operation on four types of targets: coils, inputs, input registers, and holding registers.
    Register Address: Starting address to read from, specified as a double. Enter the number for your starting address.
    Precision: Data format of the register being read from on the Modbus server. For coils and inputs, the precision is always bit. For holding registers and input resisters, you can specify precisions such as uint16.
  5. To test the configuration, click Read. If your configuration parameters are correct, the read is successful and the Read Value populates with the value from the read. If you see 'ERROR' in the Read Value field, adjust the parameters until the read is successful.

    This value needs to match the value listed in your device manual. Make sure this value and the other configuration parameters match the specifications for your device.

  6. Once you have a correct read value, click Confirm Parameters. The rest of the tab appears, and your device is listed in the Device List on the left side of the app.

  7. The register details you enter in the Configure tab are shown in the first row of the register table. You then use the table to set up reads from your device, or press Import to import a table of information that you previously exported.

    For information about setting up reads, see Read Coils, Inputs, and Registers in the Modbus Explorer.

Communicate Over Serial RTU

  1. Open the Modbus Explorer. In the MATLAB Apps tab, under Test & Measurementselect, Modbus Explorer.

  2. Choose your communication interface in the Modbus Explorer by clicking Device then Modbus Serial.

  3. On Configure tab, configure the connection to your device by setting the following Serial RTU communication parameters in the toolstrip:

    Port: Serial port Modbus server is connected to, for example COM1.
    Baud Rate: Bit transmission rate for serial port communication. The default is 9600 bits per seconds, but the actual required value is device-dependent. Change the value in the drop-down if your device requires a different baud rate. Enter your baud rate value if it is not in the list.
    Parity: Type of parity checking. Valid choices are none (default), even, and odd. The actual required value is device-dependent. If set to the default of none, parity checking is not performed, and the parity bit is not transmitted.
    Stop Bits: Number of bits used to indicate the end of data transmission. Valid choices are 1 (default) and 2. The required value is device-dependent, though 1 is typical for even/odd parity and 2 for no parity.
    Data Bits: Number of data bits to transmit. The default is 8, which is the Modbus standard for Serial RTU. Other valid values are 5, 6, and 7.
    Timeout: Maximum time in seconds to wait for a response from the Modbus server, specified as a positive value. The default is 3. You can edit the value to increase or decrease the timeout. Note that the default when using the Timeout property programmatically is 10 seconds. If your device requires more than the default of 3 seconds in the app, increase the value.
    Byte Order: Byte order of values written to or read from 16-bit registers. The default is Big Endian, as specified by the Modbus standard. If your device requires Little Endian, change the value in the drop-down.
    Word Order: Word order for register reads and writes that span multiple 16-bit registers. The default is Big Endian, and it is device-specific. If your device requires Little Endian, change the value in the drop-down.
  4. Configure the reading of data from your device by setting the following read parameters in the toolstrip:

    Server ID: Address of the server to send the read command to. If you do not specify a Server ID, the default of 1 is used. Valid values are 1-247.
    Register Type: Target type to read. You can perform a Modbus read operation on four types of targets: coils, inputs, input registers, and holding registers. Use the drop-down to select your type.
    Register Address: Starting address to read from, specified as a double. Enter the number for your starting address.
    Precision: Data format of the register being read from on the Modbus server. For coils and inputs, the precision is always bit. For holding registers and input resisters, you can specify precisions such as uint16.
  5. To test the configuration, click Read. If your configuration parameters are correct, the read is successful and the Read Value fills in with the value from the read. If you see 'ERROR' in the Read Value field, adjust the parameters until the read is successful.

    This value needs to match the value listed in your device manual. Make sure this value and the other configuration parameters match the specifications for your device.

  6. Once you have a correct read value, click Confirm Parameters. The rest of the tab appears, and your device is listed in the Device List on the left side of the app.

  7. The register details you enter in the Configure tab are shown in the first row of the register table. You then use the table to set up reads from your device, or press Import to import a table of information that you previously exported.

    For information about setting up reads, see Read Coils, Inputs, and Registers in the Modbus Explorer.

Related Topics