plcopen/Standard_Function_Blocks.xml
changeset 1313 85c167bfff93
child 1410 0d34b69cc9b5
equal deleted inserted replaced
1312:250c3ae0787c 1313:85c167bfff93
       
     1 <?xml version='1.0' encoding='utf-8'?>
       
     2 <project xmlns:ns1="http://www.plcopen.org/xml/tc6_0201" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.plcopen.org/xml/tc6_0201">
       
     3   <fileHeader companyName="Beremiz" productName="Standard Function Blocks Library" productVersion="1.0" creationDateTime="2013-09-09T09:56:11"/>
       
     4   <contentHeader name="Standard Funtion Blocks" author="Laurent Bessard" modificationDateTime="2013-09-09T10:58:13">
       
     5     <coordinateInfo>
       
     6       <fbd>
       
     7         <scaling x="0" y="0"/>
       
     8       </fbd>
       
     9       <ld>
       
    10         <scaling x="0" y="0"/>
       
    11       </ld>
       
    12       <sfc>
       
    13         <scaling x="0" y="0"/>
       
    14       </sfc>
       
    15     </coordinateInfo>
       
    16   </contentHeader>
       
    17   <types>
       
    18     <dataTypes/>
       
    19     <pous>
       
    20       <pou name="SR" pouType="functionBlock">
       
    21         <interface>
       
    22           <inputVars>
       
    23             <variable name="S1">
       
    24               <type>
       
    25                 <BOOL/>
       
    26               </type>
       
    27             </variable>
       
    28             <variable name="R">
       
    29               <type>
       
    30                 <BOOL/>
       
    31               </type>
       
    32             </variable>
       
    33           </inputVars>
       
    34           <outputVars>
       
    35             <variable name="Q1">
       
    36               <type>
       
    37                 <BOOL/>
       
    38               </type>
       
    39             </variable>
       
    40           </outputVars>
       
    41         </interface>
       
    42         <body>
       
    43           <ST>
       
    44             <xhtml:p><![CDATA[Q1 := S1 OR ((NOT R) AND Q1);]]></xhtml:p>
       
    45           </ST>
       
    46         </body>
       
    47         <documentation>
       
    48           <xhtml:p><![CDATA[The SR bistable is a latch where the Set dominates.]]></xhtml:p>
       
    49         </documentation>
       
    50       </pou>
       
    51       <pou name="RS" pouType="functionBlock">
       
    52         <interface>
       
    53           <inputVars>
       
    54             <variable name="S">
       
    55               <type>
       
    56                 <BOOL/>
       
    57               </type>
       
    58             </variable>
       
    59             <variable name="R1">
       
    60               <type>
       
    61                 <BOOL/>
       
    62               </type>
       
    63             </variable>
       
    64           </inputVars>
       
    65           <outputVars>
       
    66             <variable name="Q1">
       
    67               <type>
       
    68                 <BOOL/>
       
    69               </type>
       
    70             </variable>
       
    71           </outputVars>
       
    72         </interface>
       
    73         <body>
       
    74           <ST>
       
    75             <xhtml:p><![CDATA[Q1 := (NOT R1) AND (S OR Q1);]]></xhtml:p>
       
    76           </ST>
       
    77         </body>
       
    78         <documentation>
       
    79           <xhtml:p><![CDATA[The RS bistable is a latch where the Reset dominates.]]></xhtml:p>
       
    80         </documentation>
       
    81       </pou>
       
    82       <pou name="SEMA" pouType="functionBlock">
       
    83         <interface>
       
    84           <inputVars>
       
    85             <variable name="CLAIM">
       
    86               <type>
       
    87                 <BOOL/>
       
    88               </type>
       
    89             </variable>
       
    90             <variable name="RELEASE">
       
    91               <type>
       
    92                 <BOOL/>
       
    93               </type>
       
    94             </variable>
       
    95           </inputVars>
       
    96           <outputVars>
       
    97             <variable name="BUSY">
       
    98               <type>
       
    99                 <BOOL/>
       
   100               </type>
       
   101             </variable>
       
   102           </outputVars>
       
   103           <localVars>
       
   104             <variable name="Q_INTERNAL">
       
   105               <type>
       
   106                 <BOOL/>
       
   107               </type>
       
   108             </variable>
       
   109           </localVars>
       
   110         </interface>
       
   111         <body>
       
   112           <ST>
       
   113             <xhtml:p><![CDATA[Q_INTERNAL := CLAIM OR ( Q_INTERNAL AND (NOT RELEASE));
       
   114 BUSY := Q_INTERNAL;]]></xhtml:p>
       
   115           </ST>
       
   116         </body>
       
   117         <documentation>
       
   118           <xhtml:p><![CDATA[The semaphore provides a mechanism to allow software elements mutually exclusive access to certain ressources.]]></xhtml:p>
       
   119         </documentation>
       
   120       </pou>
       
   121       <pou name="R_TRIG" pouType="functionBlock">
       
   122         <interface>
       
   123           <inputVars>
       
   124             <variable name="CLK">
       
   125               <type>
       
   126                 <BOOL/>
       
   127               </type>
       
   128             </variable>
       
   129           </inputVars>
       
   130           <outputVars>
       
   131             <variable name="Q">
       
   132               <type>
       
   133                 <BOOL/>
       
   134               </type>
       
   135             </variable>
       
   136           </outputVars>
       
   137           <localVars retain="true">
       
   138             <variable name="M">
       
   139               <type>
       
   140                 <BOOL/>
       
   141               </type>
       
   142             </variable>
       
   143           </localVars>
       
   144         </interface>
       
   145         <body>
       
   146           <ST>
       
   147             <xhtml:p><![CDATA[Q := CLK AND NOT M;
       
   148 M := CLK;]]></xhtml:p>
       
   149           </ST>
       
   150         </body>
       
   151         <documentation>
       
   152           <xhtml:p><![CDATA[The output produces a single pulse when a rising edge is detected.]]></xhtml:p>
       
   153         </documentation>
       
   154       </pou>
       
   155       <pou name="F_TRIG" pouType="functionBlock">
       
   156         <interface>
       
   157           <inputVars>
       
   158             <variable name="CLK">
       
   159               <type>
       
   160                 <BOOL/>
       
   161               </type>
       
   162             </variable>
       
   163           </inputVars>
       
   164           <outputVars>
       
   165             <variable name="Q">
       
   166               <type>
       
   167                 <BOOL/>
       
   168               </type>
       
   169             </variable>
       
   170           </outputVars>
       
   171           <localVars retain="true">
       
   172             <variable name="M">
       
   173               <type>
       
   174                 <BOOL/>
       
   175               </type>
       
   176             </variable>
       
   177           </localVars>
       
   178         </interface>
       
   179         <body>
       
   180           <ST>
       
   181             <xhtml:p><![CDATA[Q := NOT CLK AND NOT M;
       
   182 M := NOT CLK;]]></xhtml:p>
       
   183           </ST>
       
   184         </body>
       
   185         <documentation>
       
   186           <xhtml:p><![CDATA[The output produces a single pulse when a falling edge is detected.]]></xhtml:p>
       
   187         </documentation>
       
   188       </pou>
       
   189       <pou name="CTU" pouType="functionBlock">
       
   190         <interface>
       
   191           <inputVars>
       
   192             <variable name="CU">
       
   193               <type>
       
   194                 <BOOL/>
       
   195               </type>
       
   196             </variable>
       
   197             <variable name="R">
       
   198               <type>
       
   199                 <BOOL/>
       
   200               </type>
       
   201             </variable>
       
   202             <variable name="PV">
       
   203               <type>
       
   204                 <INT/>
       
   205               </type>
       
   206             </variable>
       
   207           </inputVars>
       
   208           <outputVars>
       
   209             <variable name="Q">
       
   210               <type>
       
   211                 <BOOL/>
       
   212               </type>
       
   213             </variable>
       
   214             <variable name="CV">
       
   215               <type>
       
   216                 <INT/>
       
   217               </type>
       
   218             </variable>
       
   219           </outputVars>
       
   220           <localVars>
       
   221             <variable name="CU_T">
       
   222               <type>
       
   223                 <derived name="R_TRIG"/>
       
   224               </type>
       
   225             </variable>
       
   226           </localVars>
       
   227         </interface>
       
   228         <body>
       
   229           <ST>
       
   230             <xhtml:p><![CDATA[CU_T(CU);
       
   231 IF R THEN CV := 0;
       
   232 ELSIF CU_T.Q AND (CV < PV)
       
   233   THEN CV := CV+1;
       
   234 END_IF;
       
   235 Q := (CV >= PV);]]></xhtml:p>
       
   236           </ST>
       
   237         </body>
       
   238         <documentation>
       
   239           <xhtml:p><![CDATA[The up-counter can be used to signal when a count has reached a maximum value.]]></xhtml:p>
       
   240         </documentation>
       
   241       </pou>
       
   242       <pou name="CTU_DINT" pouType="functionBlock">
       
   243         <interface>
       
   244           <inputVars>
       
   245             <variable name="CU">
       
   246               <type>
       
   247                 <BOOL/>
       
   248               </type>
       
   249             </variable>
       
   250             <variable name="R">
       
   251               <type>
       
   252                 <BOOL/>
       
   253               </type>
       
   254             </variable>
       
   255             <variable name="PV">
       
   256               <type>
       
   257                 <DINT/>
       
   258               </type>
       
   259             </variable>
       
   260           </inputVars>
       
   261           <outputVars>
       
   262             <variable name="Q">
       
   263               <type>
       
   264                 <BOOL/>
       
   265               </type>
       
   266             </variable>
       
   267             <variable name="CV">
       
   268               <type>
       
   269                 <DINT/>
       
   270               </type>
       
   271             </variable>
       
   272           </outputVars>
       
   273           <localVars>
       
   274             <variable name="CU_T">
       
   275               <type>
       
   276                 <derived name="R_TRIG"/>
       
   277               </type>
       
   278             </variable>
       
   279           </localVars>
       
   280         </interface>
       
   281         <body>
       
   282           <ST>
       
   283             <xhtml:p><![CDATA[CU_T(CU);
       
   284 IF R THEN CV := 0;
       
   285 ELSIF CU_T.Q AND (CV < PV)
       
   286   THEN CV := CV+1;
       
   287 END_IF;
       
   288 Q := (CV >= PV);]]></xhtml:p>
       
   289           </ST>
       
   290         </body>
       
   291         <documentation>
       
   292           <xhtml:p><![CDATA[The up-counter can be used to signal when a count has reached a maximum value.]]></xhtml:p>
       
   293         </documentation>
       
   294       </pou>
       
   295       <pou name="CTU_LINT" pouType="functionBlock">
       
   296         <interface>
       
   297           <inputVars>
       
   298             <variable name="CU">
       
   299               <type>
       
   300                 <BOOL/>
       
   301               </type>
       
   302             </variable>
       
   303             <variable name="R">
       
   304               <type>
       
   305                 <BOOL/>
       
   306               </type>
       
   307             </variable>
       
   308             <variable name="PV">
       
   309               <type>
       
   310                 <LINT/>
       
   311               </type>
       
   312             </variable>
       
   313           </inputVars>
       
   314           <outputVars>
       
   315             <variable name="Q">
       
   316               <type>
       
   317                 <BOOL/>
       
   318               </type>
       
   319             </variable>
       
   320             <variable name="CV">
       
   321               <type>
       
   322                 <LINT/>
       
   323               </type>
       
   324             </variable>
       
   325           </outputVars>
       
   326           <localVars>
       
   327             <variable name="CU_T">
       
   328               <type>
       
   329                 <derived name="R_TRIG"/>
       
   330               </type>
       
   331             </variable>
       
   332           </localVars>
       
   333         </interface>
       
   334         <body>
       
   335           <ST>
       
   336             <xhtml:p><![CDATA[CU_T(CU);
       
   337 IF R THEN CV := 0;
       
   338 ELSIF CU_T.Q AND (CV < PV)
       
   339   THEN CV := CV+1;
       
   340 END_IF;
       
   341 Q := (CV >= PV);]]></xhtml:p>
       
   342           </ST>
       
   343         </body>
       
   344         <documentation>
       
   345           <xhtml:p><![CDATA[The up-counter can be used to signal when a count has reached a maximum value.]]></xhtml:p>
       
   346         </documentation>
       
   347       </pou>
       
   348       <pou name="CTU_UDINT" pouType="functionBlock">
       
   349         <interface>
       
   350           <inputVars>
       
   351             <variable name="CU">
       
   352               <type>
       
   353                 <BOOL/>
       
   354               </type>
       
   355             </variable>
       
   356             <variable name="R">
       
   357               <type>
       
   358                 <BOOL/>
       
   359               </type>
       
   360             </variable>
       
   361             <variable name="PV">
       
   362               <type>
       
   363                 <UDINT/>
       
   364               </type>
       
   365             </variable>
       
   366           </inputVars>
       
   367           <outputVars>
       
   368             <variable name="Q">
       
   369               <type>
       
   370                 <BOOL/>
       
   371               </type>
       
   372             </variable>
       
   373             <variable name="CV">
       
   374               <type>
       
   375                 <UDINT/>
       
   376               </type>
       
   377             </variable>
       
   378           </outputVars>
       
   379           <localVars>
       
   380             <variable name="CU_T">
       
   381               <type>
       
   382                 <derived name="R_TRIG"/>
       
   383               </type>
       
   384             </variable>
       
   385           </localVars>
       
   386         </interface>
       
   387         <body>
       
   388           <ST>
       
   389             <xhtml:p><![CDATA[CU_T(CU);
       
   390 IF R THEN CV := 0;
       
   391 ELSIF CU_T.Q AND (CV < PV)
       
   392   THEN CV := CV+1;
       
   393 END_IF;
       
   394 Q := (CV >= PV);]]></xhtml:p>
       
   395           </ST>
       
   396         </body>
       
   397         <documentation>
       
   398           <xhtml:p><![CDATA[The up-counter can be used to signal when a count has reached a maximum value.]]></xhtml:p>
       
   399         </documentation>
       
   400       </pou>
       
   401       <pou name="CTU_ULINT" pouType="functionBlock">
       
   402         <interface>
       
   403           <inputVars>
       
   404             <variable name="CU">
       
   405               <type>
       
   406                 <BOOL/>
       
   407               </type>
       
   408             </variable>
       
   409             <variable name="R">
       
   410               <type>
       
   411                 <BOOL/>
       
   412               </type>
       
   413             </variable>
       
   414             <variable name="PV">
       
   415               <type>
       
   416                 <ULINT/>
       
   417               </type>
       
   418             </variable>
       
   419           </inputVars>
       
   420           <outputVars>
       
   421             <variable name="Q">
       
   422               <type>
       
   423                 <BOOL/>
       
   424               </type>
       
   425             </variable>
       
   426             <variable name="CV">
       
   427               <type>
       
   428                 <ULINT/>
       
   429               </type>
       
   430             </variable>
       
   431           </outputVars>
       
   432           <localVars>
       
   433             <variable name="CU_T">
       
   434               <type>
       
   435                 <derived name="R_TRIG"/>
       
   436               </type>
       
   437             </variable>
       
   438           </localVars>
       
   439         </interface>
       
   440         <body>
       
   441           <ST>
       
   442             <xhtml:p><![CDATA[CU_T(CU);
       
   443 IF R THEN CV := 0;
       
   444 ELSIF CU_T.Q AND (CV < PV)
       
   445   THEN CV := CV+1;
       
   446 END_IF;
       
   447 Q := (CV >= PV);]]></xhtml:p>
       
   448           </ST>
       
   449         </body>
       
   450         <documentation>
       
   451           <xhtml:p><![CDATA[The up-counter can be used to signal when a count has reached a maximum value.]]></xhtml:p>
       
   452         </documentation>
       
   453       </pou>
       
   454       <pou name="CTD" pouType="functionBlock">
       
   455         <interface>
       
   456           <inputVars>
       
   457             <variable name="CD">
       
   458               <type>
       
   459                 <BOOL/>
       
   460               </type>
       
   461             </variable>
       
   462             <variable name="LD">
       
   463               <type>
       
   464                 <BOOL/>
       
   465               </type>
       
   466             </variable>
       
   467             <variable name="PV">
       
   468               <type>
       
   469                 <INT/>
       
   470               </type>
       
   471             </variable>
       
   472           </inputVars>
       
   473           <outputVars>
       
   474             <variable name="Q">
       
   475               <type>
       
   476                 <BOOL/>
       
   477               </type>
       
   478             </variable>
       
   479             <variable name="CV">
       
   480               <type>
       
   481                 <INT/>
       
   482               </type>
       
   483             </variable>
       
   484           </outputVars>
       
   485           <localVars>
       
   486             <variable name="CD_T">
       
   487               <type>
       
   488                 <derived name="R_TRIG"/>
       
   489               </type>
       
   490             </variable>
       
   491           </localVars>
       
   492         </interface>
       
   493         <body>
       
   494           <ST>
       
   495             <xhtml:p><![CDATA[CD_T(CD);
       
   496 IF LD THEN CV := PV;
       
   497 ELSIF CD_T.Q AND (CV > 0)
       
   498   THEN CV := CV-1;
       
   499 END_IF;
       
   500 Q := (CV <= 0);]]></xhtml:p>
       
   501           </ST>
       
   502         </body>
       
   503         <documentation>
       
   504           <xhtml:p><![CDATA[The down-counter can be used to signal when a count has reached zero, on counting down from a preset value.]]></xhtml:p>
       
   505         </documentation>
       
   506       </pou>
       
   507       <pou name="CTD_DINT" pouType="functionBlock">
       
   508         <interface>
       
   509           <inputVars>
       
   510             <variable name="CD">
       
   511               <type>
       
   512                 <BOOL/>
       
   513               </type>
       
   514             </variable>
       
   515             <variable name="LD">
       
   516               <type>
       
   517                 <BOOL/>
       
   518               </type>
       
   519             </variable>
       
   520             <variable name="PV">
       
   521               <type>
       
   522                 <DINT/>
       
   523               </type>
       
   524             </variable>
       
   525           </inputVars>
       
   526           <outputVars>
       
   527             <variable name="Q">
       
   528               <type>
       
   529                 <BOOL/>
       
   530               </type>
       
   531             </variable>
       
   532             <variable name="CV">
       
   533               <type>
       
   534                 <DINT/>
       
   535               </type>
       
   536             </variable>
       
   537           </outputVars>
       
   538           <localVars>
       
   539             <variable name="CD_T">
       
   540               <type>
       
   541                 <derived name="R_TRIG"/>
       
   542               </type>
       
   543             </variable>
       
   544           </localVars>
       
   545         </interface>
       
   546         <body>
       
   547           <ST>
       
   548             <xhtml:p><![CDATA[CD_T(CD);
       
   549 IF LD THEN CV := PV;
       
   550 ELSIF CD_T.Q AND (CV > 0)
       
   551   THEN CV := CV-1;
       
   552 END_IF;
       
   553 Q := (CV <= 0);]]></xhtml:p>
       
   554           </ST>
       
   555         </body>
       
   556         <documentation>
       
   557           <xhtml:p><![CDATA[The down-counter can be used to signal when a count has reached zero, on counting down from a preset value.]]></xhtml:p>
       
   558         </documentation>
       
   559       </pou>
       
   560       <pou name="CTD_LINT" pouType="functionBlock">
       
   561         <interface>
       
   562           <inputVars>
       
   563             <variable name="CD">
       
   564               <type>
       
   565                 <BOOL/>
       
   566               </type>
       
   567             </variable>
       
   568             <variable name="LD">
       
   569               <type>
       
   570                 <BOOL/>
       
   571               </type>
       
   572             </variable>
       
   573             <variable name="PV">
       
   574               <type>
       
   575                 <LINT/>
       
   576               </type>
       
   577             </variable>
       
   578           </inputVars>
       
   579           <outputVars>
       
   580             <variable name="Q">
       
   581               <type>
       
   582                 <BOOL/>
       
   583               </type>
       
   584             </variable>
       
   585             <variable name="CV">
       
   586               <type>
       
   587                 <LINT/>
       
   588               </type>
       
   589             </variable>
       
   590           </outputVars>
       
   591           <localVars>
       
   592             <variable name="CD_T">
       
   593               <type>
       
   594                 <derived name="R_TRIG"/>
       
   595               </type>
       
   596             </variable>
       
   597           </localVars>
       
   598         </interface>
       
   599         <body>
       
   600           <ST>
       
   601             <xhtml:p><![CDATA[CD_T(CD);
       
   602 IF LD THEN CV := PV;
       
   603 ELSIF CD_T.Q AND (CV > 0)
       
   604   THEN CV := CV-1;
       
   605 END_IF;
       
   606 Q := (CV <= 0);]]></xhtml:p>
       
   607           </ST>
       
   608         </body>
       
   609         <documentation>
       
   610           <xhtml:p><![CDATA[The down-counter can be used to signal when a count has reached zero, on counting down from a preset value.]]></xhtml:p>
       
   611         </documentation>
       
   612       </pou>
       
   613       <pou name="CTD_UDINT" pouType="functionBlock">
       
   614         <interface>
       
   615           <inputVars>
       
   616             <variable name="CD">
       
   617               <type>
       
   618                 <BOOL/>
       
   619               </type>
       
   620             </variable>
       
   621             <variable name="LD">
       
   622               <type>
       
   623                 <BOOL/>
       
   624               </type>
       
   625             </variable>
       
   626             <variable name="PV">
       
   627               <type>
       
   628                 <UDINT/>
       
   629               </type>
       
   630             </variable>
       
   631           </inputVars>
       
   632           <outputVars>
       
   633             <variable name="Q">
       
   634               <type>
       
   635                 <BOOL/>
       
   636               </type>
       
   637             </variable>
       
   638             <variable name="CV">
       
   639               <type>
       
   640                 <UDINT/>
       
   641               </type>
       
   642             </variable>
       
   643           </outputVars>
       
   644           <localVars>
       
   645             <variable name="CD_T">
       
   646               <type>
       
   647                 <derived name="R_TRIG"/>
       
   648               </type>
       
   649             </variable>
       
   650           </localVars>
       
   651         </interface>
       
   652         <body>
       
   653           <ST>
       
   654             <xhtml:p><![CDATA[CD_T(CD);
       
   655 IF LD THEN CV := PV;
       
   656 ELSIF CD_T.Q AND (CV > 0)
       
   657   THEN CV := CV-1;
       
   658 END_IF;
       
   659 Q := (CV <= 0);]]></xhtml:p>
       
   660           </ST>
       
   661         </body>
       
   662         <documentation>
       
   663           <xhtml:p><![CDATA[The down-counter can be used to signal when a count has reached zero, on counting down from a preset value.]]></xhtml:p>
       
   664         </documentation>
       
   665       </pou>
       
   666       <pou name="CTD_ULINT" pouType="functionBlock">
       
   667         <interface>
       
   668           <inputVars>
       
   669             <variable name="CD">
       
   670               <type>
       
   671                 <BOOL/>
       
   672               </type>
       
   673             </variable>
       
   674             <variable name="LD">
       
   675               <type>
       
   676                 <BOOL/>
       
   677               </type>
       
   678             </variable>
       
   679             <variable name="PV">
       
   680               <type>
       
   681                 <ULINT/>
       
   682               </type>
       
   683             </variable>
       
   684           </inputVars>
       
   685           <outputVars>
       
   686             <variable name="Q">
       
   687               <type>
       
   688                 <BOOL/>
       
   689               </type>
       
   690             </variable>
       
   691             <variable name="CV">
       
   692               <type>
       
   693                 <ULINT/>
       
   694               </type>
       
   695             </variable>
       
   696           </outputVars>
       
   697           <localVars>
       
   698             <variable name="CD_T">
       
   699               <type>
       
   700                 <derived name="R_TRIG"/>
       
   701               </type>
       
   702             </variable>
       
   703           </localVars>
       
   704         </interface>
       
   705         <body>
       
   706           <ST>
       
   707             <xhtml:p><![CDATA[CD_T(CD);
       
   708 IF LD THEN CV := PV;
       
   709 ELSIF CD_T.Q AND (CV > 0)
       
   710   THEN CV := CV-1;
       
   711 END_IF;
       
   712 Q := (CV <= 0);]]></xhtml:p>
       
   713           </ST>
       
   714         </body>
       
   715         <documentation>
       
   716           <xhtml:p><![CDATA[The down-counter can be used to signal when a count has reached zero, on counting down from a preset value.]]></xhtml:p>
       
   717         </documentation>
       
   718       </pou>
       
   719       <pou name="CTUD" pouType="functionBlock">
       
   720         <interface>
       
   721           <inputVars>
       
   722             <variable name="CU">
       
   723               <type>
       
   724                 <BOOL/>
       
   725               </type>
       
   726             </variable>
       
   727             <variable name="CD">
       
   728               <type>
       
   729                 <BOOL/>
       
   730               </type>
       
   731             </variable>
       
   732             <variable name="R">
       
   733               <type>
       
   734                 <BOOL/>
       
   735               </type>
       
   736             </variable>
       
   737             <variable name="LD">
       
   738               <type>
       
   739                 <BOOL/>
       
   740               </type>
       
   741             </variable>
       
   742             <variable name="PV">
       
   743               <type>
       
   744                 <INT/>
       
   745               </type>
       
   746             </variable>
       
   747           </inputVars>
       
   748           <outputVars>
       
   749             <variable name="QU">
       
   750               <type>
       
   751                 <BOOL/>
       
   752               </type>
       
   753             </variable>
       
   754             <variable name="QD">
       
   755               <type>
       
   756                 <BOOL/>
       
   757               </type>
       
   758             </variable>
       
   759             <variable name="CV">
       
   760               <type>
       
   761                 <INT/>
       
   762               </type>
       
   763             </variable>
       
   764             <variable name="CD_T">
       
   765               <type>
       
   766                 <derived name="R_TRIG"/>
       
   767               </type>
       
   768             </variable>
       
   769             <variable name="CU_T">
       
   770               <type>
       
   771                 <derived name="R_TRIG"/>
       
   772               </type>
       
   773             </variable>
       
   774           </outputVars>
       
   775         </interface>
       
   776         <body>
       
   777           <ST>
       
   778             <xhtml:p><![CDATA[CD_T(CD);
       
   779 CU_T(CU);
       
   780 IF R THEN CV := 0;
       
   781 ELSIF LD THEN CV := PV;
       
   782 ELSE
       
   783   IF NOT (CU_T.Q AND CD_T.Q) THEN
       
   784     IF CU_T.Q AND (CV < PV)
       
   785     THEN CV := CV+1;
       
   786     ELSIF CD_T.Q AND (CV > 0)
       
   787     THEN CV := CV-1;
       
   788     END_IF;
       
   789   END_IF;
       
   790 END_IF;
       
   791 QU := (CV >= PV);
       
   792 QD := (CV <= 0);]]></xhtml:p>
       
   793           </ST>
       
   794         </body>
       
   795         <documentation>
       
   796           <xhtml:p><![CDATA[The up-down counter has two inputs CU and CD. It can be used to both count up on one input and down on the other.]]></xhtml:p>
       
   797         </documentation>
       
   798       </pou>
       
   799       <pou name="CTUD_DINT" pouType="functionBlock">
       
   800         <interface>
       
   801           <inputVars>
       
   802             <variable name="CU">
       
   803               <type>
       
   804                 <BOOL/>
       
   805               </type>
       
   806             </variable>
       
   807             <variable name="CD">
       
   808               <type>
       
   809                 <BOOL/>
       
   810               </type>
       
   811             </variable>
       
   812             <variable name="R">
       
   813               <type>
       
   814                 <BOOL/>
       
   815               </type>
       
   816             </variable>
       
   817             <variable name="LD">
       
   818               <type>
       
   819                 <BOOL/>
       
   820               </type>
       
   821             </variable>
       
   822             <variable name="PV">
       
   823               <type>
       
   824                 <DINT/>
       
   825               </type>
       
   826             </variable>
       
   827           </inputVars>
       
   828           <outputVars>
       
   829             <variable name="QU">
       
   830               <type>
       
   831                 <BOOL/>
       
   832               </type>
       
   833             </variable>
       
   834             <variable name="QD">
       
   835               <type>
       
   836                 <BOOL/>
       
   837               </type>
       
   838             </variable>
       
   839             <variable name="CV">
       
   840               <type>
       
   841                 <DINT/>
       
   842               </type>
       
   843             </variable>
       
   844             <variable name="CD_T">
       
   845               <type>
       
   846                 <derived name="R_TRIG"/>
       
   847               </type>
       
   848             </variable>
       
   849             <variable name="CU_T">
       
   850               <type>
       
   851                 <derived name="R_TRIG"/>
       
   852               </type>
       
   853             </variable>
       
   854           </outputVars>
       
   855         </interface>
       
   856         <body>
       
   857           <ST>
       
   858             <xhtml:p><![CDATA[CD_T(CD);
       
   859 CU_T(CU);
       
   860 IF R THEN CV := 0;
       
   861 ELSIF LD THEN CV := PV;
       
   862 ELSE
       
   863   IF NOT (CU_T.Q AND CD_T.Q) THEN
       
   864     IF CU_T.Q AND (CV < PV)
       
   865     THEN CV := CV+1;
       
   866     ELSIF CD_T.Q AND (CV > 0)
       
   867     THEN CV := CV-1;
       
   868     END_IF;
       
   869   END_IF;
       
   870 END_IF;
       
   871 QU := (CV >= PV);
       
   872 QD := (CV <= 0);]]></xhtml:p>
       
   873           </ST>
       
   874         </body>
       
   875         <documentation>
       
   876           <xhtml:p><![CDATA[The up-down counter has two inputs CU and CD. It can be used to both count up on one input and down on the other.]]></xhtml:p>
       
   877         </documentation>
       
   878       </pou>
       
   879       <pou name="CTUD_LINT" pouType="functionBlock">
       
   880         <interface>
       
   881           <inputVars>
       
   882             <variable name="CU">
       
   883               <type>
       
   884                 <BOOL/>
       
   885               </type>
       
   886             </variable>
       
   887             <variable name="CD">
       
   888               <type>
       
   889                 <BOOL/>
       
   890               </type>
       
   891             </variable>
       
   892             <variable name="R">
       
   893               <type>
       
   894                 <BOOL/>
       
   895               </type>
       
   896             </variable>
       
   897             <variable name="LD">
       
   898               <type>
       
   899                 <BOOL/>
       
   900               </type>
       
   901             </variable>
       
   902             <variable name="PV">
       
   903               <type>
       
   904                 <LINT/>
       
   905               </type>
       
   906             </variable>
       
   907           </inputVars>
       
   908           <outputVars>
       
   909             <variable name="QU">
       
   910               <type>
       
   911                 <BOOL/>
       
   912               </type>
       
   913             </variable>
       
   914             <variable name="QD">
       
   915               <type>
       
   916                 <BOOL/>
       
   917               </type>
       
   918             </variable>
       
   919             <variable name="CV">
       
   920               <type>
       
   921                 <LINT/>
       
   922               </type>
       
   923             </variable>
       
   924             <variable name="CD_T">
       
   925               <type>
       
   926                 <derived name="R_TRIG"/>
       
   927               </type>
       
   928             </variable>
       
   929             <variable name="CU_T">
       
   930               <type>
       
   931                 <derived name="R_TRIG"/>
       
   932               </type>
       
   933             </variable>
       
   934           </outputVars>
       
   935         </interface>
       
   936         <body>
       
   937           <ST>
       
   938             <xhtml:p><![CDATA[CD_T(CD);
       
   939 CU_T(CU);
       
   940 IF R THEN CV := 0;
       
   941 ELSIF LD THEN CV := PV;
       
   942 ELSE
       
   943   IF NOT (CU_T.Q AND CD_T.Q) THEN
       
   944     IF CU_T.Q AND (CV < PV)
       
   945     THEN CV := CV+1;
       
   946     ELSIF CD_T.Q AND (CV > 0)
       
   947     THEN CV := CV-1;
       
   948     END_IF;
       
   949   END_IF;
       
   950 END_IF;
       
   951 QU := (CV >= PV);
       
   952 QD := (CV <= 0);]]></xhtml:p>
       
   953           </ST>
       
   954         </body>
       
   955         <documentation>
       
   956           <xhtml:p><![CDATA[The up-down counter has two inputs CU and CD. It can be used to both count up on one input and down on the other.]]></xhtml:p>
       
   957         </documentation>
       
   958       </pou>
       
   959       <pou name="CTUD_UDINT" pouType="functionBlock">
       
   960         <interface>
       
   961           <inputVars>
       
   962             <variable name="CU">
       
   963               <type>
       
   964                 <BOOL/>
       
   965               </type>
       
   966             </variable>
       
   967             <variable name="CD">
       
   968               <type>
       
   969                 <BOOL/>
       
   970               </type>
       
   971             </variable>
       
   972             <variable name="R">
       
   973               <type>
       
   974                 <BOOL/>
       
   975               </type>
       
   976             </variable>
       
   977             <variable name="LD">
       
   978               <type>
       
   979                 <BOOL/>
       
   980               </type>
       
   981             </variable>
       
   982             <variable name="PV">
       
   983               <type>
       
   984                 <UDINT/>
       
   985               </type>
       
   986             </variable>
       
   987           </inputVars>
       
   988           <outputVars>
       
   989             <variable name="QU">
       
   990               <type>
       
   991                 <BOOL/>
       
   992               </type>
       
   993             </variable>
       
   994             <variable name="QD">
       
   995               <type>
       
   996                 <BOOL/>
       
   997               </type>
       
   998             </variable>
       
   999             <variable name="CV">
       
  1000               <type>
       
  1001                 <UDINT/>
       
  1002               </type>
       
  1003             </variable>
       
  1004             <variable name="CD_T">
       
  1005               <type>
       
  1006                 <derived name="R_TRIG"/>
       
  1007               </type>
       
  1008             </variable>
       
  1009             <variable name="CU_T">
       
  1010               <type>
       
  1011                 <derived name="R_TRIG"/>
       
  1012               </type>
       
  1013             </variable>
       
  1014           </outputVars>
       
  1015         </interface>
       
  1016         <body>
       
  1017           <ST>
       
  1018             <xhtml:p><![CDATA[CD_T(CD);
       
  1019 CU_T(CU);
       
  1020 IF R THEN CV := 0;
       
  1021 ELSIF LD THEN CV := PV;
       
  1022 ELSE
       
  1023   IF NOT (CU_T.Q AND CD_T.Q) THEN
       
  1024     IF CU_T.Q AND (CV < PV)
       
  1025     THEN CV := CV+1;
       
  1026     ELSIF CD_T.Q AND (CV > 0)
       
  1027     THEN CV := CV-1;
       
  1028     END_IF;
       
  1029   END_IF;
       
  1030 END_IF;
       
  1031 QU := (CV >= PV);
       
  1032 QD := (CV <= 0);]]></xhtml:p>
       
  1033           </ST>
       
  1034         </body>
       
  1035         <documentation>
       
  1036           <xhtml:p><![CDATA[The up-down counter has two inputs CU and CD. It can be used to both count up on one input and down on the other.]]></xhtml:p>
       
  1037         </documentation>
       
  1038       </pou>
       
  1039       <pou name="CTUD_ULINT" pouType="functionBlock">
       
  1040         <interface>
       
  1041           <inputVars>
       
  1042             <variable name="CU">
       
  1043               <type>
       
  1044                 <BOOL/>
       
  1045               </type>
       
  1046             </variable>
       
  1047             <variable name="CD">
       
  1048               <type>
       
  1049                 <BOOL/>
       
  1050               </type>
       
  1051             </variable>
       
  1052             <variable name="R">
       
  1053               <type>
       
  1054                 <BOOL/>
       
  1055               </type>
       
  1056             </variable>
       
  1057             <variable name="LD">
       
  1058               <type>
       
  1059                 <BOOL/>
       
  1060               </type>
       
  1061             </variable>
       
  1062             <variable name="PV">
       
  1063               <type>
       
  1064                 <ULINT/>
       
  1065               </type>
       
  1066             </variable>
       
  1067           </inputVars>
       
  1068           <outputVars>
       
  1069             <variable name="QU">
       
  1070               <type>
       
  1071                 <BOOL/>
       
  1072               </type>
       
  1073             </variable>
       
  1074             <variable name="QD">
       
  1075               <type>
       
  1076                 <BOOL/>
       
  1077               </type>
       
  1078             </variable>
       
  1079             <variable name="CV">
       
  1080               <type>
       
  1081                 <ULINT/>
       
  1082               </type>
       
  1083             </variable>
       
  1084             <variable name="CD_T">
       
  1085               <type>
       
  1086                 <derived name="R_TRIG"/>
       
  1087               </type>
       
  1088             </variable>
       
  1089             <variable name="CU_T">
       
  1090               <type>
       
  1091                 <derived name="R_TRIG"/>
       
  1092               </type>
       
  1093             </variable>
       
  1094           </outputVars>
       
  1095         </interface>
       
  1096         <body>
       
  1097           <ST>
       
  1098             <xhtml:p><![CDATA[CD_T(CD);
       
  1099 CU_T(CU);
       
  1100 IF R THEN CV := 0;
       
  1101 ELSIF LD THEN CV := PV;
       
  1102 ELSE
       
  1103   IF NOT (CU_T.Q AND CD_T.Q) THEN
       
  1104     IF CU_T.Q AND (CV < PV)
       
  1105     THEN CV := CV+1;
       
  1106     ELSIF CD_T.Q AND (CV > 0)
       
  1107     THEN CV := CV-1;
       
  1108     END_IF;
       
  1109   END_IF;
       
  1110 END_IF;
       
  1111 QU := (CV >= PV);
       
  1112 QD := (CV <= 0);]]></xhtml:p>
       
  1113           </ST>
       
  1114         </body>
       
  1115         <documentation>
       
  1116           <xhtml:p><![CDATA[The up-down counter has two inputs CU and CD. It can be used to both count up on one input and down on the other.]]></xhtml:p>
       
  1117         </documentation>
       
  1118       </pou>
       
  1119       <pou name="TP" pouType="functionBlock">
       
  1120         <interface>
       
  1121           <inputVars>
       
  1122             <variable name="IN">
       
  1123               <type>
       
  1124                 <BOOL/>
       
  1125               </type>
       
  1126               <documentation>
       
  1127                 <xhtml:p><![CDATA[first input parameter]]></xhtml:p>
       
  1128               </documentation>
       
  1129             </variable>
       
  1130             <variable name="PT">
       
  1131               <type>
       
  1132                 <TIME/>
       
  1133               </type>
       
  1134               <documentation>
       
  1135                 <xhtml:p><![CDATA[second input parameter]]></xhtml:p>
       
  1136               </documentation>
       
  1137             </variable>
       
  1138           </inputVars>
       
  1139           <outputVars>
       
  1140             <variable name="Q">
       
  1141               <type>
       
  1142                 <BOOL/>
       
  1143               </type>
       
  1144               <initialValue>
       
  1145                 <simpleValue value="FALSE"/>
       
  1146               </initialValue>
       
  1147               <documentation>
       
  1148                 <xhtml:p><![CDATA[first output parameter]]></xhtml:p>
       
  1149               </documentation>
       
  1150             </variable>
       
  1151             <variable name="ET">
       
  1152               <type>
       
  1153                 <TIME/>
       
  1154               </type>
       
  1155               <initialValue>
       
  1156                 <simpleValue value="T#0s"/>
       
  1157               </initialValue>
       
  1158               <documentation>
       
  1159                 <xhtml:p><![CDATA[second output parameter]]></xhtml:p>
       
  1160               </documentation>
       
  1161             </variable>
       
  1162           </outputVars>
       
  1163           <localVars>
       
  1164             <variable name="STATE">
       
  1165               <type>
       
  1166                 <SINT/>
       
  1167               </type>
       
  1168               <initialValue>
       
  1169                 <simpleValue value="0"/>
       
  1170               </initialValue>
       
  1171               <documentation>
       
  1172                 <xhtml:p><![CDATA[internal state: 0-reset, 1-counting, 2-set]]></xhtml:p>
       
  1173               </documentation>
       
  1174             </variable>
       
  1175             <variable name="PREV_IN">
       
  1176               <type>
       
  1177                 <BOOL/>
       
  1178               </type>
       
  1179               <initialValue>
       
  1180                 <simpleValue value="FALSE"/>
       
  1181               </initialValue>
       
  1182             </variable>
       
  1183             <variable name="CURRENT_TIME">
       
  1184               <type>
       
  1185                 <TIME/>
       
  1186               </type>
       
  1187             </variable>
       
  1188             <variable name="START_TIME">
       
  1189               <type>
       
  1190                 <TIME/>
       
  1191               </type>
       
  1192             </variable>
       
  1193           </localVars>
       
  1194         </interface>
       
  1195         <body>
       
  1196           <ST>
       
  1197             <xhtml:p><![CDATA[{__SET_VAR(data__->,CURRENT_TIME,__CURRENT_TIME)}
       
  1198 
       
  1199 IF ((STATE = 0) AND NOT(PREV_IN) AND IN)   (* found rising edge on IN *)
       
  1200 THEN
       
  1201   (* start timer... *)
       
  1202   STATE := 1;
       
  1203   Q := TRUE;
       
  1204   START_TIME := CURRENT_TIME;
       
  1205 
       
  1206 ELSIF (STATE = 1)
       
  1207 THEN
       
  1208   IF ((START_TIME + PT) <= CURRENT_TIME)
       
  1209   THEN
       
  1210     STATE := 2;
       
  1211     Q := FALSE;
       
  1212     ET := PT;
       
  1213   ELSE
       
  1214     ET := CURRENT_TIME - START_TIME;
       
  1215   END_IF;
       
  1216 END_IF;
       
  1217 
       
  1218 IF ((STATE = 2) AND NOT(IN))
       
  1219 THEN
       
  1220   ET := T#0s;
       
  1221   STATE := 0;
       
  1222 END_IF;
       
  1223 
       
  1224 PREV_IN := IN;
       
  1225 ]]></xhtml:p>
       
  1226           </ST>
       
  1227         </body>
       
  1228         <documentation>
       
  1229           <xhtml:p><![CDATA[The pulse timer can be used to generate output pulses of a given time duration.]]></xhtml:p>
       
  1230         </documentation>
       
  1231       </pou>
       
  1232       <pou name="TON" pouType="functionBlock">
       
  1233         <interface>
       
  1234           <inputVars>
       
  1235             <variable name="IN">
       
  1236               <type>
       
  1237                 <BOOL/>
       
  1238               </type>
       
  1239               <documentation>
       
  1240                 <xhtml:p><![CDATA[first input parameter]]></xhtml:p>
       
  1241               </documentation>
       
  1242             </variable>
       
  1243             <variable name="PT">
       
  1244               <type>
       
  1245                 <TIME/>
       
  1246               </type>
       
  1247               <documentation>
       
  1248                 <xhtml:p><![CDATA[second input parameter]]></xhtml:p>
       
  1249               </documentation>
       
  1250             </variable>
       
  1251           </inputVars>
       
  1252           <outputVars>
       
  1253             <variable name="Q">
       
  1254               <type>
       
  1255                 <BOOL/>
       
  1256               </type>
       
  1257               <initialValue>
       
  1258                 <simpleValue value="FALSE"/>
       
  1259               </initialValue>
       
  1260               <documentation>
       
  1261                 <xhtml:p><![CDATA[first output parameter]]></xhtml:p>
       
  1262               </documentation>
       
  1263             </variable>
       
  1264             <variable name="ET">
       
  1265               <type>
       
  1266                 <TIME/>
       
  1267               </type>
       
  1268               <initialValue>
       
  1269                 <simpleValue value="T#0s"/>
       
  1270               </initialValue>
       
  1271               <documentation>
       
  1272                 <xhtml:p><![CDATA[second output parameter]]></xhtml:p>
       
  1273               </documentation>
       
  1274             </variable>
       
  1275           </outputVars>
       
  1276           <localVars>
       
  1277             <variable name="STATE">
       
  1278               <type>
       
  1279                 <SINT/>
       
  1280               </type>
       
  1281               <initialValue>
       
  1282                 <simpleValue value="0"/>
       
  1283               </initialValue>
       
  1284               <documentation>
       
  1285                 <xhtml:p><![CDATA[internal state: 0-reset, 1-counting, 2-set]]></xhtml:p>
       
  1286               </documentation>
       
  1287             </variable>
       
  1288             <variable name="PREV_IN">
       
  1289               <type>
       
  1290                 <BOOL/>
       
  1291               </type>
       
  1292               <initialValue>
       
  1293                 <simpleValue value="FALSE"/>
       
  1294               </initialValue>
       
  1295             </variable>
       
  1296             <variable name="CURRENT_TIME">
       
  1297               <type>
       
  1298                 <TIME/>
       
  1299               </type>
       
  1300             </variable>
       
  1301             <variable name="START_TIME">
       
  1302               <type>
       
  1303                 <TIME/>
       
  1304               </type>
       
  1305             </variable>
       
  1306           </localVars>
       
  1307         </interface>
       
  1308         <body>
       
  1309           <ST>
       
  1310             <xhtml:p><![CDATA[{__SET_VAR(data__->,CURRENT_TIME,__CURRENT_TIME)}
       
  1311 
       
  1312 IF ((STATE = 0) AND NOT(PREV_IN) AND IN)   (* found rising edge on IN *)
       
  1313 THEN
       
  1314   (* start timer... *)
       
  1315   STATE := 1;
       
  1316   Q := FALSE;
       
  1317   START_TIME := CURRENT_TIME;
       
  1318 
       
  1319 ELSE
       
  1320   (* STATE is 1 or 2 !! *)
       
  1321   IF (NOT(IN))
       
  1322   THEN
       
  1323     ET := T#0s;
       
  1324     Q := FALSE;
       
  1325     STATE := 0;
       
  1326 
       
  1327   ELSIF (STATE = 1)
       
  1328   THEN
       
  1329     IF ((START_TIME + PT) <= CURRENT_TIME)
       
  1330     THEN
       
  1331       STATE := 2;
       
  1332       Q := TRUE;
       
  1333       ET := PT;
       
  1334     ELSE
       
  1335       ET := CURRENT_TIME - START_TIME;
       
  1336     END_IF;
       
  1337   END_IF;
       
  1338 
       
  1339 END_IF;
       
  1340 
       
  1341 PREV_IN := IN;
       
  1342 ]]></xhtml:p>
       
  1343           </ST>
       
  1344         </body>
       
  1345         <documentation>
       
  1346           <xhtml:p><![CDATA[The on-delay timer can be used to delay setting an output true, for fixed period after an input becomes true.]]></xhtml:p>
       
  1347         </documentation>
       
  1348       </pou>
       
  1349       <pou name="TOF" pouType="functionBlock">
       
  1350         <interface>
       
  1351           <inputVars>
       
  1352             <variable name="IN">
       
  1353               <type>
       
  1354                 <BOOL/>
       
  1355               </type>
       
  1356               <documentation>
       
  1357                 <xhtml:p><![CDATA[first input parameter]]></xhtml:p>
       
  1358               </documentation>
       
  1359             </variable>
       
  1360             <variable name="PT">
       
  1361               <type>
       
  1362                 <TIME/>
       
  1363               </type>
       
  1364               <documentation>
       
  1365                 <xhtml:p><![CDATA[second input parameter]]></xhtml:p>
       
  1366               </documentation>
       
  1367             </variable>
       
  1368           </inputVars>
       
  1369           <outputVars>
       
  1370             <variable name="Q">
       
  1371               <type>
       
  1372                 <BOOL/>
       
  1373               </type>
       
  1374               <initialValue>
       
  1375                 <simpleValue value="FALSE"/>
       
  1376               </initialValue>
       
  1377               <documentation>
       
  1378                 <xhtml:p><![CDATA[first output parameter]]></xhtml:p>
       
  1379               </documentation>
       
  1380             </variable>
       
  1381             <variable name="ET">
       
  1382               <type>
       
  1383                 <TIME/>
       
  1384               </type>
       
  1385               <initialValue>
       
  1386                 <simpleValue value="T#0s"/>
       
  1387               </initialValue>
       
  1388               <documentation>
       
  1389                 <xhtml:p><![CDATA[second output parameter]]></xhtml:p>
       
  1390               </documentation>
       
  1391             </variable>
       
  1392           </outputVars>
       
  1393           <localVars>
       
  1394             <variable name="STATE">
       
  1395               <type>
       
  1396                 <SINT/>
       
  1397               </type>
       
  1398               <initialValue>
       
  1399                 <simpleValue value="0"/>
       
  1400               </initialValue>
       
  1401               <documentation>
       
  1402                 <xhtml:p><![CDATA[internal state: 0-reset, 1-counting, 2-set]]></xhtml:p>
       
  1403               </documentation>
       
  1404             </variable>
       
  1405             <variable name="PREV_IN">
       
  1406               <type>
       
  1407                 <BOOL/>
       
  1408               </type>
       
  1409               <initialValue>
       
  1410                 <simpleValue value="FALSE"/>
       
  1411               </initialValue>
       
  1412             </variable>
       
  1413             <variable name="CURRENT_TIME">
       
  1414               <type>
       
  1415                 <TIME/>
       
  1416               </type>
       
  1417             </variable>
       
  1418             <variable name="START_TIME">
       
  1419               <type>
       
  1420                 <TIME/>
       
  1421               </type>
       
  1422             </variable>
       
  1423           </localVars>
       
  1424         </interface>
       
  1425         <body>
       
  1426           <ST>
       
  1427             <xhtml:p><![CDATA[{__SET_VAR(data__->,CURRENT_TIME,__CURRENT_TIME)}
       
  1428 
       
  1429 IF ((STATE = 0) AND PREV_IN AND NOT(IN))   (* found falling edge on IN *)
       
  1430 THEN
       
  1431   (* start timer... *)
       
  1432   STATE := 1;
       
  1433   START_TIME := CURRENT_TIME;
       
  1434 
       
  1435 ELSE
       
  1436   (* STATE is 1 or 2 !! *)
       
  1437   IF (IN)
       
  1438   THEN
       
  1439     ET := T#0s;
       
  1440     STATE := 0;
       
  1441 
       
  1442   ELSIF (STATE = 1)
       
  1443   THEN
       
  1444     IF ((START_TIME + PT) <= CURRENT_TIME)
       
  1445     THEN
       
  1446       STATE := 2;
       
  1447       ET := PT;
       
  1448     ELSE
       
  1449       ET := CURRENT_TIME - START_TIME;
       
  1450     END_IF;
       
  1451   END_IF;
       
  1452 
       
  1453 END_IF;
       
  1454 
       
  1455 Q := IN OR (STATE = 1);
       
  1456 PREV_IN := IN;
       
  1457 ]]></xhtml:p>
       
  1458           </ST>
       
  1459         </body>
       
  1460         <documentation>
       
  1461           <xhtml:p><![CDATA[The off-delay timer can be used to delay setting an output false, for fixed period after input goes false.]]></xhtml:p>
       
  1462         </documentation>
       
  1463       </pou>
       
  1464     </pous>
       
  1465   </types>
       
  1466   <instances>
       
  1467     <configurations/>
       
  1468   </instances>
       
  1469 </project>