Laurent@1313: <?xml version='1.0' encoding='utf-8'?>
Laurent@1313: <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">
Laurent@1313:   <fileHeader companyName="Beremiz" productName="Standard Function Blocks Library" productVersion="1.0" creationDateTime="2013-09-09T09:56:11"/>
Laurent@1313:   <contentHeader name="Standard Funtion Blocks" author="Laurent Bessard" modificationDateTime="2013-09-09T10:58:13">
Laurent@1313:     <coordinateInfo>
Laurent@1313:       <fbd>
Laurent@1313:         <scaling x="0" y="0"/>
Laurent@1313:       </fbd>
Laurent@1313:       <ld>
Laurent@1313:         <scaling x="0" y="0"/>
Laurent@1313:       </ld>
Laurent@1313:       <sfc>
Laurent@1313:         <scaling x="0" y="0"/>
Laurent@1313:       </sfc>
Laurent@1313:     </coordinateInfo>
Laurent@1313:   </contentHeader>
Laurent@1313:   <types>
Laurent@1313:     <dataTypes/>
Laurent@1313:     <pous>
Laurent@1313:       <pou name="SR" pouType="functionBlock">
Laurent@1313:         <interface>
Laurent@1313:           <inputVars>
Laurent@1313:             <variable name="S1">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="R">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </inputVars>
Laurent@1313:           <outputVars>
Laurent@1313:             <variable name="Q1">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </outputVars>
Laurent@1313:         </interface>
Laurent@1313:         <body>
Laurent@1313:           <ST>
Laurent@1313:             <xhtml:p><![CDATA[Q1 := S1 OR ((NOT R) AND Q1);]]></xhtml:p>
Laurent@1313:           </ST>
Laurent@1313:         </body>
Laurent@1313:         <documentation>
Laurent@1313:           <xhtml:p><![CDATA[The SR bistable is a latch where the Set dominates.]]></xhtml:p>
Laurent@1313:         </documentation>
Laurent@1313:       </pou>
Laurent@1313:       <pou name="RS" pouType="functionBlock">
Laurent@1313:         <interface>
Laurent@1313:           <inputVars>
Laurent@1313:             <variable name="S">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="R1">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </inputVars>
Laurent@1313:           <outputVars>
Laurent@1313:             <variable name="Q1">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </outputVars>
Laurent@1313:         </interface>
Laurent@1313:         <body>
Laurent@1313:           <ST>
Laurent@1313:             <xhtml:p><![CDATA[Q1 := (NOT R1) AND (S OR Q1);]]></xhtml:p>
Laurent@1313:           </ST>
Laurent@1313:         </body>
Laurent@1313:         <documentation>
Laurent@1313:           <xhtml:p><![CDATA[The RS bistable is a latch where the Reset dominates.]]></xhtml:p>
Laurent@1313:         </documentation>
Laurent@1313:       </pou>
Laurent@1313:       <pou name="SEMA" pouType="functionBlock">
Laurent@1313:         <interface>
Laurent@1313:           <inputVars>
Laurent@1313:             <variable name="CLAIM">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="RELEASE">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </inputVars>
Laurent@1313:           <outputVars>
Laurent@1313:             <variable name="BUSY">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </outputVars>
Laurent@1313:           <localVars>
Laurent@1313:             <variable name="Q_INTERNAL">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </localVars>
Laurent@1313:         </interface>
Laurent@1313:         <body>
Laurent@1313:           <ST>
Laurent@1313:             <xhtml:p><![CDATA[Q_INTERNAL := CLAIM OR ( Q_INTERNAL AND (NOT RELEASE));
Laurent@1313: BUSY := Q_INTERNAL;]]></xhtml:p>
Laurent@1313:           </ST>
Laurent@1313:         </body>
Laurent@1313:         <documentation>
Laurent@1313:           <xhtml:p><![CDATA[The semaphore provides a mechanism to allow software elements mutually exclusive access to certain ressources.]]></xhtml:p>
Laurent@1313:         </documentation>
Laurent@1313:       </pou>
Laurent@1313:       <pou name="R_TRIG" pouType="functionBlock">
Laurent@1313:         <interface>
Laurent@1313:           <inputVars>
Laurent@1313:             <variable name="CLK">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </inputVars>
Laurent@1313:           <outputVars>
Laurent@1313:             <variable name="Q">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </outputVars>
Laurent@1313:           <localVars retain="true">
Laurent@1313:             <variable name="M">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </localVars>
Laurent@1313:         </interface>
Laurent@1313:         <body>
Laurent@1313:           <ST>
Laurent@1313:             <xhtml:p><![CDATA[Q := CLK AND NOT M;
Laurent@1313: M := CLK;]]></xhtml:p>
Laurent@1313:           </ST>
Laurent@1313:         </body>
Laurent@1313:         <documentation>
Laurent@1313:           <xhtml:p><![CDATA[The output produces a single pulse when a rising edge is detected.]]></xhtml:p>
Laurent@1313:         </documentation>
Laurent@1313:       </pou>
Laurent@1313:       <pou name="F_TRIG" pouType="functionBlock">
Laurent@1313:         <interface>
Laurent@1313:           <inputVars>
Laurent@1313:             <variable name="CLK">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </inputVars>
Laurent@1313:           <outputVars>
Laurent@1313:             <variable name="Q">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </outputVars>
Laurent@1313:           <localVars retain="true">
Laurent@1313:             <variable name="M">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </localVars>
Laurent@1313:         </interface>
Laurent@1313:         <body>
Laurent@1313:           <ST>
Laurent@1313:             <xhtml:p><![CDATA[Q := NOT CLK AND NOT M;
Laurent@1313: M := NOT CLK;]]></xhtml:p>
Laurent@1313:           </ST>
Laurent@1313:         </body>
Laurent@1313:         <documentation>
Laurent@1313:           <xhtml:p><![CDATA[The output produces a single pulse when a falling edge is detected.]]></xhtml:p>
Laurent@1313:         </documentation>
Laurent@1313:       </pou>
Laurent@1313:       <pou name="CTU" pouType="functionBlock">
Laurent@1313:         <interface>
Laurent@1313:           <inputVars>
Laurent@1313:             <variable name="CU">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="R">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="PV">
Laurent@1313:               <type>
Laurent@1313:                 <INT/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </inputVars>
Laurent@1313:           <outputVars>
Laurent@1313:             <variable name="Q">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="CV">
Laurent@1313:               <type>
Laurent@1313:                 <INT/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </outputVars>
Laurent@1313:           <localVars>
Laurent@1313:             <variable name="CU_T">
Laurent@1313:               <type>
Laurent@1313:                 <derived name="R_TRIG"/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </localVars>
Laurent@1313:         </interface>
Laurent@1313:         <body>
Laurent@1313:           <ST>
Laurent@1313:             <xhtml:p><![CDATA[CU_T(CU);
Laurent@1313: IF R THEN CV := 0;
Laurent@1313: ELSIF CU_T.Q AND (CV < PV)
Laurent@1313:   THEN CV := CV+1;
Laurent@1313: END_IF;
Laurent@1313: Q := (CV >= PV);]]></xhtml:p>
Laurent@1313:           </ST>
Laurent@1313:         </body>
Laurent@1313:         <documentation>
Laurent@1313:           <xhtml:p><![CDATA[The up-counter can be used to signal when a count has reached a maximum value.]]></xhtml:p>
Laurent@1313:         </documentation>
Laurent@1313:       </pou>
Laurent@1313:       <pou name="CTU_DINT" pouType="functionBlock">
Laurent@1313:         <interface>
Laurent@1313:           <inputVars>
Laurent@1313:             <variable name="CU">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="R">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="PV">
Laurent@1313:               <type>
Laurent@1313:                 <DINT/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </inputVars>
Laurent@1313:           <outputVars>
Laurent@1313:             <variable name="Q">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="CV">
Laurent@1313:               <type>
Laurent@1313:                 <DINT/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </outputVars>
Laurent@1313:           <localVars>
Laurent@1313:             <variable name="CU_T">
Laurent@1313:               <type>
Laurent@1313:                 <derived name="R_TRIG"/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </localVars>
Laurent@1313:         </interface>
Laurent@1313:         <body>
Laurent@1313:           <ST>
Laurent@1313:             <xhtml:p><![CDATA[CU_T(CU);
Laurent@1313: IF R THEN CV := 0;
Laurent@1313: ELSIF CU_T.Q AND (CV < PV)
Laurent@1313:   THEN CV := CV+1;
Laurent@1313: END_IF;
Laurent@1313: Q := (CV >= PV);]]></xhtml:p>
Laurent@1313:           </ST>
Laurent@1313:         </body>
Laurent@1313:         <documentation>
Laurent@1313:           <xhtml:p><![CDATA[The up-counter can be used to signal when a count has reached a maximum value.]]></xhtml:p>
Laurent@1313:         </documentation>
Laurent@1313:       </pou>
Laurent@1313:       <pou name="CTU_LINT" pouType="functionBlock">
Laurent@1313:         <interface>
Laurent@1313:           <inputVars>
Laurent@1313:             <variable name="CU">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="R">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="PV">
Laurent@1313:               <type>
Laurent@1313:                 <LINT/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </inputVars>
Laurent@1313:           <outputVars>
Laurent@1313:             <variable name="Q">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="CV">
Laurent@1313:               <type>
Laurent@1313:                 <LINT/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </outputVars>
Laurent@1313:           <localVars>
Laurent@1313:             <variable name="CU_T">
Laurent@1313:               <type>
Laurent@1313:                 <derived name="R_TRIG"/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </localVars>
Laurent@1313:         </interface>
Laurent@1313:         <body>
Laurent@1313:           <ST>
Laurent@1313:             <xhtml:p><![CDATA[CU_T(CU);
Laurent@1313: IF R THEN CV := 0;
Laurent@1313: ELSIF CU_T.Q AND (CV < PV)
Laurent@1313:   THEN CV := CV+1;
Laurent@1313: END_IF;
Laurent@1313: Q := (CV >= PV);]]></xhtml:p>
Laurent@1313:           </ST>
Laurent@1313:         </body>
Laurent@1313:         <documentation>
Laurent@1313:           <xhtml:p><![CDATA[The up-counter can be used to signal when a count has reached a maximum value.]]></xhtml:p>
Laurent@1313:         </documentation>
Laurent@1313:       </pou>
Laurent@1313:       <pou name="CTU_UDINT" pouType="functionBlock">
Laurent@1313:         <interface>
Laurent@1313:           <inputVars>
Laurent@1313:             <variable name="CU">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="R">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="PV">
Laurent@1313:               <type>
Laurent@1313:                 <UDINT/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </inputVars>
Laurent@1313:           <outputVars>
Laurent@1313:             <variable name="Q">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="CV">
Laurent@1313:               <type>
Laurent@1313:                 <UDINT/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </outputVars>
Laurent@1313:           <localVars>
Laurent@1313:             <variable name="CU_T">
Laurent@1313:               <type>
Laurent@1313:                 <derived name="R_TRIG"/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </localVars>
Laurent@1313:         </interface>
Laurent@1313:         <body>
Laurent@1313:           <ST>
Laurent@1313:             <xhtml:p><![CDATA[CU_T(CU);
Laurent@1313: IF R THEN CV := 0;
Laurent@1313: ELSIF CU_T.Q AND (CV < PV)
Laurent@1313:   THEN CV := CV+1;
Laurent@1313: END_IF;
Laurent@1313: Q := (CV >= PV);]]></xhtml:p>
Laurent@1313:           </ST>
Laurent@1313:         </body>
Laurent@1313:         <documentation>
Laurent@1313:           <xhtml:p><![CDATA[The up-counter can be used to signal when a count has reached a maximum value.]]></xhtml:p>
Laurent@1313:         </documentation>
Laurent@1313:       </pou>
Laurent@1313:       <pou name="CTU_ULINT" pouType="functionBlock">
Laurent@1313:         <interface>
Laurent@1313:           <inputVars>
Laurent@1313:             <variable name="CU">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="R">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="PV">
Laurent@1313:               <type>
Laurent@1313:                 <ULINT/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </inputVars>
Laurent@1313:           <outputVars>
Laurent@1313:             <variable name="Q">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="CV">
Laurent@1313:               <type>
Laurent@1313:                 <ULINT/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </outputVars>
Laurent@1313:           <localVars>
Laurent@1313:             <variable name="CU_T">
Laurent@1313:               <type>
Laurent@1313:                 <derived name="R_TRIG"/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </localVars>
Laurent@1313:         </interface>
Laurent@1313:         <body>
Laurent@1313:           <ST>
Laurent@1313:             <xhtml:p><![CDATA[CU_T(CU);
Laurent@1313: IF R THEN CV := 0;
Laurent@1313: ELSIF CU_T.Q AND (CV < PV)
Laurent@1313:   THEN CV := CV+1;
Laurent@1313: END_IF;
Laurent@1313: Q := (CV >= PV);]]></xhtml:p>
Laurent@1313:           </ST>
Laurent@1313:         </body>
Laurent@1313:         <documentation>
Laurent@1313:           <xhtml:p><![CDATA[The up-counter can be used to signal when a count has reached a maximum value.]]></xhtml:p>
Laurent@1313:         </documentation>
Laurent@1313:       </pou>
Laurent@1313:       <pou name="CTD" pouType="functionBlock">
Laurent@1313:         <interface>
Laurent@1313:           <inputVars>
Laurent@1313:             <variable name="CD">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="LD">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="PV">
Laurent@1313:               <type>
Laurent@1313:                 <INT/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </inputVars>
Laurent@1313:           <outputVars>
Laurent@1313:             <variable name="Q">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="CV">
Laurent@1313:               <type>
Laurent@1313:                 <INT/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </outputVars>
Laurent@1313:           <localVars>
Laurent@1313:             <variable name="CD_T">
Laurent@1313:               <type>
Laurent@1313:                 <derived name="R_TRIG"/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </localVars>
Laurent@1313:         </interface>
Laurent@1313:         <body>
Laurent@1313:           <ST>
Laurent@1313:             <xhtml:p><![CDATA[CD_T(CD);
Laurent@1313: IF LD THEN CV := PV;
Laurent@1313: ELSIF CD_T.Q AND (CV > 0)
Laurent@1313:   THEN CV := CV-1;
Laurent@1313: END_IF;
Laurent@1313: Q := (CV <= 0);]]></xhtml:p>
Laurent@1313:           </ST>
Laurent@1313:         </body>
Laurent@1313:         <documentation>
Laurent@1313:           <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>
Laurent@1313:         </documentation>
Laurent@1313:       </pou>
Laurent@1313:       <pou name="CTD_DINT" pouType="functionBlock">
Laurent@1313:         <interface>
Laurent@1313:           <inputVars>
Laurent@1313:             <variable name="CD">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="LD">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="PV">
Laurent@1313:               <type>
Laurent@1313:                 <DINT/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </inputVars>
Laurent@1313:           <outputVars>
Laurent@1313:             <variable name="Q">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="CV">
Laurent@1313:               <type>
Laurent@1313:                 <DINT/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </outputVars>
Laurent@1313:           <localVars>
Laurent@1313:             <variable name="CD_T">
Laurent@1313:               <type>
Laurent@1313:                 <derived name="R_TRIG"/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </localVars>
Laurent@1313:         </interface>
Laurent@1313:         <body>
Laurent@1313:           <ST>
Laurent@1313:             <xhtml:p><![CDATA[CD_T(CD);
Laurent@1313: IF LD THEN CV := PV;
Laurent@1313: ELSIF CD_T.Q AND (CV > 0)
Laurent@1313:   THEN CV := CV-1;
Laurent@1313: END_IF;
Laurent@1313: Q := (CV <= 0);]]></xhtml:p>
Laurent@1313:           </ST>
Laurent@1313:         </body>
Laurent@1313:         <documentation>
Laurent@1313:           <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>
Laurent@1313:         </documentation>
Laurent@1313:       </pou>
Laurent@1313:       <pou name="CTD_LINT" pouType="functionBlock">
Laurent@1313:         <interface>
Laurent@1313:           <inputVars>
Laurent@1313:             <variable name="CD">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="LD">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="PV">
Laurent@1313:               <type>
Laurent@1313:                 <LINT/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </inputVars>
Laurent@1313:           <outputVars>
Laurent@1313:             <variable name="Q">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="CV">
Laurent@1313:               <type>
Laurent@1313:                 <LINT/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </outputVars>
Laurent@1313:           <localVars>
Laurent@1313:             <variable name="CD_T">
Laurent@1313:               <type>
Laurent@1313:                 <derived name="R_TRIG"/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </localVars>
Laurent@1313:         </interface>
Laurent@1313:         <body>
Laurent@1313:           <ST>
Laurent@1313:             <xhtml:p><![CDATA[CD_T(CD);
Laurent@1313: IF LD THEN CV := PV;
Laurent@1313: ELSIF CD_T.Q AND (CV > 0)
Laurent@1313:   THEN CV := CV-1;
Laurent@1313: END_IF;
Laurent@1313: Q := (CV <= 0);]]></xhtml:p>
Laurent@1313:           </ST>
Laurent@1313:         </body>
Laurent@1313:         <documentation>
Laurent@1313:           <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>
Laurent@1313:         </documentation>
Laurent@1313:       </pou>
Laurent@1313:       <pou name="CTD_UDINT" pouType="functionBlock">
Laurent@1313:         <interface>
Laurent@1313:           <inputVars>
Laurent@1313:             <variable name="CD">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="LD">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="PV">
Laurent@1313:               <type>
Laurent@1313:                 <UDINT/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </inputVars>
Laurent@1313:           <outputVars>
Laurent@1313:             <variable name="Q">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="CV">
Laurent@1313:               <type>
Laurent@1313:                 <UDINT/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </outputVars>
Laurent@1313:           <localVars>
Laurent@1313:             <variable name="CD_T">
Laurent@1313:               <type>
Laurent@1313:                 <derived name="R_TRIG"/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </localVars>
Laurent@1313:         </interface>
Laurent@1313:         <body>
Laurent@1313:           <ST>
Laurent@1313:             <xhtml:p><![CDATA[CD_T(CD);
Laurent@1313: IF LD THEN CV := PV;
Laurent@1313: ELSIF CD_T.Q AND (CV > 0)
Laurent@1313:   THEN CV := CV-1;
Laurent@1313: END_IF;
Laurent@1313: Q := (CV <= 0);]]></xhtml:p>
Laurent@1313:           </ST>
Laurent@1313:         </body>
Laurent@1313:         <documentation>
Laurent@1313:           <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>
Laurent@1313:         </documentation>
Laurent@1313:       </pou>
Laurent@1313:       <pou name="CTD_ULINT" pouType="functionBlock">
Laurent@1313:         <interface>
Laurent@1313:           <inputVars>
Laurent@1313:             <variable name="CD">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="LD">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="PV">
Laurent@1313:               <type>
Laurent@1313:                 <ULINT/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </inputVars>
Laurent@1313:           <outputVars>
Laurent@1313:             <variable name="Q">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="CV">
Laurent@1313:               <type>
Laurent@1313:                 <ULINT/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </outputVars>
Laurent@1313:           <localVars>
Laurent@1313:             <variable name="CD_T">
Laurent@1313:               <type>
Laurent@1313:                 <derived name="R_TRIG"/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </localVars>
Laurent@1313:         </interface>
Laurent@1313:         <body>
Laurent@1313:           <ST>
Laurent@1313:             <xhtml:p><![CDATA[CD_T(CD);
Laurent@1313: IF LD THEN CV := PV;
Laurent@1313: ELSIF CD_T.Q AND (CV > 0)
Laurent@1313:   THEN CV := CV-1;
Laurent@1313: END_IF;
Laurent@1313: Q := (CV <= 0);]]></xhtml:p>
Laurent@1313:           </ST>
Laurent@1313:         </body>
Laurent@1313:         <documentation>
Laurent@1313:           <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>
Laurent@1313:         </documentation>
Laurent@1313:       </pou>
Laurent@1313:       <pou name="CTUD" pouType="functionBlock">
Laurent@1313:         <interface>
Laurent@1313:           <inputVars>
Laurent@1313:             <variable name="CU">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="CD">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="R">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="LD">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="PV">
Laurent@1313:               <type>
Laurent@1313:                 <INT/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </inputVars>
Laurent@1313:           <outputVars>
Laurent@1313:             <variable name="QU">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="QD">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="CV">
Laurent@1313:               <type>
Laurent@1313:                 <INT/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="CD_T">
Laurent@1313:               <type>
Laurent@1313:                 <derived name="R_TRIG"/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="CU_T">
Laurent@1313:               <type>
Laurent@1313:                 <derived name="R_TRIG"/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </outputVars>
Laurent@1313:         </interface>
Laurent@1313:         <body>
Laurent@1313:           <ST>
Laurent@1313:             <xhtml:p><![CDATA[CD_T(CD);
Laurent@1313: CU_T(CU);
Laurent@1313: IF R THEN CV := 0;
Laurent@1313: ELSIF LD THEN CV := PV;
Laurent@1313: ELSE
Laurent@1313:   IF NOT (CU_T.Q AND CD_T.Q) THEN
Laurent@1313:     IF CU_T.Q AND (CV < PV)
Laurent@1313:     THEN CV := CV+1;
Laurent@1313:     ELSIF CD_T.Q AND (CV > 0)
Laurent@1313:     THEN CV := CV-1;
Laurent@1313:     END_IF;
Laurent@1313:   END_IF;
Laurent@1313: END_IF;
Laurent@1313: QU := (CV >= PV);
Laurent@1313: QD := (CV <= 0);]]></xhtml:p>
Laurent@1313:           </ST>
Laurent@1313:         </body>
Laurent@1313:         <documentation>
Laurent@1313:           <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>
Laurent@1313:         </documentation>
Laurent@1313:       </pou>
Laurent@1313:       <pou name="CTUD_DINT" pouType="functionBlock">
Laurent@1313:         <interface>
Laurent@1313:           <inputVars>
Laurent@1313:             <variable name="CU">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="CD">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="R">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="LD">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="PV">
Laurent@1313:               <type>
Laurent@1313:                 <DINT/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </inputVars>
Laurent@1313:           <outputVars>
Laurent@1313:             <variable name="QU">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="QD">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="CV">
Laurent@1313:               <type>
Laurent@1313:                 <DINT/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="CD_T">
Laurent@1313:               <type>
Laurent@1313:                 <derived name="R_TRIG"/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="CU_T">
Laurent@1313:               <type>
Laurent@1313:                 <derived name="R_TRIG"/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </outputVars>
Laurent@1313:         </interface>
Laurent@1313:         <body>
Laurent@1313:           <ST>
Laurent@1313:             <xhtml:p><![CDATA[CD_T(CD);
Laurent@1313: CU_T(CU);
Laurent@1313: IF R THEN CV := 0;
Laurent@1313: ELSIF LD THEN CV := PV;
Laurent@1313: ELSE
Laurent@1313:   IF NOT (CU_T.Q AND CD_T.Q) THEN
Laurent@1313:     IF CU_T.Q AND (CV < PV)
Laurent@1313:     THEN CV := CV+1;
Laurent@1313:     ELSIF CD_T.Q AND (CV > 0)
Laurent@1313:     THEN CV := CV-1;
Laurent@1313:     END_IF;
Laurent@1313:   END_IF;
Laurent@1313: END_IF;
Laurent@1313: QU := (CV >= PV);
Laurent@1313: QD := (CV <= 0);]]></xhtml:p>
Laurent@1313:           </ST>
Laurent@1313:         </body>
Laurent@1313:         <documentation>
Laurent@1313:           <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>
Laurent@1313:         </documentation>
Laurent@1313:       </pou>
Laurent@1313:       <pou name="CTUD_LINT" pouType="functionBlock">
Laurent@1313:         <interface>
Laurent@1313:           <inputVars>
Laurent@1313:             <variable name="CU">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="CD">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="R">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="LD">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="PV">
Laurent@1313:               <type>
Laurent@1313:                 <LINT/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </inputVars>
Laurent@1313:           <outputVars>
Laurent@1313:             <variable name="QU">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="QD">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="CV">
Laurent@1313:               <type>
Laurent@1313:                 <LINT/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="CD_T">
Laurent@1313:               <type>
Laurent@1313:                 <derived name="R_TRIG"/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="CU_T">
Laurent@1313:               <type>
Laurent@1313:                 <derived name="R_TRIG"/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </outputVars>
Laurent@1313:         </interface>
Laurent@1313:         <body>
Laurent@1313:           <ST>
Laurent@1313:             <xhtml:p><![CDATA[CD_T(CD);
Laurent@1313: CU_T(CU);
Laurent@1313: IF R THEN CV := 0;
Laurent@1313: ELSIF LD THEN CV := PV;
Laurent@1313: ELSE
Laurent@1313:   IF NOT (CU_T.Q AND CD_T.Q) THEN
Laurent@1313:     IF CU_T.Q AND (CV < PV)
Laurent@1313:     THEN CV := CV+1;
Laurent@1313:     ELSIF CD_T.Q AND (CV > 0)
Laurent@1313:     THEN CV := CV-1;
Laurent@1313:     END_IF;
Laurent@1313:   END_IF;
Laurent@1313: END_IF;
Laurent@1313: QU := (CV >= PV);
Laurent@1313: QD := (CV <= 0);]]></xhtml:p>
Laurent@1313:           </ST>
Laurent@1313:         </body>
Laurent@1313:         <documentation>
Laurent@1313:           <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>
Laurent@1313:         </documentation>
Laurent@1313:       </pou>
Laurent@1313:       <pou name="CTUD_UDINT" pouType="functionBlock">
Laurent@1313:         <interface>
Laurent@1313:           <inputVars>
Laurent@1313:             <variable name="CU">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="CD">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="R">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="LD">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="PV">
Laurent@1313:               <type>
Laurent@1313:                 <UDINT/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </inputVars>
Laurent@1313:           <outputVars>
Laurent@1313:             <variable name="QU">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="QD">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="CV">
Laurent@1313:               <type>
Laurent@1313:                 <UDINT/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="CD_T">
Laurent@1313:               <type>
Laurent@1313:                 <derived name="R_TRIG"/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="CU_T">
Laurent@1313:               <type>
Laurent@1313:                 <derived name="R_TRIG"/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </outputVars>
Laurent@1313:         </interface>
Laurent@1313:         <body>
Laurent@1313:           <ST>
Laurent@1313:             <xhtml:p><![CDATA[CD_T(CD);
Laurent@1313: CU_T(CU);
Laurent@1313: IF R THEN CV := 0;
Laurent@1313: ELSIF LD THEN CV := PV;
Laurent@1313: ELSE
Laurent@1313:   IF NOT (CU_T.Q AND CD_T.Q) THEN
Laurent@1313:     IF CU_T.Q AND (CV < PV)
Laurent@1313:     THEN CV := CV+1;
Laurent@1313:     ELSIF CD_T.Q AND (CV > 0)
Laurent@1313:     THEN CV := CV-1;
Laurent@1313:     END_IF;
Laurent@1313:   END_IF;
Laurent@1313: END_IF;
Laurent@1313: QU := (CV >= PV);
Laurent@1313: QD := (CV <= 0);]]></xhtml:p>
Laurent@1313:           </ST>
Laurent@1313:         </body>
Laurent@1313:         <documentation>
Laurent@1313:           <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>
Laurent@1313:         </documentation>
Laurent@1313:       </pou>
Laurent@1313:       <pou name="CTUD_ULINT" pouType="functionBlock">
Laurent@1313:         <interface>
Laurent@1313:           <inputVars>
Laurent@1313:             <variable name="CU">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="CD">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="R">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="LD">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="PV">
Laurent@1313:               <type>
Laurent@1313:                 <ULINT/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </inputVars>
Laurent@1313:           <outputVars>
Laurent@1313:             <variable name="QU">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="QD">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="CV">
Laurent@1313:               <type>
Laurent@1313:                 <ULINT/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="CD_T">
Laurent@1313:               <type>
Laurent@1313:                 <derived name="R_TRIG"/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="CU_T">
Laurent@1313:               <type>
Laurent@1313:                 <derived name="R_TRIG"/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </outputVars>
Laurent@1313:         </interface>
Laurent@1313:         <body>
Laurent@1313:           <ST>
Laurent@1313:             <xhtml:p><![CDATA[CD_T(CD);
Laurent@1313: CU_T(CU);
Laurent@1313: IF R THEN CV := 0;
Laurent@1313: ELSIF LD THEN CV := PV;
Laurent@1313: ELSE
Laurent@1313:   IF NOT (CU_T.Q AND CD_T.Q) THEN
Laurent@1313:     IF CU_T.Q AND (CV < PV)
Laurent@1313:     THEN CV := CV+1;
Laurent@1313:     ELSIF CD_T.Q AND (CV > 0)
Laurent@1313:     THEN CV := CV-1;
Laurent@1313:     END_IF;
Laurent@1313:   END_IF;
Laurent@1313: END_IF;
Laurent@1313: QU := (CV >= PV);
Laurent@1313: QD := (CV <= 0);]]></xhtml:p>
Laurent@1313:           </ST>
Laurent@1313:         </body>
Laurent@1313:         <documentation>
Laurent@1313:           <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>
Laurent@1313:         </documentation>
Laurent@1313:       </pou>
Laurent@1313:       <pou name="TP" pouType="functionBlock">
Laurent@1313:         <interface>
Laurent@1313:           <inputVars>
Laurent@1313:             <variable name="IN">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:               <documentation>
Laurent@1313:                 <xhtml:p><![CDATA[first input parameter]]></xhtml:p>
Laurent@1313:               </documentation>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="PT">
Laurent@1313:               <type>
Laurent@1313:                 <TIME/>
Laurent@1313:               </type>
Laurent@1313:               <documentation>
Laurent@1313:                 <xhtml:p><![CDATA[second input parameter]]></xhtml:p>
Laurent@1313:               </documentation>
Laurent@1313:             </variable>
Laurent@1313:           </inputVars>
Laurent@1313:           <outputVars>
Laurent@1313:             <variable name="Q">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:               <initialValue>
Laurent@1313:                 <simpleValue value="FALSE"/>
Laurent@1313:               </initialValue>
Laurent@1313:               <documentation>
Laurent@1313:                 <xhtml:p><![CDATA[first output parameter]]></xhtml:p>
Laurent@1313:               </documentation>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="ET">
Laurent@1313:               <type>
Laurent@1313:                 <TIME/>
Laurent@1313:               </type>
Laurent@1313:               <initialValue>
Laurent@1313:                 <simpleValue value="T#0s"/>
Laurent@1313:               </initialValue>
Laurent@1313:               <documentation>
Laurent@1313:                 <xhtml:p><![CDATA[second output parameter]]></xhtml:p>
Laurent@1313:               </documentation>
Laurent@1313:             </variable>
Laurent@1313:           </outputVars>
Laurent@1313:           <localVars>
Laurent@1313:             <variable name="STATE">
Laurent@1313:               <type>
Laurent@1313:                 <SINT/>
Laurent@1313:               </type>
Laurent@1313:               <initialValue>
Laurent@1313:                 <simpleValue value="0"/>
Laurent@1313:               </initialValue>
Laurent@1313:               <documentation>
Laurent@1313:                 <xhtml:p><![CDATA[internal state: 0-reset, 1-counting, 2-set]]></xhtml:p>
Laurent@1313:               </documentation>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="PREV_IN">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:               <initialValue>
Laurent@1313:                 <simpleValue value="FALSE"/>
Laurent@1313:               </initialValue>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="CURRENT_TIME">
Laurent@1313:               <type>
Laurent@1313:                 <TIME/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="START_TIME">
Laurent@1313:               <type>
Laurent@1313:                 <TIME/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </localVars>
Laurent@1313:         </interface>
Laurent@1313:         <body>
Laurent@1313:           <ST>
Edouard@1410:             <xhtml:p><![CDATA[{__SET_VAR(data__->,CURRENT_TIME,,__CURRENT_TIME)}
Laurent@1313: 
Laurent@1313: IF ((STATE = 0) AND NOT(PREV_IN) AND IN)   (* found rising edge on IN *)
Laurent@1313: THEN
Laurent@1313:   (* start timer... *)
Laurent@1313:   STATE := 1;
Laurent@1313:   Q := TRUE;
Laurent@1313:   START_TIME := CURRENT_TIME;
Laurent@1313: 
Laurent@1313: ELSIF (STATE = 1)
Laurent@1313: THEN
Laurent@1313:   IF ((START_TIME + PT) <= CURRENT_TIME)
Laurent@1313:   THEN
Laurent@1313:     STATE := 2;
Laurent@1313:     Q := FALSE;
Laurent@1313:     ET := PT;
Laurent@1313:   ELSE
Laurent@1313:     ET := CURRENT_TIME - START_TIME;
Laurent@1313:   END_IF;
Laurent@1313: END_IF;
Laurent@1313: 
Laurent@1313: IF ((STATE = 2) AND NOT(IN))
Laurent@1313: THEN
Laurent@1313:   ET := T#0s;
Laurent@1313:   STATE := 0;
Laurent@1313: END_IF;
Laurent@1313: 
Laurent@1313: PREV_IN := IN;
Laurent@1313: ]]></xhtml:p>
Laurent@1313:           </ST>
Laurent@1313:         </body>
Laurent@1313:         <documentation>
Laurent@1313:           <xhtml:p><![CDATA[The pulse timer can be used to generate output pulses of a given time duration.]]></xhtml:p>
Laurent@1313:         </documentation>
Laurent@1313:       </pou>
Laurent@1313:       <pou name="TON" pouType="functionBlock">
Laurent@1313:         <interface>
Laurent@1313:           <inputVars>
Laurent@1313:             <variable name="IN">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:               <documentation>
Laurent@1313:                 <xhtml:p><![CDATA[first input parameter]]></xhtml:p>
Laurent@1313:               </documentation>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="PT">
Laurent@1313:               <type>
Laurent@1313:                 <TIME/>
Laurent@1313:               </type>
Laurent@1313:               <documentation>
Laurent@1313:                 <xhtml:p><![CDATA[second input parameter]]></xhtml:p>
Laurent@1313:               </documentation>
Laurent@1313:             </variable>
Laurent@1313:           </inputVars>
Laurent@1313:           <outputVars>
Laurent@1313:             <variable name="Q">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:               <initialValue>
Laurent@1313:                 <simpleValue value="FALSE"/>
Laurent@1313:               </initialValue>
Laurent@1313:               <documentation>
Laurent@1313:                 <xhtml:p><![CDATA[first output parameter]]></xhtml:p>
Laurent@1313:               </documentation>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="ET">
Laurent@1313:               <type>
Laurent@1313:                 <TIME/>
Laurent@1313:               </type>
Laurent@1313:               <initialValue>
Laurent@1313:                 <simpleValue value="T#0s"/>
Laurent@1313:               </initialValue>
Laurent@1313:               <documentation>
Laurent@1313:                 <xhtml:p><![CDATA[second output parameter]]></xhtml:p>
Laurent@1313:               </documentation>
Laurent@1313:             </variable>
Laurent@1313:           </outputVars>
Laurent@1313:           <localVars>
Laurent@1313:             <variable name="STATE">
Laurent@1313:               <type>
Laurent@1313:                 <SINT/>
Laurent@1313:               </type>
Laurent@1313:               <initialValue>
Laurent@1313:                 <simpleValue value="0"/>
Laurent@1313:               </initialValue>
Laurent@1313:               <documentation>
Laurent@1313:                 <xhtml:p><![CDATA[internal state: 0-reset, 1-counting, 2-set]]></xhtml:p>
Laurent@1313:               </documentation>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="PREV_IN">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:               <initialValue>
Laurent@1313:                 <simpleValue value="FALSE"/>
Laurent@1313:               </initialValue>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="CURRENT_TIME">
Laurent@1313:               <type>
Laurent@1313:                 <TIME/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="START_TIME">
Laurent@1313:               <type>
Laurent@1313:                 <TIME/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </localVars>
Laurent@1313:         </interface>
Laurent@1313:         <body>
Laurent@1313:           <ST>
Edouard@1410:             <xhtml:p><![CDATA[{__SET_VAR(data__->,CURRENT_TIME,,__CURRENT_TIME)}
Laurent@1313: 
Laurent@1313: IF ((STATE = 0) AND NOT(PREV_IN) AND IN)   (* found rising edge on IN *)
Laurent@1313: THEN
Laurent@1313:   (* start timer... *)
Laurent@1313:   STATE := 1;
Laurent@1313:   Q := FALSE;
Laurent@1313:   START_TIME := CURRENT_TIME;
Laurent@1313: 
Laurent@1313: ELSE
Laurent@1313:   (* STATE is 1 or 2 !! *)
Laurent@1313:   IF (NOT(IN))
Laurent@1313:   THEN
Laurent@1313:     ET := T#0s;
Laurent@1313:     Q := FALSE;
Laurent@1313:     STATE := 0;
Laurent@1313: 
Laurent@1313:   ELSIF (STATE = 1)
Laurent@1313:   THEN
Laurent@1313:     IF ((START_TIME + PT) <= CURRENT_TIME)
Laurent@1313:     THEN
Laurent@1313:       STATE := 2;
Laurent@1313:       Q := TRUE;
Laurent@1313:       ET := PT;
Laurent@1313:     ELSE
Laurent@1313:       ET := CURRENT_TIME - START_TIME;
Laurent@1313:     END_IF;
Laurent@1313:   END_IF;
Laurent@1313: 
Laurent@1313: END_IF;
Laurent@1313: 
Laurent@1313: PREV_IN := IN;
Laurent@1313: ]]></xhtml:p>
Laurent@1313:           </ST>
Laurent@1313:         </body>
Laurent@1313:         <documentation>
Laurent@1313:           <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>
Laurent@1313:         </documentation>
Laurent@1313:       </pou>
Laurent@1313:       <pou name="TOF" pouType="functionBlock">
Laurent@1313:         <interface>
Laurent@1313:           <inputVars>
Laurent@1313:             <variable name="IN">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:               <documentation>
Laurent@1313:                 <xhtml:p><![CDATA[first input parameter]]></xhtml:p>
Laurent@1313:               </documentation>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="PT">
Laurent@1313:               <type>
Laurent@1313:                 <TIME/>
Laurent@1313:               </type>
Laurent@1313:               <documentation>
Laurent@1313:                 <xhtml:p><![CDATA[second input parameter]]></xhtml:p>
Laurent@1313:               </documentation>
Laurent@1313:             </variable>
Laurent@1313:           </inputVars>
Laurent@1313:           <outputVars>
Laurent@1313:             <variable name="Q">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:               <initialValue>
Laurent@1313:                 <simpleValue value="FALSE"/>
Laurent@1313:               </initialValue>
Laurent@1313:               <documentation>
Laurent@1313:                 <xhtml:p><![CDATA[first output parameter]]></xhtml:p>
Laurent@1313:               </documentation>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="ET">
Laurent@1313:               <type>
Laurent@1313:                 <TIME/>
Laurent@1313:               </type>
Laurent@1313:               <initialValue>
Laurent@1313:                 <simpleValue value="T#0s"/>
Laurent@1313:               </initialValue>
Laurent@1313:               <documentation>
Laurent@1313:                 <xhtml:p><![CDATA[second output parameter]]></xhtml:p>
Laurent@1313:               </documentation>
Laurent@1313:             </variable>
Laurent@1313:           </outputVars>
Laurent@1313:           <localVars>
Laurent@1313:             <variable name="STATE">
Laurent@1313:               <type>
Laurent@1313:                 <SINT/>
Laurent@1313:               </type>
Laurent@1313:               <initialValue>
Laurent@1313:                 <simpleValue value="0"/>
Laurent@1313:               </initialValue>
Laurent@1313:               <documentation>
Laurent@1313:                 <xhtml:p><![CDATA[internal state: 0-reset, 1-counting, 2-set]]></xhtml:p>
Laurent@1313:               </documentation>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="PREV_IN">
Laurent@1313:               <type>
Laurent@1313:                 <BOOL/>
Laurent@1313:               </type>
Laurent@1313:               <initialValue>
Laurent@1313:                 <simpleValue value="FALSE"/>
Laurent@1313:               </initialValue>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="CURRENT_TIME">
Laurent@1313:               <type>
Laurent@1313:                 <TIME/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:             <variable name="START_TIME">
Laurent@1313:               <type>
Laurent@1313:                 <TIME/>
Laurent@1313:               </type>
Laurent@1313:             </variable>
Laurent@1313:           </localVars>
Laurent@1313:         </interface>
Laurent@1313:         <body>
Laurent@1313:           <ST>
Edouard@1410:             <xhtml:p><![CDATA[{__SET_VAR(data__->,CURRENT_TIME,,__CURRENT_TIME)}
Laurent@1313: 
Laurent@1313: IF ((STATE = 0) AND PREV_IN AND NOT(IN))   (* found falling edge on IN *)
Laurent@1313: THEN
Laurent@1313:   (* start timer... *)
Laurent@1313:   STATE := 1;
Laurent@1313:   START_TIME := CURRENT_TIME;
Laurent@1313: 
Laurent@1313: ELSE
Laurent@1313:   (* STATE is 1 or 2 !! *)
Laurent@1313:   IF (IN)
Laurent@1313:   THEN
Laurent@1313:     ET := T#0s;
Laurent@1313:     STATE := 0;
Laurent@1313: 
Laurent@1313:   ELSIF (STATE = 1)
Laurent@1313:   THEN
Laurent@1313:     IF ((START_TIME + PT) <= CURRENT_TIME)
Laurent@1313:     THEN
Laurent@1313:       STATE := 2;
Laurent@1313:       ET := PT;
Laurent@1313:     ELSE
Laurent@1313:       ET := CURRENT_TIME - START_TIME;
Laurent@1313:     END_IF;
Laurent@1313:   END_IF;
Laurent@1313: 
Laurent@1313: END_IF;
Laurent@1313: 
Laurent@1313: Q := IN OR (STATE = 1);
Laurent@1313: PREV_IN := IN;
Laurent@1313: ]]></xhtml:p>
Laurent@1313:           </ST>
Laurent@1313:         </body>
Laurent@1313:         <documentation>
Laurent@1313:           <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>
Laurent@1313:         </documentation>
Laurent@1313:       </pou>
Laurent@1313:     </pous>
Laurent@1313:   </types>
Laurent@1313:   <instances>
Laurent@1313:     <configurations/>
Laurent@1313:   </instances>
Laurent@1313: </project>