This article describes creating a communication function block (FB) for reading and writing devices via SLMP communication from S7-1500 to FX5. Based on TCP communication using TCON/TSEND/TRCV, it parameterises the device type, start address, and number of points, enabling Read and Write operations to be handled with nearly identical structures.
This implementation example has been compiled with a focus on a structure that is easy to debug and reuse, rather than merely ‘making it work for now’.
Right then, let’s enjoy the FA!

Reference Link
Function Block
This section describes TCON, TSEND, TRCV, and TDISCON used in this article.

TCON_IP_v4: Connection Parameter Structure
The TCON_IP_v4 structure is used to assign parameters for TCP and UDP communication connections on S7-1200 V4.0 or later and S7-1500 CPUs.

Parameters
Byte | Parameter Name | Data Type | Description |
|---|---|---|---|
0..1 | InterfaceID | HW_ANY | Identifier of local communication interface (Ethernet, etc.). Range: 0 to 65535 |
2..3 | ID | CONN_OUC | Identification number for the communication connection. Specify the same ID for TSEND_C / TRCV_C / TCON. Range: 1 to 4095 |
4 | ConnectionType | BYTE | Communication protocol specification. 11: TCP (0x0B), 17: TCP (0x11), 19: UDP (0x13) |
5 | ActiveEstablished | BOOL | Connection establishment type. FALSE: Passive connection (listening), TRUE: Active connection (initiates connection) |
6..9 | RemoteAddress | ARRAY[1..4] OF BYTE | IP address of the remote partner. Example: 192.168.0.1 → {192,168,0,1} |
10..11 | RemotePort | UINT | Port number of the remote partner. |
12..13 | LocalPort | UINT | Port number used on the local side. |
TCON: Establish communication connection
Use the “TCON” instruction to set up and establish a communication connection. Once configured and established, the connection is automatically maintained and monitored by the CPU. “TCON” executes asynchronously.
On S7-1500 CPUs with firmware version V2.0 or later, an access point for IPv4 multicast communication can be configured via the integrated PROFINET interface using the “TCON” instruction.
The connection data specified in the CONNECT and ID parameters are used to establish the communication connection. In the CONNECT parameter, use only predefined structures created in the connection parameter assignment in the program editor’s Inspector window whenever possible.
To establish a connection, a rising edge must be detected at the REQ parameter. Once the connection is successfully established, the DONE parameter is set to “1”.

Support for Connection Programming
When selecting TCON, TSEND_C, or TRCV_C instructions within a program block to create and assign parameters for TCP, UDP, ISO-on-TCP, or FDL connection types, you can utilize the connection parameter assignment support.
Connections with TCP and ISO-on-TCP
Both communication partners call the “TCON” instruction to set up and establish the communication connection. During parameter assignment, specify which partner is the active communication endpoint and which is the passive communication endpoint.
If the connection is interrupted (e.g. due to cable disconnection or an issue on the remote communication partner side), the active partner attempts to re-establish the configured connection. Calling “TCON” again is not necessary in this case, provided “TCON” executed successfully at least once (DONE = 1).
When the “TDISCON” instruction is executed or the CPU transitions to STOP mode, the existing connection is terminated and the connection setup is cleared. To reconfigure and establish the connection, execute “TCON” again.
Parameters
Parameter | Type | Data Type | Memory Area | Description |
|---|---|---|---|---|
REQ | Input | BOOL | I, Q, M, D, L or constant | Starts the job to establish the specified connection on a rising edge. |
ID | Input | CONN_OUC | I, Q, M, D, L or constant | Reference ID for the assigned communication connection. Valid range: W#16#0001 to W#16#0FFF *IDs assigned by TCONSettings may fall outside this range. |
CONNECT | InOut | VARIANT | D | Pointer to the connection descriptor. For TCP/UDP communication, use TCON_IP_v4 or TCON_QDN structures. |
DONE | Output | BOOL | I, Q, M, D, L | Connection establishment result. 0: Not started or in progress, 1: Completed successfully without errors |
BUSY | Output | BOOL | I, Q, M, D, L | Processing status. 0: Not started or completed, 1: In progress (new job cannot be started) |
ERROR | Output | BOOL | I, Q, M, D, L | Error status. 0: No error, 1: Error occurred |
STATUS | Output | WORD | I, Q, M, D, L | Detailed status code of the instruction. |
BUSY, DONE, and ERROR Parameters
The FB status can be checked using the BUSY, DONE, ERROR, and STATUS parameters.
- The BUSY parameter indicates the processing status.
- The DONE parameter is used to confirm whether the job executed successfully.
- The ERROR parameter is set if an error occurs during execution of “TCON”.
Error information is output to the STATUS parameter.
If active connection establishment to a remote partner fails, the “TCON” instruction generates an error message in version 3.0. Generate a rising edge at the REQ parameter to re-establish the connection.
Relationship Between BUSY, DONE, and ERROR Parameters
The following table shows the relationship between the BUSY, DONE, and ERROR parameters:
BUSY | DONE | ERROR | Status Description |
|---|---|---|---|
1 | 0 | 0 | Job in progress. The instruction is currently executing. |
0 | 1 | 0 | Job completed successfully. |
0 | 0 | 1 | Job terminated with an error. The cause of the error is output to the STATUS parameter. |
0 | 0 | 0 | No new job assigned. |
TSEND: Send data via communication connection
Use the “TSEND” instruction to send data via an existing communication connection. TSEND executes asynchronously.
The send area is specified by the DATA parameter, which includes the address and length of data to be sent. All data types except BOOL and BOOL arrays can be used for send data.
When a rising edge is detected at the REQ parameter, the send job is executed.
Using the LEN parameter specifies the maximum number of bytes sent in a send job.
When data is transferred via TCP (stream protocol), the “TSEND” instruction does not provide information regarding the length of sent data to “TRCV”.
Send data must not be edited until the send job completes. When the send job completes successfully, the DONE parameter is set to “1”. A signal state of “1” for the DONE parameter is not confirmation that the send data was already read by the communication partner.

Valid Interfaces
Ethernet: CPU S7-1200 and CPU S7-1500 with firmware version V4.0 or higher
PROFIBUS: FDL connection for S7-1500 with CM 1542-5 version V2.0 or higher using system data type TCON_FDL
Parameters
Parameter | Type | Data Type | Memory Area | Description |
|---|---|---|---|---|
REQ | Input | BOOL | I, Q, M, D, L or constant | Starts the send job on a rising edge. |
ID | Input | CONN_OUC | I, Q, M, D, L or constant | Reference ID of the communication connection established by TCON. Valid range: W#16#0001 to W#16#0FFF |
LEN | Input | UDINT | I, Q, M, D, L or constant | Maximum number of bytes to send. S7-1200: up to 8192 bytes, S7-1500: up to 65536 bytes *For FDL connection (CM1542-5), up to 240 bytes |
DATA | InOut | VARIANT | I, Q, M, D, L | Pointer to send data area. Process image, bit memory, DB, local data, etc. can be specified. *When sending structures, the send and receive sides must have identical structure. |
DONE | Output | BOOL | I, Q, M, D, L | Send result. 0: Not started or in progress, 1: Completed successfully without errors |
BUSY | Output | BOOL | I, Q, M, D, L | Processing status. 0: Not started or completed, 1: In progress (new send job cannot be started) |
ERROR | Output | BOOL | I, Q, M, D, L | Error status. 0: No error, 1: Error occurred |
STATUS | Output | WORD | I, Q, M, D, L | Detailed status code of the instruction. |
LEN and DATA Parameters
When LEN = 0, all data specified in the DATA parameter is sent.
If the byte count of the LEN parameter is greater than the length of send data defined by the DATA parameter, error code 8088 is output to the STATUS parameter (STATUS parameter description below).
When a structure (Struct) is referenced via the DATA parameter, LEN can be set shorter than the structure. In this case, only data up to the length specified by the LEN parameter is transferred.
For STRING and WSTRING data types, when parameter LEN = 0, all data is transferred. When LEN > 0, the length must be greater than or equal to the maximum byte count plus an additional 2 bytes containing length information.
The maximum transmittable byte count varies depending on the device.
When using structured tags from an optimized DB, the structured tag address must be connected to the DATA parameter, and LEN = 0 must be specified.
BUSY, DONE, and ERROR Parameters
The job status can be checked using the BUSY, DONE, ERROR, and STATUS parameters.
- The BUSY parameter indicates whether execution is in progress.
- The DONE parameter allows verifying whether the job executed successfully.
- The ERROR parameter is set if an error occurs during execution of “TSEND”.
Error information is output to the STATUS parameter.
The following table shows the relationship between the BUSY, DONE, and ERROR parameters:
BUSY | DONE | ERROR | Status Description |
|---|---|---|---|
1 | 0 | 0 | Job in progress. |
0 | 1 | 0 | Job completed successfully. |
0 | 0 | 1 | Job terminated with an error. The cause of the error is output to the STATUS parameter. |
0 | 0 | 0 | No new job assigned (idle state). |
TRCV: Receive Data via Communication Connection
Use the “TRCV” instruction to receive data via an existing communication connection. “TRCV” executes asynchronously.
When the EN_R parameter is set to value “1”, data reception is enabled. Received data is written to the receive area. The length of the receive area is specified by the LEN parameter (when LEN ≠ 0) or the length information of the DATA parameter (when LEN = 0), depending on the protocol variant used.
During data reception, the DATA parameter or defined receive area must not be modified to ensure integrity of the received data.
After data is received successfully, the NDR parameter is set to value “1”. The actual amount of data received can be checked with the RCVD_LEN parameter.

Valid Interfaces
Ethernet: CPU S7-1200 and CPU S7-1500 with firmware version V4.0 or higher
PROFIBUS: FDL connection for S7-1500 with CM 1542-5 version V2.0 or higher using system data type TCON_FDL
TRCV Receive Modes
The following table shows the receive modes configurable for TRCV. Note that Ad-hoc mode is used in this article.
Protocol Type | ADHOC Parameter | Data Valid Condition in Receive Area | connection_type Value | LEN Parameter Handling |
|---|---|---|---|---|
TCP (Ad-hoc mode) | 1 (Enabled) | When NDR goes high, available immediately if at least 1 byte has arrived | 16#11 (Decimal: 17) | Reads only the received data length. Does not exceed maximum length specified in LEN. LEN = 0 (Recommended): Uses entire receive area specified by DATA |
TCP (Fixed-length receive) | 0 (Disabled) | Available after entire data length specified in LEN is received | 16#11 (Decimal: 17) | S7-1200: 1 to 8192, S7-1500: 1 to 65536 |
ISO on TCP | — | Available after entire data length specified in LEN is received | 16#12 (Decimal: 18) | S7-1200: 1 to 8192, S7-1500: 1 to 65536 |
FDL | — | Available after entire data length specified in LEN is received | 16#15 (Decimal: 21) | 1 to 240 |
TCP (Ad-hoc mode)
TCP (Ad-hoc mode) is available only with TCP protocol. Ad-hoc mode is used to receive dynamically sized data using the “TRCV” instruction.
Configure Ad-hoc mode by assigning value “1” to the ADHOC parameter.
As soon as a data block is received, the “TRCV” instruction transfers it to the receive area and sets NDR. RCVD_LEN stores the data byte count contained in this data block. The minimum value of RCVD_LEN is 1.
When using TCP (Ad-hoc mode), all data types can be used for standard access data blocks.
However, for data blocks with optimized access, permitted data types vary depending on the CPU model:
- On S7-1200 CPUs, only BYTE arrays or 8-bit length data types (CHAR, USINT, SINT, etc.) can be used for data blocks with optimized access.
- On S7-1500 CPUs, all data types can be used.
Parameters
Parameter | Type | Data Type | Memory Area | Description |
|---|---|---|---|---|
EN_R | Input | BOOL | I, Q, M, D, L or constant | Receive enable. Enables data reception while TRUE. |
ID | Input | CONN_OUC | I, Q, M, D, L or constant | Reference ID of the communication connection established by TCON. Valid range: W#16#0001 to W#16#0FFF |
LEN | Input | UDINT | I, Q, M, D, L or constant | Length of receive area (bytes). S7-1200: up to 8192, S7-1500: up to 65536, CM1542-5 (FDL): up to 240 *When using optimized access for DATA, LEN = 0 must be specified. |
ADHOC | Input | BOOL | I, Q, M, D, L or constant | Specifies Ad-hoc mode usage in TCP communication. Set to FALSE for protocols other than TCP. |
DATA | InOut | VARIANT | I, Q, M, D, L | Pointer to receive data storage area. When receiving structures, send and receive sides must have identical structure. |
NDR | Output | BOOL | I, Q, M, D, L | New data receive notification. 0: Not received / in progress, 1: New data received |
BUSY | Output | BOOL | I, Q, M, D, L | Processing status. 0: Not started or completed, 1: Receive processing in progress (new receive job cannot be started) |
ERROR | Output | BOOL | I, Q, M, D, L | Error status. 0: No error, 1: Error occurred |
STATUS | Output | WORD | I, Q, M, D, L | Detailed status code of the instruction. |
RCVD_LEN | Output | UDINT | I, Q, M, D, L | Amount of data actually received (byte count). |
LEN, DATA, and RCVD_LEN Parameters
When LEN = 0, received data is stored in the receive area specified by the DATA parameter. The received byte count is indicated by the RCVD_LEN parameter. The length of data to receive is defined by the DATA parameter. It is recommended to set the receive area (DATA parameter) to the same size as data sent by TSEND.
When the value of LEN is 0 and sent data is transferred in segments smaller than the DATA receive area, the following apply:
- It is recommended to keep EN_R set until the associated TSEND instruction finishes sending all data.
- STATUS displays value 7002 unless the size of data sent by TSEND equals the size of the DATA receive area.
- EN_R must remain set until the received data quantity equals the size of the DATA receive area.
- When pulsing EN_R input, it must be continued until BUSY=0 or ERROR <> 0.
Data in the DATA receive area is valid only when BUSY has a value of 0.
If the length specified by the LEN parameter is greater than the length of data received in the DATA parameter, error code 8088 is output to the STATUS parameter.
LENパラメータで指定された長さがDATAパラメータで受信したデータの長さより大きい場合、STATUSパラメータでエラーコード8088が出力される。
When a structure (Struct) is referenced via the DATA parameter, LEN can be set shorter than the structure. In this case, only data up to the length specified by the LEN parameter is transferred.
When the DATA parameter references a data block with optimized access, the LEN parameter must be set to “0”. If the data lengths of elementary data types do not match, data is not received and error code 8088 is output to the STATUS parameter.
When the STRING data type is referenced via the DATA parameter, the length specified by the LEN parameter must be 0 or 2 or greater (LEN = 1 is not permitted).
STRINGデータ型がDATAパラメータ経由で参照される場合、LENパラメータで指定される長さは0または2以上でなければならない(LEN = 1は許可されない)。
When the WSTRING data type is referenced via the DATA parameter, the length specified by the LEN parameter must be 0 or 5 or greater.
WSTRINGデータ型がDATAパラメータ経由で参照される場合、LENパラメータで指定される長さは0または5以上でなければならない。
BUSY, NDR, and ERROR Parameters
The job status can be checked using the BUSY, NDR, ERROR, and STATUS parameters. The BUSY parameter indicates processing status. The NDR parameter confirms whether the job executed successfully. The ERROR parameter is set if an error occurs during execution of TRCV. Error information is output to the STATUS parameter.
The following table shows the relationship between the BUSY, NDR, and ERROR parameters:
BUSY | NDR | ERROR | Status Description |
|---|---|---|---|
1 | ― | ― | Receive job in progress. |
0 | 1 | 0 | Receive job completed successfully and new data was received. |
0 | 0 | 1 | Receive job terminated with an error. The cause of the error is output to the STATUS parameter. |
0 | 0 | 0 | No new receive job assigned (idle state). |
TDISCON: Terminate Communication Connection
The TDISCON instruction terminates a communication connection from the CPU to a partner. TDISCON is an asynchronously operating instruction whose job execution spans multiple calls. To start a connection termination job, call the TDISCON instruction with REQ = 1.
After TDISCON executes successfully, the ID specified in TCON is no longer valid and cannot be used for transmission or reception.
TDISCONが正常に実行された後、TCONに指定されたIDは有効ではなくなり、送受信に使用できなくなります。
The job status is indicated by the output parameters BUSY and STATUS, where STATUS corresponds to the RET_VAL output parameter of asynchronous instructions.

Parameters
Parameter | Type | Data Type | Memory Area (S7-1200) | Memory Area (S7-1500) | Description |
|---|---|---|---|---|---|
REQ | Input | BOOL | I, Q, M, D, L or constant | I, Q, M, D, L or constant | Starts the disconnect job for the specified communication connection on a rising edge. |
ID | Input | CONN_OUC (WORD) | D, L or constant | I, Q, M, D, L or constant | ID of the communication connection to disconnect. Valid range: W#16#0001 to W#16#0FFF *IDs assigned in TCONSettings may fall outside this range. |
DONE | Output | BOOL | I, Q, M, D, L | I, Q, M, D, L | Disconnect process result. 0: Not started or in progress, 1: Completed successfully without errors |
BUSY | Output | BOOL | I, Q, M, D, L | I, Q, M, D, L | Processing status. 1: Disconnect processing in progress, 0: Not started or completed |
ERROR | Output | BOOL | I, Q, M, D, L | I, Q, M, D, L | Error status. 0: No error, 1: Error occurred during processing |
STATUS | Output | WORD | I, Q, M, D, L | I, Q, M, D, L | Detailed status of error or processing result. |
BUSY, DONE, and ERROR Parameters
The following table shows the relationship between BUSY, DONE, and ERROR. Use this table to recognize the current status of TDISCON and when connection establishment is complete.
BUSY | DONE | ERROR | Status Description |
|---|---|---|---|
1 | 0 | 0 | Job in progress. |
0 | 1 | 0 | Job completed successfully. |
0 | 0 | 1 | Job terminated with an error. The cause of the error can be confirmed with the STATUS parameter. |
0 | 0 | 0 | No (new) job assigned to the instruction. |
Implementation
Mitsubishi FX5 Side
First, configure the communication settings on the Mitsubishi FX5 side.

SLMP Connection Settings
In this article, ports 7501 and 7502 are used.

Siemens Side
Next, create the communication program on the Siemens side.

IP Settings
Set the IP address of the S7-1500 on the same network as the FX5.

Programming
Next is the programming section.
Structures
udtSLMPDeviceCode
udtSLMPDeviceCode is a data type used to specify the device type (D / M / X / Y / W) to access in SLMP communication using BOOL flags.
In other words, it is positioned as a structure that makes it easy to specify “which device area do I want to use right now” from the program.
It serves as a switch box for specifying SLMP device areas in a human-understandable format.

FC
fc32BitDataTo4Bytes
This is an FC that extracts a 32-bit numeric value byte-by-byte starting from the lower bits.

#b0 := #in.%B0;
|
|---|
fcSLMPGetDeviceCode
This is an FC for converting a device type (D/M/X/Y/W) specified by BOOL into an SLMP specification “Device Code (BYTE)”.

#fcSLMPGetDeviceCode := 16#0;
|
|---|
FB
Next, create the SLMP read/write programs.
fbSLMPRead
This is a communication FB that “cyclically reads” specified device points (D/M/X/Y/W) using 3E frames.
- TCP Connection
- Frame Generation
- Explicit TSEND / TRCV Control
- Error, Timeout, and Stop Operations

Input Interface
Variable | Meaning |
|---|---|
xStart | Communication start trigger |
xStop | Communication stop request |
xReset / xAutoReset | Error recovery control |
CONN_OUC | TCON connection ID |
uiFirstDeviceOffset | Read start device number |
uiTotalDevices | Number of read points |
udtSLMPDeviceCode | D/M/X/Y/W specification (BOOL) |
Output Interface
Variable | Meaning |
|---|---|
xBusy | Communicating flag |
xError | Error occurred |
uiDoneCount | Successful completion count |
uiErrorCount | Error count |
iErrorID | Error cause code |
iCurrentStep | Current internal step |
In/Out Interface
Variable Name | Data Type | Direction | Content / Role |
|---|---|---|---|
udtTCON_IP_v4 | TCON_IP_v4 | InOut | TCP communication connection definition structure. Holds IP address, port numbers, Active/Passive settings, etc., and is passed as-is to the TCON FB. Not edited inside the FB; uses communication conditions injected from the caller. |
arrb | ARRAY[0..ebufferLength-1] OF BYTE | InOut | Actual data storage buffer retrieved from SLMP Read response. Only the data portion excluding response frame header (11 bytes) is copied. Can be used directly for parsing, conversion, and display at the caller. |
Program
Here is the structure of each STEP.
Step | Content |
|---|---|
0 | Initialization / Standby |
5 | Parameter validity check |
10–15 | TCON connection |
20 | SLMP Read frame generation |
30–33 | TSEND execution + send monitoring |
35–40 | TRCV execution + receive wait |
50 | Response check |
60 | Received data storage |
70 | To next cycle |
100–105 | Disconnect process |
9000番台 | Error handling |
#fbR_TRIG[0](CLK := #xStart);
|
|---|
fbSLMPWrite
This is a communication FB that “cyclically writes” specified device points (D/M/X/Y/W) using 3E frames.
- TCP Connection
- Frame Generation
- Explicit TSEND / TRCV Control
- Error, Timeout, and Stop Operations

Input Interface
Variable Name | Type | Content |
|---|---|---|
xStart | BOOL | Write start trigger (rising edge) |
xStop | BOOL | Write stop request |
xReset | BOOL | Manual reset after error |
xAutoReset | BOOL | Automatic reset after error |
CONN_OUC | CONN_OUC | TCON connection ID |
uiFirstDeviceOffset | UINT | Write start device number |
uiTotalDevices | UINT | Number of write points |
udtSLMPDeviceCode | UDT | Specify one of D/M/X/Y/W |
Output Interface
Variable Name | Type | Content |
|---|---|---|
xBusy | BOOL | Write processing in progress |
xError | BOOL | Error occurred |
uiDoneCount | UINT | Successful completion count |
uiErrorCount | UINT | Error count |
iErrorID | INT | Error identification code |
iCurrentStep | INT | Current internal step |
In/Out Interface
Variable Name | Type | Role |
|---|---|---|
udtTCON_IP_v4 | TCON_IP_v4 | TCP connection definition (IP, Port, Active, etc.) |
arrb | ARRAY[ ] OF BYTE | Write data body (prepared by user) |
Program
Here is the structure of each STEP.
Step | Processing Content |
|---|---|
0 | Initialization / Standby |
5 | Device specification / point count check |
10–15 | TCON connection |
20 | SLMP WRITE frame generation |
30–33 | TSEND execution / send monitoring |
35–40 | TRCV response wait |
50 | Response frame verification |
60 | Update successful completion count |
70 | Continue cyclic write |
100–105 | Disconnect process |
9000番台 | Error handling |
#fbR_TRIG[0](CLK := #xStart);
|
|---|
fbCom2FX5
Next, create the program that calls fbSLMPRead and fbSLMPWrite.

Network 2
In this network, the IP address of the target device to connect with via TCP communication is set. By assigning 192, 168, 0, and 95 to RemoteAddress.ADDR[1] to [4] of the TCON_IP_v4 structure, the destination IP is specified as 192.168.0.95.

Network 3
In this network, the connection type (ConnectionType) for TCP communication is set.
By assigning 16#11 to TCON_IP_v4.ConnectionType, the communication method is set to TCP (active connection). With this setting, TCP communication is initiated from the PLC side to the partner device.

Network 4
In this network, the port number of the partner device for TCP communication is set. By assigning 7501 to TCON_IP_v4.RemotePort, the TCP port number 7501 listening on the target device is specified. With this setting, the PLC communicates with port 7501 of the target device specified by IP address.

Network 5
In this network, the local communication interface used by the PLC is specified.
By setting 64 (Local~PROFINET_interface_1) in TCON_IP_v4.InterfaceId, PROFINET interface 1 of the PLC is designated for TCP communication. With this setting, the PLC performs TCP communication with the target device through the specified PROFINET port.

Network 6
In this network, the Connection ID used for TCP communication is set.
By assigning 16#1 to TCON_IP_v4.ID, Connection Number 1 is specified to identify this communication connection. This ID serves as a common reference number across communication FBs such as TCON, TSEND, TRCV, and TDISCON.

Network 7
In this network, the local port number used on the PLC side is set.
By assigning 7501 to TCON_IP_v4.LocalPort, the source port number used when the PLC performs TCP communication is specified as 7501. With this setting, communication with the target device is established using the combination of Local Port 7501 ↔ Remote Port 7501.

Network 8
In this network, it checks whether the device type used in SLMP is specified correctly.

Network 9
In this network, the device number (start address) for starting read/write operations in SLMP communication is configured. Specifically, constant 100 is assigned to dbFX5Read.uiFirstDeviceOffset via MOVE. In short, this process specifies “start SLMP communication reading/writing from device number 100”.

Network 10
In this network, the count (number of points) of devices handled in SLMP communication is set. Specifically, constant 10 is assigned to dbFX5Read.uiTotalDevices via MOVE. In short, this specifies “read/write 10 points together starting from the head device”.

Network 11
In this network, the flag dbFX5Read.udtTCON_IP_v4.ActiveEstablished is kept continuously ON. This specifies that communication connection is initiated actively from the PLC side.

Network 12
This is the main body portion executing the SLMP read FB using the configured communication conditions. Using these configured parameters, it launches the SLMP read FB, reads data from FX5, and returns the status and results compiled into the DB.

Network 15
In this network, the IP address of the partner device for TCP communication is set. By assigning 192, 168, 0, and 95 to RemoteAddress.ADDR[1] to [4] of the TCON_IP_v4 structure, the destination IP is specified as 192.168.0.95.

Network 16
In this network, the connection type (ConnectionType) for TCP communication is configured.
By assigning 16#11 to TCON_IP_v4.ConnectionType, the communication mode is set to TCP (active connection). With this setting, TCP communication is initiated from the PLC side to the remote partner.

Network 17
In this network, the port number of the target device for TCP communication is configured. By assigning 7502 to TCON_IP_v4.RemotePort, the TCP port number 7502 listening on the target device is specified. With this setting, the PLC communicates with port 7502 of the target device specified by IP address.

Network 18
In this network, the local communication interface used by the PLC is specified.
By setting 64 (Local~PROFINET_interface_1) in TCON_IP_v4.InterfaceId, PROFINET interface 1 of the PLC is designated for TCP communication. With this setting, the PLC performs TCP communication through the specified PROFINET port.

Network 19
In this network, the Connection ID used for TCP communication is set.
By assigning 16#2 to TCON_IP_v4.ID, Connection Number 1 is specified to identify this communication connection. This ID is used as a common reference number across communication FBs such as TCON, TSEND, TRCV, and TDISCON.

Network 20
In this network, the local port number used on the PLC side is set.
By assigning 7502 to TCON_IP_v4.LocalPort, the source port number used when the PLC performs TCP communication is set to 7502. With this setting, communication with the target device is established using the combination of Local Port 7502 ↔ Remote Port 7502.

Network 21
In this network, it checks whether the device type used in SLMP is specified correctly.

Network 22
In this network, the device number (start address) for starting read/write operations in SLMP communication is set. Specifically, constant 100 is assigned to dbFX5Write.uiFirstDeviceOffset via MOVE. In short, this process specifies “start SLMP communication writing from device number 100”.

Network 23
In this network, the count (number of points) of devices handled in SLMP communication is set. Specifically, constant 10 is assigned to dbFX5Write.uiTotalDevices via MOVE. In short, this specifies “write 10 points together starting from the head device”.

Network 24
In this network, the flag dbFX5Write.udtTCON_IP_v4.ActiveEstablished is kept continuously ON. This specifies that communication connection is initiated actively from the PLC side.
Network 25
This is the main body portion executing the SLMP write FB using the configured communication conditions. Using these configured parameters, it launches the SLMP write FB, writes data to FX5, and returns the status and results compiled into the DB.

OB1
Finally, call the created FB from OB1.

Download
Download the project to the CPU.
Results
You can check the operation from this video.
Project Download
The project for this article can be downloaded on Github.
https://github.com/soup01Threes/Siemens/blob/main/SLMP.zap20
