[84] | 1 | #*------------------------------------------------------------------- |
---|
| 2 | * EMSO Model Library (EML) Copyright (C) 2004 - 2007 ALSOC. |
---|
[1] | 3 | * |
---|
[84] | 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. |
---|
[1] | 7 | * |
---|
[84] | 8 | * EMSO Copyright (C) 2004 - 2007 ALSOC, original code |
---|
| 9 | * from http://www.rps.eng.br Copyright (C) 2002-2004. |
---|
| 10 | * All rights reserved. |
---|
[1] | 11 | * |
---|
[84] | 12 | * EMSO is distributed under the therms of the ALSOC LICENSE as |
---|
| 13 | * available at http://www.enq.ufrgs.br/alsoc. |
---|
[1] | 14 | * |
---|
[84] | 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 | *-----------------------------------------------------------------*# |
---|
[1] | 23 | |
---|
| 24 | using "tanksmodel"; |
---|
[7] | 25 | using "controllers/PIDs"; |
---|
[1] | 26 | using "controllers/PIDIncr"; |
---|
| 27 | |
---|
| 28 | |
---|
| 29 | FlowSheet Tanque_inc |
---|
| 30 | DEVICES |
---|
| 31 | Tanque1 as tank; |
---|
[295] | 32 | PIDc as PIDIncr; |
---|
[1] | 33 | |
---|
| 34 | PARAMETERS |
---|
[190] | 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'); |
---|
[1] | 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 |
---|
[190] | 44 | Tanque1.A = 8 * 'm^2'; |
---|
| 45 | h_max = 2 * 'm'; |
---|
| 46 | h_min = 0 * 'm'; |
---|
[295] | 47 | PIDc.PID_Select = "Ideal_AWBT"; |
---|
[294] | 48 | |
---|
[1] | 49 | EQUATIONS |
---|
[295] | 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; |
---|
[1] | 63 | h_ad = (Tanque1.h-h_min)/(h_max-h_min); |
---|
[295] | 64 | Tanque1.k = 8*'m^2.5/h'*PIDc.Ports.output; |
---|
[1] | 65 | |
---|
| 66 | #Perturbação servo |
---|
[190] | 67 | #Nível desejado=1*'m' |
---|
[295] | 68 | PIDc.Ports.setPoint=0.5; |
---|
[1] | 69 | |
---|
| 70 | #Perturbação regulatória |
---|
[481] | 71 | if time<10*'h' then |
---|
[190] | 72 | Tanque1.Fin= 3*'m^3/h'; |
---|
[1] | 73 | else |
---|
[190] | 74 | Tanque1.Fin= 1.5*'m^3/h'; |
---|
[1] | 75 | end |
---|
| 76 | |
---|
| 77 | INITIAL |
---|
| 78 | "altura inicial" |
---|
[190] | 79 | Tanque1.h = 0.2 * 'm'; |
---|
[1] | 80 | |
---|
| 81 | OPTIONS |
---|
[190] | 82 | TimeStep = 0.1; |
---|
| 83 | TimeEnd = 30; |
---|
| 84 | TimeUnit = 'h'; |
---|
[1] | 85 | end |
---|
| 86 | |
---|
| 87 | FlowSheet Tanque |
---|
| 88 | DEVICES |
---|
| 89 | Tanque1 as tank; |
---|
[295] | 90 | PIDx as PID; |
---|
[1] | 91 | |
---|
| 92 | PARAMETERS |
---|
[190] | 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'); |
---|
[1] | 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 |
---|
[190] | 102 | Tanque1.A = 8 * 'm^2'; |
---|
| 103 | h_max = 2 * 'm'; |
---|
| 104 | h_min = 0 * 'm'; |
---|
[295] | 105 | PIDx.PID_Select = "Ideal_AWBT"; |
---|
| 106 | |
---|
[1] | 107 | EQUATIONS |
---|
[295] | 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; |
---|
[1] | 121 | h_ad = (Tanque1.h-h_min)/(h_max-h_min); |
---|
[295] | 122 | Tanque1.k = 8*'m^2.5/h'*PIDx.Ports.output; |
---|
[1] | 123 | |
---|
| 124 | #Perturbação servo |
---|
[190] | 125 | #Nível desejado=1*'m' |
---|
[295] | 126 | PIDx.Ports.setPoint=0.5; |
---|
[1] | 127 | |
---|
| 128 | #Perturbação regulatória |
---|
[481] | 129 | if time<10*'h' then |
---|
[190] | 130 | Tanque1.Fin= 3*'m^3/h'; |
---|
[1] | 131 | else |
---|
[190] | 132 | Tanque1.Fin= 1.5*'m^3/h'; |
---|
[1] | 133 | end |
---|
| 134 | |
---|
| 135 | INITIAL |
---|
| 136 | "altura inicial" |
---|
[190] | 137 | Tanque1.h = 0.2 * 'm'; |
---|
[1] | 138 | |
---|
| 139 | OPTIONS |
---|
[190] | 140 | TimeStep = 0.1; |
---|
| 141 | TimeEnd = 30; |
---|
| 142 | TimeUnit = 'h'; |
---|
[1] | 143 | end |
---|
| 144 | |
---|
| 145 | |
---|
| 146 | |
---|