Вы находитесь на странице: 1из 82

SIEMENS S7-1200

NOTAS DE APLICAO N 01

SIEMENS S7-1200

FAQs 2010 / 2009


( j.andril@bresimar.pt , v1.0-06/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 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 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 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 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

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.
www.bresimar.pt

SIEMENS S7-1200

NOTAS DE APLICAO N 01

3. Click the navigation button in the "PLC tag" field; the object list opens. Navigate to the
"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

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Fig. 08

Note
The parameters are BCD-coded.

www.bresimar.pt

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

SIEMENS S7-1200

NOTAS DE APLICAO N 01

(folha em branco)

www.bresimar.pt

10

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

11

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

12

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

13

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

14

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

15

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

16

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

17

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

18

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

19

SIEMENS S7-1200

NOTAS DE APLICAO N 01

(folha em branco)

www.bresimar.pt

20

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

21

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Parameter

Data
type

Memory
area

Description

EN

BOOL

I, Q, M, D,
L

Block enable input (must always be on)

IN

REAL

M, D, L

Value to be integrated

Enable

BOOL

I, Q, M, D,
L

Enable input (calculation occurs only if it is TRUE; if it is FALSE,


parameter OUT displays the last calculated value)

Reset

BOOL

I, Q, M, D,
L

Reset input (if it is TRUE, parameter OUT will be reset)

SMB

BYTE

Location of the system memory byte (must be connected!)

ENO

BOOL

Q, M, D, L

Enable output

OUT

REAL

M, D, L

Integrated value (retentive)

Error

BOOL

Q, M, D, L

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

22

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

23

SIEMENS S7-1200

NOTAS DE APLICAO N 01

(folha em branco)

www.bresimar.pt

24

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

25

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

26

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

27

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

28

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

29

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

30

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

31

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Table 02

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

Item

Address example

tags

"VB0", "VX1.0", "VW2", "VD4" etc.

markers

"MB8", "MX9.2", "MW10", "MD12" etc.

inputs

"I0.0", "AI0" etc.

outputs

"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

32

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

33

SIEMENS S7-1200

NOTAS DE APLICAO N 01

(folha em branco)

www.bresimar.pt

34

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

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.

2.

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 S71200 PLC.

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

35

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

36

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

2.

Select an S7-1200 PLC

www.bresimar.pt

37

SIEMENS S7-1200

NOTAS DE APLICAO N 01

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

IPToolInstall.zip ( 56907 KB )
www.bresimar.pt

38

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

39

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Figure 02

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

www.bresimar.pt

40

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

41

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

42

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

43

SIEMENS S7-1200

NOTAS DE APLICAO N 01

(folha em branco)

www.bresimar.pt

44

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

45

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

46

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

47

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

48

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

49

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

1, if the configuration is correct


0, if the configuration is no longer correct

Error:

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

50

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

51

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

52

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

53

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

54

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

55

SIEMENS S7-1200

NOTAS DE APLICAO N 01

(folha em branco)

www.bresimar.pt

56

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

57

SIEMENS S7-1200

NOTAS DE APLICAO N 01

(folha em branco)

www.bresimar.pt

58

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

59

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

60

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]".

Fig. 04
www.bresimar.pt

61

SIEMENS S7-1200

NOTAS DE APLICAO N 01

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

62

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

63

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

Transmission Control Protocol


(TCP)

ISOonTCP
(RFC 1006)

PROFINET IO
(PNIO)

V1.0.0

--

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

64

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

65

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

66

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

67

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

Fig. 07

www.bresimar.pt

68

SIEMENS S7-1200

NOTAS DE APLICAO N 01

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
expression used in table 01, Figure 06.

Fig. 09
www.bresimar.pt

69

SIEMENS S7-1200

NOTAS DE APLICAO N 01

Table 02

Requirements

S7-1200 PLC

Ethernet cable

PC / PG with Ethernet interface

STEP 7 Basic V10.5

www.bresimar.pt

70

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

71

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

72

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

73

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

74

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

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

77

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

78

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

79

SIEMENS S7-1200

NOTAS DE APLICAO N 01

(folha em branco)

www.bresimar.pt

80

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

81

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

82

Вам также может понравиться