pous.xml
changeset 4 e8a0af6b89d9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pous.xml	Thu Jun 14 15:16:42 2012 +0200
@@ -0,0 +1,551 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xmlns="http://www.plcopen.org/xml/tc6.xsd"
+         xmlns:xhtml="http://www.w3.org/1999/xhtml"
+         xsi:schemaLocation="http://www.plcopen.org/xml/tc6.xsd">
+  <fileHeader companyName="Beremiz"
+              productName="Beremiz"
+              productVersion="0.0"
+              creationDateTime="2008-12-14T16:53:26"/>
+  <contentHeader name="LPC POUs"
+                 modificationDateTime="2012-01-20T13:35:46">
+    <coordinateInfo>
+      <fbd>
+        <scaling x="0" y="0"/>
+      </fbd>
+      <ld>
+        <scaling x="0" y="0"/>
+      </ld>
+      <sfc>
+        <scaling x="0" y="0"/>
+      </sfc>
+    </coordinateInfo>
+  </contentHeader>
+  <types>
+    <dataTypes/>
+    <pous>
+		<pou name="DEW_POINT" pouType="functionBlock">
+		  <interface>
+			<inputVars>
+			  <variable name="RH">
+				<type>
+				  <REAL/>
+				</type>
+			  </variable>
+			  <variable name="TEMP">
+				<type>
+				  <REAL/>
+				</type>
+			  </variable>
+			</inputVars>
+			<outputVars>
+			  <variable name="DEW_POINT">
+				<type>
+				  <REAL/>
+				</type>
+			  </variable>
+			</outputVars>
+		  </interface>
+		  <body>
+			<ST>
+		<![CDATA[if RH < 0.0 then
+		  RH := 0.0;
+		end_if;
+		if RH > 100.0 then
+		  RH := 100.0;
+		end_if;
+		DEW_POINT:=sqrt(sqrt(sqrt(RH/100.0)))*(112.0+(0.9*TEMP))+(0.1*TEMP)-112.0;]]>
+			</ST>
+		  </body>
+		</pou>
+      <pou name="GET_RETAIN_DATA" pouType="functionBlock">
+        <interface>
+          <inputVars>
+            <variable name="INDEX">
+              <type>
+                <UINT/>
+              </type>
+              <initialValue>
+                <simpleValue value="0"/>
+              </initialValue>
+              <documentation>
+<![CDATA[Index (row) of the retain array.]]>
+              </documentation>
+            </variable>
+            <variable name="READ">
+              <type>
+                <BOOL/>
+              </type>
+              <initialValue>
+                <simpleValue value="FALSE"/>
+              </initialValue>
+            </variable>
+          </inputVars>
+          <outputVars>
+            <variable name="WORD1">
+              <type>
+                <UINT/>
+              </type>
+              <documentation>
+<![CDATA[Data - first column.]]>
+              </documentation>
+            </variable>
+            <variable name="WORD2">
+              <type>
+                <UINT/>
+              </type>
+            </variable>
+            <variable name="WORD3">
+              <type>
+                <UINT/>
+              </type>
+            </variable>
+            <variable name="RD_OK">
+              <type>
+                <BOOL/>
+              </type>
+              <initialValue>
+                <simpleValue value="FALSE"/>
+              </initialValue>
+            </variable>
+          </outputVars>
+        </interface>
+        <body>
+          <ST>
+<![CDATA[{
+extern IEC_UINT __GetRetainData(BOOL, IEC_UINT, IEC_UINT);
+extern BOOL __GetReadStatus(BOOL);
+__SET_VAR(data__->,WORD1,__GetRetainData(__GET_VAR(data__->READ),__GET_VAR(data__->INDEX),0));
+__SET_VAR(data__->,WORD2,__GetRetainData(__GET_VAR(data__->READ),__GET_VAR(data__->INDEX),1));
+__SET_VAR(data__->,WORD3,__GetRetainData(__GET_VAR(data__->READ),__GET_VAR(data__->INDEX),2));
+__SET_VAR(data__->,RD_OK,__GetReadStatus(0));
+}]]>
+          </ST>
+        </body>
+      </pou>
+      <pou name="SET_RETAIN_DATA" pouType="functionBlock">
+        <interface>
+          <inputVars>
+            <variable name="INDEX">
+              <type>
+                <UINT/>
+              </type>
+              <initialValue>
+                <simpleValue value="0"/>
+              </initialValue>
+            </variable>
+            <variable name="WRITE">
+              <type>
+                <BOOL/>
+              </type>
+              <initialValue>
+                <simpleValue value="FALSE"/>
+              </initialValue>
+            </variable>
+            <variable name="WORD1">
+              <type>
+                <UINT/>
+              </type>
+            </variable>
+            <variable name="WORD2">
+              <type>
+                <UINT/>
+              </type>
+            </variable>
+            <variable name="WORD3">
+              <type>
+                <UINT/>
+              </type>
+            </variable>
+          </inputVars>
+          <outputVars>
+            <variable name="WR_OK">
+              <type>
+                <BOOL/>
+              </type>
+              <initialValue>
+                <simpleValue value="FALSE"/>
+              </initialValue>
+            </variable>
+          </outputVars>
+        </interface>
+        <body>
+          <ST>
+<![CDATA[{
+extern BOOL __SetRetainData(BOOL, IEC_UINT, IEC_UINT, IEC_UINT, IEC_UINT);
+__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)));
+}]]>
+          </ST>
+        </body>
+      </pou>
+      <pou name="FIND_RETAIN_DATA" pouType="functionBlock">
+        <interface>
+          <outputVars>
+            <variable name="FOUND">
+              <type>
+                <BOOL/>
+              </type>
+              <initialValue>
+                <simpleValue value="False"/>
+              </initialValue>
+            </variable>
+            <variable name="INDEX">
+              <type>
+                <UINT/>
+              </type>
+            </variable>
+          </outputVars>
+          <inputVars>
+            <variable name="START_IDX">
+              <type>
+                <UINT/>
+              </type>
+              <initialValue>
+                <simpleValue value="0"/>
+              </initialValue>
+            </variable>
+            <variable name="END_IDX">
+              <type>
+                <UINT/>
+              </type>
+              <initialValue>
+                <simpleValue value="0"/>
+              </initialValue>
+            </variable>
+            <variable name="SEARCH">
+              <type>
+                <BOOL/>
+              </type>
+              <initialValue>
+                <simpleValue value="False"/>
+              </initialValue>
+            </variable>
+            <variable name="WORD1">
+              <type>
+                <UINT/>
+              </type>
+            </variable>
+            <variable name="WORD2">
+              <type>
+                <UINT/>
+              </type>
+            </variable>
+            <variable name="WORD3">
+              <type>
+                <UINT/>
+              </type>
+            </variable>
+          </inputVars>
+        </interface>
+        <body>
+          <ST>
+<![CDATA[{
+extern BOOL __FindRetainData(BOOL, IEC_UINT, IEC_UINT, IEC_UINT, IEC_UINT, IEC_UINT);
+extern IEC_UINT __GetFoundIndex(BOOL);
+__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)));
+__SET_VAR(data__->,INDEX,__GetFoundIndex(0));
+}]]>
+          </ST>
+        </body>
+      </pou>
+      <pou name="PID_A" pouType="functionBlock">
+        <interface>
+          <inputVars>
+            <variable name="SET_POINT">
+              <type>
+                <REAL/>
+              </type>
+            </variable>
+          </inputVars>
+          <localVars>
+            <variable name="ena">
+              <type>
+                <INT/>
+              </type>
+              <initialValue>
+                <simpleValue value="1"/>
+              </initialValue>
+            </variable>
+          </localVars>
+          <inputVars>
+            <variable name="ACTUAL_VALUE">
+              <type>
+                <REAL/>
+              </type>
+            </variable>
+            <variable name="REVERSE">
+              <type>
+                <BOOL/>
+              </type>
+            </variable>
+            <variable name="HOLD">
+              <type>
+                <BOOL/>
+              </type>
+            </variable>
+            <variable name="MANUAL">
+              <type>
+                <BOOL/>
+              </type>
+            </variable>
+            <variable name="MANUAL_REF">
+              <type>
+                <REAL/>
+              </type>
+            </variable>
+            <variable name="Kp_GAIN">
+              <type>
+                <REAL/>
+              </type>
+            </variable>
+            <variable name="Ki_GAIN">
+              <type>
+                <REAL/>
+              </type>
+            </variable>
+            <variable name="Kd_GAIN">
+              <type>
+                <REAL/>
+              </type>
+            </variable>
+            <variable name="Td_FADEOUT">
+              <type>
+                <TIME/>
+              </type>
+              <initialValue>
+                <simpleValue value="t#1s"/>
+              </initialValue>
+            </variable>
+            <variable name="DEAD_BAND">
+              <type>
+                <REAL/>
+              </type>
+            </variable>
+            <variable name="OUT_MAX">
+              <type>
+                <REAL/>
+              </type>
+            </variable>
+            <variable name="OUT_MIN">
+              <type>
+                <REAL/>
+              </type>
+            </variable>
+            <variable name="CYCLE_TIME">
+              <type>
+                <TIME/>
+              </type>
+              <initialValue>
+                <simpleValue value="t#0.1s"/>
+              </initialValue>
+            </variable>
+          </inputVars>
+          <outputVars>
+            <variable name="OUT">
+              <type>
+                <REAL/>
+              </type>
+            </variable>
+          </outputVars>
+          <localVars>
+            <variable name="D_fadeout">
+              <type>
+                <REAL/>
+              </type>
+            </variable>
+            <variable name="Error_n">
+              <type>
+                <REAL/>
+              </type>
+              <initialValue>
+                <simpleValue value="0.0"/>
+              </initialValue>
+            </variable>
+            <variable name="Error_n1">
+              <type>
+                <REAL/>
+              </type>
+              <initialValue>
+                <simpleValue value="0.0"/>
+              </initialValue>
+            </variable>
+            <variable name="Error_n2">
+              <type>
+                <REAL/>
+              </type>
+              <initialValue>
+                <simpleValue value="0.0"/>
+              </initialValue>
+            </variable>
+            <variable name="Dout_n">
+              <type>
+                <REAL/>
+              </type>
+              <initialValue>
+                <simpleValue value="0.0"/>
+              </initialValue>
+            </variable>
+            <variable name="Dout">
+              <type>
+                <REAL/>
+              </type>
+              <initialValue>
+                <simpleValue value="0.0"/>
+              </initialValue>
+            </variable>
+            <variable name="Dout_1">
+              <type>
+                <REAL/>
+              </type>
+              <initialValue>
+                <simpleValue value="0.0"/>
+              </initialValue>
+            </variable>
+            <variable name="TON_1">
+              <type>
+                <derived name="TON"/>
+              </type>
+            </variable>
+            <variable name="TON_1_Q">
+              <type>
+                <BOOL/>
+              </type>
+            </variable>
+            <variable name="ET1">
+              <type>
+                <TIME/>
+              </type>
+            </variable>
+            <variable name="CTr">
+              <type>
+                <REAL/>
+              </type>
+            </variable>
+            <variable name="FTr">
+              <type>
+                <REAL/>
+              </type>
+            </variable>
+            <variable name="power">
+              <type>
+                <REAL/>
+              </type>
+            </variable>
+            <variable name="OUTchk">
+              <type>
+                <REAL/>
+              </type>
+            </variable>
+            <variable name="Dout_int">
+              <type>
+                <REAL/>
+              </type>
+            </variable>
+            <variable name="Reverse_1">
+              <type>
+                <BOOL/>
+              </type>
+            </variable>
+            <variable name="Soft_t">
+              <type>
+                <BOOL/>
+              </type>
+            </variable>
+            <variable name="R_chk">
+              <type>
+                <INT/>
+              </type>
+            </variable>
+          </localVars>
+        </interface>
+        <body>
+          <ST>
+<![CDATA[TON_1(
+     IN := NOT TON_1_Q,
+     PT := CYCLE_TIME,
+     Q => TON_1_Q,
+     ET => ET1
+     );
+if TON_1_Q then
+  if REVERSE then
+    Error_n := SET_POINT - ACTUAL_VALUE;
+  else
+    Error_n := ACTUAL_VALUE - SET_POINT;
+  end_if;
+  if Td_FADEOUT <= T#0.05s then
+  Td_FADEOUT := t#0.05s;
+  end_if;
+     CTr := TIME_TO_REAL (CYCLE_TIME);
+     FTr := TIME_TO_REAL (Td_FADEOUT);
+      power := CTr / FTr;
+       D_Fadeout := EXPT( 0.04979 , power );  (*time to reach 5% = e^(-3) *)
+         Dout := Kd_GAIN * (Error_n - 2.0 * Error_n1 + Error_n2); 
+         Dout_n := Dout + Dout_1 * D_Fadeout;  
+         Dout_int := Dout_int + Dout_n;
+           OUTchk := OUTchk + Kp_GAIN * (Error_n - Error_n1) + Ki_GAIN * Error_n * CTr;
+    R_chk:= bool_to_int(REVERSE) + bool_to_int(Reverse_1);
+        if (Soft_t or R_chk=1) then
+         Dout_int := 0.0;
+          Dout_n := 0.0;
+           Dout_1:= 0.0;
+            Dout:= 0.0;
+            OUTchk:= OUT;
+           Error_n1:=Error_n;
+          Error_n2:=Error_n;
+         Soft_t := 0;
+        end_if;
+      if R_chk =1 then 
+        Error_n:=0.0;
+        Soft_t := True;
+      end_if;
+           
+     if OUTchk > OUT_MAX then
+        OUTchk := OUT_MAX;
+     end_if;
+     
+     if OUTchk < OUT_MIN then
+        OUTchk := OUT_MIN;
+     end_if;
+    
+  if MANUAL then
+    OUT := MANUAL_REF;
+     OUTchk:= OUT;
+      Dout_int := 0.0;
+       Dout_n := 0.0;
+       Dout_1:= 0.0;
+  else 
+    if abs(Error_n) < DEAD_BAND or HOLD  then
+       OUT := OUT;
+        OUTchk:= OUT;
+        Dout_int := 0.0;
+        Dout_n := 0.0;
+       Dout_1:= 0.0;
+    else
+      OUT := OUTchk + Dout_int;
+    end_if;
+  end_if;
+  
+ if OUT > OUT_MAX then
+ OUT := OUT_MAX;
+ end_if;
+  
+ if OUT < OUT_MIN then
+ OUT := OUT_MIN;
+ end_if;
+ 
+    Error_n2 := Error_n1;
+     Error_n1 := Error_n;
+      Dout_1:=Dout_n;
+        Reverse_1 := REVERSE;
+else
+  OUT:=OUT;
+end_if;]]>
+          </ST>
+        </body>
+      </pou>
+    </pous>
+  </types>
+  <instances>
+    <configurations/>
+  </instances>
+</project>