FB_EnOceanSTM100Generic

FB_EnOceanSTM100Generic 1:

The function block FB_EnOceanSTM100Generic() provides a user-friendly evaluation of the data of an EnOcean STM100 module. The function block FB_EnOceanReceive() is required for this purpose.

FB_EnOceanSTM100Generic 2:

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

FB_EnOceanSTM100Generic 3: 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 activates 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

ST_EnOceanReceivedData

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

FB_EnOceanSTM100Generic 4: Outputs

VAR_OUTPUT
  nDataBytes : ARRAY [0..3] OF BYTE;
  bError     : BOOL := FALSE;
  nErrorId   : UDINT := 0;
END_VAR

Name

Type

Description

nDataBytes

ARRAY OF BYTE

4-byte array with the user data sent by the STM100 module. The purpose of the individual bytes is manufacturer-specific.

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;
    fbEnOceanSTM100_1 : FB_EnOceanSTM100Generic;
    fbEnOceanSTM100_2 : FB_EnOceanSTM100Generic;
    nTemperature : ARRAY [1..2] OF BYTE;
    nSetpoint : ARRAY [1..2] OF BYTE;
    nStateRotarySwitch : ARRAY [1..2] OF BYTE;
    nPresentSwitch : ARRAY [1..2] OF BYTE;
END_VAR

fbEnOceanReceive(
    bEnable := TRUE,
    stEnOceanInData := stEnOceanInData,
    stEnOceanOutData := stEnOceanOutData);
fbEnOceanSTM100_1(
    bEnable := NOT fbEnOceanReceive.bError AND fbEnOceanReceive.bEnable,
    nTransmitterId := 16#000000C4,
    tWatchdog:=t#1h,
    stEnOceanReceivedData := fbEnOceanReceive.stEnOceanReceivedData);
nTemperature[1] := fbEnOceanSTM100_1.nDataBytes[0];
nSetpoint[1] := fbEnOceanSTM100_1.nDataBytes[1];
nStateRotarySwitch[1] := fbEnOceanSTM100_1.nDataBytes[2];
nPresentSwitch[1] := fbEnOceanSTM100_1.nDataBytes[3];
fbEnOceanSTM100_2(
    bEnable := NOT fbEnOceanReceive.bError AND fbEnOceanReceive.bEnable,
    nTransmitterId := 16#000000C5,
    tWatchdog:=t#0s,
    stEnOceanReceivedData := fbEnOceanReceive.stEnOceanReceivedData);
nTemperature[2] := fbEnOceanSTM100_2.nDataBytes[0];
nSetpoint[2] := fbEnOceanSTM100_2.nDataBytes[1];
nStateRotarySwitch[2] := fbEnOceanSTM100_2.nDataBytes[2];
nPresentSwitch[2] := fbEnOceanSTM100_2.nDataBytes[3];

In this sample program two EnOcean transmitter modules are queried; one with the transmitter ID 16#000000C4, another one with the transmitter ID 16#000000C5. A function block FB_EnOceanSTM100Generic is created for both transmitters. 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 first device is monitored by the watchdog function, whereby new values must be transmitted to the control unit within 1 hour; the second device is programmed without watchdog monitoring. The values output to the function blocks are assigned to variables for further evaluation. Before the values can be used further, they have to be scaled to physical values. Details of the conversion can be found in the data sheet for the sensor.

Requirements

Development environment

required TC3 PLC library

TwinCAT v3.1.4020.14

Tc2_EnOcean from v3.3.5.0