Automazione

Páginas: 11 (2703 palabras) Publicado: 19 de junio de 2012
User Documentation: CoDeSys V2.3 Library ModBusUDP.lib
Document Version 1.2

tech_doc_e.doc / V1.2

 3S - Smart Software Solutions GmbH ModBus Lib Description UDP.doc

Page 1 of 9

Library ModBusUDP.lib

CONTENT 1 2 GENERAL INFORMATION USING THE LIBRARY
2.1 2.2 2.3 2.4 2.5 2.6 2.7 The program CyclicReceive The function block ModBusReadCoils The function blockModBusReadMultipleRegisters The function block ModBusWriteCoils The function block ModBusWriteMultipleRegisters The function block GetCommEventCounter The function block ModBusReadWriteMultipleRegisters

3 4
4 4 5 5 6 6 7

3

THE EXAMPLE MODBUSUDP_TEST.PRO

8 9

CHANGE HISTORY

tech_doc_e.doc / V1.2

 3S - Smart Software Solutions GmbH ModBus Lib Description UDP.doc

Page 2 of 9

LibraryModBusUDP.lib

1

General information

The MODBUS Protocol is a client-server communication protocol for the simple exchange of data between intelligent devices. It was developed by MODICON in 1979 and has established itself as an industrial standard. The library MODBUS_UDP.lib has been implemented for the programming system „CoDeSys“ from 3S – Smart Software Solutions GmbH. It is described in thedocuments MODBUS MESSAGING ON TCP/IP IMPLEMENTATION GUIDE 1.0 and the protocol specification „Modicon Modbus Protocol Reference Guide“,

which are both available for download on the web page www.modbus.org. The library implements the functions FC1 Read Coil Status FC3 Read Holding Registers FC15 Force Multiple Coils (Write Coils) FC16 Preset Multiple Registers (Write Multiple Registers) FC11 FetchComm Event Counter

All other functions of the protocol specification were not implemented in this version of the library. (They are needed fairly seldom and can partly be replaced by the implemented functions.) The MODBUS library is based on the libraries SysLibSockets.lib (TCP/UDP-connections) and the SysLibCallbacks.lib (system calls). Both are delivered along with a 3S runtime system (e.g.CoDeSys SP).

tech_doc_e.doc / V1.2

 3S - Smart Software Solutions GmbH ModBus Lib Description UDP.doc

Page 3 of 9

Library ModBusUDP.lib

2

Using the library

In order to be able to use the MODBUS library in a CoDeSys application (PLC program) it has to be inserted in CoDeSys. To do so open the library manager and choose “insert -> Additional library…“. Then select theModBusUDP.lib. The system libs “SysLibCallback“ and “SysLibSockets“ are then automatically inserted. Only the function blocks and the program “CyclicReceive“ of the library may be used by the application. All other functions are used internally by the library itself as only the library can make sensible use of them.

2.1

The program CyclicReceive

The program CyclicReceive must be called cyclicallyby the application. This means the user has to write: “CyclicReceive()“ into the POU connected to the task which manages the MODBUS communication (if no task configuration is used, this is done by PLC_PRG). This POU receives the telegrams of the other MODBUS devices in the network and distributes them among the callers (the function blocks of the library).

2.2

The function blockModBusReadCoils

The function block ReadCoils implements the MODBUS function FC1 (ReadCoilStatus). The following parameters are passed at the inputs of the POUs listed below: The target address of the MODBUS user to whom the query is to be sent. The address is passed as a 32-bit value so that the 4-byte IP address of the user is written in the 4 bytes of the DWORD. The IP address “192.168.100.32“ for exampleis passed as 16#C0A86420. (C0 in hexadecimal is 192 in decimal and so on) The target port of the recipient used to receive the telegram. Port No. 502 is defined as the standard port in the MODBUS protocol specification and has to be supported by all MODBUS devices. This means the constant 502 is passed here under normal circumstances. The start address from which BitCount bits are read from the...
Leer documento completo

Regístrate para leer el documento completo.

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS