|
|
|
|
Modbus - The Universal Industrial Protocol?
The following description gives an overview of the protocol and some of the points to consider when connecting dissimilar equipment using Modbus. Master / Slave FunctionalityModbus is a Master / slave protocol. A number of devices may be interconnected using the protocol, but only one device can be the master. Communications is always instigated and controlled by the master device. All other devices are connected as slaves and will only communicate in response to requests or commands from the single master. The protocol provides for one master device and up to 247 slave devices on a common line. Each device is assigned an address to distinguish it from all other connected devices. This simple structure ensures the protocol overhead is kept to a minimum. Device addressing is simple. Methods of CommunicationThe original Modbus protocol was designed for use with serial communications devices using RS-232 or RS-485. RS-232 is normally restricted to single slave, short distance communications, whereas RS-485 is better when distance and / or multiple slaves are required. Modbus Plus was introduced by Modicon as a global fieldbus network to enable faster (2 MBit/s) communications between multiple (up to 32) devices. A token passing topology is used over an RS485 interconnection. Modbus TCP/IP takes the original protocol and structures it for use over Ethernet using the TCP/IP protocols. This is done in such a way as to minimise implementation changes to software developers and has resulted in a large number of devices quickly supporting the protocol. Modbus TCP/IP allows concurrent master / slave operation. For simple non-networked implementations, the original protocol is fine. For larger, distributed systems, especially where Ethernet may already be installed, Modbus TCP/IP has many advantages. Be aware however, that Modbus TCP/IP installations will only be as good / reliable as the underlying network! Protocol versionsModbus devices can communicate using either of two versions of the Modbus protocol, RTU (Remote Terminal Unit) or ASCII (American Standard Code for Information Interchange). RTU is a binary format requiring the least number of characters for transmission, whereas ASCII uses only text readable characters requiring more per message and is thus slower. Some devices will only support one or the other. All connected devices should be configured to the same version Modbus TCP/IP does not have the ASCII option. Some proprietary 'versions' define additional data types / uses such as Enron / Daniels which define methods of passing 32 bit integer and floating point values (see Compatibility between devices below). Note that these are still RTU or ASCII based however. Protocol DetailsData EncodingMODBUS uses a ‘big-Endian’ representation for addresses and data items. This means that when a numerical quantity larger than a single byte is transmitted, the most significant byte is sent first (see Compatibility between devices below). Data ModelMODBUS bases its data model on a series of tables that have distinguishing characteristics. The four primary tables are:
The distinctions between inputs and outputs, and between bit-addressable and word-addressable data items, do not imply any application behaviour. It is perfectly acceptable, and very common, to regard all four tables as overlaying one another, if this is the most natural interpretation on the target machine in question. For each of the primary tables, the protocol allows individual selection of 65536 data items, and the operations of read or write of those items are designed to span multiple consecutive data items up to a data size limit which is dependent on the transaction function code. It’s obvious that all the data handled via MODBUS (bits, registers) must be located in device application memory. But physical address in memory should not be confused with data reference. The only requirement is to link data reference with physical address. MODBUS logical reference number, which are used in MODBUS functions, are unsigned integer indices starting at zero. It is worth noting at this point that only single bit and 16 bit words are defined object types for data access (ASCII characters are also included in diagnostic messages). How the words are interpreted / combined is not defined in the protocol definition (see Compatibility between devices below). AddressingModbus can address 65536 separate addresses. Function CodesPublic Function Codes
User-Defined Function Codes
Reserved Function Codes
Compatibility between devicesSome implementations deviate and / or extend on the defined protocol. Examples include alternate byte / word ordering and other data types. This can lead to problems unless all interconnected master and slave devices support the variations. To guarantee communications between devices using Modbus, several checks should be made:
Modbus Support in Hexatec SoftwareHexatec software fully supports the Modbus protocol. Hexatec Saturn and SCAN1000 supports both Master and Slave functionality allowing it to be interconnected with a wide range of Modbus communication equipment. The product is available with a wide range of options. |