FB_EnOceanPTM100 1:

The function block FB_EnOceanPTM100() provides a user-friendly evaluation of the state of an EnOcean PTM100 module. The function block FB_EnOceanReceive() is required for this purpose.

In contrast to the PTM200 and PTM250 modules, only one button at a time can be pressed in the PTM100 module. In addition, the PTM100 module supports eight buttons, not four.

FB_EnOceanPTM100 2:

A new instance of this function block must be created for each button module used.


bEnable               : BOOL := FALSE;
tWatchdog             : TIME;
nTransmitterId        : UDINT;
stEnOceanReceivedData : ST_EnOceanReceivedData;

bEnable: A positive signal at this input activates the block. A negative signal at the input disables the block functionality, and all outputs are set to 0 or FALSE.

tWatchdog: Monitoring time. Within this time, new information must reach this block via the input stEnOceanReceivedData described below. If this time is set to t#0s, the watchdog function is inactive.

nTransmitterId: ID of the EnOcean module, to which the block should respond.

stEnOceanReceivedData: Information and required connection to the EnOcean receive block FB_EnOceanReceive(). This information is stored in a structure (see ST_EnOceanReceivedData).


bSwitches : ARRAY [0..7] OF BOOL;
bError    : BOOL := FALSE;
nErrorId  : UDINT := 0;

bSwitches: This field of 8 Boolean values describes the states of the 8 buttons on the button module.

bError: this output goes TRUE as soon as an error occurs. This error is described via the variable nErrorId.

nErrorId: Describes the error type (see error codes).

The following sample program illustrates the operating principle of this block:

    fbEnOceanReceive  : FB_EnOceanReceive;
    fbEnOceanPTM100_1 : FB_EnOceanPTM100;
    fbEnOceanPTM100_2 : FB_EnOceanPTM100;
    bSwitches1   : ARRAY    [0..7]    OF    BOOL;
    bSwitches2_1 : BOOL;
    bSwitches2_2 : BOOL;
    bSwitches2_3 : BOOL;
    bSwitches2_4 : BOOL;
    bSwitches2_5 : BOOL;
    bSwitches2_6 : BOOL;
    bSwitches2_7 : BOOL;
    bSwitches2_8 : BOOL;

    bEnable := TRUE,
    stEnOceanInData := stEnOceanInData,
    stEnOceanOutData := stEnOceanOutData);
    bEnable := NOT fbEnOceanReceive.bError AND fbEnOceanReceive.bEnable,
    nTransmitterId := 16#000000C4,
    stEnOceanReceivedData := fbEnOceanReceive.stEnOceanReceivedData);
bSwitches1 := fbEnOceanPTM100_1.bSwitches;
    bEnable := NOT fbEnOceanReceive.bError AND fbEnOceanReceive.bEnable,
    nTransmitterId := 16#000000C5,
    stEnOceanReceivedData := fbEnOceanReceive.stEnOceanReceivedData);
bSwitches2_1 := fbEnOceanPTM100_2.bSwitches[0];
bSwitches2_3 := fbEnOceanPTM100_2.bSwitches[1];
bSwitches2_6 := fbEnOceanPTM100_2.bSwitches[2];
bSwitches2_5 := fbEnOceanPTM100_2.bSwitches[3];
bSwitches2_8 := fbEnOceanPTM100_2.bSwitches[4];
bSwitches2_2 := fbEnOceanPTM100_2.bSwitches[5];
bSwitches2_7 := fbEnOceanPTM100_2.bSwitches[6];
bSwitches2_4 := fbEnOceanPTM100_2.bSwitches[7];

In this example program two transmitter modules (PTM100) are queried: a transmitter module with the transmitter ID 16#C4 and another module with the transmitter ID 16#C5. A function block FB_EnOceanPTM100 is created for both transmitter modules. Both function blocks obtain their information from the upstream receive block FB_EnOceanReceive and are only active (input bEnable) if the receive block is active and not in error. The buttons of the first transmitter module are assigned to a Boolean array bSwitches1 for further analysis, while the buttons of the second transmitter module are assigned to individual Boolean variables bSwitches2_1 to bSwitches2_8; both options are conceivable.


Development environment

required TC3 PLC library

TwinCAT v3.1.4020.14

Tc2_EnOcean from v3.3.5.0