source: trunk/Block-Oriented EML/Control Systems/PID_Id.mso @ 965

Last change on this file since 965 was 947, checked in by Argimiro Resende Secchi, 10 years ago

Updating PID with derivative filter.

File size: 2.3 KB
Line 
1#*-------------------------------------------------------------------
2* EMSO Model Library (EML) Copyright (C) 2004 - 2007 ALSOC.
3*
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.
7*
8* EMSO is distributed under the terms of the ALSOC LICENSE as
9* available at http://www.enq.ufrgs.br/alsoc.
10*-----------------------------------------------------------------------
11* Author: Jonathan Ospino P.
12* $Id: PID_id.mso  2012$
13*---------------------------------------------------------------------*#
14
15using "types";
16
17Model PID_id
18
19        ATTRIBUTES
20       
21        Pallete=true;
22        Icon="icon/PID";
23        Info="== PID Controller block ==";
24
25        PARAMETERS
26
27        #Controller Options
28        Controller_Mode as Switcher(Valid=["P","I","D","PI","PD","PID"],Default="PID");
29
30        # PID Parameters
31        Kc as Real(Brief="Proportional controller gain");
32        TauI as Real(Brief="Integral or reset time",Unit='s');
33        TauD as Real(Brief="Derivative time",Unit='s');
34        N as Real(Brief="Filter parameter",Unit='1/s', Default=200);
35
36
37        VARIABLES
38
39        in e as Real(Brief="Deviation error",Protected=true,PosX=0,PosY=0.5);
40        Inte as Real(Brief="Integral of the error",Hidden=true,Unit='s');
41        ef as Real(Brief="Derivative error filter",Hidden=true);
42
43        P as Real(Brief="Proportional action",Hidden=true);
44        I as Real(Brief="Integral or reset action",Hidden=true);
45        D as Real(Brief="Final Derivative or anticipative action",Hidden=true);
46        out m as Real(Brief="Controller Output",PosX=1, PosY=0.5,Protected=true);
47
48
49        EQUATIONS
50
51        "Integral of the error"
52        diff(Inte)=e;
53
54        "Proportional action"
55        P=Kc*e;
56
57        "Integral or reset action"
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;
65       
66        #PID Controller equation
67        switch Controller_Mode
68                case "P":
69                        m=P;
70                case "I":
71                        m=I;
72                case "D":
73                        m=D;
74                case "PI":
75                        m=P+I;
76                case "PID":
77                        m=P+I+D;
78                case "PD":
79                        m=P+D;
80        end
81       
82       
83        INITIAL
84
85        Inte=0*'s';
86        diff(ef)*'s'=0;
87#       ef=0;
88end
89
90
91#*
92Notes:
93
94(1) A simple derivative-filtered approach as in Simulink was implemented.
95
96(2) The controller modes I and D were added for analysis purposes.
97
98
99Revision Date: 02.09.2013
100
101*#
Note: See TracBrowser for help on using the repository browser.