CPU-CPU communication using the S7 basic communication via PROFIBUS

Một phần của tài liệu simotion_motion_control_communication_system_manual (Trang 37 - 41)

4.2 Cyclical data exchange between a SIMOTION and SIMATIC controller

4.2.4 CPU-CPU communication using the S7 basic communication via PROFIBUS

4.2.4.1 Introduction

CPU-CPU communication

CPU-CPU communication using the S7 basic communication between a SIMATIC and a SIMOTION controller, is set up using the SFC65 (XSEND) and SFC66 (XRECEIVE) system functions on the SIMATIC side and the _Xsend() and _Xreceive() system functions on the SIMOTION side. This application communication is effected via PROFIBUS, or MPI.

Table 4-2 CPU-CPU communication

Protocol SIMATIC device Function SIMOTION device Function

PROFIBUS S7-300 CPU

S7-400 CPU

SFC65 (XSEND) SFC66 (XRCV)

SIMOTION C SIMOTION D SIMOTION P

_Xsend _Xreceive

PROFIBUS addresses are assigned in HW Config. This must also be passed as a parameter when the system function _Xsend() is called. That is, the parameters that are important for communication are determined by the user and passed in the function call. It is not necessary to configure the communication link in NetPro.

Note

For further information, refer to the online help of each system function.

You will find additional information in the FAQ for SIMATIC communication:

● CPU-CPU communication with SIMATIC controllers (http://

support.automation.siemens.com/WW/view/en/20982954)

● S7 basic communication (http://support.automation.siemens.com/WW/view/en/28866132)

4.2.4.2 SIMOTION functions

The SIMOTION functions for a PROFIBUS connection are explained in more detail below. .

System functions Xsend() and Xreceive()

Table 4-3 Xsend()

RetVal_PB_Senden:=

_xsend(

communicationMode := PB_Senden_CommunicationMode, address := PB_Senden_Address,

messageID := PB_Senden_MessageID, nextCommand := PB_Sender_NextCommand, commandID := PB_Senden_CommandID, data := PB_Sende_Daten,

datalenght := PB_Sende_Daten_Laenge );

Example of the call of the SIMOTION function _xsend

If the SIMATIC S7 station and the SIMOTION device communicate via PROFIBUS, the _xsend function is called on the SIMOTION side for sending purposes.

Note

Application transmission and reception via S7 basic communication (_Xreceive() or _Xsend()) is only possible on a PROFIBUS interface of the SIMOTION controller if the Programming, status/force, or other PG functions and non-configured communication connections possible option is set.

The "communicationmode" parameter informs the called function of what is to happen to the connection after the successful data transfer. The function data type can assign the

ABORT_CONNECTION or HOLD_CONNECTION values. If ABORT_CONNECTION is assigned to the parameter, the connection will be removed after the data transfer. The HOLD_CONNECTION value is used to parameterize the function so that the connection will be retained after a successful data transfer.

The address parameter contains a structure of the StructXsendDestAddr data type, which also consists of various parameters. This structure contains all the information about the

communication partner address of the SIMOTION device.

Parameter structure "StructXsendDestAddr

The individual parameters of the structure are listed and explained in the following.

The deviceid parameter is used for the respective SIMOTION hardware. The physical connection point is specified with the parameter. For example, the value 1 is entered for interface X8 for a SIMOTION C2xx. The value 2 is entered for interface X9. If a SIMATIC S7 station is connected to X101 of a SIMOTION P, the value 1 is assigned in the deviceid parameter. The value 2 is written in the deviceid parameter for the X102 interface. For the SIMOTION D, the value 1 is entered for the X126 interface and the value 2 for the X136 interface in the deviceid parameter.

The value 1 is set in the remotestaddrlength parameter for the MPI or PROFIBUS communication.

The nextstaddrlength parameter specifies the length of the router address. As a router is not used for the MPI or PROFIBUS communication between the SIMATIC S7 station and the SIMOTION device, the value 0 is assigned for this parameter. Consequently, the nextstaddr parameter is also irrelevant (see below).

The following remotesubnetid parameter identifies the subnet mask and has, as already mentioned above, no significance for the communication via MPI or PROFIBUS.

The remotestaddr parameter specifies the actual destination address. The parameter is an array. However, only the first index is used for the MPI or PROFIBUS communication. The other five indices have no significance.

The nextstaddr parameter is used to specify the router address. The same applies for this parameter as for the remotesubnetid parameter. Its assignment is also irrelevant for the communication via MPI or PROFIBUS.

The messageid parameter is assigned by the user for the identification of the SIMOTION on the receive side. The value entered enables an assignment on the SIMATIC S7 station via the REQ_ID parameter. The value can be fetched there from the messageid parameter.

The behavior of this function with respect to the advance when called is parameterized with the nextcommand parameter. There are two setting options: IMMEDIATELY and

WHEN_COMMAND_DONE. With the first value, the advance is immediately and with the second value, after completion of the command.

When the function is called, a system-wide unique number is assigned in the commandid parameter to allow tracking of the command status.

The send data is specified with the data variable when the function is called.

The datalength parameter specifies the length of the data to be transferred from the send area.

The return value of the _xsend function to the user program is of data type DINT. The various return values indicate any problems that occurred during the execution of the function. There is also a confirmation when the data has been successfully sent.

Table 4-4 Xreceive()

RetVal_PB_Empfangen:=

_xreceive(

messageID := PB_Empfangen_MessageID, nextCommand := PB_Empfangen_NextCommand, commandID := PB_Empfangen_CommandID );

Call example of the SIMOTION _xreceive function

The example shows the use of the _xreceive function. The function is used when data from a SIMATIC S7 station is to be received via PROFIBUS.

The messageid parameter is transferred to the _xreceive function for the identification of the S7 station from which the data is to be received. The entered value is that what was assigned on the S7 page in the REQ_ID parameter of the corresponding _xsend system function.

The behavior of this function with respect to the advance when called is parameterized with the nextcommand parameter. There are two setting options: IMMEDIATELY and

WHEN_COMMAND_DONE. With the first value, the advance is immediately and with the second value, after completion of the command.

When the function is called, a system-wide unique number is assigned in the commandid parameter to allow tracking of the command status.

The structure returned from the function to the user program contains the functionresult, datalength and data parameters. The receive status can be queried via the functionresult parameter. The datalength parameter returns the number of received useful data bytes after a successful call of the _xreceive function. The received useful data can be accessed via the data parameter.

5

Một phần của tài liệu simotion_motion_control_communication_system_manual (Trang 37 - 41)

Tải bản đầy đủ (PDF)

(414 trang)