Bergvärme
Detaljer
- Typ
- Program
- Upplaggd av
- Ove Jansson, Abelko Innovation
- Version
- 3
- Uppdaterad
- 2013-09-03
- Skapad
- 2013-08-28
- Kategori
- Allmän automation, Värme
- Visningar
- 3460
Beskrivning
Responsmätning?
Bruksanvisning
Se kommentarerna i skriptet
Juridisk information
Alla skript tillhandahålls i befintligt skick och all användning sker på eget ansvar. Felaktig använding kan leda till skadad eller förstörd utrustning.
Skript kod
ROUTINE PIDCTRL_3
ALIAS
input = CHANNEL[149];
y = CHANNEL[150];
out = CHANNEL[151];
Ivalue = CHANNEL[152];
Dvalue = CHANNEL[153];
yold = CHANNEL[154];
cError = CHANNEL[155];
K = PARAMETER[4];
Ti = PARAMETER[5];
Td = PARAMETER[6];
Tt = PARAMETER[7];
active = CHANNEL[148];
filterCoef = PARAMETER[8];
user_sv = PARAMETER[2]; %Önskatflöde
man_auto = PARAMETER[3]; %Man/Auto
pump_user = PARAMETER[9]; %
patron_user = PARAMETER[12]; %Patronstatus vid manuell drift
current_flow = CHANNEL[69]; %Volymflöde
pump = CHANNEL[25]; %Tryckstyrning pump
patron = CHANNEL[33]; %Elpatron
run = PARAMETER[1]; %Kör processen
patron_start_err = PARAMETER[10]; %Reglerfel för patron start
patron_start_time = PARAMETER[11]; %Tid patron start
VAR
P;
uc;
h;
v;
firstRun;
yFilt; yFiltPrev; N; b; ulow; uhigh; cnt;
patron_cnt;
BEGIN
input <- user_sv;
% convert m3/h to l/s
y <- (current_flow*1000)/3600;
IF run = 1 THEN
% set some constants
N:=10; b:=1; ulow:=0; uhigh:=100;
% Set sample time, this is dependat of how often the
% Kamstrupmeater can be read. 10 s is the fastest.
h := 20;
IF firstRun = 0 THEN
yFilt := y;
ELSE
yFilt := filterCoef * yFiltPrev + (1-filterCoef) * y;
ENDIF;
yFiltPrev := yFilt;
IF man_auto = 1 THEN
IF cnt >= h THEN
IF active > 0 THEN
uc := input;
P := K * ( b * uc - yFilt );
IF (Td > 0) AND (N > 0) THEN
Dvalue <- ( Td/(Td+N*h) ) * Dvalue - ( K*N*Td/(Td+N*h) ) * (yFilt - yold);
ELSE
Dvalue <- 0;
ENDIF;
v := P + Ivalue + Dvalue;
IF v < ulow THEN
out <- ulow;
ELSIF v > uhigh THEN
out <- uhigh;
ELSE
out <- v;
ENDIF;
IF (Ti > 0) AND (Tt > 0) THEN
Ivalue <- Ivalue + ( K*h/Ti ) * ( uc - yFilt ) + ( h/Tt ) * ( out - v );
ELSIF (Ti > 0) AND (Tt <= 0) THEN
Ivalue <- Ivalue + ( K*h/Ti ) * ( uc - yFilt );
ELSE
Ivalue <- 0;
ENDIF;
yold <- yFilt;
cError <- yFilt - uc;
IF ABS(cError) < patron_start_err THEN
patron_cnt := patron_cnt + h;
ELSE
patron_cnt := 0;
ENDIF;
IF patron_cnt > patron_start_time THEN
patron <- 1;
ENDIF;
ELSE
out <- 0; Ivalue <- 0; Dvalue <- 0; yold <- 0; cError <- 0;
patron_cnt := 0;
ENDIF;
cnt := 0;
ENDIF;
IF firstRun = 0 THEN
firstRun := 1;
ENDIF;
cnt := cnt+1;
pump <- out;
ELSE
out <- 0; Ivalue <- 0; Dvalue <- 0; yold <- 0; cError <- 0;
pump <- pump_user;
patron <- patron_user;
patron_cnt := 0;
ENDIF;
ELSE
out <- 0; Ivalue <- 0; Dvalue <- 0; yold <- 0; cError <- 0;
pump <- 0;
patron <- 0;
patron_cnt := 0;
ENDIF;
END;
ALIAS
input = CHANNEL[149];
y = CHANNEL[150];
out = CHANNEL[151];
Ivalue = CHANNEL[152];
Dvalue = CHANNEL[153];
yold = CHANNEL[154];
cError = CHANNEL[155];
K = PARAMETER[4];
Ti = PARAMETER[5];
Td = PARAMETER[6];
Tt = PARAMETER[7];
active = CHANNEL[148];
filterCoef = PARAMETER[8];
user_sv = PARAMETER[2]; %Önskatflöde
man_auto = PARAMETER[3]; %Man/Auto
pump_user = PARAMETER[9]; %
patron_user = PARAMETER[12]; %Patronstatus vid manuell drift
current_flow = CHANNEL[69]; %Volymflöde
pump = CHANNEL[25]; %Tryckstyrning pump
patron = CHANNEL[33]; %Elpatron
run = PARAMETER[1]; %Kör processen
patron_start_err = PARAMETER[10]; %Reglerfel för patron start
patron_start_time = PARAMETER[11]; %Tid patron start
VAR
P;
uc;
h;
v;
firstRun;
yFilt; yFiltPrev; N; b; ulow; uhigh; cnt;
patron_cnt;
BEGIN
input <- user_sv;
% convert m3/h to l/s
y <- (current_flow*1000)/3600;
IF run = 1 THEN
% set some constants
N:=10; b:=1; ulow:=0; uhigh:=100;
% Set sample time, this is dependat of how often the
% Kamstrupmeater can be read. 10 s is the fastest.
h := 20;
IF firstRun = 0 THEN
yFilt := y;
ELSE
yFilt := filterCoef * yFiltPrev + (1-filterCoef) * y;
ENDIF;
yFiltPrev := yFilt;
IF man_auto = 1 THEN
IF cnt >= h THEN
IF active > 0 THEN
uc := input;
P := K * ( b * uc - yFilt );
IF (Td > 0) AND (N > 0) THEN
Dvalue <- ( Td/(Td+N*h) ) * Dvalue - ( K*N*Td/(Td+N*h) ) * (yFilt - yold);
ELSE
Dvalue <- 0;
ENDIF;
v := P + Ivalue + Dvalue;
IF v < ulow THEN
out <- ulow;
ELSIF v > uhigh THEN
out <- uhigh;
ELSE
out <- v;
ENDIF;
IF (Ti > 0) AND (Tt > 0) THEN
Ivalue <- Ivalue + ( K*h/Ti ) * ( uc - yFilt ) + ( h/Tt ) * ( out - v );
ELSIF (Ti > 0) AND (Tt <= 0) THEN
Ivalue <- Ivalue + ( K*h/Ti ) * ( uc - yFilt );
ELSE
Ivalue <- 0;
ENDIF;
yold <- yFilt;
cError <- yFilt - uc;
IF ABS(cError) < patron_start_err THEN
patron_cnt := patron_cnt + h;
ELSE
patron_cnt := 0;
ENDIF;
IF patron_cnt > patron_start_time THEN
patron <- 1;
ENDIF;
ELSE
out <- 0; Ivalue <- 0; Dvalue <- 0; yold <- 0; cError <- 0;
patron_cnt := 0;
ENDIF;
cnt := 0;
ENDIF;
IF firstRun = 0 THEN
firstRun := 1;
ENDIF;
cnt := cnt+1;
pump <- out;
ELSE
out <- 0; Ivalue <- 0; Dvalue <- 0; yold <- 0; cError <- 0;
pump <- pump_user;
patron <- patron_user;
patron_cnt := 0;
ENDIF;
ELSE
out <- 0; Ivalue <- 0; Dvalue <- 0; yold <- 0; cError <- 0;
pump <- 0;
patron <- 0;
patron_cnt := 0;
ENDIF;
END;
Användarnas noteringar
Du måste vara inloggad för att göra en notering. Bli medlem eller logga in. Vi använder en moderator som godkänner noteringarna innan de visas.