FB_EnOceanSTM100

FB_EnOceanSTM100 1:

Obsolete! Please use in new projects the function block FB_EnOceanSTM100Generic().

The function-block FB_EnOceanSTM100() 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 EnOcean 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

eEnOceanRotarySwitch  : E_EnOceanRotarySwitch;
nSetpoint             : INT;
nTemperature          : INT;
bPresentSwitch        : BOOL;
bLearnSwitch          : BOOL;
bError                : BOOL := FALSE;
nErrorId              : UDINT := 0;

eEnOceanRotarySwitch: This output describes the state of the rotary-switch on the transmitting-module. The information is defined by an ENUM called E_EnOceanRotarySwitch.

nSetpoint: The setpoint on the transmitter can be read at this output-variable. The range goes from -100 up to 100.

nTemperature: At this variable the measured temperature is given in 1/10 deg C. The lower limit is 0 deg C and the upper limit is 40 deg C. If the function-block is in a Watchdog-error-state, the temperature will be set to 850 deg C.

bPresentSwitch: This output will be TRUE, if the present-button on the transmitter is pressed.

bLearnSwitch: This output will be TRUE, if the learn-button on the transmitter is pressed.

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_EnOceanSTM100;
  fbEnOceanSTM100_2  : FB_EnOceanSTM100;
  nTemperature       : ARRAY [1..2] OF INT;
  nSetpoint          : ARRAY [1..2] OF INT;
  nStateRotarySwitch : ARRAY [1..2] OF E_EnOceanRotarySwitch;
  bPresentSwitch     : ARRAY [1..2] OF BOOL;
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 => Temperature[1],
          nSetpoint => nSetpoint[1] ,
          eEnOceanRotarySwitch => nStateRotarySwitch[1],
          bPresentSwitch => bPresentSwitch[1]);
     
fbEnOceanSTM100_2(bEnable := NOT fbEnOceanReceive.bError AND fbEnOceanReceive.bEnable,
          nTransmitterId := 16#000000C5,
          tWatchdog := t#0s,
          stEnOceanReceivedData := fbEnOceanReceive.stEnOceanReceivedData,
          nTemperature => Temperature[2],
          nSetpoint => nSetpoint[2] ,
          eEnOceanRotarySwitch => nStateRotarySwitch[2],
          bPresentSwitch => bPresentSwitch[2]);

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_EnOceanSTM100() - 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 has to 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.

In continuous function chart editor (CFC) this example would look like the following:

FB_EnOceanSTM100 2: