RLC Circuit of February 10, 2011
Jump to navigation
Jump to search
The problem was set up in class starting on February 10, 2011. The Octave script below simulates the control system using a full order observer for the states, and assuming that the output voltage is all that is available for measurement.
% This script simulates the RLC circuit from the notes of February 10, % 2011. It uses a full order observer. It also shows how to reorder % the states. It includes a simulation of the system which is very % interesting because it shows how there is a big error in the observer % at first. c=2 %Capacitance R=3 %Resistance L=4 %Inductance A=[[0 -1/L];[1/c -1/(R*c)]] B=[1/L; 0] C=[0 1] D=0 sys1=ss(A,B,C,D); T=fliplr(eye(2)); %Transformation Matrix for swapping states Ar=T*A*T^(-1); %Transformed system Br=T*B; Cr=C*T^(-1); sysr=ss(Ar,Br,Cr,0); Rr=obsv(sysr); %Observability Matrix for swapped states R=obsv(sys1); %Not swapped Observability Matrix rank_r=rank(R); %Is the system observable rank_rr=rank(Rr) g=place(sys1,[-1.5 -2.5]); %Place the poles for the controller printf("Check to see if the place did the right thing.") printf("The poles after feedback are at: ") controller_poles = eig(A-B*g) K=place(A',C',[-33,-30.5])' %Place poles for the observer % Note: you can see the observer problem with poles [-100,-105] % and initial conditions [1 2 3 4] Ahat=A-K*C; printf("Check to see if the place did the right thing.") printf("The poles of the observer are: ") observer_poles = eig(Ahat) Bhat=B; %Make a concatinated system of the observer and system Atot=[[A, -B*g];[K*C, Ahat-Bhat*g]]; Btot=[B;Bhat]; Ctot=eye(size(Atot)); systot=ss(Atot,Btot,Ctot); polestot=pole(systot) t=0:.0001:.5; [X,Y]=lsim(systot, zeros(size(t))', t, [5 5 1 1]'); plot(t,X) legend('x_1','x_2','xhat_1','xhat_2') title('System and Observer Simulation') xlabel('Time (seconds)') % Check the transformed to error terms total system. T=[[1 0 0 0];[0 1 0 0];[1 0 -1 0];[0 1 0 -1]]; TAtotTI=T*Atot*T^(-1); polestot_transformed=eig(TAtotTI);