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