pous.xml
changeset 4 e8a0af6b89d9
equal deleted inserted replaced
2:0c697b8fc443 4:e8a0af6b89d9
       
     1 <?xml version="1.0" encoding="UTF-8"?>
       
     2 <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       
     3          xmlns="http://www.plcopen.org/xml/tc6.xsd"
       
     4          xmlns:xhtml="http://www.w3.org/1999/xhtml"
       
     5          xsi:schemaLocation="http://www.plcopen.org/xml/tc6.xsd">
       
     6   <fileHeader companyName="Beremiz"
       
     7               productName="Beremiz"
       
     8               productVersion="0.0"
       
     9               creationDateTime="2008-12-14T16:53:26"/>
       
    10   <contentHeader name="LPC POUs"
       
    11                  modificationDateTime="2012-01-20T13:35:46">
       
    12     <coordinateInfo>
       
    13       <fbd>
       
    14         <scaling x="0" y="0"/>
       
    15       </fbd>
       
    16       <ld>
       
    17         <scaling x="0" y="0"/>
       
    18       </ld>
       
    19       <sfc>
       
    20         <scaling x="0" y="0"/>
       
    21       </sfc>
       
    22     </coordinateInfo>
       
    23   </contentHeader>
       
    24   <types>
       
    25     <dataTypes/>
       
    26     <pous>
       
    27 		<pou name="DEW_POINT" pouType="functionBlock">
       
    28 		  <interface>
       
    29 			<inputVars>
       
    30 			  <variable name="RH">
       
    31 				<type>
       
    32 				  <REAL/>
       
    33 				</type>
       
    34 			  </variable>
       
    35 			  <variable name="TEMP">
       
    36 				<type>
       
    37 				  <REAL/>
       
    38 				</type>
       
    39 			  </variable>
       
    40 			</inputVars>
       
    41 			<outputVars>
       
    42 			  <variable name="DEW_POINT">
       
    43 				<type>
       
    44 				  <REAL/>
       
    45 				</type>
       
    46 			  </variable>
       
    47 			</outputVars>
       
    48 		  </interface>
       
    49 		  <body>
       
    50 			<ST>
       
    51 		<![CDATA[if RH < 0.0 then
       
    52 		  RH := 0.0;
       
    53 		end_if;
       
    54 		if RH > 100.0 then
       
    55 		  RH := 100.0;
       
    56 		end_if;
       
    57 		DEW_POINT:=sqrt(sqrt(sqrt(RH/100.0)))*(112.0+(0.9*TEMP))+(0.1*TEMP)-112.0;]]>
       
    58 			</ST>
       
    59 		  </body>
       
    60 		</pou>
       
    61       <pou name="GET_RETAIN_DATA" pouType="functionBlock">
       
    62         <interface>
       
    63           <inputVars>
       
    64             <variable name="INDEX">
       
    65               <type>
       
    66                 <UINT/>
       
    67               </type>
       
    68               <initialValue>
       
    69                 <simpleValue value="0"/>
       
    70               </initialValue>
       
    71               <documentation>
       
    72 <![CDATA[Index (row) of the retain array.]]>
       
    73               </documentation>
       
    74             </variable>
       
    75             <variable name="READ">
       
    76               <type>
       
    77                 <BOOL/>
       
    78               </type>
       
    79               <initialValue>
       
    80                 <simpleValue value="FALSE"/>
       
    81               </initialValue>
       
    82             </variable>
       
    83           </inputVars>
       
    84           <outputVars>
       
    85             <variable name="WORD1">
       
    86               <type>
       
    87                 <UINT/>
       
    88               </type>
       
    89               <documentation>
       
    90 <![CDATA[Data - first column.]]>
       
    91               </documentation>
       
    92             </variable>
       
    93             <variable name="WORD2">
       
    94               <type>
       
    95                 <UINT/>
       
    96               </type>
       
    97             </variable>
       
    98             <variable name="WORD3">
       
    99               <type>
       
   100                 <UINT/>
       
   101               </type>
       
   102             </variable>
       
   103             <variable name="RD_OK">
       
   104               <type>
       
   105                 <BOOL/>
       
   106               </type>
       
   107               <initialValue>
       
   108                 <simpleValue value="FALSE"/>
       
   109               </initialValue>
       
   110             </variable>
       
   111           </outputVars>
       
   112         </interface>
       
   113         <body>
       
   114           <ST>
       
   115 <![CDATA[{
       
   116 extern IEC_UINT __GetRetainData(BOOL, IEC_UINT, IEC_UINT);
       
   117 extern BOOL __GetReadStatus(BOOL);
       
   118 __SET_VAR(data__->,WORD1,__GetRetainData(__GET_VAR(data__->READ),__GET_VAR(data__->INDEX),0));
       
   119 __SET_VAR(data__->,WORD2,__GetRetainData(__GET_VAR(data__->READ),__GET_VAR(data__->INDEX),1));
       
   120 __SET_VAR(data__->,WORD3,__GetRetainData(__GET_VAR(data__->READ),__GET_VAR(data__->INDEX),2));
       
   121 __SET_VAR(data__->,RD_OK,__GetReadStatus(0));
       
   122 }]]>
       
   123           </ST>
       
   124         </body>
       
   125       </pou>
       
   126       <pou name="SET_RETAIN_DATA" pouType="functionBlock">
       
   127         <interface>
       
   128           <inputVars>
       
   129             <variable name="INDEX">
       
   130               <type>
       
   131                 <UINT/>
       
   132               </type>
       
   133               <initialValue>
       
   134                 <simpleValue value="0"/>
       
   135               </initialValue>
       
   136             </variable>
       
   137             <variable name="WRITE">
       
   138               <type>
       
   139                 <BOOL/>
       
   140               </type>
       
   141               <initialValue>
       
   142                 <simpleValue value="FALSE"/>
       
   143               </initialValue>
       
   144             </variable>
       
   145             <variable name="WORD1">
       
   146               <type>
       
   147                 <UINT/>
       
   148               </type>
       
   149             </variable>
       
   150             <variable name="WORD2">
       
   151               <type>
       
   152                 <UINT/>
       
   153               </type>
       
   154             </variable>
       
   155             <variable name="WORD3">
       
   156               <type>
       
   157                 <UINT/>
       
   158               </type>
       
   159             </variable>
       
   160           </inputVars>
       
   161           <outputVars>
       
   162             <variable name="WR_OK">
       
   163               <type>
       
   164                 <BOOL/>
       
   165               </type>
       
   166               <initialValue>
       
   167                 <simpleValue value="FALSE"/>
       
   168               </initialValue>
       
   169             </variable>
       
   170           </outputVars>
       
   171         </interface>
       
   172         <body>
       
   173           <ST>
       
   174 <![CDATA[{
       
   175 extern BOOL __SetRetainData(BOOL, IEC_UINT, IEC_UINT, IEC_UINT, IEC_UINT);
       
   176 __SET_VAR(data__->,WR_OK,__SetRetainData(__GET_VAR(data__->WRITE),__GET_VAR(data__->INDEX),__GET_VAR(data__->WORD1),__GET_VAR(data__->WORD2),__GET_VAR(data__->WORD3)));
       
   177 }]]>
       
   178           </ST>
       
   179         </body>
       
   180       </pou>
       
   181       <pou name="FIND_RETAIN_DATA" pouType="functionBlock">
       
   182         <interface>
       
   183           <outputVars>
       
   184             <variable name="FOUND">
       
   185               <type>
       
   186                 <BOOL/>
       
   187               </type>
       
   188               <initialValue>
       
   189                 <simpleValue value="False"/>
       
   190               </initialValue>
       
   191             </variable>
       
   192             <variable name="INDEX">
       
   193               <type>
       
   194                 <UINT/>
       
   195               </type>
       
   196             </variable>
       
   197           </outputVars>
       
   198           <inputVars>
       
   199             <variable name="START_IDX">
       
   200               <type>
       
   201                 <UINT/>
       
   202               </type>
       
   203               <initialValue>
       
   204                 <simpleValue value="0"/>
       
   205               </initialValue>
       
   206             </variable>
       
   207             <variable name="END_IDX">
       
   208               <type>
       
   209                 <UINT/>
       
   210               </type>
       
   211               <initialValue>
       
   212                 <simpleValue value="0"/>
       
   213               </initialValue>
       
   214             </variable>
       
   215             <variable name="SEARCH">
       
   216               <type>
       
   217                 <BOOL/>
       
   218               </type>
       
   219               <initialValue>
       
   220                 <simpleValue value="False"/>
       
   221               </initialValue>
       
   222             </variable>
       
   223             <variable name="WORD1">
       
   224               <type>
       
   225                 <UINT/>
       
   226               </type>
       
   227             </variable>
       
   228             <variable name="WORD2">
       
   229               <type>
       
   230                 <UINT/>
       
   231               </type>
       
   232             </variable>
       
   233             <variable name="WORD3">
       
   234               <type>
       
   235                 <UINT/>
       
   236               </type>
       
   237             </variable>
       
   238           </inputVars>
       
   239         </interface>
       
   240         <body>
       
   241           <ST>
       
   242 <![CDATA[{
       
   243 extern BOOL __FindRetainData(BOOL, IEC_UINT, IEC_UINT, IEC_UINT, IEC_UINT, IEC_UINT);
       
   244 extern IEC_UINT __GetFoundIndex(BOOL);
       
   245 __SET_VAR(data__->,FOUND,__FindRetainData(__GET_VAR(data__->SEARCH),__GET_VAR(data__->START_IDX),__GET_VAR(data__->END_IDX),__GET_VAR(data__->WORD1),__GET_VAR(data__->WORD2),__GET_VAR(data__->WORD3)));
       
   246 __SET_VAR(data__->,INDEX,__GetFoundIndex(0));
       
   247 }]]>
       
   248           </ST>
       
   249         </body>
       
   250       </pou>
       
   251       <pou name="PID_A" pouType="functionBlock">
       
   252         <interface>
       
   253           <inputVars>
       
   254             <variable name="SET_POINT">
       
   255               <type>
       
   256                 <REAL/>
       
   257               </type>
       
   258             </variable>
       
   259           </inputVars>
       
   260           <localVars>
       
   261             <variable name="ena">
       
   262               <type>
       
   263                 <INT/>
       
   264               </type>
       
   265               <initialValue>
       
   266                 <simpleValue value="1"/>
       
   267               </initialValue>
       
   268             </variable>
       
   269           </localVars>
       
   270           <inputVars>
       
   271             <variable name="ACTUAL_VALUE">
       
   272               <type>
       
   273                 <REAL/>
       
   274               </type>
       
   275             </variable>
       
   276             <variable name="REVERSE">
       
   277               <type>
       
   278                 <BOOL/>
       
   279               </type>
       
   280             </variable>
       
   281             <variable name="HOLD">
       
   282               <type>
       
   283                 <BOOL/>
       
   284               </type>
       
   285             </variable>
       
   286             <variable name="MANUAL">
       
   287               <type>
       
   288                 <BOOL/>
       
   289               </type>
       
   290             </variable>
       
   291             <variable name="MANUAL_REF">
       
   292               <type>
       
   293                 <REAL/>
       
   294               </type>
       
   295             </variable>
       
   296             <variable name="Kp_GAIN">
       
   297               <type>
       
   298                 <REAL/>
       
   299               </type>
       
   300             </variable>
       
   301             <variable name="Ki_GAIN">
       
   302               <type>
       
   303                 <REAL/>
       
   304               </type>
       
   305             </variable>
       
   306             <variable name="Kd_GAIN">
       
   307               <type>
       
   308                 <REAL/>
       
   309               </type>
       
   310             </variable>
       
   311             <variable name="Td_FADEOUT">
       
   312               <type>
       
   313                 <TIME/>
       
   314               </type>
       
   315               <initialValue>
       
   316                 <simpleValue value="t#1s"/>
       
   317               </initialValue>
       
   318             </variable>
       
   319             <variable name="DEAD_BAND">
       
   320               <type>
       
   321                 <REAL/>
       
   322               </type>
       
   323             </variable>
       
   324             <variable name="OUT_MAX">
       
   325               <type>
       
   326                 <REAL/>
       
   327               </type>
       
   328             </variable>
       
   329             <variable name="OUT_MIN">
       
   330               <type>
       
   331                 <REAL/>
       
   332               </type>
       
   333             </variable>
       
   334             <variable name="CYCLE_TIME">
       
   335               <type>
       
   336                 <TIME/>
       
   337               </type>
       
   338               <initialValue>
       
   339                 <simpleValue value="t#0.1s"/>
       
   340               </initialValue>
       
   341             </variable>
       
   342           </inputVars>
       
   343           <outputVars>
       
   344             <variable name="OUT">
       
   345               <type>
       
   346                 <REAL/>
       
   347               </type>
       
   348             </variable>
       
   349           </outputVars>
       
   350           <localVars>
       
   351             <variable name="D_fadeout">
       
   352               <type>
       
   353                 <REAL/>
       
   354               </type>
       
   355             </variable>
       
   356             <variable name="Error_n">
       
   357               <type>
       
   358                 <REAL/>
       
   359               </type>
       
   360               <initialValue>
       
   361                 <simpleValue value="0.0"/>
       
   362               </initialValue>
       
   363             </variable>
       
   364             <variable name="Error_n1">
       
   365               <type>
       
   366                 <REAL/>
       
   367               </type>
       
   368               <initialValue>
       
   369                 <simpleValue value="0.0"/>
       
   370               </initialValue>
       
   371             </variable>
       
   372             <variable name="Error_n2">
       
   373               <type>
       
   374                 <REAL/>
       
   375               </type>
       
   376               <initialValue>
       
   377                 <simpleValue value="0.0"/>
       
   378               </initialValue>
       
   379             </variable>
       
   380             <variable name="Dout_n">
       
   381               <type>
       
   382                 <REAL/>
       
   383               </type>
       
   384               <initialValue>
       
   385                 <simpleValue value="0.0"/>
       
   386               </initialValue>
       
   387             </variable>
       
   388             <variable name="Dout">
       
   389               <type>
       
   390                 <REAL/>
       
   391               </type>
       
   392               <initialValue>
       
   393                 <simpleValue value="0.0"/>
       
   394               </initialValue>
       
   395             </variable>
       
   396             <variable name="Dout_1">
       
   397               <type>
       
   398                 <REAL/>
       
   399               </type>
       
   400               <initialValue>
       
   401                 <simpleValue value="0.0"/>
       
   402               </initialValue>
       
   403             </variable>
       
   404             <variable name="TON_1">
       
   405               <type>
       
   406                 <derived name="TON"/>
       
   407               </type>
       
   408             </variable>
       
   409             <variable name="TON_1_Q">
       
   410               <type>
       
   411                 <BOOL/>
       
   412               </type>
       
   413             </variable>
       
   414             <variable name="ET1">
       
   415               <type>
       
   416                 <TIME/>
       
   417               </type>
       
   418             </variable>
       
   419             <variable name="CTr">
       
   420               <type>
       
   421                 <REAL/>
       
   422               </type>
       
   423             </variable>
       
   424             <variable name="FTr">
       
   425               <type>
       
   426                 <REAL/>
       
   427               </type>
       
   428             </variable>
       
   429             <variable name="power">
       
   430               <type>
       
   431                 <REAL/>
       
   432               </type>
       
   433             </variable>
       
   434             <variable name="OUTchk">
       
   435               <type>
       
   436                 <REAL/>
       
   437               </type>
       
   438             </variable>
       
   439             <variable name="Dout_int">
       
   440               <type>
       
   441                 <REAL/>
       
   442               </type>
       
   443             </variable>
       
   444             <variable name="Reverse_1">
       
   445               <type>
       
   446                 <BOOL/>
       
   447               </type>
       
   448             </variable>
       
   449             <variable name="Soft_t">
       
   450               <type>
       
   451                 <BOOL/>
       
   452               </type>
       
   453             </variable>
       
   454             <variable name="R_chk">
       
   455               <type>
       
   456                 <INT/>
       
   457               </type>
       
   458             </variable>
       
   459           </localVars>
       
   460         </interface>
       
   461         <body>
       
   462           <ST>
       
   463 <![CDATA[TON_1(
       
   464      IN := NOT TON_1_Q,
       
   465      PT := CYCLE_TIME,
       
   466      Q => TON_1_Q,
       
   467      ET => ET1
       
   468      );
       
   469 if TON_1_Q then
       
   470   if REVERSE then
       
   471     Error_n := SET_POINT - ACTUAL_VALUE;
       
   472   else
       
   473     Error_n := ACTUAL_VALUE - SET_POINT;
       
   474   end_if;
       
   475   if Td_FADEOUT <= T#0.05s then
       
   476   Td_FADEOUT := t#0.05s;
       
   477   end_if;
       
   478      CTr := TIME_TO_REAL (CYCLE_TIME);
       
   479      FTr := TIME_TO_REAL (Td_FADEOUT);
       
   480       power := CTr / FTr;
       
   481        D_Fadeout := EXPT( 0.04979 , power );  (*time to reach 5% = e^(-3) *)
       
   482          Dout := Kd_GAIN * (Error_n - 2.0 * Error_n1 + Error_n2); 
       
   483          Dout_n := Dout + Dout_1 * D_Fadeout;  
       
   484          Dout_int := Dout_int + Dout_n;
       
   485            OUTchk := OUTchk + Kp_GAIN * (Error_n - Error_n1) + Ki_GAIN * Error_n * CTr;
       
   486     R_chk:= bool_to_int(REVERSE) + bool_to_int(Reverse_1);
       
   487         if (Soft_t or R_chk=1) then
       
   488          Dout_int := 0.0;
       
   489           Dout_n := 0.0;
       
   490            Dout_1:= 0.0;
       
   491             Dout:= 0.0;
       
   492             OUTchk:= OUT;
       
   493            Error_n1:=Error_n;
       
   494           Error_n2:=Error_n;
       
   495          Soft_t := 0;
       
   496         end_if;
       
   497       if R_chk =1 then 
       
   498         Error_n:=0.0;
       
   499         Soft_t := True;
       
   500       end_if;
       
   501            
       
   502      if OUTchk > OUT_MAX then
       
   503         OUTchk := OUT_MAX;
       
   504      end_if;
       
   505      
       
   506      if OUTchk < OUT_MIN then
       
   507         OUTchk := OUT_MIN;
       
   508      end_if;
       
   509     
       
   510   if MANUAL then
       
   511     OUT := MANUAL_REF;
       
   512      OUTchk:= OUT;
       
   513       Dout_int := 0.0;
       
   514        Dout_n := 0.0;
       
   515        Dout_1:= 0.0;
       
   516   else 
       
   517     if abs(Error_n) < DEAD_BAND or HOLD  then
       
   518        OUT := OUT;
       
   519         OUTchk:= OUT;
       
   520         Dout_int := 0.0;
       
   521         Dout_n := 0.0;
       
   522        Dout_1:= 0.0;
       
   523     else
       
   524       OUT := OUTchk + Dout_int;
       
   525     end_if;
       
   526   end_if;
       
   527   
       
   528  if OUT > OUT_MAX then
       
   529  OUT := OUT_MAX;
       
   530  end_if;
       
   531   
       
   532  if OUT < OUT_MIN then
       
   533  OUT := OUT_MIN;
       
   534  end_if;
       
   535  
       
   536     Error_n2 := Error_n1;
       
   537      Error_n1 := Error_n;
       
   538       Dout_1:=Dout_n;
       
   539         Reverse_1 := REVERSE;
       
   540 else
       
   541   OUT:=OUT;
       
   542 end_if;]]>
       
   543           </ST>
       
   544         </body>
       
   545       </pou>
       
   546     </pous>
       
   547   </types>
       
   548   <instances>
       
   549     <configurations/>
       
   550   </instances>
       
   551 </project>