diff --git a/Band Elimination Chebyshev/Multisim/band_elimination_chebyshev.ms14 (Security copy) b/Band Elimination Chebyshev/Multisim/band_elimination_chebyshev.ms14 (Security copy) deleted file mode 100644 index b2e5b55..0000000 Binary files a/Band Elimination Chebyshev/Multisim/band_elimination_chebyshev.ms14 (Security copy) and /dev/null differ diff --git a/Band Pass Chebyshev/Multisim/band_pass_chebyshev.ms14 (Security copy) b/Band Pass Chebyshev/Multisim/band_pass_chebyshev.ms14 (Security copy) deleted file mode 100644 index 6c70b32..0000000 Binary files a/Band Pass Chebyshev/Multisim/band_pass_chebyshev.ms14 (Security copy) and /dev/null differ diff --git a/Low Pass Inverse Chebyshev/Multisim/low_pass_inversed_chebyshev.ms14 b/Low Pass Inverse Chebyshev/Multisim/low_pass_inversed_chebyshev.ms14 new file mode 100644 index 0000000..23da8d5 Binary files /dev/null and b/Low Pass Inverse Chebyshev/Multisim/low_pass_inversed_chebyshev.ms14 differ diff --git a/Low Pass Inverse Chebyshev/low_pass_design.m b/Low Pass Inverse Chebyshev/low_pass_design.m new file mode 100644 index 0000000..3fa958b --- /dev/null +++ b/Low Pass Inverse Chebyshev/low_pass_design.m @@ -0,0 +1,349 @@ +% AUTHOR : Apostolos Fanakis +% $DATE : 02-May-2018 17:21:18 $ +% $Revision : 1.00 $ +% DEVELOPED : 9.0.0.341360 (R2016a) +% FILENAME : low_pass_design_single.m +% AEM : 8261 + +%% ========== DESIGN SPECIFICATIONS START ========== +% Figures out design specifications according to my AEM number + +AEM = [8 2 6 1]; + +if AEM(3)<3 + design_param_m = 1; +elseif AEM(3)<7 + design_param_m = 2; +else + design_param_m = 3; +end + +specification_pass_frequency = (1.1*(3+design_param_m))*1000; % Hz +specification_pass_radial_frequency = ... + specification_pass_frequency*(2*pi); % rad/s + +specification_stop_frequency = 2.1*specification_pass_frequency; % Hz +specification_stop_radial_frequency = ... + specification_stop_frequency*(2*pi); % rad/s + +specification_min_stop_attenuation = 23+(max(1,AEM(3))-5)*(3/4); % dB +specification_max_pass_attenuation = 0.6+((max(1,AEM(4))-5)/16); % dB + +clear design_param_m + +% ========== DESIGN SPECIFICATIONS END ========== + +%% ========== NORMALIZED DESIGN START ========== +% Calculates normalized design specifications and designs a normalized +% filter using them + +normalized_pass_radial_frequency = specification_pass_radial_frequency/ ... + specification_stop_radial_frequency; % rad/s +% normalized_stop_radial_frequency = 1; % Hz (stop_frequency/stop_frequency) + +% Calculates the filter's order using the eq. 9-137 +design_filter_order = ceil( ... + acosh(((10^(specification_min_stop_attenuation/10)-1)/ ... + (10^(specification_max_pass_attenuation/10)-1))^(1/2)) ... + /acosh(1/normalized_pass_radial_frequency)); +% Calculates epsilon parameter using the eq. 9-123 +epsilon_parameter = 1/(10^(specification_min_stop_attenuation/10)-1)^(1/2); + +% Calculates alpha using the eq. ?? wtf is this? =========^^^^^^^^^^^^^^^^^^&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&========== +alpha_parameter = asinh(1/epsilon_parameter)/design_filter_order; + +% Calculates the frequency at which half power occurs using the eq. 9-139 +design_half_power_radial_frequency = specification_stop_radial_frequency/ ... + (cosh(acosh(1/epsilon_parameter)/design_filter_order)); % rad/s + +% ----- +% Calculates stable poles, zeros, angles and other characteristic sizes +% using the Guillemin algorithm +% ----- + +% Initializes necessary variables +design_number_of_poles = idivide(design_filter_order,int32(2),'ceil'); +% Creates five vector arrays of dimensions [1 * number_of_poles] filled +% with zeros to store: +% - the Butterworth angles with reference to the negative horizontal axes, +% - the real parts of the poles, +% - the imaginary parts of the poles, +% - the radial frequencies (Omega0) of the poles and +% - the Q's of the poles (both the Chebyshev and Inverse Chebyshev poles +% have the same Q's) +design_butterworth_angles = zeros([1 design_number_of_poles]); +chebyshev_poles_real_parts = zeros([1 design_number_of_poles]); +chebyshev_poles_imaginary_parts = zeros([1 design_number_of_poles]); +chebyshev_poles_radial_frequencies = zeros([1 design_number_of_poles]); +inverse_chebyshev_poles_Q = zeros([1 design_number_of_poles]); + +% Calculates the Butterworth angles using the method suggested in chapter +% 9 (page 10) of the course notes and then uses them to calculate the +% inverse Chebyshev poles +if mod(design_filter_order,2)~=0 % Odd number of poles + % First pole has a zero angle + design_butterworth_angles(1,1)=0; + % The rest of the poles are scattered in the left half pane with + % equal angles + % Theta is a helper parameter + theta=180/design_filter_order; + + % Calculates the first pole's real part using the eq. 9-102 + chebyshev_poles_real_parts(1,1) = -sinh(alpha_parameter)* ... + cosd(design_butterworth_angles(1,1)); + % Calculates the first pole's imaginary part using the eq. 9-103 + chebyshev_poles_imaginary_parts(1,1) = cosh(alpha_parameter)* ... + sind(design_butterworth_angles(1,1)); + % Calculates the first pole's radial frequency using the eq. 9-150 + chebyshev_poles_radial_frequencies(1,1) = ... + (chebyshev_poles_real_parts(1,1)^2+ ... + chebyshev_poles_imaginary_parts(1,1)^2)^(1/2); + % Calculates the first pole's Q using the eq. 9-151 + inverse_chebyshev_poles_Q(1,1) = 1/ ... + (2*cos(atan(chebyshev_poles_imaginary_parts(1,1)/ ... + chebyshev_poles_real_parts(1,1)))); + + % Calculates the rest of the poles in the same way + for i=2:design_number_of_poles + design_butterworth_angles(1,i)=double((i-1)*theta); + % Pole's real part, eq. 9-102 + chebyshev_poles_real_parts(1,i) = -sinh(alpha_parameter)* ... + cosd(design_butterworth_angles(1,i)); + % Pole's imaginary part, eq. 9-103 + chebyshev_poles_imaginary_parts(1,i) = cosh(alpha_parameter)* ... + sind(design_butterworth_angles(1,i)); + % Pole's radial frequency, eq. 9-150 + chebyshev_poles_radial_frequencies(1,i) = ... + (chebyshev_poles_real_parts(1,i)^2+ ... + chebyshev_poles_imaginary_parts(1,i)^2)^(1/2); + % Pole's Q, eq. 9-151 + inverse_chebyshev_poles_Q(1,i) = 1/ ... + (2*cos(atan(chebyshev_poles_imaginary_parts(1,i)/ ... + chebyshev_poles_real_parts(1,i)))); + end +else % Even number of poles + % Theta is a helper parameter + theta=90/design_number_of_poles; + + for i=1:design_number_of_poles + design_butterworth_angles(1,i)=double(90)/ ... + double(design_filter_order)+double((i-1)*theta); + % Pole's real part, eq. 9-102 + chebyshev_poles_real_parts(1,i) = -sinh(alpha_parameter)* ... + cosd(design_butterworth_angles(1,i)); + % Pole's imaginary part, eq. 9-103 + chebyshev_poles_imaginary_parts(1,i) = cosh(alpha_parameter)* ... + sind(design_butterworth_angles(1,i)); + % Pole's radial frequency, eq. 9-150 + chebyshev_poles_radial_frequencies(1,i) = ... + (chebyshev_poles_real_parts(1,i)^2+ ... + chebyshev_poles_imaginary_parts(1,i)^2)^(1/2); + % Pole's Q, eq. 9-151 + inverse_chebyshev_poles_Q(1,i) = 1/ ... + (2*cos(atan(chebyshev_poles_imaginary_parts(1,i)/ ... + chebyshev_poles_real_parts(1,i)))); + end +end + +% Initializes array to hold the inversed poles +inverse_chebyshev_poles_radial_frequencies = ... + zeros([1 design_number_of_poles]); +% Calculates inverse Chebyshev poles by inversing the Chebyshev poles +% using the eq. 9-146 +for i=1:design_number_of_poles + inverse_chebyshev_poles_radial_frequencies(1,i) = 1/ ... + chebyshev_poles_radial_frequencies(1,i); +end + +% Initializes array to hold the transfer function zeros and a temporary +% helper variable +inverse_chebyshev_transfer_function_zeros = ... + zeros([1 length(design_butterworth_angles)]); +temp_index = 1; +% Calculates the transfer function's zeros using the eq. 9-143 +for i=1:2:design_filter_order + inverse_chebyshev_transfer_function_zeros(1,temp_index) = ... + sec((i*pi)/(2*design_filter_order)); + temp_index = temp_index + 1; +end + +% Clears unneeded variable from workspace +clearVars = {'theta', 'i', 'temp_index', 'alpha_parameter' ... + 'epsilon_parameter', 'normalized_pass_radial_frequency'}; +clear(clearVars{:}) +clear clearVars +clear -regexp ^chebyshev_ + +% ========== NORMALIZED DESIGN END ========== + +%% ========== ZEROS-POLES GROUPING START ========== + +% ------------------------------------------------------------------------- +% Unit 1 has a pole pair with Q equal to 0.5822, radial frequency equal to +% 0.9631 rad/s and is grouped with a zero at 1.0824, resulting in a low +% pass notch. +% ------------------------------------------------------------------------- +% Unit 1 has a pole pair with Q equal to 1.8086, radial frequency equal to +% 0.7484 rad/s and is grouped with a zero at 2.6131, resulting in a low +% pass notch. +% ------------------------------------------------------------------------- + +% Two low pass notch units are required to implement the desired low pass +% filter. + +% ========== ZEROS-POLES GROUPING END ========== + +%% ========== UNITS IMPLEMENTATION START ========== +% AEM(3) = 6, so the circuit shown in 7.23 is going to be used for the low +% pass notch units. + +% Initializes necessary arrays, each array is 1X2, the first element (1,1) +% corresponds to the first unit and the second element (1,2) to second unit. +unit_low_pass_notch_resistors_1 = zeros([1 2]); +unit_low_pass_notch_resistors_2 = zeros([1 2]); +unit_low_pass_notch_resistors_3 = zeros([1 2]); +unit_low_pass_notch_resistors_4 = zeros([1 2]); +unit_low_pass_notch_resistors_5 = zeros([1 2]); +unit_low_pass_notch_capacitors = zeros([1 2]); +unit_low_pass_notch_gains_high = zeros([1 2]); +unit_low_pass_notch_gains_low = zeros([1 2]); +unit_frequency_scale_factors = zeros([1 2]); +unit_amplitude_scale_factors = zeros([1 2]); +unit_transfer_function = [tf(1) tf(1)]; + +for i=1:design_number_of_poles + % normalized_inverse_pole_radial_frequency = 1; + normalized_transfer_function_zero = ... + inverse_chebyshev_transfer_function_zeros(1,i)/ ... + inverse_chebyshev_poles_radial_frequencies(1,i); + + % According to the design method outlined in 7.6-B, at page 35 + unit_low_pass_notch_resistors_1(1,i) = 1; % Ohm + % Calculates the capacity of the normalized circuit capacitors using + % the eq. 7-150 + unit_low_pass_notch_capacitors(1,i) = 1/ ... + (2*inverse_chebyshev_poles_Q(1,i)); % Farad + % Calculates the resistance of R2 using the same equations (7-150) + unit_low_pass_notch_resistors_2(1,i) = 4* ... + inverse_chebyshev_poles_Q(1,i)^2; % Ohm + % Calculates the resistance of R5 using the eq. 7-152 + unit_low_pass_notch_resistors_5(1,i) = ... + (4*inverse_chebyshev_poles_Q(1,i)^2)/ ... + (normalized_transfer_function_zero^2-1); % Ohm + unit_low_pass_notch_resistors_4(1,i) = 1; % Ohm + % Calculates the resistance of R3 using the eq. 7-155 + unit_low_pass_notch_resistors_3(1,i) = ... + (normalized_transfer_function_zero^2)/ ... + (2*inverse_chebyshev_poles_Q(1,i)^2); % Ohm + % Calculates the gain of this unit in high frequencies using the eq. 7-143 + unit_low_pass_notch_gains_high(1,i) = ... + (unit_low_pass_notch_resistors_4(1,i))/ ... + (unit_low_pass_notch_resistors_3(1,i)+ ... + unit_low_pass_notch_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 + unit_low_pass_notch_gains_low(1,i) = ... + unit_low_pass_notch_gains_high(1,i)* ... + normalized_transfer_function_zero^2; + + % Performs scaling + unit_frequency_scale_factors(1,i) = ... + specification_stop_radial_frequency* ... + inverse_chebyshev_poles_radial_frequencies(1,i); + % AEM(4) = 1, so the scaling will be performed to achieve a capacitor + % value of 0.1uF using the eq. 6-33 + unit_amplitude_scale_factors(1,i) = ... + unit_low_pass_notch_capacitors(1,i)/ ... + (unit_frequency_scale_factors(1,i)*0.1*10^(-6)); + + unit_low_pass_notch_resistors_1(1,i) = ... + unit_low_pass_notch_resistors_1(1,i)* ... + unit_amplitude_scale_factors(1,i); % Ohm + unit_low_pass_notch_resistors_2(1,i) = ... + unit_low_pass_notch_resistors_2(1,i)* ... + unit_amplitude_scale_factors(1,i); % Ohm + unit_low_pass_notch_resistors_3(1,i) = ... + unit_low_pass_notch_resistors_3(1,i)* ... + unit_amplitude_scale_factors(1,i); % Ohm + unit_low_pass_notch_resistors_4(1,i) = ... + unit_low_pass_notch_resistors_4(1,i)* ... + unit_amplitude_scale_factors(1,i); % Ohm + unit_low_pass_notch_resistors_5(1,i) = ... + unit_low_pass_notch_resistors_5(1,i)* ... + unit_amplitude_scale_factors(1,i); % Ohm + unit_low_pass_notch_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 ... + (((unit_low_pass_notch_gains_high(1,i)-1)/ ... + (unit_low_pass_notch_gains_high(1,i)* ... + unit_low_pass_notch_resistors_1(1,i)* ... + unit_low_pass_notch_capacitors(1,i)))+ ... + (2/(unit_low_pass_notch_resistors_2(1,i)* ... + unit_low_pass_notch_capacitors(1,i)))+ ... + (2/(unit_low_pass_notch_resistors_5(1,i)* ... + unit_low_pass_notch_capacitors(1,i)))) ... + (1/(unit_low_pass_notch_resistors_1(1,i)* ... + unit_low_pass_notch_resistors_5(1,i)* ... + unit_low_pass_notch_capacitors(1,i)^2)+ ... + 1/(unit_low_pass_notch_resistors_1(1,i)* ... + unit_low_pass_notch_resistors_2(1,i)* ... + unit_low_pass_notch_capacitors(1,i)^2))]; + unit_denominator = [1 ... + 2/(unit_low_pass_notch_resistors_2(1,i)* ... + unit_low_pass_notch_capacitors(1,i)) ... + 1/(unit_low_pass_notch_resistors_1(1,i)* ... + unit_low_pass_notch_resistors_2(1,i)* ... + unit_low_pass_notch_capacitors(1,i)^2)]; + + unit_transfer_function(1,i) = tf(unit_numerator, unit_denominator); + unit_transfer_function(1,i) = unit_transfer_function(1,i)* ... + unit_low_pass_notch_gains_high(1,i); +end + +% Clears unneeded variable from workspace +clearVars = {'normalized_transfer_function_zero', 'i'}; +clear(clearVars{:}) +clear clearVars + +% ========== UNITS IMPLEMENTATION END ========== + +%% ========== GAIN ADJUSTMENT START ========== + +total_fried_units_attenuation = unit_low_pass_notch_gains_low(1,1)* ... + unit_low_pass_notch_gains_low(1,2); +unit_adjustment_gain = 1/total_fried_units_attenuation; +% We arbitrarily choose to use a 10KOhm series resistor in the adjustment +% unit +unit_adjustment_feedback_resistor = 10*10^3*unit_adjustment_gain; + +% ========== GAIN ADJUSTMENT END ========== + +%% ========== TRANSFER FUNCTIONS START ========== + +total_transfer_function = series(unit_transfer_function(1,1), ... + unit_transfer_function(1,2)); +total_transfer_function = total_transfer_function*unit_adjustment_gain; + +%{ +plot_transfer_function(total_transfer_function, ... + [10 ... + specification_pass_frequency ... + design_half_power_radial_frequency/(2*pi) ... + specification_stop_frequency]); +%} + +%ltiview(unit_transfer_function(1,1)); +%ltiview(unit_transfer_function(1,2)); +%ltiview(total_transfer_function); +ltiview(unit_transfer_function(1,1), unit_transfer_function(1,2), ... + total_transfer_function); + +% Clears unneeded variable from workspace +clear -regexp _numerator$ +clear -regexp _denominator$ +clear -regexp _transfer_function$ + +% ========== TRANSFER FUNCTIONS END ========== \ No newline at end of file diff --git a/Low Pass Inverse Chebyshev/low_pass_design_single.m b/Low Pass Inverse Chebyshev/low_pass_design_single.m deleted file mode 100644 index 36b6f4a..0000000 --- a/Low Pass Inverse Chebyshev/low_pass_design_single.m +++ /dev/null @@ -1,397 +0,0 @@ -% AUTHOR : Apostolos Fanakis -% $DATE : 02-May-2018 17:21:18 $ -% $Revision : 1.00 $ -% DEVELOPED : 9.0.0.341360 (R2016a) -% FILENAME : low_pass_design_single.m -% AEM : 8261 - -%% ========== DESIGN SPECIFICATIONS START ========== -% Figures out design specifications according to my AEM number - -AEM = [8 2 6 1]; - -if AEM(3)<3 - design_param_m = 1; -elseif AEM(3)<7 - design_param_m = 2; -else - design_param_m = 3; -end - -specification_pass_frequency = (1.1*(3+design_param_m))*1000; % Hz -specification_pass_radial_frequency = specification_pass_frequency*(2*pi); % rad/s - -specification_stop_frequency = 2.1*specification_pass_frequency; % Hz -specification_stop_radial_frequency = specification_stop_frequency*(2*pi); % rad/s - -specification_min_stop_attenuation = 23+(max(1,AEM(3))-5)*(3/4); % dB -specification_max_pass_attenuation = 0.6+((max(1,AEM(4))-5)/16); % dB - -clear design_param_m - -specification_pass_radial_frequency = 1000; % rad/s -specification_stop_radial_frequency = 1400; % rad/s -specification_min_stop_attenuation = 18; % dB -specification_max_pass_attenuation = 0.25; % dB -% ========== DESIGN SPECIFICATIONS END ========== - -%% ========== NORMALIZED DESIGN START ========== -% Calculates normalized design specifications and designs a normalized -% filter using them - -normalized_pass_radial_frequency = specification_pass_radial_frequency/ ... - specification_stop_radial_frequency; % rad/s -% normalized_stop_radial_frequency = 1; % Hz (stop_frequency/stop_frequency) - -% Calculates the filter's order using the eq. 9-137 -design_filter_order = ceil( ... - acosh(((10^(specification_min_stop_attenuation/10)-1)/ ... - (10^(specification_max_pass_attenuation/10)-1))^(1/2)) ... - /acosh(1/normalized_pass_radial_frequency)); -% Calculates epsilon parameter using the eq. 9-123 -epsilon_parameter = 1/(10^(specification_min_stop_attenuation/10)-1)^(1/2); - -% Calculates alpha using the eq. ?? wtf is this? =========^^^^^^^^^^^^^^^^^^&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&========== -alpha_parameter = asinh(1/epsilon_parameter)/design_filter_order; - -% Calculates the frequency at which half power occurs using the eq. 9-139 -design_half_power_radial_frequency = specification_stop_radial_frequency/ ... - (cosh(acosh(1/epsilon_parameter)/design_filter_order)); % rad/s - -% ----- -% Calculates stable poles, zeros, angles and other characteristic sizes -% using the Guillemin algorithm -% ----- - -% Initializes necessary variables -design_number_of_poles = idivide(design_filter_order,int32(2),'ceil'); -% Creates five vector arrays of dimensions [1 * number_of_poles] filled -% with zeros to store: -% - the Butterworth angles with reference to the negative horizontal axes, -% - the real parts of the poles, -% - the imaginary parts of the poles, -% - the radial frequencies (Omega0) of the poles and -% - the Q's of the poles -design_butterworth_angles = zeros([1 design_number_of_poles]); -poles_real_parts = zeros([1 design_number_of_poles]); -poles_imaginary_parts = zeros([1 design_number_of_poles]); -poles_radial_frequencies = zeros([1 design_number_of_poles]); -inverse_poles_Q = zeros([1 design_number_of_poles]); - -% Calculates the Butterworth angles using the method suggested in chapter -% 9 (page 10) of the course notes and then uses them to calculate the -% inverse Chebyshev poles -if mod(design_filter_order,2)~=0 % Odd number of poles - % First pole has a zero angle - design_butterworth_angles(1,1)=0; - % The rest of the poles are scattered in the left half pane with - % equal angles - % Theta is a helper parameter - theta=180/design_filter_order; - - % Calculates the first pole's real part using the eq. 9-102 - poles_real_parts(1,1) = -sinh(alpha_parameter)* ... - cosd(design_butterworth_angles(1,1)); - % Calculates the first pole's imaginary part using the eq. 9-103 - poles_imaginary_parts(1,1) = cosh(alpha_parameter)* ... - sind(design_butterworth_angles(1,1)); - % Calculates the first pole's radial frequency using the eq. 9-150 - poles_radial_frequencies(1,1) = (poles_real_parts(1,1)^2+ ... - poles_imaginary_parts(1,1)^2)^(1/2); - % Calculates the first pole's Q using the eq. 9-151 - inverse_poles_Q(1,1) = 1/ ... - (2*cos(atan(poles_imaginary_parts(1,1)/poles_real_parts(1,1)))); - - % Calculates the rest of the poles in the same way - for i=2:design_number_of_poles - design_butterworth_angles(1,i)=double((i-1)*theta); - % Pole's real part, eq. 9-102 - poles_real_parts(1,i) = -sinh(alpha_parameter)* ... - cosd(design_butterworth_angles(1,i)); - % Pole's imaginary part, eq. 9-103 - poles_imaginary_parts(1,i) = cosh(alpha_parameter)* ... - sind(design_butterworth_angles(1,i)); - % Pole's radial frequency, eq. 9-150 - poles_radial_frequencies(1,i) = (poles_real_parts(1,i)^2+ ... - poles_imaginary_parts(1,i)^2)^(1/2); - % Pole's Q, eq. 9-151 - inverse_poles_Q(1,i) = 1/ ... - (2*cos(atan(poles_imaginary_parts(1,i)/poles_real_parts(1,i)))); - end -else % Even number of poles - % Theta is a helper parameter - theta=90/design_number_of_poles; - - for i=1:design_number_of_poles - design_butterworth_angles(1,i)=double(90)/ ... - double(design_filter_order)+double((i-1)*theta); - % Pole's real part, eq. 9-102 - poles_real_parts(1,i) = -sinh(alpha_parameter)* ... - cosd(design_butterworth_angles(1,i)); - % Pole's imaginary part, eq. 9-103 - poles_imaginary_parts(1,i) = cosh(alpha_parameter)* ... - sind(design_butterworth_angles(1,i)); - % Pole's radial frequency, eq. 9-150 - poles_radial_frequencies(1,i) = (poles_real_parts(1,i)^2+ ... - poles_imaginary_parts(1,i)^2)^(1/2); - % Pole's Q, eq. 9-151 - inverse_poles_Q(1,i) = 1/ ... - (2*cos(atan(poles_imaginary_parts(1,i)/poles_real_parts(1,i)))); - end -end - -% Initializes array to hold the inversed poles -inverse_poles_radial_frequencies = zeros([1 design_number_of_poles]); -% Calculates inverse Chebyshev poles by inversing the Chebyshev poles -% using the eq. 9-146 -for i=1:design_number_of_poles - inverse_poles_radial_frequencies(1,i) = 1/poles_radial_frequencies(1,i); -end - -% Initializes array to hold the transfer function zeros and a temporary -% helper variable -inverse_transfer_function_zeros = zeros([1 length(design_butterworth_angles)]); -temp_index = 1; -% Calculates the transfer function's zeros using the eq. 9-143 -for i=1:2:design_filter_order - inverse_transfer_function_zeros(1,temp_index) = sec((i*pi)/ ... - (2*design_filter_order)); - temp_index = temp_index + 1; -end - -% Clears unneeded variable from workspace -clearVars = {'theta', 'i', 'temp_index', 'alpha_parameter' ... - 'epsilon_parameter', 'normalized_pass_radial_frequency', ... - 'poles_real_parts', 'poles_imaginary_parts', 'poles_radial_frequencies'}; -clear(clearVars{:}) -clear clearVars - -% ========== NORMALIZED DESIGN END ========== - -%% ========== ZEROS-POLES GROUPING START ========== - -% Grouping is done "by hand". The first pole, that has a radial frequency -% equal to 0.9631, is grouped with the first zero (1.0824) and the second -% pole, that has a radial frequency equal to 0.7484, is grouped with the -% second zero (2.6131). -% Two low pass notch units are required to implement the desired low pass filter. - -% ========== ZEROS-POLES GROUPING END ========== - -%% ========== UNITS IMPLEMENTATION START ========== -% AEM(3) = 6, so the circuit shown in 7.23 is going to be used for the low -% pass notch units. - -% Initializes necessary arrays, each array is 1X2, the first element (1,1) -% corresponds to the first unit and the second element (1,2) to second unit. -unit_low_pass_notch_resistors_1 = zeros([1 2]); -unit_low_pass_notch_resistors_2 = zeros([1 2]); -unit_low_pass_notch_resistors_3 = zeros([1 2]); -unit_low_pass_notch_resistors_4 = zeros([1 2]); -unit_low_pass_notch_resistors_5 = zeros([1 2]); -unit_low_pass_notch_capacitors = zeros([1 2]); -unit_low_pass_notch_gains_high = zeros([1 2]); -unit_low_pass_notch_gains_low = zeros([1 2]); - -% The specifications for the first unit are: -% - inverse pole radial frequency = 0.9631 -% - zero at 1.0824 (zero > inverse pole radial frequency) -% - pole angle = 0.5822 - -% normalized_inverse_pole_radial_frequency = 1; -normalized_transfer_function_zero = inverse_transfer_function_zeros(1,1)/ ... - inverse_poles_radial_frequencies(1,3); - -% According to the design method outlined in 7.6-B, at page 35 -unit_low_pass_notch_resistors_1(1,1) = 1; % Ohm -% Calculates the capacity of the normalized circuit capacitors using the -% eq. 7-150 -unit_low_pass_notch_capacitors(1,1) = 1/(2*inverse_poles_Q(1,3)); % Farad -% Calculates the resistance of R2 using the same equations (7-150) -unit_low_pass_notch_resistors_2(1,1) = 4*inverse_poles_Q(1,3)^2; % Ohm -% Calculates the resistance of R5 using the eq. 7-152 -unit_low_pass_notch_resistors_5(1,1) = (4*inverse_poles_Q(1,3)^2)/ ... - (normalized_transfer_function_zero^2-1); % Ohm -unit_low_pass_notch_resistors_4(1,1) = 1; % Ohm -% Calculates the resistance of R3 using the eq. 7-155 -unit_low_pass_notch_resistors_3(1,1) = (normalized_transfer_function_zero^2)/ ... - (2*inverse_poles_Q(1,3)^2); % Ohm -% Calculates the gain of this unit in high frequencies using the eq. 7-143 -unit_low_pass_notch_gains_high(1,1) = (unit_low_pass_notch_resistors_4(1,1))/ ... - (unit_low_pass_notch_resistors_3(1,1)+unit_low_pass_notch_resistors_4(1,1)); -% Calculates the gain of this unit in low frequencies using the -% eq. 7-146, 7-147, 7-148, setting s = 0 -unit_low_pass_notch_gains_low(1,1) = unit_low_pass_notch_gains_high(1,1)* ... - normalized_transfer_function_zero^2; - -% The specifications for the first unit are: -% - inverse pole radial frequency = $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -% - zero at $$$$$$$$$$$$$$$$$$$$ (zero > inverse pole radial frequency) -% - pole angle = $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ - -normalized_transfer_function_zero = inverse_transfer_function_zeros(1,2)/ ... - inverse_poles_radial_frequencies(1,2); - -% According to the design method outlined in 7.6-B, at page 35 -unit_low_pass_notch_resistors_1(1,2) = 1; % Ohm -% Calculates the capacity of the normalized circuit capacitors using the -% eq. 7-150 -unit_low_pass_notch_capacitors(1,2) = 1/(2*inverse_poles_Q(1,2)); % Farad -% Calculates the resistance of R2 using the same equations (7-150) -unit_low_pass_notch_resistors_2(1,2) = 4*inverse_poles_Q(1,2)^2; % Ohm -% Calculates the resistance of R5 using the eq. 7-152 -unit_low_pass_notch_resistors_5(1,2) = (4*inverse_poles_Q(1,2)^2)/ ... - (normalized_transfer_function_zero^2-1); % Ohm -unit_low_pass_notch_resistors_4(1,2) = 1; % Ohm -% Calculates the resistance of R3 using the eq. 7-155 -unit_low_pass_notch_resistors_3(1,2) = (normalized_transfer_function_zero^2)/ ... - (2*inverse_poles_Q(1,2)^2); % Ohm -% Calculates the gain of this unit in high frequencies using the eq. 7-143 -unit_low_pass_notch_gains_high(1,2) = (unit_low_pass_notch_resistors_4(1,2))/ ... - (unit_low_pass_notch_resistors_3(1,2)+unit_low_pass_notch_resistors_4(1,2)); -% Calculates the gain of this unit in low frequencies using the -% eq. 7-146, 7-147, 7-148, setting s = 0 -unit_low_pass_notch_gains_low(1,2) = unit_low_pass_notch_gains_high(1,2)* ... - normalized_transfer_function_zero^2; - -% Clears unneeded variable from workspace -clear normalized_transfer_function_zero - -% ========== UNITS IMPLEMENTATION END ========== - -%% ========== DENORMALIZATION START ========== - -% Unit sizes rescale -unit_frequency_scale_factors = zeros([1 2]); -unit_amplitude_scale_factors = zeros([1 2]); - -% For unit 1 -unit_frequency_scale_factors(1,1) = specification_stop_radial_frequency* ... - inverse_poles_radial_frequencies(1,3); -% AEM(4) = 1, so the scaling will be performed to achieve a capacitor value -% of 0.1uF using the eq. 6-33 -unit_amplitude_scale_factors(1,1) = unit_low_pass_notch_capacitors(1,1)/ ... - (unit_frequency_scale_factors(1,1)*0.1*10^(-6)); - -unit_low_pass_notch_resistors_1(1,1) = unit_low_pass_notch_resistors_1(1,1)* ... - unit_amplitude_scale_factors(1,1); % Ohm -unit_low_pass_notch_resistors_2(1,1) = unit_low_pass_notch_resistors_2(1,1)* ... - unit_amplitude_scale_factors(1,1); % Ohm -unit_low_pass_notch_resistors_3(1,1) = unit_low_pass_notch_resistors_3(1,1)* ... - unit_amplitude_scale_factors(1,1); % Ohm -unit_low_pass_notch_resistors_4(1,1) = unit_low_pass_notch_resistors_4(1,1)* ... - unit_amplitude_scale_factors(1,1); % Ohm -unit_low_pass_notch_resistors_5(1,1) = unit_low_pass_notch_resistors_5(1,1)* ... - unit_amplitude_scale_factors(1,1); % Ohm -unit_low_pass_notch_capacitors(1,1) = 0.1*10^(-6); % Farad - -% For unit 2 -unit_frequency_scale_factors(1,2) = specification_stop_radial_frequency* ... - inverse_poles_radial_frequencies(1,2); -% AEM(4) = 1, so the scaling will be performed to achieve a capacitor value -% of 0.1uF using the eq. 6-33 -unit_amplitude_scale_factors(1,2) = unit_low_pass_notch_capacitors(1,2)/ ... - (unit_frequency_scale_factors(1,2)*0.1*10^(-6)); - -unit_low_pass_notch_resistors_1(1,2) = unit_low_pass_notch_resistors_1(1,2)* ... - unit_amplitude_scale_factors(1,2); % Ohm -unit_low_pass_notch_resistors_2(1,2) = unit_low_pass_notch_resistors_2(1,2)* ... - unit_amplitude_scale_factors(1,2); % Ohm -unit_low_pass_notch_resistors_3(1,2) = unit_low_pass_notch_resistors_3(1,2)* ... - unit_amplitude_scale_factors(1,2); % Ohm -unit_low_pass_notch_resistors_4(1,2) = unit_low_pass_notch_resistors_4(1,2)* ... - unit_amplitude_scale_factors(1,2); % Ohm -unit_low_pass_notch_resistors_5(1,2) = unit_low_pass_notch_resistors_5(1,2)* ... - unit_amplitude_scale_factors(1,2); % Ohm -unit_low_pass_notch_capacitors(1,2) = 0.1*10^(-6); % Farad - -% ========== DENORMALIZATION END ========== - -%% ========== GAIN ADJUSTMENT START ========== - -total_fried_units_attenuation = unit_low_pass_notch_gains_low(1,1)*unit_low_pass_notch_gains_low(1,2); -unit_adjustment_gain = 1/total_fried_units_attenuation; -% We arbitrarily choose to use a 10KOhm series resistor in the adjustment -% unit -unit_adjustment_feedback_resistor = 10*10^3*unit_adjustment_gain; - -% ========== GAIN ADJUSTMENT END ========== - -%% ========== TRANSFER FUNCTIONS START ========== - -% Builds numerator and denominator of the transfer function of each unit -% using the eq. 7-146, 7-147 & 7-148 -unit_1_numerator = [1 ... - (((unit_low_pass_notch_gains_high(1,1)-1)/ ... - (unit_low_pass_notch_gains_high(1,1)*unit_low_pass_notch_resistors_1(1,1)* ... - unit_low_pass_notch_capacitors(1,1)))+ ... - (2/(unit_low_pass_notch_resistors_2(1,1)* ... - unit_low_pass_notch_capacitors(1,1)))+ ... - (2/(unit_low_pass_notch_resistors_5(1,1)* ... - unit_low_pass_notch_capacitors(1,1)))) ... - (1/(unit_low_pass_notch_resistors_1(1,1)* ... - unit_low_pass_notch_resistors_5(1,1)*unit_low_pass_notch_capacitors(1,1)^2)+ ... - 1/(unit_low_pass_notch_resistors_1(1,1)* ... - unit_low_pass_notch_resistors_2(1,1)*unit_low_pass_notch_capacitors(1,1)^2))]; -unit_1_denominator = [1 ... - 2/(unit_low_pass_notch_resistors_2(1,1)* ... - unit_low_pass_notch_capacitors(1,1)) ... - 1/(unit_low_pass_notch_resistors_1(1,1)* ... - unit_low_pass_notch_resistors_2(1,1)*unit_low_pass_notch_capacitors(1,1)^2)]; - - -unit_1_transfer_function = tf(unit_1_numerator, unit_1_denominator); -unit_1_transfer_function = unit_1_transfer_function*unit_low_pass_notch_gains_high(1,1); - -unit_2_numerator = [1 ... - ((unit_low_pass_notch_gains_high(1,2)-1)/ ... - (unit_low_pass_notch_gains_high(1,2)*unit_low_pass_notch_resistors_1(1,2)* ... - unit_low_pass_notch_capacitors(1,2))+ ... - 2/(unit_low_pass_notch_resistors_2(1,2)* ... - unit_low_pass_notch_capacitors(1,2))+ ... - 2/(unit_low_pass_notch_resistors_5(1,2)* ... - unit_low_pass_notch_capacitors(1,2))) ... - (1/(unit_low_pass_notch_resistors_1(1,2)* ... - unit_low_pass_notch_resistors_5(1,2)*unit_low_pass_notch_capacitors(1,2)^2)+ ... - 1/(unit_low_pass_notch_resistors_1(1,2)* ... - unit_low_pass_notch_resistors_2(1,2)*unit_low_pass_notch_capacitors(1,2)^2))]; -unit_2_denominator = [1 ... - 2/(unit_low_pass_notch_resistors_2(1,2)* ... - unit_low_pass_notch_capacitors(1,2)) ... - 1/(unit_low_pass_notch_resistors_1(1,2)* ... - unit_low_pass_notch_resistors_2(1,2)*unit_low_pass_notch_capacitors(1,2)^2)]; - -unit_2_transfer_function = tf(unit_2_numerator, unit_2_denominator); -unit_2_transfer_function = unit_2_transfer_function*unit_low_pass_notch_gains_high(1,2); - -tmpHpRC = double(1)/double(0.1*10^(-6)*4.14*10^3); -unit_3_transfer_function = tf([0 tmpHpRC], [1 tmpHpRC]); - -total_transfer_function = series(series(unit_1_transfer_function,unit_2_transfer_function), unit_3_transfer_function); -total_transfer_function = total_transfer_function*unit_adjustment_gain; -%plot_transfer_function(unit_1_transfer_function, [1 10]); -%plot_transfer_function(unit_2_transfer_function, [1 192.82 222.817 234 238.73]); -%plot_transfer_function(0.656*series(unit_1_transfer_function,unit_2_transfer_function), ... -% [1 159.155 192.82 222.817 234 238.73]); -%{ -plot_transfer_function(total_transfer_function, ... - [1 ... - specification_pass_radial_frequency/(2*pi) ... - design_half_power_radial_frequency/(2*pi) ... - specification_stop_radial_frequency/(2*pi)]); -%} - -%ltiview(unit_1_transfer_function); -%ltiview(unit_2_transfer_function); -%ltiview(unit_3_transfer_function); -%ltiview(total_transfer_function); -%ltiview(unit_1_transfer_function, unit_2_transfer_function, ... -% unit_3_transfer_function, total_transfer_function); - -% Clears unneeded variable from workspace -clear tmpHpRC -clear -regexp _numerator$ -clear -regexp _denominator$ -clear -regexp _transfer_function$ - -% ========== TRANSFER FUNCTIONS END ========== \ No newline at end of file