--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/derivative_st.txt Wed Jun 10 15:02:14 2009 +0200
@@ -0,0 +1,18 @@
+ FUNCTION_BLOCK DERIVATIVE
+ VAR_INPUT
+ RUN : BOOL ; (* 0 = reset *)
+ XIN : REAL ; (* Input to be differentiated *)
+ CYCLE : TIME ; (* Sampling period *)
+ END_VAR
+ VAR_OUTPUT
+ XOUT : REAL ; (* Differentiated output *)
+ END_VAR
+ VAR X1, X2, X3 : REAL ; END_VAR
+ IF RUN THEN
+ XOUT := (3.0 * (XIN - X3) + X1 - X2)
+ / (10.0 * TIME_TO_REAL(CYCLE)) ;
+ X3 := X2 ; X2 := X1 ; X1 := XIN ;
+ ELSE XOUT := 0.0; X1 := XIN ; X2 := XIN ; X3 := XIN ;
+ END_IF ;
+ END_FUNCTION_BLOCK
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/hysteresis_st.txt Wed Jun 10 15:02:14 2009 +0200
@@ -0,0 +1,10 @@
+FUNCTION_BLOCK HYSTERESIS
+ (* Boolean hysteresis on difference *)
+ (* of REAL inputs, XIN1 - XIN2 *)
+ VAR_INPUT XIN1, XIN2, EPS : REAL; END_VAR
+ VAR_OUTPUT Q : BOOL := 0; END_VAR
+ IF Q THEN IF XIN1 < (XIN2 - EPS) THEN Q := 0; END_IF ;
+ ELSIF XIN1 > (XIN2 + EPS) THEN Q := 1 ;
+ END_IF ;
+END_FUNCTION_BLOCK
+
--- a/lib/ieclib.txt Wed Jun 10 13:20:52 2009 +0200
+++ b/lib/ieclib.txt Wed Jun 10 15:02:14 2009 +0200
@@ -31,8 +31,8 @@
{#include "bistable.txt" }
{#include "counter.txt" }
{#include "timer.txt" }
-{#include "../AnnexF/derivative_st.txt"}
-{#include "../AnnexF/hysteresis_st.txt"}
-{#include "../AnnexF/integral_st.txt"}
-{#include "../AnnexF/pid_st.txt"}
-{#include "../AnnexF/ramp_st.txt"}
+{#include "derivative_st.txt" }
+{#include "hysteresis_st.txt" }
+{#include "integral_st.txt" }
+{#include "pid_st.txt" }
+{#include "ramp_st.txt" }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/integral_st.txt Wed Jun 10 15:02:14 2009 +0200
@@ -0,0 +1,18 @@
+ FUNCTION_BLOCK INTEGRAL
+ VAR_INPUT
+ RUN : BOOL ; (* 1 = integrate, 0 = hold *)
+ R1 : BOOL ; (* Overriding reset *)
+ XIN : REAL ; (* Input variable *)
+ X0 : REAL ; (* Initial value *)
+ CYCLE : TIME ; (* Sampling period *)
+ END_VAR
+ VAR_OUTPUT
+ Q : BOOL ; (* NOT R1 *)
+ XOUT : REAL ; (* Integrated output *)
+ END_VAR
+ Q := NOT R1 ;
+ IF R1 THEN XOUT := X0 ;
+ ELSIF RUN THEN XOUT := XOUT + XIN * TIME_TO_REAL(CYCLE);
+ END_IF ;
+ END_FUNCTION_BLOCK
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/pid_st.txt Wed Jun 10 15:02:14 2009 +0200
@@ -0,0 +1,25 @@
+ FUNCTION_BLOCK PID
+ VAR_INPUT
+ AUTO : BOOL ; (* 0 - manual , 1 - automatic *)
+ PV : REAL ; (* Process variable *)
+ SP : REAL ; (* Set point *)
+ X0 : REAL ; (* Manual output adjustment - *)
+ (* Typically from transfer station *)
+ KP : REAL ; (* Proportionality constant *)
+ TR : REAL ; (* Reset time *)
+ TD : REAL ; (* Derivative time constant *)
+ CYCLE : TIME ; (* Sampling period *)
+ END_VAR
+ VAR_OUTPUT XOUT : REAL; END_VAR
+ VAR ERROR : REAL ; (* PV - SP *)
+ ITERM : INTEGRAL ; (* FB for integral term *)
+ DTERM : DERIVATIVE ; (* FB for derivative term *)
+ END_VAR
+ 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) ;
+ END_FUNCTION_BLOCK
+