From 64f83f0da93ef7dcf946f7f20d87f08d768f66c3 Mon Sep 17 00:00:00 2001 From: Apostolof Date: Thu, 16 Aug 2018 14:10:42 +0300 Subject: [PATCH] Complete band elimination units and transfer functions --- .../band_elimination_design.m | 202 ++++++++++++++++-- 1 file changed, 186 insertions(+), 16 deletions(-) diff --git a/Band Elimination Chebyshev/band_elimination_design.m b/Band Elimination Chebyshev/band_elimination_design.m index 3b9a616..3bdeb6f 100644 --- a/Band Elimination Chebyshev/band_elimination_design.m +++ b/Band Elimination Chebyshev/band_elimination_design.m @@ -390,8 +390,8 @@ clear -regexp ^transformation_ % grouped with a zero at 0.0 + 15707.96 i, resulting in a low pass notch. % ------------------------------------------------------------------------- -% Two low pass notch units are required to implement the desired band -% elimination filter. +% Two low pass notch units and two high pass notch units are required to +% implement the desired band elimination filter. % ========== ZEROS-POLES GROUPING END ========== @@ -418,18 +418,20 @@ high_pass_notch_units_transfer_functions = [tf(1) tf(1)]; for i=1:2 unit_index = i*2-1; + + % normalized_pole_radial_frequency = 1; + normalized_transfer_function_zero = ... + abs(band_elimination_transfer_function_zeros(1,i))/ ... + band_elimination_poles_radial_frequencies(1,unit_index); % Calculates k1 design parameter using the eq. 7-135 - high_pass_notch_units_k1(1,i) = ... - band_elimination_poles_radial_frequencies(1,unit_index)^2/ ... - abs(band_elimination_transfer_function_zeros(1,i))^2-1; + high_pass_notch_units_k1(1,i) = 1/normalized_transfer_function_zero^2-1; % Calculates k2 design parameter using the eq. 7-136 temp = (2+high_pass_notch_units_k1(1,i))* ... band_elimination_poles_Q(1,unit_index)^2; high_pass_notch_units_k2(1,i) = temp/(temp+1); % Calculates k (unit's gain at high frequencies) using the eq. 7-137 high_pass_notch_units_gain_high(1,i) = high_pass_notch_units_k2(1,i)* ... - (band_elimination_poles_radial_frequencies(1,unit_index)^2/ ... - abs(band_elimination_transfer_function_zeros(1,i))^2); + (1/normalized_transfer_function_zero^2); % Calculates R2 using the eq. 7-138 high_pass_notch_units_R2(1,i) = band_elimination_poles_Q(1,unit_index)^2* ... (high_pass_notch_units_k1(1,i)+2)^2; @@ -475,15 +477,15 @@ for i=1:2 (high_pass_notch_units_frequency_scale_factors(1,i)* ... high_pass_notch_units_amplitude_scale_factors(1,i)); - % Builds unit's transfer function + % Builds unit's transfer function using the eq. 7-129, 7-130, 7-131 high_pass_notch_unit_numerator = [1 ... 0 ... - 1/(high_pass_notch_units_R2(1,i)*high_pass_notch_units_C(1,i)^2* ... + 1/(high_pass_notch_units_R1(1,i)*high_pass_notch_units_R2(1,i)*high_pass_notch_units_C(1,i)^2* ... (high_pass_notch_units_k1(1,i)+1))]; high_pass_notch_unit_denominator = [1 ... (2+high_pass_notch_units_k1(1,i))/ ... (high_pass_notch_units_R2(1,i)*high_pass_notch_units_C(1,i)) ... - 1/(high_pass_notch_units_R2(1,i)*high_pass_notch_units_C(1,i)^2)]; + 1/(high_pass_notch_units_R1(1,i)*high_pass_notch_units_R2(1,i)*high_pass_notch_units_C(1,i)^2)]; high_pass_notch_units_transfer_functions(1,i) = tf( ... high_pass_notch_unit_numerator, high_pass_notch_unit_denominator); @@ -492,18 +494,186 @@ for i=1:2 high_pass_notch_units_gain_high(1,i); end -plot_transfer_function(high_pass_notch_units_transfer_functions(1,1)); -%ltiview(high_pass_notch_units_transfer_functions(1,1)); +% Low pass notch units 2 and 4 +% Initializes necessary arrays, each array is 1X2, the first element (1,1) +% corresponds to the first unit (unit 2) and the second element (1,2) to +% second unit (unit 4). +low_pass_notch_units_resistors_1 = zeros([1 2]); +low_pass_notch_units_resistors_2 = zeros([1 2]); +low_pass_notch_units_resistors_3 = zeros([1 2]); +low_pass_notch_units_resistors_4 = zeros([1 2]); +low_pass_notch_units_resistors_5 = zeros([1 2]); +low_pass_notch_units_capacitors = zeros([1 2]); +low_pass_notch_units_gains_high = zeros([1 2]); +low_pass_notch_units_gains_low = zeros([1 2]); +low_pass_notch_units_frequency_scale_factors = zeros([1 2]); +low_pass_notch_units_amplitude_scale_factors = zeros([1 2]); +low_pass_notch_units_transfer_functions = [tf(1) tf(1)]; + +for i=1:2 + unit_index = i*2; + + % normalized_inverse_pole_radial_frequency = 1; + normalized_transfer_function_zero = ... + abs(band_elimination_transfer_function_zeros(1,unit_index))/ ... + band_elimination_poles_radial_frequencies(1,unit_index); + + % According to the design method outlined in 7.6-B, at page 35 + low_pass_notch_units_resistors_1(1,i) = 1; % Ohm + % Calculates the capacity of the normalized circuit capacitors using + % the eq. 7-150 + low_pass_notch_units_capacitors(1,i) = 1/ ... + (2*band_elimination_poles_Q(1,unit_index)); % Farad + % Calculates the resistance of R2 using the same equations (7-150) + low_pass_notch_units_resistors_2(1,i) = 4* ... + band_elimination_poles_Q(1,unit_index)^2; % Ohm + % Calculates the resistance of R5 using the eq. 7-152 + low_pass_notch_units_resistors_5(1,i) = ... + (4*band_elimination_poles_Q(1,unit_index)^2)/ ... + (normalized_transfer_function_zero^2-1); % Ohm + low_pass_notch_units_resistors_4(1,i) = 1; % Ohm + % Calculates the resistance of R3 using the eq. 7-155 + low_pass_notch_units_resistors_3(1,i) = ... + (normalized_transfer_function_zero^2)/ ... + (2*band_elimination_poles_Q(1,unit_index)^2); % Ohm + % Calculates the gain of this unit in high frequencies using the eq. 7-143 + low_pass_notch_units_gains_high(1,i) = ... + (low_pass_notch_units_resistors_4(1,i))/ ... + (low_pass_notch_units_resistors_3(1,i)+ ... + low_pass_notch_units_resistors_4(1,i)); + % Calculates the gain of this unit in low frequencies using the + % eq. 7-146, 7-147, 7-148, setting s = 0 + low_pass_notch_units_gains_low(1,i) = ... + low_pass_notch_units_gains_high(1,i)* ... + normalized_transfer_function_zero^2; + + % Performs scaling + low_pass_notch_units_frequency_scale_factors(1,i) = ... + band_elimination_poles_radial_frequencies(1,unit_index); + % AEM(4) = 1, so the scaling will be performed to achieve a capacitor + % value of 0.1uF using the eq. 6-33 + low_pass_notch_units_amplitude_scale_factors(1,i) = ... + low_pass_notch_units_capacitors(1,i)/ ... + (low_pass_notch_units_frequency_scale_factors(1,i)*0.1*10^(-6)); + + low_pass_notch_units_resistors_1(1,i) = ... + low_pass_notch_units_resistors_1(1,i)* ... + low_pass_notch_units_amplitude_scale_factors(1,i); % Ohm + low_pass_notch_units_resistors_2(1,i) = ... + low_pass_notch_units_resistors_2(1,i)* ... + low_pass_notch_units_amplitude_scale_factors(1,i); % Ohm + low_pass_notch_units_resistors_3(1,i) = ... + low_pass_notch_units_resistors_3(1,i)* ... + low_pass_notch_units_amplitude_scale_factors(1,i); % Ohm + low_pass_notch_units_resistors_4(1,i) = ... + low_pass_notch_units_resistors_4(1,i)* ... + low_pass_notch_units_amplitude_scale_factors(1,i); % Ohm + low_pass_notch_units_resistors_5(1,i) = ... + low_pass_notch_units_resistors_5(1,i)* ... + low_pass_notch_units_amplitude_scale_factors(1,i); % Ohm + low_pass_notch_units_capacitors(1,i) = 0.1*10^(-6); % Farad + + % Builds unit's transfer function + % Builds numerator and denominator of the transfer function using the + % eq. 7-146, 7-147 & 7-148 + unit_numerator = [1 ... + (((low_pass_notch_units_gains_high(1,i)-1)/ ... + (low_pass_notch_units_gains_high(1,i)* ... + low_pass_notch_units_resistors_1(1,i)* ... + low_pass_notch_units_capacitors(1,i)))+ ... + (2/(low_pass_notch_units_resistors_2(1,i)* ... + low_pass_notch_units_capacitors(1,i)))+ ... + (2/(low_pass_notch_units_resistors_5(1,i)* ... + low_pass_notch_units_capacitors(1,i)))) ... + (1/(low_pass_notch_units_resistors_1(1,i)* ... + low_pass_notch_units_resistors_5(1,i)* ... + low_pass_notch_units_capacitors(1,i)^2)+ ... + 1/(low_pass_notch_units_resistors_1(1,i)* ... + low_pass_notch_units_resistors_2(1,i)* ... + low_pass_notch_units_capacitors(1,i)^2))]; + unit_denominator = [1 ... + 2/(low_pass_notch_units_resistors_2(1,i)* ... + low_pass_notch_units_capacitors(1,i)) ... + 1/(low_pass_notch_units_resistors_1(1,i)* ... + low_pass_notch_units_resistors_2(1,i)* ... + low_pass_notch_units_capacitors(1,i)^2)]; + + low_pass_notch_units_transfer_functions(1,i) = ... + tf(unit_numerator, unit_denominator); + low_pass_notch_units_transfer_functions(1,i) = ... + low_pass_notch_units_transfer_functions(1,i)* ... + low_pass_notch_units_gains_high(1,i); +end + +% Clears unneeded variable from workspace +clearVars = {'i', 'temp', 'unit_index', 'normalized_transfer_function_zero'}; +clear(clearVars{:}) +clear clearVars +clear -regexp _numerator$ +clear -regexp _denominator$ + +% ========== UNITS IMPLEMENTATION END ========== + +%% ========== GAIN ADJUSTMENT START ========== + +total_gain_high = high_pass_notch_units_gain_high(1,1)* ... + high_pass_notch_units_gain_high(1,2)* ... + low_pass_notch_units_gains_high(1,1)* ... + low_pass_notch_units_gains_high(1,2); +unit_adjustment_gain = 1/total_gain_high; +% We arbitrarily choose to use a 10KOhm series resistor in the adjustment +% unit +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; %{ ltiview(high_pass_notch_units_transfer_functions(1,1), ... - high_pass_notch_units_transfer_functions(1,2), ... - series(high_pass_notch_units_transfer_functions(1,1), ... - high_pass_notch_units_transfer_functions(1,2))); + high_pass_notch_units_transfer_functions(1,2)); %} -% ========== UNITS IMPLEMENTATION END ========== +%{ +ltiview(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), ... + 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), ... + 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); +%} +%ltiview(total_transfer_function); +% +plot_transfer_function(total_transfer_function, ... + [specification_central_frequency ... + design_half_power_radial_frequency/(2*pi) ... + specification_low_stop_frequency ... + specification_low_pass_frequency ... + specification_high_pass_frequency ... + specification_high_stop_frequency]); +% + +% Clears unneeded variable from workspace +clearVars = {'total_transfer_function'}; +clear(clearVars{:}) +clear clearVars +clear -regexp _transfer_functions$ +% ========== GAIN ADJUSTMENT END ========== \ No newline at end of file