Modbus RTU communication example for Siemens PLC 1200 and 1500

freeFree Technical Resource

This content is free to read, suitable for basic learning and search traffic.

Modbus RTU communication example for Siemens PLC 1200 and 1500
In highly integrated modern industries, communication between PLCs is often utilized, with common communication protocols such as Modbus, Profibus DP, Profinet, CANOPEN, and more. Today, we will demonstrate how to establish Modbus RTU communication between two PLCs using the Siemens TIA Portal platform.

Before establishing communication, we must meet the following hardware and software requirements:
1. A computer equipped with TIA V16 software;
2. Two Siemens series PLCs, which must support the use of TIA Portal V16 version;
3. A DP9-pin male connector (for use with 1200 port), a DP15-pin male connector (for use with 1500 port), and a two-core shielded cable (specification: 0.5 square);
4. The communication module models and specifications used in today's experiment are as follows:
CM1241RS422/485, order number: 6ES7 241-1CH320XB0;
CMPtP RS422/485HF, order number: 6ES7 541-1AB00-0AB0;

The following images show the communication modules and DP connectors required for today's demonstration;
Modbus RTU communication example for Siemens PLC 1200 and 1500插图


1200 port communication module

Modbus RTU communication example for Siemens PLC 1200 and 1500插图1


1500 port communication module

Modbus RTU communication example for Siemens PLC 1200 and 1500插图2


1200 port DP9-pin male connector

Modbus RTU communication example for Siemens PLC 1200 and 1500插图3


1500 terminal DB15 male connector

1200 and 1500 modbus connection:
1200 PLC terminal 1500 PLC terminal
3+ 11+
8- 4-
Configure the master station (1200 terminal):
1. Create a project and add a CPU and RS485 module as shown below:

Modbus RTU communication example for Siemens PLC 1200 and 1500插图4



Modbus RTU communication example for Siemens PLC 1200 and 1500插图5



Modbus RTU communication example for Siemens PLC 1200 and 1500插图6



Modbus RTU communication example for Siemens PLC 1200 and 1500插图7



2. After adding the hardware, set the parameters of the CM1241-R485 module here:

Modbus RTU communication example for Siemens PLC 1200 and 1500插图8



3. Create a DB block for the 1200 PLC terminal (master station) to store data:

Modbus RTU communication example for Siemens PLC 1200 and 1500插图9



Modify the DB block to "optimize for access".

Modbus RTU communication example for Siemens PLC 1200 and 1500插图10




Modbus RTU communication example for Siemens PLC 1200 and 1500插图11



4. Create the required data:

Modbus RTU communication example for Siemens PLC 1200 and 1500插图12



5. Add an FC function block:

Modbus RTU communication example for Siemens PLC 1200 and 1500插图13



6.) We write the program into the FB segment and set the Modbus_Comm_Load pin parameters:

Modbus RTU communication example for Siemens PLC 1200 and 1500插图14



Modbus RTU communication example for Siemens PLC 1200 and 1500插图15



7.) Since the default working mode of the Modbus_Comm_Load block is RS232, we need to change it to RS485 mode here. There are two ways to modify it. The first is to modify the "MODE" parameter in the Modbus_Comm_Load background DB block from 16#00 to 16#04, as shown below:

Modbus RTU communication example for Siemens PLC 1200 and 1500插图16



The second is to use the "move" instruction to pass a 4 to Modbus_Comm_Load_MODE, as shown below:

Modbus RTU communication example for Siemens PLC 1200 and 1500插图17



Set the Modbus_Mastr function block pin parameters:

Modbus RTU communication example for Siemens PLC 1200 and 1500插图18



Modbus RTU communication example for Siemens PLC 1200 and 1500插图19



Modbus RTU communication example for Siemens PLC 1200 and 1500插图20



8.) Test program:
Write to the slave 1500Q area:

Modbus RTU communication example for Siemens PLC 1200 and 1500插图21



Read from the slave 1500Q area:

Modbus RTU communication example for Siemens PLC 1200 and 1500插图22



After writing the master station program, configure the slave PLC
10.) Create a project and add the CPU and communication module, as shown below:

Modbus RTU communication example for Siemens PLC 1200 and 1500插图23




Modbus RTU communication example for Siemens PLC 1200 and 1500插图24




Modbus RTU communication example for Siemens PLC 1200 and 1500插图25



11.) Set the PtP-RS422/485 communication module parameters as shown below:

Modbus RTU communication example for Siemens PLC 1200 and 1500插图26



12. Add a global data background DB block:

Modbus RTU communication example for Siemens PLC 1200 and 1500插图27




Modbus RTU communication example for Siemens PLC 1200 and 1500插图28




Modbus RTU communication example for Siemens PLC 1200 and 1500插图29



13.) Create storage data:

Modbus RTU communication example for Siemens PLC 1200 and 1500插图30



14.) We began to write the program, adding a "Modbus_comm_Load" communication initialization instruction block to the FB program segment, and setting the corresponding pin parameters:

Modbus RTU communication example for Siemens PLC 1200 and 1500插图31




Modbus RTU communication example for Siemens PLC 1200 and 1500插图32



Since the "Modbus_comm_Load" function block is defaulted to RS232, and we are enabling RS485, some modifications are required. The first method is to directly modify Modbus_comm_Load as shown below:

Modbus RTU communication example for Siemens PLC 1200 and 1500插图33



The second method is consistent with the method mentioned earlier for modifying the 1200 communication data block, as shown below:

Modbus RTU communication example for Siemens PLC 1200 and 1500插图34



15. Add a slave instruction block:

Modbus RTU communication example for Siemens PLC 1200 and 1500插图35



16. Test program:
Master 1200 writes to slave 1500's Q0.0 and Q0.1;

Modbus RTU communication example for Siemens PLC 1200 and 1500插图36



slave 1500 writes to master 1200's Q0.2, Q0.3, and Q0.4;

Modbus RTU communication example for Siemens PLC 1200 and 1500插图37



Monitoring program:

Modbus RTU communication example for Siemens PLC 1200 and 1500插图38



 
 
 
 
 
Today 09:59
0
 
Put this resource to use in a real project?

Go to the Tool Center for message parsing, CRC verification and device debugging, or submit your requirements for selection and integration advice.

Engineer Membership

Turn this article into actionable debugging resources

After activation, you can use advanced message parsing, resource pack downloads, code examples, engineering cases and priority technical support, suitable for real project delivery.

Unlimited Advanced Tools
Resource & Code Packs
Complete Engineering Case Library
Priority Technical Support

Leave a Reply

Your email address will not be published. Required fields are marked *.