• No results found

WagoLibModbus_IP_01.lib

N/A
N/A
Protected

Academic year: 2021

Share "WagoLibModbus_IP_01.lib"

Copied!
7
0
0

Loading.... (view fulltext now)

Full text

(1)

WAGO-I/O-

PRO

CAA library

WagoLibModbus_IP_01.lib

The library WagoLibModbus_IP_01.lib contains two function blocks:

ETHERNET_MODBUSMASTER_UDP and

ETHERNET_MODBUSMASTER_TCP

Using this function blocks communication with one or more slaves can be

established.

It is recommended to use the function block

ETHERNET_MODBUSMASTER_UDP since data exchange can be handled

more quickly than using the TCP block.

Content

WagoLibModbus_IP_01.lib 3

ETHERNET_MODBUSMASTER_UDP... 3

ETHERNET_MODBUSMASTER_TCP ... 5

(2)
(3)

WagoLibModbus_IP_01.lib

ETHERNET_MODBUSMASTER_UDP

WAGO-I/O-

PRO

CAA Library elements

Category: Communication

Name: ETHERNET_MODBUSMASTER_UDP

Type: Function Function block X Program

Library : WagoLibModbus_IP_01.lib

Requiered libraries SysLibSocket.lib

Applicable to: 750-841(Release 07), 758-870(Release01)

Input: Data type: Comment:

xOPEN_SOCKET BOOL Opens a socket on the client strIP_ADDRESS STRING IP address of server

wPORT WORD Port

bUNIT_ID BYTE -According to the “UnitId” in protocol header -Slave-ID in a serial modbus network - Buffer index of modbus slave on a PC according to example ActiveMBTSlaveCtl. bFUNCTION_CODE BYTE Supported function codes

0x1: Read Coil Status 0x2: Read Input Status 0x3: Read Holding Registers 0x4: Read Multiple Register 0x5: Force Single Coil 0x6: Write Single Register 0x7: Read Exception Status 0x0F: Write Multiple Coils 0x10: Write Multiple Register

0x17: Read and Write Multiple Registers wREAD_ADDRESS WORD Start address for reading commands. wREAD_QUANTITY WORD Number of data for reading.

ptREAD_DATA POINTER

TO BYTE Pointer to array, where the read data will be stored. wWRITE_ADDRESS WORD Start address for writing commands. wWRITE_QUANTITY WORD Number of data for writing

ptSEND_DATA POINTER

TO BYTE Pointer to array, where the data, which shall be written, are placed. tTIME_OUT TIME Time within the slave ought to respond to

the request.

InOut: Data type: Comment:

xSEND BOOL Send modbus request. This variable will be reset by the functionblock.

(4)

WAGO-I/O-

PRO

CAA Library elements

xIS_OPEN BOOL Socket is created on the client. Client ready to send modbus request.

wERROR WORD 0x0000 – Succesful

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 respond 0x0079 – no socket available

0x0097 – Illegal number of points 0x0098 – Internal buffer overrun 0x0099 - TimeOut

bRESPONSE_UNIT_ID BYTE According to the “UnitId” in protocoll header

Graphical description:

Description:

Using ETHERNET_MODBUSMASTER_UDP the IPC becomes a Modbus-Master. First a socket has to be opened by the input xOPEN_SOCKET. If the socket could be opend the output xIS_OPEN will show TRUE. Otherwise the wERROR output will display 0x79. Modbus requests can be send by setting the IN_OUT variable xSEND to True. The function block will reset this variable after execution of the command.

If the slave does not respond within the time tTIME_OUT error code 0x99 will be displayed. The function block ETHERNET_MODBUSMASTER_UDP uses UDP as protocoll(User Datagramm Protocoll) This allows quicker data exchange than using TCP protocoll.

(5)

ETHERNET_MODBUSMASTER_TCP

WAGO-I/O-

PRO

CAA Library elements

Category: Communikation

Name: ETHERNET_MODBUSMASTER_TCP

Type: Function Function block X Program

Name of library: WagoLibModbus_IP_01.lib

Requiered libraries SysLibSocket.lib

Applicable to: 750-841(Release 07), 758-870(Release01)

Input: Data type: Comment:

xCONNECT BOOL Establishes the connection to the server strIP_ADDRESS STRING IP address of server

wPORT WORD Port

bUNIT_ID BYTE -According to the “UnitId” in protocoll header -Slave-ID in a serial modbus network - Buffer index of modbus slave on a PC according to example ActiveMBTSlaveCtl. bFUNCTION_CODE BYTE Supported function codes

0x1: Read Coil Status 0x2: Read Input Status 0x3: Read Holding Registers 0x4: Read Multiple Register 0x5: Force Single Coil 0x6: Write Single Register 0x7: Read Exception Status 0x0F: Write Multiple Coils 0x10: Write Multiple Register

0x17: Read and Write Multiple Registers wREAD_ADDRESS WORD Start address for reading commands. wREAD_QUANTITY WORD Number of data for reading.

ptREAD_DATA POINTER TO BYTE

Pointer to array, where the read data will be stored.

wWRITE_ADDRESS WORD Start address for writing commands. wWRITE_QUANTITY WORD Number of data for writing

ptSEND_DATA POINTER

TO BYTE Pointer to array, where the data, which shall be written, are placed. tTIME_OUT TIME Time within the slave ought to respond to

the modbus request.

tCON_WATCHDOG TIME Time within the server ought to respond if the connection is to be established.

(6)

InOut: Data type: Comment:

xSEND BOOL Send modbus request. This variable will be reset by the functionblock.

Output: Data type: Comment:

xIS_CONNECTED BOOL Connection to the server is established. wERROR WORD 0x0000 – Succesful

0x0001 – Illegal function code 0x0002 – Illegal data address 0x0003 – Illegal data value 0x0004 – Slave device failure 0x0005 – Acknoledge

0x0006 – Slave device busy 0x0007 – Negative acknowledge 0x0008 – Memory parity error 0x000A – Gateway path unaviable 0x000B – Gateway target norespond 0x0079 – No socket available

0x0080 – Can not send modbus request 0x0096 – Server not available

0x0097 – Illegal number of points 0x0098 – Internal buffer overrun 0x0099 - TimeOut

bRESPONSE_UNIT_ID BYTE According to the “UnitId” in protocoll header

Graphical description:

(7)

Using ETHERNET_MODBUSMASTER_TCP the IPC becomes a Modbus-Master. Number of slaves is only limited by the modbus protocoll.

The function block ETHERNET_MODBUSMASTER_TCP uses TCP as protocoll. The function block ETHERNET_MODBUSMASTER_TCP is recommended to use, if the modbus slave only supports TCP protocoll rather than UDP.

Warning: This function block may block on the 750-841. It is therefore strongly recommended to use this function block in an own task.

References

Related documents