Changeset 294 for trunk/eml/controllers
 Timestamp:
 Jun 21, 2007, 4:16:17 PM (16 years ago)
 Location:
 trunk/eml/controllers
 Files:

 1 added
 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/eml/controllers/PIDIncr.mso
r190 r294 12 12 * EMSO is distributed under the therms of the ALSOC LICENSE as 13 13 * available at http://www.enq.ufrgs.br/alsoc. 14 *15 *16 * Model of incremental PIDs17 *18 *  Inputs19 *  a scaled processs variable20 *  a scaled bias21 *  a scaled setpoint22 *23 *  Outputs24 *  a scaled output25 *26 *27 14 * 28 15 * Author: Tiago Osório … … 33 20 Model MParameters 34 21 22 ATTRIBUTES 23 Pallete = false; 24 Brief = "Model of Parameters to be used with incremental PIDs."; 25 35 26 VARIABLES 36 27 … … 49 40 Model MOptions 50 41 42 ATTRIBUTES 43 Pallete = false; 44 Brief = "Model of Options to be used with incremental PIDs."; 45 51 46 VARIABLES 52 47 … … 59 54 Model MPorts 60 55 56 ATTRIBUTES 57 Pallete = false; 58 Brief = "Model of Ports to be used with incremental PIDs."; 61 59 VARIABLES 62 60 … … 69 67 Model MInternal_Variables 70 68 69 ATTRIBUTES 70 Pallete = false; 71 Brief = "Model of Internal Variables to be used with incremental PIDs."; 71 72 VARIABLES 72 73 … … 86 87 end 87 88 88 Model PIDIncr_basic 89 89 Model PIDIncr 90 91 ATTRIBUTES 92 Pallete = true; 93 Icon = "PIDIncr"; 94 Brief = "Model of incremental PIDs."; 95 Info = 96 " 97  Inputs 98 *  a scaled processs variable. 99 *  a scaled bias. 100 *  a scaled setpoint. 101 102  Outputs 103 *  a scaled output. 104 "; 105 106 PARAMETERS 107 108 PID_Select as Switcher (Brief="Type of PID Incremental", Valid=["Ideal","Parallel","Series","Ideal_AWBT","Parallel_AWBT","Series_AWBT","Ideal_AW","Parallel_AW","Series_AW"], Default = "Ideal"); 109 90 110 VARIABLES 91 111 Parameters as MParameters; … … 93 113 Internal as MInternal_Variables; 94 114 Ports as MPorts; 115 AWFactor as Real (Brief="Integral term multiplier used in antireset windup"); 95 116 96 117 EQUATIONS … … 161 182 end 162 183 184 switch PID_Select 185 186 case "Ideal": 187 188 "Calculate integral term" 189 Parameters.intTime*Internal.dintTerm = Internal.errorI; 190 191 "Sum of proportional, integral and derivative terms" 192 Internal.doutp = Options.action*Parameters.gain*(Internal.dpropTerm + Internal.dintTerm + Internal.dderivTerm); 193 194 "Calculate AWFactor  Not in use in this mode" 195 AWFactor=1; 196 197 case "Parallel": 198 199 "Calculate integral term" 200 Parameters.intTime*Internal.dintTerm = Internal.errorI; 201 202 "Sum of proportional, integral and derivative terms" 203 Internal.doutp = Options.action*(Parameters.gain*Internal.dpropTerm + Internal.dintTerm + Internal.dderivTerm); 204 205 "Calculate AWFactor  Not in use in this mode" 206 AWFactor=1; 207 208 case "Series": 209 210 "Calculate integral term" 211 Parameters.intTime*Internal.dintTerm = Internal.errorI; 212 213 "Sum of proportional, integral and derivative terms" 214 Internal.doutp = Options.action*(Parameters.gain*(Internal.dpropTerm + Internal.dintTerm)*(1/'s' + Internal.dderivTerm)*'s'); 215 216 "Calculate AWFactor  Not in use in this mode" 217 AWFactor=1; 218 219 case "Ideal_AWBT": 220 221 "Calculate integral term with antiwindup and bumpless transfer" 222 Options.action*Parameters.gain*(Parameters.intTime*Internal.dintTermInternal.errorI) = Ports.outputInternal.outp; 223 224 "Sum of proportional, integral and derivative terms" 225 Internal.doutp = Options.action*Parameters.gain*(Internal.dpropTerm + Internal.dintTerm + Internal.dderivTerm); 226 227 "Calculate AWFactor  Not in use in this mode" 228 AWFactor=1; 229 230 case "Parallel_AWBT": 231 232 "Calculate integral term with antiwindup and bumpless transfer" 233 Options.action*Parameters.gain*(Parameters.intTime*Internal.dintTermInternal.errorI) = Ports.outputInternal.outp; 234 235 "Sum of proportional, integral and derivative terms" 236 Internal.doutp = Options.action*(Parameters.gain*Internal.dpropTerm + Internal.dintTerm + Internal.dderivTerm); 237 238 "Calculate AWFactor  Not in use in this mode" 239 AWFactor=1; 240 241 case "Series_AWBT": 242 243 "Calculate integral term with antiwindup and bumpless transfer" 244 Options.action*Parameters.gain*(Parameters.intTime*Internal.dintTermInternal.errorI) = Ports.outputInternal.outp; 245 246 "Sum of proportional, integral and derivative terms" 247 Internal.doutp = Options.action*(Parameters.gain*(Internal.dpropTerm + Internal.dintTerm)*(1/'s' + Internal.dderivTerm)*'s'); 248 249 "Calculate AWFactor  Not in use in this mode" 250 AWFactor=1; 251 252 case "Ideal_AW": 253 254 "Calculate integral term with antiwindup" 255 Parameters.intTime*Internal.dintTerm = AWFactor*Internal.errorI; 256 257 "Sum of proportional, integral and derivative terms" 258 Internal.doutp = Options.action*Parameters.gain*(Internal.dpropTerm + Internal.dintTerm + Internal.dderivTerm); 259 260 if abs(Internal.outps)>1 and (Options.action*sign(Internal.outps)*Internal.errorI)>0 then 261 "Calculate AWFactor" 262 AWFactor=tanh(sign(Internal.outps)*Internal.outps*100102); 263 else 264 "Calculate AWFactor" 265 AWFactor=1; 266 end 267 268 case "Parallel_AW": 269 270 "Calculate integral term with antiwindup" 271 Parameters.intTime*Internal.dintTerm = AWFactor*Internal.errorI; 272 273 "Sum of proportional, integral and derivative terms" 274 Internal.doutp = Options.action*(Parameters.gain*Internal.dpropTerm + Internal.dintTerm + Internal.dderivTerm); 275 276 if abs(Internal.outps)>1 and (Options.action*sign(Internal.outps)*Internal.errorI)>0 then 277 "Calculate AWFactor" 278 AWFactor=tanh(sign(Internal.outps)*Internal.outps*100102); 279 else 280 "Calculate AWFactor" 281 AWFactor=1; 282 end 283 284 case "Series_AW": 285 286 "Calculate integral term with antiwindup" 287 Parameters.intTime*Internal.dintTerm = AWFactor*Internal.errorI; 288 289 "Sum of proportional, integral and derivative terms" 290 Internal.doutp = Options.action*(Parameters.gain*(Internal.dpropTerm + Internal.dintTerm)*(1/'s' + Internal.dderivTerm)*'s'); 291 292 if abs(Internal.outps)>1 and (Options.action*sign(Internal.outps)*Internal.errorI)>0 then 293 "Calculate AWFactor" 294 AWFactor=tanh(sign(Internal.outps)*Internal.outps*100102); 295 else 296 "Calculate AWFactor" 297 AWFactor=1; 298 end 299 300 end 301 163 302 INITIAL 164 303 Ports.output = Parameters.bias; … … 166 305 diff(Internal.inputFilt)=0/'s'; 167 306 diff(Internal.setPointFilt)=0/'s'; 168 end 169 170 Model PIDIncr_Ideal as PIDIncr_basic 171 172 EQUATIONS 173 174 "Calculate integral term" 175 Parameters.intTime*Internal.dintTerm = Internal.errorI; 176 177 "Sum of proportional, integral and derivative terms" 178 Internal.doutp = Options.action*Parameters.gain*(Internal.dpropTerm + Internal.dintTerm + Internal.dderivTerm); 179 180 end 181 182 Model PIDIncr_Parallel as PIDIncr_basic 183 184 EQUATIONS 185 186 "Calculate integral term" 187 Parameters.intTime*Internal.dintTerm = Internal.errorI; 188 189 "Sum of proportional, integral and derivative terms" 190 Internal.doutp = Options.action*(Parameters.gain*Internal.dpropTerm + Internal.dintTerm + Internal.dderivTerm); 191 192 end 193 194 Model PIDIncr_Series as PIDIncr_basic 195 196 EQUATIONS 197 198 "Calculate integral term" 199 Parameters.intTime*Internal.dintTerm = Internal.errorI; 200 201 "Sum of proportional, integral and derivative terms" 202 Internal.doutp = Options.action*(Parameters.gain*(Internal.dpropTerm + Internal.dintTerm)*(1/'s' + Internal.dderivTerm)*'s'); 203 204 end 205 206 Model PIDIncr_Ideal_AWBT as PIDIncr_basic 207 208 EQUATIONS 209 210 "Calculate integral term with antiwindup and bumpless transfer" 211 Options.action*Parameters.gain*(Parameters.intTime*Internal.dintTermInternal.errorI) = Ports.outputInternal.outp; 212 213 "Sum of proportional, integral and derivative terms" 214 Internal.doutp = Options.action*Parameters.gain*(Internal.dpropTerm + Internal.dintTerm + Internal.dderivTerm); 215 216 end 217 218 Model PIDIncr_Parallel_AWBT as PIDIncr_basic 219 220 EQUATIONS 221 222 "Calculate integral term with antiwindup and bumpless transfer" 223 Options.action*Parameters.gain*(Parameters.intTime*Internal.dintTermInternal.errorI) = Ports.outputInternal.outp; 224 225 "Sum of proportional, integral and derivative terms" 226 Internal.doutp = Options.action*(Parameters.gain*Internal.dpropTerm + Internal.dintTerm + Internal.dderivTerm); 227 228 end 229 230 Model PIDIncr_Series_AWBT as PIDIncr_basic 231 232 EQUATIONS 233 234 "Calculate integral term with antiwindup and bumpless transfer" 235 Options.action*Parameters.gain*(Parameters.intTime*Internal.dintTermInternal.errorI) = Ports.outputInternal.outp; 236 237 "Sum of proportional, integral and derivative terms" 238 Internal.doutp = Options.action*(Parameters.gain*(Internal.dpropTerm + Internal.dintTerm)*(1/'s' + Internal.dderivTerm)*'s'); 239 240 end 241 242 Model PIDIncr_Ideal_AW as PIDIncr_basic 243 244 VARIABLES 245 AWFactor as Real (Brief="Integral term multiplier used in antireset windup"); 246 247 EQUATIONS 248 249 "Calculate integral term with antiwindup" 250 Parameters.intTime*Internal.dintTerm = AWFactor*Internal.errorI; 251 252 "Sum of proportional, integral and derivative terms" 253 Internal.doutp = Options.action*Parameters.gain*(Internal.dpropTerm + Internal.dintTerm + Internal.dderivTerm); 254 255 256 if abs(Internal.outps)>1 and (Options.action*sign(Internal.outps)*Internal.errorI)>0 then 257 "Calculate AWFactor" 258 AWFactor=tanh(sign(Internal.outps)*Internal.outps*100102); 259 else 260 "Calculate AWFactor" 261 AWFactor=1; 262 end 263 264 end 265 266 Model PIDIncr_Parallel_AW as PIDIncr_basic 267 268 VARIABLES 269 AWFactor as Real (Brief="Integral term multiplier used in antireset windup"); 270 271 EQUATIONS 272 273 "Calculate integral term with antiwindup" 274 Parameters.intTime*Internal.dintTerm = AWFactor*Internal.errorI; 275 276 "Sum of proportional, integral and derivative terms" 277 Internal.doutp = Options.action*(Parameters.gain*Internal.dpropTerm + Internal.dintTerm + Internal.dderivTerm); 278 279 if abs(Internal.outps)>1 and (Options.action*sign(Internal.outps)*Internal.errorI)>0 then 280 "Calculate AWFactor" 281 AWFactor=tanh(sign(Internal.outps)*Internal.outps*100102); 282 else 283 "Calculate AWFactor" 284 AWFactor=1; 285 end 286 287 end 288 289 Model PIDIncr_Series_AW as PIDIncr_basic 290 291 VARIABLES 292 AWFactor as Real (Brief="Integral term multiplier used in antireset windup"); 293 294 EQUATIONS 295 296 "Calculate integral term with antiwindup" 297 Parameters.intTime*Internal.dintTerm = AWFactor*Internal.errorI; 298 299 "Sum of proportional, integral and derivative terms" 300 Internal.doutp = Options.action*(Parameters.gain*(Internal.dpropTerm + Internal.dintTerm)*(1/'s' + Internal.dderivTerm)*'s'); 301 302 if abs(Internal.outps)>1 and (Options.action*sign(Internal.outps)*Internal.errorI)>0 then 303 "Calculate AWFactor" 304 AWFactor=tanh(sign(Internal.outps)*Internal.outps*100102); 305 else 306 "Calculate AWFactor" 307 AWFactor=1; 308 end 309 310 end 311 307 308 end 309 310
Note: See TracChangeset
for help on using the changeset viewer.