Blog

Configuring PLCSIM Advanced for Modbus Testing

Configuring PLCSIM Advanced for Modbus Testing

After writing about the benefits of hardware simulation, and PLCSIM Advanced in particular, I spent some time thinking of other great ways I've used this tool to improve the development process. Another area that PLCSIM Advanced really shines is testing Modbus communications.

Perhaps you're in the development phase and want to simulate, or maybe you're commissioning and want to confirm everything will go as planned before downloading to critical systems. In both cases, PLCSIM Advanced is the tool you'll want to know how to use. This blog piggybacks heavily on Nikhil Holay's blog 5 Tips For Getting Started In PLCSIM Advanced, but you might also check out my previous blog Configuring PLCSIM Advanced for PLC and Ignition Development over OPC UA if you've still got questions.

What About Modbus?

In addition to PLCSIM Advanced, you’ll want to grab another tool, Modbus Poll, and install it on the same VM (or host machine) as PLCSIM Advanced. For this example, I’ll simply read the first 10 holding registers I configured on my PLC.

First, I created the MB_SERVER object in my project. A TCON_IP_v4 object is required to configure the Modbus server, and you’ll want to also include a non-optimized DB with your holding registers as well. For a great in-depth discussion of what’s going on with this block, check out Jason Mayes’s blog Using an S7-1200 PLC as a Modbus TCP Slave.

Screenshot: MB_SERVER object in Siemens TIA Portal.

In this example, we’ll be communicating over TCP/IP, so set the ConnectionType to 11 and LocalPort to 502 (although these should be set by default).

Screenshot: TCON_IP_v4 connection parameters object in Siemens TIA Portal.

When you first open a connection in Modbus Poll, you’ll be prompted to configure the connection settings. Just enter the IP address of your PLCSIM Advance controller, the same port you configured in Portal, and verify you’re using Modbus TCP/IP.

Screenshot: Connection Setup dialog in Modbus Poll.

After you press OK, it will return to the main screen where you’ll see a table with 10 entries corresponding to the first 10 holding registers on your Modbus server. If all of your communication settings are correct, the data in Modbus Poll should match what’s online with your simulated PLC.

Screenshot left: Modbus holding registers in Modbus Poll. Screenshot right: Modbus holding registers in Siemens TIA Portal.

If you’d like to extend the number of registers or test something other than Read Holding Registers, navigate to Setup -> Read/Write Definition screen to modify these settings.

Screenshot: Read/Write Definitions setup menu in Modbus Poll.

Conclusion

PLC emulation is a great development tool, and PLCSIM Advanced makes it easy to test Modbus communications without physical hardware and without interruptions of service to critical systems.

You can learn more about our Siemens expertise, or contact DMC to discuss your next project.

Comments

There are currently no comments, be the first to post one.

Post a comment

Name (required)

Email (required)

CAPTCHA image
Enter the code shown above:

Related Blog Posts