FB_MBUS_General_Ext

FB_MBUS_General_Ext 1:

Some M-Bus devices send values distributed over several telegrams. The function block FB_MBUS_General_Ext can be used to read all telegrams from any M-Bus devices.

The variable arrTelegram[1..cMBUS_MaxTelegrams].arrData[1..cMBUS_MaxData] supplies a maximum of cMBUS_MaxData data from a maximum of cMBUS_MaxTelegrams telegrams. String values and vendor-specific information are not shown correctly.

The number of telegrams to be read can be changed with the constant cMBUS_MaxTelegrams.

The number of data per telegram to be read can be changed with the constant cMBUS_MaxData.

The function block FB_MBUS_General_Ext can only be executed together with the function block FB_MBUSKL6781().

FB_MBUS_General_Ext 2:

Further information

See Operating principle of the function block

FB_MBUS_General_Ext 3: Inputs

VAR_INPUT
  usiAddress   : USINT;
  stSecAdr     : ST_MBUS_SecAdr;
  eBaudrate    : E_MBUS_Baudrate := eMBUS_Baud2400;
  bStart       : BOOL;
  bSND_NKE     : BOOL := TRUE;
  bReadInit    : BOOL := TRUE;
  tMinSendTime : TIME := t#2s;
  usiUnit      : USINT;
  bDisabled    : BOOL := FALSE;
END_VAR

Name

Type

Description

usiAddress

USINT

Primary address of the meter to be read with this function block.

stSecAdr

ST_MBUS_SecAdr

Secondary address of the meter to be read with this function block.

eBaudrate

E_MBUS_Baudrate

300, 600, 1200, 2400, 4800, 9600 baud

bStart

BOOL

All meters are read once on the positive edge of this input.

bSND_NKE

BOOL

TRUE initializes the meter for each read operation and sets the meter to the first telegram (SND_NKE).

bReadInit

BOOL

If the PLC is restarted, the meter is read once.

tMinSendTime

TIME

Default t#2s. The meter is read again, once the time set here has elapsed. If t#0s the meter is not read and can be read manually with bStart.

usiUnit

USINT

Unit of the energy values to be output by the function block. 0=W(h) / 1=KW(h) / 2 =MW(h) / 3=GW(h).

bDisabled

BOOL

TRUE = deselection of the function block

FB_MBUS_General_Ext 4: Inputs/outputs

VAR_IN_OUT
  stCom : ST_MBUS_Communication;
END_VAR

Name

Type

Description

stCom

ST_MBUS_Communication

This structure is used to link the function block FB_MBUSKL6781() with the meter blocks.

FB_MBUS_General_Ext 5: Outputs

VAR_OUTPUT
  bBusy          : BOOL;
  bReady         : BOOL;
  bError         : BOOL;
  eError         : E_MBUS_ERROR;
  dwIdNumber     : DWORD;
  byStatus       : BYTE;
  byGEN          : BYTE;
  byCounter      : BYTE;
  usiRecivedAdr  : USINT;
  eMedium        : E_MBUS_Medium;
  sMan           : STRING(3);
  arrTelegram    : ARRAY [1..cMBUS_MaxTelegrams] OF ST_MBus_Data2;
END_VAR

Name

Type

Description

bBusy

BOOL

The bBusy output is TRUE as long as the meter is being read.

bReady

BOOL

The bReady output is TRUE for one cycle, once meter reading is completed.

bError

BOOL

This output goes TRUE as soon as an error occurs. This error is described via the eError variable.

eError

E_MBUS_ERROR

This output outputs an error code in the event of an error. bError goes TRUE at the same time.

dwIdNumber

DWORD

Serial number of the meter (secondary address)

byStatus

BYTE

Device status

byGEN

BYTE

Software version of the device

byCounter

BYTE

Number of times the master has accessed data of the respective slave

usiRecivedAdr

USINT

Received primary address (0-250)

eMedium

E_MBUS_Medium

Medium

sMan

STRING

Manufacturer sign

arrTelegram

ARRAY OF ST_MBus_Data2

Maximum cMBUS_MaxTelegrams telegrams. The meaning of the values is explained in the M-Bus protocol for the device.

Requirements

Development Environment

PLC library to include

TwinCAT from v3.1.4020.14

Tc2_MBus from 3.3.5.0