Changeset 294


Ignore:
Timestamp:
Jun 21, 2007, 4:16:17 PM (15 years ago)
Author:
gerson bicca
Message:

updated controllers models

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/eml/controllers/PIDIncr.mso

    r190 r294  
    1212* EMSO is distributed under the therms of the ALSOC LICENSE as
    1313* available at http://www.enq.ufrgs.br/alsoc.
    14 *
    15 *-------------------------------------------------------------------
    16 * Model of incremental PIDs
    17 *--------------------------------------------------------------------
    18 *  - Inputs
    19 *       - a scaled processs variable
    20 *       - a scaled bias
    21 *       - a scaled setpoint
    22 *
    23 *  - Outputs
    24 *   - a scaled output
    25 *
    26 *
    2714*--------------------------------------------------------------------
    2815* Author: Tiago Osório
     
    3320Model MParameters
    3421
     22ATTRIBUTES
     23        Pallete         = false;
     24        Brief           = "Model of Parameters to be used with incremental PIDs.";
     25       
    3526        VARIABLES
    3627       
     
    4940Model MOptions 
    5041
     42ATTRIBUTES
     43        Pallete         = false;
     44        Brief           = "Model of Options to be used with incremental PIDs.";
     45       
    5146        VARIABLES       
    5247       
     
    5954Model MPorts
    6055
     56ATTRIBUTES
     57        Pallete         = false;
     58        Brief           = "Model of Ports to be used with incremental PIDs.";
    6159        VARIABLES
    6260       
     
    6967Model MInternal_Variables
    7068       
     69        ATTRIBUTES
     70        Pallete         = false;
     71        Brief           = "Model of Internal Variables to be used with incremental PIDs.";
    7172        VARIABLES
    7273
     
    8687end
    8788
    88 Model PIDIncr_basic
    89 
     89Model PIDIncr
     90
     91ATTRIBUTES
     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       
    90110        VARIABLES
    91111        Parameters         as MParameters;
     
    93113        Internal           as MInternal_Variables;
    94114        Ports              as MPorts;
     115        AWFactor     as Real     (Brief="Integral term multiplier used in anti-reset windup");
    95116       
    96117        EQUATIONS
     
    161182        end
    162183
     184switch PID_Select
     185       
     186case "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       
     197case "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       
     208case "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       
     219case "Ideal_AWBT":
     220       
     221        "Calculate integral term with anti-windup and bumpless transfer"
     222        Options.action*Parameters.gain*(Parameters.intTime*Internal.dintTerm-Internal.errorI) = Ports.output-Internal.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       
     230case "Parallel_AWBT":
     231       
     232        "Calculate integral term with anti-windup and bumpless transfer"
     233        Options.action*Parameters.gain*(Parameters.intTime*Internal.dintTerm-Internal.errorI) = Ports.output-Internal.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
     241case "Series_AWBT":
     242       
     243        "Calculate integral term with anti-windup and bumpless transfer"
     244        Options.action*Parameters.gain*(Parameters.intTime*Internal.dintTerm-Internal.errorI) = Ports.output-Internal.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       
     252case "Ideal_AW":
     253       
     254        "Calculate integral term with anti-windup"
     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*100-102);
     263        else
     264                "Calculate AWFactor"
     265                AWFactor=1;
     266        end
     267
     268case "Parallel_AW":
     269       
     270        "Calculate integral term with anti-windup"
     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*100-102);
     279        else
     280                "Calculate AWFactor"
     281                AWFactor=1;
     282        end
     283
     284case "Series_AW":
     285       
     286        "Calculate integral term with anti-windup"
     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*100-102);
     295        else
     296                "Calculate AWFactor"
     297                AWFactor=1;
     298        end
     299
     300end
     301
    163302        INITIAL
    164303        Ports.output = Parameters.bias;
     
    166305        diff(Internal.inputFilt)=0/'s';
    167306        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 anti-windup and bumpless transfer"
    211         Options.action*Parameters.gain*(Parameters.intTime*Internal.dintTerm-Internal.errorI) = Ports.output-Internal.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 anti-windup and bumpless transfer"
    223         Options.action*Parameters.gain*(Parameters.intTime*Internal.dintTerm-Internal.errorI) = Ports.output-Internal.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 anti-windup and bumpless transfer"
    235         Options.action*Parameters.gain*(Parameters.intTime*Internal.dintTerm-Internal.errorI) = Ports.output-Internal.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 anti-reset windup");
    246 
    247         EQUATIONS
    248 
    249         "Calculate integral term with anti-windup"
    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*100-102);
    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 anti-reset windup");
    270 
    271         EQUATIONS
    272 
    273         "Calculate integral term with anti-windup"
    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*100-102);
    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 anti-reset windup");
    293 
    294         EQUATIONS
    295 
    296         "Calculate integral term with anti-windup"
    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*100-102);
    305         else
    306                 "Calculate AWFactor"
    307                 AWFactor=1;
    308         end
    309 
    310 end
    311 
     307       
     308end
     309
     310
  • trunk/sample/controllers/Sample_flash_pid.mso

    r247 r294  
    5656        DEVICES
    5757        #Controlador para o nível
    58         pidL as PIDIncr_Parallel_AWBT;
     58        pidL as PIDIncr;
    5959        #Controlador para a pressão
    60         pidP as PIDIncr_Parallel_AWBT;
     60        pidP as PIDIncr;
    6161        fl as flash;
    6262        s1 as source;
     
    6464        SET
    6565        NComp = PP.NumberOfComponents;
     66       
     67        pidL.PID_Select = "Parallel_AWBT";
     68        pidP.PID_Select = "Parallel_AWBT";
    6669       
    6770        #Parâmetros do modelo de flash
  • trunk/sample/controllers/sample_tanks_pid.mso

    r247 r294  
    3030        DEVICES
    3131        Tanque1 as tank;
    32         PID     as PIDIncr_Ideal_AWBT;
     32        PID     as PIDIncr;
    3333       
    3434        PARAMETERS     
     
    4545        h_max = 2 * 'm';
    4646        h_min = 0 * 'm';
    47 
     47        PID.PID_Select = "Ideal_AWBT";
     48       
    4849        EQUATIONS
    4950        PID.Parameters.tau = 1*'s';     
Note: See TracChangeset for help on using the changeset viewer.