s7300400 CM PTP Programming Manual en-US en-US
s7300400 CM PTP Programming Manual en-US en-US
s7300400 CM PTP Programming Manual en-US en-US
an S7-300/400 ___________________
Documentation guide 1
___________________
Introduction 2
SIMATIC Programming -
___________
3
communication using
instructions
ET 200MP/ET 200SP
PtP communication instructions ___________________
4
Error messages
used with distributed I/O of an
S7‑300/400
___________________
Service & Support A
Programming Manual
01/2013
A5E31625081-AA
Legal information
Warning notice system
This manual contains notices you have to observe in order to ensure your personal safety, as well as to prevent
damage to property. The notices referring to your personal safety are highlighted in the manual by a safety alert
symbol, notices referring only to property damage have no safety alert symbol. These notices shown below are
graded according to the degree of danger.
DANGER
indicates that death or severe personal injury will result if proper precautions are not taken.
WARNING
indicates that death or severe personal injury may result if proper precautions are not taken.
CAUTION
indicates that minor personal injury can result if proper precautions are not taken.
NOTICE
indicates that property damage can result if proper precautions are not taken.
If more than one degree of danger is present, the warning notice representing the highest degree of danger will
be used. A notice warning of injury to persons with a safety alert symbol may also include a warning relating to
property damage.
Qualified Personnel
The product/system described in this documentation may be operated only by personnel qualified for the specific
task in accordance with the relevant documentation, in particular its warning notices and safety instructions.
Qualified personnel are those who, based on their training and experience, are capable of identifying risks and
avoiding potential hazards when working with these products/systems.
Proper use of Siemens products
Note the following:
WARNING
Siemens products may only be used for the applications described in the catalog and in the relevant technical
documentation. If products and components from other manufacturers are used, these must be recommended
or approved by Siemens. Proper transport, storage, installation, assembly, commissioning, operation and
maintenance are required to ensure that the products operate safely and without any problems. The permissible
ambient conditions must be complied with. The information in the relevant documentation must be observed.
Trademarks
All names identified by ® are registered trademarks of Siemens AG. The remaining trademarks in this publication
may be trademarks whose use by third parties for their own purposes could violate the rights of the owner.
Disclaimer of Liability
We have reviewed the contents of this publication to ensure consistency with the hardware and software
described. Since variance cannot be precluded entirely, we cannot guarantee full consistency. However, the
information in this publication is reviewed regularly and any necessary corrections are included in subsequent
editions.
Conventions
The term "CPU" is used in this manual to refer to both the CPUs of the S7-300/400 and the
interface modules of the distributed I/O system.
Please also observe notes labeled as follows:
Note
The notes contain important information on the product described in the documentation, on
the handling of the product or on part of the documentation to which particular attention
should be paid.
Additional assistance
● Information about the Technical support (http://www.siemens.com/automation/support-
request) available can be found in the appendix to this documentation.
● The range of technical documentation for the individual SIMATIC products and systems
can be found on the SIMATIC Portal (http://www.siemens.com/simatic-tech-doku-portal).
● The online catalog and the ordering system are available in the Catalog
(http://mall.automation.siemens.com).
Note on IT security
Siemens offers IT security mechanisms for its automation and drive product portfolio in order
to support the safe operation of the plant/machine. We recommend that you inform yourself
regularly on the IT security developments regarding your products. You can find information
on this on the Internet (http://support.automation.siemens.com).
You can register for a product-specific newsletter here.
For the safe operation of a plant/machine, however, it is also necessary to integrate the
automation components into an overall IT security concept for the entire plant/machine,
which corresponds to the state-of-the-art IT technology. You can find information on this on
the Internet (http://www.siemens.com/industrialsecurity).
Products used from other manufacturers should also be taken into account here.
Preface ...................................................................................................................................................... 3
1 Documentation guide................................................................................................................................. 7
2 Introduction................................................................................................................................................ 9
2.1 Convention .....................................................................................................................................9
2.2 Overview of instructions.................................................................................................................9
3 Programming - communication using instructions.................................................................................... 13
3.1 Point-to-point................................................................................................................................13
3.1.1 Overview PtP communication ......................................................................................................13
3.1.2 Using the instructions...................................................................................................................16
3.1.3 Shared parameters for point-to-point operations .........................................................................18
3.1.4 Port_Config: Configure PtP communication port .........................................................................20
3.1.5 Send_Config: Configure PtP sender............................................................................................23
3.1.6 Receive_Config: Configure PtP recipient.....................................................................................25
3.1.7 P3964_Config: Configuring the 3964(R) protocol ........................................................................30
3.1.8 Send_P2P: Sending data.............................................................................................................32
3.1.9 Using LENGTH and BUFFER parameters in communication operations ...................................34
3.1.10 Receive_P2P: Receiving data......................................................................................................35
3.1.11 Receive_Reset: Clear receive buffer ...........................................................................................36
3.1.12 Signal_Get: Read status ..............................................................................................................37
3.1.13 Signal_Set: Set accompanying signals........................................................................................38
3.1.14 Get_Features: Get extended functions ........................................................................................39
3.1.15 Set_Features: Set extended functions.........................................................................................40
3.2 Modbus ........................................................................................................................................41
3.2.1 Overview of the Modbus RTU communication ............................................................................41
3.2.2 Modbus_Comm_Load: Configure communication module for Modbus .......................................43
3.2.3 Modbus_Master: Communicate as Modbus master ....................................................................46
3.2.4 Modbus_Slave: Communicate as Modbus slave .........................................................................53
3.2.5 Frame structure............................................................................................................................58
3.3 USS..............................................................................................................................................65
3.3.1 Overview of USS communication ................................................................................................65
3.3.2 Requirements for using the USS protocol ...................................................................................67
3.3.3 USS_Port_Scan: Communication by means of a USS network ..................................................71
3.3.4 USS_Drive_Control: Preparing and displaying data for the drive ................................................74
3.3.5 USS_Read_Param: Read data from drive ...................................................................................77
3.3.6 USS_Write_Param: Change data in drive....................................................................................79
3.3.7 General information on drive setup..............................................................................................81
4 Error messages ....................................................................................................................................... 85
A Service & Support.................................................................................................................................. 101
Glossary ................................................................................................................................................ 105
Index...................................................................................................................................................... 109
SIMATIC Manuals
The latest manuals of SIMATIC products are available on the Internet
(http://www.siemens.com/automation/service&support) and can be downloaded free of
charge.
Note
TIA Portal terminology is used in this documentation.
• Instruction
For the description of the blocks for point-to-point, Modbus and USS, this means that the
differentiation between FB and SFB and between FC and SFC familiar to you from the
S7-300/400 environment is no longer relevant and reference is now made only to
instructions.
All instructions are no longer dependent on the CPU used, but rather can be used both
for S7-300/400 (distributed in an ET 200MP/SP) and for S7-1500 (central and
distributed).
• Communication module
For the description of the devices, this means that the term "communication processor"
familiar to you from the S7-300/400 environment is replaced by "communication module".
Note
Use of the instructions
In order to be able to use the instructions described below in an S7-300/400-Umfeld
(distributed in an ET 200MP/SP), you need to have integrated the required library in your
STEP 7 (SIMATIC Manager) via a HSP (Hardware Support Package).
The following libraries are available:
• Punkt-zu-Punkt: PtP Communication, PtP_Comm
• Modbus (RTU): MODBUS ( RTU ), MODBUS_(RTU)
• USS: USS Communication, USS_Comm
Instruction Meaning
Port_Config The instruction Port_Config allows you to dynamically assign basic interface
(Page 20) parameters.
Send_Config The instruction Send_Config (send configuration) allows you to dynamically
(Page 23) assign send parameters of a port.
Receive_Config The instruction Receive_Config (receive configuration) allows you to dynamically
(Page 25) assign receive parameters of a port.
P3964_Config The instruction P3964_Config (protocol configuration) allows you to dynamically
(Page 30) assign the parameters of the 3964(R) procedure.
Send_P2P The instruction Send_P2P allows you to send data to a communication partner.
(Page 32)
Receive_P2P The instruction Recveive_P2P allows you to receive data from a communication
(Page 35) partner.
Receive_Reset The instruction Receive_Reset allows you to clear the receive buffer of the
(Page 36) communication module.
Signal_Get The instruction Signal_Get allows you to read the RS232 accompanying signals.
(Page 37)
Signal_Set The instruction Signal_Set allows you to set the RS232 accompanying signals.
(Page 38)
Get_Features The instruction Get_Features allows you to read the extended functions
(Page 39) supported by the communication module.
Set_Features The instruction Set_Features allows you to activate the extended functions
(Page 40) supported by the communication module.
Instruction Meaning
USS_Port_Scan The instruction USS_Port_Scan allows you to communicate by means of the
(Page 71) USS network.
USS_Drive_Control The instruction USS_Drive_Control allows you to swap data with the drive.
(Page 74)
USS_Read_Param The instruction USS_Read_Param allows you to read parameters from the
(Page 77) drive.
USS_Write_Param The instruction USS_Write_Param allows you to change parameters in the
(Page 79) drive.
Instruction Meaning
Modbus_Comm_Load The instruction Modbus_Comm_Load allows you to configure the port of
(Page 43) the communication module for Modbus RTU. .
Modbus_Master The instruction Modbus_Master allows you to communicate as Modbus
(Page 46) master by means of the PtP port.
Modbus_Slave The instruction Modbus_Slave allows you to communicate as Modbus
(Page 53) slave by means of the PtP port.
Note
CPU quantity structures
The point-to-point instructions communicate with the communication modules by reading or
writing data records.
When using the instructions, you should therefore check the quantity structure of the CPU for
reading and writing data records.
If multiple instructions need to read or write data records simultaneously on a CPU, there
may need to be a gap between the calls of each instruction by the user program.
Configuration instructions
Before the user program can start the PtP communication, the communication interface and
the parameters for sending and receiving of data must be configured.
The interface configuration and the data configuration can be set for each CM in the device
configuration or with the following instructions of your user program:
● Port_Config (Page 20)
● Send_Config (Page 23)
● Receive_Config (Page 25)
● P3964_Config (Page 30)
NOTICE
Device configuration <-> Configuration instructions
The device configuration parameters are transferred to the CM upon each Power On of the
CPU (return of voltage).
The parameters of the configuration instructions are transferred to the CM as defined in
your user program.
The parameters of the device configuration are not synchronized with the parameters of the
configuration instructions, i.e. the parameters of the configuration instructions are not
applied to the CPU device configuration.
With your user program, you determine which parameters apply in the CM and when.
Communication instructions
The user program uses the instructions for point-to-point communication to send data to and
receive data from the communication interfaces. The CMs send data to and receive data
from the communication stations. The protocol is located in a buffer that is received from or
sent to a specific communication interface.
● Send_P2P (Page 32)
● Receive_P2P (Page 35)
Note
Data consistency
If the data to be sent is to be transmitted consistently, it may not be changed after the
positive edge at the REQ parameter until DONE has been set by the Send_P2P parameter.
If the receive data is to be read consistently, it may only be evaluated when NDR = true.
The receive buffer can be reset with additional instructions and special RS232 signals can
be queried and set.
● Receive_Reset (Page 36)
● Signal_Get (Page 37)
● Signal_Set (Page 38)
The following instructions let you read or write extended functions, as long as these are
supported by the module.
● Get_Features (Page 39)
● Set_Features (Page 40)
All PtP instructions are asynchronous, i.e. the user program is not paused until the
instruction has been completed. The instruction must therefore be called until the output
parameter DONE indicates that execution is complete.
The user program can determine the send and receive status with the help of the query
architecture. Send_P2P and Receive_P2P can be run at the same time. The communication
modules buffer the send and receive data as required until a module-specific maximum
buffer size has been reached.
Note
Resolution of bit times
The number of bit times is specified with the configured data transmission rate for different
parameters. Specifying the parameter in bit times makes it independent of the data
transmission rate. All parameters with units of bit times can be specified with a maximum
number of 65535. However, the maximum time period that can be measured by a CM is 8
seconds.
Note
STATUS backup
The parameters DONE, NDR, ERROR and STATUS are only available for one block cycle.
To display the STATUS, you should therefore copy STATUS to a free data area.
Master
Typical sequence for a master:
1. The Send_P2P instruction triggers transmission to the CM.
Data transmission is initiated by a positive edge at the REQ input.
2. The Send_P2P instruction is executed in subsequent cycles to query the status of the
transmission process.
3. When the Send_P2P instruction signals that transmission is complete, the user code can
prepare the receipt of the answer.
4. The Receive_P2P instruction is run repeatedly to query an answer. If the CM has
acquired response data, the Receive_P2P instruction copies the response to the CPU
and signals that new data has been received.
5. The user program can process the response.
6. Back to step 1 and repetition of the cycle.
Slave
Typical sequence for a slave:
1. The user program runs the Receive_P2P instruction in each cycle.
2. If the CM has received a request, the Receive_P2P instruction signals that new data is
available, and the request is copied to the CPU.
3. The user program processes the request and creates a response.
4. The response is returned to the master with the Send_P2P instruction.
5. Run Send_P2P repeatedly to ensure that the send process is actually taking place.
6. Back to step 1 and repetition of the cycle.
The slave must ensure that Receive_P2P is called up often enough so that a transmission
can be received by the master before it cancels the process due to a timeout while waiting
for the response. To do so, the user program Receive_P2P can be called from within a cycle
OB whose cycle time is sufficiently short so that the master can receive a transmission
before the timeout setting expires. If the OB cycle time is set so that two runs can take place
during the timeout setting of the master, the user program can receive all transmissions
without any losses.
Parameters Description
REQ Data transmission is initiated by a positive edge at the REQ input. Another edge at REQ may
only be created after the command has been completed (DONE or ERROR). Data transmission
can take several calls (program cycles), depending on the data volume.
When you add a PtP instruction to your program, STEP 7 will prompt you to specify the instance
DB (or to have STEP 7 create a corresponding instance DB). Use a unique DB for each PtP
instruction call.
PORT A port address is assigned during configuration of the communication module. The PORT
parameter communicates assignment to a specific communication module to the instruction.
You can select a symbolic name for the standard port after the configuration. The assigned CM
port value is the "Hardware ID" property of the device configuration with S7-1200/1500 and the
"Input address" with S7-300/400. The symbolic port name is assigned in the symbol table.
The output parameters DONE, NDR, ERROR and STATUS of the PtP instructions indicate
the execution status of the PtP functions.
Note
Please note that the parameters DONE, NDR, ERROR and STATUS are only set for one
cycle.
Description
The Port_Config instruction (port configuration) allows you to change parameters such as the
data transmission rate in runtime using your program.
Port_Config configuration changes are saved on the CM and not in the CPU. The
parameters saved in the device configuration are restored when the CPU is switched on
again.
Parameters
Description
The Send_Config instruction (send configuration) allows you to change serial transmission
parameters in runtime using your program. Any data pending in a CM is deleted when
Send_Config is executed.
Send_Config configuration changes are saved on the CM and not in the CPU. The
parameters saved in the device configuration are restored when the CPU is switched on
again.
Parameters
Description
The Receive_Config instruction (receive configuration) allows you to change serial receive
parameters in runtime using your program. This instruction configures the conditions that
mark the start and the end of received data. Any data pending in a CM is deleted when
Receive_Config is executed.
Port_Config configuration changes are saved on the CM and not in the CPU. The
parameters saved in the device configuration are restored when the CPU is switched on
again.
Parameters
Example
Have a look at the following received data in hexadecimal coding: "68 10 aa 68 bb 10 aa 16".
The configured start character strings are available in the following table. Start character
strings are evaluated once the first character 68H has been successfully received. After the
fourth character has been successfully received (the second 68H), start condition 1 has been
met. Once the start conditions have been met, the evaluation of the end conditions starts.
Processing of the start character string can be canceled due to different errors in parity,
framing or time intervals between characters. These errors prevent receipt of the data
because the start condition has not been met.
Start condition First character First character +1 First character +2 First character +3 First character +4
1 68H xx xx 68H xx
2 10H aaH xx xx xx
3 dcH aaH xx xx xx
4 e5H xx xx xx xx
Description
The P3964_Config instruction (protocol configuration) allows you to change protocol
parameters for 3964(R), such as character delay time, priority and block check, in runtime
using your program.
P3964_Config configuration changes are saved on the CM and not in the CPU. The
parameters saved in the device configuration are restored when the CPU is switched on
again.
Parameters
Description
The Send_P2P instruction (send point-to-point data) starts the transmission of data and
transmits the contents of the assigned buffer to the communication module. The CPU
program continues to run while the CM sends the data at the assigned data transmission
rate. Only one send instruction per communication module may be pending at any time. The
CM will output an error if a second Send_P2P instruction is executed when the CM is already
sending a frame.
Parameters
Parameters
If a send instruction is in progress, the status of outputs DONE and ERROR will be FALSE.
At the end of a send instruction, the DONE or the ERROR output is set to TRUE to signal the
status of the send instruction. The error code at the STATUS output can be evaluated when
the status of ERROR is TRUE.
The instruction outputs the status 16#7001 when the communication interface accepts the
send data. Subsequent executions of Send_P2P output the value 16#7002 if the CM is still
sending. At the end of the send instruction, the CM outputs the status 16#0000 for the send
instruction (if no errors have occurred). Subsequent executions of Send_P2P with REQ = 0
output the status 16#7000 (free).
The diagram below shows the relationship between the output values and REQ. It is based
on the assumption that the instruction is called cyclically to check the status of the send
process (indicated by the STATUS values).
The figure below shows how the DONE and STATUS parameters are only valid for one cycle
if a pulse is pending on the REQ line (for one cycle) to trigger the send instruction.
The figure below shows the relationship between the DONE, ERROR and STATUS
parameters in the event of an error.
The DONE, ERROR and STATUS values are only valid until Send_P2P is executed again by
the same instance DB.
LENGTH Description
>0 Transfers the configured number of bytes.
=0 Transfers the entire contents of the send buffer addressed with BUFFER.
If BUFFER points to a string, the entire string contents will be transferred except for the bytes with
the maximum and actual length.
BUFFER Description
Elementary data type When sending: The LENGTH value must include the byte size of this data type.
Example: For a Word value, the LENGTH must be two. For a DWord value or Real value, the
LENGTH must be four.
Structure For optimized memory: The maximum possible BUFFER length is 1024 Byte.
For sending: The LENGTH value can include a byte size smaller than the complete byte length of
the structure; in this case, only the first LENGTH bytes of the structure from BUFFER are sent.
Array For optimized memory: If the array data type is not equal to Byte, Word or DWord, the maximum
possible buffer length is 1024 Byte.
For sending: The LENGTH value must include a byte size smaller than the complete byte length of
the array; this byte size is a multiple of the byte size of the data element. Example: The LENGTH
parameter of an array of the Word type must be a multiple of two and a multiple of four for an array
of the Real type. If LENGTH is specified, the number of array elements is transmitted in LENGTH
bytes. If BUFFER contains an array with 15 DWord elements (a total of 60 Bytes), for example,
and you specify LENGTH = 20, the first five DWord elements from the array will be transmitted.
String The LENGTH parameter includes the number or characters to be sent. Only the characters of the
String are transmitted. The bytes with the maximum and actual length of the String are not sent.
Description
The Receive_P2P instruction (receive data using point-to-point communication) checks the
frames received in the CM. If a frame is available, it is transmitted from the CM to the CPU.
A receive error is indicated at the STATUS parameter.
Parameters
The error code at the STATUS output can be evaluated when the status of ERROR is TRUE.
The STATUS value provides the reason for terminating the receive operation in the CM. This
is usually a positive value which indicates that the receive operation has been successful
and which frame criterion has been detected. If the STATUS value is negative (the most
significant bit of the hexadecimal value is set), the receive operation was terminated due to
an error condition, such as a parity, framing or overflow error.
Each PtP communication interface can buffer a module-specific maximum number of bytes.
If more than one frame is available in the CM, the Receive_P2P instruction will output the
oldest available frame. Once the oldest frame has been fetched, the second-oldest frame
becomes the oldest.
Description
The Receive_Reset instruction (reset receiver) clears the receive buffer in the CM.
Parameters
Description
The Signal_Get instruction (get RS232 signals) reads the current states of the RS232
accompanying signals and displays them at the corresponding instruction outputs.
Parameters
Description
The Signal_Set instruction (set RS232 signals) allows you to set the states of the RS232
communication signals.
This function is only valid for RS232 CM.
Parameters
Description
If supported by the module, you can use the Get_Features instruction (get extended
functions) to get information on the ability of the module to support CRC and to generate
diagnostic messages.
Parameters
Description
If supported by the module, you can use the Set_Features instruction (set extended
functions) to activate CRC support and the generation of diagnostic messages.
Parameters
3.2 Modbus
Table 3- 12 Functions for reading data: Reading distributed I/O and program data
Modbus function code Functions for reading the slave (server) - standard addressing
01 Read output bits: 1 to 1992 bits per request
02 Read input bits: 1 to 1992 bits per request
03 Read holding register: 1 to 124 words per request
04 Read input words: 1 to 124 words per request
Table 3- 13 Functions for writing data: Changing distributed I/O and program data
Modbus function code Functions for writing in the slave (server) - standard addressing
05 Write one output bit: 1 bit per request
06 Write one holding register: 1 word per request
15 Write one or several output bits: 1 to1960 bits per request
16 Write one or several holding registers: 1 to 122 words per request
● The Modbus function codes 08 and 11 offer diagnostic information for communication of
the slave device.
● Modbus slave address 0 sends a broadcast frame to all slaves (without slave response;
for function codes 5, 6, 15, 16).
Station Address
RTU station Standard station address 1 to 247 and 0 for broadcast
Extended station address 1 to 65535 and 0 for broadcast
Description
The Modbus_Comm_Load instruction configures a communication module for
communication by means of the Modbus-RTU protocol. An instance data block is
automatically assigned when you add the Modbus_Comm_Load instruction in your program.
Parameters
Modbus_Comm_Load is executed to configure a port for the Modbus RTU protocol. Once
you have configured the port for the Modbus RTU protocol, it can only be used by the
Modbus_Master or Modbus_Slave instructions.
You have to run Modbus_Comm_Load for the configuration of each communication port that
is to be used for Modbus communication. You must assign a unique Modbus_Comm_Load
instance DB to each port that you use. Only run Modbus_Comm_Load again if you need to
change communication parameters, such as data transmission rate or parity.
For example, an instance data block is assigned to the instruction if you add Modbus_Master
or Modbus_Slave to your program. You need to connect the MB_DB parameter of instruction
Modbus_Comm_Load to the MB_DB parameter of instruction Modbus_Master or
Modbus_Slave.
Description
The Modbus_Master instruction communicates as Modbus master via a port configured by
the Modbus_Comm_Load instruction. An instance data block is automatically assigned when
you add the Modbus_Master instruction in your program. The MB_DB parameter of the
Modbus_Comm_Load instruction must be connected to the (static) MB_DB parameter of the
Modbus_Master instruction.
Parameters
REQ parameter
FALSE = no request; TRUE = request to send data to the Modbus slave
Enable requested transmission at a positive edge of this enable input. This transmits the
contents of the buffer to the point-to-point communication interface.
You use the DATA_ADDR and MODE parameters to select the Modbus function code.
DATA_ADDR (Modbus start address in the slave): Specifies the start address of the data
that is accessed in the Modbus slave.
The Modbus_Master instruction uses the MODE input instead of a function code input. The
combination of MODE and DATA_ADDR specifies the function code that is used in the
actual Modbus frame. The table below shows how the MODE parameter, the Modbus
function code and the Modbus address range in DATA_ADDR are related.
- 1 -
81 1 word per request 08 Reset slave event counter using
data diagnostic code 0x000A
- 1 -
3 to 10, - - Reserved
12 to
79,
82 to
255
1 In extended addressing, see the Extended_Adressingparameter, the maximum data length is shorter by 1 byte or
1 word depending on the data type of the function.
2 MODE 2 allows you to write one or more output bits and one or more holding registers using the Modbus functions 15
and 16.
MODE 1 uses the Modbus functions 5 and 6 to write 1 output bit and 1 holding register, and Modbus functions 15 and
16 to write multiple output bits and multiple holding registers.
DATA_PTR parameter
The DATA_PTR parameter points to the DB or flag address in which to write or from which to
read. If you use a data block, you must create a global data block that provides the data
memory for read and write processes on Modbus slaves.
Note
S7-1200/1500 - The data block addressed using DATA_PTR must support direct addressing
The data block must permit direct (absolute) and symbolic addressing.
See also
Modbus_Slave: Communicate as Modbus slave (Page 53)
Description
The Modbus_Slave instruction allows your program to communicate as Modbus slave via a
PtP port of a CM (RS422/485 or RS232). STEP 7 automatically generates an instance DB
when you add the instruction. The MB_DB parameter of the Modbus_Comm_Load
instruction must be connected to the (static) MB_DB parameter of the Modbus_Slave
instruction.
Parameters
The function codes of the Modbus communication (1, 2, 4, 5 and 15) can read and write bits
and words directly in the process image of the inputs and in the process image of the outputs
of the CPU. The MB_HOLD_REG parameter must be defined as data type greater than one
byte for these function codes. The table below shows the sample assignment of Modbus
addresses to the process image in the CPU.
Note
The available address area may be smaller, depending on the memory configuration of the
CPU.
The function codes of the Modbus communication (3, 6, 16) use a Modbus holding register
which is an address area in the memory area of the flags or a data block. The type of hold
register is specified by the MB_HOLD_REG parameter of the Modbus_Slave instruction.
Note
S7-1200/1500 - type of data block MB_HOLD_REG
The data block with Modbus holding register must permit direct (absolute) and symbolic
addressing.
The Modbus_Slave instruction supports broadcast write requests from Modbus masters as
long as the requests include access to valid addresses. Modbus_Slave generates error code
0x8188 for function codes that are not supported by the broadcast function.
You program can write values to the HR_Start_Offset and Extended_Addressing variables
and control the Modbus slave operations. The other variables can be read to monitor the
Modbus status.
5HVSRQVH
WLPHRXWSHULRG
$'5 )& 'DWD &5& $'5
0DVWHUVHQGV 6ODYHVHQGV
The timeout period for the RESP_TO response is the time a Modbus master waits for the
beginning of a response from a Modbus slave. This period is not defined by the Modbus
protocol, but by a parameter of the Modbus_Comm_Load instruction. As both receiving and
sending a frame requires multiple calls of the Modbus_Slave instruction (at least three), you
should execute Modbus_Slave at least twelve times during the timeout period for the
response of the Modbus master so that the Modbus slave receives and sends data twice as
many times as specified by the timeout period.
HR_Start_Offset
The Modbus holding register addresses start at 40001 or 400001. These addresses
correspond to the start address of the holding register in the target system memory.
However, you can configure the HR_Start_Offset tag to set a start address other than 40001
or 400001 for the Modbus holding register.
You can, for example, configure a holding register with start at MW100 and a length of 100
words. With an offset of 20, you can enter a holding register start address of 40021 instead
of 40001. Each address under 40021 and above 400119 results in an addressing error.
Table 3- 22 Example: addressing the Modbus holding register when DATA_PTR is a pointer to MW100
HR_Start_Offset is a word value which specifies the start address of the Modbus holding
register and is saved in the Modbus_Slave instance data block. You select this public static
tag by means of the parameter drop-down list once you have added Modbus_Slave in your
program.
If you have added Modbus_Slave to an LAD network, for example, you can go to a previous
network and assign the value HR_Start_Offset using the move command. The value must be
assigned prior to execution of Modbus_Slave.
Enter Modbus slave tag using the standard DB name:
1. Position the cursor in the parameter field OUT1 and enter the character m.
2. Select the required instance DB of the Modbus_Slave instruction from the drop-down list.
3. Position the cursor to the right of the DB name (after the quotation mark) and enter a
point.
4. Select "Modbus_Slave_DB.HR_Start_Offset" in the drop-down list.
Extended_Addressing
You access the Extended_Addressing tag as described for the HR_Start_Offset reference,
except that the Extended_Addressing tag is a Boolean value.
You can configure a single byte (Modbus standard) or a double byte for addressing the
Modbus slave. Extended addressing is used to address more than 247 devices in a single
network. If you decide to use extended addressing, you can address up to 65535 addresses.
The following example shows a frame of the Modbus function 1.
Frame description
Data traffic between master and slave / slave and master starts with the slave address,
following by the function code. The data is then transferred. The structure of the data field
depends on the function code used. The CRC check is transmitted at the end of the frame.
Function code 11 - This function can read 2 bytes of "Status word" and 2 bytes of "Event counter"
Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7 Byte 8 Byte n
Query Slave address Function Start address Number of output Byte Value
code words counter 1
Valid Slave address Function Start address Number of output ---
response code words
Error Slave address 0x8F E code 2 ---
message
1 Byte counter: If there is a remainder when the number of bytes is divided by 8, the number of bytes must be increased
by 1.
2 E code: 01 or 02 or 03 or 04
Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7 Byte 8 Byte n
Query Slave address Function Start address Number of registers Byte Value
code counter 1
Valid Slave address Function Start address Number of registers ---
response code
Error Slave address 0x90 E code 2 ---
message
1 Byte counter: Number of registers * 2
2 E code: 01 or 02 or 03 or 04
3.3 USS
USS communication
The USS instructions control the operation of drives which support the protocol of the
universal serial interface (USS). You can communicate with several drives by means of
RS485 connections and the USS instructions with the PtP communication modules. Each
RS485 port can operate up to 16 drives.
The USS protocol uses a master-slave network for communication via a serial bus. The
master uses an address parameter to send data to a selected slave. A slave cannot send
without having first received a send request. Communication between individual slaves is not
possible. USS communication takes place in half-duplex mode. The figure below shows a
network diagram for a sample application with 16 drives.
1 2
&38 &0
① CPU
② CM
③ USS drives in a USS network
Note
Communicating with a drive using RS232
In principle, CM PtP RS232 BA and CM PtP RS232 HF can also be used to communicate
with a drive. However, only one drive can be connected to an RS232 port.
,QVWDQFH'% &RPPXQLFDWLRQ
6HQGB33 PRGXOH
866B3RUWB6FDQ 0DVWHU
5HFHLYHB33
,QVWDQFH'%
866B'ULYHB&RQWURO
'ULYH
B&RQILJ
866
866B'ULYHB&RQWURO 'ULYH
'ULYH
866
'ULYH
866
'ULYH
866B'ULYHB&RQWURO
'ULYH
866B5HDGB3DUDP
866B:ULWHB3DUDP
All drives (max. 16) that are connected to one RS485 port are part of the same USS
network. All drives that are connected to another RS485 port are part of a different USS
network. Each USS network is managed using a unique instance data block for all
USS_Drive_Control instructions and one further instance data block for the USS_Port_Scan
instruction. All instructions that are part of a USS network must share this instance data
block for USS_Drive_Conrol. The instructions USS_Port_Scan, USS_Read_Param and
USS_Write_Param have the parameter USS_DB for this function; this parameter must be
connected to the (static) USS_DB parameter of the instance DB of the USS_Drive_Control
instruction.
● The instructions USS_Drive_Control and USS_Port_Scan are function blocks (FB). If you
add the USS_Drive_Control or USS_Port_Scan instruction to the programming editor, you
will be prompted to assign a DB for this FB in the "Call options" dialog. If it is the first
USS_Drive_Control instruction in this program for this USS network, you can apply the
DB standard assignment (or change the name, if necessary) and the new DB will be
created for you. If, however, it is not the first USS_Drive_Control instruction for this drive,
you will need to select the DB which has already been assigned to this USS network from
the drop-down list in the "Call options" dialog.
● The USS_Port_Scan and USS_Read_Param instructions are functions (FCs). No DB is
assigned when you add these FCs in the editor. If you add these FCs or the instruction
USS_Port_Scan in the editor, you will need to assign the USS_DB parameter of the
corresponding USS_Drive_Controlinstance DB to the USS_DB input of these instructions.
Double-click the parameter field and click the symbol to display the available DBs. Enter
a period "." and select the parameter USS_DB from the drop-down list.
● TheUSS_Port_Scan function controls communication between the CPU and the drives
via the point-to-point (PtP) RS485 communication port. A communication with the drive is
processed every time you call this function. Your program must call this function fast
enough so that the drives do not signal a timeout. To ensure a constant time response for
frame communication, you should call this instruction in a cyclic interrupt OB.
● The USS_Drive_Control instruction gives your program access to a specified drive in the
USS network. Its inputs and outputs correspond to the states and operating functions of
the drive. If there are 16 drives in your network, you must call USS_Drive_Control at least
16 times in your program, i.e. once for each drive.
You should only call the USS_Drive_Control instruction from a cyclic OB.
● The operating parameters of the drive are read and written with the USS_Read_Param
and USS_Write_Param functions. These parameters control the internal operation of the
drive. See the drive manual for a definition of these parameters. Your program may
include any number of these functions, but only one read or write request may be active
for a drive at any particular time. You may only call the USS_Read_Param and
USS_Write_Param functions from the cycle OB of a main program.
NOTICE
USS instruction calls
Only ever call USS_Drive_Control, USS_Read_Param or USS_Write_Param from a cycle
OB of the main program. The USS_Port_Scan instruction function can be called from any
OB, but it is usually called from a cyclic interrupt OB.
Do not use the USS_Drive_Control, USS_Read_Param or USS_Write_Param instruction in
an OB with a higher priority than the corresponding USS_Port_Scan instruction. For
example, do not add USS_Port_Scan to the main program or USS_Read_Param to a cyclic
interrupt OB. You may encounter unexpected errors if the execution of USS_Port_Scan is
interrupted by another instruction.
Example:
5 drives
Data transmission rate = 9600 bps
28 characters per frame
Cycle time = 0.020 sec
Time interval = (5 * 5 * 0.02 sec + 2 * 28 * 11 / 1200 sec) * 3 = 1.69 sec
The watchdog for the drive needs to be set to approx. 2 seconds in this case.
Description
The USS_Port_Scan instruction processes communication via a USS network. STEP 7
generates the DB automatically when you add the instruction.
Note
Changing use of the communication module
If you want to use the communication module for the USS protocol after using it for Modbus,
you will first need to switch the power off and back on (to reset the Modbus_Comm_Load
settings).
Parameters
There is only one USS_Port_Scan instruction per PtP communication port in the program
and each call of this instruction controls a transmission to or from all drives in this network.
All USS functions assigned to one USS network and one PtP communication port must use
the same instance DB.
Your program must execute the USS_Port_Scan instruction often enough to prevent a
timeout in the drive (see Requirements for using the USS protocol (Page 67) "Calculating
time for communication with the drive").
The USS_Port_Scan instruction is usually called from a cyclic interrupt OB to prevent drive
timeouts and to have the last USS data updates available for calls of USS_Drive_Control
.
Description
The instruction USS_Drive_Control prepares send data for the drive and evaluates the drive
response data. You need to use a separate instance of the instruction for each drive, and all
USS functions assigned to one USS network and one PtP communication port must use the
same instance DB. You must enter the DB name when you add the first USS_Drive_Control
instruction. You then refer to this DB that was created when the first instruction was added.
STEP 7 automatically creates the DB when you add the instruction.
Parameters
When the initial execution of USS_Drive_Control takes place, the drive specified by the USS
address (DRIVE parameter) is initialized in the instance DB. After initialization, subsequent
USS_Port_Scan instructions can start communication with the drive from this drive number.
If you change the drive number, you must first switch the CPU to STOP and then back to
RUN to initialize the instance DB. The input parameters are configured in the USS send
buffer and any outputs are read from a "previous" valid response buffer. USS_Drive_Control
only configures the data to be sent and evaluates data received in a previous request.
You can control the direction of rotation of the drive using either the D_IR input (Bool) or the
sign (positive or negative) at the SPEED_SP input (Real). The table below explains how
these inputs work together to determine the direction of rotation of the drive, provided the
motor rotates forward.
Description
The USS_Read_Param instruction reads a parameter from a drive. All USS functions
assigned to one USS network and one PtP communication port must use the instance data
block of the USS_Drive_Control instruction. USS_Read_Param must be called from a cycle
OB of the main program.
Parameters
Note
For EEPROM write instructions (EEPROM in a USS drive):
Keep the number of EEPROM write operations to a minimum in order to maximize the
EEPROM service life.
Description
The USS_Write_Param instruction changes a parameter in the drive. All USS functions
assigned to one USS network and one PtP communication port must use the instance data
block of the USS_Drive_Control.
USS_Write_Param must be called from the cycle OB of a main program.
Parameters
NOTICE
If you connect devices that do not have the same reference voltage, you may create
unwanted currents in the connection cable.
These unwanted currents may cause communication errors or damages in the devices.
Make sure that all devices you connect with a communication cable either have the same
reference conductor in the circuit or are electrically disconnected to prevent the occurrence
of unwanted currents. The shielding must be connected to the ground or pin 1 of the 9-pin
plug connector. The wiring terminal 2-0V of the MicroMaster drive should be connected to
the ground.
Insert the two wires at the other end of the RS485 cable into the terminal block of the MM4
drive. To create a cable connection at the MM4 drive, remove the drive cover(s) to gain
access to the terminal blocks. The MM4 drive System Manual includes a detailed description
on how to remove the cover(s) on your specific drive.
The connections on the terminal block are numbered consecutively. At the S7-1200/1500
end, use a PROFIBUS connection plug and connect terminal A of the cable to terminal 15 of
the drive (for an MM420) or terminal 30 of the drive (for an MM440). Connect terminal B (P)
A (N) of the connector to terminal 14 (for an MM420) or to terminal 29 (for an MM440).
If the S7-1200/1500 is a terminating station in the network or a point-to-point connection, you
must use terminals A1 and B1 (not A2 and B2) of the plug connector, as these terminals
provide termination settings (for example, with the DP plug connector
6ES7972-0BA40-0X40).
NOTICE
Fitting the drive covers
Make sure that you install the drive covers carefully once again before you connect the
power supply of the device.
MM440
P 29
120 Ω
N 30
1.5 kΩ
470 Ω
0V 2
+10 V 1
12. Specify the timeout value for the serial P2014 index 0 = (0 to 65535 ms)
connection. 0 = timeout deactivated
This is the maximum permitted interval between
two incoming data frames. This function turns off
the inverter in case of a communication failure.
The time measurement starts once a valid frame
has been received. If no additional data frame is
received during the specified time, the inverter
turns off and displays error code F0070. If you
set the value to zero, the control is turned off.
13. Transmit the data from RAM to EEPROM: P0971 = 1 (start transmission). Save the
changes to the parameter settings in
EEPROM.
VUW
6XSSRUW
)LH LFH
6HUYLFH
3D
6H
(QJLQHHULQJ
UH
UY
OG
3URJUDPV 6XSSRUW
D
6S
5HSDLU6HUYLFHV
0RGHUQL]DWLRQ 2SWLPL]DWLRQ
6HUYLFHV 6HUYLFHV
Online Support
The comprehensive online information platform supports you in all aspects of our Service &
Support at any time and from any location in the world.
You can find Online Support at the following address on the Internet
(http://www.siemens.com/automation/service&support).
Technical Consulting
Support in planning and designing your project: From detailed actual-state analysis,
definition of the goal and consultation on product and system questions right through to the
creation of the automation solution.
Technical Support
Expert advice on technical questions with a wide range of demand-optimized services for all
our products and systems.
You can find Technical Support at the following address on the Internet
(http://www.siemens.com/automation/support-request).
Training
Extend your competitive edge – through practical know-how directly from the manufacturer.
You can find the training courses at the following address on the Internet
(http://www.siemens.com/sitrain).
Engineering Support
Support during project engineering and development with services fine-tuned to your
requirements, from configuration through to implementation of an automation project.
Field Service
Our Field Service offers you services for commissioning and maintenance – to ensure that
your machines and plants are always available.
Spare parts
In every sector worldwide, plants and systems are required to operate with constantly
increasing reliability. We will provide you with the support you need to prevent a standstill
from occurring in the first place: with a worldwide network and optimum logistics chains.
Repairs
Downtimes cause problems in the plant as well as unnecessary costs. We can help you to
reduce both to a minimum – with our worldwide repair facilities.
Optimization
During the service life of machines and plants, there is often a great potential for increasing
productivity or reducing costs.
To help you achieve this potential, we are offering a complete range of optimization services.
Modernization
You can also rely on our support when it comes to modernization – with comprehensive
services from the planning phase all the way to commissioning.
Service programs
Our service programs are select service packages for an automation and drives system or
product group. The individual services are coordinated with each other to ensure smooth
coverage of the entire life cycle and support optimum use of your products and systems.
The services of a service program can be flexibly adapted at any time and used separately.
Examples of service programs:
● Service contracts
● Plant IT Security Services
● Life Cycle Services for Drive Engineering
● SIMATIC PCS 7 Life Cycle Services
● SINUMERIK Manufacturing Excellence
● SIMATIC Remote Support Services
Benefits at a glance:
● Reduced downtimes for increased productivity
● Optimized maintenance costs due to a tailored scope of services
● Costs that can be calculated and therefore planned
● Service reliability due to guaranteed response times and spare part delivery times
● Customer service personnel will be supported and relieved of additional tasks
● Comprehensive service from a single source, fewer interfaces and greater expertise
Contact
At your service locally, around the globe: your partner for consultation, sales, training,
service, support, spare parts... for the entire range of products from Industry Automation and
Drive Technologies.
You can find your personal contact in our contacts database on the Internet
(http://www.siemens.com/automation/partner).
Automation system
An automation system is a programmable logic controller consisting of at least one CPU,
various input and output modules, and operating and monitoring devices.
Communication module
Communication modules are used for point-to-point connections and bus links.
Configuring
Configuring refers to the configuration of separate modules of an automation system in the
configuration table.
CPU
Central Processing Unit = Central module of the automation system that consists of the
control and computing units, memory, system program, and interfaces to the I/O modules.
CTS
Clear to send. The communication partner is ready to receive data.
Cycle time
The cycle time is the time that the CPU requires to process the user program once.
Default setting
The default setting is a reasonable basic setting that can be used whenever no other value is
specified.
Diagnostic events
Diagnostics events are, for example, module errors or system errors in the CPU that may be
caused by a program error.
Diagnostic functions
The diagnostic functions cover the entire system diagnostics and include the recognition,
interpretation and reporting of errors within the automation system.
Diagnostics buffer
Memory area in which detailed information on all diagnostics events is entered based on the
order of their occurrence.
Hardware
Hardware is the entire physical and technical equipment of a automation system.
Module parameters
Module parameters are values with which the behavior of the module can be set.
Online/Offline
When you are online there is a data connection between the automation system and
programming device, when you are offline there is no data connection between them.
Parameter assignment
Parameter assignment refers to the setting of a module's behavior.
Parameters
Parameters are values that can be allocated. There are two different types of parameters:
block parameters and module parameters.
Point-to-point communication
In point-to-point communication the communication processor forms the interface between a
programmable logic controller and a communication partner.
Procedure
Procedure refers to the process of a data transmission according to a specific protocol.
Protocol
All communication partners involved in data transmission must follow fixed rules for handling
and implementing the data traffic. Such rules are called protocols.
RTS
Request to send. The communication module is ready to send.
Software
Software refers to the entirety of all programs that are used on a computing system. The
operating system and user programs belong to this.
User program
The user program contains all instructions and declarations for processing the signals used
for controlling a system or a process. In SIMATIC S7 the user program is structured and
divided into small units, the blocks.
USS
The USS® protocol (universal serial interface protocol) defines an access method based on
the master-slave principle for communication by means of a serial bus. The point-to-point
connection is included as a subset in this protocol.
XON/XOFF
Software data flow control with XON/XOFF. You can configure the characters for XON and
XOFF (any ASCII character). The user data may not contain these characters.
USS_Read_Param, 77
USS_Write_Param, 79
Interface configuration
Instructions, 14
B
BUFFER parameter, Send_P2P, 34
L
LENGTH parameter, Send_P2P, 34
C
Library for the USS protocol
Communication General information on drive setup, 81
Query architecture, 16 Overview, 65
Communication interfaces Requirements for use, 67
Programming, 13 USS_Drive_Control, 74
Communication module (CM) USS_Port_Scan, 71
Data reception, 35 USS_Read_Param, 77
Programming, 13 USS_Write_Param, 79
D M
Data transmission, trigger, 32 Modbus
Modbus_Comm_Load, 43
Modbus_Slave, 46, 53
F Modbus_Comm_Load, 11, 43
Modbus_Master, 11
Frame configuration
Modbus_Slave, 11, 46, 53
Instructions, 14
P
G
P3964_Config, 10
Get_Features, 10
P3964_Config (protocol configuration), 30
Global library
Parameter configuration
Overview of the USS protocol, 65
LENGH and BUFFER for Send_P2P, 34
Point-to-point programming, 13
Port_Config, 10
I
Port_Config (port configuration), 20
Instructions Programming
P3964_Config (protocol configuration), 30 PtP instructions, 13
Port_Config (port configuration), 20 PtP communication
Receive_Config (receive configuration), 25 Programming, 13
Receive_P2P (receive point-to-point data), 35 PtP error classes, 19
Receive_Reset (reset receiver), 36 PtP instructions return values, 18
Send_Config (send configuration), 23
Send_P2P (send point-to-point data), 32
Signal_Get (get RS232 signals), 37 Q
Signal_Get (set RS232 signals), 38
Query architecture, 16
USS_Drive_Control, 74
Query architecture master, 16
USS_Port_Scan, 71
R
Receive_Config, 10
Receive_Config (receive configuration), 25
Receive_P2P, 10
Receive_P2P (receive point-to-point data), 35
Receive_Reset, 10
Receive_Reset (reset receiver), 36
Return values
PtP instructions, 18
Return values receive runtime, 35
S
Send_Config, 10
Send_Config (send configuration), 23
Send_P2P, 10
Send_P2P (send point-to-point data), 32
LENGH and BUFFER parameters, 34
Set_Features, 10
Shared PtP parameter errors, 19
Signal_Get, 10
Signal_Get (get RS232 signals), 37
Signal_Get (set RS232 signals), 38
Signal_Set, 10
U
USS_Drive_Control, 11, 66, 74
USS_Port_Scan, 11, 66, 71
USS_Read_Param, 11, 66, 77
USS_Write_Param, 11, 66, 79