Anda di halaman 1dari 16

Instruction manual Modbus protocol Enraf gauges

February 2003 Part no.: 4416.513_Rev0

Enraf B.V. P.O. Box 812 2600 AV Delft Netherlands Tel. Fax E-mail Home page : +31 15 2698600 : +31 15 2619574 : info@enraf.nl : http://www.enraf.com

Instruction manual Modbus protocol Enraf gauges

Page 1

Copyright 2003 Enraf B.V. All rights reserved. Reproduction in any form without the prior consent of Enraf B.V. is not allowed. This manual is for information only. The contents, descriptions and specifications are subject to change without notice. Enraf B.V. accepts no responsibility for any errors that may appear in this manual. The warranty terms and conditions applicable in the country of purchase in respect to Enraf B.V. products are available from your supplier. Please retain them with your proof of purchase.

Page 2

Preface

Preface
This manual describes the Modbus protocol, used in the Enraf servo gauges type 854, the series SmartRadar gauges and the field indicator model 877 FDI. The document is intended for a control technician that is experienced and trained in setting up a Standard Modbus interface. For installation and commissioning of the Enraf gauges, please refer to the Installation guides and Instruction manuals of the related instrument. Refer also to the list of related documents in Appendix B. A description preceding the technical procedures gives the technical information necessary to understand its functioning. It is recommended to read this description prior to performing any of the procedures. Communication Modbus communication can only be performed via the optional RS-232C / RS-485 communication channel. Then it is not possible to connected an optional analog level output (4 - 20 mA). Also the standard Enraf field bus communication is not available. There cannot be connected a 977 TSI Tank Side Indicator to the 854 servo gauges, 873 SmartRadar and 877 FDI, however a 977 TSI can be connected to the 970, 971 and 973 SmartRadar LT series. Safety and prevention of damage "Notes" are used throughout this manual to bring special matters to the immediate attention of the reader. A Note points out a statement deserving more emphasis than the general text. Legal aspects The information in this manual is the copyright property of Enraf B.V., Netherlands. Enraf B.V. accepts no responsibility for any errors that may appear in this manual. Additional information Please do not hesitate to contact Enraf or its representative if you require additional information.

Instruction manual Modbus protocol Enraf gauges

Page 3

Table of contents

Table of contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1 2 3 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Setup for Modbus RTU mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Modbus protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 3.1 Communication parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 3.2 Communication procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 3.3 Function codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3.3.1 Function code 03 Read holding registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3.3.2 Function code 05 Force single coil . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3.4 Memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3.5 On-line switch in Modbus mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Modbus register contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.1 ProductLevel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.2 ProductLevelStatus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.3 ProductLevelAlarms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4 WaterLevel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.5 WaterLevelStatus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.6 ProductTemp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.7 ProductTempStatus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.8 VapRoomTemp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.9 VapRoomTempStatus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.10 VapRoomPress . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.11 VapRoomPressStatus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.12 ObsDensity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.13 ObsDensityStatus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Appendix A Appendix B 11 11 11 12 12 12 12 13 13 13 14 14 15 15

ASCII Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Related documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

Page 4

Introduction

Introduction

The modbus communication takes place via the optional RS-232C / RS-485 communication channel. Reference is made to: Instruction manual XPU-2 option RS-232C / RS-485 Instruction manual SmartRadar LT RS-232C / RS-485 output communication

These Instruction manuals describe the commissioning of the optional communication channel. In addition to that information, this manual describes the setup for the optional Modbus protocol and the implemented Modbus function codes. The RS-232C communication is used between the instrument and one other user (DCE). This can be a modem or line driver or any host system using RS-232C. The RS-232C communication is limited to 15 m (50 ft) distance and handshake signals (RTS, CTS, DTR, DSR or DCD) are not supported. The communication is half duplex. With RS-485 communication a multi-drop bus structure is possible with maximum 32 slaves (instruments) and one master (host). The maximum distance with RS-485 is approximately 1000 m (3000 ft) at 9600 baud. The communication is half duplex. The Enraf instruments communicate with the Enraf GPU-protocol on the RS-232C / RS-485 communication channel. A software switch is used to switch over from Enraf GPU-protocol to Modbus protocol RTU mode.

Instruction manual Modbus protocol Enraf gauges

Page 5

Setup for Modbus RTU mode

Setup for Modbus RTU mode

Before the setup for Modbus RTU mode is made, the gauge should be commissioned and operational. When set for Modbus RTU mode, access to items is limited to the Portable Enraf Terminal via the infra-red connector. Item W2= BC= Name Protection level 2 Address byte CIU emulation Description Enter password 2. One ASCII character (default: -). For the Modbus RTU mode, it is required that there is no CIU address emulation. Therefore, this item must be set to - . Two ASCII numbers, ranging from 00 till 99 (default: 00). Read the transmission address and note it for use in the Modbus RTU addressing. One ASCII character (default: G) Selects the communication mode of the RS-232C / RS-485 communication channel G = Enraf GPU protocol M = Modbus RTU protocol Set to M, for Modbus communication. Exit protection level.

TA

Transmission address

GM=

GPU Modbus mode switch

EX

Exit

Note:
When the Modbus mode is selected, the command to return to Enraf GPU mode via the RS-232C / RS-485 communication channel, is with Modbus Function code 05: Force single coil (refer to section 3.5), or via the Portable Enraf Terminal by setting item GM to G.

Page 6

Modbus protocol

Modbus protocol

Enraf has implemented in the gauges (as option) the Standard Modbus (RTU mode), as defined by the Schneider Automation Modicon Modbus Protocol Reference Guide (PI-MBUS, Rev. J). Only a limited set of functions is used as the protocol for query / response is straight forward. Gauge commands and parameter settings (item settings) are not supported within the Modbus implementation. As with RS-485 communication a bus structure can be built, it is possible to connect a maximum of 32 gauges (as slaves) onto one host (master). Each slave has its unique address. The host (master) initiates the communication by addressing one of the slaves in its query. Only the addressed slave (gauge) will respond. With RS-232C there can be only one slave (the gauge) and one master (the host).

3.1 Communication parameters


The following communication settings are fixed and should be taken over by the host: Physical layer: Baudrate: Protocol: start bit: data bits: parity: stop bit: message delimiter: Turn around delay: RS-232C or RS-485 (no handshake) 1200, 2400, 4800, 9600 or 19K2 baud as set by item BI Modbus RTU 1 8 odd 1 3.5 character frame time (2 msec. at baudrate 19K2) Selectable between 10 and 900 msec as set by item TH

3.2 Communication procedure


A Modbus message is placed by the transmitting device into a frame that has a known beginning and ending point. This allows receiving devices to begin at the start of the message, read the address portion and determine which device is addressed, and to know when the message is completed. RTU mode is a binary mode of data representation. Messages start with a silent interval of at least 3.5 character times. This is most easily implemented as a multiple of character times at the baud rate that is being used on the network (shown as T1T2T3T4 in the figure below). The first field then transmitted is the device address. The gauges monitor the bus continuously, including during the silent intervals. When the first byte (the address byte) is received, each gauge decodes it to find out if it is the addressed gauge. Following the last transmitted byte, a similar interval of at least 3.5 character times marks the end of the message. A new message can begin after this interval. A typical message frame is shown below: start T1T2T3T4 address 8 bits function 8 bits data n * 8 bits CRC check 2 * 8 bits end T1T2T3T4

Instruction manual Modbus protocol Enraf gauges

Page 7

Modbus protocol
start address Synchronisation 3.5 character time elapsed The address field of a message frame contains eight bits. The address must be the binary representation of the programmed address in item TA. Item TA can range from 00 to 99 (decimal), which means the largest value in this field can be: 63H (0110 0011B). A master addresses a slave by placing the slave address in the address field of the message. When the slave sends its response, it places its own address in this address field of the response to let the master know which slave is responding. function The function code field of a message frame contains eight bits. With the Modbus protocol in the Enraf gauges, only function code 03 (read holding registers) and function code 05 (force single coil) are valid. When a message is sent from a master to a slave the function code field tells the slave what kind of action to perform. For a normal response, the slave simply echoes the original function code. data The data field is constructed using sets of two 8 bit bytes (16 bit registers), in the range of 0000...FFFF. The data field of messages sent from a master to slave devices contains additional information which the slave must use to take the action defined by the function code. The data field of a response from a slave to a master contains the requested data. CRC check The CRC check field contains a 16-bit value implemented as two eight-bit bytes. The error check value is the result of a CRC (Cyclical Redundancy Check) calculation performed on the message contents. The CRC field is appended to the message as the last field in the message. end Synchronisation 3.5 character time elapsed

3.3 Function codes 3.3.1 Function code 03 Read holding registers


Holding registers are located in the memory range (4)0000 ... (4)001DH. Register values can range from 0000 to FFFFH. Depending on the use, the registers contain a value or bit coded status in single (16 bit) or double (32 bit) register signed (twos complement) or not signed. The query message specifies the starting register and quantity of registers to be read: Slave address 8 bits Function 03 8 bits Start address 16 bits No. of registers 16 bits CRC check 16 bits

The register data in the response message is packed as two bytes per register with the binary contents visually right-justified within each register: Slave address 8 bits Function 03 8 bits Byte count (N) 8 bits Data (N) x 8 bits CRC check 16 bits

The amount of bytes N is double the amount of requested registers, because each register occupies two bytes.

Page 8

Modbus protocol 3.3.2 Function code 05 Force single coil


Coils are located in the memory range (0)0000 ... (0)0001H. The value of a coil can be forced to: FF00H = ON or 0000H = OFF. The query message specifies the coil reference to be forced: Slave address 8 bits Function 05 8 bits Coil address 16 bits Force data 16 bits CRC check 16 bits

The normal response is an echo of the query, returned after the coil state has been forced: Slave address 8 bits Function 05 8 bits Coil address 8 bits Force data 16 bits CRC check 16 bits

3.4 Memory map


There is a fixed memory map in the gauges for reading the holding registers. Modbus unit ProductLevel ProductLevelStatus ProductLevelAlarm WaterLevel WaterLevelStatus ProductTemp ProductTempStatus VapRoomTemp VapRoomTempStatus VapRoomPress VapRoomPressStatus ObsDensity ObsDensityStatus Modbus address (hexa-decimal) 0000 0002 0003 0004 0006 0007 0009 000A 000C 0010 0012 0017 0019 Modbus type SD40001 40003 40004 SD40005 40007 SD40008 40010 SD40011 40013 ... 16 SD40017 40019 ... 23 SD40024 40026 ... 30 No. of registers 2 1 1 2 1 2 1 2 4 2 5 2 5

There is no offset applicable for the given data. However, there is a fixed scaling which depends on the selected dimension of the measured unit. S = signed data (twos complement) D = double register (4 bytes; 32 bits) When a measured unit is in fail, the register value will contain the maximum value, considering the Modbus type. For example: a signed double register then contains: 7FFFFFFFH; a signed single register then contains: 7FFFH.

Instruction manual Modbus protocol Enraf gauges

Page 9

Modbus protocol 3.5 On-line switch in Modbus mode


When communicating in Modbus, the command to return to GPU-protocol is by Function code 05: Force single coil. The data FF00H must be written at coil address 0000H. When the gauge receives this message, it updates its NOVRAM with item GM=G (for communication in GPU-protocol) and resets itself. After the reset, the RS-232C / RS-485 communication channel communicates with the GPU protocol. Example: Slave address 8 bits Function 05 05H Coil address 00 00H Force data FF 00H CRC check 16 bits

Page 10

Modbus register contents

Modbus register contents

4.1 ProductLevel
Signed number; double register. Depending on the level dimension of the gauge (item LD), this double register contains the product level in: Level dimension item LD M F I P Modbus data representation 0.1 0.001 0.01 1 /16 mm ft inch inch Scaling (divide by) 10 1000 100 16 for for for for mm, or 10 000 for m ft inch inch

4.2 ProductLevelStatus
This register contains the bit coded product level status. This status information is coded in such a way that an ASCII code for a character is generated. The ASCII characters are listed below (refer to the ASCII table in Appendix A). The product level status depends on the type of gauge. 854 Servo gauge level status: F C B L R T W D Invalid level data hardware / software error 854 in service mode Motor limit switch reached Block or freeze active Lock test or calibrate active Density scan active (TP or IP) Test gauge (TG), searching for level, balance test or measure frequency command active Water level found (by displacer) Searching for water (downwards) Valid level SmartRadar gauge level status: F Invalid level data level fail initial status th 4 character of item LU out of measuring range rd 3 character of item LU measurement blocked nd 2 character of item LU warning general APU/ICU fail st 1 character of item LU reduced accuracy Valid level

C*) B*) M*) ?*) -

877 FDI level status when used as HTG: F *) The characters given here are the default Invalid level data settings in item LU (level status conversion); general HPU/HCU fail it may be set to different characters. level fail P1 and/or P3 out of range P2 out of range Reduced accuracy manual P3 used last valid P3 used manual density used last valid density used manual gas density used level below item LN (minimum HTG level) Valid level

?*) -

Instruction manual Modbus protocol Enraf gauges

Page 11

Modbus register contents 4.3 ProductLevelAlarms


The product level alarm status is represented by the following number in this Modbus register: Product level alarm status no alarm low level alarm high level alarm low low level alarm high high level alarm level alarm failure Modbus register value (decimal) 0 1 2 3 4 255

4.4 WaterLevel
Signed number; double register. Depending on the level dimension of the gauge (item LD), this double register contains the water level in: Level dimension item LD M F I P Modbus data representation 0.1 0.001 0.01 1 /16 mm ft inch inch Scaling (divide by) 10 1000 100 16 for for for for mm, or 10 000 for m ft inch inch

4.5 WaterLevelStatus
This register contains the bit coded water level status. This status information is coded in such a way that an ASCII code for a character is generated. The ASCII characters are listed below (refer to the ASCII table in Appendix A). F A Z Invalid water alarm data general probe failure Water above probe warning Water below probe warning Valid water level

4.6 ProductTemp
Signed number; double register. Depending on the temperature dimension of the gauge (item TD), this double register contains the product temperature in: Temperature dimension item LD C F Modbus data representation 0.01 C 0.01 F Scaling (divide by) 100 for C 100 for F

Page 12

Modbus register contents 4.7 ProductTempStatus


This register contains the bit coded product temperature status. This status information is coded in such a way that an ASCII code for a character is generated. The ASCII characters are listed below (refer to the ASCII table in Appendix A). F Invalid temperature data optional board absent multiple temperature general fail fail in average product temperature reading Reduced accuracy (character from item TU) out of specified temperature range exceeding differential temperature range (MTT) device not calibrated (MTT) last valid level used manual level used level below lowest temperature element alternative temperature element selected (MRT) Valid temperature

T*) -

*) The character T is the default value of item TU (temperature status conversion); it may be set to a different character.

4.8 VapRoomTemp
Signed number; double register. Depending on the temperature dimension of the gauge (item TD), this double register contains the vapour room (gas) temperature in: Temperature dimension item LD C F Modbus data representation 0.01 C 0.01 F Scaling (divide by) 100 for C 100 for F

4.9 VapRoomTempStatus
These four registers contains the bit coded vapour room temperature status. With exception of the first register, the status information is coded in such a way that an ASCII code for a character is generated. The 8 bits ASCII coded character is placed in the Low byte of the register; the High byte remains empty (zero). The ASCII characters are listed below (refer to the ASCII table in Appendix A). Modbus address Register contents 000CH item MQ, byte 0 000DH item MQ, byte 1 000EH item MQ, byte 2 000FH item MQ, byte 3

Status byte 0: Contains one of the characters 0 to F (as a hexa-decimal number), indicating the highest immersed (spot)element of the temperature element.

Instruction manual Modbus protocol Enraf gauges

Page 13

Modbus register contents


Status byte 1: bit 0 : General temperature fail 1 : Fail in average product temperature 2 : Fail in average vapour temperature 3 : Level exceeds lowest (spot)element 4 : Level exceeds highest (spot)element 5 : (Spot)element fail 6 : 1 7 : 0 Status byte 3: bit 0 : No previous store command 1 : Alternative element selected (MRT) 2-5 : 0 6 : 1 7 : 0 Status byte 2: bit 0 : Last valid level used 1 : Manual level used 2 : Level time out 3 : Device not calibrated (MTT) 4 : Exceeding differential temp. range (MTT) 5 : Out of specified temperature range 6 : 1 7 : 0

Note:
Only the bits which are set to 1 have an active status.

4.10 VapRoomPress
Signed number; double register. Depending on the pressure dimension of the gauge (item PI), this double register contains the vapour pressure in: Pressure dimension item PI P I, S K Modbus data representation 0.001 bar 0.001 psi 1 Pa Scaling (divide by) 1000 for bar 1000 for psi no scaling

4.11 VapRoomPressStatus
These five registers contain the bit coded vapour room pressure and observed density status. The status information is coded in such a way that an ASCII code for a character is generated. The 8 bits ASCII coded character is placed in the Low byte of the register; the High byte remains empty (zero). The ASCII characters are listed below (refer to the ASCII table in Appendix A). Modbus address Register contents 0012H item QF, byte 0 0013H item QF, byte 1 0014H item QF, byte 2 0015H item QF, byte 3 0016H item QF, byte 4

Status byte 0: bit 0 : General option board fail 1 : Low level alarm *) 2 : Low low level alarm *) 3 : High level alarm *) 4 : High high level alarm *) 5 : Level time out *) 6 : 1 7 : 0

Status byte 1: bit 0 : P1 exceeds min. / max. trip pressure 1 : P2 exceeds min. / max. trip pressure 2 : P3 exceeds min. / max. trip pressure 3 : Exceeding range P1 4 : Exceeding range P2 5 : Exceeding range P3 6 : 1 7 : 0

Page 14

Modbus register contents


Status byte 2: bit 0 : Fail P1 1 : Fail P2 2 : Fail P3 3 : Manual P3 used 4 : Last valid P3 used 5 : Manual level used 6 : 0 7 : 1 Status byte 3: bit 0 : Last valid density used 1 : Manual density used 2 : High density alarm 3 : Low density used 4 : HTG level fail *) 5 : No previous store command 6 : 1 7 : 0

*)

Status byte 4: bit 0 : Manual gas density used Note: 1 : Level below LN Only the bits which are set to 1 have an active 2 : Last valid level used status. 3 : Invalid level reading 4 : API underflow/overflow or negative density 5 : 0 6 : 1 *) These bits represent typical HIMS / HTG status 7 : 0 messages. Ignore for vapour pressure and observed density measurement.

4.12 ObsDensity
Signed number; double register. Depending on the density dimension of the gauge (item DI), this double register contains the observed density in: Density dimension item DI K A L Modbus data representation 0.01 kg/m 0.001 API 3 0.0001 lbs/ft
3

Scaling (divide by) 100 for kg/m 1 000 for API 3 10 000 for lbs/ft
3

4.13 ObsDensityStatus
These five registers contain the bit coded observed density and vapour room pressure status. Refer to section 4.11 VapRoomPressStatus.

Instruction manual Modbus protocol Enraf gauges

Page 15

Appendix

Appendix A ASCII Table

Appendix B Related documents


Instruction manual 854 ATG level gauge Instruction manual 854 series XTG level gauge Instruction manual 877 FDI Field Display & Interface Instruction manual 873 SmartRadar Instruction manual 973 SmartRadar LT Instruction manual 971 SmartRadar LTi Instruction manual 970 SmartRadar ATi Instruction manual XPU-2 option RS-232C / RS-485 Instruction manual 973 SmartRadar LT RS-232C / RS-485 output communication

Page 16

Anda mungkin juga menyukai