Function Blocks

Function blocks

MasterUDP (FB)

Overview

The MasterUDP function block serves as the KNX driver for communication with a KNX Net/IP gateway. It processes telegrams and coordinates communication with slave function blocks.

Inputs

Inputs
Initial value
Description

xEnable

TRUE

Turn the function block on/off

sIPAddressKNXInterface

''

IP address of the KNX interface

uiPortKNXInterface

gc_LibPara.gc_uiPort

Port number of the KNX interface

itfNetworkInterface

-

Network interface for communication

uiPortPLC

gc_LibPara.gc_uiPortLocal

Port number of the PLC

xResError

FALSE

Error reset flag

tResponseTimeout

gc_LibPara.gc_tResponseTimeout

Timeout duration for requests

Outputs

  • xConnected (BOOL): Connection status

  • itfKnxConnector (IKnxConnector): Interface for slave blocks

  • udiConnectedSlaves (UDINT): Number of connected modules

  • eStatus (KnxStatus): Current KNX connection status

  • stDeviceInfo (DeviceInfo): Device information

  • stKnxData (KnxData): KNX data structure

  • bChannel (BYTE): Communication channel identifier

  • eError (ErrorKnx): Current error status

  • eLastError (ErrorKnx): Last error

Usage

  1. Configure the KNX interface with sIPAddressKNXInterface and uiPortKNXInterface.

  2. Set uiPortPLC according to your PLC configuration.

  3. Activate the block with xEnable = TRUE.

  4. Monitor xConnected for the connection status.

  5. Use itfKnxConnector to interact with slave blocks.

  6. Check eStatus and eError regularly.

  7. Use xResError to reset error states.

Notes

  • Ensure correct network settings (itfNetworkInterface) are in place.

  • Adjust tResponseTimeout if necessary to account for network latency.

General about KNX_Read_DPT_xx

The usage of all KNX_Read_DPT_xx function blocks follows a similar pattern:

  1. Configure group address:

    • Set byAdrMainGroup (0-31)

    • Set byAdrMiddleGroup (0-7)

    • Set byAdrGroup (0-255)

  2. Select DPT format:

    • Choose the desired format via eDPT_Format

  3. Configure read behavior:

    • For cyclic reading: Set tRequestTime to the desired interval

    • For event-based reading: Use xRequest or xRequestVisu if needed

  4. Configure initialization:

    • Set eInitOption to InitOption.PollingOnStartUp or InitOption.InitValue

    • When InitOption.InitValue: Set the corresponding initial value:

      • DPT_13x: diInitValue

      • DPT_14x: rInitValue

      • DPT_19x: dtInitValue (not effective)

  5. Monitor outputs:

    • Check tNextRequest for the time of the next read operation

    • Monitor the corresponding value outputs:

      • DPT_13x: diValue, rValue

      • DPT_14x: rValue

      • DPT_19x: wYear, wMonth, wDayOfMonth, wDayOfWeek, wHourOfDay, wMinutes, wSeconds

    • For DPT_13x and DPT_14x: Note sUnit for the unit

  6. Error handling:

    • Monitor the error outputs of the parent SlaveBasic block

KNX_Read_DPT_1x (FB)

Overview

Read function for DPT 1.x (1-bit).

Inputs

Inputs
Initial value
Description

xRequest

FALSE

Trigger for single read

xRequestVisu

FALSE

Trigger for single read (visualization)

tRequestTime

T#0S

Interval for cyclic reading

eDPT_Format

-

DPT 1.x format selection

byAdrGroup

0

Group address (0-255)

byAdrMiddleGroup

0

Middle group address (0-7)

byAdrMainGroup

0

Main group address (0-31)

xInitValue

FALSE

Initial value when InitOption.InitValue

eInitOption

-

initialization option

Outputs

  • xValue (BOOL): Received boolean value

  • Encoding (STRING[15]): Textual representation of the value

  • tNextRequest (TIME): Time until the next read operation

Usage

  1. Select the DPT 1.x format with eDPT_Format.

  2. Configure the read options:

    • For cyclic reading: tRequestTime > T#0S

    • For event-based reading: Use xRequest or xRequestVisu

  3. Set eInitOption and if applicable xInitValue for initialization.

  4. Monitor xValue for received values and Encoding for the textual representation.

KNX_Read_DPT_2x (FB)

Overview

Read function for DPT 2.x (1-bit controlled).

Inputs

Inputs
Initial value
Description

xRequest

FALSE

Trigger for single read

xRequestVisu

FALSE

Trigger for single read (visualization)

tRequestTime

T#0S

Interval for cyclic reading

eDPT_Format

-

DPT 2.x format selection

byAdrGroup

0

Group address (0-255)

byAdrMiddleGroup

0

Middle group address (0-7)

byAdrMainGroup

0

Main group address (0-31)

xInitValue

FALSE

Initial value when InitOption.InitValue

eInitOption

-

initialization option

Outputs

  • xValue (BOOL): Received boolean value

  • xControlBit (BOOL): Received control bit

  • tNextRequest (TIME): Time until the next read operation

Usage

  1. Select the DPT 2.x format with eDPT_Format.

  2. Configure the read options as with DPT 1.x.

  3. Monitor xValue for the main value and xControlBit for the control bit.

KNX_Read_DPT_5x (FB)

Overview

Read function for DPT 5.x (8-bit unsigned).

Inputs

Inputs
Initial value
Description

xRequest

FALSE

Trigger for single read

xRequestVisu

FALSE

Trigger for single read (visualization)

tRequestTime

T#0S

Interval for cyclic reading

eDPT_Format

-

DPT 5.x format selection

byAdrGroup

0

Group address (0-255)

byAdrMiddleGroup

0

Middle group address (0-7)

byAdrMainGroup

0

Main group address (0-31)

iInitValue

0

Initial value when InitOption.InitValue

eInitOption

-

initialization option

Outputs

  • iValue (INT): Received integer value

  • sUnit (STRING[10]): Unit of the value

  • tNextRequest (TIME): Time until the next read operation

Usage

  1. Select the DPT 5.x format with eDPT_Format.

  2. Configure the read options as with the previous blocks.

  3. Monitor iValue for received values and sUnit for the unit.

KNX_Read_DPT_6x (FB)

Overview

Read function for DPT 6.x (8-bit signed).

Inputs

Inputs
Initial value
Description

xRequest

FALSE

Trigger for single read

xRequestVisu

FALSE

Trigger for single read (visualization)

tRequestTime

T#0S

Interval for cyclic reading

eDPT_Format

-

DPT 6.x format selection

byAdrGroup

0

Group address (0-255)

byAdrMiddleGroup

0

Middle group address (0-7)

byAdrMainGroup

0

Main group address (0-31)

iInitValue

0

Initial value when InitOption.InitValue

eInitOption

-

initialization option

Outputs

  • iValue (INT): Received integer value

  • sUnit (STRING[10]): Unit of the value

  • xStatus_A to xStatus_E (BOOL): Status bits (only for DPT 6.020)

  • xMode_0 to xMode_2 (BOOL): Mode bits (only for DPT 6.020)

  • tNextRequest (TIME): Time until the next read operation

Usage

  1. Select the DPT 6.x format with eDPT_Format.

  2. Configure the read options as with the previous blocks.

  3. Monitor iValue for received values and sUnit for the unit.

  4. For DPT 6.020: Note the additional status and mode bits.

KNX_Read_DPT_9x (FB)

Overview

Read function for DPT 9.x (2-byte floating point).

Inputs

Inputs
Initial value
Description

xRequest

FALSE

Trigger for single read

xRequestVisu

FALSE

Trigger for single read (visualization)

tRequestTime

T#0S

Interval for cyclic reading

eDPT_Format

-

DPT 9.x format selection

byAdrGroup

0

Group address (0-255)

byAdrMiddleGroup

0

Middle group address (0-7)

byAdrMainGroup

0

Main group address (0-31)

rInitValue

0.0

Initial value when InitOption.InitValue

eInitOption

-

initialization option

Outputs

  • rValue (REAL): Received floating point value

  • sUnit (STRING[10]): Unit of the value

  • tNextRequest (TIME): Time until the next read operation

Usage

  1. Select the DPT 9.x format with eDPT_Format.

  2. Configure the read options as with the previous blocks.

  3. Monitor rValue for received values and sUnit for the unit.

KNX_Read_DPT_13x (FB)

Overview

Read function for DPT 13.x (4-byte signed value).

Inputs

Inputs
Initial value
Description

xRequest

FALSE

Trigger for single read

xRequestVisu

FALSE

Trigger for single read (visualization)

tRequestTime

T#0S

Interval for cyclic reading

eDPT_Format

-

DPT 13.x format selection

byAdrGroup

0

Group address (0-255)

byAdrMiddleGroup

0

Middle group address (0-7)

byAdrMainGroup

0

Main group address (0-31)

diInitValue

0

Initial value when InitOption.InitValue

eInitOption

-

initialization option

Outputs

  • diValue (DINT): Received integer value

  • rValue (REAL): Received floating point value

  • rFactor (REAL): Scaling factor

  • sUnit (STRING[10]): Unit of the value

  • tNextRequest (TIME): Time until the next read operation

Usage

  1. Select the DPT 13.x format with eDPT_Format.

  2. Configure the read options:

    • For cyclic reading: tRequestTime > T#0S

    • For event-based reading: Use xRequest or xRequestVisu

  3. Set eInitOption and if applicable diInitValue for initialization.

  4. Monitor diValue or rValue for received values and sUnit for the unit.

KNX_Read_DPT_14x (FB)

Overview

Read function for DPT 14.x (4-byte floating point value).

Inputs

Inputs
Initial value
Description

xRequest

FALSE

Trigger for single read

xRequestVisu

FALSE

Trigger for single read (visualization)

tRequestTime

T#0S

Interval for cyclic reading

eDPT_Format

-

DPT 14.x format selection

byAdrGroup

0

Group address (0-255)

byAdrMiddleGroup

0

Middle group address (0-7)

byAdrMainGroup

0

Main group address (0-31)

rInitValue

0.0

Initial value when InitOption.InitValue

eInitOption

-

initialization option

Outputs

  • rValue (REAL): Received floating point value

  • sUnit (STRING[10]): Unit of the value

  • tNextRequest (TIME): Time until the next read operation

Usage

  1. Select the DPT 14.x format with eDPT_Format.

  2. Configure the read options:

    • For cyclic reading: tRequestTime > T#0S

    • For event-based reading: Use xRequest or xRequestVisu

  3. Set eInitOption and if applicable rInitValue for initialization.

  4. Monitor rValue for received values and sUnit for the unit.

KNX_Read_DPT_19x (FB)

Overview

Read function for DPT 19.x (date and time).

Inputs

Inputs
Initial value
Description

xRequest

FALSE

Trigger for single read

xRequestVisu

FALSE

Trigger for single read (visualization)

tRequestTime

T#0S

Interval for cyclic reading

eDPT_Format

-

DPT 19.x format selection

byAdrGroup

0

Group address (0-255)

byAdrMiddleGroup

0

Middle group address (0-7)

byAdrMainGroup

0

Main group address (0-31)

dtInitValue

-

Initial value (not effective)

eInitOption

-

initialization option

Outputs

  • wYear (WORD): Year

  • wMonth (WORD): Month

  • wDayOfMonth (WORD): Day of the month

  • wDayOfWeek (WORD): Day of the week

  • wHourOfDay (WORD): Hour

  • wMinutes (WORD): Minutes

  • wSeconds (WORD): Seconds

  • tNextRequest (TIME): Time until the next read operation

Usage

  1. Select the DPT 19.x format with eDPT_Format.

  2. Configure the read options:

    • For cyclic reading: tRequestTime > T#0S

    • For event-based reading: Use xRequest or xRequestVisu

  3. Set eInitOption for initialization (note that dtInitValue is not effective).

  4. Monitor the individual time components (wYear, wMonth, etc.) for received values.

KNX_Read_Data (FB)

Overview

The KNX_Read_Data function block is used to receive KNX data without specific DPT conversion. It is particularly useful for progressive controls, such as in lighting control.

Inputs

Inputs
Initial value
Description

byAdrGroup

0

Group address (0-255)

byAdrMiddleGroup

0

Middle group address (0-7)

byAdrMainGroup

0

Main group address (0-31)

Outputs

  • abyDaten (ARRAY[0..38] OF BYTE): Received raw data

Usage

  1. Configure group address:

    • Set byAdrMainGroup (0-31)

    • Set byAdrMiddleGroup (0-7)

    • Set byAdrGroup (0-255)

  2. Data reception:

    • The block automatically receives data when it is sent to the configured group address.

    • The received data is stored in the abyDaten array.

  3. Data processing:

    • The received data in the abyDaten array can be further processed as needed.

    • Since no DPT conversion takes place, you must interpret the data yourself.

General about KNX_Write_DPT_xx

The usage of all KNX_Write_DPT_xx function blocks follows a similar pattern:

  1. Configure group address:

    • Set byAdrMainGroup (0-31)

    • Set byAdrMiddleGroup (0-7)

    • Set byAdrGroup (0-255)

  2. Select DPT format:

    • Choose the desired format via eDPT_Format

  3. Set send value:

    • Set the value to be sent at the corresponding input:

      • DPT_1x: xValue (BOOL)

      • DPT_2x: xValue (BOOL) and xPrio (BOOL)

      • DPT_6x: iValue (INT)

      • DPT_9x: rValue (REAL)

      • DPT_13x: diValue (DINT)

      • DPT_14x: rValue (REAL)

  4. Configure send behavior:

    • For cyclic sending: Set tTimeUpdateSetp to the desired interval

    • For event-based sending: Set xUpdateSetp or xWriteVisu if needed

    • Optional: Adjust tPauseTimeUntilNextSend to configure the send pause

  5. Monitor outputs:

    • Check tNextWrite for the time of the next send operation

    • Monitor the corresponding *LastBusValueoutput for the last received value

    • For DPT_1x: Also note Encoding for the textual representation

    • For DPT_2x: Also note xControlBit for the priority status

  6. Observe unit:

    • For DPT_6x, DPT_9x, DPT_13x, DPT_14x: Check sUnit for the current unit

  7. Error handling:

    • Monitor the error outputs of the parent SlaveBasicWr block

KNX_Write_DPT_1x (FB)

Inputs

Inputs
Initial value
Description

xUpdateSetp

FALSE

Trigger for setpoint update

xValue

-

BOOL value to send

xWriteVisu

-

Trigger for single send

eDPT_Format

-

DPT 1.x format selection

byAdrGroup

0

Group address (0-255)

byAdrMiddleGroup

0

Middle group address (0-7)

byAdrMainGroup

0

Main group address (0-31)

tTimeUpdateSetp

T#0S

Cyclic update interval

tPauseTimeUntilNextSend

T#3S

Send pause

Outputs

  • Encoding (STRING[15]): Textual representation of the value

  • tNextWrite (TIME): Time until the next write operation

  • xLastBusValue (BOOL): Last received value

Usage

  1. Select the DPT 1.x format with eDPT_Format.

  2. Set the value to be sent in xValue.

  3. Configure the send options:

    • For cyclic sending: tTimeUpdateSetp > T#0S

    • For event-based sending: Use xUpdateSetp or xWriteVisu

  4. Monitor xLastBusValue for received values.

  5. Note Encoding for the textual interpretation of the value.

KNX_Write_DPT_2x (FB)

Overview

Send function for DPT 2.x (2-bit value).

Inputs

Inputs
Initial value
Description

xUpdateSetp

FALSE

Trigger for setpoint update

xValue

-

Main value to send (BOOL)

xPrio

-

Priority value to send (BOOL)

xWriteVisu

-

Trigger for single send

eDPT_Format

-

DPT 2.x format selection

byAdrGroup

0

Group address (0-255)

byAdrMiddleGroup

0

Middle group address (0-7)

byAdrMainGroup

0

Main group address (0-31)

tTimeUpdateSetp

T#0S

Cyclic update interval

tPauseTimeUntilNextSend

T#3S

Send pause

Outputs

  • tNextWrite (TIME): Time until the next write operation

  • xLastBusValue (BOOL): Last received main value

  • xControlBit (BOOL): Last received control bit (priority)

Usage

  1. Select the DPT 2.x format with eDPT_Format.

  2. Set the main value to send in xValue and the priority value in xPrio.

  3. Configure the send options:

    • For cyclic sending: tTimeUpdateSetp > T#0S

    • For event-based sending: Use xUpdateSetp or xWriteVisu

  4. Monitor xLastBusValue for the last received main value.

  5. Note xControlBit for the last received priority value.

KNX_Write_DPT_6x (FB)

Overview

Send function for DPT 6.x (8-bit signed value).

Inputs

Inputs
Initial value
Description

xUpdateSetp

FALSE

Trigger for setpoint update

iValue

-

INT value to send

xWriteVisu

-

Trigger for single send

uiDelta

1

Threshold for value-change detection

eDPT_Format

-

DPT 6.x format selection

byAdrGroup

0

Group address (0-255)

byAdrMiddleGroup

0

Middle group address (0-7)

byAdrMainGroup

0

Main group address (0-31)

tTimeUpdateSetp

T#0S

Cyclic update interval

tPauseTimeUntilNextSend

T#3S

Send pause

Outputs

  • sUnit (STRING[10]): Unit of the value

  • tNextWrite (TIME): Time until the next write operation

  • iLastBusValue (INT): Last received value

Usage

  1. Select the DPT 6.x format with eDPT_Format.

  2. Set the value to be sent in iValue.

  3. Configure the send options:

    • For cyclic sending: tTimeUpdateSetp > T#0S

    • For event-based sending: Use xUpdateSetp or xWriteVisu

  4. Adjust uiDelta to adjust the sensitivity for value changes.

  5. Monitor iLastBusValue for received values and sUnit for the unit.

KNX_Write_DPT_9x (FB)

Overview

Send function for DPT 9.x (2-byte floating point).

Inputs

Inputs
Initial value
Description

xUpdateSetp

FALSE

Trigger for setpoint update

rValue

-

REAL value to send

xWriteVisu

-

Trigger for single send

rDelta

0.05

Threshold for value-change detection

eDPT_Format

-

DPT 9.x format selection

byAdrGroup

0

Group address (0-255)

byAdrMiddleGroup

0

Middle group address (0-7)

byAdrMainGroup

0

Main group address (0-31)

tTimeUpdateSetp

T#0S

Cyclic update interval

tPauseTimeUntilNextSend

T#3S

Send pause

Outputs

  • sUnit (STRING[10]): Unit of the value

  • tNextWrite (TIME): Time until the next write operation

  • rLastBusValue (REAL): Last received value

Usage

  1. Select the DPT 9.x format with eDPT_Format.

  2. Set the value to be sent in rValue.

  3. Configure the send options:

    • For cyclic sending: tTimeUpdateSetp > T#0S

    • For event-based sending: Use xUpdateSetp or xWriteVisu

  4. Adjust rDelta to adjust the sensitivity for value changes.

  5. Monitor rLastBusValue for received values and sUnit for the unit.

KNX_Write_DPT_13x (FB)

Overview

Send function for DPT 13.x (4-byte signed integer).

Inputs

Inputs
Initial value
Description

xUpdateSetp

FALSE

Trigger for setpoint update

diValue

-

DINT value to send

xWriteVisu

-

Trigger for single send

uiDelta

1

Threshold for value-change detection

eDPT_Format

-

DPT 13.x format selection

byAdrGroup

0

Group address (0-255)

byAdrMiddleGroup

0

Middle group address (0-7)

byAdrMainGroup

0

Main group address (0-31)

tTimeUpdateSetp

T#0S

Cyclic update interval

tPauseTimeUntilNextSend

T#3S

Send pause

Outputs

  • rFactor (REAL): Conversion factor

  • sUnit (STRING[10]): Unit of the value

  • tNextWrite (TIME): Time until the next write operation

  • diLastBusValue (DINT): Last received value

  • rLastBusValue (REAL): Last received value as REAL

Usage

  1. Select the DPT 13.x format with eDPT_Format.

  2. Set the value to be sent in diValue.

  3. Configure the send options:

    • For cyclic sending: tTimeUpdateSetp > T#0S

    • For event-based sending: Use xUpdateSetp or xWriteVisu

  4. Adjust uiDelta to adjust the sensitivity for value changes.

  5. Monitor diLastBusValue or rLastBusValue for received values.

  6. Note rFactor for any conversions and sUnit for the unit.

KNX_Write_DPT_14x (FB)

Overview

Send function for DPT 14.x (4-byte floating point).

Inputs

Inputs
Initial value
Description

xUpdateSetp

FALSE

Trigger for setpoint update

rValue

-

REAL value to send

xWriteVisu

-

Trigger for single send

rDelta

0.5

Threshold for value-change detection

eDPT_Format

-

DPT 14.x format selection

byAdrGroup

0

Group address (0-255)

byAdrMiddleGroup

0

Middle group address (0-7)

byAdrMainGroup

0

Main group address (0-31)

tTimeUpdateSetp

T#0S

Cyclic update interval

tPauseTimeUntilNextSend

T#3S

Send pause

Outputs

  • sUnit (STRING[10]): Unit of the value

  • tNextWrite (TIME): Time until the next write operation

  • rLastBusValue (REAL): Last received value

Usage

  1. Select the DPT 14.x format with eDPT_Format.

  2. Set the value to be sent in rValue.

  3. Configure the send options:

    • For cyclic sending: tTimeUpdateSetp > T#0S

    • For event-based sending: Use xUpdateSetp or xWriteVisu

  4. Adjust rDelta to adjust the sensitivity for value changes.

  5. Monitor rLastBusValue for received values and sUnit for the unit.

Last updated