×
Siemens Industry Online Support
Siemens AG
Entry type: FAQ Entry ID: 26558253, Entry date: 10/09/2008
(12)
Rate

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

  • 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 315-2DP with CP343-1 (6GK7 343-1EX21-0XE0)

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

  • ET 200S with IM151-3 PN (6ES7 151-3AA10-0AB0)
  • ET 200S with IM151-3 PN HF (6ES7 151-3BA22-0AB0)

Fig. 1

The following input and output modules are configured for the ET 200S with IM151-3 PN:

  • 4 DO with the address range 0.0-0.3
  • 4 DI with the address range 0.0-0.3
  • 4 DO with the address range 1.0-1.3

Fig. 2

The following input and output modules are configured in the ET 200S with IM151-3 PN HF:

  • 2 DO with the address range 20.0-20.1
  • 4 DI with the address range 10.0-10.3

Fig. 3

This results in a total address range for the:

  • Inputs: 0 to 10 = 11 bytes
  • Outputs: 0 to 20 = 21 bytes

Note
The address range of the inputs and outputs must start with the IO address "0".

Description of the user program
In this example we use an S7-300 station with CP343-1 as PROFINET IO controller.
The STEP 7 program consists of the blocks OB1, FB100, DB30, DB31, DB12, FC11 and FC12.

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

Fig. 4

FB100

The 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 controller. 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 FC11 "PNIO_SEND" you specify the length of the total address range of the configured outputs (21 bytes). The data area for the address range of the outputs is specified by the SEND parameter of FC11 "PNIO_SEND". This data area must be as long as the total address range of the configured outputs (21 bytes).

At the input parameter LEN of FC12 "PNIO_RECV" you specify the length of the total address range of the configured inputs (11 bytes). The data area for the address range of the inputs is specified by the RECV parameter of FC12 "PNIO_RECV". This data area must be as long as the total address range of the configured inputs (11 bytes).

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

  • DB30 for the address range of the outputs: In this example the DB30 must be at least 21 bytes long.
  • DB31 for the address range of the inputs: In this example DB31 must be at least 11 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. 07). In this example the module address of the CP343-1 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 in the user program
In this example there are two DBs to store the IO data.
DB30 covers the address range of the outputs of the connected IO devices. DB31 covers the address range of the inputs of the connected IO devices.
If you use the first bit in the data block as start value for the pointer at the "SEND" and "RECV" input, for example p#DB*.DBX0.0 BYTE *, then it is possible to access the areas of the data blocks in the user program via load and transfer commands as if the addresses of the data block correspond to the peripheral addresses.

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

The address range for the inputs and outputs is mapped from the start value of the pointer at the "SEND" and "RECV" input in the data area. If, for example, you use the first bit in byte 10 as start value (p#DB*.DBX10.0 BYTE *), then you access the IO addresses as follows:

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

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

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 SP4.

FC11_und_FC12_CTRL.zip (553 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.