Tangle to the matlab directory instead of src

This commit is contained in:
2020-11-10 12:51:16 +01:00
parent 8b92419775
commit 895c443a15
6 changed files with 5 additions and 5 deletions

48
matlab/comp_pi_cedrat.m Normal file
View File

@@ -0,0 +1,48 @@
%% Clear Workspace and Close figures
clear; close all; clc;
%% Intialize Laplace variable
s = zpk('s');
addpath('./mat/');
% Results
ce_results = load('cedrat_la75b_high_1_stack.mat', 't', 'V_in', 'V_out');
pi_results = load('pi_505_high.mat', 't', 'V_in', 'V_out');
Ts = 1e-4;
win = hann(ceil(0.1/Ts));
[tf_ce, f] = tfestimate(ce_results.V_in, ce_results.V_out, win, [], [], 1/Ts);
[tf_pi, ~] = tfestimate(pi_results.V_in, pi_results.V_out, win, [], [], 1/Ts);
% We remove the phase delay due to the time delay of the ADC/DAC:
angle_delay = 180/pi*angle(squeeze(freqresp(exp(-s*Ts), f, 'Hz')));
figure;
ax1 = subplot(2, 1, 1);
hold on;
plot(f, abs(tf_pi), 'DisplayName', 'PI')
plot(f, abs(tf_ce), 'DisplayName', 'Cedrat')
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
ylabel('Amplitude'); xlabel('Frequency [Hz]');
hold off;
legend('location', 'southwest');
ylim([0.1, 50]);
ax2 = subplot(2, 1, 2);
hold on;
plot(f, 180/pi*unwrap(angle(tf_pi))-angle_delay)
plot(f, 180/pi*unwrap(angle(tf_ce))-angle_delay)
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'lin');
ylabel('Phase'); xlabel('Frequency [Hz]');
hold off;
ylim([-270, 90]);
yticks(-360:90:90)
linkaxes([ax1,ax2], 'x');
xlim([10, 5000]);

View File

@@ -0,0 +1,112 @@
%% Clear Workspace and Close figures
clear; close all; clc;
%% Intialize Laplace variable
s = zpk('s');
addpath('./mat/');
% Cedrat Technology
% Load Data
piezo1 = load('cedrat_la75b_med_1_stack.mat', 't', 'V_in', 'V_out');
piezo2 = load('cedrat_la75b_med_2_stack.mat', 't', 'V_in', 'V_out');
piezo3 = load('cedrat_la75b_med_3_stack.mat', 't', 'V_in', 'V_out');
% Compute Coherence and Transfer functions
Ts = 1e-4;
win = hann(ceil(0.1/Ts));
[tf_1, f] = tfestimate(piezo1.V_in, piezo1.V_out, win, [], [], 1/Ts);
[co_1, ~] = mscohere(piezo1.V_in, piezo1.V_out, win, [], [], 1/Ts);
[tf_2, ~] = tfestimate(piezo2.V_in, piezo2.V_out, win, [], [], 1/Ts);
[co_2, ~] = mscohere(piezo2.V_in, piezo2.V_out, win, [], [], 1/Ts);
[tf_3, ~] = tfestimate(piezo3.V_in, piezo3.V_out, win, [], [], 1/Ts);
[co_3, ~] = mscohere(piezo3.V_in, piezo3.V_out, win, [], [], 1/Ts);
% We remove the phase delay due to the time delay of the ADC/DAC:
angle_delay = 180/pi*angle(squeeze(freqresp(exp(-s*Ts), f, 'Hz')));
figure;
ax1 = subplot(2, 1, 1);
hold on;
plot(f, abs(tf_1), 'DisplayName', '1 stack')
plot(f, abs(tf_2), 'DisplayName', '2 stacks')
plot(f, abs(tf_3), 'DisplayName', '3 stacks')
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
ylabel('Amplitude'); xlabel('Frequency [Hz]');
hold off;
legend('location', 'southwest');
ylim([1, 40]);
ax2 = subplot(2, 1, 2);
hold on;
plot(f, 180/pi*unwrap(angle(tf_1))-angle_delay)
plot(f, 180/pi*unwrap(angle(tf_2))-angle_delay)
plot(f, 180/pi*unwrap(angle(tf_3))-angle_delay)
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'lin');
ylabel('Phase'); xlabel('Frequency [Hz]');
hold off;
ylim([-270, 90]);
yticks(-360:90:90)
linkaxes([ax1,ax2], 'x');
xlim([10, 5000]);
% PI
piezo1 = load('pi_505_high.mat', 't', 'V_in', 'V_out');
piezo2 = load('pi_505_high_2_stacks.mat', 't', 'V_in', 'V_out');
piezo3 = load('pi_505_high_3_stacks.mat', 't', 'V_in', 'V_out');
Ts = 1e-4;
win = hann(ceil(0.1/Ts));
[tf_1, f] = tfestimate(piezo1.V_in, piezo1.V_out, win, [], [], 1/Ts);
[co_1, ~] = mscohere(piezo1.V_in, piezo1.V_out, win, [], [], 1/Ts);
[tf_2, ~] = tfestimate(piezo2.V_in, piezo2.V_out, win, [], [], 1/Ts);
[co_2, ~] = mscohere(piezo2.V_in, piezo2.V_out, win, [], [], 1/Ts);
[tf_3, ~] = tfestimate(piezo3.V_in, piezo3.V_out, win, [], [], 1/Ts);
[co_3, ~] = mscohere(piezo3.V_in, piezo3.V_out, win, [], [], 1/Ts);
% We remove the phase delay due to the time delay of the ADC/DAC:
angle_delay = 180/pi*angle(squeeze(freqresp(exp(-s*Ts), f, 'Hz')));
figure;
ax1 = subplot(2, 1, 1);
hold on;
plot(f, abs(tf_1), 'DisplayName', '1 stack')
plot(f, abs(tf_2), 'DisplayName', '2 stacks')
plot(f, abs(tf_3), 'DisplayName', '3 stacks')
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
ylabel('Amplitude'); xlabel('Frequency [Hz]');
hold off;
legend('location', 'southwest');
ylim([0.05, 11]);
ax2 = subplot(2, 1, 2);
hold on;
plot(f, 180/pi*unwrap(angle(tf_1))-angle_delay)
plot(f, 180/pi*unwrap(angle(tf_2))-angle_delay)
plot(f, 180/pi*unwrap(angle(tf_3))-angle_delay)
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'lin');
ylabel('Phase'); xlabel('Frequency [Hz]');
hold off;
ylim([-360, 0]);
yticks(-360:90:90)
linkaxes([ax1,ax2], 'x');
xlim([10, 5000]);

View File

@@ -0,0 +1,95 @@
%% Clear Workspace and Close figures
clear; close all; clc;
%% Intialize Laplace variable
s = zpk('s');
addpath('./mat/');
% Cedrat Technology
hi = load('cedrat_la75b_high_1_stack.mat', 't', 'V_in', 'V_out');
me = load('cedrat_la75b_med_1_stack.mat', 't', 'V_in', 'V_out');
lo = load('cedrat_la75b_low_1_stack.mat', 't', 'V_in', 'V_out');
Ts = 1e-4;
win = hann(ceil(0.1/Ts));
[tf_hi, f] = tfestimate(hi.V_in, hi.V_out, win, [], [], 1/Ts);
[co_hi, ~] = mscohere(hi.V_in, hi.V_out, win, [], [], 1/Ts);
[tf_me, ~] = tfestimate(me.V_in, me.V_out, win, [], [], 1/Ts);
[co_me, ~] = mscohere(me.V_in, me.V_out, win, [], [], 1/Ts);
[tf_lo, ~] = tfestimate(lo.V_in, lo.V_out, win, [], [], 1/Ts);
[co_lo, ~] = mscohere(lo.V_in, lo.V_out, win, [], [], 1/Ts);
% We remove the phase delay due to the time delay of the ADC/DAC:
angle_delay = 180/pi*angle(squeeze(freqresp(exp(-s*Ts), f, 'Hz')));
figure;
ax1 = subplot(2, 1, 1);
hold on;
plot(f, abs(tf_lo), 'DisplayName', 'low')
plot(f, abs(tf_me), 'DisplayName', 'med')
plot(f, abs(tf_hi), 'DisplayName', 'high')
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
ylabel('Amplitude'); xlabel('Frequency [Hz]');
hold off;
legend('location', 'southwest');
ylim([1, 50]);
ax2 = subplot(2, 1, 2);
hold on;
plot(f, 180/pi*unwrap(angle(tf_lo))-angle_delay)
plot(f, 180/pi*unwrap(angle(tf_me))-angle_delay)
plot(f, 180/pi*unwrap(angle(tf_hi))-angle_delay)
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'lin');
ylabel('Phase'); xlabel('Frequency [Hz]');
hold off;
ylim([-360, 0]);
yticks(-360:90:90)
linkaxes([ax1,ax2], 'x');
xlim([10, 5000]);
% PI
hi = load('pi_505_high.mat', 't', 'V_in', 'V_out');
lo = load('pi_505_low.mat', 't', 'V_in', 'V_out');
Ts = 1e-4;
win = hann(ceil(0.1/Ts));
[tf_hi, f] = tfestimate(hi.V_in, hi.V_out, win, [], [], 1/Ts);
[co_hi, ~] = mscohere(hi.V_in, hi.V_out, win, [], [], 1/Ts);
[tf_lo, ~] = tfestimate(lo.V_in, lo.V_out, win, [], [], 1/Ts);
[co_lo, ~] = mscohere(lo.V_in, lo.V_out, win, [], [], 1/Ts);
figure;
ax1 = subplot(2, 1, 1);
hold on;
plot(f, abs(tf_hi), 'DisplayName', 'high')
plot(f, abs(tf_lo), 'DisplayName', 'low')
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
ylabel('Amplitude'); xlabel('Frequency [Hz]');
hold off;
legend('location', 'southwest');
ylim([0.1, 20]);
ax2 = subplot(2, 1, 2);
hold on;
plot(f, 180/pi*unwrap(angle(tf_hi))-angle_delay)
plot(f, 180/pi*unwrap(angle(tf_lo))-angle_delay)
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'lin');
ylabel('Phase'); xlabel('Frequency [Hz]');
hold off;
ylim([-360, 0]);
yticks(-360:90:90)
linkaxes([ax1,ax2], 'x');
xlim([10, 5000]);

112
matlab/impedance_meas.m Normal file
View File

@@ -0,0 +1,112 @@
%% Clear Workspace and Close figures
clear; close all; clc;
%% Intialize Laplace variable
s = zpk('s');
addpath('./mat/');
% Compute Impedance
R = 10; % Resistive Load used [Ohm]
V = 0.998; % Output Voltage without any load [V]
Vp = 0.912; % Output Voltage with resistice load [V]
R * (V - Vp)/Vp;
% #+RESULTS:
% : 0.94298
R = 47; % Resistive Load used [Ohm]
V = 4.960; % Output Voltage without any load [V]
Vp = 4.874; % Output Voltage with resistice load [V]
R * (V - Vp)/Vp;
% Effect of Impedance on the phase drop
C_1 = 5e-6; % Capacitance in [F]
C_2 = 10e-6; % Capacitance in [F]
C_3 = 15e-6; % Capacitance in [F]
Ri = R * (V - Vp)/Vp; % Internal resistance [Ohm]
G0 = 20;
G_1 = G0/(1+Ri*C_1*s);
G_2 = G0/(1+Ri*C_2*s);
G_3 = G0/(1+Ri*C_3*s);
piezo1 = load('cedrat_la75b_med_1_stack.mat', 't', 'V_in', 'V_out');
piezo2 = load('cedrat_la75b_med_2_stack.mat', 't', 'V_in', 'V_out');
piezo3 = load('cedrat_la75b_med_3_stack.mat', 't', 'V_in', 'V_out');
Ts = 1e-4;
win = hann(ceil(0.1/Ts));
[tf_1, f] = tfestimate(piezo1.V_in, piezo1.V_out, win, [], [], 1/Ts);
[co_1, ~] = mscohere(piezo1.V_in, piezo1.V_out, win, [], [], 1/Ts);
[tf_2, ~] = tfestimate(piezo2.V_in, piezo2.V_out, win, [], [], 1/Ts);
[co_2, ~] = mscohere(piezo2.V_in, piezo2.V_out, win, [], [], 1/Ts);
[tf_3, ~] = tfestimate(piezo3.V_in, piezo3.V_out, win, [], [], 1/Ts);
[co_3, ~] = mscohere(piezo3.V_in, piezo3.V_out, win, [], [], 1/Ts);
angle_delay = 180/pi*angle(squeeze(freqresp(exp(-s*Ts), f, 'Hz')));
freqs = logspace(1, 4, 1000);
figure;
ax1 = subplot(2, 1, 1);
hold on;
plot(freqs, abs(squeeze(freqresp(G_1, freqs, 'Hz'))));
plot(freqs, abs(squeeze(freqresp(G_2, freqs, 'Hz'))));
plot(freqs, abs(squeeze(freqresp(G_3, freqs, 'Hz'))));
set(gca,'ColorOrderIndex',1);
plot(f, abs(tf_1), '--')
plot(f, abs(tf_2), '--')
plot(f, abs(tf_3), '--')
hold off;
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
ylabel('Amplitude [m/N]'); set(gca, 'XTickLabel',[]);
ax2 = subplot(2, 1, 2);
hold on;
plot(freqs, 180/pi*angle(squeeze(freqresp(G_1, freqs, 'Hz'))));
plot(freqs, 180/pi*angle(squeeze(freqresp(G_2, freqs, 'Hz'))));
plot(freqs, 180/pi*angle(squeeze(freqresp(G_3, freqs, 'Hz'))));
set(gca,'ColorOrderIndex',1);
plot(f, 180/pi*unwrap(angle(tf_1))-angle_delay, '--')
plot(f, 180/pi*unwrap(angle(tf_2))-angle_delay, '--')
plot(f, 180/pi*unwrap(angle(tf_3))-angle_delay, '--')
hold off;
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'lin');
ylabel('Phase [deg]'); xlabel('Frequency [Hz]');
ylim([-90, 45]);
yticks([-90:15:45]);
linkaxes([ax1,ax2],'x');
% PI
R = 10; % Resistive Load used [Ohm]
V = 1.059; % Output Voltage without any load [V]
Vp = 0.828; % Output Voltage with resistice load [V]
R * (V - Vp)/Vp
% #+RESULTS:
% : 2.7899
R = 10; % Resistive Load used [Ohm]
V = 2.092; % Output Voltage without any load [V]
Vp = 1.637; % Output Voltage with resistice load [V]
R * (V - Vp)/Vp

118
matlab/pi_e505_filters.m Normal file
View File

@@ -0,0 +1,118 @@
%% Clear Workspace and Close figures
clear; close all; clc;
%% Intialize Laplace variable
s = zpk('s');
addpath('./mat/');
% PI
% Three measurements are done:
% - Slew Rate limitation at maximum
% - Slew Rate limitation at minimum
% - Notch Filter at maximum frequency
pi_sr_min = load('pi_slew_rate_min.mat');
pi_sr_max = load('pi_slew_rate_max.mat');
pi_sr_max_notch = load('pi_slew_rate_max_notch_high.mat');
pi_sr_load = load('pi_slew_rate_max_notch_high_2stacks.mat');
Ts = 1e-4;
win = hann(ceil(0.1/Ts));
[tf_sr_min, f] = tfestimate(pi_sr_min.V_in, pi_sr_min.V_out, win, [], [], 1/Ts);
[tf_sr_max, ~] = tfestimate(pi_sr_max.V_in, pi_sr_max.V_out, win, [], [], 1/Ts);
[tf_sr_max_notch, ~] = tfestimate(pi_sr_max_notch.V_in, pi_sr_max_notch.V_out, win, [], [], 1/Ts);
[tf_sr_load, ~] = tfestimate(pi_sr_load.V_in, pi_sr_load.V_out, win, [], [], 1/Ts);
angle_delay = 180/pi*angle(squeeze(freqresp(exp(-s*Ts), f, 'Hz')));
figure;
ax1 = subplot(2, 1, 1);
hold on;
plot(f, abs(tf_sr_min), 'DisplayName', 'Slew Rate - Min')
plot(f, abs(tf_sr_max), 'DisplayName', 'Slew Rate - Max')
plot(f, abs(tf_sr_max_notch), 'DisplayName', 'Remove Notch')
plot(f, abs(tf_sr_load), 'DisplayName', 'With Load')
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
ylabel('Amplitude'); xlabel('Frequency [Hz]');
hold off;
legend('location', 'southwest');
ax2 = subplot(2, 1, 2);
hold on;
plot(f, 180/pi*unwrap(angle(tf_sr_min))-angle_delay)
plot(f, 180/pi*unwrap(angle(tf_sr_max))-angle_delay)
plot(f, 180/pi*unwrap(angle(tf_sr_max_notch))-angle_delay)
plot(f, 180/pi*unwrap(angle(tf_sr_load))-angle_delay)
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'lin');
ylabel('Phase'); xlabel('Frequency [Hz]');
hold off;
ylim([-180, 45]);
yticks(-360:45:90)
linkaxes([ax1,ax2], 'x');
xlim([10, 5e3]);
% Transfer function of the Voltage Amplifier
% The identified transfer function still seems to match the one of a notch filter at 5kHz.
w_nf = 2*pi*5e3; % Notch Filter Frequency [rad/s]
G = 10.5*(s^2 + 2*w_nf*0.12*s + w_nf^2)/(s^2 + 2*w_nf*s + w_nf^2);
figure;
ax1 = subplot(2, 1, 1);
hold on;
plot(f, abs(tf_sr_max_notch), 'DisplayName', 'Remove Notch')
plot(f, abs(squeeze(freqresp(G, f, 'Hz'))), 'DisplayName', 'Remove Notch')
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
ylabel('Amplitude'); xlabel('Frequency [Hz]');
hold off;
legend('location', 'southwest');
ax2 = subplot(2, 1, 2);
hold on;
plot(f, 180/pi*unwrap(angle(tf_sr_max_notch))-angle_delay)
plot(f, 180/pi*angle(squeeze(freqresp(G, f, 'Hz'))), 'DisplayName', 'Remove Notch')
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'lin');
ylabel('Phase'); xlabel('Frequency [Hz]');
hold off;
ylim([-180, 45]);
yticks(-360:45:90)
linkaxes([ax1,ax2], 'x');
xlim([10, 5e3]);
% With Load
R = 2.78; % Output Impedance [Ohm]
C = 9e-6; % Load capacitance [F]
G_amp = 10/(1 + s*R*C);
figure;
ax1 = subplot(2, 1, 1);
hold on;
plot(f, abs(tf_sr_max_notch), 'DisplayName', 'No load')
plot(f, abs(tf_sr_load), 'DisplayName', '$10\mu F$ load')
plot(f, abs(squeeze(freqresp(G_amp, f, 'Hz'))), 'k--', 'DisplayName', 'Model')
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
ylabel('Amplitude'); xlabel('Frequency [Hz]');
hold off;
legend('location', 'southwest');
ax2 = subplot(2, 1, 2);
hold on;
plot(f, 180/pi*unwrap(angle(tf_sr_max_notch))-angle_delay)
plot(f, 180/pi*unwrap(angle(tf_sr_load))-angle_delay)
plot(f, 180/pi*unwrap(angle(squeeze(freqresp(G_amp, f, 'Hz')))), 'k--')
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'lin');
ylabel('Phase'); xlabel('Frequency [Hz]');
hold off;
ylim([-180, 45]);
yticks(-360:45:90)
linkaxes([ax1,ax2], 'x');
xlim([10, 5e3]);