×
Siemens Industry Online Support
Siemens AG
Entry type: FAQ Entry ID: 31764614, Entry date: 07/29/2021
(3)
Rate

How do you program communication blocks FC11 and FC12 for the PROFINET IO device?

  • Entry
  • Associated product(s)
If you operate an Industrial Ethernet CP of the S7-300 as PROFINET IO controller or PROFINET IO device, then you have to call the communication functions FC11 "PNIO_SEND" and FC12 "PNIO_RECV" in the user program.

Features of communication blocks FC11 "PNIO_SEND" and FC12 "PNIO_RECV":

  • FC11 and FC12 are synchronous communication blocks.
  • The blocks are contained in the "SIMATIC_NET_CP" library for the S7-300 controller.
  • The blocks must be called in the OB1 cycle (see also Entry ID: 2795485).
  • The end of the job is indicated by "DONE", "NDR" or "ERROR".

Features of communication block FC11 "PNIO_SEND":

  • Operation as PROFINET IO controller
    The block transfers the process data (outputs) of a specified output range to the IE CP for forwarding to PROFINET IO devices and as status display supplies the IO Consumer Status (IOCS) of the outputs of the PROFINET IO devices.
  • Operation as PROFINET IO device
    The block reads the preprocessed process inputs of the CPU in the PROFINET IO device and transfers them to the PROFINET IO controller (configured I addresses); furthermore, the block supplies the IO Consumer Status (IOCS) of the PROFINET IO controller as status display.

Features of communication block FC12 "PNIO_RECV":

  • Operation as PROFINET IO controller
    The block accepts the process data (inputs) from PROFINET IO devices (inputs of the controller) and the IO Provider Status (IOPS) of the inputs from the PROFINET IO devices in the specified input areas.
  • Operation as PROFINET IO device
    The block accepts the data (configured Q addresses) transferred by the PROFINET IO controller and the IO Provider Status (IOPS) of the PROFINET IO controller and writes it to data areas of the CPU reserved for the process outputs in the PROFINET IO device.

Description of the configuration
The STEP 7 project includes the following S7-300 station that is configured as PROFINET IO controller:

  • CPU 319-3PN/DP

In the STEP 7 project the following modules are configured as PROFINET IO devices:

  • CPU 315-2DP with CP343-1 Lean (6GK7 343-1CX10-0XE0)
  • ET 200S

Fig. 1

The following input/output modules are configured for the PROFINET IO device CP343-1 Lean:

  • 16-byte DI with the address range 0-15
  • 8-byte DI with the address range 16-23
  • 16-byte DO with the address range 0-15
  • 4-byte DO with the address range 16-19

This means the address range of the inputs is 24 bytes (0-23) and the address range of the outputs is 20 bytes (0-19). The address range of the inputs and outputs does not have to begin with the IO address "0".

Fig. 2

The following input modules are configured in the ET 200S

  • 2 DO with the address range 20.0-20.1

Fig. 3

This results in a total address range for the:

  • Inputs: 0 to 23 = 24 bytes
  • Outputs: 0 to 20 = 21 bytes

Description of the user program of the PROFINET IO device
In this example, a CP343-1 Lean is used to connect an S7-300 station as PROFINET IO device to a PROFINET IO system. Marker byte 0 (MB0) is defined as clock marker in the S7-300 CPU. The STEP 7 program consists of the blocks OB1, FB100, DB30, DB31, DB12, FC11 and FC12.

OB1
OB1 is called cyclically. In this OB is the call of FB100 (instance DB: DB100).

Fig. 4

FB100
FB100 is called in the OB1 cycle. In this FB is the call of FC11 "PNIO_SEND" and FC12 "PNIO_RECV".

Fig. 5


Fig. 6

The input parameter MODE=0, because the IE CP is only operated as PROFINET IO device. If the IE CP is operated in parallel as PROFINET IO controller and PROFINET IO device, then the input parameter is MODE=1.

At the input parameter LEN of the FC11 "PNIO_SEND" you specify the length of the total address range of the inputs that you have configured for the CP 343-1 Lean (24 bytes). The data area for the address range of the inputs is specified at the SEND parameter of FC11 "PNIO_SEND". This data area must be as long as the total address range of the inputs you have configured for the CP 343-1 Lean (24 bytes).

At the input parameter LEN of FC12 "PNIO_RECV" you specify the length of the total address range of the outputs you have configured for the CP 343-1 Lean (20 bytes). The data area for the address range of the outputs is specified at the RECV parameter of FC12 "PNIO_RECV". This data area must be as long as the total address range of the outputs you have configured for the CP 343-1 Lean (20 bytes).

In this example the following data areas are used for IO data:

  • DB30 for the address range of the inputs: In this example the DB30 must be at least 24 bytes long.
  • DB31 for the address range of the outputs: In this example DB31 must be at least 20 bytes long.

At the input parameter CPLADDR of the communication functions you specify the module address of the PROFINET IO controller. You take this from the hardware configuration, in the Properties dialog of the Industrial Ethernet CPs -> "Addresses" tab (see Fig. 06). In this example the module address of the CP343-1 Lean is 256dec = 100hex.

Fig. 7

The output parameters "DONE", "NDR", "ERROR" and "STATUS" of the communication functions FC11 "PNIO_SEND" and FC12 "PNIO_RECV" are required for the job evaluation.

The output parameter "DONE" at FC11 "PNIO_SEND" is set if the Send job has been completed successfully.
The output parameter "NDR" at FC12 "PNIO_RECV" is set if the Receive job has been completed successfully, in other words the data has been accepted.

If the communication function FC11 "PNIO_SEND" or FC12 "PNIO_RECV" ends with an error, the communication function's status word is saved for error analysis.

Fig. 8

Access to the IO data of the CP 343-1 Lean in the user program of the PROFINET IO devices
In this example there are two DBs to store the IO data.
DB30 covers the address range of the inputs of the CP 343-1 Lean. DB31 covers the address range of the outputs of the CP 343-1 Lean.
In the user program you access the areas of the data blocks via load and transfer commands to read and write the IO addresses.

  • T DB30.DBB0 then corresponds to T EB0
  • L DB31.DBB0 then corresponds to L AB0

Description of the user program in the PROFINET IO controller
In this example, a S7-300 CPU with integrated Industrial Ethernet interface is used as PROFINET IO controller. Marker byte 0 (MB0) is defined as clock marker.

The STEP 7 program consists of the blocks OB1, FB100 and DB20.

It is not necessary to call communication blocks in the user program. You access the I/O with load and transfer commands, i.e. you read out the values of the inputs and write the values to the outputs. The values of the inputs read are stored in the the data block (DB20).

Note
A detailed description including sample program for the call of the communication blocks FC11 and FC12 in the PROFINET IO controller is available in Entry ID: 26558253.

The STEP 7 project as download
The following STEP 7 project contains a sample program for the call of the FC11 and the call of the FC12 with status evaluation. It was created with STEP 7 V5.4 SP3.

  fc11_und_fc12_dev.zip (296,0 KB) 

Dearchive the file "FC11_and_FC12_CTRL.zip" in the SIMATIC Manager via the menu "File -> Dearchive". The STEP 7 project is now unpacked with all the subdirectories. Now you can open and edit the STEP 7 project with the SIMATIC Manager.

Security information
In order to protect technical infrastructures, systems, machines and networks against cyber threats, it is necessary to implement – and continuously maintain – a holistic, state-of-the-art IT security concept. Siemens’ products and solutions constitute one element of such a concept. For more information about cyber security, please visit
https://www.siemens.com/cybersecurity#Ouraspiration.
Rate entry
no rating
Requests and feedback
What do you want to do?
Note: The feedback always relates to the current entry / product. Your message will be forwarded to our technical editors working in the Online Support. In a few days, you will receive a response if your feedback requires one. If we have no further questions, you will not hear from us.