Modbus RTU Slave Interface: X-Gateway Interface Addendum
Modbus RTU Slave Interface: X-Gateway Interface Addendum
HMS Industrial Networks AB Germany + 49 - 721 - 96472 - 0 Japan + 81 - 45 - 478 -5340 Sweden + 46 - 35 - 17 29 20 U.S.A + 1 - 773 - 404 - 3486
Table of Contents
Table of Contents
Preface About This Document
How To Use This Document ............................................................................................................ P-1 Important User Information .............................................................................................................. P-1 Related Documents.............................................................................................................................. P-2 Document History ............................................................................................................................... P-2 Conventions & Terminology.............................................................................................................. P-3 Support .................................................................................................................................................. P-3
Chapter 1
Chapter 2
Chapter 3
Data Exchange
General Information.............................................................................................................................3-1 Modbus Exceptions ..............................................................................................................................3-1 Coil & Register Map .............................................................................................................................3-2 Modbus Diagnostics .............................................................................................................................3-2
Preface
Warning:
This is a class A product. In a domestic environment this product may cause radio interference in which case the user may be required to take adequate measures. This product contains ESD (Electrostatic Discharge) sensitive parts that may be damaged if ESD control procedures are not followed. Static control precautions are required when handling the product. Failure to observe this may cause damage to the product.
ESD Note:
Related Documents
Document name Anybus X-gateway User Manual Anybus-S Modbus RTU Fieldbus Appendix Author HMS HMS -
Document History
Summary of Recent Changes (v1.03... v1.11)
Change Rewrote chapters: - P-1 Preface - Chapter 1 - About the Modbus RTU Slave Interface - Chapter 3 - Data Exchange Updated Chapter 2 Installation and Configuration - added section Gateway Config Interface Removed redundant chapter Modbus Diagnostics and Error Handling (merged with Chapter 3) Removed redundant information about Parameter Data (not applicable on Modbus RTU) Misc. minor corrections Page(s) P-1... P-3 1-1... 1-2 3-1... 3-2 2-3 -
Revision List
Revision 1.00 1.02 1.03 1.10 1.11 Date 2004-03-10 2006-05-31 2007-04-02 2007-12-03 2008-05-21 Author(s) PeP PeP PeP PeP PeP Chapter(s) All 1, 2 A P, 1, 2, 3 Description First release Minor update Minor update Major rewrite Minor update -
Support
HMS Sweden (Head Office) E-mail: Phone: Fax: Online: HMS America E-mail: Phone: Toll Free: Fax: Online: HMS Germany E-mail: Phone: Fax: Online: HMS Japan E-mail: Phone: Fax: Online: [email protected] +81-45-478-5340 +81-45-476-0315 www.anybus.com [email protected] +49-721-96472-0 +49-721-964-7210 www.anybus.com [email protected] +1-773-404-2271 888-8-Anybus +1-773-404-1797 www.anybus.com [email protected] +46 (0) 35 - 17 29 20 +46 (0) 35 - 17 29 09 www.anybus.com
Chapter 1
Output Buffer This buffer is forwarded to the other network, and can be both read and written by the Modbus Master. Note however that the unidirectional nature of the X-gateway means it will still only be forwarded to the other network, never the other way around (for that purpose, use registers associated with the Input Buffer instead).
Input Buffer
(from Gateway)
Features
Modbus-RTU compliant, passive slave node operation Modbus diagnostics Up to 256 Modbus registers in each direction RS485 or RS232 operation Baudrates from 1200bps to 57600bps On-board configuration switches Galvanically isolated bus electronics
External View
Modbus RTU Status LEDs
LED Colour Indication Processing Green Processing message Off Not processing Bus Error Red Bus error Off Normal operation Bus Ready Green Normal operation Red Bus timeout error off Bus not running HW Status Red Configuration switch error Off Gateway Status (Consult the user manual for further details)
Top mounted Slave interface Processing Bus Error Bus Ready HW Status Gateway Status
1 2
3 4
1 2 3
Chapter 2
In this example, the Modbus node ID will be 42. Note: Depending on if the Slave interface is top or bottom mounted, the orientation of the switches are different.
Baudrate Configuration
The standard baudrate of Modbus RTU is 19.2kbit/s. The Slave interface does however allow baudrates from 1.2kbit/s to 57.6kbit/s to be selected via the baudrate switches. The switches are read once during startup, i.e. the gateway must be restarted for any changes to have effect.
Switch 1-7a Switch 8 OFF OFF OFF OFF ON ON ON ON Switch 1 OFF OFF ON ON OFF OFF ON ON Switch 2 OFF ON OFF ON OFF ON OFF ON Switch 3b Switch 4b Baudrate (invalid) 1.2kbit/s 2.4kbit/s 4.8kbit/s 9.6kbit/s 19.2kbit/s (standard) 38.4kbit/s 57.6kbit/s
a. These switches are used for Node ID configuration, see previous section. b. This switch is used for Parity configuration, see next section.
OFF
In this example, the baudrate will be 1.2kbit/s. Note: Depending on if the Slave interface is top or bottom mounted, the orientation of the switches are different.
OFF ON
Example:
Example:
Physical Interface
The Slave interface supports RS232 and RS485 communication standards.
Switch 1a Switch 2a Switch 3b Switch 4b Switch 5 OFF ON Physical Interface RS485 RS232
a. See 2-1 Baudrate Configuration b. See 2-2 Parity and Stop Bits Configuration
Network Termination
The end nodes of a RS485-based Modbus RTU network must be terminated in order to avoid reflections on the bus line. The Slave interface features a termination switch, which is used to enable internal termination resistors.
Switch Position OFF ON Internal Termination Disabled Enabled
The figure below shows the connection and the values of the internal termination and bias resistors. If the values does not match the network termination convention, external termination must be used.
5V 390R RS485 Line A 120R RS485 Line B 390R GND
ON
Example:
OFF ON
Example:
Input I/O data size (bytes) Specifies the amount of Input Data to exchange on Modbus-RTU.
Output I/O data size (bytes) Specifies the amount of Output Data to exchange on Modbus-RTU.
Offline option (Consult the Anybus X-gateway User Manual for further information).
Control / Status word This settings enables/disables representation of the Control/Status word on Ethernet. (Consult the Anybus X-gateway User Manual for further information).
See also... 3-1 Data Exchange 3-2 Coil & Register Map
Chapter 3
Data Exchange
General Information
The Slave Interface acts as a passive node and as such it responds to incoming Querys and accepts broadcast messages. It will not initiate communication autonomously. In the Anybus implementation, several Modbus functions are associated with the very same data. While this may appear confusing at first, it allows data to be manipulated in a very flexible manner (e.g. it is possible to manipulate individual bits of a register by accessing coils associated with the same memory location). The following functions can be used to access data in the Slave Interface:
Modbus Function Read Coil Read Input Discretes Read Holding Registers Read Input Registers Write Coil Write Single Register Force Multiple Coils Force Multiple Registers Mask Write Register Read/Write Registers Function Code 1 2 3 4 5 6 15 16 22 23 Direction Gateway to Modbus Associated with Buffer Input- and Output Buffers
Modbus to Gateway
Output Buffer
Bidirectional
Modbus Exceptions
With the exception of broadcast messages, the Modbus Master expects its slaves to respond within a certain defined time period. If no response is received (e.g. due to a transmission error), this eventually triggers a timeout condition in the Master. If the Slave Interface receives a Query from the Master, but for some reason is unable to process it (e.g. the Master tries to access a non-existent Register), an Exception is returned to inform the Master of the nature of the problem. The Slave Interface may issue the following Exception responses:
# 01h 02h 03h Meaning Illegal Function Illegal Data Address Illegal Data Value Description The Query contains an illegal or unsupported function call The Query contains an illegal data address The Query contains invalid data
(reserved) Applicable Modbus functions: - Read Coil - Read Input Discretes - Read Holding Registers - Read Input Registers - Write Coil - Write Single Register - Force Multiple Coils - Force Multiple Registers - Mask Write Register - Read/Write Registers (reserved)
Note: Coils are mapped MSB first, i.e. coil 0 corresponds to bit 15 of register 0.
Modbus Diagnostics
The Modbus RTU interface features several diagnostic counters which increments each time the interface encounters certain pre-defined events. These counters may provide valuable clues when troubleshooting the Modbus communication, and can be accessed through the standard Modbus Diagnostic function (function code 08h). The following sub-functions are implemented:
# Meaning 00h Return Query Data Description Loopback; instructs the slave to return the data from the Query
0Ah Clear Counters and Diagnostic Register Clears all diagnostic counters 0Ch Return Bus Communication Error Count Returns the no. of detected CRC-errors 0Dh Return Bus Exception Error Count 0Eh Return Slave Message Count Returns the no. of exception responses previously returned by the slave Returns the number of messages addressed to the slave interface (broadcast included)
Appendix A
Technical Specification
Modbus RTU Interface Details
Media: Cable: Topology: Isolation: Baudrates: RS485 or RS232 (specified via on-board switches) Shielded copper cable, twisted pair Master-slave communication Galvanically isolated bus electronics 1.2kbit/s - 57.6kbit/s (specified via on-board switches)
Node ID Range: 1 - 127 (specified via on-board switches) Data size: Up to 256 registers in each direction
Implemented Functions: 01h - Read Coil 02h - Read Input Discretes 03h - Read Holding Registers 04h - Read Input Registers 05h - Write Coil 06h - Write Single Register 08h - Diagnostics (Sub-functions 0,10,12,13 and 14) 0Fh - Force Multiple Coils 10h - Force Multiple Registers 16h - Mask Write Register 17h - Read/Write Registers
5 (female) 1
a. These pins can be used to power external bias/termination circuitry, or external equipment such as media converters etc. The maximum current consumption of such equipment must not exceed 50mA.