Ticket #4481: PI_discreet.mo

File PI_discreet.mo, 992 bytes (added by rahul.dutta.bits@…, 9 years ago)

PI contoller

Line 
1model PI_discreet
2 Modelica.Blocks.Interfaces.RealInput e annotation(
3 Placement(visible = true, transformation(origin = {-120, 0}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-120, 0}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
4 Modelica.Blocks.Interfaces.RealOutput PI_out annotation(
5 Placement(visible = true, transformation(origin = {110, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {110, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
6 parameter Real Kp = 0 "Proportional gain";
7 parameter Real Ki = 0 "Integral gain";
8 parameter Real Init = 0 "Initial output of the controller";
9 Real I(start=Init) "Integral accumulator";
10
11equation
12
13 when Clock(0.001) then
14 I = previous(I) + Ki * e;
15 PI_out = Kp * e + I;
16 end when
17 annotation(
18 uses(Modelica(version = "3.2.2")),
19 Diagram(graphics = {Rectangle(extent = {{-100, 100}, {100, -100}})}));
20end PI_discreet;