├── Plots ├── 1.1. OnlyAVR-step.jpg ├── 2.1. AVR+PID_step.jpg ├── 3.1 AVR+LQR-step.jpg ├── 1.3. OnlyAVR-bode-plot.jpg ├── 2.3. AVR+PID_bode-plot.jpg ├── 3.2 AVR+LQR-root-locus.jpg ├── 3.3 AVR+LQR_bode-plot.jpg ├── 1.2. OnlyAVR-root-locus.jpg └── 2.2. AVR+PID_root-locus.jpg ├── README.md ├── 1. AVR.m ├── LICENSE ├── 2. AVR+PID.m └── 3. AVR+LQR.m /Plots/1.1. OnlyAVR-step.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rayid-mojumder/Control-System-Design-Matlab-Simulink/HEAD/Plots/1.1. OnlyAVR-step.jpg -------------------------------------------------------------------------------- /Plots/2.1. AVR+PID_step.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rayid-mojumder/Control-System-Design-Matlab-Simulink/HEAD/Plots/2.1. AVR+PID_step.jpg -------------------------------------------------------------------------------- /Plots/3.1 AVR+LQR-step.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rayid-mojumder/Control-System-Design-Matlab-Simulink/HEAD/Plots/3.1 AVR+LQR-step.jpg -------------------------------------------------------------------------------- /Plots/1.3. OnlyAVR-bode-plot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rayid-mojumder/Control-System-Design-Matlab-Simulink/HEAD/Plots/1.3. OnlyAVR-bode-plot.jpg -------------------------------------------------------------------------------- /Plots/2.3. AVR+PID_bode-plot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rayid-mojumder/Control-System-Design-Matlab-Simulink/HEAD/Plots/2.3. AVR+PID_bode-plot.jpg -------------------------------------------------------------------------------- /Plots/3.2 AVR+LQR-root-locus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rayid-mojumder/Control-System-Design-Matlab-Simulink/HEAD/Plots/3.2 AVR+LQR-root-locus.jpg -------------------------------------------------------------------------------- /Plots/3.3 AVR+LQR_bode-plot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rayid-mojumder/Control-System-Design-Matlab-Simulink/HEAD/Plots/3.3 AVR+LQR_bode-plot.jpg -------------------------------------------------------------------------------- /Plots/1.2. OnlyAVR-root-locus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rayid-mojumder/Control-System-Design-Matlab-Simulink/HEAD/Plots/1.2. OnlyAVR-root-locus.jpg -------------------------------------------------------------------------------- /Plots/2.2. AVR+PID_root-locus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rayid-mojumder/Control-System-Design-Matlab-Simulink/HEAD/Plots/2.2. AVR+PID_root-locus.jpg -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # control-system-design 2 | Design robust control system in Matlab (programming+Simulink). 3 | Key themes of application: 4 | (1) Power System 5 | (2) Vehicle Propulsion 6 | (3) Distributed Generating Unit Control 7 | (4) Control of Cyber-Physical System 8 | (5) Smart Grid Controlling. 9 | ## Key Controller ## 10 | (1) Proportional-Integral-Derivative (PID) 11 | (2) Linear Quadratic Regulator (LQR) 12 | (3) Linear Quadratic Gaussian (LQG) 13 | (4) Model Predictive Control (MPC) 14 | -------------------------------------------------------------------------------- /1. AVR.m: -------------------------------------------------------------------------------- 1 | %% Define the gain parameters for Amplifier (Ka), Exciter (Ke), Generator (Kg), and Sensor (Ks) 2 | Ka=10; 3 | Ke=1.0; 4 | Kg=1.0; 5 | Ks=1.0; 6 | %% Define the time constant for Amplifier (Ta), Exciter (Te), Generator (Tg), and Sensor (Ts) 7 | Ta=0.1; 8 | Te=0.4; 9 | Tg=1; 10 | Ts=0.01; 11 | %% Define transfer function for Amplifier (Ga), Exciter (Ge), Generator (Gg), and Sensor (Gs) 12 | s = tf('s'); 13 | Ga=Ka/(1+Ta*s); 14 | Ge=Ke/(1+Te*s); 15 | Gg=Kg/(1+Tg*s); 16 | Gs=Ks/(1+Ts*s); 17 | %% Create close loop transfer function for the AVR system 18 | Gnum=Ga*Ge*Gg; 19 | Gdenum=Gs; 20 | Gavr=Gnum/(1+Gnum*Gdenum) 21 | %Initiate open loop system without controller 22 | t=0:0.01:15; 23 | [S,t1]=step(Gavr,t); 24 | I= stepinfo(Gavr); 25 | sserror=abs(1-S(end));%get steady-state error 26 | hold on 27 | % Analysis plot 28 | pole(Gavr); 29 | %plot(t,S); 30 | % figure 31 | %rlocus(Gavr); 32 | %bode(Gavr),grid; 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Md. Rayid Hasan Mojumder 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /2. AVR+PID.m: -------------------------------------------------------------------------------- 1 | %% Define the gain parameters for Amplifier (Ka), Exciter (Ke), Generator (Kg), and Sensor (Ks) 2 | Ka=10; 3 | Ke=1; 4 | Kg=1; 5 | Ks=1; 6 | %% Define the time constant for Amplifier (Ta), Exciter (Te), Generator (Tg), and Sensor (Ts) 7 | Ta=0.1; 8 | Te=0.4; 9 | Tg=1; 10 | Ts=0.01; 11 | %% Define transfer function for Amplifier (Ga), Exciter (Ge), Generator (Gg), and Sensor (Gs) 12 | s = tf('s'); 13 | Ga=Ka/(1+Ta*s); 14 | Ge=Ke/(1+Te*s); 15 | Gg=Kg/(1+Tg*s); 16 | Gs=Ks/(1+Ts*s); 17 | %% Create close loop transfer function for the AVR system 18 | Gnum=Ga*Ge*Gg; 19 | Gdenum=Gs; 20 | Gavr=Gnum/(1+Gnum*Gdenum); 21 | %Initiate open loop system without controller 22 | t=0:0.01:15; 23 | S=step(Gavr,t); 24 | %I= stepinfo(Gavr) %get rise time, settling time, peak overshoot, etc. 25 | hold on 26 | % Analysis plot 27 | pole(Gavr); 28 | % figure(1); 29 | % rlocus(Gavr); 30 | %% Initiate close loop system with PID controller 31 | Kp=0.70958; 32 | Ki=0.54015; 33 | Kd=0.19211; 34 | Gpid=Kp+Ki*(1/s)+Kd*s; 35 | Gnum1=Gpid*Ga*Ge*Gg; 36 | Gavrpid=Gnum1/(1+Gnum1*Gdenum); 37 | t=0:0.01:15; 38 | Spid=step(Gavrpid,t) 39 | pole(Gavrpid); 40 | %plot(t,Spid) 41 | %I_pid= stepinfo(Gavrpid) 42 | %sserror_pid=abs(1-Spid(end)) 43 | %rlocus(Gavrpid); 44 | bode(Gavrpid) -------------------------------------------------------------------------------- /3. AVR+LQR.m: -------------------------------------------------------------------------------- 1 | %% Define the gain parameters for Amplifier (Ka), Exciter (Ke), Generator (Kg), and Sensor (Ks) 2 | Ka=10; 3 | Ke=1; 4 | Kg=1; 5 | Ks=1; 6 | %% Define the time constant for Amplifier (Ta), Exciter (Te), Generator (Tg), and Sensor (Ts) 7 | Ta=0.1; 8 | Te=0.4; 9 | Tg=1; 10 | Ts=0.01; 11 | %% Define transfer function for Amplifier (Ga), Exciter (Ge), Generator (Gg), and Sensor (Gs) 12 | s = tf('s'); 13 | Ga=Ka/(1+Ta*s); 14 | Ge=Ke/(1+Te*s); 15 | Gg=Kg/(1+Tg*s); 16 | Gs=Ks/(1+Ts*s); 17 | %% Create close loop transfer function for the AVR system 18 | Gnum=Ga*Ge*Gg; 19 | Gdenum=Gs; 20 | Gavr=Gnum/(1+Gnum*Gdenum); 21 | fraction_n= [0.004 0.454 5.55 15.1 10];%numerator of Gavr, transfer function 22 | fraction_dn=[1.6e-05 0.002032 0.04732 0.4286 2.133 8.76 18.01 11]; %denominator of Gavr, transfer function 23 | [A,B,C,D] = tf2ss(fraction_n,fraction_dn) % convert fractional transfer function to A, B, C, D space matrix 24 | %% Initiate close loop system with LQR controller 25 | Q=1*[1 0 0 0 0 0 0; 26 | 0 1000 0 0 0 0 0; 27 | 0 0 10 0 0 0 0; 28 | 0 0 0 1 0 0 0; 29 | 0 0 0 0 1 0 0; 30 | 0 0 0 0 0 1 0; 31 | 0 0 0 0 0 0 1]; 32 | %Q=1*eye(7);%positive control weighting matrix, size is similar to A matrix 33 | % p = 2; 34 | % Q = p*C'*C 35 | R = 0.0001; %non-negative state weighting matrix 36 | %% Remember TF to SS is not equal, there is a problem do not directly use tf2ss...%% 37 | % convert to numerator, denominator first 38 | % then use tf2ss(num,denom) 39 | % do not use the following two line, never 40 | % [num,den] = tfdata(Gavr,'v'); 41 | % [A,B,C,D] = tf2ss(num, den); 42 | %% Continue %% 43 | K=lqr(A,B,Q,R); %See how many value is there, could be useful for designing Simulink system 44 | Af=A-B*K; % Feedback Subtraction node 45 | sys_lqr=ss(Af,B,C,D);%closed loop system with feedback 46 | t=0:0.01:15; 47 | Slqr=step(sys_lqr,t); 48 | pole(sys_lqr) 49 | % A 50 | figure(1) 51 | plot(t,Slqr) 52 | %sim(AVR_LQR_sim.slx) 53 | I_lqr= stepinfo(sys_lqr) 54 | sserror_lqr=abs(1-Slqr(end)) 55 | figure(2) 56 | rlocus(sys_lqr); 57 | figure(3) 58 | bode(sys_lqr) 59 | % ylabel('Terminal Voltage (pu)') 60 | % xlabel('Time (sec)') 61 | % legend('AVR LQR') 62 | --------------------------------------------------------------------------------