2CSG445012D0201 - Modbus Communication Protocol - M2M Basic
2CSG445012D0201 - Modbus Communication Protocol - M2M Basic
Communication protocol
Contents
1 Setting up M2M Basic serial communication ....................................................................................... 1
1.1 Serial network ID programming .................................................................................................... 1
1.2 RS-485 communication interface.................................................................................................. 1
2 Communication frame in RTU mode .................................................................................................... 2
2.1 Modbus RTU protocol ................................................................................................................... 2
2.1.1 Communication frame structure .......................................................................................... 2
2.1.2 CRC generation...................................................................................................................... 3
2.2 Function 03h: “Read holding registers” ........................................................................................ 4
2.2.1 Read request (Master) .......................................................................................................... 4
2.2.2 Reply (Slave) .......................................................................................................................... 4
2.2.3 Memory maps ....................................................................................................................... 5
2.3 Exceptions on the Bus ................................................................................................................. 11
M2M Basic – Communication Protocol
Technical specification V.1.0
Communication parameters
Baud rate 4800 ÷ 38400
Data bit 8
Stop bit 1, 2
Parity Even, odd, none
If the device to which the instrument have to be connected is not equipped with RS485 serial port, a
serial RS232/RS485 interface converter should be used between PC and the instruments.
1 / 11
M2M Basic – Communication Protocol
Technical specification V.1.0
T1 T2 T3
ADDRESS FIELD = 8 bits
FUNCTION CODE = 8 bits
DATA FIELD = N x 8 bits
ERROR CHECK = 16 bit CRC
T1 T2 T3
in which:
a) the Address field contains the address of the Slave to which the message is sent
b) the Function field contains the code of the function that must be carried out by the Slave
c) the Data field contains the information needed by the Slave to carry out a specific function or contains
data collected from the Slave in response to a question
d) the CRC field allows both the Master and the Slave to check a message in order to detect any errors in
transmission. Sometimes, due to electrical “noise” or other interference, a message may be changed
during the transmission from one unit to another. The error check ensures that neither the Master nor
the Slave react to messages that have been haltered
e) the T1 T2 T3 sequence represents the time that separates one frame from another, and corresponds
to at least 3 and a half characters: during this period no one is allowed to talk on the bus, to let the
instruments detect that a frame is over and another one is starting
In RTU mode, the synchronisation of the frame can be maintained only by simulating a synchronous
message. The receiving device measures the time that separates the reception of one character and the
reception of the subsequent one (for example, between address and function). If this time is longer than
the time needed to transmit three and a half characters, then the message is considered lost and the
next character arriving is considered to be an address, in other words the beginning of a new frame.
2 / 11
M2M Basic – Communication Protocol
Technical specification V.1.0
The CRC used in Modbus follows the standard CRC-16 defined by CCITT.
Many algorithms are ready off-the-shelf; an algorithm written in C, using a look-up table, is reported
below:
word crc16_rev_table[256] =
{ 0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40,
0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841,
0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40,
0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41,
0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641,
0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040,
0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240,
0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441,
0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41,
0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840,
0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41,
0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40,
0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640,
0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041,
0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240,
0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441,
0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41,
0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840,
0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41,
0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40,
0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640,
0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041,
0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241,
0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440,
0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40,
0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841,
0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40,
0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41,
0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641,
0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040};
unsigned fast_crc16( unsigned char *ucpBuf, int nSize){
register word x;
register word crc;
int i;
crc = 0xFFFF; /* start with all 1's for a reverse CRC */
for( i = 0; i < nSize; ++i) {
/* process each character in the message - 2 steps per char only! */ x = crc ^ ucpBuf[i];
crc = (crc >> 8) ^ crc16_rev_table[x & 0x00FF];
}
return( crc);
}
3 / 11
M2M Basic – Communication Protocol
Technical specification V.1.0
In the example above, the master sends the ‘read function’ Func = 03h to the slave with address Addr =
1Fh, starting from base register address Data Start Register = 1000h for Data Regs = 14h consecutive
registers. So the command reads all registers from address 1000h a 1013h. The CRC = 42BBh closes the
data stream.
The table above shows the fields in the instrument reply, which are:
4 / 11
M2M Basic – Communication Protocol
Technical specification V.1.0
There are three particular cases that can happen using this command; the first is related to the quantity
of requested memory, the second is related to the beginning of the requested segment and the last is
related to the quantity of the requested words.
In particular, if the quantity of the requested bytes is greater than the instrument’s memory extension,
the instrument will answer an “INVALID DATA” for the not available values; for example, if are requested
20 bytes from the last fourth valid address, a part of the request overflows in the non available memory.
The exceeded bytes will be filled with the value 00, indicating a non-managed value for those memory
cells.
The second particular case is related to a request starting from a non-valid address, when the request
starts from an address not present in the following table. In this case the instrument will answer with an
exception “02 ILLEGAL DATA ADDRESS”.
The last particular case is the request of a number of words greater than the maximum for the
instrument: in this case the instrument will answer with an exception “02 ILLEGAL DATA address”.
The following 3 tables indicate the correspondence between the address of the location, the number of
accessible words beginning with that address, the description of the measurement value, the unit of
measurement of the measurement value and the binary format. They differentiate each other for the
data format.
Integer 32 bits
Reg Reg
Measurement description Unit Format
[Dec] [Hex]
Unsigned integer 32
4096 1000 3-PHASE SYSTEM VOLTAGE V
bits
Unsigned integer 32
4098 1002 PHASE VOLTAGE L1-N V
bits
Unsigned integer 32
4100 1004 PHASE VOLTAGE L2-N V
bits
Unsigned integer 32
4102 1006 PHASE VOLTAGE L3-N V
bits
Unsigned integer 32
4104 1008 LINE VOLTAGE L1-2 V
bits
Unsigned integer 32
4106 100A LINE VOLTAGE L2-3 V
bits
Unsigned integer 32
4108 100C LINE VOLTAGE L3-1 V
bits
Unsigned integer 32
4110 100E 3-PHASE SYSTEM CURRENT mA
bits
Unsigned integer 32
4112 1010 LINE CURRENT L1 mA
bits
Unsigned integer 32
4114 1012 LINE CURRENT L2 mA
bits
Unsigned integer 32
4116 1014 LINE CURRENT L3 mA
bits
4118 1016 3-PHASE SYS. POWER FACTOR /1000 Signed integer 32 bits
4120 1018 POWER FACTOR L1 /1000 Signed integer 32 bits
4122 101A POWER FACTOR L2 /1000 Signed integer 32 bits
4124 101C POWER FACTOR L3 /1000 Signed integer 32 bits
4126 101E 3-PHASE SYSTEM COS Phi /1000 Signed integer 32 bits
5 / 11
M2M Basic – Communication Protocol
Technical specification V.1.0
6 / 11
M2M Basic – Communication Protocol
Technical specification V.1.0
Unsigned integer 32
4232 1088 CURRENT ThdF L1 (NORMAL VISUALISATION) % /100
bits
Unsigned integer 32
4234 108A CURRENT ThdF L2 (NORMAL VISUALISATION) % /100
bits
Unsigned integer 32
4236 108C CURRENT ThdF L3 (NORMAL VISUALISATION) % /100
bits
Unsigned integer 32
4262 10A6 3-PHASE SYS. APPARENT ENERGY Vah*100
bits
Unsigned integer 32
4270 10AE 3-PHASE SYS. GENERATED ACTIVE ENERGY Wh*100
bits
Unsigned integer 32
4278 10B6 3-PHASE S. GENERATED REACTIVE ENERGY Varh*100
bits
Unsigned integer 32
4294 10C6 Current Demand L1 mA
bits
Unsigned integer 32
4296 10C8 Current Demand L2 mA
bits
Unsigned integer 32
4298 10CA Current Demand L3 mA
bits
Unsigned integer 32
4512 11A0 CURRENT TRANSFORM RATIO (CT) A/A
bits
Unsigned integer 32
4514 11A2 VOLTAGE TRANSFORM RATIO (VT) V/V
bits
Unsigned integer 32
4516 11A4 PULSE ENERGY WEIGHT 1/kW
bits
Float 32 bits
Reg Reg
[Dec] [Hex] Measurement description Unit Format
12288 3000 Voltage L1 and Neutral V Float 32 bits
12290 3002 Voltage L2 and Neutral V Float 32 bits
12292 3004 Voltage L3 and Neutral V Float 32 bits
12294 3006 Voltage L1 and L2 V Float 32 bits
12296 3008 Voltage L2 and L3 V Float 32 bits
12298 300A Voltage L3 and L1 V Float 32 bits
12300 300C Three phase system voltage V Float 32 bits
12302 300E Reserved
12304 3010 Current phase 1 A Float 32 bits
12306 3012 Current phase 2 A Float 32 bits
12308 3014 Current phase 3 A Float 32 bits
12310 3016 Neutral current A Float 32 bits
12312 3018 Three phase system current A Float 32 bits
12314 301A Reserved
12316 301C Active power phase 1 W Float 32 bits
12318 301E Active power phase 2 W Float 32 bits
12320 3020 Active power phase 3 W Float 32 bits
12322 3022 Active power total W Float 32 bits
12324 3024 Reactive power phase 1 Var Float 32 bits
12326 3026 Reactive power phase 2 Var Float 32 bits
12328 3028 Reactive power phase 3 Var Float 32 bits
12330 302A Reactive power total Var Float 32 bits
12332 302C Apparente power fase 1 VA Float 32 bits
7 / 11
M2M Basic – Communication Protocol
Technical specification V.1.0
8 / 11
M2M Basic – Communication Protocol
Technical specification V.1.0
Unsigned integer 32
12416 3080 Reverse reactive energy kWh in *100 kvarh bits
Unsigned integer 32
12418 3082 Apparent energy kVAh *100 kVAh bits
Integer 16 bits
Reg Reg
Measurement description Conversion factor Format
[Dec] [Hex]
Unsigned
80 50 Primary of the CT Integer value
word*
Unsigned
81 51 Number of decimal places for primary of CT 0,1,2 or 3
word*
Unsigned
82 52 Magnitude of the CT 0 (A),3 (kA)
word*
Unsigned
83 53 Primary of the VT Integer value
word*
Unsigned
84 54 Number of decimal places for primary of VT 0,1,2 or 3
word*
Unsigned
85 55 Magnitude of the VT 0 (V),3 (kV)
word*
Unsigned
86 56 Nominal power Integer value
word*
Unsigned
87 57 Number of decimal places for power 0,1,2 or 3
word*
0 (W),3 (kW) or 6 Unsigned
88 58 Magnitude of the power
(MW) word*
Unsigned
100 64 Voltage L1 and Neutral 16384 = Rated Value
word*
Unsigned
101 65 Voltage L2 and Neutral 16384 = Rated Value
word*
Unsigned
102 66 Voltage L3 and Neutral 16384 = Rated Value
word*
Unsigned
103 67 Voltage L1 and L2 16384 = Rated Value
word*
Unsigned
104 68 Voltage L2 and L3 16384 = Rated Value
word*
Unsigned
105 69 Voltage L3 and L1 16384 = Rated Value
word*
Unsigned
106 6A Current I1 16384 = Rated Value
word*
Unsigned
107 6B Current I2 16384 = Rated Value
word*
Unsigned
108 6C Current I3 16384 = Rated Value
word*
Unsigned
109 6D Neutral current 16384 = Rated Value
word*
110 6E Active Power P1 16384 = Rated Value Signed word*
111 6F Active Power P2 16384 = Rated Value Signed word*
112 70 Active Power P3 16384 = Rated Value Signed word*
113 71 Total Active Power PT 16384 = Rated Value Signed word*
114 72 Reactive Power Q1 16384 = Rated Value Signed word*
115 73 Reactive Power Q2 16384 = Rated Value Signed word*
116 74 Reactive Power Q3 16384 = Rated Value Signed word*
117 75 Total Reactive Power QT 16384 = Rated Value Signed word*
Unsigned
118 76 Apparent Power S1 16384 = Rated Value
word*
Unsigned
119 77 Apparent Power S2 16384 = Rated Value
word*
Unsigned
120 78 Apparent Power S3 16384 = Rated Value
word*
9 / 11
M2M Basic – Communication Protocol
Technical specification V.1.0
Unsigned
121 79 Total Apparent Power ST 16384 = Rated Value
word*
122 7A Power Factor 1 16384 = Rated Value Signed word*
123 7B Power Factor 2 16384 = Rated Value Signed word*
124 7C Power Factor 3 16384 = Rated Value Signed word*
125 7D Power Factor T 16384 = Rated Value Signed word*
Unsigned
126 7E Frequency 2000H = 50 Hz
word*
Unsigned
127 7F Imported active energy in MWh 1 = 1 MWh
word*
Unsigned
128 80 Imported active energy in kWh 1 = 1 kWh
word*
Unsigned
129 81 Imported active energy in Wh 1 = 1 Wh
word*
Unsigned
130 82 Imported reactive energy in Mvarh 1 = 1 Mvarh
word*
Unsigned
131 83 Imported reactive energy in kvarh 1 = 1 kvarh
word*
Unsigned
132 84 Imported reactive energy in varh 1 = 1 varh
word*
Unsigned
133 85 Exported active energy in MWh 1 = 1 MWh
word*
Unsigned
134 86 Exported active energy in kWh 1 = 1 kWh
word*
Unsigned
135 87 Exported active energy in Wh 1 = 1 Wh
word*
Unsigned
136 88 Exported reactive energy in Mvarh 1 = 1 Mvarh
word*
Unsigned
137 89 Exported reactive energy in kvarh 1 = 1 kvarh
word*
Unsigned
138 8A Exported reactive energy in varh *1 1 = 1 varh
word*
Unsigned
139 8B Angle Phi 1 16384 = 360
word*
Unsigned
140 8C Angle Phi 2 16384 = 360
word*
Unsigned
141 8D Angle Phi 3 16384 = 360
word*
Unsigned
142 8E Angle Phi t 16384 = 360
word*
Unsigned
143 8F Demand of Current I1 16384 = Rated Value
word*
Unsigned
144 90 Demand of Current I2 16384 = Rated Value
word*
Unsigned
145 91 Demand of Current I3 16384 = Rated Value
word*
146 92 Demand of Real Power 16384 = Rated Value Signed word*
147 93 Demand of Reactive Power 16384 = Rated Value Signed word*
Unsigned
148 94 Demand of Apparent Power 16384 = Rated Value
word*
Unsigned
149 95 Phase 1 Voltage Angle 16384 = Rated Value
word*
Unsigned
150 96 Phase 2 Voltage Angle 16384 = Rated Value
word*
Unsigned
151 97 Phase 3 Voltage Angle 16384 = Rated Value
word*
Unsigned
152 98 Phase 1 Current Angle 16384 = Rated Value
word*
Unsigned
153 99 Phase 2 Current Angle 16384 = Rated Value
word*
Unsigned
154 9A Phase 3 Current Angle 16384 = Rated Value
word*
155 9B Cos Phi 1 16384 = Rated Value Signed word*
156 9C Cos Phi 2 16384 = Rated Value Signed word*
10 / 11
M2M Basic – Communication Protocol
Technical specification V.1.0
Exception Description
01 Illegal function
02 Illegal data address
03 Illegal data value
11 / 11