Sei sulla pagina 1di 20

Appendix A Additional libraries

WAGO-I/O-PRO 32 library

ModbusEthernet_04.lib
The ModbusEthernet_04.lib library provides the user with the two function modules, ETHERNET_MODBUSMASTER_UDP and ETHERNET_MODBUSMASTER_TCP. With these modules, a data exchange can be set up with several Modbus TCP / UDP slaves. The ETHERNET_MODBUSMASTER_UDP module should be used in preference, as this enables faster data transfer. The ETHERNET_TERMINAL_MODBUSSLAVE module is also included in the library. This module provides a Modbus server, which maps the Modbus services to a word array.

Content
ModbusEthernet_04.lib ........................................................................3 ETHERNET_MODBUSMASTER_UDP.................................................... 3 ETHERNET_MODBUSMASTER_TCP .................................................... 5 ETHERNET_MODBUSMASTER_RTU.................................................... 7 MB_MASTER_SERIAL_OVER_TCP....................................................... 9 ETHERNET_CLIENT_OPEN_CLOSE.................................................... 12 IP_ADRESSE ............................................................................................ 13 ETHERNET_TERMINAL_MODBUSSLAVE ........................................ 14 ETHERNET_SERVER_OPEN_CLOSE .................................................. 16 typETH_SLAVE_DATEN (data type) ...................................................... 17 typSER_ModbusQuery (Data type)........................................................... 18 typSER_ModbusResponse (Data Type) .................................................... 19 enumSER_MB_ERROR (Enumeration) ................................................... 20

WAGO-I/O-PRO 32

Version 1.1.0

ModbusEthernet_04.lib - 1

ETHERNET_MODBUSMASTER_UDP

2 ModbusEthernet_04.lib

ml00101e

WAGO-I/O-PRO 32

Appendix A Additional libraries

ModbusEthernet_04.lib
ETHERNET_MODBUSMASTER_UDP
WAGO-I/O-PRO 32 Library elements
Category: Name: Type: Library name: Requiered libraries Applicable to: Communications module ETHERNET_MODBUSMASTER_UDP Function Function block X Program ModbusEthernet_04.lib Ethernet.lib Fieldbus controller 750-842 from FW: 02.02.00(04) Fieldbus controller 750-841 Data type: BYTE Comment: Fills the UnitId field in the Modbus protocol header. Use: - References the slave ID in a serial Modbus sub-network. - Buffer index of the Modbus slave on the PC in conjunction with ActiveMBTSlaveCtl. The following Modbus function codes are supported: FC1: (0x01) read coils FC2: (0x02) read input discretes FC3: (0x03) read multiple registers FC4: (0x04) read input registers FC5: (0x05) write coil FC6: (0x06) write single register FC7: (0x07) read exception status FC11: (0x0B) get comm event counter FC15: (0x0F) force multiple coils FC16 (0x10) write multiple registers FC23 (0x17) read write multiple registers Modbus address in slave to be read. Number of bits or words to be read. Pointer to the local data range in which the read data are stored. Modbus address in slave to be written. Number of bits or words to be written. Pointer to the local data range in which the data to be written are stored. Initiate Modbus telegram Reset internal data Maximum waiting time for the reply telegram from the Modbus slave.

Input parameter: bUNIT_ID

bFUNCTION_CODE

BYTE

wREAD_ADDRESS wREAD_QUANTITY ptREAD_DATA wWRITE_ADDRESS wWRITE_QUANTITY ptSEND_DATA xSTART xRESET tTIME_OUT

WORD WORD POINTER TO BYTE WORD WORD POINTER TO BYTE BOOL BOOL TIME

WAGO-I/O-PRO 32

Version 1.1.0

ModbusEthernet_04.lib - 3

ETHERNET_MODBUSMASTER_UDP

Return value: xREADY wERROR

Data type: BOOL WORD

bRESPONSE_UNIT_ID

BYTE

Comment: Data transfer is complete or the waiting time parameterised in tTIME_OUT has expired. 0x0000 Successful 0x0001 Illegal function code 0x0002 Illegal data address 0x0003 Illegal data value 0x0004 Slave device failure 0x0005 Acknowledge 0x0006 Slave device busy 0x0007 Negative acknowledge 0x0008 Memory parity error 0x000A Gateway path unavailable 0x000B Gateway target no response 0x0095 Error Socket-Close 0x0096 no valid Socket from FW 0x0097 Illegal number of points 0x0098 Internal buffer overrun 0x0099 - TimeOut Content of the UnitId field in the Modbus protocol header of the reply telegram

Graphical description:

Functional description: With the ETHERNET_MODBUSMASTER_UDP module, an Ethernet controller becomes the Modbus master. The number of slaves is only limited by the Modbus protocol. The ETHERNET_MODBUSMASTER_UDP uses the UDP protocol (User Datagram Protocol) and thus enables data to be exchanged more quickly than the TCP version.

4 ModbusEthernet_04.lib

ml00101e

WAGO-I/O-PRO 32

Appendix A Additional libraries

ETHERNET_MODBUSMASTER_TCP
WAGO-I/O-PRO 32 Library elements
Category: Name: Type: Library name: Requiered libraries Applicable to: Communications module ETHERNET_MODBUSMASTER_TCP Function Function block X Program ModbusEthernet_04.lib Ethernet.lib Fieldbus controller 750-842 from FW: 02.02.00(04) Fieldbus controller 750-841 Data type: STRING BYTE Comment: IP address of Modbus slave. Fills the UnitId field in the Modbus protocol header. Use: - References the slave ID in a serial Modbus sub-network. - Buffer index of the Modbus slave on the PC in conjunction with ActiveMBTSlaveCtl. The following Modbus function codes are supported: FC1: (0x01) read coils FC2: (0x02) read input discretes FC3: (0x03) read multiple registers FC4: (0x04) read input registers FC5: (0x05) write coil FC6: (0x06) write single register FC7: (0x07) read exception status FC11: (0x0B) get comm event counter FC15: (0x0F) force multiple coils FC16 (0x10) write multiple registers FC23 (0x17) read write multiple registers Modbus address in slave to be read. Number of bits or words to be read. Pointer to the local data range in which the read data are stored. Modbus address in slave to be written. Number of bits or words to be written. Pointer to the local data range in which the data to be written are stored. Initiate Modbus telegram Reset internal data Maximum waiting time for the reply telegram from the Modbus slave. Example: t#500ms

Input parameter: strIP_ADDRESS bUNIT_ID

bFUNCTION_CODE

BYTE

wREAD_ADDRESS wREAD_QUANTITY ptREAD_DATA wWRITE_ADDRESS wWRITE_QUANTITY ptSEND_DATA xSTART xRESET tTIME_OUT

WORD WORD POINTER TO BYTE WORD WORD POINTER TO BYTE BOOL BOOL TIME

WAGO-I/O-PRO 32

Version 1.1.0

ModbusEthernet_04.lib - 5

ETHERNET_MODBUSMASTER_TCP

Return value: xREADY wERROR

Data type: BOOL WORD

bRESPONSE_UNIT_ID

BYTE

Comment: Data transfer is complete or the waiting time parameterised in tTIME_OUT has expired. 0x0000 Successful 0x0001 Illegal function code 0x0002 Illegal data address 0x0003 Illegal data value 0x0004 Slave device failure 0x0005 Acknowledge 0x0006 Slave device busy 0x0007 Negative acknowledge 0x0008 Memory parity error 0x000A Gateway path unavailable 0x000B Gateway target no response 0x0097 Illegal number of points 0x0098 Internal buffer overrun 0x0099 TimeOut Content of the UnitId field in the Modbus protocol header of the reply telegram

Graphical description:

Functional description: With the ETHERNET_MODBUSMASTER_TCP module, an Ethernet controller becomes the Modbus master using the TCP protocol. The number of slaves is only limited by the Modbus protocol. The ETHERNET_MODBUSMASTER_TCP module should only be used when this is necessitated by the remote station. The Beijer E300 operating terminal, for example, supports only MODBUS TCP. The disadvantage of the TCP protocol is its basic connection-orientated concept. As a result of this, a new connection is set up for each data transfer, which leads to a costly protocol overhead in terms of time.

6 ModbusEthernet_04.lib

ml00101e

WAGO-I/O-PRO 32

Appendix A Additional libraries

ETHERNET_MODBUSMASTER_RTU
WAGO-I/O-PRO 32 Library elements
Category: Name: Type: Library name: Requiered libraries Applicable to: Communications module ETHERNET_MODBUSMASTER_RTU Function Function block X Program ModbusEthernet_04.lib Ethernet.lib Fieldbus controller 750-842 from FW: 02.02.00(04) Fieldbus controller 750-841 Data type: WORD BYTE Comment: Fills the UnitId field in the Modbus protocol header. Use: - References the slave ID in a serial Modbus sub-network. - Buffer index of the Modbus slave on the PC in conjunction with ActiveMBTSlaveCtl. The following Modbus function codes are supported: FC1: (0x01) read coils FC2: (0x02) read input discretes FC3: (0x03) read multiple registers FC4: (0x04) read input registers FC5: (0x05) write coil FC6: (0x06) write single register FC7: (0x07) read exception status FC11: (0x0B) get comm event counter FC15: (0x0F) force multiple coils FC16 (0x10) write multiple registers FC23 (0x17) read write multiple registers Modbus address in slave to be read. Number of bits or words to be read. Modbus address in slave to be written. Number of bits or words to be written. Maximum waiting time for the reply telegram from the Modbus slave. Example: t#500ms Pointer to the local data range in which the read data are stored.

Input parameter: SOCKET UNIT_ID

FUNCTION_CODE

BYTE

READ_REFERENCE QUANTITY_TO_ READ WRITE_ REFERENCE QUANTITY_TO_ WRITE TIME_OUT

WORD WORD WORD WORD TIME

ptRECEIVE_BUFFER

ptSEND_DATA

START_FUNCTION

POINTER TO ARRAY[1..3] OF BYTE POINTER Pointer to the local data range in which the TO data to be written are stored. ARRAY[1..3] OF BYTE BOOL Initiate Modbus telegram

WAGO-I/O-PRO 32

Version 1.1.0

ModbusEthernet_04.lib - 7

WAGO-I/O-PRO 32 Library elements


RESET Return value: ERROR BOOL Data type: WORD Reset internal data Comment: 0x0000 Successful 0x0001 Illegal function code 0x0002 Illegal data address 0x0003 Illegal data value 0x0004 Slave device failure 0x0005 Acknowledge 0x0006 Slave device busy 0x0007 Negative acknowledge 0x0008 Memory parity error 0x000A Gateway path unavailable 0x000B Gateway target no response 0x0097 Illegal number of points 0x0098 Internal buffer overrun 0x0099 TimeOut Data transfer is complete or the waiting time parameterised in tTIME_OUT has expired. Content of the UnitId field in the Modbus protocol header of the reply telegram

READY RESPONSE_UNIT_ID

BOOL BYTE

Graphical description:

Functional description: The ETHERNET_MODBUSMASTER_RTU module is used by: ETHERNET_MODBUSMASTER_UDP ETHERNET_MODBUSMASTER_TCP

8 ModbusEthernet_04.lib

ml00101e

WAGO-I/O-PRO 32

Appendix A Additional libraries

MB_MASTER_SERIAL_OVER_TCP
WAGO-I/O-PRO 32 Library Elements
Category: Name: Type: Library Name: Libraries used Applicable to: Communication modules
MB_MASTER_SERIAL_OVER_TCP

Function Function block X ModbusEthernet_04.lib


Ethernet.lib Mod_Com.lib

Program

Fieldbus Controller 750-842 from FW: 02.02.00(04) Fieldbus Controller 750-841 Data type: Comment:

Input parameter:

strIP_ADDRE STRING SS WORD iPORT xCONNECT


BOOL

IP address of Modbus slave.


Port no. of Modbus slave Default -> 502 TRUE -> TCP connection is established permanently FALSE -> TCP connection is only controled via StartFunction max. permissible response time of the slave

tTIME_OUT Input / output parameters: StartFunction

TIME

Data type:

Comment:

BOOL

Query

typModbusQuery

A TRUE at this parameter starts the service specified via "FunctionCode". It is automatically reset by the function block after the service was performed. TYPE typSER_ModbusQuery : STRUCT SlaveAddress : BYTE; FunctionCode : BYTE; StartAddress : UINT; Quantity : UINT; Data : ARRAY[0..124] OF WORD; END_STRUCT END_TYPE

Response

typModbusRespo TYPE typSER_ModbusResponse : nse STRUCT Error : WORD; SlaveAddress : BYTE; FunctionCode : BYTE; StartAddress : UINT; Quantity : UINT; Data : ARRAY[0..124] OF WORD; END_STRUCT END_TYPE

WAGO-I/O-PRO 32

Version 1.1.0

ModbusEthernet_04.lib - 9

MB_MASTER_SERIAL_OVER_TCP

WAGO-I/O-PRO 32 Library Elements


Output parameter: MB_Error Data type:
enumSER_MB_ ERROR

Comment:
Error code TYPE enumSER_MB_ERROR :( SER_MB_NO_ERROR := 16#00, SER_MB_NOT_SUPPORTED_FUNCTION := 16#01, SER_MB_ILLEGAL_DATA := 16#03, SER_MB_EXTENDED_SLAVE_ERROR := 16#90, SER_MB_CRC_ERROR := 16#96, SER_MB_ILLEGAL_NUMBER_OF_POINTS := 16#97, SER_MB_OVERRUN := 16#98, SER_MB_TIME_OUT := 16#99 ); END_TYPE

OPEN_Error

ETH_ERROR

See Ethernet.lib description

Graphical illustration:

Function description: The "MB_MASTER_SERIAL_OVER_TCP" function block expands the functionality of a programmable Ethernet controller to that of a serial MODBUS master, communicating via Ethernet TCP. Serial Modbus RTU frames with CRC are sent and received in TCP packets. The function block acts as a serial Modbus master. Ethernet is only used as a transport medium. A TRUE signal at input "xCONNECT" enables the TCP connection to be permanently established (default setting -> FALSE). With the default setting of this input, the TCP connection is only established via the StartFunction input and is then automatically terminated after the task has been carried out. Supported MODBUS services: 0x01 Read Coil Status 0x02 Read Input Status 0x03 Read Holding Register 0x04 Read Input Registers 0x05 Force Single Coil 0x06 Preset Single Registers 0x0B Fetch Comm Event Ctr 0x0F Force Multiple Coils 0x10 Preset Multiple Registers

10 ModbusEthernet_04.lib

ml00101e

WAGO-I/O-PRO 32

Appendix A Additional libraries

WAGO-I/O-PRO 32 Library Elements


Executing Modbus function The data relevant for the query must be entered into the query structure. The Modbus function is performed on the rising edge at the StartFunction input. The response of the slave is stored in the response structure.

WAGO-I/O-PRO 32

Version 1.1.0

ModbusEthernet_04.lib - 11

ETHERNET_CLIENT_OPEN_CLOSE

ETHERNET_CLIENT_OPEN_CLOSE
WAGO-I/O-PRO 32 Library elements
Category: Name: Type: Library name: Requiered libraries Applicable to: Communications module ETHERNET_CLIENT_OPEN_CLOSE Function Function block X Program ModbusEthernet_04.lib Ethernet.lib Fieldbus controller 750-842 from FW: 02.02.00(04) Fieldbus controller 750-841 Data type: BOOL STRING WORD BOOL Comment: TRUE -> Open socket FALSE -> Close socket IP address of remote station (Modbus slave) Port number of remote station (Modbus slave) TRUE -> Use TCP protocol FALSE -> Use UDP protocol Comment: = 0: no errors found <> 0: error in operation (see ETH_ERROR data type in Ethernet.lib for details) Handle on current socket

Input parameter: EN IP PORT TCP_PROTOKOLL

Return value: ERROR

Data type: WORD

SOCKET Graphical description:

WORD

Functional description: The ETHERNET_CLIENT_OPEN_CLOSE module is used by: ETHERNET_MODBUSMASTER_UDP ETHERNET_MODBUSMASTER_TCP

12 ModbusEthernet_04.lib

ml00101e

WAGO-I/O-PRO 32

Appendix A Additional libraries

IP_ADRESSE
WAGO-I/O-PRO 32 Library elements
Category: Name: Type: Library name: Requiered libraries Applicable to: Communications module IP_ADRESSE Function X Function block Program ModbusEthernet_04.lib Ethernet.lib Fieldbus controller 750-842 from FW: 02.02.00(04) Fieldbus controller 750-841 Data type: STRING Comment: IP address of remote station (Modbus slave) Comment: IP address of remote station (numeric)

Input parameter: IP_ADR

Return value: IP_ADR Graphical description:

Data type: WORD

Functional description: The module converts an IP address The module is used by: - ETHERNET_MODBUSMASTER_UDP - ETHERNET_MODBUSMASTER_TCP - ETHERNET_CLIENT_OPEN_CLOSE

WAGO-I/O-PRO 32

Version 1.1.0

ModbusEthernet_04.lib - 13

ETHERNET_TERMINAL_MODBUSSLAVE

ETHERNET_TERMINAL_MODBUSSLAVE
WAGO-I/O-PRO 32 Library elements
Category: Name: Type: Library name: Requiered libraries Applicable to: Communications module ETHERNET_TERMINAL_MODBUSSLAVE Function Function block X Program ModbusEthernet_04.lib Ethernet.lib Fieldbus controller 750-842 from FW: 02.02.00(04) Fieldbus controller 750-841 Data type: Comment: BOOL TRUE -> Activate Modbus server INT Port on which the Modbus server is to be accessed. BOOL TRUE -> TCP server FALSE -> UDP server INT Address from which Modbus bit services access the data array TIME The watchdog is started with the first telegram from the master. A check is made as to whether the master sends telegrams regularly. If the master drops out, i.e. the watchdog triggers, the xWATCHDOG_OK output is reset. Data type: Comment: typETH_SLAVE_ WORD ARRAY [0.. ETH_SIZE_SLAVEBUFFER] DATEN Data type: BOOL WORD Comment: Master is sending telegrams. 0x0000 No error 0x0001 Unsupported function code 0x0002 Illegal address from master 0x0003 Illegal data from master

Input parameter: EN iPORT TCP_PROTOKOLL iBIT_OFFSET tWATCHDOG_TIME

Input/Output parameter: aDATA

Output parameter: xWATCHDOG_OK wERROR

Graphical description:

14 ModbusEthernet_04.lib

ml00101e

WAGO-I/O-PRO 32

Appendix A Additional libraries

WAGO-I/O-PRO 32 Library elements


Functional description: This module is responsible for communication with external Modbus masters (e.g. various text displays / graphical displays). For this purpose, the master accesses the aDATA word array presented to the module. Word No. 0 1 2 ... 255 Data

For bit services (function code 0x01, 0x02, 0x0F), an offset can be specified by means of the parameter iBIT_OFFSET. When the bit services are used, the master only accesses the data from the specified offset address (word offset). Example: iBIT_OFFSET = 10 The master writes a bit (coil) to Address 2 using function code 0x0F. We can subsequently retrieve this bit from Bit 1 (counting method 0..15) of Word 10 (iBIT_OFFSET). This module supports the following Modbus functions

0x01 Read Coil Status 0x02 Read Input Status 0x03 Read Holding Registers 0x04 Read Input Registers 0x05 Force Single Coil 0x06 Preset Single Register 0x0F Force Multiple Coils 0x10 Preset Multiple Registers 0x17 Read / Write Multiple Registers

WAGO-I/O-PRO 32

Version 1.1.0

ModbusEthernet_04.lib - 15

ETHERNET_SERVER_OPEN_CLOSE

ETHERNET_SERVER_OPEN_CLOSE
WAGO-I/O-PRO 32 Library elements
Category: Name: Type: Library name: Requiered libraries Applicable to: Communications module ETHERNET_SERVER_OPEN_CLOSE Function Function block X Program ModbusEthernet_04.lib Ethernet.lib Fieldbus controller 750-842 from FW: 02.02.00(04) Fieldbus controller 750-841 Data type: BOOL WORD BOOL Comment: TRUE -> Open socket FALSE -> Close socket Port on which the server is to be accessed. TRUE -> Use TCP protocol FALSE -> Use UDP protocol Comment: = 0: no errors found <> 0: error in operation (see ETH_ERROR data type in Ethernet.lib for details) Handle on current socket

Input parameter: EN PORT TCP_PROTOKOLL

Return value: ERROR

Data type: WORD

SOCKET Graphical description:

WORD

Functional description: The ETHERNET_CLIENT_OPEN_CLOSE module is used by: ETHERNET_TERMINAL_MODBUSSLAVE

16 ModbusEthernet_04.lib

ml00101e

WAGO-I/O-PRO 32

Appendix A Additional libraries

typETH_SLAVE_DATEN (data type)


WAGO-I/O-PRO 32 Library elements
Category: Name: Type: Library name: typETH_SLAVE_DATEN Data type X Enumeration ModbusEthernet_04.lib

Element: Data type: Description: typETH_SLAVE_DATEN ARRAY[0..ETH_SIZE_SLAVEBUFFER] Word array for OF WORD user data

Declaration: TYPE typETH_SLAVE_DATEN : ARRAY[0..ETH_SIZE_SLAVEBUFFER] OF WORD; END_TYPE Description: The size of the field can be varied by "masking" the global constants ETH_SIZE_SLAVEBUFFER (default setting = 255).

WAGO-I/O-PRO 32

Version 1.1.0

ModbusEthernet_04.lib - 17

typSER_ModbusQuery (Data type)

typSER_ModbusQuery (Data type)


WAGO-I/O-PRO 32 Library Elements
Category: Name: Type: Name of library: Structure: Element: SlaveAdress FunctionCode StartAddress Quantity Data typSER_ModbusQuery Data type X Enumeration ModbusEthernet_04.lib

Data type: BYTE BYTE UINT UINT ARRAY [0..512] OF BYTE

Description Address of the slave being queried Modbus FunctionCode Target memory address of the information Quantity of information Information (only with write services)

Declaration:
TYPE typModbusQuery : STRUCT SlaveAddress : FunctionCode : StartAddress : Quantity : Data : END_STRUCT END_TYPE

BYTE; BYTE; UINT; UINT; ARRAY[0..124] OF WORD; (* Modbus specifies max. 125 words in one telegram *)

18 ModbusEthernet_04.lib

ml00101e

WAGO-I/O-PRO 32

Appendix A Additional libraries

typSER_ModbusResponse (Data Type)


WAGO-I/O-PRO 32 Library Elements
Category: Name: Type: Name of library: Structure: Element: Error SlaveAdress FunctionCode StartAddress Quantity Data typSER_ModbusResponse Data type X Enumeration ModbusEthernet_04.lib

Data type: WORD BYTE BYTE UINT UINT ARRAY [0..512] OF BYTE

Description Error code from slave Address of the slave being queried Modbus FunctionCode Target memory address of the information Quantity of information Information (only with read services)

Declaration:
TYPE typModbusResponse: STRUCT Error : SlaveAddress : FunctionCode : StartAddress : Quantity : Data : END_STRUCT END_TYPE

WORD; BYTE; BYTE; UINT; UINT; ARRAY[0..124] OF WORD; (* Modbus specifies max. 125 words in one telegram *)

WAGO-I/O-PRO 32

Version 1.1.0

ModbusEthernet_04.lib - 19

enumSER_MB_ERROR (Enumeration)

enumSER_MB_ERROR (Enumeration)
WAGO-I/O-PRO 32 Library Elements
Category: Name: Type: Name of library: Declaration:
TYPE enumSER_MB_ERROR :( SER_MB_NO_ERROR SER_MB_NOT_SUPPORTED_FUNCTION SER_MB_ILLEGAL_DATA SER_MB_EXTENDED_SLAVE_ERROR SER_MB_CRC_ERROR SER_MB_ILLEGAL_NUMBER_OF_POINTS SER_MB_OVERRUN SER_MB_TIME_OUT ); END_TYPE := := := := := := := := 16#00, 16#01, 16#03, 16#90, 16#96, 16#97, 16#98, 16#99

enumSER_MB_ERROR Data type Enumeration X ModbusEthernet_04.lib

20 ModbusEthernet_04.lib

ml00101e

WAGO-I/O-PRO 32

Potrebbero piacerti anche