Modbus Explorer App Overview - MATLAB
Video Player is loading.
Current Time 0:00
Duration 5:10
Loaded: 3.19%
Stream Type LIVE
Remaining Time 5:10
 
1x
  • Chapters
  • descriptions off, selected
  • en (Main), selected
    Video length is 5:10

    Modbus Explorer App Overview

    The Modbus Explorer App lets you read and write data to any Modbus® device without writing MATLAB® code. With this app you can configure Modbus communication, read and write to Modbus registers, view live plots of register data, and automatically generate a MATLAB live script. The app supports communication over Modbus TCP/IP and Modbus Serial (RTU). Using interactive panels, you can set the baud rate of the communication, define the word and byte order, and set the timeout. You can add coils, input registers, and holding registers. You can save your configuration for future use, eliminating the need to set up the device each time you open MATLAB. The app automatically reads the register data and provides live plots. You can also interactively write data to registers from the app.

    We'll demonstrate how to use the app to set up Modbus communication with a Click Koyo Programmable Logic Controller (PLC). The controller is programmed with two holding registers and 3 coils/switches. The holding registers are set up as counters. We'll show how to use the app to change the switch values, which will turn the counters on and off. The effect of our changes can be easily viewed in the live plots, which display the values stored in the counter registers.

    At the end of the demonstration, we'll show how to automatically generate a MATLAB live script, which can be used as reference for building test programs that require Modbus connectivity.

    Published: 12 Feb 2019

    In this video, we will demonstrate how to use the Modbus Explorer App. The Modbus Explorer App, included with Industrial Communication Toolbox, lets you read and write data to any Modbus device without writing MATLAB code. With this app, you can configure Modbus communication, read and write to Modbus registers, view live plots of registered data, and automatically generate a MATLAB live script.

    To get started, we go to the Apps tab on the MATLAB tool strip. And we click on the Modbus Explorer icon. The next step is to configure the app. Before we do that, we need to decide what we are going to connect to. On my desk, I have a Click Koyo programmable logic controller, which I can communicate with using Modbus. This PLC and the Modbus Explorer App support communication over Modbus TCP/IP and Modbus Serial. For this demo, we are using the serial port, so we will connect using Modbus Serial.

    To establish the connection, we need to add a Modbus device and choose Modbus Serial from the Devices tab. My PLC is on COM3. The Baud rate is 38,400. And the parity is odd. I can change the default settings for Baud rate and parity to match my device using this setup window.

    Before saving the configuration, the app asks you to read data from one of the registers on the device. I know that my PLC has a coil at address 16385. If I click Read, I can see that the value is set to 1. Now, I just click Confirm Parameters to finish the setup of the device. I can add additional coils and holding registers by clicking Insert.

    My PLC has two additional coils at addresses 16386 and 16387. I also have two holding registers at addresses 45058 and 45057. Let's add them all now.

    Now, if we hit Resume Reads, we can see the data is read in from those registers. Now we can export this register table so that we don't have to set up the registers the next time we run MATLAB. If we close MATLAB, all we have to do is import this register table using Import. And we are ready to go. You can see here that I have also renamed the registers for convenience in this version of the register table.

    Now, how can we interactively communicate with the device? Clearly, we can read the values at the defined memory locations, as can be seen here and in the plot at the bottom. We could also use the Write Registers pane to change the values.

    Before we change the value of the Write Register, let me explain a little bit about what the program is that's running on the PLC. The PLC has been previously programmed using the PLC vendor's software. We've downloaded a simple program that associates three coil switches and two holding registers. The holding registers are configured as counters.

    Holding Register 1 will start counting when Coil_1 and Coil_3 are high. The Holding Register 2 at address 45058 set to start counting five seconds after Holding Register 1. Let's test it out.

    I will set Coil_3 to high by writing a 1. And we'll see what happens.

    You can see in the graph here that Counter_1 has started, the purple line. And now, five seconds later, you can see the green line. And Counter_2 has started. You can also see the same information in the table with the read values that are now incrementing with time.

    As a final step, we can generate a MATLAB script that can help get us started if we are building a larger program. If we click Generate Script, a MATLAB live script is automatically generated. Here, we can see how to read and write from registers on the PLC using MATLAB code.

    So to summarize, with the Modbus Explorer App, you can connect to my Modbus devices, such as PLC's, without writing code, configure the Modbus communication, read and write to coils, input registers and holding registers, view live visualizations of registered data, and automatically generate MATLAB code from your interactions in the app.