M-Bus (Meter-Bus)

M-Bus dataSources

M-Bus datasources (later just dataurls) consist of multiple parts, just like regular http-urls do. Here is an example of mbus dataSource: mbus://ioPorts%2FmbusSerial%2FP1/12016562/datarecords/5/value?scale=10&lolimit=0

The dataurl can be split into parts which are separated by / character.

protocol

mbus://

This part tells the mbus library which protocol to use.

ioPort

ioPorts%2FmbusSerial%2FP1 This is the point name to the ioPort we want to use. The / in point name needs to be replaced with %2F (urlencoding)

address

12016562

This is the slave address of the device we’re reading from

data records

datarecords

Data records are the actual data measured by the meter.

data index

5

This is the data we want to read. Index starts from 0 and the data type of specific indexes depends on the meter.

value

value This simply tells the mbus library to read the value from the data index.

parameters

Optional parameters can be used to manipulate the raw data value. First parameter is separated from the value with the character ? and subsequent parameters with & Syntax for parameters is parameterName=value, e.g. scale=0.1 Some useful parameters

scale:

multiplies the raw value with scale value. e.g. value of 0.1 makes 100->10

datatype:

datatype for the register value, e.g. int16 or float32

offset:

sets offset for raw value

invert:

invert (raw value is subtracted from this value. Mainly useful for binary data)

x1,y1,x2,y2..xn,yn:

set scaling curve for raw value. Excel or other assistive tools are recommended

hilimit, lolimit:

set high or low limit for the pv value

damping:

floating average between reading rounds

bitmask:

bitmask to select/unselect individual bits from raw. On dataSource, when raw value is read from register, bitwise AND operation is performed between bitmask parameter and raw value, and result is written to pv.

ondelay, offdelay:

Time in milliseconds between raw<->pv change

It’s rarely meaningful to build these dataurls by hand. Excel, IO-profiles or other means are strongly recommended to be used when importing dataUrls to database. Imagination is the only limiting factor :) Manually editing dataUrls makes sense mainly when debugging or testing new devices and finding out the registers.

M-Bus-task logic

When Actiweb9 core (re)starts, mbus-task scans the database and finds all datapoints that have mbus related dataSources. It then matches the points to ioPorts and every ioPort starts its own parallel task. This means that reading different mbus busses happens concurrently and if one mbus task hangs it does not affect other mbus tasks. This also means that if any changes are made to the dataSources the core needs to be restarted for the changes to apply.

After reading register

When mbus task has read the register it will push that raw value to a field called raw. If the dataUrl has any parameters configured it will then apply those to the raw value. Order of the parameters is as follows:

  1. scale + offset

  2. inline curve

  3. bitmask

  4. datatype casting

The result value will then be stored in pv field.

Recap

For reading: mbus peripheral device -> raw -> pv

Tip

Overriding pv value

If user wants to override the value of the database point it can be done by first adding priority field and then setting it to 8 and writing wanted value to the pv field. If using graphical UI this behaviour will automated in the value setting dialog when priority field is present