<?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="Additional Function Blocks Library" productVersion="1.0" creationDateTime="2013-09-09T09:56:11"/>
<contentHeader name="Standard Funtion Blocks" author="Laurent Bessard" modificationDateTime="2013-09-10T22:45:31">
<pou name="RTC" pouType="functionBlock">
<xhtml:p><![CDATA[0 - current time, 1 - load time from PDT]]></xhtml:p>
<xhtml:p><![CDATA[Preset datetime]]></xhtml:p>
<simpleValue value="FALSE"/>
<xhtml:p><![CDATA[Copy of IN]]></xhtml:p>
<xhtml:p><![CDATA[Datetime, current or relative to PDT]]></xhtml:p>
<variable name="PREV_IN">
<simpleValue value="FALSE"/>
<variable name="CURRENT_TIME">
<xhtml:p><![CDATA[{__SET_VAR(data__->,CURRENT_TIME,,__CURRENT_TIME)}
OFFSET := PDT - CURRENT_TIME;
(* PDT + time since PDT was loaded *)
CDT := CURRENT_TIME + OFFSET;
<xhtml:p><![CDATA[The real time clock has many uses including time stamping, setting dates and times of day in batch reports, in alarm messages and so on.]]></xhtml:p>
<pou name="INTEGRAL" pouType="functionBlock">
<xhtml:p><![CDATA[1 = integrate, 0 = hold]]></xhtml:p>
<xhtml:p><![CDATA[Overriding reset]]></xhtml:p>
<xhtml:p><![CDATA[Input variable]]></xhtml:p>
<xhtml:p><![CDATA[Initial value]]></xhtml:p>
<xhtml:p><![CDATA[Sampling period]]></xhtml:p>
<xhtml:p><![CDATA[NOT R1]]></xhtml:p>
<xhtml:p><![CDATA[Integrated output]]></xhtml:p>
<xhtml:p><![CDATA[Q := NOT R1 ;
ELSIF RUN THEN XOUT := XOUT + XIN * TIME_TO_REAL(CYCLE);
<xhtml:p><![CDATA[The integral function block integrates the value of input XIN over time.]]></xhtml:p>
<pou name="DERIVATIVE" pouType="functionBlock">
<xhtml:p><![CDATA[0 = reset]]></xhtml:p>
<xhtml:p><![CDATA[Input to be differentiated]]></xhtml:p>
<xhtml:p><![CDATA[Sampling period]]></xhtml:p>
<xhtml:p><![CDATA[Differentiated output]]></xhtml:p>
<xhtml:p><![CDATA[IF RUN THEN
XOUT := (3.0 * (XIN - X3) + X1 - X2)
/ (10.0 * TIME_TO_REAL(CYCLE));
<xhtml:p><![CDATA[The derivative function block produces an output XOUT proportional to the rate of change of the input XIN.]]></xhtml:p>
<pou name="PID" pouType="functionBlock">
<xhtml:p><![CDATA[0 - manual , 1 - automatic]]></xhtml:p>
<xhtml:p><![CDATA[Process variable]]></xhtml:p>
<xhtml:p><![CDATA[Set point]]></xhtml:p>
<xhtml:p><![CDATA[Manual output adjustment - Typically from transfer station]]></xhtml:p>
<xhtml:p><![CDATA[Proportionality constant]]></xhtml:p>
<xhtml:p><![CDATA[Reset time]]></xhtml:p>
<xhtml:p><![CDATA[Derivative time constant]]></xhtml:p>
<xhtml:p><![CDATA[Sampling period]]></xhtml:p>
<xhtml:p><![CDATA[PV - SP]]></xhtml:p>
<derived name="INTEGRAL"/>
<xhtml:p><![CDATA[FB for integral term]]></xhtml:p>
<derived name="DERIVATIVE"/>
<xhtml:p><![CDATA[FB for derivative term]]></xhtml:p>
<xhtml:p><![CDATA[ERROR := PV - SP ;
(*** Adjust ITERM so that XOUT := X0 when AUTO = 0 ***)
ITERM(RUN := AUTO, R1 := NOT AUTO, XIN := ERROR,
X0 := TR * (X0 - ERROR), CYCLE := CYCLE);
DTERM(RUN := AUTO, XIN := ERROR, CYCLE := CYCLE);
XOUT := KP * (ERROR + ITERM.XOUT/TR + DTERM.XOUT*TD);]]></xhtml:p>
<xhtml:p><![CDATA[The PID (proportional, Integral, Derivative) function block provides the classical three term controller for closed loop control.]]></xhtml:p>
<pou name="RAMP" pouType="functionBlock">
<xhtml:p><![CDATA[0 - track X0, 1 - ramp to/track X1]]></xhtml:p>
<xhtml:p><![CDATA[Ramp duration]]></xhtml:p>
<xhtml:p><![CDATA[Sampling period]]></xhtml:p>
<xhtml:p><![CDATA[BUSY = 1 during ramping period]]></xhtml:p>
<simpleValue value="0.0"/>
<xhtml:p><![CDATA[Initial value]]></xhtml:p>
<simpleValue value="T#0s"/>
<xhtml:p><![CDATA[Elapsed time of ramp]]></xhtml:p>
<xhtml:p><![CDATA[BUSY := RUN ;
ELSE XOUT := XI + (X1-XI) * TIME_TO_REAL(T)
<xhtml:p><![CDATA[The RAMP function block is modelled on example given in the standard.]]></xhtml:p>
<pou name="HYSTERESIS" pouType="functionBlock">
<xhtml:p><![CDATA[IF Q THEN
IF XIN1 < (XIN2 - EPS) THEN
ELSIF XIN1 > (XIN2 + EPS) THEN
<xhtml:p><![CDATA[The hysteresis function block provides a hysteresis boolean output driven by the difference of two floating point (REAL) inputs XIN1 and XIN2.]]></xhtml:p>