plcopen/Additional_Function_Blocks.xml
changeset 1313 85c167bfff93
child 1314 822d483197ad
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="Additional Function Blocks Library" productVersion="1.0" creationDateTime="2013-09-09T09:56:11"/>
       
     4   <contentHeader name="Standard Funtion Blocks" author="Laurent Bessard" modificationDateTime="2013-09-10T22:45:31">
       
     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="RTC" pouType="functionBlock">
       
    21         <interface>
       
    22           <inputVars>
       
    23             <variable name="IN">
       
    24               <type>
       
    25                 <BOOL/>
       
    26               </type>
       
    27               <documentation>
       
    28                 <xhtml:p><![CDATA[0 - current time, 1 - load time from PDT]]></xhtml:p>
       
    29               </documentation>
       
    30             </variable>
       
    31             <variable name="PDT">
       
    32               <type>
       
    33                 <DT/>
       
    34               </type>
       
    35               <documentation>
       
    36                 <xhtml:p><![CDATA[Preset datetime]]></xhtml:p>
       
    37               </documentation>
       
    38             </variable>
       
    39           </inputVars>
       
    40           <outputVars>
       
    41             <variable name="Q">
       
    42               <type>
       
    43                 <BOOL/>
       
    44               </type>
       
    45               <initialValue>
       
    46                 <simpleValue value="FALSE"/>
       
    47               </initialValue>
       
    48               <documentation>
       
    49                 <xhtml:p><![CDATA[Copy of IN]]></xhtml:p>
       
    50               </documentation>
       
    51             </variable>
       
    52             <variable name="CDT">
       
    53               <type>
       
    54                 <DT/>
       
    55               </type>
       
    56               <documentation>
       
    57                 <xhtml:p><![CDATA[Datetime, current or relative to PDT]]></xhtml:p>
       
    58               </documentation>
       
    59             </variable>
       
    60           </outputVars>
       
    61           <localVars>
       
    62             <variable name="PREV_IN">
       
    63               <type>
       
    64                 <BOOL/>
       
    65               </type>
       
    66               <initialValue>
       
    67                 <simpleValue value="FALSE"/>
       
    68               </initialValue>
       
    69             </variable>
       
    70             <variable name="OFFSET">
       
    71               <type>
       
    72                 <TIME/>
       
    73               </type>
       
    74             </variable>
       
    75             <variable name="CURRENT_TIME">
       
    76               <type>
       
    77                 <DT/>
       
    78               </type>
       
    79             </variable>
       
    80           </localVars>
       
    81         </interface>
       
    82         <body>
       
    83           <ST>
       
    84             <xhtml:p><![CDATA[{__SET_VAR(data__->,CURRENT_TIME,__CURRENT_TIME)}
       
    85 
       
    86  IF IN
       
    87  THEN
       
    88    IF NOT PREV_IN
       
    89    THEN
       
    90        OFFSET := PDT - CURRENT_TIME;
       
    91    END_IF;
       
    92 
       
    93    (* PDT + time since PDT was loaded *)
       
    94    CDT := CURRENT_TIME + OFFSET;
       
    95  ELSE
       
    96    CDT := CURRENT_TIME;
       
    97  END_IF;
       
    98 
       
    99  Q := IN;
       
   100  PREV_IN := IN;
       
   101 ]]></xhtml:p>
       
   102           </ST>
       
   103         </body>
       
   104         <documentation>
       
   105           <xhtml:p><![CDATA[The real time clock has many uses including time stamping, setting dates and times of day in batch reports, in alarm messages and so on.]]></xhtml:p>
       
   106         </documentation>
       
   107       </pou>
       
   108       <pou name="INTEGRAL" pouType="functionBlock">
       
   109         <interface>
       
   110           <inputVars>
       
   111             <variable name="RUN">
       
   112               <type>
       
   113                 <BOOL/>
       
   114               </type>
       
   115               <documentation>
       
   116                 <xhtml:p><![CDATA[1 = integrate, 0 = hold]]></xhtml:p>
       
   117               </documentation>
       
   118             </variable>
       
   119             <variable name="R1">
       
   120               <type>
       
   121                 <BOOL/>
       
   122               </type>
       
   123               <documentation>
       
   124                 <xhtml:p><![CDATA[Overriding reset]]></xhtml:p>
       
   125               </documentation>
       
   126             </variable>
       
   127             <variable name="XIN">
       
   128               <type>
       
   129                 <REAL/>
       
   130               </type>
       
   131               <documentation>
       
   132                 <xhtml:p><![CDATA[Input variable]]></xhtml:p>
       
   133               </documentation>
       
   134             </variable>
       
   135             <variable name="X0">
       
   136               <type>
       
   137                 <REAL/>
       
   138               </type>
       
   139               <documentation>
       
   140                 <xhtml:p><![CDATA[Initial value]]></xhtml:p>
       
   141               </documentation>
       
   142             </variable>
       
   143             <variable name="CYCLE">
       
   144               <type>
       
   145                 <TIME/>
       
   146               </type>
       
   147               <documentation>
       
   148                 <xhtml:p><![CDATA[Sampling period]]></xhtml:p>
       
   149               </documentation>
       
   150             </variable>
       
   151           </inputVars>
       
   152           <outputVars>
       
   153             <variable name="Q">
       
   154               <type>
       
   155                 <BOOL/>
       
   156               </type>
       
   157               <documentation>
       
   158                 <xhtml:p><![CDATA[NOT R1]]></xhtml:p>
       
   159               </documentation>
       
   160             </variable>
       
   161             <variable name="XOUT">
       
   162               <type>
       
   163                 <REAL/>
       
   164               </type>
       
   165               <documentation>
       
   166                 <xhtml:p><![CDATA[Integrated output]]></xhtml:p>
       
   167               </documentation>
       
   168             </variable>
       
   169           </outputVars>
       
   170         </interface>
       
   171         <body>
       
   172           <ST>
       
   173             <xhtml:p><![CDATA[Q := NOT R1 ;
       
   174 IF R1 THEN XOUT := X0;
       
   175 ELSIF RUN THEN XOUT := XOUT + XIN * TIME_TO_REAL(CYCLE);
       
   176 END_IF;]]></xhtml:p>
       
   177           </ST>
       
   178         </body>
       
   179         <documentation>
       
   180           <xhtml:p><![CDATA[The integral function block integrates the value of input XIN over time.]]></xhtml:p>
       
   181         </documentation>
       
   182       </pou>
       
   183       <pou name="DERIVATIVE" pouType="functionBlock">
       
   184         <interface>
       
   185           <inputVars>
       
   186             <variable name="RUN">
       
   187               <type>
       
   188                 <BOOL/>
       
   189               </type>
       
   190               <documentation>
       
   191                 <xhtml:p><![CDATA[0 = reset]]></xhtml:p>
       
   192               </documentation>
       
   193             </variable>
       
   194             <variable name="XIN">
       
   195               <type>
       
   196                 <REAL/>
       
   197               </type>
       
   198               <documentation>
       
   199                 <xhtml:p><![CDATA[Input to be differentiated]]></xhtml:p>
       
   200               </documentation>
       
   201             </variable>
       
   202             <variable name="CYCLE">
       
   203               <type>
       
   204                 <TIME/>
       
   205               </type>
       
   206               <documentation>
       
   207                 <xhtml:p><![CDATA[Sampling period]]></xhtml:p>
       
   208               </documentation>
       
   209             </variable>
       
   210           </inputVars>
       
   211           <outputVars>
       
   212             <variable name="XOUT">
       
   213               <type>
       
   214                 <REAL/>
       
   215               </type>
       
   216               <documentation>
       
   217                 <xhtml:p><![CDATA[Differentiated output]]></xhtml:p>
       
   218               </documentation>
       
   219             </variable>
       
   220           </outputVars>
       
   221           <localVars>
       
   222             <variable name="X1">
       
   223               <type>
       
   224                 <REAL/>
       
   225               </type>
       
   226             </variable>
       
   227             <variable name="X2">
       
   228               <type>
       
   229                 <REAL/>
       
   230               </type>
       
   231             </variable>
       
   232             <variable name="X3">
       
   233               <type>
       
   234                 <REAL/>
       
   235               </type>
       
   236             </variable>
       
   237           </localVars>
       
   238         </interface>
       
   239         <body>
       
   240           <ST>
       
   241             <xhtml:p><![CDATA[IF RUN THEN
       
   242   XOUT := (3.0 * (XIN - X3) + X1 - X2)
       
   243           / (10.0 * TIME_TO_REAL(CYCLE));
       
   244   X3 := X2;
       
   245   X2 := X1;
       
   246   X1 := XIN;
       
   247 ELSE 
       
   248   XOUT := 0.0;
       
   249   X1 := XIN;
       
   250   X2 := XIN;
       
   251   X3 := XIN;
       
   252 END_IF;]]></xhtml:p>
       
   253           </ST>
       
   254         </body>
       
   255         <documentation>
       
   256           <xhtml:p><![CDATA[The derivative function block produces an output XOUT proportional to the rate of change of the input XIN.]]></xhtml:p>
       
   257         </documentation>
       
   258       </pou>
       
   259       <pou name="PID" pouType="functionBlock">
       
   260         <interface>
       
   261           <inputVars>
       
   262             <variable name="AUTO">
       
   263               <type>
       
   264                 <BOOL/>
       
   265               </type>
       
   266               <documentation>
       
   267                 <xhtml:p><![CDATA[0 - manual , 1 - automatic]]></xhtml:p>
       
   268               </documentation>
       
   269             </variable>
       
   270             <variable name="PV">
       
   271               <type>
       
   272                 <REAL/>
       
   273               </type>
       
   274               <documentation>
       
   275                 <xhtml:p><![CDATA[Process variable]]></xhtml:p>
       
   276               </documentation>
       
   277             </variable>
       
   278             <variable name="SP">
       
   279               <type>
       
   280                 <REAL/>
       
   281               </type>
       
   282               <documentation>
       
   283                 <xhtml:p><![CDATA[Set point]]></xhtml:p>
       
   284               </documentation>
       
   285             </variable>
       
   286             <variable name="X0">
       
   287               <type>
       
   288                 <REAL/>
       
   289               </type>
       
   290               <documentation>
       
   291                 <xhtml:p><![CDATA[Manual output adjustment - Typically from transfer station]]></xhtml:p>
       
   292               </documentation>
       
   293             </variable>
       
   294             <variable name="KP">
       
   295               <type>
       
   296                 <REAL/>
       
   297               </type>
       
   298               <documentation>
       
   299                 <xhtml:p><![CDATA[Proportionality constant]]></xhtml:p>
       
   300               </documentation>
       
   301             </variable>
       
   302             <variable name="TR">
       
   303               <type>
       
   304                 <REAL/>
       
   305               </type>
       
   306               <documentation>
       
   307                 <xhtml:p><![CDATA[Reset time]]></xhtml:p>
       
   308               </documentation>
       
   309             </variable>
       
   310             <variable name="TD">
       
   311               <type>
       
   312                 <REAL/>
       
   313               </type>
       
   314               <documentation>
       
   315                 <xhtml:p><![CDATA[Derivative time constant]]></xhtml:p>
       
   316               </documentation>
       
   317             </variable>
       
   318             <variable name="CYCLE">
       
   319               <type>
       
   320                 <TIME/>
       
   321               </type>
       
   322               <documentation>
       
   323                 <xhtml:p><![CDATA[Sampling period]]></xhtml:p>
       
   324               </documentation>
       
   325             </variable>
       
   326           </inputVars>
       
   327           <outputVars>
       
   328             <variable name="XOUT">
       
   329               <type>
       
   330                 <REAL/>
       
   331               </type>
       
   332             </variable>
       
   333           </outputVars>
       
   334           <localVars>
       
   335             <variable name="ERROR">
       
   336               <type>
       
   337                 <REAL/>
       
   338               </type>
       
   339               <documentation>
       
   340                 <xhtml:p><![CDATA[PV - SP]]></xhtml:p>
       
   341               </documentation>
       
   342             </variable>
       
   343             <variable name="ITERM">
       
   344               <type>
       
   345                 <derived name="INTEGRAL"/>
       
   346               </type>
       
   347               <documentation>
       
   348                 <xhtml:p><![CDATA[FB for integral term]]></xhtml:p>
       
   349               </documentation>
       
   350             </variable>
       
   351             <variable name="DTERM">
       
   352               <type>
       
   353                 <derived name="DERIVATIVE"/>
       
   354               </type>
       
   355               <documentation>
       
   356                 <xhtml:p><![CDATA[FB for derivative term]]></xhtml:p>
       
   357               </documentation>
       
   358             </variable>
       
   359           </localVars>
       
   360         </interface>
       
   361         <body>
       
   362           <ST>
       
   363             <xhtml:p><![CDATA[ERROR := PV - SP ;
       
   364 (*** Adjust ITERM so that XOUT := X0 when AUTO = 0 ***)
       
   365 ITERM(RUN := AUTO, R1 := NOT AUTO, XIN := ERROR,
       
   366       X0 := TR * (X0 - ERROR), CYCLE := CYCLE);
       
   367 DTERM(RUN := AUTO, XIN := ERROR, CYCLE := CYCLE);
       
   368 XOUT := KP * (ERROR + ITERM.XOUT/TR + DTERM.XOUT*TD);]]></xhtml:p>
       
   369           </ST>
       
   370         </body>
       
   371         <documentation>
       
   372           <xhtml:p><![CDATA[The PID (proportional, Integral, Derivative) function block provides the classical three term controller for closed loop control.]]></xhtml:p>
       
   373         </documentation>
       
   374       </pou>
       
   375       <pou name="RAMP" pouType="functionBlock">
       
   376         <interface>
       
   377           <inputVars>
       
   378             <variable name="RUN">
       
   379               <type>
       
   380                 <BOOL/>
       
   381               </type>
       
   382               <documentation>
       
   383                 <xhtml:p><![CDATA[0 - track X0, 1 - ramp to/track X1]]></xhtml:p>
       
   384               </documentation>
       
   385             </variable>
       
   386             <variable name="X0">
       
   387               <type>
       
   388                 <REAL/>
       
   389               </type>
       
   390             </variable>
       
   391             <variable name="X1">
       
   392               <type>
       
   393                 <REAL/>
       
   394               </type>
       
   395             </variable>
       
   396             <variable name="TR">
       
   397               <type>
       
   398                 <TIME/>
       
   399               </type>
       
   400               <documentation>
       
   401                 <xhtml:p><![CDATA[Ramp duration]]></xhtml:p>
       
   402               </documentation>
       
   403             </variable>
       
   404             <variable name="CYCLE">
       
   405               <type>
       
   406                 <TIME/>
       
   407               </type>
       
   408               <documentation>
       
   409                 <xhtml:p><![CDATA[Sampling period]]></xhtml:p>
       
   410               </documentation>
       
   411             </variable>
       
   412           </inputVars>
       
   413           <outputVars>
       
   414             <variable name="BUSY">
       
   415               <type>
       
   416                 <BOOL/>
       
   417               </type>
       
   418               <documentation>
       
   419                 <xhtml:p><![CDATA[BUSY = 1 during ramping period]]></xhtml:p>
       
   420               </documentation>
       
   421             </variable>
       
   422             <variable name="XOUT">
       
   423               <type>
       
   424                 <REAL/>
       
   425               </type>
       
   426               <initialValue>
       
   427                 <simpleValue value="0.0"/>
       
   428               </initialValue>
       
   429             </variable>
       
   430           </outputVars>
       
   431           <localVars>
       
   432             <variable name="XI">
       
   433               <type>
       
   434                 <REAL/>
       
   435               </type>
       
   436               <documentation>
       
   437                 <xhtml:p><![CDATA[Initial value]]></xhtml:p>
       
   438               </documentation>
       
   439             </variable>
       
   440             <variable name="T0">
       
   441               <type>
       
   442                 <TIME/>
       
   443               </type>
       
   444               <initialValue>
       
   445                 <simpleValue value="T#0s"/>
       
   446               </initialValue>
       
   447               <documentation>
       
   448                 <xhtml:p><![CDATA[Elapsed time of ramp]]></xhtml:p>
       
   449               </documentation>
       
   450             </variable>
       
   451           </localVars>
       
   452         </interface>
       
   453         <body>
       
   454           <ST>
       
   455             <xhtml:p><![CDATA[BUSY := RUN ;
       
   456 IF RUN THEN
       
   457   IF T >= TR THEN 
       
   458     BUSY := 0;
       
   459     XOUT := X1;
       
   460   ELSE XOUT := XI + (X1-XI) * TIME_TO_REAL(T)
       
   461                             / TIME_TO_REAL(TR);
       
   462     T := T + CYCLE;
       
   463   END_IF;
       
   464 ELSE
       
   465   XOUT := X0;
       
   466   XI := X0;
       
   467   T := T#0s;
       
   468 END_IF;]]></xhtml:p>
       
   469           </ST>
       
   470         </body>
       
   471         <documentation>
       
   472           <xhtml:p><![CDATA[The RAMP function block is modelled on example given in the standard.]]></xhtml:p>
       
   473         </documentation>
       
   474       </pou>
       
   475       <pou name="HYSTERESIS" pouType="functionBlock">
       
   476         <interface>
       
   477           <inputVars>
       
   478             <variable name="XIN1">
       
   479               <type>
       
   480                 <REAL/>
       
   481               </type>
       
   482             </variable>
       
   483             <variable name="XIN2">
       
   484               <type>
       
   485                 <REAL/>
       
   486               </type>
       
   487             </variable>
       
   488             <variable name="EPS">
       
   489               <type>
       
   490                 <REAL/>
       
   491               </type>
       
   492             </variable>
       
   493           </inputVars>
       
   494           <outputVars>
       
   495             <variable name="Q">
       
   496               <type>
       
   497                 <BOOL/>
       
   498               </type>
       
   499             </variable>
       
   500           </outputVars>
       
   501         </interface>
       
   502         <body>
       
   503           <ST>
       
   504             <xhtml:p><![CDATA[IF Q THEN
       
   505   IF XIN1 < (XIN2 - EPS) THEN 
       
   506     Q := 0;
       
   507   END_IF;
       
   508 ELSIF XIN1 > (XIN2 + EPS) THEN
       
   509   Q := 1;
       
   510 END_IF;]]></xhtml:p>
       
   511           </ST>
       
   512         </body>
       
   513         <documentation>
       
   514           <xhtml:p><![CDATA[The hysteresis function block provides a hysteresis boolean output driven by the difference of two floating point (REAL) inputs XIN1 and XIN2.]]></xhtml:p>
       
   515         </documentation>
       
   516       </pou>
       
   517     </pous>
       
   518   </types>
       
   519   <instances>
       
   520     <configurations/>
       
   521   </instances>
       
   522 </project>