Changeset 946 for trunk


Ignore:
Timestamp:
Sep 8, 2013, 1:00:46 PM (9 years ago)
Author:
Argimiro Resende Secchi
Message:

Updating PID with derivative filter.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Block-Oriented EML/Control Systems/PID_Id.mso

    r945 r946  
    2727        #Controller Options
    2828        Controller_Mode as Switcher(Valid=["P","I","D","PI","PD","PID"],Default="PID");
    29         Controller_Structure as Switcher(Valid=["Ideal","Approx. Derivative"],Default="Ideal");
    3029
    3130        # PID Parameters
     
    3332        TauI as Real(Brief="Integral or reset time",Unit='s');
    3433        TauD as Real(Brief="Derivative time",Unit='s');
    35         N as Real(Brief="Divisor terms when the approximative approach",Unit='1/s', Default=100);
     34        N as Real(Brief="Filter parameter",Unit='1/s', Default=200);
    3635
    3736
     
    3938
    4039        in e as Real(Brief="Deviation error",Protected=true,PosX=0,PosY=0.5);
    41         Inte as Real(Brief="Integral of the error",Hidden=true);
    42         Diffe as Real(Brief="Derivative of the error",Hidden=true);
     40        Inte as Real(Brief="Integral of the error",Hidden=true,Unit='s');
     41        ef as Real(Brief="Derivative error filter",Hidden=true);
    4342
    4443        P as Real(Brief="Proportional action",Hidden=true);
    4544        I as Real(Brief="Integral or reset action",Hidden=true);
    46         D1 as Real(Brief="Derivative or anticipative action for structure 1",Hidden=true);
    47         D2 as Real(Brief="Derivative or anticipative action  for structure 2",Hidden=true);
    4845        D as Real(Brief="Final Derivative or anticipative action",Hidden=true);
    4946        out m as Real(Brief="Controller Output",PosX=1, PosY=0.5,Protected=true);
     
    5350
    5451        "Integral of the error"
    55         diff(Inte)*'s'=e;
    56 
    57         "Derivative of the error"
    58         Diffe=diff(e)*'s';
     52        diff(Inte)=e;
    5953
    6054        "Proportional action"
     
    6256
    6357        "Integral or reset action"
    64         I=Kc*(Inte/TauI)*'s';
    65        
    66         switch Controller_Structure
    67                 case "Ideal":
    68                         "Derivative or anticipative action"
    69                         D1=Kc*TauD*Diffe/'s';
    70                         diff(D2)*'s'=0;
    71                         D=D1;
    72                 case "Approx. Derivative":
    73                         "Derivative or anticipative action"
    74                         (1/N)*diff(D2)+D2=Kc*TauD*Diffe/'s';
    75                         D1=0;
    76                         D=D2;
    77         end
     58        I=Kc*(Inte/TauI);
     59
     60        "Derivative or anticipative action"
     61        D=Kc*TauD*diff(ef);
     62
     63        "Error filter"
     64        (1/N)*diff(ef)=e-ef;
    7865       
    7966        #PID Controller equation
     
    9683        INITIAL
    9784
    98         Inte=0;
    99         D2=0;
     85        Inte=0*'s';
     86        diff(ef)*'s'=0;
     87#       ef=0;
     88end
    10089
    101 end
    10290
    10391#*
    10492Notes:
    10593
    106 (1) The "PID with approximate Derivative" approach of Simulink was implemented too.
     94(1) A simple derivative-filtered approach as in Simulink was implemented.
    10795
    10896(2) The controller modes I and D were added for analysis purposes.
    10997
    11098
    111 Revision Date: 09.11.2012
     99Revision Date: 02.09.2013
    112100
    113101*#
Note: See TracChangeset for help on using the changeset viewer.