define(`TITLE', `M-Bus Master, Part 1 (Basics)')
define(`DATE', `2018-07-24')
define(`CONTENT', `
(Sorry, all images lost in a former migration.)

<p>
The M-Bus (short for meter-bus) is primarily used for household meters for water, gas and electric power. See <a href="http://www.m-bus.com" title="www.m-bus.com" target="_blank">here</a> and <a href="https://en.wikipedia.org/wiki/Meter-Bus" title="Meter-Bus (Wikipedia)" target="_blank">here</a>.
</p>

<p>
This is an attempt to build a simple master for this bus, which is a single-master multiple-slave bus, to be controlled using an Arduino system.
</p>

<p>
<a href="http://a385e-5.de/wp-content/uploads/2013/07/laser-drucker_005070.jpg"><img src="http://a385e-5.de/wp-content/uploads/2013/07/laser-drucker_005070-300x218.jpg" alt="laser-drucker_005070" width="300" height="218" class="alignnone size-medium wp-image-118" /></a>
</p>

<p>
Master to slave communication is performed by lowering the voltage at the bus by 12V, so here, from 30V to 18V. In the above schematic, T2 and IC1 together with the divider of R1 and R2 are forming a voltage source. When T1 is blocking, the bottom part of the divider is inactive and full 30V is the reference for the voltage source and the output voltage at the bus is 30V. When T1 is conducting (high signal at TX), the bottom part of the divider becomes active and the reference voltage is lowered to 18V, consequently the output voltage at the bus is 18V too.
</p>

<p>
(Maybe the signal driving T1 needs to be inverted first to get the correct logical polarity, not yet verified.)
</p>

<p>
This is the waveform with a feed of 10kHz at TX:
</p>

<p>
<a href="http://a385e-5.de/wp-content/uploads/2013/07/TX.jpg"><img src="http://a385e-5.de/wp-content/uploads/2013/07/TX-300x219.jpg" alt="TX" width="300" height="219" class="alignnone size-medium wp-image-123" /></a>
</p>

<p>
Ch. 2 (blue) is the input signal from the function generator, Ch. 1 (yellow) is the output signal at the bus terminals. It still needs to be verified whether the setup time (delay between falling edge of input and raising edge of output) is short enough.
</p>

<p>
R5 is a current sense for the receive path, R4 is a ground-load for an open bus and C1 serves to filter the output voltage. Only a rather small capacitor is used here to only filter the high-frequency noise (around 1MHz) from the source but not the signal of about 10kHz fed through T1 from TX.
</p>

<p>
Slave to master communication is performed by changing the current sinked by the slave. A logical "1" is signalled by a current of maximum 1,5mA, a logical "0" is signalled by a current of 11-20mA. This is sensed at R5 and needs to be conditioned before feeding as RX into the microcontroller.
</p>

<p>
The voltage over R5 is in the low load situation about 100mV, in the high load situation about 1V. These are good voltages to block or conduct a PNP transistor, in the following schematic T3.
</p>

<p>
<a href="http://a385e-5.de/wp-content/uploads/2013/07/schematic1.png"><img src="http://a385e-5.de/wp-content/uploads/2013/07/schematic1-255x300.png" alt="schematic1" width="255" height="300" class="alignnone size-medium wp-image-128" /></a>
</p>

<p>
The voltage of the signal at the point RX is limited using a Z-diode to fit into the range acceptable for a microcontroller. It is:
</p>

<p>
<a href="http://a385e-5.de/wp-content/uploads/2013/07/NewFile2.png"><img src="http://a385e-5.de/wp-content/uploads/2013/07/NewFile2-300x219.png" alt="NewFile2" width="300" height="219" class="alignnone size-medium wp-image-130" /></a>
</p>

<p>
Ch. 1 (yellow) is the signal from the generator to switch the load situation, Ch. 2 (blue) the signal at RX.
</p>

<p>
The MOSFET T1 has been replaced by a NPN transistor BC547, the waveforms are still very good:
</p>

<p>
<a href="http://a385e-5.de/wp-content/uploads/2013/07/NewFile3.png"><img src="http://a385e-5.de/wp-content/uploads/2013/07/NewFile3-300x219.png" alt="NewFile3" width="300" height="219" class="alignnone size-medium wp-image-129" /></a>
</p>

<p>
Ch. 1 (yellow) is the voltage on the M-bus terminal, Ch. 2 (blue) is the generator signal at TX.
</p>

')