source: trunk/sample/controllers/sample_tanks_pid.mso @ 494

Last change on this file since 494 was 481, checked in by Rafael de Pelegrini Soares, 16 years ago

Fixed units of measurement in controller sample

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.2 KB
Line 
1#*-------------------------------------------------------------------
2* EMSO Model Library (EML) Copyright (C) 2004 - 2007 ALSOC.
3*
4* This LIBRARY is free software; you can distribute it and/or modify
5* it under the therms of the ALSOC FREE LICENSE as available at
6* http://www.enq.ufrgs.br/alsoc.
7*
8* EMSO Copyright (C) 2004 - 2007 ALSOC, original code
9* from http://www.rps.eng.br Copyright (C) 2002-2004.
10* All rights reserved.
11*
12* EMSO is distributed under the therms of the ALSOC LICENSE as
13* available at http://www.enq.ufrgs.br/alsoc.
14*
15*
16*-------------------------------------------------------------------
17* Sample file for tanks level control
18*
19*-------------------------------------------------------------------
20* Author: Tiago Osório
21* $Id: sample_tanks_pid.mso 481 2008-03-11 12:18:21Z rafael $
22*-----------------------------------------------------------------*#
23
24using "tanksmodel";
25using "controllers/PIDs";
26using "controllers/PIDIncr";
27
28
29FlowSheet Tanque_inc
30        DEVICES
31        Tanque1 as tank;
32        PIDc     as PIDIncr;
33       
34        PARAMETERS     
35        h_max as Real (Brief="Altura máxima do nível do tanque", Unit='m');
36        h_min as Real (Brief="Altura mínima do nível do tanque", Unit='m');
37
38    VARIABLES
39        h_ad  as Real (Brief="Altura adimensional do nível do tanque", Lower=0,Upper=1);
40
41        CONNECTIONS
42       
43        SET
44        Tanque1.A = 8 * 'm^2';
45        h_max = 2 * 'm';
46        h_min = 0 * 'm';
47        PIDc.PID_Select = "Ideal_AWBT";
48       
49        EQUATIONS
50        PIDc.Parameters.tau = 1*'s';   
51        PIDc.Parameters.tauSet = 1*'s';
52        PIDc.Parameters.alpha = 0.3;
53        PIDc.Parameters.bias = 0;       
54        PIDc.Parameters.gamma = 1;
55        PIDc.Parameters.beta = 1;
56        PIDc.Options.action = -1;
57        PIDc.Options.clip=1;
58        PIDc.Options.autoMan = 0;
59        PIDc.Parameters.intTime=5000*'s';
60        PIDc.Parameters.gain = 3.5;
61        PIDc.Parameters.derivTime=1*'s';
62        PIDc.Ports.input = h_ad;
63        h_ad = (Tanque1.h-h_min)/(h_max-h_min);
64        Tanque1.k = 8*'m^2.5/h'*PIDc.Ports.output;     
65
66        #Perturbação servo
67        #Nível desejado=1*'m'
68        PIDc.Ports.setPoint=0.5;
69
70        #Perturbação regulatória
71        if time<10*'h' then
72                Tanque1.Fin= 3*'m^3/h';
73        else
74                Tanque1.Fin= 1.5*'m^3/h';
75        end     
76       
77        INITIAL
78        "altura inicial"
79        Tanque1.h = 0.2 * 'm';
80       
81        OPTIONS
82        TimeStep = 0.1;
83        TimeEnd = 30;
84        TimeUnit = 'h';
85end
86
87FlowSheet Tanque
88        DEVICES
89        Tanque1 as tank;
90        PIDx     as PID;
91       
92        PARAMETERS     
93        h_max as Real (Brief="Altura máxima do nível do tanque", Unit='m');
94        h_min as Real (Brief="Altura mínima do nível do tanque", Unit='m');
95
96    VARIABLES
97        h_ad  as Real (Brief="Altura adimensional do nível do tanque", Lower=0,Upper=1);
98
99        CONNECTIONS
100       
101        SET
102        Tanque1.A = 8 * 'm^2';
103        h_max = 2 * 'm';
104        h_min = 0 * 'm';
105        PIDx.PID_Select = "Ideal_AWBT";
106       
107        EQUATIONS
108        PIDx.Parameters.tau = 1*'s';   
109    PIDx.Parameters.tauSet = 1*'s';     
110        PIDx.Parameters.alpha = 0.3;
111        PIDx.Parameters.bias = 0;
112        PIDx.Parameters.gamma = 1;
113        PIDx.Parameters.beta = 1;
114        PIDx.Parameters.intTime=5000*'s';
115        PIDx.Parameters.gain =3.5;
116        PIDx.Parameters.derivTime=1*'s';
117        PIDx.Options.action = -1;
118        PIDx.Options.clip=1;
119        PIDx.Options.autoMan = 0;
120        PIDx.Ports.input = h_ad;
121        h_ad = (Tanque1.h-h_min)/(h_max-h_min);
122        Tanque1.k = 8*'m^2.5/h'*PIDx.Ports.output;     
123
124        #Perturbação servo
125        #Nível desejado=1*'m'
126        PIDx.Ports.setPoint=0.5;
127
128        #Perturbação regulatória
129        if time<10*'h' then
130                Tanque1.Fin= 3*'m^3/h';
131        else
132                Tanque1.Fin= 1.5*'m^3/h';
133        end
134       
135        INITIAL
136        "altura inicial"
137        Tanque1.h = 0.2 * 'm';
138       
139        OPTIONS
140        TimeStep = 0.1;
141        TimeEnd = 30;
142        TimeUnit = 'h';
143end
144
145
146
Note: See TracBrowser for help on using the repository browser.