solutions to magnetic bearing lab #5 digital controller design for … · 2017. 10. 8. · the...

12
Solutions to Magnetic Bearing Lab #5 Digital Controller Design for a Magnetic Bearing System by Löhning, Matthias University of Calgary Department of Mechanical and Manufacturing Engineering 25 August 2004

Upload: others

Post on 09-Mar-2021

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Solutions to Magnetic Bearing Lab #5 Digital Controller Design for … · 2017. 10. 8. · The frequency response vectors C of the lead controller and N of the notch filter ... In

Solutions to Magnetic Bearing Lab #5Digital Controller Design for a Magnetic Bearing

System

by Löhning, Matthias

University of CalgaryDepartment of Mechanical and Manufacturing Engineering

25 August 2004

Page 2: Solutions to Magnetic Bearing Lab #5 Digital Controller Design for … · 2017. 10. 8. · The frequency response vectors C of the lead controller and N of the notch filter ... In

Magnetic Bearing: Digital Controller Design

Exercise 1:

The frequency response vectors C of the lead controller and N of the notch filterare generated. Instead of generating the rps vector as described in the instructionsthe measured rps vector of lab2 Exercise 9 is taken (see lab5 Exercise2). TheMatlab code can be seen in the Appendix B Exercise 1 to 3.

Exercise 2:

As described in Exercise 1 the measured rps vector is taken. This is necessary,because the vectors g, C and N have to be on the same frequency to calculate theclosed loop frequency response vector. The Bode diagram is implemented manualdue to better colors and commands and can be seen in Figure 1 and 2. In Figure 1the measured data of the open loop magnetic bearing system obtained in lab2Exercise 9 is taken. In Figure 2 the averaged data is taken to get the closed looptransfer function.

Figure 1: Bode diagram of the closed loop transfer function (non-averaged signal)

Page 2

Page 3: Solutions to Magnetic Bearing Lab #5 Digital Controller Design for … · 2017. 10. 8. · The frequency response vectors C of the lead controller and N of the notch filter ... In

Magnetic Bearing: Digital Controller Design

Figure 2: Bode diagram of the closed loop transfer function (averaged signal)

Exercise 3:

With the help of the Matlab code (see Appendix B Exercise 1 to 3) the frequency ofthe second flexible rotor mode is determined to 12879 rad/sec which correspondsto 2050 Hz.

Exercise 4:

Theoretical a sampling frequency of 2*2000 Hz = 4 kHz is enough to avoid aliasingeffects. In practice instead of the factor 2 a factor in the range of 4 to 8 should bechosen.In Figure 1 the read closed loop bandwidth is 1445 rad/sec or 230 Hz. In Figure 2the read bandwidth is 1431 rad/sec or 228 Hz. With this approach the samplingfrequency should be chosen to 20*229 Hz = 4580 Hz.

Exercise 5:

The Matlab code in Appendix B Exercise 5 to7 transforms the continuous notchfilter in an equivalent discrete notch filter.

Page 3

Page 4: Solutions to Magnetic Bearing Lab #5 Digital Controller Design for … · 2017. 10. 8. · The frequency response vectors C of the lead controller and N of the notch filter ... In

Magnetic Bearing: Digital Controller Design

Exercise 6:

In Figure 3 and 4 the read gain crossover frequency is 164 Hz.

Figure 3: Bode diagram of the open loop transfer function (non-averaged signal)

Figure 4: Bode diagram of the open loop transfer function (averaged signal)

Page 4

Page 5: Solutions to Magnetic Bearing Lab #5 Digital Controller Design for … · 2017. 10. 8. · The frequency response vectors C of the lead controller and N of the notch filter ... In

Magnetic Bearing: Digital Controller Design

Exercise 7:

The Matlab code can be seen in Appendix B Exercise 5 to 7.

Exercise 8:

As described in the instruction the m-file is written and can be seen in Appendix BExercise 8.

Exercise 9:

The used Simulink set-up can be seen in Appendix A. Instead of the dSPACEhard- and software the Quanser equipment is used as in the lab solutions before.

Exercise 10 and 11:

As a result of the same used set-up in the previous laboratories the implementeddigital controller and notch filter stabilise the magnetic bearing system. The test ofrobustness described in lab 4 Exercise 8 does not result in instability and thusadjustments are not necessary.

Exercise 12 (optional):

Due to no aliasing problems the exercises below are made exemplarily with the

values sec

7000**2 radn and 2Q . Figure 5 shows this chosen low pass filter as

well as the reference low pass filter of the instruction.

Page 5

Page 6: Solutions to Magnetic Bearing Lab #5 Digital Controller Design for … · 2017. 10. 8. · The frequency response vectors C of the lead controller and N of the notch filter ... In

Magnetic Bearing: Digital Controller Design

Figure 5: Bode diagram of the low pass filter

Exercise 13 and 16:

One possibility is to transform the second equation to 2

2

18

1 *10

FnF RR

, insert this

result in the third equation and solve it to 2FR . Therewith the solution is

8.34k8340

5.0****10*5.2*10 49

2 QRRRR

RQGn

QGF

. With the equation above 1FR is

61.985k61985 .

Page 6

Page 7: Solutions to Magnetic Bearing Lab #5 Digital Controller Design for … · 2017. 10. 8. · The frequency response vectors C of the lead controller and N of the notch filter ... In

Magnetic Bearing: Digital Controller Design

Appendix A:Simulink model of the discrete controller and notch filter:

Appendix B:Matlabcode Exercise 1 to 3:

% lab5 exercise 1 to 3

% to load the data the files has to be in the correct folder load lab2ex9gaverage_ver1_rpsg; % load the bearing frequency response vector g

and the frequency vector rps (identified andaveraged filtered in lab2)

rpsaverage=rps';gaverage=g; % generate gaverage to overwrite it belowload lab2ex9g_ver3_rpsg; % load the bearing frequency response vector g

and the frequency vector rps (identified in lab2)rps=rps';

% -----------------------------------------------exercise 1------------------------------------------------------------% create the notch filter parametersAn=1; % An is chosen as described in lab3 page 10Q=3; % Q is chosen as described in lab3 solution

exercise 10omegan=2*pi*746; % omegan is chosen as described in lab3

solution exercise 10% create the controller parametersk=0.7; % the controller values are chosen as described T=3*10^(-3); in lab4 solution exercise 8alpha=0.25849;T0=7.7547*10^(-5);

% create the frequency response vectorsleadnum=[k*T k]; % generate the numerator of the lead controllerleadden=conv([alpha*T 1],[T0 1]); % generate the denominator of the lead

controllerC=freqs(leadnum,leadden,rps)'; % generate the frequency response vector of the

lead controller at the frequencies measured in lab2

Page 7

Page 8: Solutions to Magnetic Bearing Lab #5 Digital Controller Design for … · 2017. 10. 8. · The frequency response vectors C of the lead controller and N of the notch filter ... In

Magnetic Bearing: Digital Controller Design

Caverage=freqs(leadnum,leadden,rpsaverage)'; % generate the frequency response vector of thelead controller at the averaged frequencies of lab2

notchnum=[An 0 An*omegan^2]; % generate the numerator of the notch filternotchden=[1 omegan/Q omegan^2]; % generate the denominator of the notch filterN=freqs(notchnum,notchden,rps)'; % generate the frequency response vector of the

notch filter at the frequencies measured in lab 2Naverage=freqs(notchnum,notchden,rpsaverage)'; % generate the frequency response vector of the

notch filter at the averaged frequencies of lab 2

% -----------------------------------------------exercise 2------------------------------------------------------------% generate the closed loop system frequency response vectorsystemfr=g./(ones(size(g))+g.*N.*C); % the command ones generate a vector, which

elements are one and which has the length of gsystemfraverage=gaverage./(ones(size(gaverage))+gaverage.*Naverage.*Caverage); % generate the

frequency response vector of the averagedsignal

%minus3dB=10^(-3/20)*ones(size(systemfr));%vsys=vpck([systemfr minus3dB],rps);%vplot('bode_g',vsys);

% Bode plot of the non averaged signalminus3absdb=-3*ones(size(systemfr)); % minus 3 dbminus3phase=zeros(size(systemfr)); % phase of minus 3 dbsystemfrabsdb = 20*log10(abs(systemfr)); % magnitude of the measured data in dbsystemfrphase = angle(systemfr)/pi*180; % phase angle of the measured data in degreefigure; subplot(211);semilogx(rps,systemfrabsdb,'b',rps,minus3absdb,'g');grid on;title('Bode Diagram of the closed loop system transfer function (non-averaged signal)');ylabel('Magnitude (dB)');legend('closed loop frequency response','-3 dB line',3);subplot(212);semilogx(rps,systemfrphase,'b',rps,minus3phase,'g');grid on;xlabel('Frequency (rad/sec)');ylabel('Phase (deg)');legend('closed loop frequency response','-3 dB line',3);

% Bode plot of the averaged signalminus3averageabsdb=-3*ones(size(systemfraverage)); % minus 3 dbminus3averagephase=zeros(size(systemfraverage)); % phase of minus 3 dbsystemfraverageabsdb = 20*log10(abs(systemfraverage)); % magnitude of the averaged data in dbsystemfraveragephase = angle(systemfraverage)/pi*180; % phase angle of the averaged data in degreefigure; subplot(211);semilogx(rpsaverage,systemfraverageabsdb,'b',rpsaverage,minus3averageabsdb,'g');grid on;title('Bode Diagram of the closed loop system transfer function (averaged signal)');ylabel('Magnitude (dB)');legend('closed loop frequency response','-3 dB line',3);subplot(212);semilogx(rpsaverage,systemfraveragephase,'b',rpsaverage,minus3averagephase,'g');grid on;xlabel('Frequency (rad/sec)');ylabel('Phase (deg)');legend('closed loop frequency response','-3 dB line',3);

Page 8

Page 9: Solutions to Magnetic Bearing Lab #5 Digital Controller Design for … · 2017. 10. 8. · The frequency response vectors C of the lead controller and N of the notch filter ... In

Magnetic Bearing: Digital Controller Design

% -----------------------------------------------exercise 3------------------------------------------------------------% to get the frequency of the second flexible rotor mode

%format short e % change the format%[abs(systemfraverage) rpsaverage'/2/pi]' % show the frequency response vector with the

frequencies

% generate automatical the frequency of the second flexible rotor modefl=1500*2*pi; % the chosen start frequency to search the

maximumfu=2500*2*pi; % the chosen end frequency to search the

maximumlowvalue=rps(1,1); % the next 5 line generate the indices

correspond to the chosen frequencieshighvalue=rps(1,length(rps));factor=length(rps)/(highvalue-lowvalue);startf=round(factor*(fl-lowvalue));endf=round(factor*(fu-lowvalue));systemfrsec=systemfr(startf:endf,1);rpssec=rps(1,startf:endf);

[systemfrmax,rpsindicesmax] = max(systemfrsec); % find the maximum value of systemfr and thecorresponding indices

disp(['the frequency of the second flexible rotor mode is ', num2str(rpssec(rpsindicesmax)), ' rad/sec']);disp(['the frequency of the second flexible rotor mode is ', num2str(rpssec(rpsindicesmax)/(2*pi)), ' Hz']);

Matlabcode Exercise 5 to 7:

% lab5 exercise 5 to 7

Ts=1/10000; % the chosen sampling rate

% -----------------------------------------------exercise 5------------------------------------------------------------% create the notch filter parametersAn=1; % An is chosen as described in lab3 page 10Q=3; % Q is chosen as described in lab3 solution

exercise 10omegan=2*pi*746; % omegan is chosen as described in lab3

solution exercise 10% create the controller parametersk=0.7; % the controller values are chosen as described

in lab4 solution exercise 8T=3*10^(-3);alpha=0.25849;T0=7.7547*10^(-5);

% create the numerator and denominator of the the lead controller and notch filterleadnum=[k*T k]; % generate the numerator of the lead controllerleadden=conv([alpha*T 1],[T0 1]); % generate the denominator of the lead

controllernotchnum=[An 0 An*omegan^2]; % generate the numerator of the notch filternotchden=[1 omegan/Q omegan^2]; % generate the denominator of the notch filter

% transforms the continuous notch filter in an equivalent discrete notch filter[an,bn,cn,dn]=tf2ss(notchnum,notchden); % convert to state space form[and,bnd,cnd,dnd]=c2dm(an,bn,cn,dn,Ts,'prewarp',omegan); % transfer to discrete state space[dnotchnum,dnotchden]=ss2tf(and,bnd,cnd,dnd); % convert to transfer function

Page 9

Page 10: Solutions to Magnetic Bearing Lab #5 Digital Controller Design for … · 2017. 10. 8. · The frequency response vectors C of the lead controller and N of the notch filter ... In

Magnetic Bearing: Digital Controller Design

% -----------------------------------------------exercise 6------------------------------------------------------------% to load the data the files has to be in the correct folder load lab2ex9gaverage_ver1_rpsg; % load the bearing frequency response vector g

and the frequency vector rps (identified andaveraged filtered in lab2)

rpsaverage=rps';gaverage=g; % generate gaverage to overwrite it belowload lab2ex9g_ver3_rpsg; % load the bearing frequency response vector g

and the frequency vector rps (identified in lab2) rps=rps';C=freqs(leadnum,leadden,rps)'; % generate the frequency response vector of the

lead controller at the frequencies measured in lab2

Caverage=freqs(leadnum,leadden,rpsaverage)'; % generate the frequency response vector of thelead controller at the averaged frequencies of lab2

N=freqs(notchnum,notchden,rps)'; % generate the frequency response vector of thenotch filter at the frequencies measured in lab 2

Naverage=freqs(notchnum,notchden,rpsaverage)'; % generate the frequency response vector of thenotch filter at the averaged frequencies of lab 2

% generate the open loop system frequency response vectoropenloop=g.*N.*C;openloopaverage=gaverage.*Naverage.*Caverage;

% Bode plot of the non averaged signalzeroabsdb=zeros(size(openloop)); % 0 dbzerophase=zeros(size(openloop)); % phase of 0 dbopenloopabsdb = 20*log10(abs(openloop)); % magnitude of the measured data in dbopenloopphase = angle(openloop)/pi*180; % phase angle of the measured data in degreefigure; subplot(211);semilogx(rps,openloopabsdb,'b',rps,zeroabsdb,'g');grid on;title('Bode Diagram of the open loop system transfer function (non-averaged signal)');ylabel('Magnitude (dB)');legend('open loop frequency response','0 dB line',3);subplot(212);semilogx(rps,openloopphase,'b',rps,zerophase,'g');grid on;xlabel('Frequency (rad/sec)');ylabel('Phase (deg)');legend('open loop frequency response','0 dB line',3);

% Bode plot of the averaged signalzeroaverageabsdb=zeros(size(openloopaverage)); % 0 dbzeroaveragephase=zeros(size(openloopaverage)); % phase of 0 dbopenloopaverageabsdb = 20*log10(abs(openloopaverage)); % magnitude of the averaged data in dbopenloopaveragephase = angle(openloopaverage)/pi*180; % phase angle of the averaged data in degreefigure; subplot(211);semilogx(rpsaverage,openloopaverageabsdb,'b',rpsaverage,zeroaverageabsdb,'g');grid on;title('Bode Diagram of the open loop system transfer function (averaged signal)');ylabel('Magnitude (dB)');legend('open loop frequency response','0 dB line',3);subplot(212);semilogx(rpsaverage,openloopaveragephase,'b',rpsaverage,zeroaveragephase,'g');grid on;xlabel('Frequency (rad/sec)');ylabel('Phase (deg)');legend('open loop frequency response','0 dB line',3);

Page 10

Page 11: Solutions to Magnetic Bearing Lab #5 Digital Controller Design for … · 2017. 10. 8. · The frequency response vectors C of the lead controller and N of the notch filter ... In

Magnetic Bearing: Digital Controller Design

% -----------------------------------------------exercise 7------------------------------------------------------------omegap=164*2*pi; % gain crossover frequency from exercise 6 % transforms the continuous lead controller in an equivalent discrete lead controller[al,bl,cl,dl]=tf2ss(leadnum,leadden); % convert to state space form[ald,bld,cld,dld]=c2dm(al,bl,cl,dl,Ts,'prewarp',omegap); % transfer to discrete state space[dleadnum,dleadden]=ss2tf(ald,bld,cld,dld); % convert to transfer function

Matlabcode Exercise 8:

% lab5 exercise 8

%----------------------------------to chose the parameter-----------------------------------------------------% sampling rateTs=1/10000;%notch filter parametersAn=1; % An is chosen as described in lab3 page 10Q=3; % Q is chosen as described in lab3 solution

exercise 10omegan=2*pi*746; % omegan is chosen as described in lab3

solution exercise 10%controller parametersk=0.7; % the controller values are chosen as described

in lab4 solution exercise 8T=3*10^(-3);alpha=0.25849;T0=7.7547*10^(-5);omegap=164*2*pi; % gain crossover frequency

%--------------------------------------------------------------------------------------------------------------% create the numerator and denominator of the the lead controller and notch filterleadnum=[k*T k]; % generate the numerator of the lead controllerleadden=conv([alpha*T 1],[T0 1]); % generate the denominator of the lead

controllernotchnum=[An 0 An*omegan^2]; % generate the numerator of the notch filternotchden=[1 omegan/Q omegan^2]; % generate the denominator of the notch filter

% transforms the continuous notch filter in an equivalent discrete notch filter[an,bn,cn,dn]=tf2ss(notchnum,notchden); % convert to state space form[and,bnd,cnd,dnd]=c2dm(an,bn,cn,dn,Ts,'prewarp',omegan); % transfer to discrete state space[dnotchnum,dnotchden]=ss2tf(and,bnd,cnd,dnd); % convert to transfer function

% transforms the continuous lead controller in an equivalent discrete lead controller[al,bl,cl,dl]=tf2ss(leadnum,leadden); % convert to state space form[ald,bld,cld,dld]=c2dm(al,bl,cl,dl,Ts,'prewarp',omegap); % transfer to discrete state space[dleadnum,dleadden]=ss2tf(ald,bld,cld,dld); % convert to transfer function

Matlabcode Exercise 12:

%lab5 exercise 12

%Define vectors of frequenciesrps=2*pi*logspace(1,5,801); % generate a logarithmical frequency vector from

10^1 to 10^5 Hz with 801 points

% Define the first filter parametersomegan=2*pi*7000;Q=3;

% Determine the first filter transfer function and frequency responsefnum=[omegan^2];

Page 11

Page 12: Solutions to Magnetic Bearing Lab #5 Digital Controller Design for … · 2017. 10. 8. · The frequency response vectors C of the lead controller and N of the notch filter ... In

Magnetic Bearing: Digital Controller Design

fden=[1 omegan/Q omegan^2];fsys=nd2sys(fnum,fden);vresp1=frsp(fsys,rps);

% Define the second filter parametersomegan2=2*pi*5000;Q2=1;

% Determine the second filter transfer function and frequency responsef2num=[omegan2^2];f2den=[1 omegan2/Q2 omegan2^2];f2sys=nd2sys(f2num,f2den);vresp2=frsp(f2sys,rps);

% Form varying matrix and plot via plotvresp1hz=scliv(vresp1,1/2/pi);vresp2hz=scliv(vresp2,1/2/pi);%vplot('bode_g',vresp1hz, vresp2hz);%subplot(2,1,1),xlabel('Frequency [Hz]');%subplot(2,1,2),xlabel('Frequency [Hz]');

% Bode plotvresp1hzabsdb = 20*log10(abs(vresp1hz));vresp1hzphase = angle(vresp1hz)/pi*180;vresp2hzabsdb = 20*log10(abs(vresp2hz));vresp2hzphase = angle(vresp2hz)/pi*180;figure; subplot(211);semilogx(rps/(2*pi),vresp1hzabsdb(1:801,1),'b',rps/(2*pi),vresp2hzabsdb(1:801,1),'g');xlim([10 10^5]);grid on;title('Bode Diagram of the anti-aliasing filter');ylabel('Magnitude (dB)');legend(['omegan1 = ',num2str(omegan/2/pi),' Hz; Q1 = ', num2str(Q)],['omegan2 = ',num2str(omegan2/2/pi),'Hz; Q2 = ', num2str(Q2)],3);subplot(212);semilogx(rps/(2*pi),vresp1hzphase(1:801,1),'b',rps/(2*pi),vresp2hzphase(1:801,1),'g');xlim([10 10^5]);grid on;xlabel('Frequency (Hz)');ylabel('Phase (deg)');legend(['omegan1 = ',num2str(omegan/2/pi),' Hz; Q1 = ', num2str(Q)],['omegan2 = ',num2str(omegan2/2/pi),'Hz; Q2 = ', num2str(Q2)],3);

Matlabcode Exercise 13 and 16:

%lab5 exercise 13RQ=10^6;RG=47.6*10^3;Q=2;omegan=2*pi*7000;RF2=(2.5*10^13*(RG+RQ))/(omegan*RG*RQ*(Q-0.5));RF1=10^18/(omegan^2*RF2);disp(['RF1 = ',num2str(RF1),' ohm']);disp(['RF2 = ',num2str(RF2),' ohm']);

Page 12