TIP Thüringer Industrie Produkte GmbH Bahnhofstraße 26 • 99842 Ruhla • GERMANY • Tel. : +49 (0)36929/64029-0 • Fax : +49 (0)36929/64029-99 • info@stromzaehler.de • www.stromzaehler.
Limitation of liability The Manufacturer reserves the right to modify the software or the software specifications in this manual without previous warning. Any copy of this manual, in part or in full, whether by photocopy or by other means, even of electronic nature, without the manufacture giving written authorisation, breaches the terms of copyright and is liable to prosecution.
Modbus communication protocol NOVA RS485 MOD-BUS NOVA LAN-GATEWAY User manual October Edition 2012
Index 1. Description................................................................ 5 1.1 LRC generation.................................................................. 6 1.2 CRC generation.................................................................. 7 2. Read commands structure...................................... 10 2.1 MODBUS ASCII/RTU........................................................ 10 2.2 MODBUS TCP................................................................... 11 2.
MODBUS ASCII/RTU is a master-slave communication protocol, able to support up to 247 slaves connected in a bus or a star network. The protocol uses a simplex connection on a single line. In this way, the communication messages move on a single line in two opposite directions. MODBUS TCP is a variant of the MODBUS family. Specifically, it covers the use of MODBUS messaging in an “Intranet” or “Internet” environment using the TCP/IP protocol on a fixed port 502.
English TCP mode Bit per byte: 1 Start, 7 Bit, Even, 2 Stop (7E2) Name Length Function TRANSACTION ID 2 bytes For synchronization between messages of server & client PROTOCOL ID 2 bytes Zero for MODBUS TCP BYTE COUNT 2 bytes Number of remaining bytes in this frame UNIT ID 1 byte Slave address (255 if not used) FUNCTION CODE 1 byte Function code ($01 / $04 / $10) DATA BYTES n bytes Data as response or command 1.
The Cyclical Redundancy Check (CRC) field is two bytes, containing a 16–bit value. The CRC value is calculated by the transmitting device, which appends the CRC to the message. The receiving device recalculates a CRC during receipt of the message, and compares the calculated value to the actual value it received in the CRC field. If the two values are not equal, an error results. The CRC is started by first preloading a 16–bit register to all 1’s.
English CRC generation functions - With Table All of the possible CRC values are preloaded into two arrays, which are simply indexed as the function increments through the message buffer. One array contains all of the 256 possible CRC values for the high byte of the 16–bit CRC field, and the other array contains all of the values for the low byte. Indexing the CRC in this way provides faster execution than would be achieved by calculating a new CRC value with each new character from the message buffer.
English CRC generation functions - Without Table unsigned short ModBus_CRC16( unsigned char * Buffer, unsigned short Length ) { /* ModBus_CRC16 Calculatd CRC16 with polynome 0xA001 and init value 0xFFFF Input *Buffer - pointer on data Input Lenght - number byte in buffer Output - calculated CRC16 */ unsigned int cur_crc; cur_crc=0xFFFF; do { unsigned int i = 8; cur_crc = cur_crc ^ *Buffer++; do { if (0x0001 & cur_crc) { cur_crc >>= 1; cur_crc ^= 0xA001; } else {
English 2. Read commands structure The master communication device can send commands to the module to read its status and setup or the measured values, status and setup relevant to the combined counter. More registers can be read, at the same time, sending a single command, only if the registers are consecutive (see chapter 5). According to the used MODBUS protocol mode, the read command is structured as follows. 2.1 MODBUS ASCII/RTU Values contained both in Query or Response messages are in hex format.
English 2.2 MODBUS TCP Values contained both in Query or Response messages are in hex format. Query example in case of MODBUS TCP: 010000000006010400020002 Example Byte 01 - 00 High 00 Low 00 High 00 Low 06 01 Description No. of bytes Transaction identifier 1 Protocol identifier 4 - Byte count 1 - Unit identifier 1 04 - Function code 1 00 High 02 Low Starting register 2 00 High 02 Low No.
English 2.3 Floating point as per IEEE Standard The basic format allows a IEEE standard floating-point number to be represented in a single 32 bit format, as shown below: N.n = (-1)S 2 e’-127 (1.f ) where S is the sign bit, e’ is the first part of the exponent and f is the decimal fraction placed next to 1. Internally the exponent is 8 bits in length and the stored fraction is 23 bits long. A round to nearest method is applied to the calculated value of floating point.
The master communication device can send commands to the module to program itself or the combined counter. More settings can be carried out, at the same time, sending a single command, only if the relevant registers are consecutive (see chapter 5). According to the used MODBUS protocol type, the write command is structured as follows. 3.1 MODBUS ASCII/RTU Values contained both in Request or Response messages are in hex format.
English 3.2 MODBUS TCP Values contained both in Request or Response messages are in hex format. Query example in case of MODBUS TCP: 010000000009011005150001020008 Example Byte 01 - 00 High 00 Low 00 High 00 Low 09 01 Description No. of bytes Transaction identifier 1 Protocol identifier 4 - Byte count 1 - Unit identifier 1 10 - Function code 1 05 High 15 Low Starting register 2 00 High 01 Low No.
English 4. Exception codes When the module receives a not-valid query, an error message (exception code) is sent. According to the used MODBUS protocol mode, possible exception codes are as follows. 4.1 MODBUS ASCII/RTU Values contained in Response messages are in hex format. Response example in case of MODBUS RTU: 01830131F0 Example Byte Description No.
English $03 ILLEGAL DATA VALUE: a value contained in the query data field is not an allowable value for the combined counter. $04 SERVER FAILURE: the server failed during the execution. $05 ACKNOWLEDGE: the server accepted the server invocation but the service requires a relatively long time to execute. The server therefore returns only an aknowledgement of the service invocation receipt. $06 SERVER BUSY: the server was unable to accept the MB request PDU.
English 5.1 Reading registers (Function code $01 / $03 / $04) Pa ra meter F. code (Hex) INTE G E R Sign Register Words (Hex) IE E E M.U. Register Words (Hex) M.U.
English Pa ra meter F. code (Hex) INTE G E R Sign Register Words (Hex) IE E E M.U. Register Words (Hex) M.U. total counter values -kVAh1-L • Phase 1 exported lagging apparent energy 03 / 04 0124 3 0.1 VAh 1118 2 VAh -kVAh2-L • Phase 2 exported lagging apparent energy -kVAh3-L • Phase 3 exported lagging apparent energy 03 / 04 0127 3 03 / 04 012A 3 0.1 VAh 111A 2 VAh 0.1 VAh 111C 2 VAh -kVAh∑-L • System exported lagging apparent energy 03 / 04 012D 3 0.
INTE G E R Sign Register Words (Hex) IE E E M.U. Register Words (Hex) M.U. tARIFF 1 counter values +kVAh1-C • Phase 1 imported leading apparent energy 03 / 04 0230 3 0.1 VAh 1220 2 VAh +kVAh2-C • Phase 2 imported leading apparent energy 03 / 04 0233 3 0.1 VAh 1222 2 VAh +kVAh3-C • Phase 3 imported leading apparent energy 03 / 04 0236 3 0.1 VAh 1224 2 VAh +kVAh∑-C • System imported leading apparent energy 03 / 04 0239 3 0.
English Pa ra meter F. code (Hex) INTE G E R Sign Register Words (Hex) IE E E M.U. Register Words (Hex) M.U. tARIFF 2 counter values -kVAh1-C • Phase 1 exported leading apparent energy 03 / 04 033C 3 0.1 VAh 1328 2 VAh -kVAh2-C • Phase 2 exported leading apparent energy 03 / 04 033F 3 -kVAh3-C • Phase 3 exported leading apparent energy 03 / 04 0342 3 0.1 VAh 132A 2 VAh 0.1 VAh 132C 2 VAh -kVAh∑-C • System exported leading apparent energy 03 / 04 0345 3 0.
English R eg is ter des c r i pti o n F. code (Hex) INTE G E R D a ta mea n ing Register Words (Hex) COUNTEr & COMMUNICATION MODULE data Serial number 03 / 04 0500 5 10 ASCII chars. ($00÷$FF) Model 03 / 04 0505 1 $03=6A 3phases/4wires $06=6A 3phases/3wires $08=80A 3phases/4wires $0A=80A 3phases/3wires $0C=80A 1phase/2wires Type 03 / 04 0506 1 $02=MID Firmware release 03 / 04 0507 1 Convert the read Hex value in Decimal value. e.g. $66=102 =rel. 1.
English R eg is ter des c r i pti o n F. code (Hex) INTE G E R Register Words (Hex) D a ta mea n ing COUNTEr & COMMUNICATION MODULE data Partial counters status 03 0517 1 Convert the read Hex value in Binary. e.g. $0003= 0000000000000011 Each bit corresponds to the status of a partial counter. 0=inactive 1=active 0000000000000011 < Start to read bit string following the arrow.
F.
English 5.2 Writing registers (Function code $10) R eg is ter des c r i pti o n F.
English MODBUS RTU, ASCII, TCP 25
English 26 MODBUS RTU, ASCII, TCP
English MODBUS RTU, ASCII, TCP 27
TIP Thüringer Industrie Produkte GmbH Bahnhofstraße 26 • 99842 Ruhla • GERMANY • Tel. : +49 (0)36929/64029-0 • Fax : +49 (0)36929/64029-99 • info@stromzaehler.de • www.stromzaehler.