Long set
Data is sent to the M-bus device with a long set. The long set is composed of a maximum of 255 bytes and is transferred to the counter with the FB_MBUS_General_Send block.
Structure of the protocol:
Byte | Long set | Description | Assignment in the ‘FB_MBUS_General_Send’ block |
---|---|---|---|
1 | Start character | 68hex | Is added in the block |
2 | L field | Length of user data plus 3 | Is added in the block |
3 | L field | Length of user data plus 3 | Is added in the block |
4 | Start character | 68hex | Is added in the block |
5 | C field | Function field | Is transferred to the ‘byC_Field’ input variable |
6 | A field | Primary address of the M-Bus device | Is transferred to the ‘usiAddress’ input variable |
7 | CI Field | Identifier field | Is transferred to the ‘byCI_Field’ input variable |
8..x | User data (0 – 240) | User data | Are transferred to the ‘arrData’ input variable |
x+1 | Checksum | Checksum | Is added in the block |
x+2 | Stop character | 16hex | Is added in the block |
Only the bytes marked in bold letters need to be transferred to the block.
The user data in the arrData array must contain ‘16hex’ as the last character. It is important to ensure that the subsequent bytes are empty.
Example: Changing the primary address at address 14, old address is 0.
(*Transfer of user data*)
fbSend.arrData[0] := 16#01; (*DIF / Data format 8 -bit integer*)
fbSend.arrData[1] := 16#7A; (*VIF / Change address*)
fbSend.arrData[2] := 14; (*New address = 14*)
fbSend.arrData[3] := 16#16; (*Do not transfer stop character/checksum; they will be calculated in the block*)
fbSend.byC_Field := 16#53; (*C field*)
fbSend.byCI_Field := 16#51; (*CI field*)
fbSend.usiAddress := 0; (*Old address*)
fbSend(iComId := 1, (*Block call*)
bStart := bStart,
bInit := TRUE);
Sending is started with the bStart variable. The bStart variable is reset in the block after sending is complete.
Download sample program for PC/CX systems:
Download sample program for BC systems:
Download sample program for BX systems: