FB_EnOceanSTM100Generic

FB_EnOceanSTM100Generic 1:

The function-block FB_EnOceanSTM100Generic() allows a user-friendly anaysis of the data sent by an EnOcean STM100-module. It gets its information from the receiver-unit FB_EnOceanReceive().

It is very important , that for every new EnOcen STM100-module a new instance of the FB_EnOceanSTM100() has to be programmed.

VAR_INPUT

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

bEnable: A positive signal at this input sets the function-block to the active-state. With a negative signal at the bEnable input the unit is without function and all outputs will be set to 0 or FALSE.

tWatchdog: Within this time the information at the input stEnOceanReceivedData has to be updated. The watchdog is disabled, if the entered time is set to t#0s.

nTransmitterId: The ID of the EnOcean-Transmitter, the function-block is assigned to.

stEnOceanReceivedData: Raw-information and therefore neccessary connection to the EnOcean receive function block FB_EnOceanReceive(). This information is assemled in a structure of the type ST_EnOceanReceivedData.

VAR_OUTPUT

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

nDataBytes: Array of four bytes that contains the data of the STM100-module. The meaning of the data dependens on the manufacturer.

bError: If the function-block is in an error-state, this output will be set to TRUE. This error is described by the variable nErrorId.

nErrorId: Type of error (see Errorcodes).

The following example should give some idea, how the function-block has to be used:

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 program two sensor-modules are observed - one has the ID 16#000000C4 and the other one 16#000000C5. Each transmitter has its own instance of the function-block FB_EnOceanSTM100Generic() - these two units are getting their information of the pre-posted receiver FB_EnOceanReceive() and are only active (Input bEnable), if the receiver is active and not in an error-state. The first transmitter is observed by the watchdog-function, in this case the information must be updated every hour. The second transmitter works without watchdog-observation. The resulting information is then assigned to variables for further usage in the program. You should scale the data to real physical units. Usually, in the datasheet of the sensor are more information about the data conversion.