AN451
W
I R E L E S S
M-B
US
S
OFTWA RE
I
MPLEMENTATION
1. Introduction
This application note describes the Silicon Labs implementation of Wireless M-Bus using a Silicon Labs C8051
MCU and EZRadioPRO
®
. Wireless M-bus is a European Standard for meter-reading applications using the
868 MHz frequency band.
1.1. Stack Layers
Wireless M-Bus uses the 3-layer IEC model, which is a subset of the 7-layer OSI model (see Figure 1).
Application
EN 13757-3
MCU
app
Data Link
EN 60870-5-2
mbus
phy
PHY
EN 13757-4
Figure 1. Stack Layers
Si443x
The Physical (PHY) layer is defined in EN 13757-4. The physical layer defines how the bits are encoded and
transmitted, the RF modem characteristics (chip rate, preamble, and synchronization word), and RF parameters
(modulation, center frequency, and frequency deviation).
The PHY layer is implemented using a combination of hardware and firmware. The EZRadioPRO performs all of
the RF and modem functions. The EZRadioPRO is used in FIFO mode with the packet handler. The MbusPhy.c
module provides SPI interface, encoding/decoding, block read/write, and packet handling and manages the
transceiver states.
The M-Bus Data link layer is implemented in the MbusLink.c module. The M-Bus Application Programming
interface consists of public functions that may be called from the application layer in the main thread. The
MbusLink module also implements the Data Link Layer. The Data link layer will format and copy data from the
application TX buffer to the MbusPhy TX buffer, adding the required headers and CRCs.
The Application layer itself is not part of the M-bus firmware. The application layer defines how a wide variety of
data is to be formatted for transmission. Most meters only need to transmit one or two types of data. Adding a large
amount of code to accommodate any kind of data to the meter would add unnecessary code and cost to the meter.
It might be feasible to implement a library or a header file with an exhaustive list of data types. However, most
metering customers know exactly what kind of data they need to transmit and can refer to the standard for
formatting details. A universal reader or sniffer might implement a complete set of application data types on the PC
GUI. For these reasons, the application layer is implemented using example applications for a meter and reader.
Rev. 0.1 2/10
Copyright © 2010 by Silicon Laboratories
AN451
AN451
1.2. Required Standards
1.2.1. EN 13757-4
EN 13757-4
Communication system for meters and remote reading of meters
Part 4: Wireless meter readout
Radio meter reading for operation in the 868 MHz to 870 MHz SRD band
1.2.2. EN 13757-3
Communication system for meters and remote reading of meters
Part 3: Dedicated application layer
1.2.3. IEC 60870-2-1:1992
Telecontrol equipment and systems
Part 5: Transmission protocols
Section 1:Link transmission procedure
1.2.4. IEC 60870-1-1:1990
Telecontrol equipment and systems
Part 5: Transmission protocols
Section 1: Transmission frame formats
1.3. Definitions
M-Bus—M-Bus
is a wired standard for meter reading in Europe.
Wireless M-Bus—Wireless
M-Bus for meter reading applications in Europe.
PHY—Physical
Layer defines how data bits and bytes are encoded and transmitted.
API—Application
Programmer interface.
LINK—Data
Link Layer defines how blocks and frames are transmitted.
CRC—Cyclic
Redundancy Check.
FSK—Frequency
Shift Keying.
Chip—Smallest
unit of transmitted data. One data bit is encoded as multiple chips.
Module—A
C code source .c file.
2
Rev. 0.1
AN451
2. M-Bus PHY Functional Description
2.1. Preamble Sequence
The Preamble sequence specified by the M-bus specification is an integer number alternating zeros and ones. A
one is defined as the higher frequency, and a zero is defined as the lower frequency.
n x (01)
The Preamble options for the Si443x is an integer number of nibbles consisting of alternating ones and zeros.
n x (1010)
A preamble with an extra leading one would not be a problem, but, then, the synchronization word and payload
would be misaligned by one bit.
The solution is to invert the entire packet by setting the
eninv
bit in the
Modulation Control 2
register (0x71). This
will invert the preamble, sync word, and TX/RX data. As a consequence, the data should be inverted when writing
the TX data or reading the RX data. Also, the synchronization word is inverted before writing to the Si443x
Synchronization Word registers.
2.2. Synchronization Word
The synchronization word required by EN-13757-4 is either 18 chips for Mode S and Mode R or 10 chips for
Mode T. The synchronization word for the Si443x is 1 to 4 bytes. However, since the synchronization word is
always preceded by the preamble, the last six bits of the preamble can be considered part of the synchronization
word; so, the first synchronization word is padded by three repetitions of a zero followed by a one. The
synchronization word is complemented before writing to the Si443x registers.
Table 1. Synchronization Word for Mode S and Mode R
EN 13757-4
00
00
pad with (01) x 3
01010100
54
complement
10101011
AB
01110110
76
01110110
76
10001001
89
10010110
96
10010110
96
01101001
69
binary
hex
binary
hex
binary
hex
SYNCH
WORD
3
SYNCH
WORD
2
Si443x Register
SYNCH
WORD
1
Rev. 0.1
3
AN451
Table 2. Synchronization Word for Mode T Meter to Other
EN 13757-4
00
00
pad with (01) x 3
01010100
54
complement
10101011
AB
00111101
3D
00111101
3D
11000010
C2
binary
hex
binary
hex
binary
hex
SYNCH
WORD
3
SYNCH
WORD
2
Si443x register
2.3. Transmit Preamble Length
The minimum preamble is specified for four different operating modes. It is acceptable to have a preamble longer
than specified. Subtracting six chips for the preamble gives the minimum number of chips for the Si443x preamble.
The implementation adds two extra nibbles of preamble in all short preamble modes to improve preamble detection
and interoperability. The preamble on Mode S with a long preamble is very long; so, the minimum preamble is
used. The preamble length in nibbles is written to the Preamble Length (0x34) register. The preamble length
register determines the preamble upon transmission only. The minimum specification and preamble length settings
are summarized in Table 3.
Table 3. Transmit Preamble Length
EN-13757-4
minimum
n x (01)
Mode S short preamble
Mode S long preamble
Mode T (meter-other)
Mode R
15
279
19
39
chips
30
558
38
78
Si443x Preamble
Setting
nibbles
8
138
10
20
chips
32
552
40
80
Sync
Word
chips
6
6
6
6
Total
chips
38
558
46
86
extra
chips
8
0
8
8
The minimum preamble for reception is determined by the Preamble Detection Control register (0x35). Upon
reception, the number of bits in the sync word must be subtracted from the specified minimum preamble to
determine the usable preamble. The minimum settling time of the receiver is 16-chips if AFC is enabled or 8-chips
if AFC is disabled. The receiver settling time is also subtracted from the usable preamble to determine the
minimum setting for the Preamble Detection Control register.
4
Rev. 0.1
AN451
The probability of a false preamble depends on the setting of the Preamble Detection Control register. A short
setting of 8-chips may result in a false preamble detected every few seconds. The recommended setting of 20-
chips makes false preamble detection an unlikely event. The preamble lengths for Mode R and Mode SL are
sufficiently long for the recommended setting to be used. There is very little benefit to making the preamble detect
longer than 20 chips.
The AFC is disabled for Mode S with a short preamble and Mode T. This reduces the receiver settling time and
permits a longer preamble detection setting. With AFC disabled, Mode T can use the recommended setting of 20
chips. A setting of 4 nibbles or 20 chips is used for Mode S with a short preamble. This makes the probability of a
false preamble detection slightly higher for this mode.
Table 4. Preamble Detection
EN-13757-4
minimum
n x (01)
Mode S short preamble
Mode S long preamble
Mode T (meter-other)
Mode R
*Note:
AFC disabled
Sync
Word
chips
6
6
6
6
usable
RX Settling
preamble
chips
24
552
32
72
chips
8*
16
8*
16
Detect
min
chips
16
536
24
56
Si443x Preamble
Detection Setting
nibbles
4
5
5
5
chips
16
20
20
20
chips
30
558
38
78
15
279
19
39
The receiver is configured to interoperate with a transmitter using the minimum specified preamble. This ensures
the receiver will interoperate with any M-bus-compliant transmitter.
The Wireless M-Bus specification requires a very long preamble for Mode S1 of at least 558 chips. This will take
about 17 ms just to transmit the preamble. The Si443x does not require such a long preamble and does not benefit
from the long preamble. While the long preamble is noted as optional for Mode S2, there is no reason to use a long
preamble with the Si443x. If one-way communication is desired, Mode T1 will provide a shorter preamble, higher
data rate, and longer battery life. If two-way communication using Mode S2 is required, the short preamble is
recommended.
Notice that the detection threshold for Mode S with a long preamble is longer than the number of preamble nibbles
transmitted for Mode S with a short preamble. This means that the long preamble Mode S receiver will not detect a
preamble from a short preamble Mode S transmitter. This is necessary if the long preamble Mode S receiver is to
receive any benefit from the longer preamble.
Note that the short preamble Mode S receiver will detect the preamble and receive packets from both a short-
preamble Mode S transmitter and a long-preamble Mode S transmitter; so, in general, the meter reader should use
the short preamble Mode S receiver configuration.
Rev. 0.1
5