Professional Documents
Culture Documents
PID Control and Communication in Siemens PLC Day3
PID Control and Communication in Siemens PLC Day3
PID Control and Communication in Siemens PLC Day3
COMMUNICATION IN
SIEMENS PLC
S7 COMMUNICATION (DAY3)
8 MARCH 2022
GET- Read Data from Remote CPU
Description
With the instruction "GET", you can read data from a remote CPU.
The instruction is started on a positive edge at control input REQ:
• The relevant pointers to the areas to be read out (ADDR_i) are then sent to the partner CPU. The partner CPU
can be in RUN or STOP mode.
• The partner CPU returns the data:
• If the reply exceeds the maximum user data length, this is displayed with error code "2" at the STATUS
parameter.
• The received data is copied to the configured receive areas (RD_i) at the next call.
• Completion of this action is indicated by the status parameter NDR having the value "1".
GET- Read Data from Remote CPU
Parameters
The following table shows the parameters of the "GET" instruction:
GET- Read Data from Remote CPU
Parameters
The following table shows the parameters of the "GET" instruction:
GET- Read Data from Remote CPU
Parameters
The following table shows the parameters of the "GET" instruction:
GET- Read Data from Remote CPU
Description
You can write data to a remote CPU with the instruction "PUT".
The instruction is started on a positive edge at control input REQ:
• The pointers to the areas to be written (ADDR_i) and the data (SD_i) are then sent to the partner CPU. The
partner CPU can be in RUN or STOP mode.
• The data to be sent is copied from the configured send areas ((SD_i). The partner CPU saves the sent data
under the addresses supplied with the data and returns an execution acknowledgment.
• If no errors occur, this is indicated at the next instruction call with status parameter DONE = "1". The writing
process can only be activated again after the last job is complete.
Errors and warnings are output via ERROR and STATUS if access problems occurred while the data was being
written or if the execution check results in an error.
PUT- Write Data to a Remote CPU
ERROR and STATUS parameters
The following table contains all specific error information for the "PUT" instruction that can be output via the
ERROR and STATUS parameters.
PUT- Write Data to a Remote CPU
Parameters
The following table shows the parameters of the "PUT" instruction:
PUT- Write Data to a Remote CPU
Parameters
The following table shows the parameters of the "PUT" instruction:
PUT- Write Data to a Remote CPU
ERROR and STATUS parameters
The following table contains all specific error information for the "PUT" instruction that can be output via the
ERROR and STATUS parameters.
Give Permit Access of 1st PLC
Configure the parameter of 2nd PLC
Add 2nd PLC
Configure the parameter of 1st PLC
Uncheck Optimized Block Address
Add PUT from Communication
Give Permit Access of 2nd PLC
Add DB to Send Data to PLC_2
Uncheck Optimized Block Address
Add PUT from Communication
Add PUT - GET from Communication
Description of MB_CLIENT
Description
The "MB_CLIENT" instruction communicates as a Modbus TCP client via the PROFINET connection. With the
"MB_CLIENT" instruction, you establish a connection between the client and the server, send Modbus requests
and receive responses and control connection termination of the Modbus TCP client.
For the S7-1200 with firmware version V4.0 you can use the "MB_CLIENT" instruction up to and including
library version V3.1. With the S7-1200 as of firmware version V4.1 and the S7-1500, you can use the
"MB_CLIENT" instruction of all library versions.
The connection can take place via the local interface of the CPU or CM/CP.
To use the instruction, you do not require an additional hardware module.
Description of MB_CLIENT
Parameters
The following table shows the parameters of the "MB_CLIENT" instruction:
Modbus Protocol
Modbus is often used to connect a plant/system supervisory computer with a remote terminal unit (RTU) in
supervisory control and data acquisition (SCADA) systems in the electric power industry. Many of the data
types are named from industrial control of factory devices, such as ladder logic because of its use in driving
relays: A single physical output is called a coil, and a single physical input is called a discrete input or a contact.
Modbus object types
The following is a table of object types provided by a Modbus server device to a Modbus client device:
Description of MB_CLIENT
Description
The "MB_CLIENT" instruction communicates as a Modbus TCP client via the PROFINET connection. With the
"MB_CLIENT" instruction, you establish a connection between the client and the server, send Modbus requests
and receive responses and control connection termination of the Modbus TCP client.
For the S7-1200 with firmware version V4.0 you can use the "MB_CLIENT" instruction up to and including
library version V3.1. With the S7-1200 as of firmware version V4.1 and the S7-1500, you can use the
"MB_CLIENT" instruction of all library versions.
The connection can take place via the local interface of the CPU or CM/CP.
To use the instruction, you do not require an additional hardware module.
Description of MB_CLIENT
Parameters
The following table shows the parameters of the "MB_CLIENT" instruction:
Description of MB_CLIENT
Parameters
The following table shows the parameters of the "MB_CLIENT" instruction:
MB_MODE, MB_DATA_ADDR and MB_DATA_LEN parameters
Examples:
•The combination MB_MODE=1, MB_DATA_ADDR=1, MB_DATA_LEN=1 specifies the function code 05. 1 output
bit is written starting from the remote address 0.
•The combination MB_MODE=1, MB_DATA_ADDR=1, MB_DATA_LEN=2 specifies the function code 15. 2 output
bits are written starting from the remote address 0.
Description of MB_CLIENT
Static tags of the instruction
The following table describes the editable static tags of the instance data block of the "MB_CLIENT"
instruction.
Description of MB_CLIENT
Static tags of the instruction
The following table describes the editable static tags of the instance data block of the "MB_CLIENT"
instruction.
REQ and DISCONNECT parameters
Description
If no job is active and if the value of the DISCONNECT parameter is "0", a new job executes if REQ=1. If there is
not yet a connection, this is established during execution.
If the same instance of the "MB_CLIENT" instruction executes again (DISCONNECT = 0 and REQ = 1), before the
active job was executed, this is not executed on completion of the active job. A new job can only be started on
completion of the active job (REQ = 1).
The status of the execution is output by the output parameters. You can use it to monitor the execution status
when the "MB_CLIENT" instruction is executed sequentially.
MB_MODE, MB_DATA_ADDR and MB_DATA_LEN parameters
Description
The combination of the MB_MODE, MB_DATA_ADDR and MB_DATA_LEN parameters defines the Modbus
function code used in the current Modbus message for the values 0, 1 and 2 of MB_MODE:
• MB_MODE contains the information on whether to read or to write.
• MB_MODE=0: Read, MB_MODE=1 and 2: Write (Note: With MB_MODE=2, there is not distinction between
Modbus functions 15 and 05 or between Modbus functions 16 and 06.)
• MB_DATA_ADDR contains the information on what is to be read or written, as well as address information
from which the "MB_CLIENT" instruction calculates the remote address.
• MB_DATA_LEN contains the number of values to be read/written.
MB_MODE, MB_DATA_ADDR and MB_DATA_LEN parameters
The following table shows the relationship between the input parameters MB_MODE, MB_DATA_ADDR,
MB_DATA_LEN of the "MB_CLIENT" instruction and the associated Modbus function.
MB_MODE, MB_DATA_ADDR and MB_DATA_LEN parameters
The following applies to the values 101 to 106 and 115 to 116 from MB_MODE:
•MB_MODE defines the Modbus function code.
•MB_DATA_ADDR contains the remote address.
•MB_DATA_LEN contains the number of values to be read/written.
Example:
MB_MODE=104, MB_DATA_ADDR=17,834, MB_DATA_LEN=125
• MB_MODE=104 defines the function code 04 (read input words).
• MB_DATA_ADDR=17,834 defines the remote address 17,834.
• MB_DATA_LEN=125 defines that 125 values are read.
MB_MODE, MB_DATA_ADDR and MB_DATA_LEN parameters
The following table shows the relationship between the input parameters MB_MODE, MB_DATA_ADDR,
MB_DATA_LEN of the "MB_CLIENT" instruction and the associated Modbus function.
MB_MODE, MB_DATA_ADDR and MB_DATA_LEN parameters
The following table shows the relationship between the input parameters MB_MODE, MB_DATA_ADDR,
MB_DATA_LEN of the "MB_CLIENT" instruction and the associated Modbus function.
MB_MODE, MB_DATA_ADDR and MB_DATA_LEN parameters
The following table shows the relationship between the input parameters MB_MODE, MB_DATA_ADDR,
MB_DATA_LEN of the "MB_CLIENT" instruction and the associated Modbus function.
MB_MODE, MB_DATA_ADDR and MB_DATA_LEN parameters
The following table shows the relationship between the input parameters MB_MODE, MB_DATA_ADDR,
MB_DATA_LEN of the "MB_CLIENT" instruction and the associated Modbus function.
MB_DATA_PTR parameter
Description
The MB_DATA_PTR parameter is a pointer to a data buffer for the data to be received from the Modbus server
or to be sent to the Modbus server. As the data buffer, you can use a global data block or a memory area (M).
For a buffer in the memory area (M), use a pointer in the ANY format as follows: "P#bit address" "data type"
"length" (example: P#M1000.0 WORD 500).
MB_DATA_PTR parameter
Depending on the memory area in which the data buffer is located, MB_DATA_PTR can reference different data
structures:
• When you use a global DB with optimized access, MB_DATA_PTR can reference a tag with elementary data
type or an array of elementary data types. The following data types are supported:
CONNECT parameter
Connection description for programmed connections
Use the following structure for connection description to TCON_IP_v4 for programmed connections at the
CONNECT parameter:
•Make sure that only connections of the type TCP are specified in the TCON_IP_v4 structure.
•The connection may not use the following TCP port numbers: 20, 21, 25, 80, 102, 123, 5001, 34962, 34963
and 34964.
CONNECT parameter
Connection description for programmed connections
Parameter STATUS
Parameter STATUS (general status information)
Parameter STATUS
Parameter STATUS (protocol error)
Parameter STATUS
Parameter STATUS (protocol error)
Differences between PLCSIM & PLCSIM Advanced
Runtime Independence
The PLCSIM (V12 or V5.X) cannot run without running of Step-7 software program unlike the PLCSIM
Advanced it’s independent.
Communication
For PLCSIM (V15 or V5.X) they are communicating just into your PC with a bus called SOFTBUS.
But on the other hand, we will find that PLCSIM Advanced has the ability to communicate with outside
devices using TCP/IP protocol and Virtual SIEMENS LAN adaptor and can also make a connection into your
PC using SOFTBUS.
Supported CPUs
The PLCSIM Advanced supports S7-1500 and ET-200SP CPUs for the emulating, PLCSIM V12 and Higher
support S7-1200, S7-1500, and ET-200SP CPUs and for PLCSIM V5.X can handle S7-300 and S7-400.
Differences between PLCSIM & PLCSIM Advanced
Virtual SIMATIC Memory Card Open an Explorer window here in which you select the path to the virtual
memory card.
Display messages Here you disable the PLCSIM Advanced messages in the Windows task bar for the duration of
the operation.
Function manual This is where you open the S7-PLCSIM Advanced Function Manual in a standard PDF viewer.
Exit logs off all instances and closes the Control Panel
Set the Server PLC
Advantages of PLCSIM Advanced