FB_EnOceanPTM200

The function block FB_EnOceanPTM200() provides a user-friendly evaluation of the state of an EnOcean® PTM200 or PTM250 module. The function block FB_EnOceanReceive() is required for this purpose.
In contrast to the PTM100 module, the PTM200 and PTM250 modules allow up to two switches to be pressed simultaneously. In addition, the PTM200 and PTM250 modules support four instead of eight switches.
![]() | A new instance of this function block must be created for each switch module used. |
Inputs
VAR_INPUT
bEnable : BOOL := FALSE;
tWatchdog : TIME;
nTransmitterId : UDINT;
stEnOceanReceivedData : ST_EnOceanReceivedData;
END_VAR
Name | Type | Description |
---|---|---|
bEnable | BOOL | A positive signal at this input enables the function block. A negative signal at the input disables the function block functionality, and all outputs are set to 0 or FALSE. |
tWatchdog | TIME | Monitoring time. Within this time, new information must reach this function block via the input stEnOceanReceivedData described below. If this time is set to t#0s, the watchdog function is inactive. |
nTransmitterId | UDINT | ID of the EnOcean® module, to which the function block should respond. |
stEnOceanReceivedData | Information and required connection to the EnOcean® receive function block FB_EnOceanReceive(). This information is stored in a structure. |
Outputs
VAR_OUTPUT
bSwitches : ARRAY [0..3] OF BOOL;
bError : BOOL := FALSE;
nErrorId : UDINT := 0;
END_VAR
Name | Type | Description |
---|---|---|
bSwitches | ARRAY OF BOOL | This field of 4 Boolean values describes the states of the 4 push buttons on the push button module. |
bError | BOOL | This output goes TRUE as soon as an error occurs. This error is described via the variable nErrorID. |
nErrorId | UDINT | Describes the type of error. |
The following sample program illustrates the operating principle of this function block:
PROGRAM MAIN
VAR
fbEnOceanReceive : FB_EnOceanReceive;
fbEnOceanPTM100_1 : FB_EnOceanPTM200;
fbEnOceanPTM100_2 : FB_EnOceanPTM200;
bSwitches1 : ARRAY [0..3] OF BOOL;
bSwitches2_1 : BOOL;
bSwitches2_2 : BOOL;
bSwitches2_3 : BOOL;
bSwitches2_4 : BOOL;
END_VAR
fbEnOceanReceive(
bEnable := TRUE,
stEnOceanInData := stEnOceanInData
stEnOceanOutData := stEnOceanOutData);
fbEnOceanPTM200_1(
bEnable := NOT fbEnOceanReceive.bError AND fbEnOceanReceive.bEnable,
nTransmitterId := 16#000000C6,
tWatchdog:=t#0s,
stEnOceanReceivedData := fbEnOceanReceive.stEnOceanReceivedData);
bSwitches1 := fbEnOceanPTM200_1.bSwitches;
fbEnOceanPTM200_2(
bEnable := NOT fbEnOceanReceive.bError AND fbEnOceanReceive.bEnable,
nTransmitterId := 16#000000C7,
tWatchdog:=t#0s,
stEnOceanReceivedData := fbEnOceanReceive.stEnOceanReceivedData);
bSwitches2_1 := fbEnOceanPTM200_2.bSwitches[0];
bSwitches2_2 := fbEnOceanPTM200_2.bSwitches[1];
bSwitches2_3 := fbEnOceanPTM200_2.bSwitches[2];
bSwitches2_4 := fbEnOceanPTM200_2.bSwitches[3];
In this sample program two transmitter modules (PTM200/PTM250) are queried; one with the transmitter ID 16#C6, another one with the transmitter ID 16#C7. A function block FB_EnOceanPTM200 is created for each of the two transmitter modules. Both function blocks obtain their information from the upstream receive function block FB_EnOceanReceive and are only active (input bEnable) if the receive function block is active and not in error. The push buttons of the first transmitter module are assigned to a Boolean array bSwitches1 for further analysis, while the push buttons of the second transmitter module are assigned to individual Boolean variables bSwitches2_1 to bSwitches2_4; both options are conceivable.
Prerequisites
Development environment | PLC library to include |
---|---|
TwinCAT from v3.1.4020.14 | Tc2_EnOcean from v3.3.5.0 |