FB_EnOceanPTM200

FB_EnOceanPTM200 1:

The function-block FB_EnOceanPTM200() allows a user-friendly analysis of the data sent by an EnOcean PTM200- or PTM250-transmitter-module. It gets its information from the receiver-unit FB_EnOceanReceive().

In the difference of the PTM100-module, it is possible to press up to two pushbuttons simultaneous. Besides, the PTM200-module supports four pushbuttons, instead of eight pushbuttons.

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

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

bSwitches: This array of 4 boolean variables contains the actual information about the pushbutton-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;
  fbEnOceanPTM200_1  : FB_EnOceanPTM200;
  fbEnOceanPTM200_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);
     
fbEnOceanPTM200_2(bEnable := NOT fbEnOceanReceive.bError AND fbEnOceanReceive.bEnable,
          nTransmitterId := 16#000000C7,
          tWatchdog := t#0s,
          stEnOceanReceivedData := fbEnOceanReceive.stEnOceanReceivedData);
bSwitches1 := fbEnOceanPTM200_1.bSwitches;
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 program two transmitter-modules (PTM200/PTM250) are observed - one has the ID 16#000000C6 and the other one 16#000000C7. Each transmitter has its own instance of the function-block FB_EnOceanSTM200()- 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_4) - both solutions are possible.

An Example in continuous function chart editor (CFC) is under the discription of the FB_EnOceanPTM100().