You are on page 1of 124

SIEMENS S7-1200

NOTAS DE APLICAO N 01

SIEMENS S7-1200

FAQs 2010 / 2009


( j.andril@bresimar.pt , v1.1 - 12/2010 )

www.bresimar.pt

SIEMENS S7-1200

NOTAS DE APLICAO N 01

(folha em branco)

www.bresimar.pt

SIEMENS S7-1200

NOTAS DE APLICAO N 01

FAQs 2010 / 2009 FAQ - How do you establish MODBUS-RTU communication with STEP 7 Basic V10.5 for the SIMATIC S7-1200 ? FAQ - How can you prevent data loss of runtime-generated parameters when updating your S7-1200 PLC program ? FAQ - How can you share runtime-generated between several S7-1200 PLCs with a KTP Basic Panel ? FAQ - How do you synchronize the time and date of an HMI Basic Panel with an S71200 PLC using the "Job mailbox" area pointer ? FAQ - How can you manage block execution errors detected by the S7-1200 PLC ? FAQ - How can you deal with time errors detected by the S7-1200 CPU ? FAQ - How is numerical integration programmed in STEP 7 Basic V10.5 ? FAQ How can you access an S7-1200 PLC by PC-Access and what is to be considered? FAQ How can you establish a connection between an S7-1200 PLC and SIMATIC NET OPC ? FAQ How can you erase the IP address and set your S7-1200 PLC back to factory settings , using the SIMATIC MC memory card (2MB or 24MB) ? FAQ How can you change the IP address of an S7-1200 PLC without STEP 7 Basic ? FAQ How can you download to a network of several S7-1200 PLCs with the same IP address ? FAQ How you reset the IP address of your S7-1200 PLC using STEP7 Basic software? FAQ How can you manage peripheral device errors detected by the S7-1200 PLC ? FAQ How can you use an analog current output with wire break diagnostics on your S7-1200 PLC ? FAQ How can you use analog 0-20mA signal modules and signal boards with 4-20mA signals ? FAQ - How do you synchronize the time of the HMI Basic Panel with S7-1200 PLC ? FAQ How do you access S7-1200 tags with a panel or RT configured with WinCC flexible 2008 SP2 ? FAQ With which devices can the S7-1200 communicate via the PN connection ? FAQ How do you compensate for the string mismatch caused by the RCV_PTP and SEND_PTP blocks ? FAQ How can you reduce memory usage with Multi instancing ? FAQ How many high-speed counters (HSCs) are provided by SIMATIC S7-1200 PLC? FAQ How do you connect a sensor to the analog signal modules of the SIMATIC S71200 ? FAQ How can you back up parameters before loading a new control program ?

www.bresimar.pt

SIEMENS S7-1200

NOTAS DE APLICAO N 01

(folha em branco)

www.bresimar.pt

SIEMENS S7-1200

NOTAS DE APLICAO N 01

FAQ - How do you establish MODBUS-RTU communication with STEP 7 Basic V10.5 for the SIMATIC S7-1200 ?
Description The SIMATIC S7-1200 enables point-to-point communication using the communication modules CM 1241 RS485 and CM 1241 RS232. You can add up to three communication modules to each S7-1200 controller. Using the MODBUS library integrated in STEP 7 Basic V10.5 you can define each communication module as a MODBUS master or slave. If you define the CM 1241 RS232 as MODBUS master, then there is a physical limitation that permits communication with one slave only. If you define the CM 1241 RS485 as MODBUS master, then it is possible to communicate with up to 32 slaves one after the other. We will take a sample project to describe the configuration procedure in STEP 7 Basic V10.5 for communication with multiple slaves using the CM 1241 RS485. Instructions We have taken the example of MODBUS communication between a master and a slave. There is alternate writing to the holding register of the slave (function code 16) and reading from the holding register of the slave (function code 03). Since the RS485 has a two-wire (half-duplex) interface, writing and reading must be conducted consecutively. By the same principle, the address of the slave to be addressed can be changed between two actions (here writing and reading), thus making it possible to exchange data with multiple slaves.

Fig. 01 The CM 1241 RS485 communication modules are linked to each other using a PROFIBUS cable. You can continue with the PROFIBUS cable to connect up to 31 additional MODBUS slaves to the master. The configuration is done in STEP 7 Basic V10.5 SP2. The program code is transferred to the controllers with the switch CSM 1277. MB_COMM_LOAD The configuration block MB_COMM_LOAD is required on both sides (master and slave) for MODBUS communication.

www.bresimar.pt

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig. 02

The MB_COMM_LOAD block is used to select the communication module, set the communication parameters and establish the connection with the master or slave parameters.

The MB_COMM_LOAD block must be called in the first program cycle (by activating the system marker M1.0 in the hardware settings or by a call in Startup OB 100).

After inserting the communication module in the hardware configuration you can select the symbolic name of the communication module at the PORT parameter.

The communication parameters BAUD (transmission rate) and PARITY (parity) must be identical for all nodes. The port configuration of the RS485 interface in the STEP 7 V10.5 device view is irrelevant here.

The instance data block of the master or slave block is transferred at the MB_DB parameter and thus defines the communication module (PORT parameter) as MODBUS master or slave. MB_MASTER You use the MB_MASTER block to define the communication module selected with the MB_COMM_LOAD configuration block as MODBUS master.

www.bresimar.pt

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig. 03 The MB_MASTER block is used to select the MODBUS slave to be addressed, select the function code (read/write, MODBUS start address and data length) and define the local data storage area.

The communication is triggered by the REQ parameter.

The MODBUS-RTU station address to be addressed is transferred at the MB_ADDR parameter.

The MODE parameter specifies the direction of transmission ("0" = read, "1" = write or additional diagnostics functions).

The MB_MASTER block must be called in the first program cycle (by activating the system marker M1.0 in the hardware settings or by a call in Startup OB 100).

The DATA_ADDR and DATA_LEN parameters are for setting the MODBUS start address and the data length (bits or words depending on the MODBUS start address selected).

The DATA_PTR parameter defines the local receive and send data storage areas of the master. DATA_PTR must refer to a global data block created with the "Symbolic access only" option disabled. When multiple elements are to be transferred (bits or words), the symbolic name of an array or struct that covers this data storage area (DATA_ADDR and DATA_PTR) must be transferred here. MB_SLAVE You use the MB_SLAVE block to define the communication module selected with the MB_COMM_LOAD configuration block as MODBUS slave.

www.bresimar.pt

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig. 04 The MB_SLAVE block is used to define the MODBUS-RTU station address and specify the local data storage area for the holding register data transfer.

The local MODBUS-RTU station address is transferred at the MB_ADDR parameter. The MODBUS master identifies the slave with this.

The MB_HOLD_REG parameter defines the local holding register data storage area of the slave. MB_HOLD_REG must refer to a global data block created with the "Symbolic access only" option disabled. When multiple registers (words) are to be transferred, the symbolic name of an array or struct that covers the specified data volume of the master (DATA_ADDR and DATA_PTR) must be transferred here. The first word of this array or struct corresponds to the MODBUS holding register start address 40001. The parameters can be switched with the inputs and outputs of the blocks or by accessing the instance data block concerned. Sample project In the master project, the alternate writing to / reading from the holding register of the slave is done using a sequencer.

www.bresimar.pt

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig. 05 The MB_COMM_LOAD configuration block is called in the initialization step 0.

In Step 1 the MB_Master with the communication parameters for writing to the slave (MODE = 1) is called and executed (REQ = 1).

The transition to Step 2 is made by the positive (DONE) or negative (ERROR) confirmation from the MB_MASTER.

The transition resets the execution of the MB_MASTER (REQ = 0).

In Step 2 the communication parameters for reading from the slave (MODE = 0) are written using the MB_MASTER in the same instance data block as from Step 1 (MB_DB parameter of the MB_COMM_LOAD block).

Execution and transition are the same as in Step 1. The figure below shows a step (networks 6 and 7) with transition (network 8).

www.bresimar.pt

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig. 06 The MB_ADDR parameter (see Network 6) can therefore also be used to change the slave to be addressed per step, which permits data to be exchanged with up to 32 slaves. www.bresimar.pt

10

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Download
The compressed file "MODBUS_RTU.zip" contains the sample project "MODBUS_RTU.ap10" for alternate data transfer between a master and a slave.

Unpack the "MODBUS_RTU.zip" file and open the sample project "MODBUS_RTU.ap10" with STEP 7 Basic V10.5 (>= SP2).

The version of the firmware of the SIMATIC S7-1200 controllers used is V1.0.2.

Download the project folders ("Master" and "Slave") into the controllers.

You can track the data transfer in the monitoring table.

Modbus_RTU.zip ( 969 KB )

Note
More information about Modbus Library Operations is available in the SIMATIC S7 S7-1200 Programmable Controller System Manual (Entry ID: 36932465).

www.bresimar.pt

11

SIEMENS S7-1200

NOTAS DE APLICAO N 01

(folha em branco)

www.bresimar.pt

12

SIEMENS S7-1200

NOTAS DE APLICAO N 01

FAQ - How can you prevent data loss of runtime-generated parameters when updating your S7-1200 PLC program ? Description
You need to apply changes to your user program running on a S7-1200 PLC, but you do not want to loose your runtime-generated parameters. Buffer your runtime-generated parameters in the HMI "Runtime" recipe function of STEP 7 Basic and download your program changes to your S7-1200 PLC. To apply this feature, execute the following steps: Prepare your STEP 7 Basic HMI project to buffer your parameters. No changes to your PLC program are necessary. Buffer your parameters in the HMI "Runtime" recipe function of STEP 7 Basic. Download your changed program to your S7-1200 PLC. Retrieve your parameters from the HMI "Runtime".

Capacity of the recipe function: You can buffer up to 20 elements (tags) per recipe. You can use up to a maximum of 5 recipes.

Each recipe allows you to buffer different sets of tags (total sum of tags: 5x20=100). Please find an example project in the attached file.

Fig. 01 Configuring the buffering feature in your project In the following description, the HMI project of the attached STEP 7 Basic project is used.

www.bresimar.pt

13

SIEMENS S7-1200

NOTAS DE APLICAO N 01

No . Integrating the recipe function 1. Prepare the projects


Follow these steps: Open your own project with STEP 7 Basic. Download, unzip, and open the attached STEP 7 Basic project " DataStore".

This project is designed to match the following devices: S7-1200 PLC with CPU 1214 (6ES7 214-1BE30-0XB0) KPT600PN Basic Panel (6AV6 647-0AD11-3AX0)

The panel type is not important as the HMI "Runtime" can simulate any configured type of KPT Basic Panels.

2. Copy the HMI device into your project


Drag and Drop the "HMI_DataStore" HMI project from the attached "DataStore" STEP 7 Basic project into your own project. Drag and Drop the "DataStore" global data block from the "DataStore" project to your own project. Drag and Drop the "RuntimeParameters" global data block from the "DataStore" project to your own project. Compile the data blocks of "PLC_1".

The "RuntimeParameters" data block holds the parameter tags for the example project. It is used to demonstrate this feature. In your own project any data tag capable of holding numerals can be used.

Fig. 02

www.bresimar.pt

14

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Important
Compile the data blocks of "PLC_1". Make sure the used data tags are "retentive". Otherwise the restored data will not survive a PLC STOP or a power-cycle condition.

3. Delete the HMI tags


Follow these steps: Browse the "Project tree" for the "HMI tags" editor. Select all "HMI_connection_x" entries, and click "Delete" in the context menu.

Fig. 03 Note Do not delete the "s_ipAddress" internal tag.

4. Configure the HMI Connection


Follow these steps: Browse for "Device&Networks" and click the "Connections" button. Select the "Connections" tab and delete the HMI connection of the "HMI_DataStore" panel by clicking "Delete" in the context menu. Acknowledge the following dialog window.

Fig. 04 www.bresimar.pt

15

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Connect the Ethernet ports of the "HMI_DataStore" panel and the "PLC_1" S7-1200 PLC. A new HMI connection is established.

Fig. 05

5. Configure the HMI area pointer


Follow these steps: In the context menu of the "HMI_connection_2" select the "Go to Connections editor.." item (see Fig. 05). In the "Area pointers" tab, check the Data record area pointer active, and assign the "aw_dataRecord" tag from the "DataStore" data block. Check the "Job mailbox" area pointer, and assign the "aw_jobMailbox" tag from the "DataStore" data block.

Fig 06 www.bresimar.pt

16

SIEMENS S7-1200

NOTAS DE APLICAO N 01

6. Add the tags to recipe function


Follow these steps: Browse the "Project tree" for the "Recipes" item of the "HMI_dataStore" HMI device. In the recipe, view select "Recipe 1" Change to the "Elements" tab, and assign the tags you want to share with your other S7-1200 PLCs to the elements of this recipe. The default setting for decimal places is zero. Increase the number of decimal places up to the resolution you need. Configure up to 20 elements per recipe.

Note Any invalid tag needs to be deleted or reassigned. Invalid tags are highlighted red.

Fig. 07

7. Configure the screen tags


Browse the "Project tree" for the "Screens" folder of the "HMI_DataStore" device, and open the "root screen". Assign the "aw_dataRecord[3]" word tag to the status output field.

Fig. 08 Assign the "HMI_connection_2" connection to the "Release" event of the Change IP button.

www.bresimar.pt

17

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig. 09

Table 01

Buffering and retrieving the parameters with HMI "Runtime" No. Buffering and retrieving the parameters 1. Start the HMI "Runtime" of STEP 7 Basic
Follow these steps: Select the "HMI_DataStore" HMI device. Click the "Start runtime" button.

www.bresimar.pt

18

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig. 10

2. Buffer the parameters in the HMI


Follow these steps: On your HMI display select "Recipe_1" and click the "OPEN" button. The "Recipe_data_record_1" opens.

Fig.11 Press the "PLC>>HMI" button to read the parameters from the S7-1200 PLC. The "Save as" window opens.

www.bresimar.pt

19

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig. 12 To save the data record number "1", enter the number "1" in the "Number" input field, and click the "OK" button.

Fig. 13 Click the "Open" button to see the parameter values of this data record.

Fig. 14 Your parameters are now stored in Runtime. Note You can also archive / retrieve parameter element values.

3. Download your program


Click the "Download to device" button to download your program to your S7-1200 PLC.

www.bresimar.pt

20

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig. 15

4. Restore the parameters to the PLC


Follow these steps: On your HMI display select "Recipe_1" and click the "OPEN" button. The "Recipe_data_record_1" opens. See Fig. 11/12 for details. Press the "HMI>>PLC" button to write the parameters to your S7-1200 PLC.

Table 02

Adjusting the IP address


Change the IP address, that is configured in the HMI connection, if you want to access another S7-1200 PLC (for example, PLC_2). Each S7-1200 PLC has a unique IP address.

No. Adjust the IP address


1. If the IP address of the S7-1200 PLC in the project does not match the IP address of the actual S7-1200 PLC you are using, you must change the IP address configured in the HMI "Runtime" (for example, you run the same project on several S7-1200 PLCs). Follow these steps: On your HMI "Runtime", enter the IP address of the S7-1200 PLC (for example, "192.168.0.1") in the input field. Click the "Change IP" button.

www.bresimar.pt

21

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig. 16

Table 03

Requirements
S7-1200 PLC Ethernet cable PG / PC STEP 7 Basic V10.5

S71200_DataStore.zip ( 3134 KB )

www.bresimar.pt

22

SIEMENS S7-1200

NOTAS DE APLICAO N 01

FAQ - How can you share runtime-generated between several S7-1200 PLCs with a KTP Basic Panel ? Description
Your application consists of one master project which you want to run simultaneously on several PLCs. While commissioning the first PLC, miscellaneous specific parameters will be generated which shall be used for all other PLCs. Archive these parameters in your KTP Basic Panel, and retrieve them on your other PLCs, instead of commissioning every single PLC. The KTP Basic Panel allows for the archiving and retrieving of these parameters, while being connected to an S7-1200 PLC, using its retentive recipe function. The recipe function of the KTP Basic Panel is used for this task. To use this "Parameter sharing" feature, follow these steps: 1. Integrate the recipe function into your HMI program, and link the parameter tags you want to archive / retrieve. 2. Download your master project to all of your PLCs. 3. Assign unique IP addresses to each of your PLCs.Youcan use either STEP 7 Basic or the "IP TOOL" which you will find in entry ID 41737436. 4. Download your HMI program to your KTP Basic Panel. 5. Connect your KTP Basic Panel to your first S7-1200 PLC. 6. In the configuration of the KTP Basic Panel, adjust the IP address (for example, 192.168.0.1) for communications with your first S7-1200 PLC. 7. Commission your first PLC, and generate specific runtime parameters. 8. Archive the commissioned parameters in your KTP Basic Panel. 9. Connect your KTP Basic Panel to your next S7-1200 PLC. 10. In the configuration of the KTP Basic Panel, adjust the IP address (for example, 192.168.0.2) for communications with your next S7-1200 PLC. 11. Retrieve your parameters from your KTP Basic Panel. 12. Repeat steps 9 through 11 until all your S7-1200 PLCs are updated. To integrate this feature into your program, follow the steps described in the "Integrating the recipe function" section of this article. An overview on the use of this feature can be found in the "Applying the parameter sharing feature" section of this article.

Fig. 01 www.bresimar.pt

23

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Integrating the recipe function No. Integrating the recipe function 1. Prepare the projects
Follow these steps: Open your own project with STEP 7 Basic. Download, unzip and open the attached STEP 7 Basic project " DataStore".

This project is designed to match the following devices: S7-1200 PLC with CPU 1214 (6ES7 214-1BE30-0XB0) KTP600PN Basic Panel (6AV6 647-0AD11-3AX0)

2. Copy the HMI device and the data blocks into your project
Follow these steps: Drag and Drop the "HMI_DataStore" HMI project from the "DataStore" project to your own project. Drag and Drop the "DataStore" global data block from the "DataStore" project to your own project. Drag and Drop the "RuntimeParameters" global data block from the "DataStore" project to your own project. Compile the data blocks of "PLC_1".

The "RuntimeParameters" data block holds the parameter tags for the example project. It is used to demonstrate this feature. In your own project any data tag capable of holding numerals can be used.

Fig. 02

www.bresimar.pt

24

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Important
Compile the data blocks of "PLC_1". Make sure the used data tags are "rententive". Otherwise the restored data will not survive a PLC STOP or a power-cycle condition.

3. Delete HMI tags


Follow these steps: Browse the "Project tree" for the "HMI tags" editor. Select all "HMI_connection_x" entries, and click "Delete" in the context menu.

Fig. 03

Note
Do not delete the "s_ipAddress" internal tag.

4. Configure HMI Connection


Follow these steps: Browse for "Device&Networks" and click the "Connections" button. Select the "Connections" tab, and delete the HMI connection of the "HMI_DataStore" panel by clicking "Delete" in the context menu. Acknowledge the following dialog wind

Fig. 04 www.bresimar.pt

25

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Connect the Ethernet ports of the "HMI_DataStore" panel and the "PLC_1" S7-1200 PLC. A new HMI connection is established.

Fig. 05

5. Configure the HMI area pointer

Follow these steps: In the context menu of the "HMI_connection_2" select the "Go to Connections editor.." item (see Fig. 05). In the "Area pointers" tab, check the Data record area pointer active, and assign the "aw_dataRecord" tag from the "DataStore" data block. Check the "Job mailbox" area pointer, and assign the "aw_jobMailbox" tag from the "DataStore" data block.

www.bresimar.pt

26

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig 06

6. Add the tags to recipe function


Follow these steps: Browse the "Project tree" for the "Recipes" item of the "HMI_dataStore" HMI device. In the recipe view, select "Recipe 1" Change to the "Elements" tab, and assign the tags you want to share with your other S7-1200 PLCs to the elements of this recipe.

Note
Any invalid tag needs to be deleted or to reassigned. Invalid tags are highlighted in red.

www.bresimar.pt

27

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig. 07

Note
You can configure the tags stored in the HMI by adding new elements to the "Elements" view of the "Recipe_data_record_1". There are up to 5 recipes available for you to configure 5 different sets of tags. One recipe holds up to 20 data records with 20 elements each. Therefore you can store 20 different setups in one recipe.

7. Configure the screen tags


Follow these steps: Browse the "Project tree" for the "Screens" folder of the "HMI_DataStore" device, and open the "root screen". Assign the "aw_dataRecord[3]" word tag to the status output field.

Fig. 08 www.bresimar.pt

28

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Assign the "HMI_connection_2" connection to the "Release" event of the Change IP button.

Fig. 09

Table 01

Applying the "parameter sharing" feature


The following overview is based on the attached "DataStore" project.

No. Applying the "parameter sharing" feature 1. Download your program to all of your PLCs
Follow these steps: Select the "PLC_DataStore" S7-1200 PLC. Click the "Download to device" button and acknowledge the following dialog windows.

www.bresimar.pt

29

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig. 10

2. Assign unique IP addresses


Assign unique IP addresses to all of your S7-1200 PLCs. You can use either STEP 7 Basic or the IP TOOL. Please find the IP TOOL in entry ID 41737436.

3. Download your HMI program to your HMI device


Follow these steps: Select the "HMI_DataStore" HMI device. Click the "Download to device" button. See Fig. 10 for details.

4. Change IP address
To address an S7-1200 PLC with your KTP Basic Panel, you need to use the IP address of the S7-1200 PLC in your HMI device: Connect your KTP Basic Panel to your S7-1200 PLC. On your KTP Basic Panel, enter the IP address of the S7-1200 PLC (for example, "192.168.0.1") in the input field. Click the "Change IP" button.

Fig. 11

www.bresimar.pt

30

SIEMENS S7-1200

NOTAS DE APLICAO N 01

5. Store parameters in HMI


Follow these steps: On your HMI display, select "Recipe_1", and click the "OPEN" button. The "Recipe_data_record_1" opens. Press the "PLC>>HMI" button to read the parameters from the S7-1200 PLC. The "Save as" window opens.

Fig. 12 To save the data record number "1", enter the number "1" in the "Number" input field, and click the "OK" button.

Fig. 13 Click the "Open" button to see the parameter values of this data record.

Fig. 14

www.bresimar.pt

31

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Your parameters are now stored in your panel.

Note
It is also possible to archive / retrieve parameter elements.

6. Restore data in PLC


On your HMI display, select "Recipe_1", and click the "OPEN" button. The "Recipe_data_record_1" opens. See Fig. 11/12 for details. Press the "HMI>>PLC" button to write the parameters to your S7-1200 PLC.

Table 02

Note
You can also use the "Runtime" feature of STEP 7 Basic instead of a KTP Basic Panel.

Requirements
S7-1200 PLC Ethernet cable PG / PC STEP 7 Basic V10.5 KTP600PN basic panel

S71200_DataStore.zip ( 3137 KB )

www.bresimar.pt

32

SIEMENS S7-1200

NOTAS DE APLICAO N 01

FAQ - How do you synchronize the time and date of an HMI Basic Panel with an S7-1200 PLC using the "Job mailbox" area pointer ? Description
To synchronize the time and date of your HMI Basic Panel to the local time of your S7-1200 PLC, perform the following steps: Set up a tag array for the area pointer to store the time and date information. Enable and configure the "Job mailbox" area pointer. Enter the time and date information into the tag array. Evaluate the "Job mailbox".

Synchronizing the time and date


The necessary steps to synchronize time and date via the "Job mailbox" area pointer are described in the table below.

No. Synchronizing the time and date 1. Set up a tag array for the area pointer
You use the area pointer to access a data area in the PLC, and this data area is saved in the PLC. Set up the data area as a tag array in a global data block or an instance data block. The configuration of the tags in a data block is based upon the length of the area pointer you want to use. The unit for the length of an area pointer is a 16-bit word. The "Job mailbox" area pointer requires an array of 4 elements.

1. Expand the view of the PLC in the "Project tree", and open the "Program blocks" folder. Doubleclick on "Add new block", click on "Data block (DB)" with "Global DB" as the type and click the "OK" button. The data block opens.

Fig. 01 2. Enter a tag name (for example "a_jobMailbox") in the "Name" column. 3. Select "Array [lo .. hi] of type" as the data type in the "Data type" column. Replace the "lo" and "hi" entries in the brackets with the low ("0") and high ("3") values for the dimensions of the array. 4. Replace the "type" designation with the "word" data type. The full data type for an array of 4 tags appears as follows: "Array [0 .. 3] of word".

Fig. 02 5. Select the PLC in the "Project tree" and click the "Compile" button in the tool bar. The data block is www.bresimar.pt

33

SIEMENS S7-1200

NOTAS DE APLICAO N 01

compiled. Following compilation, the tag array is available for further use in the project.

Fig. 03

Note
The data block must be compiled before the tag array is available for further use.

2.

Configure the "Job mailbox" area pointer


To configure the "Job mailbox" area pointer, open the "Connections" editor and open the "Area pointer" tab.

1. Expand the view of the HMI device in the "Project tree" and double-click the "Connections" entry.
The "Connections" editor opens.

Fig. 04 2. Open the "Area pointers" tab and enable the "Job mailbox" area pointer by checking the box in the "Active" column. 3. Click the navigation button in the "PLC tag" field; the object list opens. Navigate to the www.bresimar.pt

34

SIEMENS S7-1200

NOTAS DE APLICAO N 01

"Data_block_1"data block in the object list and select the "a_jobMailbox" tag in the right window.

Fig. 05

3.

Enter the parameters in the "Job_mailbox" tag array


The PLC can use the "Job mailbox" to transfer jobs to the HMI Basic Panel in order to trigger corresponding actions on the HMI device. The HMI Basic Panel evaluates the "Job mailbox" if the first word of this job is unequal to zero. This means that the parameters must be entered in the "Job mailbox" first, followed by the job number. When the HMI Basic Panel accepts the "Job mailbox", the first word is set to 0 again. The execution of the "Job mailbox" is generally not completed at this point in time. The first word of the "Job mailbox" contains the job number; this is "14" to set the time. The second word contains "Parameter 1". The third word contains "Parameter 2". The fourth word contains "Parameter 3".

Fig. 06 Read the local time from the PLC

Fig. 07 Enter the parameters in the "Job mailbox" tag.

www.bresimar.pt

35

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig. 08

Note
The parameters are BCD-coded.

www.bresimar.pt

36

SIEMENS S7-1200

NOTAS DE APLICAO N 01

4.

Evaluate the "Job_mailbox"


Enter the job number in the "Job mailbox" tag. This will start the evaluation of the "Job mailbox".

Fig. 09 The "Job mailbox" is evaluated and the time of the HMI Basic Panel is set to the local time of the S7-1200 PLC.

5.

Set the date of the HMI Basic Panel


The setting of the date is similar to the setting of the time. To start the evaluation of the "Job_mailbox" the first word needs to be set to "15".

Fig. 10 Table 01

Requirements
S7-1200 PLC Ethernet cable PG / PC STEP 7 Basic V10.5

www.bresimar.pt

37

SIEMENS S7-1200

NOTAS DE APLICAO N 01

(folha em branco)

www.bresimar.pt

38

SIEMENS S7-1200

NOTAS DE APLICAO N 01

FAQ - How can you manage block execution errors detected by the S7-1200 PLC ? Description
By default, the CPU responds to a block execution error by logging an error in the diagnostics buffer and switching to STOP mode, as this is the predefined system response. You can change this behavior by placing one or more "GetError" or "GetErrorID" instructions within the program block you want to monitor. In this case the CPU does not switch to STOP mode and does not log an error in the diagnostics buffer. Instead, this block is now set to manage errors within the block. The error information is reported in the output of the "GetError" or "GetErrorID" instruction.

"GetError"
The "GetError" instruction indicates that a program block execution error has occurred and fills a predefined error data structure of the data type: "ErrorStruct" with detailed error information. The "GetError" instruction can also be used to forward an alarm about the error status to the calling block. To do this, the instruction must be positioned in the last network of the called block.

"GetErrorID"
The "GetErrorID" instruction indicates that a program block execution error has occurred and reports the ID (identifier code) of the error. Please find a list of the error codes in the online help of STEP 7 Basic, search for the keyword "GetErrorID".

Note
No "GetError" or "GetErrorID" instruction is present when you create a new project.

Evaluating a block execution error event with the "GetError" instruction


Information on the block execution event will be stored in a tag of the "ErrorStruct" system data type.

No. Evaluating a block execution error event with the "GetError" instruction 1 Add the "GetError" instruction
Browse the instructions pane for "Extended instructions > Program control > GetError". Drag and Drop a "GetError" instruction into the last network of the OB you want to monitor. Click the "OK" button.

Please see the figure below for details.

2 Reading out the "ERROR" output information of the "GetError" instruction


You can store the local error information in a global tag as described below: Create a local "error_local" tag of the data type "ErrorStruct". Store the value of the "Error" output in the local "error_local" tag. Browse the instructions pane for "Instructions > Move > MOVE". Drag and Drop a "MOVE" instruction in the network, where your "GetError" instruction is located. Connect the ENO contact of the "GetError" instruction with the EN contact of the "MOVE" instruction. Create a global tag "gl_error" of the "ErrorStruct" data type in the "data_block" data block.

www.bresimar.pt

39

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Move the "GetError" tag into the `"data_block".gl_error tag.

Fig. 01

3 Evaluating the "ERROR" output information of the "GetError" instruction


Only tags of the "ErrorStruct" system data type can be specified at the ERROR output. The "ErrorStruct" system data type specifies the exact structure in which the information about the error is stored. Using additional instructions, you can evaluate this structure and program an appropriate response. The "ErrorStruct" tag contains the following information: The type of block, in which the error occurred (for example "data_block".gl_error.block_type) The number of the block in which the error occurred (for example: "data_block".gl_error.code_block_number)

Please find a detailed overview in the figure below. A detailed list of the contents of the "ErrorStruct" data type can be found in the online help of STEP 7 Basic, search for the keyword "GetError".

www.bresimar.pt

40

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig. 02 Table 01

Error conditions indicated by the "ENO" enable output


The output "ENO" of the "GetError" or "GetErrorID" instruction is set only if the two following preconditions are met: The input EN is enabled. Error information is present.

If one of these conditions does not apply, then the remaining program execution is not affected by the "GetError" instruction. If EN = TRUE and "GetError" or "GetErrorID" executes, then: ENO = TRUE indicates a code block execution error occurred and error data is present ENO = FALSE indicates no code block execution error occurred

You can connect error reaction program logic to the "ENO" output which activates after an error occurs. If an error exists, then the output parameter stores the error data where your program has access to it. "GetError" and "GetErrorID" can be used to send error information from the currently executing block (called block) to a calling block. Place the instruction in the last network of the called block program to report the final execution status of the www.bresimar.pt

41

SIEMENS S7-1200

NOTAS DE APLICAO N 01

called block.

Online diagnostics with STEP 7 Basic


When you do not use an "GetError" instruction, and you have online access to your S7-1200 PLC with STEP 7 Basic, you can use the "Online & diagnostics" function: Go online to your S7-1200 PLC. Browse the "Project tree" for the entry "Online & diagnostics". Browse the navigation area of the "Online Access" window for the entry "Diagnostics buffer". Select a program block execution error event from the "Events" table. Beneath the "Events" table, details on the selected event are displayed. Here, you will find the number of the affected OB and the event ID of the error.

Fig. 03

Note
An "Incoming event" shows the beginning of an event. An "Outgoing event" shows the end of an event.

Use case
If a directly addressed contact (for example "IW120:P") is not available, you can use the "GetError" instruction to achieve the following results: Prevent the CPU from going to STOP mode Launch an error message Set up a substitute value on the missing contact

Requirements
S7-1200 PLC Ethernet cable PG / PC STEP 7 Basic V10.5

www.bresimar.pt

42

SIEMENS S7-1200

NOTAS DE APLICAO N 01

FAQ - How can you deal with time errors detected by the S7-1200 CPU ? Description
Time errors usually occur during commissioning of the S7-1200 PLC. Time errors can be triggered by any of the following conditions: Maximum cycle time exceeded Called OB still being executed Queue overflow Interrupt loss due to excessive interrupt load

All time error events trigger the execution of OB 80, if it exists. OB 80 includes startup information that helps you determine which event and OB generated the time error. If OB 80 does not exist, then the CPU ignores the error, for when the maximum cycle time is exceeded.

Understanding time error events No. Understanding time error events 1. "Maximum cycle time exceeded"
If the cyclic program exceeds the maximum cycle time, the reaction will be as follows: 1. When the cycle time exceeds the cycle monitoring time for the first time, there is an attempt to start the "Time error interrupt" OB (OB 80). If there is no "Time error interrupt" OB in the CPU, the CPU generates an error and continues to execute the user program. 2. If the event "maximum cycle time exceeded" happens twice within the same program cycle, without resetting the cycle timer, then the CPU turns to STOP, regardless of whether OB 80 exists. You can prevent the CPU from turning to STOP by restarting the CPU cycle monitoring with the "RE_TRIGR" instruction. The operating system monitors the execution time of the cyclic program for a configurable upper limit known as the "Maximum cycle time". You find the "Maximum cycle time" in the properties of your S7-1200 PLC. Browse the "Project tree" for your S7-1200 PLC. Double-click the "Device configuration" item. Select your S7-1200 PLC in the "Devices & Networks" view. On the "Properties" tab, browse for the "Cycle time" entry.

www.bresimar.pt

43

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig. 01

2. "Called OB still being executed"


The called OB is currently being executed. This is possible for time-delay interrupt OBs and cyclic interrupt OBs.

3. "Queue overflow"
An overflow has occurred in an interrupt OB queue. There is a queue for each interrupt priority group. If an interrupt event occurs when the corresponding queue is full, a time error event is generated.

4. "Interrupt loss due to excessive interrupt load"


An interrupt was lost due to the excessive interrupt load. Table 01

The "RE_TRIGR" instruction

The "RE_TRIGR" instruction (Re-trigger cycle time monitoring) allows you to reset the timer that measures the cycle time. However, this instruction must be executed in a program cycle OB. The "RE_TRIGR" instruction is www.bresimar.pt

44

SIEMENS S7-1200

NOTAS DE APLICAO N 01

ignored if executed in other blocks (for example OB 80). If the maximum scan cycle time is exceeded twice within the same program cycle with no "RE_TRIGR" instruction executed, the CPU will switch to STOP immediately. To insert a "RE_TRIGR" instruction: Browse the instructions pane for "Extended instructions" > "Program control" > "RE_TRIGR". Drag and Drop this instruction into a network of a program cycle OB.

Fig. 02

Note
Use the "RE_TRIGR" instruction with care. Repeated executions of the "RE_TRIGR" instruction can create an endless loop or a very long scan. As a result of this endless loop, the cyclic program will never end, and the output process image will never be written. Therefore you will never receive a save state at the outputs.

Evaluating the time error event with the "Time error interrupt" OB
The operating system calls the "Time error interrupt" OB 80, if one of the previously mentioned events occurs.

No. Evaluate the time error event with the "Time error interrupt" OB 1. Add the "Time error interrupt" OB
Browse the "Project tree" for the "Add new block" item. In the "Add new block" window, click the "Organization block" button. Select the "Time error interrupt" OB from the list. Click the "OK" button.

Note
You can use only one "Time error interrupt" OB in your program.

www.bresimar.pt

45

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig. 03

2. Monitoring the start information of the "Time error interrupt" OB


Double-click the "Time error interrupt" OB of your S7-1200 PLC in the "Project tree". Browse the instructions pane for "Instructions" > "Move" >"Move". Drag and Drop a move instruction into a network of your "Time error interrupt" OB. Move the value of the "fault_id" tag into a global tag (for example ""Data_block".by_fault_ID"). Program the other tags you want to monitor in the same way. Please refer to the example in Fig. 04.

Fig. 04 www.bresimar.pt

46

SIEMENS S7-1200

NOTAS DE APLICAO N 01

3. Evaluating the start information of the "Time error interrupt" OB


The "Time error interrupt" OB has the following start information:

"fault_id" (BYTE)
The "fault_id" identifies the type of error. 0x01: Maximum cycle time exceeded 0x02: Called OB still being executed 0x07: Queue overflow 0x09: Interrupt loss due to excessive interrupt load

"csg_OBnr "(OB-ANY)
Number of the OB being executed at the time of the error.

"csg_prio" (UINT)
Priority of the OB being executed at the time of the error. Table 02

Requirements
S7-1200 PLC Ethernet cable PG / PC STEP 7 Basic V10.5

www.bresimar.pt

47

SIEMENS S7-1200

NOTAS DE APLICAO N 01

(folha em branco)

www.bresimar.pt

48

SIEMENS S7-1200

NOTAS DE APLICAO N 01

FAQ - How is numerical integration programmed in STEP 7 Basic V10.5 ? Instructions


The integral is the mathematical calculation of the area under a given function curve. However, there is often no mathematical correlation in practice, but rather an analog value which varies over time. The integral calculation involes totaling the trapezoidal areas, spread between the last two function values and the time. This trapezoidal area is identical to the product of the average of the two process values and the time interval.

Fig. 01 Figure 01 illustrates the calculation of the integral of a trapezoidal area: Calculation: 0.5*(F(t1)+F(t0))*(t1-t0) + 0.5*(F(t2)+F(t1))*(t2-t1) + ...

Fig. 02 www.bresimar.pt

49

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Parameter
EN IN Enable Reset SMB ENO OUT Error

Data type
BOOL REAL BOOL BOOL BYTE BOOL REAL BOOL

Memory area
I, Q, M, D, L M, D, L I, Q, M, D, L I, Q, M, D, L M Q, M, D, L M, D, L Q, M, D, L

Description
Block enable input (must always be on) Value to be integrated Enable input (calculation occurs only if it is TRUE; if it is FALSE, parameter OUT displays the last calculated value) Reset input (if it is TRUE, parameter OUT will be reset) Location of the system memory byte (must be connected!) Enable output Integrated value (retentive) Error output (it is steady TRUE, if the system memory byte is disabled or not connected and it is TRUE for one cycle, if a power up occurs while the integration is enabled = sign for a power break down while integration)

Downloads
The downloads below contain the library and a sample program for calculating integrals. Copy the ZIP files into a separate folder, and unpack the files with the WinZip program.

Sample program: Integral calculation with STEP 7 Basic


The "Integral.zip" download contains the STEP 7 Basic program (FB602) program for calculating the integral. There is one example programmed in the STEP 7 Basic project.

Integral_sample.zip( 2350 KB ) In the example, an analog input value (IW64, "velocity_INT" variable) is converted to a floating-point value in Network 1 (MD10, "velocity_REAL" variable). This floating-point value is the input "IN" for the integrator FB602, which results in the output "OUT" (MD14, "distance"). The calculation of the integral is started with the "DB_2".Enable bit (which is selected als retentive) on FB602's "Enable" parameter. The "Error" output must be stored by a retentive counter or a RS-Flip-Flop (Network 3) to see, that a power failure occurred while integration. M5.0 resets the output value and the error flag M5.3 in Network 4.

Library "Integral"
The "Integral.zip" library contains the know-how protected, "Integration" function block (FB602). The password to disable the know-how protection is "1234".

Integral.zip( 434 KB )

www.bresimar.pt

50

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig. 03 To open libraries in STEP 7 Basic, follow these steps: 1. 2. 3. 4. Open the "Libraries" task card in STEP 7 Basic. Under "Global libraries" click on the "Open Global Libraries" button in the toolbar. Browse for the library in the "Open Global Libraries" dialog and select the "Integral.al10" file. Click the "Open" button.

The "Integral" library with the FB602 "Integration" appears in the "Global libraries".

Validity
This FAQ is valid for S7-1200 PLCs from firmware version V1.0.0. STEP 7 Basic from V10.5.

www.bresimar.pt

51

SIEMENS S7-1200

NOTAS DE APLICAO N 01

(folha em branco)

www.bresimar.pt

52

SIEMENS S7-1200

NOTAS DE APLICAO N 01

FAQ How can you access an S7-1200 PLC by PC Access and what is to be considered ? Description
You can establish a connection between PC Access and your S7-1200 PLC. Nevertheless, there are some restrictions to keep in mind.

Note
Although establishing a connection between an S7-1200 PLC and SIMATIC NET OPC is not officially supported by Siemens, this FAQ describes a solution. In the following chapters, you will find a description of how to establish such a connection.

Restrictions
There are certain restrictions to be considered due to the fact that PC Access was originally intended to access an S7-200 PLC: Only tags in the data block DB1 of your S7-1200 PLC can be accessed because the S7-200 only had one data block. DB1 in your S7-1200 PLC needs to be non-symbolic. Please uncheck the checkbox "Symbolic access only" when creating your DB1 (Figure 01).

Requirements
The following items are the hardware and software requirements: S7-1200 PLC Ethernet cable STEP 7 Basic V10.5 PC Access V1.0.4.10 (SP4)

Create tags in data block DB1 of your S7-1200 PLC project


To create tags in your S7-1200 PLC follow the instructions below.

No. Create tags in data block DB1 of your S7-1200 PLC project 1. Add the data block DB1 to your project Browse the "project tree" and click on the item "Add new block". Click the button "Data block (DB)". Uncheck the checkbox "Symbolic access only". Click the "OK" button.

www.bresimar.pt

53

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig.01

2. Allocate the tags in STEP 7 Basic


Double-click DB1. Add the following three tags under "name" and "Data type" and give them an "initial value". Item_01: "Byte" Item_02: "Int" Item_03: "DWord"

Fig.02 Click the item "Save project" in the tool bar. Download the project by clicking the download button in the tool bar. www.bresimar.pt

54

SIEMENS S7-1200

NOTAS DE APLICAO N 01

3. Monitor the tags in STEP 7 Basic


To cross-check the tag values, use the watch table function of STEP 7 Basic. Browse the "Project tree" for the item "Add new watch table" and fill in the "Name" and "Address" of the required tags. In this example, add the following three tags: Item_01: "DB1.DBB0" Item_02: "DB1.DBW2" Item_03: "DB1.DBD4"

Fig.03

Table 01

Create a new PC Access project and access tags


Follow these instructions to establish a connection between PC Access and your S7-1200 PLC to access data of your PLC.

No. Create a new PC Access project and access tags 1. Create a new project
Browse the menu bar, and select "File > New". A new project will be created.

www.bresimar.pt

55

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig.04

2. Add a new PLC


Highlight the entry "MicroWin(TCP/IP)" in the "project tree". Browse the menu bar, and select "Edit > New > PLC". A "NewPLC" object will be added, and the "PLC properties" dialog window of the new PLC opens. Enter the following parameters into the input fields of this window: Name: "S7-1200_PLC" IP Address: "192.168.0.11" (IP adress of your S7-1200 PLC) TSAP Local: "10.00." (TSAP of your S7-1200 PLC) TSAP Remote: "03.01." (TSAP of PC Access)

Click the "OK" button.

Fig.05 www.bresimar.pt

56

SIEMENS S7-1200

NOTAS DE APLICAO N 01

3. Add a new item Highlight your S7-1200 PLC in the "project tree". Browse the menu bar, and select "Edit > New > Item". The dialog window "Item properties" opens. To access data in your S7-1200 PLC, perform the following steps:

Enter an item name in the "Name:" input field. Enter the address of the tag in the "Address:" input field. Select the type of data in the "Data Type:" input field.

Additionally, you can restrict the memory address access to "read" only or "write" only. Click the "OK" button.

Fig.06

Note
Please find a list of the accessible items at the end of this document in the table "accessible tags and items".

www.bresimar.pt

57

SIEMENS S7-1200

NOTAS DE APLICAO N 01

4. Save the project


Browse the menu bar, and select "File > Save" to save your project.

Fig,07

Note
Anytime you open or edit a PC Access project, you must click the "Save" button to send tag configurations to the server.

Fig.08

www.bresimar.pt

58

SIEMENS S7-1200

NOTAS DE APLICAO N 01

5. Monitor items via the Test Client


Highlight the items you want to monitor and and click the "Add current items to test client" button in the tool bar. The selected items will be added to the Test Client.

Fig.09

6. Start the Test Client


Click the "Start Test Client" button in the tool bar. The Test Client will go online and access the designated data. In the "Value" column, you can see the actual values of the listed items. If you are connected to your S71200 PLC, the "Quality" of the item is listed as "Good".

Fig.10

www.bresimar.pt

59

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Table 02

Accessible items
The following table shows all accessible items, including address examples.

Item
tags markers inputs outputs

Address example
"VB0", "VX1.0", "VW2", "VD4" etc. "MB8", "MX9.2", "MW10", "MD12" etc. "I0.0", "AI0" etc. "Q1.3", "AQ0" etc.

Table 03

Required version of PC Access


The required version of PC Access is V1.0.4.10 (SP4) or higher. Please download PC access V1.0.4.10 (SP4) .

www.bresimar.pt

60

SIEMENS S7-1200

NOTAS DE APLICAO N 01

FAQ How can you establish a connection between an S7-1200 PLC and SIMATIC NET OPC ?
Description Please find a detailed description on how to realize a connection between an S7-1200 PLC and SIMATIC NET OPC V8.0 in the attached pdf-document. Click the link "S7-1200_OPC_SIMATIC_NET_e.pdf" and save the document to your computer.

S7-1200_OPC_SIMATIC_NET_e.pdf ( 822 KB ) Keywords client, scout

www.bresimar.pt

61

SIEMENS S7-1200

NOTAS DE APLICAO N 01

(folha em branco)

www.bresimar.pt

62

SIEMENS S7-1200

NOTAS DE APLICAO N 01

FAQ How can you erase the IP address and set your S7-1200 PLC back to factory settings , using the SIMATIC MC memory card (2MB or 24MB) ? Description
You can erase the IP address and set your S7-1200 PLC back to factory settings without using the STEP 7 Basic software and without knowing the exact IP address. To do so use any SIMATIC MC memory card.

Disabling the write protection


Check that the memory card is not write-protected. Slide the protection switch away from the "Lock" position.

Figure 01

Figure 02

Obtaining a blank SIMATIC MC memory card


There are two ways to obtain a blank SIMATIC MC memory card: Use a new, blank SIMATIC MC memory card from SIEMENS. If you habe a SIMATIC MC memory card that is not blank, delete the "SIMATIC.S7S" folder and the "S7_JOB.S7S" file on the memory card, using an application such as Windows Explorer.

Deleting the IP address


In order to erase the IP address and set your S7-1200 PLC back to factory settings, you must 1. 2. insert a blank memory card into the S7-1200 PLC. power cycle the S7-1200 PLC.

Now the S7-1200 PLC reboots. After rebooting and evaluating the SIMATIC MC memory card, the internal load memory, this means the device configuration including the IP address, the user program and any force values, is copied to the memory card. The memory card turns into a program card, containing the data and IP address stored in the internal load memory before. After the copy has been completed, the internal load memory of the S7-1200 PLC is erased. The S7-1200 PLC then goes to the configured startup mode (RUN or STOP). When the operation is complete, the S7-1200 PLC flashes the maintenance LED to indicate that the memory card can be removed. 3. 4. Remove the memory card from the S7-1200 PLC. Power cycle the S7-1200 PLC.

The internal load memory including the IP address is erased and the S7-1200 PLC is set back to factory settings.

www.bresimar.pt

63

SIEMENS S7-1200

NOTAS DE APLICAO N 01

(folha em branco)

www.bresimar.pt

64

SIEMENS S7-1200

NOTAS DE APLICAO N 01

FAQ How can you change the IP address of an S7-1200 PLC without STEP 7 Basic ? Description
You can change the IP address of an S7-1200 PLC using the IP TOOL, which you can find attached to this entry. This tool is useful when you load a master project to multiple S7-1200 PLCs, connected to the same network.

Requirements
Operating sytem: Windows XP or Vista S7-1200 PLC Ethernet cable PC / PG with Ethernet interface IP TOOL V1.1.0.1

Use cases of the IP TOOL


The IP TOOL can change the IP address of an S7-1200 PLC in one of two ways. The proper method is automatically determined by the state of that IP address: 1. Assigning an initial IP address: If the S7-1200 PLC has no IP address, the IP TOOL uses the primary setup function to allocate an initial IP address to the S7-1200 PLC. Changing the IP address: If an IP address already exists, the IP TOOL will modify the hardware configuration (HW config) of your S7-1200 PLC.

2.

Restrictions
After an IP address is assigned by the IP TOOL, you cannot change it again with the IP TOOL, until after you have downloaded the hardware configuration to your S7-1200 PLC using STEP 7 Basic. You cannot communicate with a PLC to which no IP address has been assigned. An IP address cannot be used more than once in a network; each PLC must have a unique IP address.

Note In the IP TOOLs "Update accessible devices" list, PLCs with duplicate IP addresses are shown in red.Assigning an initial IP address to your S7-1200 PLC

No. 1.

Update accessible devices


Double-click the item "Update accessible devices" to show all accessible devices.

www.bresimar.pt

65

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig.01 2. Select an S7-1200 PLC Double-click the S7-1200 PLC without an IP address. On the right side of the dialog, the available data of the S7-1200 PLC is displayed. Identify your S7-1200 PLC on site by clicking the "Flash LED Lights" button.

Fig.02 3. Assign a new IP address Enter the initial IP address in the "IP address:" input field. Write the subnet mask in the "Subnet Mask:" input field. Click the "Set" button.

On the left side of the dialog, the designated IP address is listed.

www.bresimar.pt

66

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig.03 Table 01 Changing the IP address of an S7-1200 PLC

No. 1. Update accessible devices Double-click the item "Update accessible devices" to show all accessible devices.

Fig.04

www.bresimar.pt

67

SIEMENS S7-1200

NOTAS DE APLICAO N 01

2.

Select an S7-1200 PLC Double-click the S7-1200 PLC whose IP address you want to change. On the right side of hte dialog, the available data of the S7-1200 PLC is displayed. Identify your S7-1200 PLC on site by clicking the "Flash LED Lights" button.

Fig.05 3. Assign a new IP address Enter the new IP address in the "IP address:" input field.. Write the subnet mask in the "Subnet Mask:" input field. Click the "Set" button.

On the left side of the dialog, the designated IP address is listed.

Fig.06 Table 02 www.bresimar.pt

68

SIEMENS S7-1200

NOTAS DE APLICAO N 01

IPToolInstall.zip ( 56907 KB )

www.bresimar.pt

69

SIEMENS S7-1200

NOTAS DE APLICAO N 01

(folha em branco)

www.bresimar.pt

70

SIEMENS S7-1200

NOTAS DE APLICAO N 01

FAQ How can you download to a network of several S7-1200 PLCs with the same IP address ? Description
When you first download a PLC program of a STEP 7 Basic project to a network which contains several S7-1200 PLCs, a situation may occur in which more than one PLC shares the same IP address. This means you will miss one or more PLCs. In this case, delete the IP addresses of all PLCs to be able to access them by their MAC addresses.

Figure 01

Deleting the IP address


Delete the IP address of an S7-1200 PLC using a SIMATIC MC memory card.

Identifying PLCs by their MAC address


To address a PLC by its MAC address, enable the checkbox "Show all accessible devices" in the "Extended download to device" dialog box and select a MAC address from the list.

Downloading to the PLC


Select a MAC address from the list of accessible devices and click the "Load" button.

www.bresimar.pt

71

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Figure 02

Note
A new, unconfigured PLC has no preset IP address.

www.bresimar.pt

72

SIEMENS S7-1200

NOTAS DE APLICAO N 01

FAQ How you reset the IP address of your S7-1200PLC using STEP 7 Basic software ? Description
You can reset the IP address of your S7-1200 PLC using the function "Reset to factory settings" of the STEP 7 Basic software. Therefore you need online access to your S7-1200 PLC. This means the IP address of your S7-1200 PLC needs to be the same as the IP address in your STEP 7 Basic project. Otherwise you cannot go online.

Adjustingthe IP address
1. To figure out the IP address of your S7-1200 PLC, highlight your S7-1200 PLC in the project tree. Browse the menu bar for "Online > Extended download to device..." and check the "Show all accessible devices" check box. The IP address of your S7-1200 PLC is listed in the "address" column.

Figure 01 2. Change the IP address of the S7-1200 PLC in your project. Browse the project tree for the "Device configuration" of your S7-1200 PLC and click the Ethernet port in the work area. Open the "Ethernet addresses" properties and enter the IP address which you figured out in step 1.

www.bresimar.pt

73

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Figure 02

Resetting the IP address


1. 2. 3. Launch STEP 7 Basic, and open the project containing the S7-1200 PLC whose IP address you want to reset. In the project tree, browse for the S7-1200 PLC and highlight it. Click the toolbar command "Go online". The title bar changes to orange. You have online access to the S71200 PLC now.

www.bresimar.pt

74

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Figure 03 4. 5. 6. Double-click item "Online & Diagnostics" in the PLC folder in the project tree. The "Online access" dialog window of your PLC opens. In the Navigation area, browse for "Functions > Reset to factory settings". Select the radio button "Reset IP address" in the work area, and click the "Reset" button.

Figure 04 7. A "Reset to factory settings" dialog box opens. Click the "OK" button.

The IP address is erased.

Note
Make sure that no SIMATIC MC memory card is inserted in your S7-1200 PLC while deleting the IP address.

www.bresimar.pt

75

SIEMENS S7-1200

NOTAS DE APLICAO N 01

(folha em branco)

www.bresimar.pt

76

SIEMENS S7-1200

NOTAS DE APLICAO N 01

FAQ How can you manage peripheral device errors detected by S7-1200 PLC ? Description
The S7-1200 PLC can detect and report peripheral device errors for diagnostics-capable devices. These errors are called diagnostic errors. The following diagnostic errors are supported: No user power (on the signal module / board) High limit exceeded (of the value on an analog input or output) Low limit exceeded (of the value on an analog input or output) Wire break (on an analog Current output) Short circuit (on an analog Voltage output)

All diagnostic error events trigger the execution of the "Diagnostic error interrupt" organization block (OB82). The "Diagnostic error interrupt" OB82 includes startup information that helps you determine the circumstances of the error occurrence: Which device and channel reported the error. Whether the event is due to the occurrence or removal of an error.

You can program instructions inside OB82 to examine these startup values and to take appropriate action.

Evaluating the diagnostic error events with the "Diagnostic error interrupt" organization block (OB82)
The occurrence or removal of any of several different diagnostic error conditions results in a diagnostic error event if the following preconditions are met: The OB82 has been added to the program of your S7-1200 PLC. The diagnostic error event has been enabled for the module.

If OB82 does not exist, then the CPU ignores the error. The "Diagnostic error interrupt" OB82 interrupts the normal cyclic program execution if a diagnostics-capable module recognizes an error.

Note
No "Diagnostic error interrupt" OB82 is present when you create a new project.

No. Evaluating the diagnostic error events with the "Diagnostic error interrupt" organization block OB82 1 Add the "Diagnostic error interrupt" OB82
Browse the project tree for the "Add new block" item. In the "Add new block" window, click the "Organization block" button. Select the "Diagnostic error interrupt" OB82 from the list. Click the "OK" button.

www.bresimar.pt

77

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Note
You can have only one "Diagnostic error interrupt" OB in your program.

Fig. 01

Reading out the start information of the "Diagnostic error interrupt" OB82
Double-click the "Diagnostic error interrupt" OB82 of your S7-1200 PLC in the "Project tree". Browse the instructions pane for "Instructions > Move > MOVE". Drag and Drop a "MOVE" instruction into a network of your "Diagnostic error interrupt" OB82. Move the value of the "IOstate" tag into a global tag (for example "`DB1`.w_IOstate"). Program the other tags you want to monitor in the same way. Please find an example in the figure below.

www.bresimar.pt

78

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig. 02

Evaluating the start information of the "Diagnostic error interrupt" OB82


The "Diagnostic error interrupt" OB82 has the following start information: "IOstate" (WORD) The "IOstate" contains the I/O status of the diagnostics-capable module. Please find details on the "IOstate" tag in Table no. 3. "ladder" (HW-ANY) This is the hardware-identifier. The Hardware identifier (HW-ID) identifies modules or functional units of modules (for example outputs and high speed counter). The hardware identifier consists of a whole number and is reported by the system along with diagnostics alarms to allow the faulty module or functional unit to be localized. You find the HW-ID of a functional unit in the "Properties" tab of the "Device configuration". Browse the navigation area for the item "IO addresses/HW identifier" (see figure below). "Channel" (UINT) The "Channel" contains the number of the output channel being used on the signal module / board. "multierror" (BOOL) The "multierror" bit indicates that more than one error has occurred.

www.bresimar.pt

79

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig. 03 Table 01

Enabling and understanding the different diagnostic error events


The operating system monitors the diagnostics-capable devices for the diagnostic errors mentioned above. Diagnostic error events will be indicated by red blinking LEDs. The following table shows additional information on the different diagnostic error events, how to enable them, and the indicating LEDs.

No. Understanding the different diagnostic error events 1 "No user power"
The power supply is insufficient or missing. The following S7-1200 PLC LEDs will blink (color of blinking LEDs: red): The "ERROR" LED on the CPU. All LEDs of the signal module / board.

"Enable power diagnostics" Browse the "Project tree" for the "Device configuration" of your S7-1200 PLC. Click your signal module in the "Device configuration" window. Select the "Properties" tab and click the "AI4/AO2" item from the navigation area. Click the "Enable power diagnostics" checkbox.

www.bresimar.pt

80

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig 04

"High limit exceeded"


The high limit of an analog input / output has been exceeded (output value greater than "+32511"). The following S7-1200 PLC LEDs will blink (color of blinking LEDs: red): The "ERROR" LED on the CPU. The "DIAG" LED, if it is a signal module. The LED of the associated channel.

"Enable overflow diagnostics"


Browse the "Project tree" for the "Device configuration" of your S7-1200 PLC. Click your signal module in the "Device configuration" window. Select the "Properties" tab and click the "AI4/AO2" item from the navigation area. Scroll down to the channel you want to monitor. Click the "Enable overflow diagnostics" checkbox.

www.bresimar.pt

81

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig 05

"Low limit exceeded"


The low limit of an analog input /output has been exceeded (output value less than "0" for Current, less than "-32512" for Voltage). The following S7-1200 PLC LEDs will blink (color of blinking LEDs: red): The "ERROR" LED on the CPU. The "DIAG" LED, if it is a signal module. The LED of the associated channel.

"Enable underflow diagnostics"


Browse the "Project tree" for the "Device configuration" of your S7-1200 PLC. Click your signal module in the "Device configuration" window. Select the "Properties" tab and click the "AI4/AO2" item from the navigation area. Scroll down to the channel you want to monitor. Click the "Enable underflow diagnostics" checkbox.

Please see figure above for details.

"Wire break"
The power circuit of an analog Current output is not closed.

www.bresimar.pt

82

SIEMENS S7-1200

NOTAS DE APLICAO N 01

The following S7-1200 PLC LEDs will blink (color of blinking LEDs: red): The "ERROR" LED on the CPU. The "DIAG" LED, if it is a signal module. The LED of the associated channel.

"Enable wire break diagnostics"


Browse the "Project tree" for the "Device configuration" of your S7-1200 PLC. Click your signal module in the "Device configuration" window. Select the "Properties" tab and click the "AI4/AO2" item from the navigation area. Scroll down to the channel you want to monitor. Choose the "Current" analog output type. Click the "Enable wire break diagnostics" checkbox.

Fig 06

"Short circuit"
The contacts of an analog Voltage output are short-circuited. The following S7-1200 PLC LEDs will blink (color of blinking LEDs: red): The "ERROR" LED on the CPU. The "DIAG" LED, if it is a signal module.

www.bresimar.pt

83

SIEMENS S7-1200

NOTAS DE APLICAO N 01

The LED of the associated channel.

"Enable short circuit diagnostics" Browse the "Project tree" for the "Device configuration" of your S7-1200 PLC. Click your signal module in the "Device configuration" window. Select the "Properties" tab and click the "AI4/AO2" item from the navigation area. Scroll down to the channel you want to monitor. Choose the "Voltage" analog output type. Click the "Enable short circuit diagnostics" checkbox.

Fig 07 Table 02

Online diagnostics with STEP 7 Basic


When you have online access to your S7-1200 PLC with STEP 7 Basic, you can use the "Online & diagnostics" function:

www.bresimar.pt

84

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Go online to your S7-1200 PLC. Browse the "Project tree" for the entry "Online & diagnostics". Browse the navigation area of the "Online Access" window for the entry "Diagnostics buffer". Select a diagnostic error event from the "Events" table. Beneath the "Events" table, details on the selected event are displayed. Here, you will find the HW-ID, the channel number, and the event type.

Note
An "Incoming event" shows the beginning of an event. An "Outgoing event" shows the end of an event.

Fig. 08

"IOstate" tag
The following table shows the possible I/O states of the "IOstate" tag.

IO_state Description
Bit 0 Configuration correct: Bit 4 Error: 1, if an error is present (for example a wire break) 0, if the error is no longer present 1, if the configuration is correct 0, if the configuration is no longer correct

www.bresimar.pt

85

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Bit 5

Configuration not correct: 1, if the configuration is not correct 0, if the configuration is once again correct

Bit 6

I/O cannot be accessed: 1, if an I/O access error has occurred. In this case, the "ladder" tag contains the hardware identifier of the I/O with the access error. 0, if the I/O can be accessed once again

Table 03

Requirements
S7-1200 PLC Ethernet cable PG / PC STEP 7 Basic V10.5 Diagnostics-capable signal module / board

www.bresimar.pt

86

SIEMENS S7-1200

NOTAS DE APLICAO N 01

FAQ How can you use an analog current output with wire break diagnostics on your S7-1200 PLC ? Description
You can detect a wire break event at an analog current output with the wire break function of STEP 7 Basic. You evaluate a wire break event using the "Diagnostic error interrupt" organization block (OB82). In this description, the signal module SM1234 is used. You can use other signal modules or signal boards with an analog current output instead.

Adding a signal module with an analog current output to the S7-1200 PLC and enabling the wire break diagnostics
No. Adding a signal module with an analog current output to the S7-1200 PLC and

enabling the wire break diagnostics


1. Add the signal module to the S7-1200 PLC
You will find a description on how to install a signal module or a signal board in Chapter 2, "Installation", in the S7-1200 System Manual.

Fig. 01

Note
Please find the S7-1200 System Manual .

2. Add the signal module to the device configuration


Browse the hardware catalog for the signal module. Drag and drop it into the S7-1200 rack in the device configuration.

Fig. 02

www.bresimar.pt

87

SIEMENS S7-1200

NOTAS DE APLICAO N 01

3. Configure the analog output channel and enable the wire break diagnostics
Open the "Device configuration" in the "Project tree". In the "Device view", select the analog signal module. Browse the "Properties" of the analog signal module for "Analog outputs" > "Channel 0". Select "Current" as the analog output type. Click the "Enable wire break diagnostics" checkbox.

Fig.03

Note
The range of the substitute values is [0...32511]. For a current output of 20mA, the equivalent substitute value is 27648.

Table 01

Evaluating the wire break event using the "Diagnostic error interrupt" OB
The "Diagnostic error interrupt" OB is called when a module detects an error. The "Diagnostic error interrupt" OB will interrupt the cyclic program execution if a diagnostics-capable module, for which the diagnostic error interrupt has been enabled, detects an error. The signal module will blink the "DIAG" light and the light of the concerned channel.

www.bresimar.pt

88

SIEMENS S7-1200

NOTAS DE APLICAO N 01

No. Evaluating the wire break event using the "Diagnostic error interrupt" OB 1. Add "Diagnostic error interrupt" organization block OB82
Browse the project tree for the item "Add new block". In the "Add new block" window, click the "Organization block (OB)" button. Select the "Diagnostic error interrupt" OB. Click the "OK" button.

Note
You can use only one diagnostic error interrupt OB in your program.

Fig. 04

2. Read-out the start information of the "Diagnostics error interrupt" OB


Browse the instructions pane for "Instructions" > "Move". Drag and Drop a move instruction into a network of your "Diagnostic error interrupt" OB. Move the value of the tag "IOstate" into a global tag (for example "DB1:w_IOstate"). Program the other tags you want to monitor in the same way. Please find an example in Fig. 05.

www.bresimar.pt

89

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig. 05

3. Evaluate the start information of the "Diagnostics error interrupt" OB


The "Diagnostic error interrupt" OB has the following start information:

"IOstate" (WORD)
The "IOstate" contains the I/O status of the diagnostics-capable module. Please find details on the "IOstate" tag in Table no. 3.

"laddr"(HW-ANY)
This is the hardware-identifier. The Hardware identifier (HW-ID) identifies modules or functional units of modules (for example outputs and high speed counter). The hardware identifier consists of a whole number and is reported by the system along with diagnostics alarms to allow the faulty module or functional unit to be localized (see Fig. 07 for details). To identify the functional unit belonging to the HW-ID, browse the "Project tree" for the "PLC tags" item. Select the "Constants" tab from the "PLC tags" window. The "Value" column holds a list of the used HW-IDs (Fig. 06).

"Channel" (UINT)
The "Channel" contains the number of the output channel being used on the signal module.

"multierror" (BOOL)
The "multierror" bit indicates that more than one error has occurred.

www.bresimar.pt

90

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig. 06 Table 02

Online diagnostics with STEP 7 Basic


When you have online access to your S7-1200 PLC with STEP 7 Basic, you can use the diagnostics function. Go online to your S7-1200 PLC. The wrench symbol beside your PLC indicates a diagnostic error (Fig. 07, blue circle). Browse the "Project tree" for the entry "Online & diagnostics". Browse the navigation area of the "Online Access" window for the entry "Diagnostics buffer". Select the wire break event from the "Events" table.

Beneath the "Events" table, details on the selected event are displayed. Here, you will find the HW-ID, the channel number, and the type event.

Note
An "incoming event" shows the beginning of an event, in this case a wire break. An "Outgoing event" shows the end of an event. The signal module will blink the "DIAG" light and the light of the concerned channel.

Fig. 07 www.bresimar.pt

91

SIEMENS S7-1200

NOTAS DE APLICAO N 01

"IOstate" tag
The following table shows the possible I/O states of the "IOstate" tag.

IO_state Description
Configuration correct:

Bit 0

Error:

1, if the configuration is correct 0, if the configuration is no longer correct

Bit 4

1, if an error is present (for example a wire break) 0, if the error is no longer present

Configuration not correct:

Bit 5

1, if the configuration is not correct 0, if the configuration is once again correct

I/O cannot be accessed:

Bit 6

1, if an I/O access error has occurred. In this case, the "laddr" tag contains the hardware identifier of the I/O with the access error. 0, if the I/O can be accessed once again

Table 03

Requirements
S7-1200 PLC Ethernet cable PG / PC STEP 7 Basic V10.5 Signal module / board with analog current output

www.bresimar.pt

92

SIEMENS S7-1200

NOTAS DE APLICAO N 01

FAQ How can you use analog 0-20mA signal modules and signal boards with 4-20mA signals ? Description
You can use analog 4-20 mA input and output signals with the analog 0-20 mA signal modules and signal boards. You can scale the signal range of the analog inputs and outputs using the "Scale_current_input" and "Scale_current_output" predefined functions (FCs), which you can find attached to this FAQ.

Adding the "Scale_current" Global library


1. 2. 3. Download the attached library, and unzip it. Open the "Libraries" task card. Click the "Open global library" button. The "Open global library" dialog window opens. Browse for the "Scale_current" library folder, and open the "Scale_current.al10" file. Now, the library is displayed in the "Global libraries" pane in the "Libraries" task card.

Fig. 01

Scaling of the analog input


The range of 0-20 mA without the "Scale_current_input" instruction corresponds to the PLCs internal signal range of 0-27648. The "Scale_current_input" instruction adapts this internal range to 4-20 mA linearly, starting with "0" for 4 mA and ending up with "27648" for 20 mA. A limit for wire break monitoring can be chosen by hand.

www.bresimar.pt

93

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig. 02

No. Scaling of the analog input 1. Insert the "Scale_Current_input" instruction into a network
Browse the Global libraries tree for the "Scale_current_input" FC. Drag and drop this FC into a network of your S7-1200 PLC program.

Fig. 03

2. Scaling the analog input signal


Connect the contact "w_input_0-20mA" (2) to your analog hardware input (for example, IW96). You receive the scaled value at the contact "r_input_4-20mA" (4).

Note
For any input value lower than 4 mA the signal at "r_input_4-20mA" (4) will be set to "0". Accordingly, any input values higher than 20 mA will not exceed the maximum of "27648".

www.bresimar.pt

94

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig. 04

3. Wire break monitoring


At the contact "r_wire_break_limit" (1), enter the limit for the wire break monitoring. The value "2764.8" for example will set the wire break limit to 2 mA. This means, if your input current is lower than 2 mA, the contact "b_wire_break" (3) will be set to "1".

Table 01

Scaling of the analog output


The range of 0-20 mA without the "Scale_current_input" instruction corresponds to the PLC1 internal signal range of 0-27648. The Scale_current_output" instruction adapts this internal range to 4-20 mA linearly, starting with 4 mA for "0" and ending up with 20 mA for "27648".

Fig. 05 www.bresimar.pt

95

SIEMENS S7-1200

NOTAS DE APLICAO N 01

No. Scaling of the analog output 1. Insert the "Scale_current_output" instruction into a network
Browse the Global libraries tree for the "Scale_current_output" FC. Drag and drop this FC into a network of your S7-1200 PLC program.

Fig. 06

2. Scaling the analog input signal


Connect the contact "r_output_4-20mA" (1) to your software value. You receive the scaled value at the contact "w_output_0-20mA" (2) to send it to your analog hardware output (for example, QW96).

Note
For any input value lower than "0", the signal at "w_output_0-20mA" will be set to 4mA. Accordingly, any input values higher than "27648"will not exceed the maximum of 20mA.

Fig. 07 Table 02 www.bresimar.pt

96

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Requirements
S7-1200 PLC Ethernet cable signal board / signal module for analog output / input STEP 7 Basic V10.5

S7-1200_Scale_current.zip ( 348 KB )

www.bresimar.pt

97

SIEMENS S7-1200

NOTAS DE APLICAO N 01

(folha em branco)

www.bresimar.pt

98

SIEMENS S7-1200

NOTAS DE APLICAO N 01

FAQ - How do you synchronize the time of the HMI Basic Panel with an S7-1200 PLC ? Description
Synchronize the system time of your HMI Basic Panel with the system time of your S7-1200 PLC by configuring tags and blocks and incorporating the configuration in your HMI Basic Panel.

Synchronize the time


Detailed instructions for synchronizing the time are available in PDF format in the section "Instructions for Synchronizing Time" in the file "S7-1200_HMI_time_sync_HowTo.pdf". The sample project created in the instructions for STEP 7 Basic V10.5 can be downloaded in the section "Download" in the file "S7-1200_HMI_time_sync_example.zip".

Instructions for synchronizing the time


Contents: 1. 2. 3. Configuring the S7-1200 PLC Configuring the HMI Basic Panel Using the time functions

Double-click the link "S7-1200_HMI_time_sync.pdf" to open the instructions. You need the Acrobat Reader program for this.

S7-1200_HMI_time_sync_HowTo_e.pdf ( 748 KB )

Download
Right-click the link. In the pop-up menu that opens, select the item "Save target as..." and save the file on your computer. Unpack the file with WinZip program.

S7-1200_HMI_time_sync_example.zip( 1816 KB )

Validity
This FAQ is valid for S7-1200 PLCs from firmware version V1.0.0. STEP 7 Basic from V10.5.

Keywords
CPU, Alignment

www.bresimar.pt

99

SIEMENS S7-1200

NOTAS DE APLICAO N 01

(folha em branco)

www.bresimar.pt

100

SIEMENS S7-1200

NOTAS DE APLICAO N 01

FAQ How do you access S7-1200 tags with a panel or RT configured with WinCC flexible 2008 SP2 ? Core statement
With WinCC flexible 2008 Service Pack 2 all panels with an Ethernet interface that can be configured with WinCC flexible 2008 and the WinCC flexible 2008 Runtime can access S7-1200 data blocks using absolute addresses (no symbolic DBs) via the "SIMATIC S7 300/400" driver.

Compatibility
The following items are supported: Data type: Bool, Byte, Char, DInt, DWord, Int, Real, Time, Word, String, Array New S7-1200 data type: o SInt can be connected in WinCC flexible 2008 SP2 as Char (range: -128 to 127) o USInt can be connected in WinCC flexible 2008 SP2 as Byte (range: 0 to 255) o UInt can be connected in WinCC flexible 2008 SP2 as Word (range: 0 to 65535) o UDInt can be connected in WinCC flexible 2008 SP2 as DWord (range: 0 to 4294967295) Structures (Struct, IEC_Counter, IEC_Timer, DTL, IEC_SCounter, IEC_DCounter, IEC_UCounter, IEC_USCounter, IEC_UDCounter, ErrorStruct) are not supported, but elements of structures can be connected in WinCC flexible 2008 SP2 separately. Read and write access to peripheral inputs and outputs Tag multiplexing Recipes Discrete alarms Analog alarms Screen number Project ID Data records Coordination Controller jobs

Procedure
The procedure for the communication with WinCC flexible 2008 Runtime is described below.

No. Remarks
1 Create a data block using an absolute address in STEP 7 Basic V10.5 via "Add new block" and "Global DB".

www.bresimar.pt

101

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig. 01 Remove the check mark for the option "Symbolic access only".

In the data block, you create the tags that WinCC flexible 2008 will access.

Fig. 02 www.bresimar.pt

102

SIEMENS S7-1200

NOTAS DE APLICAO N 01

In WinCC flexible 2008, you create a connection via "Communication > Connections".

Fig. 03 Select "SIMATIC S7 300/400" as the communication driver. Select "Ethernet" as the interface. Enter the IP address for the WinCC flexible Runtime and the S7-1200 station. Select "S7ONLINE" as the operator panel's access point. Specify "1" as the PLC's expansion slot.

Open the PG/PC interface under "Start > Control panel > Set PG/PC interface". In the PG/PC interface, you must set the access point "S7ONLINE" to "TCP/IP -> [Used network card]".

www.bresimar.pt

103

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig. 04

Create the S7-1200 tags using absolute addresses under "Communication > Tags" (compare with Fig. 02).

Fig. 05 Table 01

Notice
Service Pack 2 for WinCC flexible 2008 is available.

www.bresimar.pt

104

SIEMENS S7-1200

NOTAS DE APLICAO N 01

FAQ With which devices can the S7-1200 communicate via the PN connection ? Communication partners of S7-1200
The S7-1200 PLC communicates with the following devices via the PN connection: Other S7 CPUs (S7-200, S7-300, S7-400, S7-1200) STEP 7 Basic programming devices Basic panels Devices that use the TCP communication protocol or ISOonTCP

Maximum number of connections for the PROFINET port The PROFINET port on the CPU supports the following simultaneous communication connections: 3 connections for HMI to CPU communication 1 connection for programming device (PG) to CPU communication 8 connections for S7-1200 program communication using the T-block instructions (TSEND_C, TRCV_C, TCON, TDISCON, TSEND, TRCV) 3 connections for a passive S7-1200 CPU communicating with an active S7 CPU: o The active S7 CPU uses GET and PUT instructions (S7-300 and S7-400) or ETHx_XFER instructions (S7-200). o An active S7-1200 communication connection is only possible with the T-block instructions.

Figure 01

www.bresimar.pt

105

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Validity
This FAQ is valid from S7-1200 CPUs with firmware version V1.0.0. Software version STEP 7 Basic V10.5 without Service Pack.

PN connection of the S7-1200


(1) PN connection (Ethernet interface RJ-45) of the S7-1200 PLC:

Figure 02

Supported protocols
The S7-1200 PLC supports the following protocols via the PN connection:

Firmware version V1.0.0

Transmission Control Protocol (TCP) X

ISOonTCP (RFC 1006) X

PROFINET IO (PNIO) --

Table 01

Additional information
More information on this topic is available in chapter 7 in the system manual of the S7-1200 PLC.

www.bresimar.pt

106

SIEMENS S7-1200

NOTAS DE APLICAO N 01

FAQ How do you compensate for the string mismatch caused by the RCV_PTP and SEND_PTP blocks ? Description
When dealing with string tags, the PTP (point-to-point) communication blocks ignore the specific properties of maximum string length and actual string length (Fig.01). When writing data to a string tag, the RCV_PTP block will overwrite the string header data (Fig.02). When reading data from a string tag, the SEND_PTP block will read the string header information as part of the virtual string data and send them as well (Fig.03).

Structure of a string tag


A string tag in STEP 7 Basic consists of three parts: Maximum length of the string Actual length of the string Virtual string data

Fig. 01 From the point of view of PTP communication, a string tag consists of the virtual string data only.

Characteristics of the RCV_PTP block


The RCV_PTP block writes the received virtual string data to the prepared string tag in the S7-1200 PLC, without the necessary length data in the first two bytes. As a result, the processing of this data cannot be continued, due to the nonexistent string tag header.

Fig. 02 www.bresimar.pt

107

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Characteristics of the SEND_PTP block


The SEND_PTP block reads the requested string data including the string header data, which are sent as the first two bytes of the requested data string.

Fig. 03

Preconditions
The data block (DB), in which the string tag is created, needs to be "non-symbolic". Absolute addressing of the buffer is required.

Creating a string tag in a non-symbolic data block Browse the "Project tree" and double-click the item "Add new block" of your PLC. In the "Add new block" dialog window, click the "Data Block (DB)" button and uncheck the checkbox "symbolic access only". To match the absolute addresses used in this example, set the number of this data block manually to "2". Click the "OK" button.

www.bresimar.pt

108

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig. 04 Browse the "Project tree", and double-click the data-block "Data_block_2 (DB2)". In the "Static" column of the table, enter a tag with a "String[8]" data type.

Fig.05

Compensation of string mismatch using the RCV_PTP block


For compensation, the string length information has to be handled separately. In this example, a string tag with a length of eight bytes is used. www.bresimar.pt

109

SIEMENS S7-1200

NOTAS DE APLICAO N 01

No. Compensation of string mismatch using the RCV_PTP block 1. Write the virtual string data into the string tag To keep the string header data, the received virtual string data needs to be written in the string tag starting at the third byte. Absolute addressing of the buffer makes thsi possible. In this example, the string tag has a length of eight bytes. It begins at offset 10.0 (DB2.DBBX10.0), so the virtual string data begins at offset 12.0 (DB2.DBBX12.0). The address expression consists of the following items: Pointer "P#". Absolute address of the 1st bit of the 3rd byte, (for example DB2.DBX12.0). Number of bytes you want to write into the string tag, separated by a blank. This should be the maximum length of the string tag (for example BYTE 8).

Fig. 06 2.

Copy the maximum and actual string length into the string header

www.bresimar.pt

110

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig. 07

Note
Before you copy the "actual length" value, you need to convert its data type from UINT to BYTE. Table 01

Compensation of string mismatch using the SEND_PTP block


For compensation, the string length information has to be handled separately. In this example, a string tag with a length of eight bytes is used. No. Compensation of string mismatch using the SEND_PTP block 1. Replace the actual string length in the SEND_PTP block

Fig. 08

Note
Before you replace the "#length" value, you need to convert its data type from BYTE to UINT. 2.

Read the virtual string data from the string tag


To prevent the string header data from being sent, the SEND_PTP block needs to start reading at the 3rd byte of the string tag. Absolute addressing of the buffer makes this possible. In this example, the string tag has a length of eight bytes. It begins at offset 10.0 (DB2.DBBX10.0), so the virtual string data begins at offset 12.0 (DB2.DBBX12.0). The address expression is similar to the

www.bresimar.pt

111

SIEMENS S7-1200

NOTAS DE APLICAO N 01

expression used in table 01, Figure 06.

Fig. 09 Table 02

Requirements
S7-1200 PLC Ethernet cable PC / PG with Ethernet interface STEP 7 Basic V10.5

www.bresimar.pt

112

SIEMENS S7-1200

NOTAS DE APLICAO N 01

FAQ How can you reduce memory usage with Multi instancing ? Description
When you call counters or timers in STEP 7 Basic V10.5, the "Call options" dialog appears to assign the instance data block for this function.

Figure 01 If you call the counter or timer in a function block (FB), you can choose either a "Single Instance" DB or the "Multi Instance" DB of the FB. Otherwise, you can only choose a "Single Instance" DB. Thus, in this case, you generate a single instance DB for every counter or timer, which makes your project confusing and increases the load memory. To avoid this situation, you can create a global DB with multi instance properties as follows (example for counters):

No. Remarks

Add a new global DB in your project.

www.bresimar.pt

113

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Figure 02 Choose the property "Symbolic access only" property if you want to select several counters as retentive. 2 Open the new generated DB, and add a static tag using data type "IEC_Counter" (or, depending on the counter range, one of the other data types: "IEC_SCounter", "IEC_DCounter", "IEC_UCounter", "IEC_USCounter" or "IEC_UDCounter").

Figure 03

www.bresimar.pt

114

SIEMENS S7-1200

NOTAS DE APLICAO N 01

In the "Retain" column, you can select the counter as retentive: For DBs with disabled "Symbolic access only", you can select the whole DB as retentive. For DBs with enabled "Symbolic access only", you can select several items of the DB as retentive.

Cancel the "Call options" when calling your counter function.

Figure 04 www.bresimar.pt

115

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Double click on the three question marks ("<???>") above the counter block, click on the "eye" icon (which lists available parameters) and select the newly generated "Multi_instance_DB".

Figure 05 By inserting a dot (".") after the symbolic name of the DB, you can choose the required tag element. Choose the symbolic name of the added counter structure ("IEC_Counter_0"). 5 Repeat step 2 through 4 for every additional counter.

Note
Please find further information about, how the property "Symbolic access only" affects the design of data blocks . Please find further information about the SIMATIC S7-1200 in the System Manual or in the help files of STEP 7 Basic V10.5.

www.bresimar.pt

116

SIEMENS S7-1200

NOTAS DE APLICAO N 01

FAQ How many high-speed counters (HSCs) are provided by SIMATIC S7-1200 PLC ?

Description
With the SIMATIC S7-1200 PLC you can use up to 6 high-speed counters. Depending on the CPU, the signal board and the high-speed counting specification you can use some or all of them. The attached document provides detailed information about this, as well as an overview in the summary to find the solution for your high-speed counting task quickly. Double-click the link "S7-1200_HSCs.pdf" to open the instructions. You need the Acrobat Reader program for this.

S7-1200_HSCs_e.pdf ( 659 KB )

Note
Please find further information about the SIMATIC S7-1200 HSCs in the SIMATIC S7-1200 System Manual or in the help files of STEP 7 Basic V10.5. If you don't find your selected signal board in STEP 7 Basic V10.5 please update the Hardware Catalog with the STEP 7 Basic V10.5 Hardware Support Packages .

www.bresimar.pt

117

SIEMENS S7-1200

NOTAS DE APLICAO N 01

(folha em branco)

www.bresimar.pt

118

SIEMENS S7-1200

NOTAS DE APLICAO N 01

FAQ How do you connect a sensor to the analog signal modules of the SIMATIC S7-1200 ?

Description
A field sensor with the following attributes: Resolution: 12 bit + sign bit Range: +/-10V, +/-5V or +/-2.5V for voltage or Range: 0 to 20 mA for current

can be connected to the following S7-1200 analog signal modules: SM 1231 AI 4 x 13 Bit SM 1231 AI 8 x 13 Bit SM 1234 AI 4 x 13 Bit / AQ 2 x 14 Bit

The measurement type (voltage or current) is selectable in groups of 2 channels. Sample connections for various sensor types (power supply: 24V DC) to the analog signal module SM 1231 AI 4 x 13 Bit (channel 0) are shown in the figures below:

Figure 01: 4-wire sensor connection www.bresimar.pt

119

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Figure 02: 3-wire sensor connection

Figure 03: Current measurement via 2-wire sensor www.bresimar.pt

120

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Note
When using a 4mA to 20mA sensor, you must convert the measured value accordingly. Please find further information about the SIMATIC S7-1200 in the SIMATIC S7-1200 System Manual .

www.bresimar.pt

121

SIEMENS S7-1200

NOTAS DE APLICAO N 01

(folha em branco)

www.bresimar.pt

122

SIEMENS S7-1200

NOTAS DE APLICAO N 01

FAQ How can you back up parameters before loading a new control program ? Description
When you load a new control program into your S7-1200 with STEP 7 Basic V10.5, all the data is overwritten. Thus, when you change programs, the plant-specific or optimized parameters are lost. The current version does not permit uploading of the data block content to an offline project. Therefore, you must use STEP 7 Basic V10.5 to read out such parameters manually from the relevant data blocks and configure them as Start values in the new control program.

Backing up and configuring the parameters


No. Procedure:

Backing up the parameters from the control program used Make sure that you can access your S7-1200 online with STEP 7 Basic. Navigate to your monitoring table (watch table) in the project structure via "<Project_name>" -> "<CPU_designation>" -> "Watch tables". In the "Address" column you specify the appropriate absolute addresses of the parameters required or you specify the corresponding symbolic name in the "Name" column. Click on the button for monitoring the parameters. The current values are displayed in the "Monitor value" column. Save the values with a screenshot, for example.

Fig. 01

Note
To add a monitoring (watch) table, under "Watch tables" you double-click on the item "Add new Watch table".

www.bresimar.pt

123

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Configuring the parameters in the new control program Open the new control program for your S7-1200. Navigate to your data block in the project structure via "<Project_name>" -> "<CPU_designation>" -> "Program blocks". In the "Initial value" column you configure the values read out previously for your parameters. Save your changed project.

Fig. 02

Note
The initial values are transferred when you load into your S7-1200. Table 01

Validity
This FAQ is valid for S7-1200 CPUs up to and including firmware version V1.0.0. STEP 7 Basic V10.5.

Keywords:
Variable, Constant, Remanent, Retentivity

www.bresimar.pt

124

You might also like