필터 지우기
필터 지우기

unable to tune PID controller with matlab function block

조회 수: 2 (최근 30일)
Jose
Jose 2014년 2월 2일
답변: Arkadiy Turevskiy 2015년 3월 11일
I am trying to design controllers for 3-ph buck-type PWM rectifier. Attached is the model i am using to design the circuit. Inside the 'SVPWM' subsystem i am trying to design a current controller using PI block. The system plant model is a matlab function block. the code inside is given below. Basically, i am trying to generate a pwm waveform. Using a formula that takes input parameters as the 3 ph voltages and returns the duty cycle. using the duty cycle i create a certain kind of pwm pattern and return 1 or 0 to the 6 switches which produces dc current/voltage. using this dc current,Idc (feedback) i am trying to input to PI controller with its output going into the matlab function block. I get the error plant linearises to zero. can someone please help me tune this PI controller and teach me how???
Thanks a lot.....
if true
function [sector,sr,ss,st,s1,s2,s3,s4,s5,s6] = find_sector(t,angle,Van,Vbn,Vcn,Voref)
persistent y1; % store same duty values within the same sector
persistent y2; % store same duty values within the same sector
persistent y3; % store same duty values within the same sector
persistent ctr; % counter for number of sectors in total
persistent n; % number of the swithcing periods
carr_freq = 396*50;
switching_period = 1/carr_freq;
if isempty(y1) y1 = 0; end if isempty(y2) y2 = 0; end if isempty(y3) y3 = 0; end
if isempty(ctr) ctr = 0; end
if isempty(n) n = 0; end
s1 = nan; s2 = nan; s3 = nan; s4 = nan; s5 = nan; s6 = nan;
sr = 0.2; ss = 0.2; st = 0.2; sector = nan;
if(angle >= 0 && angle < 30) sector = 0; elseif(angle >= 30 && angle < 60) sector = 1; elseif(angle >= 60 && angle < 90) sector = 2; elseif(angle >= 90 && angle < 120) sector = 3; elseif(angle >= 120 && angle < 150) sector = 4; elseif(angle >= 150 && angle < 180) sector = 5; elseif(angle >= 180 && angle < 210) sector = 6; elseif(angle >= 210 && angle < 240) sector = 7; elseif(angle >= 240 && angle < 270) sector = 8; elseif(angle >= 270 && angle < 300) sector = 9; elseif(angle >= 300 && angle < 330) sector = 10; elseif(angle >= 330 && angle < 360) sector = 11; end
% calculate preliminary duty once every swithcing period
if(t >= ctr*switching_period) y1 = (Voref*abs(Van))/(Van*Van + Vbn*Vbn + Vcn*Vcn); y2 = (Voref*abs(Vbn))/(Van*Van + Vbn*Vbn + Vcn*Vcn); y3 = (Voref*abs(Vcn))/(Van*Van + Vbn*Vbn + Vcn*Vcn); ctr = ctr + 1; end
if(sector == 0 sector == 6) %sector = -1, -1 is for sector calculating algorithm, just ignore it. sr = y1; ss = (1 - y3 + td); st = y3;
elseif(sector == 1 sector == 7) sr = y1; ss = (1 - y1 + td); st = y3;
elseif(sector == 2 sector == 8) sr = (1 - y2 + td); ss = y2; st = y3;
elseif(sector == 3 sector == 9) sr = (1 - y3 + td); ss = y2; st = y3;
elseif(sector == 4 sector == 10) sr = y1; ss = y2; st = (1 - y1 + td);
elseif(sector == 5 sector == 11) sr = y1; ss = y2; st = (1 - y2 + td);
end
% change duty ratio to ON time in seconds
on_time_sr = sr*(1/carr_freq); on_time_ss = ss*(1/carr_freq); on_time_st = st*(1/carr_freq);
% _______ % ___| h _v____
% h = hill and v = valley, swithching pattern generation for 6 switches for %each of 12 (0-11) sector % s1, s3, s5 -> odd/top switches % s2, s4, s6 -> even/bottom switches
if(sector == 0) s2 = 0; s3 = 0; s5 = 0; pattern = 'v'; [s1,n] = SLO_switching(on_time_sr,carr_freq,t,n,pattern); [s6,n] = SLO_switching(on_time_st,carr_freq,t,n,pattern); pattern = 'h'; [s4,n] = SLO_switching(on_time_ss,carr_freq,t,n,pattern);
elseif(sector == 1) s2 = 0; s4 = 0; s5 = 0; pattern = 'v'; [s1,n] = SLO_switching(on_time_sr,carr_freq,t,n,pattern); [s6,n] = SLO_switching(on_time_st,carr_freq,t,n,pattern); pattern = 'h'; [s3,n] = SLO_switching(on_time_ss,carr_freq,t,n,pattern);
elseif(sector == 2) s2 = 0; s4 = 0; s5 = 0; pattern = 'v'; [s3,n] = SLO_switching(on_time_ss,carr_freq,t,n,pattern); [s6,n] = SLO_switching(on_time_st,carr_freq,t,n,pattern); pattern = 'h'; [s1,n] = SLO_switching(on_time_sr,carr_freq,t,n,pattern);
elseif(sector == 3) s1 = 0; s4 = 0; s5 = 0; pattern = 'v'; [s3,n] = SLO_switching(on_time_ss,carr_freq,t,n,pattern); [s6,n] = SLO_switching(on_time_st,carr_freq,t,n,pattern); pattern = 'h'; [s2,n] = SLO_switching(on_time_sr,carr_freq,t,n,pattern);
elseif(sector == 4) s1 = 0; s4 = 0; s5 = 0; pattern = 'v'; [s2,n] = SLO_switching(on_time_sr,carr_freq,t,n,pattern); [s3,n] = SLO_switching(on_time_ss,carr_freq,t,n,pattern); pattern = 'h'; [s6,n] = SLO_switching(on_time_st,carr_freq,t,n,pattern);
elseif(sector == 5) s1 = 0; s4 = 0; s6 = 0; pattern = 'v'; [s2,n] = SLO_switching(on_time_sr,carr_freq,t,n,pattern); [s3,n] = SLO_switching(on_time_ss,carr_freq,t,n,pattern); pattern = 'h'; [s5,n] = SLO_switching(on_time_st,carr_freq,t,n,pattern);
elseif(sector == 6) s1 = 0; s4 = 0; s6 = 0; pattern = 'v'; [s2,n] = SLO_switching(on_time_sr,carr_freq,t,n,pattern); [s5,n] = SLO_switching(on_time_st,carr_freq,t,n,pattern); pattern = 'h'; [s3,n] = SLO_switching(on_time_ss,carr_freq,t,n,pattern);
elseif(sector == 7) s1 = 0; s3 = 0; s6 = 0; pattern = 'v'; [s2,n] = SLO_switching(on_time_sr,carr_freq,t,n,pattern); [s5,n] = SLO_switching(on_time_st,carr_freq,t,n,pattern); pattern = 'h'; [s4,n] = SLO_switching(on_time_ss,carr_freq,t,n,pattern);
elseif(sector == 8) s1 = 0; s3 = 0; s6 = 0; pattern = 'v'; [s4,n] = SLO_switching(on_time_ss,carr_freq,t,n,pattern); [s5,n] = SLO_switching(on_time_st,carr_freq,t,n,pattern); pattern = 'h'; [s2,n] = SLO_switching(on_time_sr,carr_freq,t,n,pattern);
elseif(sector == 9) s2 = 0; s3 = 0; s6 = 0; pattern = 'v'; [s4,n] = SLO_switching(on_time_ss,carr_freq,t,n,pattern); [s5,n] = SLO_switching(on_time_st,carr_freq,t,n,pattern); pattern = 'h'; [s1,n] = SLO_switching(on_time_sr,carr_freq,t,n,pattern);
elseif(sector == 10) s2 = 0; s3 = 0; s6 = 0; pattern = 'v'; [s1,n] = SLO_switching(on_time_sr,carr_freq,t,n,pattern); [s4,n] = SLO_switching(on_time_ss,carr_freq,t,n,pattern); pattern = 'h'; [s5,n] = SLO_switching(on_time_st,carr_freq,t,n,pattern);
elseif(sector == 11) s2 = 0; s3 = 0; s5 = 0; pattern = 'v'; [s1,n] = SLO_switching(on_time_sr,carr_freq,t,n,pattern); [s4,n] = SLO_switching(on_time_ss,carr_freq,t,n,pattern); pattern = 'h'; [s6,n] = SLO_switching(on_time_st,carr_freq,t,n,pattern);
end
% Function = create symmetrical Switching Loss Optimised (SLO) pattern through %amplitude control every 1us
% Inputs = switch_output-> 1/0, n = same as ctr in the find_sector function, %count number of sectors % Outputs =
function [switch_output,n] = SLO_switching(on_time,carr_freq,t,n,pattern)
persistent amplitude; % output is zero if niether of conidtions match
if isempty(amplitude) amplitude = 0; end
% divide on time of phase a/s or b/r or c/t into half half_on_time = on_time/2; switching_period = (1/carr_freq);
if( (t >= n*switching_period) && (t < (n*switching_period + half_on_time))) if(pattern == 'v') amplitude = 1; elseif(pattern == 'h') amplitude = 0; end elseif( (t >= (n*switching_period + half_on_time)) && (t <= (((n+1)*switching_period) - half_on_time))) if(pattern == 'v') amplitude = 0; elseif(pattern == 'h') amplitude = 1; end elseif((t > (((n+1)*switching_period) - half_on_time)) && (t < (n+1)*switching_period)) if(pattern == 'v') amplitude = 1; elseif(pattern == 'h') amplitude = 0; end elseif(t >= (((n+1)*switching_period) - (1e-6))) % check and increment n (go to next switching period) one simulation time step ahead n = n + 1; end switch_output = amplitude;
end

답변 (1개)

Arkadiy Turevskiy
Arkadiy Turevskiy 2015년 3월 11일
Take a look at this video and try to follow the shown approach. Step by step instructions are here .

카테고리

Help CenterFile Exchange에서 PID Controller Tuning에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by