Browse Source

Band elimination response to input signal Matlab and Multisim init, Minor fixes

master
Apostolos Fanakis 6 years ago
parent
commit
91cf2713aa
  1. BIN
      Band Elimination Chebyshev/Multisim/band_elimination_chebyshev.ms14
  2. 133
      Band Elimination Chebyshev/band_elimination_design.m
  3. 29
      Band Pass Chebyshev/band_pass_design.m

BIN
Band Elimination Chebyshev/Multisim/band_elimination_chebyshev.ms14

Binary file not shown.

133
Band Elimination Chebyshev/band_elimination_design.m

@ -774,14 +774,6 @@ unit_adjustment_gain = 1/total_gain_high;
% unit % unit
unit_adjustment_feedback_resistor = 10*10^3*unit_adjustment_gain; unit_adjustment_feedback_resistor = 10*10^3*unit_adjustment_gain;
total_transfer_function = series(series(series( ...
high_pass_notch_units_transfer_functions(1,1), ...
high_pass_notch_units_transfer_functions(1,2)), ...
low_pass_notch_units_transfer_functions(1,1)), ...
low_pass_notch_units_transfer_functions(1,2));
total_transfer_function = total_transfer_function*unit_adjustment_gain;
fprintf(['\n' '===== GAIN ADJUSTMENT =====' '\n' ... fprintf(['\n' '===== GAIN ADJUSTMENT =====' '\n' ...
'A gain adjustment unit is needed to achieve 0dB attenuation at ' ... 'A gain adjustment unit is needed to achieve 0dB attenuation at ' ...
'pass band.\n' ... 'pass band.\n' ...
@ -791,48 +783,117 @@ fprintf(['\n' '===== GAIN ADJUSTMENT =====' '\n' ...
% ========== GAIN ADJUSTMENT END ========== % ========== GAIN ADJUSTMENT END ==========
%% ========== TRANSFER FUNCTIONS START ========== %% ========== TRANSFER FUNCTIONS STUDY START ==========
%{
ltiview(high_pass_notch_units_transfer_functions(1,1), ...
high_pass_notch_units_transfer_functions(1,2));
%}
%{ total_transfer_function = series(series(series( ...
ltiview(low_pass_notch_units_transfer_functions(1,1), ... high_pass_notch_units_transfer_functions(1,1), ...
high_pass_notch_units_transfer_functions(1,2)), ...
low_pass_notch_units_transfer_functions(1,1)), ...
low_pass_notch_units_transfer_functions(1,2)); low_pass_notch_units_transfer_functions(1,2));
%}
%{ total_transfer_function = total_transfer_function*unit_adjustment_gain;
ltiview(high_pass_notch_units_transfer_functions(1,1), ...
high_pass_notch_units_transfer_functions(1,2), ...
low_pass_notch_units_transfer_functions(1,1), ...
low_pass_notch_units_transfer_functions(1,2));
%}
%{ %{
ltiview(high_pass_notch_units_transfer_functions(1,1), ... % Plots each unit's frequency response
high_pass_notch_units_transfer_functions(1,2), ... for i=1:band_elimination_number_of_poles
low_pass_notch_units_transfer_functions(1,1), ... if i==1 || i==3
low_pass_notch_units_transfer_functions(1,2), ... plot_transfer_function( ...
total_transfer_function); high_pass_notch_units_transfer_functions(1,(i+1)/2), ...
%} (band_elimination_poles_radial_frequencies(1,i)/(2*pi)));
else
%ltiview(total_transfer_function); plot_transfer_function( ...
low_pass_notch_units_transfer_functions(1,i/2), ...
(band_elimination_poles_radial_frequencies(1,i)/(2*pi)));
end
end
%{ % Plots the total filter frequency response
plot_transfer_function(total_transfer_function, ... plot_transfer_function(total_transfer_function, ...
[specification_low_stop_frequency ... [specification_low_stop_frequency ...
specification_low_pass_frequency ... specification_low_pass_frequency ...
specification_central_frequency ... specification_central_frequency ...
specification_high_pass_frequency ... specification_high_pass_frequency ...
specification_high_stop_frequency]); specification_high_stop_frequency]);
% Plots the total filter attenuation function
plot_transfer_function(inv(total_transfer_function), ...
[specification_low_stop_frequency ...
specification_low_pass_frequency ...
specification_central_frequency ...
specification_high_pass_frequency ...
specification_high_stop_frequency]);
%} %}
% Clears unneeded variable from workspace %{
clearVars = {'total_transfer_function'}; ltiview(unit_transfer_function(1,1));
ltiview(unit_transfer_function(1,2));
ltiview(unit_transfer_function(1,3));
ltiview(unit_transfer_function(1,4));
ltiview(total_transfer_function);
ltiview(unit_transfer_function(1,1), unit_transfer_function(1,2), ...
unit_transfer_function(1,3), unit_transfer_function(1,4), ...
total_transfer_function);
%}
hold off
sampling_time_seconds = 60; % s
sampling_frequency_Fs = 80000; % Hz
sampling_period_T = 1/sampling_frequency_Fs; % s
sampling_time_vector = 0:sampling_period_T: ...
sampling_time_seconds-sampling_period_T;
sampling_length_L = length(sampling_time_vector);
frequency_vector = sampling_frequency_Fs/sampling_length_L* ...
(0:(sampling_length_L/2));
input_cos_signal_frequency_1 = specification_central_radial_frequency- ...
(specification_central_radial_frequency- ...
specification_low_stop_radial_frequency)/2;
input_cos_signal_frequency_2 = specification_central_radial_frequency+ ...
(specification_central_radial_frequency+ ...
specification_low_stop_radial_frequency)/3;
input_cos_signal_frequency_3 = 0.4*specification_low_pass_radial_frequency;
input_cos_signal_frequency_4 = 2.5*specification_high_pass_radial_frequency;
input_cos_signal_frequency_5 = 3*specification_high_pass_radial_frequency;
input_signal = 0.5*cos(input_cos_signal_frequency_1*sampling_time_vector)+ ...
0.8*cos(input_cos_signal_frequency_2*sampling_time_vector)+ ...
0.8*cos(input_cos_signal_frequency_3*sampling_time_vector)+ ...
0.6*cos(input_cos_signal_frequency_4*sampling_time_vector)+ ...
1.2*cos(input_cos_signal_frequency_5*sampling_time_vector);
system_output = lsim(total_transfer_function, input_signal, ...
sampling_time_vector);
% Plots only the first 500 samples
figure(1)
plot(sampling_time_vector(1:500), input_signal(1:500), ...
sampling_time_vector(1:500), system_output(1:500));
grid on
% Plots the power spectrum of the input signal
input_square_wave_fft = fft(input_signal);
Pyy = input_square_wave_fft.*conj(input_square_wave_fft)/sampling_length_L;
figure(2)
semilogx(frequency_vector,Pyy(1:sampling_length_L/2+1))
grid on
% Plots the power spectrum of the output signal
system_output_fft = fft(system_output, length(sampling_time_vector));
Pyy = system_output_fft.*conj(system_output_fft)/sampling_length_L;
figure(3)
semilogx(frequency_vector,Pyy(1:sampling_length_L/2+1))
grid on
% Clears unneeded variables from workspace
clearVars = {'temp', 'Pyy', 'frequency_vector', 'i' ...
'system_output', 'total_transfer_function', 'system_output_fft'};
clear(clearVars{:}) clear(clearVars{:})
clear clearVars clear clearVars
clear -regexp ^sampling_
clear -regexp ^input_
clear -regexp _transfer_functions$ clear -regexp _transfer_functions$
% ========== TRANSFER FUNCTIONS END ========== % ========== TRANSFER FUNCTIONS STUDY END ==========

29
Band Pass Chebyshev/band_pass_design.m

@ -376,7 +376,7 @@ units_central_frequency_gain = zeros([1 band_pass_number_of_poles]);
units_alpha = zeros([1 band_pass_number_of_poles]); units_alpha = zeros([1 band_pass_number_of_poles]);
units_Z2 = zeros([1 band_pass_number_of_poles]); units_Z2 = zeros([1 band_pass_number_of_poles]);
units_Z3 = zeros([1 band_pass_number_of_poles]); units_Z3 = zeros([1 band_pass_number_of_poles]);
unit_transfer_function = [tf(1) tf(1) tf(1) tf(1)]; unit_transfer_functions = [tf(1) tf(1) tf(1) tf(1)];
units_filter_central_frequency_gain = zeros([1 band_pass_number_of_poles]); units_filter_central_frequency_gain = zeros([1 band_pass_number_of_poles]);
for i=1:band_pass_number_of_poles for i=1:band_pass_number_of_poles
@ -442,10 +442,10 @@ for i=1:band_pass_number_of_poles
units_BW(1,i) ... units_BW(1,i) ...
band_pass_poles_radial_frequencies(1,i)^2]; band_pass_poles_radial_frequencies(1,i)^2];
%} %}
unit_transfer_function(i) = tf(unit_numerator, unit_denominator); unit_transfer_functions(i) = tf(unit_numerator, unit_denominator);
[units_filter_central_frequency_gain(1,i),phase] = ... [units_filter_central_frequency_gain(1,i),phase] = ...
bode(unit_transfer_function(i), ... bode(unit_transfer_functions(i), ...
design_geometric_central_radial_frequency); design_geometric_central_radial_frequency);
end end
@ -473,7 +473,7 @@ end
% Clears unneeded variables from workspace % Clears unneeded variables from workspace
clearVars = {'units_central_frequency_gain', 'i', 'units_alpha', ... clearVars = {'units_central_frequency_gain', 'i', 'units_alpha', ...
'unit_denominator', 'unit_numerator', 'unit_Z_parallel' ... 'unit_denominator', 'unit_numerator', 'unit_Z_parallel', 'phase' ...
'units_amplitude_scale_factors', 'units_frequency_scale_factors'}; 'units_amplitude_scale_factors', 'units_frequency_scale_factors'};
clear(clearVars{:}) clear(clearVars{:})
clear clearVars clear clearVars
@ -483,14 +483,14 @@ clear clearVars
%% ========== TRANSFER FUNCTIONS STUDY START ========== %% ========== TRANSFER FUNCTIONS STUDY START ==========
total_transfer_function = series(series(series( ... total_transfer_function = series(series(series( ...
unit_transfer_function(1), unit_transfer_function(2)), ... unit_transfer_functions(1), unit_transfer_functions(2)), ...
unit_transfer_function(3)), unit_transfer_function(4)); unit_transfer_functions(3)), unit_transfer_functions(4));
%{ %{
% Plots each unit's frequency response % Plots each unit's frequency response
for i=1:band_pass_number_of_poles for i=1:band_pass_number_of_poles
plot_transfer_function(unit_transfer_function(1,i), ... plot_transfer_function(unit_transfer_functions(1,i), ...
design_geometric_central_radial_frequency); (band_pass_poles_radial_frequencies(1,i)/(2*pi)));
end end
% Plots the total filter frequency response % Plots the total filter frequency response
@ -511,6 +511,7 @@ plot_transfer_function(inv(total_transfer_function), ...
specification_high_pass_frequency ... specification_high_pass_frequency ...
specification_high_stop_frequency]); specification_high_stop_frequency]);
%} %}
%{ %{
ltiview(unit_transfer_function(1,1)); ltiview(unit_transfer_function(1,1));
ltiview(unit_transfer_function(1,2)); ltiview(unit_transfer_function(1,2));
@ -549,10 +550,6 @@ input_signal = cos(input_cos_signal_frequency_1*sampling_time_vector)+ ...
0.6*cos(input_cos_signal_frequency_4*sampling_time_vector)+ ... 0.6*cos(input_cos_signal_frequency_4*sampling_time_vector)+ ...
0.5*cos(input_cos_signal_frequency_5*sampling_time_vector); 0.5*cos(input_cos_signal_frequency_5*sampling_time_vector);
[gain,phase] = ...
bode(total_transfer_function, ...
850*2*pi);
system_output = lsim(total_transfer_function, input_signal, ... system_output = lsim(total_transfer_function, input_signal, ...
sampling_time_vector); sampling_time_vector);
@ -579,12 +576,12 @@ semilogx(frequency_vector,Pyy(1:sampling_length_L/2+1))
grid on grid on
% Clears unneeded variables from workspace % Clears unneeded variables from workspace
clearVars = {'temp', 'Pyy', 'frequency_vector', ... clearVars = {'temp', 'Pyy', 'frequency_vector', 'system_output', ...
'system_output', 'system_output_fft'}; 'unit_transfer_functions', 'system_output_fft', ...
'total_transfer_function'};
clear(clearVars{:}) clear(clearVars{:})
clear clearVars clear clearVars
clear -regexp _transfer_function$
clear -regexp ^sampling_ clear -regexp ^sampling_
%clear -regexp ^input_ clear -regexp ^input_
% ========== TRANSFER FUNCTIONS STUDY END ========== % ========== TRANSFER FUNCTIONS STUDY END ==========
Loading…
Cancel
Save