Upload
crnoglavac
View
253
Download
1
Embed Size (px)
Citation preview
8/2/2019 ModbusEthernet_04
1/20
Appendix A Additional libraries
WAGO-I/O-PRO32 Version 1.1.0 ModbusEthernet_04.lib - 1
WAGO-I/O-PRO32 library
ModbusEthernet_04.lib
The ModbusEthernet_04.lib library provides the user with the two function
modules, ETHERNET_MODBUSMASTER_UDP andETHERNET_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
8/2/2019 ModbusEthernet_04
2/20
8/2/2019 ModbusEthernet_04
3/20
Appendix A Additional libraries
WAGO-I/O-PRO32 Version 1.1.0 ModbusEthernet_04.lib - 3
ModbusEthernet_04.lib
ETHERNET_MODBUSMASTER_UDP
WAGO-I/O-PRO32 Library elements
Category: Communications module
Name: ETHERNET_MODBUSMASTER_UDP
Type: Function Function block X Program
Library name: ModbusEthernet_04.lib
Requiered libraries Ethernet.lib
Applicable to: Fieldbus controller 750-842 from FW: 02.02.00(04)Fieldbus controller 750-841
Input parameter: Data type: Comment:
bUNIT_ID BYTE Fills the UnitId field in the Modbus protocolheader.
Use:
- References the slave ID in a serial Modbussub-network.
- Buffer index of the Modbus slave on thePC in conjunction with ActiveMBTSlaveCtl.
bFUNCTION_CODE BYTE The following Modbus function codes aresupported:
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
wREAD_ADDRESS WORD Modbus address in slave to be read.wREAD_QUANTITY WORD Number of bits or words to be read.
ptREAD_DATA POINTERTO BYTE
Pointer to the local data range in which theread data are stored.
wWRITE_ADDRESS WORD Modbus address in slave to be written.
wWRITE_QUANTITY WORD Number of bits or words to be written.
ptSEND_DATA POINTERTO BYTE
Pointer to the local data range in which thedata to be written are stored.
xSTART BOOL Initiate Modbus telegram
xRESET BOOL Reset internal data
tTIME_OUT TIME Maximum waiting time for the reply telegramfrom the Modbus slave.
8/2/2019 ModbusEthernet_04
4/20
ETHERNET_MODBUSMASTER_UDP
4 ModbusEthernet_04.lib ml00101e WAGO-I/O-PRO32
Return value: Data type: Comment:
xREADY BOOL Data transfer is complete or the waiting timeparameterised in tTIME_OUT has expired.
wERROR WORD 0x0000 Successful0x0001 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-Close0x0096 no valid Socket from FW
0x0097 Illegal number of points
0x0098 Internal buffer overrun
0x0099 - TimeOut
bRESPONSE_UNIT_ID BYTE Content of the UnitId field in the Modbusprotocol header of the reply telegram
Graphical description:
Functional description:With the ETHERNET_MODBUSMASTER_UDP module, an Ethernet controller becomes theModbus 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.
8/2/2019 ModbusEthernet_04
5/20
Appendix A Additional libraries
WAGO-I/O-PRO32 Version 1.1.0 ModbusEthernet_04.lib - 5
ETHERNET_MODBUSMASTER_TCP
WAGO-I/O-PRO32 Library elements
Category: Communications module
Name: ETHERNET_MODBUSMASTER_TCPType: Function Function block X Program
Library name: ModbusEthernet_04.lib
Requiered libraries Ethernet.lib
Applicable to: Fieldbus controller 750-842 from FW: 02.02.00(04)Fieldbus controller 750-841
Input parameter: Data type: Comment:
strIP_ADDRESS STRING IP address of Modbus slave.
bUNIT_ID BYTE Fills the UnitId field in the Modbus protocolheader.
Use:- References the slave ID in a serial Modbussub-network.
- Buffer index of the Modbus slave on thePC in conjunction with ActiveMBTSlaveCtl.
bFUNCTION_CODE BYTE The following Modbus function codes aresupported:
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
wREAD_ADDRESS WORD Modbus address in slave to be read.
wREAD_QUANTITY WORD Number of bits or words to be read.
ptREAD_DATA POINTERTO BYTE
Pointer to the local data range in which theread data are stored.
wWRITE_ADDRESS WORD Modbus address in slave to be written.
wWRITE_QUANTITY WORD Number of bits or words to be written.
ptSEND_DATA POINTERTO BYTE
Pointer to the local data range in which thedata to be written are stored.
xSTART BOOL Initiate Modbus telegram
xRESET BOOL Reset internal data
tTIME_OUT TIME Maximum waiting time for the reply telegramfrom the Modbus slave.
Example: t#500ms
8/2/2019 ModbusEthernet_04
6/20
ETHERNET_MODBUSMASTER_TCP
6 ModbusEthernet_04.lib ml00101e WAGO-I/O-PRO32
Return value: Data type: Comment:
xREADY BOOL Data transfer is complete or the waiting timeparameterised in tTIME_OUT has expired.
wERROR WORD 0x0000 Successful
0x0001 Illegal function code0x0002 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 overrun0x0099 TimeOut
bRESPONSE_UNIT_ID BYTE Content of the UnitId field in the Modbusprotocol 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 isnecessitated by the remote station. The Beijer E300 operating terminal, for example, supportsonly 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 protocoloverhead in terms of time.
8/2/2019 ModbusEthernet_04
7/20
Appendix A Additional libraries
WAGO-I/O-PRO32 Version 1.1.0 ModbusEthernet_04.lib - 7
ETHERNET_MODBUSMASTER_RTU
WAGO-I/O-PRO32 Library elements
Category: Communications module
Name: ETHERNET_MODBUSMASTER_RTUType: Function Function block X Program
Library name: ModbusEthernet_04.lib
Requiered libraries Ethernet.lib
Applicable to: Fieldbus controller 750-842 from FW: 02.02.00(04)Fieldbus controller 750-841
Input parameter: Data type: Comment:
SOCKET WORD
UNIT_ID BYTE Fills the UnitId field in the Modbus protocolheader.
Use:- References the slave ID in a serial Modbussub-network.
- Buffer index of the Modbus slave on thePC in conjunction with ActiveMBTSlaveCtl.
FUNCTION_CODE BYTE The following Modbus function codes aresupported:
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
READ_REFERENCE WORD Modbus address in slave to be read.
QUANTITY_TO_READ
WORD Number of bits or words to be read.
WRITE_REFERENCE
WORD Modbus address in slave to be written.
QUANTITY_TO_WRITE
WORD Number of bits or words to be written.
TIME_OUT TIME Maximum waiting time for the reply telegramfrom the Modbus slave.
Example: t#500ms
ptRECEIVE_BUFFER POINTERTOARRAY[1..3]
OF BYTE
Pointer to the local data range in which theread data are stored.
ptSEND_DATA POINTERTOARRAY[1..3]
OF BYTE
Pointer to the local data range in which thedata to be written are stored.
START_FUNCTION BOOL Initiate Modbus telegram
8/2/2019 ModbusEthernet_04
8/20
8 ModbusEthernet_04.lib ml00101e WAGO-I/O-PRO32
WAGO-I/O-PRO32 Library elements
RESET BOOL Reset internal data
Return value: Data type: Comment:
ERROR WORD 0x0000 Successful0x0001 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 points0x0098 Internal buffer overrun
0x0099 TimeOut
READY BOOL Data transfer is complete or the waiting timeparameterised in tTIME_OUT has expired.
RESPONSE_UNIT_ID BYTE Content of the UnitId field in the Modbusprotocol header of the reply telegram
Graphical description:
Functional description:
The ETHERNET_MODBUSMASTER_RTU module is used by:
- ETHERNET_MODBUSMASTER_UDP
- ETHERNET_MODBUSMASTER_TCP
8/2/2019 ModbusEthernet_04
9/20
Appendix A Additional libraries
WAGO-I/O-PRO32 Version 1.1.0 ModbusEthernet_04.lib - 9
MB_MASTER_SERIAL_OVER_TCP
WAGO-I/O-PRO32 Library Elements
Category: Communication modules
Name: MB_MASTER_SERIAL_OVER_TCPType: Function Function block X Program
Library Name: ModbusEthernet_04.lib
Libraries used Ethernet.lib
Mod_Com.lib
Applicable to: Fieldbus Controller 750-842 from FW: 02.02.00(04)
Fieldbus Controller 750-841
Inputparameter:
Data type: Comment:
strIP_ADDRESS
STRING IP address of Modbus slave.
iPORT WORD Port no. of Modbus slaveDefault -> 502
xCONNECT BOOL TRUE -> TCP connection is establishedpermanently
FALSE -> TCP connection is onlycontroled via StartFunction
tTIME_OUT TIME max. permissible response time of the slave
Input /output
parameters:
Data type: Comment:
StartFunction BOOL A TRUE at this parameter starts the service specified via"FunctionCode".It is automatically reset by the function block after theservice was performed.
Query typModbusQuery TYPE typSER_ModbusQuery :
STRUCT
SlaveAddress : BYTE;
FunctionCode : BYTE;
StartAddress : UINT;
Quantity : UINT;
Data : ARRAY[0..124]OF WORD;
END_STRUCTEND_TYPE
Response typModbusResponse
TYPE typSER_ModbusResponse :
STRUCT
Error : WORD;
SlaveAddress : BYTE;
FunctionCode : BYTE;
StartAddress : UINT;
Quantity : UINT;
Data : ARRAY[0..124]OF WORD;
END_STRUCTEND_TYPE
8/2/2019 ModbusEthernet_04
10/20
MB_MASTER_SERIAL_OVER_TCP
10 ModbusEthernet_04.lib ml00101e WAGO-I/O-PRO32
WAGO-I/O-PRO32 Library Elements
Outputparameter:
Data type: Comment:
MB_Error enumSER_MB_ERROR
Error codeTYPE 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 aprogrammable Ethernet controller to that of a serial MODBUS master, communicating viaEthernet 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 theStartFunction input and is then automatically terminated after the task has been carried out.
Supported MODBUS services:0x01 Read Coil Status0x02 Read Input Status0x03 Read Holding Register
0x04 Read Input Registers0x05 Force Single Coil0x06 Preset Single Registers0x0B Fetch Comm Event Ctr0x0F Force Multiple Coils0x10 Preset Multiple Registers
8/2/2019 ModbusEthernet_04
11/20
Appendix A Additional libraries
WAGO-I/O-PRO32 Version 1.1.0 ModbusEthernet_04.lib - 11
WAGO-I/O-PRO32 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.
8/2/2019 ModbusEthernet_04
12/20
ETHERNET_CLIENT_OPEN_CLOSE
12 ModbusEthernet_04.lib ml00101e WAGO-I/O-PRO32
ETHERNET_CLIENT_OPEN_CLOSE
WAGO-I/O-PRO32 Library elements
Category: Communications module
Name: ETHERNET_CLIENT_OPEN_CLOSEType: Function Function block X Program
Library name: ModbusEthernet_04.lib
Requiered libraries Ethernet.lib
Applicable to: Fieldbus controller 750-842 from FW: 02.02.00(04)Fieldbus controller 750-841
Input parameter: Data type: Comment:
EN BOOL TRUE -> Open socket
FALSE -> Close socket
IP STRING IP address of remote station
(Modbus slave)PORT WORD Port number of remote station
(Modbus slave)
TCP_PROTOKOLL BOOL TRUE -> Use TCP protocol
FALSE -> Use UDP protocol
Return value: Data type: Comment:
ERROR WORD = 0: no errors found
0: error in operation (see ETH_ERRORdata type in Ethernet.lib for details)
SOCKET WORD Handle on current socket
Graphical description:
Functional description:
The ETHERNET_CLIENT_OPEN_CLOSE module is used by:
- ETHERNET_MODBUSMASTER_UDP
- ETHERNET_MODBUSMASTER_TCP
8/2/2019 ModbusEthernet_04
13/20
Appendix A Additional libraries
WAGO-I/O-PRO32 Version 1.1.0 ModbusEthernet_04.lib - 13
IP_ADRESSE
WAGO-I/O-PRO32 Library elements
Category: Communications module
Name: IP_ADRESSEType: Function X Function block Program
Library name: ModbusEthernet_04.lib
Requiered libraries Ethernet.lib
Applicable to: Fieldbus controller 750-842 from FW: 02.02.00(04)Fieldbus controller 750-841
Input parameter: Data type: Comment:
IP_ADR STRING IP address of remote station
(Modbus slave)
Return value: Data type: Comment:IP_ADR WORD IP address of remote station (numeric)
Graphical description:
Functional description:
The module converts an IP address
The module is used by:- ETHERNET_MODBUSMASTER_UDP- ETHERNET_MODBUSMASTER_TCP- ETHERNET_CLIENT_OPEN_CLOSE
8/2/2019 ModbusEthernet_04
14/20
ETHERNET_TERMINAL_MODBUSSLAVE
14 ModbusEthernet_04.lib ml00101e WAGO-I/O-PRO32
ETHERNET_TERMINAL_MODBUSSLAVE
WAGO-I/O-PRO32 Library elementsCategory: Communications module
Name: ETHERNET_TERMINAL_MODBUSSLAVE
Type: Function Function block X Program
Library name: ModbusEthernet_04.lib
Requiered libraries Ethernet.lib
Applicable to: Fieldbus controller 750-842 from FW: 02.02.00(04)Fieldbus controller 750-841
Input parameter: Data type: Comment:
EN BOOL TRUE -> Activate Modbus server
iPORT INT Port on which the Modbus server is to beaccessed.
TCP_PROTOKOLL BOOL TRUE -> TCP server
FALSE -> UDP server
iBIT_OFFSET INT Address from which Modbus bit servicesaccess the data array
tWATCHDOG_TIME TIME The watchdog is started with the firsttelegram from the master. A check is madeas to whether the master sends telegramsregularly. If the master drops out, i.e. thewatchdog triggers, the xWATCHDOG_OKoutput is reset.
Input/Output parameter: Data type: Comment:
aDATA typETH_SLAVE_DATEN
WORD ARRAY [0..ETH_SIZE_SLAVEBUFFER]
Output parameter: Data type: Comment:
xWATCHDOG_OK BOOL Master is sending telegrams.
wERROR WORD 0x0000 No error
0x0001 Unsupported function code
0x0002 Illegal address from master
0x0003 Illegal data from master
Graphical description:
8/2/2019 ModbusEthernet_04
15/20
Appendix A Additional libraries
WAGO-I/O-PRO32 Version 1.1.0 ModbusEthernet_04.lib - 15
WAGO-I/O-PRO32 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 themodule.
For bit services (function code 0x01, 0x02, 0x0F), an offset can be specified by meansof the parameteriBIT_OFFSET.
When the bit services are used, the master only accesses the data from the specifiedoffset address (word offset).
Example: iBIT_OFFSET = 10The 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) ofWord 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
Word No. Data
0
1
2
...
255
8/2/2019 ModbusEthernet_04
16/20
ETHERNET_SERVER_OPEN_CLOSE
16 ModbusEthernet_04.lib ml00101e WAGO-I/O-PRO32
ETHERNET_SERVER_OPEN_CLOSE
WAGO-I/O-PRO32 Library elements
Category: Communications module
Name: ETHERNET_SERVER_OPEN_CLOSEType: Function Function block X Program
Library name: ModbusEthernet_04.lib
Requiered libraries Ethernet.lib
Applicable to: Fieldbus controller 750-842 from FW: 02.02.00(04)Fieldbus controller 750-841
Input parameter: Data type: Comment:
EN BOOL TRUE -> Open socket
FALSE -> Close socket
PORT WORD Port on which the server is to be accessed.
TCP_PROTOKOLL BOOL TRUE -> Use TCP protocolFALSE -> Use UDP protocol
Return value: Data type: Comment:
ERROR WORD = 0: no errors found
0: error in operation (see ETH_ERRORdata type in Ethernet.lib for details)
SOCKET WORD Handle on current socket
Graphical description:
Functional description:
The ETHERNET_CLIENT_OPEN_CLOSE module is used by:- ETHERNET_TERMINAL_MODBUSSLAVE
8/2/2019 ModbusEthernet_04
17/20
Appendix A Additional libraries
WAGO-I/O-PRO32 Version 1.1.0 ModbusEthernet_04.lib - 17
typETH_SLAVE_DATEN (data type)
WAGO-I/O-PRO32 Library elements
Category:
Name: typETH_SLAVE_DATENType: Data type X Enumeration
Library name: ModbusEthernet_04.lib
Element: Data type: Description:
typETH_SLAVE_DATEN ARRAY[0..ETH_SIZE_SLAVEBUFFER]OF WORD
Word array foruser 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 constantsETH_SIZE_SLAVEBUFFER (default setting = 255).
8/2/2019 ModbusEthernet_04
18/20
typSER_ModbusQuery (Data type)
18 ModbusEthernet_04.lib ml00101e WAGO-I/O-PRO32
typSER_ModbusQuery (Data type)
WAGO-I/O-PRO32 Library Elements
Category:
Name: typSER_ModbusQueryType: Data type X Enumeration
Name of library: ModbusEthernet_04.lib
Structure:
Element: Data type: Description
SlaveAdress BYTE Address of the slave being queried
FunctionCode BYTE Modbus FunctionCode
StartAddress UINT Target memory address of theinformation
Quantity UINT Quantity of information
Data ARRAY [0..512]OF BYTE
Information(only with write services)
Declaration:
TYPE typModbusQuery :
STRUCT
SlaveAddress : BYTE;
FunctionCode : BYTE;
StartAddress : UINT;
Quantity : UINT;
Data : ARRAY[0..124] OF WORD; (* Modbus specifies max.125 words in one telegram *)
END_STRUCTEND_TYPE
8/2/2019 ModbusEthernet_04
19/20
Appendix A Additional libraries
WAGO-I/O-PRO32 Version 1.1.0 ModbusEthernet_04.lib - 19
typSER_ModbusResponse (Data Type)
WAGO-I/O-PRO32 Library Elements
Category:
Name: typSER_ModbusResponseType: Data type X Enumeration
Name of library: ModbusEthernet_04.lib
Structure:
Element: Data type: Description
Error WORD Error code from slave
SlaveAdress BYTE Address of the slave being queried
FunctionCode BYTE Modbus FunctionCode
StartAddress UINT Target memory address of theinformation
Quantity UINT Quantity of information
Data ARRAY [0..512]OF BYTE
Information(only with read services)
Declaration:TYPE typModbusResponse:
STRUCT
Error : WORD;
SlaveAddress : BYTE;
FunctionCode : BYTE;
StartAddress : UINT;
Quantity : UINT;
Data : ARRAY[0..124] OF WORD; (* Modbus specifies max.125 words in one telegram *)
END_STRUCT
END_TYPE
8/2/2019 ModbusEthernet_04
20/20