FB_EnOceanPTM100

FB_EnOceanPTM100 1:

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

In the difference of the PTM200- and PTM250-module, it is only possible to press one pushbuttons at the same time. Besides, the PTM100-module supports eight pushbuttons, instead of four pushbuttons.

It is very important, that for every new transmitting-module a new instance of the FB_EnOceanSTM100() must 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

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

bSwitches: This array of 8 boolean variables contains the actual information about the button-states on the transmitter.

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;
  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;
END_VAR
     
fbEnOceanReceive(bEnable := TRUE,
         stEnOceanInData := stEnOceanInData,
         stEnOceanOutData := stEnOceanOutData);
     
fbEnOceanPTM100_1(bEnable := NOT fbEnOceanReceive.bError AND fbEnOceanReceive.bEnable,
          nTransmitterId := 16#000000C4,
          tWatchdog := t#0s,
          stEnOceanReceivedData := fbEnOceanReceive.stEnOceanReceivedData);
          bSwitches1 := fbEnOceanPTM100_1.bSwitches;
     
fbEnOceanPTM100_2(bEnable := NOT fbEnOceanReceive.bError AND fbEnOceanReceive.bEnable,
         nTransmitterId := 16#000000C5,
         tWatchdog := t#0s,
         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 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 switches of the first transmitter is then assigned to the boolean array bSwitches1 of the same size, those of the second transmitter are each assigned to different boolean variables (bSwitches2_1...bSwitches2_8) - both solutions are possible.

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

FB_EnOceanPTM100 2: