Energy Meters Iec 870-5-102 Protocol Imp
Energy Meters Iec 870-5-102 Protocol Imp
Energy Meters Iec 870-5-102 Protocol Imp
CONNECTED SYSTEMS
ABSTRACT: This work presents in a simple and practical way how read from a computer the energy values recorded
by standard energy meters installed in PV grid connected systems in order to be monitored local or remotely. This
communication can be easily implemented as a software program itself or integrated as a part in any other monitoring
software. Remote energy metering for PV grid connected installations is used, exclusively in most of the installations,
by the electrical company for remote energy metering and automatic billing. Energy meters communications from
any manufacturer must fulfill the IEC 870-5-102 standard, mandatory in Spain, and complemented by the Electrical
Grid Company, REE, regulation. For remote energy metering the user must install a GSM modem and supply to the
electrical companies the phone number and counters addresses and passwords in order to perform automatic energy
telereadings using software programs. Local energy metering is easily implementable trough energy meters RS485
network and the communication protocol explained in this work.
Keywords: Energy meters reading, IEC870-5-102.
1 INTRODUCTION will be a PC computer and the slaves are each one of the
energy meters, identified by one address in a RS485
Energy meters readings can be monitored local or network. The information exchanges are performed by
remotely in using the IEC 870-5-102 communications request/respond methods, but also send/reply and
protocol and can be used in a specific software o included send/confirm modes are supported. The commands or
as part of the monitoring software of the whole plant. In transmission frame formats can be of fixed and variable
PV installation, this Remote energy metering is a length, 255 characters max., Figure 1.
requirement [1] for PV grid connected installations of
power ≥15 kW and it is being to be mandatory for all 2.1 Start character
general users in near future. This capability is used, It is the start frame character (1 byte). In variable
exclusively in most of the installations, by the electrical length frames is the hexadecimal byte 68, indicated as
company for remote energy metering and automatic H68. It used two times, one for starting frame and other
billing. Energy meters communications from any to indicate the starting of the commands. In the fixed
manufacturer must fulfill the IEC 870-5-102 standard [2], length frames it is the byte H10.
in Spain mandatory and complemented by the Electrical
Grid Company, REE, regulation [3]. Energy meters 2.2 Length
should have optical ports [4] RS232 or RS485. For Two repeated bytes, each one indicates the number of
remote energy metering the user must install a GSM bytes in the frame starting for the control field (included)
modem and supply to the electrical companies the phone until the checksum (not included).
number and counters addresses and passwords in order to
perform automatic energy telereadings using software START (H68) START (H10)
programs. In any case, different energy meters LENGTH CONTROL FIELD C
manufacturers have commercially available software LENGTH ADDRESS
programs, from simple to highly advanced, to perform START (H68) ADDRESS
CONTROL FIELD C END (H16)
telereading and energy meter programming different
ADDRESS (b)
operational parameters. Even some engineering
ADDRESS Figure 1: Transmission
companies that provide PV monitoring are including this
APPLICATION SERVICE frame formats:
kind of services. In any case, the option presented in this
DATA UNIT (ASDU) (a) variable length.
work is aimed to provide the information to any user with
CHECKSUM
light programming skill to be able to develop its own (b) fixed length.
END (H16)
energy meters reading software or include it in a global (a)
monitoring system. Some basic but relevant concepts
from these documents are reproduced here in order to
facilitate to the reader the implementation of simple 2.3 Control field
commands to read the energy values, integrated by time The control field byte (8 bits or 1 octet), C, has the
periods or load curves and tariff information. structure indicated in Figure 2, where:
RES: Reserve (Always 0)
Bite reserved for future applications. Allways0.
2 COMMUNICATIONS PROTOCOL PRM: Control Address
<0> Message from slave (respond)
The communication protocol is not balanced; there is <1> Message from master (start)
a primary device (master) that asks information to one or FCB: Frame Count Bit.
more secondary stations (slaves). In our case the master
<0> <1> = alternant bit for consecutive A common record address of the ASDU (3
send/confirm o request/respond messages. bytes).
The master alternates the bit FCB for each new
transmission addressed to the same slave START (68H) [1byte]
energy meter. Therefore the master should LENGTH [2bytes]
retain this bit to change in each message to a Start frame START (68H) [1byte]
salve. CONTROL FIELD C [1byte]
FCV: Habilitates the bit FCB.
ADDRESS [2bytes]
<0> FCB no habilitated
Type identifier
<1> FCB habilitated
ACD: Access bit. Ignored in this protocol. Da unit SQ=0 N=nº info objects
identifier Cause of transmission
DFC: Data flow control bit.
<0> Next message accepted ASDU address
<1> Next message rejected(data overflow) Info Obj. 1 Info Obj. 1 address
The valid function codes in the frames from master to Application Element or combination
slave (PRM=1) are: Service Label time type a (5 bytes) or
0 Remote link reposition, FCV=0. Data Unit type b (7 bytes)
Information
(ASDU)
3 User data, FCV=1. Objects Info Obj. 2 Info Obj. 2 address
9 Link state request, FCV=0. Element or combination
11 Class 2 data request, FCV=1. Label time type a (5 bytes) or
The valid function codes in the frames from slaves to type b (7 bytes)
master (PRM=0) are: …
0 ACK. Positive acknowledgment. ASDU Label time (5 bytes)
1 NACK. Not accepted command.
CHECKSUM [1byte]
8 User data. Stop frame
END (16H) [1byte]
9 NACK. Data not available.
11 Link estate or access request. Figure 3: Variable length frames, showing the complete
structure of the Application Service Data Units (ASDU).
FCB FCV 23 22 21 20 PRM=1 master to slave
C RES PRM 3.1.1 Type identifier
ACD DFC Function Code PRM=0 slave to master
Bit 8 7 6 5 4 3 2 1 The type identifier is a function number to indicate
Figure 2: Control field C structure. the type of action or reading, Table I. The nomenclature
used in the IEC870-5-102 is:
2.4 Address Type identifier :=UI8[1..8]<1..255>
Is a 2 bytes slave address with values from 0 (H0000)
to 65535 (HFFFF), unique for each energy meter in the Meaning that is an 8 bits unsigned integer that can have
RS485 network. the values from 1 to 255 (H01 to HFF in hexadecimal).
The values <1..127> are defined in the IEC870-5-102,
2.5 Application Service Data Units (ASDU) while the values <128..255> are for special use and are
The Application Service Data Unit has the defined in the REE document, ref. [3].
information sent by masters or slaves en variable length
frames. Only one ASDU can be send by frame. Its Table I: Some of the type identifiers, from ref. [3]
structure will be analyzed in next section. Type identifiers
<8> Operational integrated totals, 4 octets (absolute
2.6 Checksum and END character energy meters readings, in kWh o kVArh)
It is a byte with the arithmetic addition of all frame <11> Periodically reset operational integrated totals
bytes, starting by the control field (included) until the <122> Read operational integrated totals of a selected
time range and of a selected range of addresses
checksum byte (not included). The end of the message is
<123> Read periodically reset operational integrated
indicated with the Hexadecimal byte H16. totals of a selected time range and of a selected
range of addresses
<183> Password and session start
3 APPLICATION SERVICE DATA UNITS (ASDU) <187> Closing session
4 STRUCTURE OF THE SPECIFIC APPLICATION Table IX: Command example to request total integrated
SERVICE DATA UNITS (ASDU) energy readings, ASDU 122.
Byte Nº Hexadecimal 6815 1568 7358 1B7A 0106
In the section 7.3 of the IEC870-5-102 are defined 0100 0B01 0800 0B07 020A
the ASDU with type identifiers from 1 to 127. In the 0011 0A02 0AC1 16
section 5.3 of the REE document [3] the ASDU 128 to 27 H68 Start frame byte
149 and 180 to 190. In this section are reproduced the 26 H15 length, H15=21 bytes
ASDUs for reading energy values. 25 H15 Length (duplicate)
24 H68 Start frame byte
4.1 Integrated totals by time interval 23 H73 Control field
The reading of the integrated totals energy values are 21..22 H581B Energy meter Address
performed in two steps. First the master (computer) sends 20 H7A ASDU type identifier,
the ASDU with type identifier 122 (absolute energy H7A=122, Table I
readings) or 123 (incremental energy readings) and the 19 H01 SQ=0 N=1
slave (energy meter) answer with the data contained in 18 H06 Cause, (Table II)
the ASDU with type identifier 8 (absolute) or 17 H01 Measurement point
11(incremental). The cause of transmission can be any of 15..16 H000B Record address(Table III)
the Table II for ASDUs 122 or 123 and 5 (requested) for H000B=11
ASDUs 8 and 11. The load curve are requested if the 14 H01 Address of the first integrated,
record address is 11, while if it is 21, the daily summary H01=1 (Table IV)
is requested. Load curve are integrated totals for each 13 H08 Address of the last integrated,
time period programmed in the energy meter, being H08=8 (Table IV)
multiple of 5 minutes, usually every 15 or 60 minutes. In 8..12 H000B07020A Initial label time
ASDUs 8 or 11 the time label refers to the end of the
3..7 H00110A020A End label time
integration period. The reading of the last integration
2 HC1 Checksum
period of the day D has date D+1 and time 00:00:00.
1 H16 END character
4.2 Example of reading Integrated totals by time interval
Let’s assume that energy readings by time intervals The control field is H73, 0111 0011 in binary, from
are required for dates from 7th February 2010 at 11:00 Figure 2 the 4 first bits are the function code, 00113
hours to the 10th February at 17:00 hours. It is known that decimal, i.e. User data, FCV=1). Bits 8 to 5, 0111, mean
that: RES=0 (reserve), PRM=1 (master to salve), FCB=1 <58..59> H581B Energy meter Address
(frame count bit) y FCV=1 (FCB valid). The ASDU type <57> H08 ASDU type identifier, H08=8,
identifier is H7A=Dec 122 (Table I). The energy meter Table I
address, decimal Dec 7000=H581B (swap bytes Figure <56> H08 SQ=0 N=8
7). The time labels (5 bytes) are created according Table <55> H05 Cause, (Table II)
<54> H01 Measurement point
VI.
<52..53> H000B Record address(Table III)
“7/02/10 11:00” becomes “H000B 0702 0A” as H000B=11
indicated in Table XI, where tariff info was not <21> H01 Address of the first integrated,
considered. H01=1 (Table IV)
Decimal 7000 <46..50> H1801 0000 00 Integrated total 1, Active input, 280
Binary (16 bits) 0001 1011 0101 1000 kWh
Nº bit 15..12 11..8 7..4 3..0
<45> H02 2nd integrated Address
Hex. 1 B 5 8 <40..44> H6E1F 0300 00 Integrated total2, Active output,
High-byte Low-byte 204,654 kWh
<39> H03 3rd integrated Address
<34..38> H0400 0000 00 Integrated total3, Reactive quadrant
Send data , 4 kVArh
4-dígits Hexadecimal 58 1B <33> H04 4th integrated Address
Figure 7: Energy meter address, from decimal to <28..32> H0000 0000 00 Integrated total4, Reactive quadrant
Hexadecimal. 2, 0 kVArh
<27> H05 5th integrated Address
Table X: Time label for “7/02/10 11:00” <22..26> HCCBE 0000 Integrated total5, Reactive quadrant
Time label type a (5 bytes) Dec Bin 00 3, 48,844 kVArh
minute :=UI6 0 00 0000 <21> H06 6th integrated Address
TIS=Tariff info :=BS1 0 0 <16..20> H980D 0000 00 Integrated total6, Reactive quadrant
4, 3,480 kVArh
IV=Valid :=BS1 0 0
<15> H07 7th integrated Address
Hour :=UI5 11 0 1011
<10..14> H0000 0000 80 Integrated total 7, reserve 1
RES1=Reserve1 :=BS2 0 00 <9> H08 8th integrated Address
SU=Summer time :=BS1 0 0 <8..11> H0000 0000 80 Integrated total 8, reserve 2
Month day :=UI5 7 0 0111 <3..7> H00 81B2 0909 Time label, 18 September 01:00
Week day :=UI3 0 000 <2> HE1 Checksum
Month :=UI4 2 0010 <1> H16 END
ETI=Energy tariff info :=UI2 0 00
PTI=Power tariff info :=UI2 0 00 Each integrated total energy value has 5 bytes, 4
Year :=UI7 10 000 1010 bytes for the value and the last byte for the qualifier, Fig.
RES2=Reserve2 :=BS1 0 0 5.For example, the first integrated total, Active output
energy is H6E1F 0300 00. Last byte, H00, is the qualifier
Table XI: Time label hexadecimal code derivation. and indicates a valid reading, IV=0, and values in kWh or
Bin 0000 0000 1101 0000 1110 0000 0100 0000 0101 0000 kVArh, U=0. The first 4 bytes H6E1F 0300 indicate
Bin(swap) 0000 1010 0000 0010 0000 0111 0000 1011 0000 0000 204,654 kWh of generated active energy.
Hex. 0A 02 07 0B 00
Hex. (swap) 00 0B 07 02 0A Table XIII: Integrated total Hex to Dec conversion.
Nº Byte 4 Byte 3 Byte 2 Byte 1
Finally the checksum byte is calculated form the Hex. 00 03 1F 6E
Bin. 0000 0000 0000 0011 0001 1111 0110 1110
arithmetic addition of all bytes, from the control field
Dec. 204 654
(included) to the checksum (not included), as the hex.
value of the rest of the addition divided by 256.
H73+H58+H1B+H7A+H01+H06+H01+H00+H0B+H01 4.3 Password and session start
+H08+H00+H0B+H07+H02+H0A+H00+H11+H0A+H0 An ASDU 183 (HB7) is used to send the password
2+H0A115+88+27+122+1+6+1+0+11+1+8+0+11+7+ and session start. The cause of transmission from master
2+10+0+17+10+2+10=449; Rest(449/256)=193=HC1. to salve is 6 (activation) and from slave to master can be
4.1.1 Example of command ASDU 8 7 (activation confirmation if correct password, positive
Answering to ASDU 122 the energy meter sends data confirmation if bit P/N=0 or negative if bit P/N=1, Figure
with ASDU 8. An example is presented in Table XII. 4) or 14 (ASDU not available).
Table XII: Command example sent by the energy meter Table XIV: Password and session start, ASDU 183.
with total integrated energy data, ASDU 8. Type identifier = <183>
Byte Nº Hex. 683E 3E68 0858 1B08 0805 0100 SQ=<0> Nº information objects, N=<1>
0B01 1801 0000 0002 6E1F 0300 Cause of transmission
0003 0400 0000 0004 0000 0000 Measurement point
0005 CCBE 0000 0006 980D 0000 Record address =<0>
0007 0000 0000 8008 0000 0000 Password (4 bytes)
8000 81B2 0909 E116
<64> H68 Start frame byte
<63> H3E length, H3E=62 bytes 4.3.1 Example: password and session start
<62> H3E Length (duplicate) In the case of measurement point 1, energy meter
<61> H68 Start frame byte address 7000 and password “12345678” the command
<60> H08 Control field should be H680D 0D68 7358 1BB7 0106 0100 004E
61BC 0010 16, where the password is H4E 61BC 0000 (10) The Energy meters returns an ASDU 183 (HB7) of
BC 614E12345678. correct password confirmation (control field H08),
cause H07.
(11) The computer asks to the energy meter for the
5 EXAMPLE OF A COMMAND SEQUENCE
integrated total energy values, ASDU 122(H7A),
An example of a complete commands sequence is section 4.1. The initial label time (H01 0012 0909)
presented in Table XV. As in the previous examples it is is 18/09/09 00:01:00 and the final (H0000 1309 09)
assumed an energy meter with address 7000, is 19/09/09 00:00:00.
measurement point 1 and password “07”. (12) Idem to (4), positive acknowledgment.
(13) Idem to (9), data request.
Table XV: Full commands sequence, example. (14) The Energy meter returns an ASDU 122(H7A) with
# From computer From energy meter
control field H08 (user data respond) and cause H07
(1) 1049 581B BC16 of confirmation.
(2) 100B 581B 7E16 (15) Data are again requested, but the frame count bit is
(3) 1040 581B B316
alternated with a control field H7B; i.e. PRM=0,
(4) 1000 581B 7316
(5) 1049 581B BC16 FCB=1, FCV=1 and function code 11. In each
(6) 100B 581B 7E16 request it is necessary to alternate the frame count
(7) 680D 0D68 7358 1BB7 bit, FCB. In that way the commands
0106 0100 0007 0000
0042 16 H105B581BCE16 and H107B581B EE16 are sent
(8) 1000 581B 7316 alternatively.
(9) 105B 581B BC16
680D 0D68 0858 1BB7 0107 0100 0007
(16) The Energy meter answers with the integrated total
(10)
0000 0042 16 energy data for the first requested time period, see
(11)6815 1568 7358 1B7A section 4.1.
0106 0100 0B01 0801
0012 0909 0000 1309 (19) The energy meter sends an ASDU 122(7A) of
09C6 16 integrated total request, but with a cause bit
(12) 1000 581B 7316
(13)105B 581B CE16 H0A(cause 10), showing the end of available data.
(14) 6815 1568 0858 1B7A 0107 0100 0B01 (20) Closing session with an ASDU 187 (HBB). The
0801 0012 0909 0000 1309 095C 16
(15)107B 581B EE16
Energy meter sends (21) a positive
(16) 683E 3E68 0858 1B08 0805 0100 0B01 acknowledgement. A data request is sent (22),
1801 0000 0002 6E1F 0300 0003 0400 0000 considering the previous FCB and finally (23) the
0004 0000 0000 0005 CCBE 0000 0006
980D 0000 0007 0000 0000 8008 0000 energy meter sends a closing session ASDU 187 and
0000 8000 81B2 0909 E116 cause H07 of confirmation.
(17)105B 581B EE16
(18) 683E 3E68 0858 1B08 0805 0100 0B01
1801 0000 0002 6E1F 0300 0003 0400 0000
0004 0000 0000 0005 CCBE 0000 0006 6 REFERENCES
980D 0000 0007 0000 0000 8008 0000
0000 8000 82B2 0909 E216
…Sequence is repeated
alternating the Frame [1] RD 1110/2007, BOE 224 of 18 September 2007.
Count Bit... Unified Regulation of electric system measurement.
(19) 6815 1568 0858 1B7A 010A 0100 0B01
0801 0012 0909 0000 1309 095F 16 [2] IEC 870-5-102. Telecontrol equipment and systems.
(20)6809 0968 5358 1BBB Par 5: Transmission protocols. Section 102: Companion
0006 0100 0088 16 standard for the transmission of integrated total in electric
(21) 1000 581B 7316
power systems. First Ed. 1996-06.
(22)107B 581B EE16
6809 0968 5358 1BBB 0007 0100 0088 16
[3] RED ELÉCTRICA ESPAÑOLA, REE. Reglamento
(23)
de puntos de medida. Protocolo de comunicaciones entre
registradores y concentradores de medidas o terminales
The commands interpretation of Table XV is the
de medidas o terminales portátiles lectura. Revisión
following:
10.04.02, 10 de Abril de 2002.
(1) The computer (master) starts the communication
[4] UNE EN 62 056-21 section 4.
with a fixed length frame. Control field H49; i.e.
PRM=1 and function code 9, Figure 2.
(2) The energy meter answers with a control field H0B,
i.e. function code 11.
(3) The computer sends a control field H40; i.e. PRM=1
and function code 0: Remote link reposition.
(4) Control field H00, PRM=0 y function code 0: ACK,
positive acknowledgment type confirm.
(7) Password sent, see section 4.2.
(8) Idem to (4)
(9) Control field H5B=Bin 0101 1011, i.e. PRM=1,
FCV=1 and function code 11: Class 2 data request.