Ignore:
Timestamp:
Mar 7, 2007, 3:09:13 PM (16 years ago)
Author:
Rafael de Pelegrini Soares
Message:

Adapted PID models for the new language (the usage of switcher is still pending)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/newlanguage/sample/controllers/sample_tanks_pid.mso

    r84 r190  
    3333       
    3434        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");
     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');
    3737
    3838    VARIABLES
     
    4242       
    4343        SET
    44         Tanque1.A = 8 * "m^2";
    45         h_max = 2 * "m";
    46         h_min = 0 * "m";
     44        Tanque1.A = 8 * 'm^2';
     45        h_max = 2 * 'm';
     46        h_min = 0 * 'm';
    4747
    4848        EQUATIONS
    49         PID.Parameters.tau = 1*"s";     
    50         PID.Parameters.tauSet = 1*"s"
     49        PID.Parameters.tau = 1*'s';     
     50        PID.Parameters.tauSet = 1*'s'
    5151        PID.Parameters.alpha = 0.3;
    5252        PID.Parameters.bias = 0;       
     
    5656        PID.Options.clip=1;
    5757        PID.Options.autoMan = 0;
    58         PID.Parameters.intTime=5000*"s";
     58        PID.Parameters.intTime=5000*'s';
    5959        PID.Parameters.gain = 3.5;
    60         PID.Parameters.derivTime=1*"s";
     60        PID.Parameters.derivTime=1*'s';
    6161        PID.Ports.input = h_ad;
    6262        h_ad = (Tanque1.h-h_min)/(h_max-h_min);
    63         Tanque1.k = 8*"m^2.5/h"*PID.Ports.output;       
     63        Tanque1.k = 8*'m^2.5/h'*PID.Ports.output;       
    6464
    6565        #Perturbação servo
    66         #Nível desejado=1*"m"
     66        #Nível desejado=1*'m'
    6767        PID.Ports.setPoint=0.5;
    6868
    6969        #Perturbação regulatória
    7070        if time<10*"h" then
    71                 Tanque1.Fin= 3*"m^3/h";
     71                Tanque1.Fin= 3*'m^3/h';
    7272        else
    73                 Tanque1.Fin= 1.5*"m^3/h";
     73                Tanque1.Fin= 1.5*'m^3/h';
    7474        end     
    7575       
    7676        INITIAL
    7777        "altura inicial"
    78         Tanque1.h = 0.2 * "m";
     78        Tanque1.h = 0.2 * 'm';
    7979       
    8080        OPTIONS
    8181        DAESolver = "dassl";
    82         time = [0:0.1:30] * "h" ;
     82        TimeStep = 0.1;
     83        TimeEnd = 30;
     84        TimeUnit = 'h';
    8385end
    8486
     
    8991       
    9092        PARAMETERS     
    91         h_max as Real (Brief="Altura máxima do nível do tanque", Unit="m");
    92         h_min as Real (Brief="Altura mínima do nível do tanque", Unit="m");
     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');
    9395
    9496    VARIABLES
     
    98100       
    99101        SET
    100         Tanque1.A = 8 * "m^2";
    101         h_max = 2 * "m";
    102         h_min = 0 * "m";
     102        Tanque1.A = 8 * 'm^2';
     103        h_max = 2 * 'm';
     104        h_min = 0 * 'm';
    103105
    104106        EQUATIONS
    105         PID.Parameters.tau = 1*"s";     
    106     PID.Parameters.tauSet = 1*"s";     
     107        PID.Parameters.tau = 1*'s';     
     108    PID.Parameters.tauSet = 1*'s';     
    107109        PID.Parameters.alpha = 0.3;
    108110        PID.Parameters.bias = 0;
    109111        PID.Parameters.gamma = 1;
    110112        PID.Parameters.beta = 1;
    111         PID.Parameters.intTime=5000*"s";
     113        PID.Parameters.intTime=5000*'s';
    112114        PID.Parameters.gain =3.5;
    113         PID.Parameters.derivTime=1*"s";
     115        PID.Parameters.derivTime=1*'s';
    114116        PID.Options.action = -1;
    115117        PID.Options.clip=1;
     
    117119        PID.Ports.input = h_ad;
    118120        h_ad = (Tanque1.h-h_min)/(h_max-h_min);
    119         Tanque1.k = 8*"m^2.5/h"*PID.Ports.output;       
     121        Tanque1.k = 8*'m^2.5/h'*PID.Ports.output;       
    120122
    121123        #Perturbação servo
    122         #Nível desejado=1*"m"
     124        #Nível desejado=1*'m'
    123125        PID.Ports.setPoint=0.5;
    124126
    125127        #Perturbação regulatória
    126128        if time<10*"h" then
    127                 Tanque1.Fin= 3*"m^3/h";
     129                Tanque1.Fin= 3*'m^3/h';
    128130        else
    129                 Tanque1.Fin= 1.5*"m^3/h";
     131                Tanque1.Fin= 1.5*'m^3/h';
    130132        end
    131133       
    132134        INITIAL
    133135        "altura inicial"
    134         Tanque1.h = 0.2 * "m";
     136        Tanque1.h = 0.2 * 'm';
    135137       
    136138        OPTIONS
    137139        NLASolver = "sundials";
    138         time = [0:0.1:30] * "h" ;
     140        TimeStep = 0.1;
     141        TimeEnd = 30;
     142        TimeUnit = 'h';
    139143end
    140144
Note: See TracChangeset for help on using the changeset viewer.