Rename all files, tangle Matlab code

This commit is contained in:
2024-03-25 10:01:56 +01:00
parent b6ee956cea
commit 27d859df04
105 changed files with 1026 additions and 1238 deletions

View File

@@ -0,0 +1,75 @@
%% Clear Workspace and Close figures
clear; close all; clc;
%% Intialize Laplace variable
s = zpk('s');
%% Path for functions, data and scripts
addpath('./mat/'); % Path for data
%% Colors for the figures
colors = colororder;
% Measurement Results
% # - Strange shape: 5
% The expected flexible beam thickness is $250\,\mu m$.
% However, it is more important that the thickness of all beams are close to each other.
% The dimension of the beams are been measured at each end to be able to estimate the mean of the beam thickness.
% All the measured dimensions are summarized in Table ref:tab:test_joints_flex_dim.
meas_flex = [[223, 226, 224, 214];
[229, 231, 237, 224];
[234, 230, 239, 231];
[233, 227, 229, 232];
[225, 212, 228, 228];
[220, 221, 224, 220];
[206, 207, 228, 226];
[230, 224, 224, 223];
[223, 231, 228, 233];
[228, 230, 235, 231];
[197, 207, 211, 204];
[227, 226, 225, 226];
[215, 228, 231, 220];
[216, 224, 224, 221];
[209, 214, 220, 221];
[213, 210, 230, 229]];
% #+name: tab:test_joints_flex_dim
% #+caption: Measured Dimensions of the flexible beams in $\mu m$
% #+attr_latex: :environment tabularx :width 0.4\linewidth :align Xcccc
% #+attr_latex: :center t :booktabs t :float t
% #+RESULTS:
% | | Y1 | Y2 | X1 | X2 |
% |----+-----+-----+-----+-----|
% | 1 | 223 | 226 | 224 | 214 |
% | 2 | 229 | 231 | 237 | 224 |
% | 3 | 234 | 230 | 239 | 231 |
% | 4 | 233 | 227 | 229 | 232 |
% | 5 | 225 | 212 | 228 | 228 |
% | 6 | 220 | 221 | 224 | 220 |
% | 7 | 206 | 207 | 228 | 226 |
% | 8 | 230 | 224 | 224 | 223 |
% | 9 | 223 | 231 | 228 | 233 |
% | 10 | 228 | 230 | 235 | 231 |
% | 11 | 197 | 207 | 211 | 204 |
% | 12 | 227 | 226 | 225 | 226 |
% | 13 | 215 | 228 | 231 | 220 |
% | 14 | 216 | 224 | 224 | 221 |
% | 15 | 209 | 214 | 220 | 221 |
% | 16 | 213 | 210 | 230 | 229 |
% An histogram of these measured dimensions is shown in Figure ref:fig:test_joints_size_hist.
figure;
histogram([(meas_flex(:,1)+meas_flex(:,2))/2,(meas_flex(:,3)+meas_flex(:,4))/2], 7)
xlabel("Beam's Thickness [$\mu m$]");
%% Save beam sizes
save('./mat/flex_meas_dim.mat', 'meas_flex');

View File

@@ -0,0 +1,59 @@
%% Clear Workspace and Close figures
clear; close all; clc;
%% Intialize Laplace variable
s = zpk('s');
%% Path for functions, data and scripts
addpath('./mat/'); % Path for data
%% Colors for the figures
colors = colororder;
% Flexible joint Geometry
% The flexible joint used for the Nano-Hexapod is shown in Figure ref:fig:test_joints_bend_geometry.
% Its bending stiffness is foreseen to be $k_{R_y}\approx 5\,\frac{Nm}{rad}$ and its stroke $\theta_{y,\text{max}}\approx 25\,mrad$.
% #+name: fig:test_joints_bend_geometry
% #+caption: Geometry of the flexible joint
% [[file:figs/test_joints_bend_geometry.png]]
% The height between the flexible point (center of the joint) and the point where external forces are applied is $h = 20\,mm$.
% Let's define the parameters on Matlab.
kRx = 5; % Bending Stiffness [Nm/rad]
Rxmax = 25e-3; % Bending Stroke [rad]
h = 20e-3; % Height [m]
% Required external applied force
% The bending $\theta_y$ of the flexible joint due to the force $F_x$ is:
% \begin{equation}
% \theta_y = \frac{M_y}{k_{R_y}} = \frac{F_x h}{k_{R_y}}
% \end{equation}
% Therefore, the applied force to test the full range of the flexible joint is:
% \begin{equation}
% F_{x,\text{max}} = \frac{k_{R_y} \theta_{y,\text{max}}}{h}
% \end{equation}
Fxmax = kRx*Rxmax/h; % Force to induce maximum stroke [N]
% And we obtain:
sprintf('\\begin{equation} F_{x,max} = %.1f\\, [N] \\end{equation}', Fxmax)
% Required actuator stroke and sensors range
% The flexible joint is designed to allow a bending motion of $\pm 25\,mrad$.
% The corresponding stroke at the location of the force sensor is:
% \[ d_{x,\text{max}} = h \tan(R_{x,\text{max}}) \]
dxmax = h*tan(Rxmax);
sprintf('\\begin{equation} d_{max} = %.1f\\, [mm] \\end{equation}', 1e3*dxmax)

View File

@@ -0,0 +1,73 @@
%% Clear Workspace and Close figures
clear; close all; clc;
%% Intialize Laplace variable
s = zpk('s');
%% Path for functions, data and scripts
addpath('./mat/'); % Path for data
%% Colors for the figures
colors = colororder;
% Finite Element Model
% From the Finite Element Model, the stiffness and stroke of the flexible joint have been computed and summarized in Tables ref:tab:test_joints_axial_shear_prop and ref:tab:test_joints_bending_torsion_prop.
%% Stiffness
ka = 94e6; % Axial Stiffness [N/m]
ks = 13e6; % Shear Stiffness [N/m]
kb = 5; % Bending Stiffness [Nm/rad]
kt = 260; % Torsional Stiffness [Nm/rad]
%% Maximum force
Fa = 469; % Axial Force before yield [N]
Fs = 242; % Shear Force before yield [N]
Fb = 0.118; % Bending Force before yield [Nm]
Ft = 1.508; % Torsional Force before yield [Nm]
%% Compute the corresponding stroke
Xa = Fa/ka; % Axial Stroke before yield [m]
Xs = Fs/ks; % Shear Stroke before yield [m]
Xb = Fb/kb; % Bending Stroke before yield [rad]
Xt = Ft/kt; % Torsional Stroke before yield [rad]
% Setup
% The setup is schematically represented in Figure ref:fig:test_joints_bench_side_bis.
% The force is applied on top of the flexible joint with a distance $h$ with the joint's center.
% The displacement of the flexible joint is also measured at the same height.
% The height between the joint's center and the force application point is:
h = 25e-3; % Height [m]
% Estimation error due to force sensor compression
% The measured displacement is not done directly at the joint's location.
% The force sensor compression will then induce an error on the joint's stiffness.
% The force sensor stiffness $k_F$ is estimated to be around:
kF = 50/0.05e-3; % [N/m]
sprintf('k_F = %.1e [N/m]', kF)
% Estimation error due to height estimation error
% Let's consider an error in the estimation of the height from the application of the force to the joint's center:
% \begin{equation}
% h_{\text{est}} = h (1 + \epsilon)
% \end{equation}
% The computed bending stiffness will be:
% \begin{equation}
% k_\text{est} \approx h_{\text{est}}^2 \frac{F_x}{d_x}
% \end{equation}
% And the stiffness estimation error is:
% \begin{equation}
% \frac{k_{\text{est}}}{k_{R_y}} = (1 + \epsilon)^2
% \end{equation}
h_err = 0.2e-3; % Height estimation error [m]

View File

@@ -0,0 +1,175 @@
%% Clear Workspace and Close figures
clear; close all; clc;
%% Intialize Laplace variable
s = zpk('s');
%% Path for functions, data and scripts
addpath('./mat/'); % Path for data
%% Colors for the figures
colors = colororder;
% Force Sensor Calibration
% #+begin_note
% *Load Cells*:
% - [[file:doc/A700000007147087.pdf][FC2231-0000-0010-L]]
% - [[file:doc/FRE_DS_XFL212R_FR_A3.pdf][XFL212R]]
% #+end_note
% There are both specified to have $\pm 1 \%$ of non-linearity over the full range.
% The XFL212R has a spherical interface while the FC2231 has a flat surface.
% Therefore, we should have a nice point contact when using the two force sensors as shown in Figure ref:fig:test_joints_force_sensor_calib.
% #+name: fig:test_joints_force_sensor_calib
% #+caption: Zoom on the two force sensors in contact
% #+attr_latex: :width 0.8\linewidth
% [[file:figs/test_joints_force_sensor_calib.jpg]]
% The two force sensors are therefore measuring the exact same force, and we can compare the two measurements.
% Let's load the measured force of both sensors.
%% Load measurement data
load('calibration_force_sensor.mat', 't', 'F', 'Fc')
% We remove any offset such that they are both measuring no force when not in contact.
%% Remove offset
F = F - mean(F( t > 0.5 & t < 1.0));
Fc = Fc - mean(Fc(t > 0.5 & t < 1.0));
figure;
hold on;
plot(t, F, 'DisplayName', 'FC2231');
plot(t, Fc, 'DisplayName', 'XFL212R');
hold off;
xlabel('Time [s]'); ylabel('Measured Force [N]');
xlim([0,15]); ylim([0,55]);
legend('location', 'southeast');
% #+name: fig:test_joints_force_sensor_calib_time
% #+caption: Measured force using both sensors as a function of time
% #+RESULTS:
% [[file:figs/test_joints_force_sensor_calib_time.png]]
% Let's select only the first part from the moment they are in contact until the maximum force is reached.
%% Only get the first part until maximum force
F = F( t > 1.55 & t < 4.65);
Fc = Fc(t > 1.55 & t < 4.65);
% Then, let's make a linear fit between the two measured forces.
%% Make a line fit
fit_F = polyfit(Fc, F, 1);
% The two forces are plotted against each other as well as the linear fit in Figure ref:fig:test_joints_force_sensor_calib_fit.
figure;
hold on;
plot(Fc, F, '-', 'DisplayName', 'Raw Data');
plot(Fc([1,end]), Fc([1,end])*fit_F(1) + fit_F(2), '--', 'DisplayName', 'Line Fit');
hold off;
xlabel('XFL212R [N]'); ylabel('FC2231 [N]');
xlim([0,50]); ylim([0,50]);
legend('location', 'southeast');
% #+name: fig:test_joints_force_sensor_calib_fit
% #+caption: Measured two forces and linear fit
% #+RESULTS:
% [[file:figs/test_joints_force_sensor_calib_fit.png]]
% The measurement error between the two sensors is shown in Figure ref:fig:test_joints_force_sensor_calib_error.
% It is below 0.1N for the full measurement range.
figure;
hold on;
plot(Fc, F - (Fc*fit_F(1) + fit_F(2)), 'k-');
hold off;
xlim([0,50]); ylim([-0.12, 0.12]);
xlabel('Measured Force [N]');
ylabel('Error [N]')
% Force Sensor Stiffness
% The objective of this measurement is to estimate the stiffness of the force sensor [[file:doc/A700000007147087.pdf][FC2231-0000-0010-L]].
% To do so, a very stiff element is fixed in front of the force sensor as shown in Figure ref:fig:test_joints_meas_force_sensor_stiffness.
% Then, we apply a force on the stiff element through the force sensor.
% We measure the deflection of the force sensor using an encoder.
% Then, having the force and the deflection, we should be able to estimate the stiffness of the force sensor supposing the stiffness of the other elements are much larger.
% #+name: fig:test_joints_meas_force_sensor_stiffness
% #+caption: Bench used to measured the stiffness of the force sensor
% #+attr_latex: :width 0.6\linewidth
% [[file:figs/test_joints_meas_force_sensor_stiffness.jpg]]
% From the documentation, the deflection of the sensor at the maximum load (50N) is 0.05mm, the stiffness is therefore foreseen to be around $1\,N/\mu m$.
% Let's load the measured force as well as the measured displacement.
%% Load measurement data
load('force_sensor_stiffness_meas.mat', 't', 'F', 'd')
% Some pre-processing is applied on the data.
%% Remove offset
F = F - mean(F(t > 0.5 & t < 1.0));
%% Select important part of data
F = F( t > 4.55 & t < 7.24);
d = d( t > 4.55 & t < 7.24); d = d - d(1);
t = t( t > 4.55 & t < 7.24);
% The linear fit is performed.
%% Linear fit
fit_k = polyfit(F, d, 1);
% The displacement as a function of the force as well as the linear fit are shown in Figure ref:fig:test_joints_force_sensor_stiffness_fit.
figure;
hold on;
plot(F, 1e6*d, '-', 'DisplayName', 'Raw Data');
plot(F([1,end]), 1e6*(F([1,end])*fit_k(1) + fit_k(2)), '--', 'DisplayName', 'Line Fit');
hold off;
xlabel('Force [$N$]'); ylabel('Displacement [$\mu m$]');
xlim([0,45]); ylim([0,60]);
legend('location', 'southeast');
% #+name: fig:test_joints_force_sensor_stiffness_fit
% #+caption: Displacement as a function of the measured force
% #+RESULTS:
% [[file:figs/test_joints_force_sensor_stiffness_fit.png]]
% And we obtain the following stiffness:
%% Force Sensor Stiffness
sprintf('k = %.2f [N/um]', 1e-6*1/fit_k(1));

View File

@@ -0,0 +1,285 @@
%% Clear Workspace and Close figures
clear; close all; clc;
%% Intialize Laplace variable
s = zpk('s');
%% Path for functions, data and scripts
addpath('./mat/'); % Path for data
%% Colors for the figures
colors = colororder;
% Analysis of one measurement
% In this section is shown how the data are analysis in order to measured:
% - the bending stiffness
% - the bending stroke
% - the stiffness once the mechanical stops are in contact
% The height from the flexible joint's center and the point of application force $h$ is defined below:
h = 25e-3; % [m]
%% Load Data
load('meas_stiff_flex_1_x.mat', 't', 'F', 'd');
%% Zero the force
F = F - mean(F(t > 0.1 & t < 0.3));
%% Start measurement at t = 0.2 s
d = d(t > 0.2);
F = F(t > 0.2);
t = t(t > 0.2); t = t - t(1);
% The obtained time domain measurements are shown in Figure ref:fig:test_joints_meas_bend_time.
%% Time Domain plots
figure;
tiledlayout(2, 1, 'TileSpacing', 'Compact', 'Padding', 'None');
ax1 = nexttile;
plot(t, F);
ylabel('Force [N]'); set(gca, 'XTickLabel',[]);
ax2 = nexttile;
plot(t, 1e3*d);
hold off;
xlabel('Time [s]'); ylabel('Displacement [mm]');
linkaxes([ax1,ax2],'x');
xlim([0,5]);
% #+name: fig:test_joints_meas_bend_time
% #+caption: Typical time domain measurements
% #+RESULTS:
% [[file:figs/test_joints_meas_bend_time.png]]
% The displacement as a function of the force is then shown in Figure ref:fig:test_joints_meas_F_d.
figure;
plot(F, 1e3*d);
xlabel('Force [N]'); ylabel('Displacement [mm]');
xlim([0,6]); ylim([0,1]);
% #+name: fig:test_joints_meas_F_d
% #+caption: Typical measurement of the diplacement as a function of the applied force
% #+RESULTS:
% [[file:figs/test_joints_meas_F_d.png]]
% The bending stiffness can be estimated by computing the slope of the curve in Figure ref:fig:test_joints_meas_F_d.
% The bending stroke and the stiffness when touching the mechanical stop can also be estimated from the same figure.
%% Determine the linear region and region when touching the mechanical stop
% Find when the force sensor touches the flexible joint
i_l_start = find(F > 0.3, 1, 'first');
% Reset the measured diplacement at that point
d = d - d(i_l_start);
% Find then the maximum force is applied
[~, i_s_stop] = max(F);
% Linear region stops ~ when 90% of the stroke is reached
i_l_stop = find(d > 0.9*d(i_s_stop), 1, 'first');
% "Stop" region start ~1N before maximum force is applied
i_s_start = find(F > max(F)-1, 1, 'first');
%% Define variables for the two regions
F_l = F(i_l_start:i_l_stop);
d_l = d(i_l_start:i_l_stop);
F_s = F(i_s_start:i_s_stop);
d_s = d(i_s_start:i_s_stop);
%% Fit the best straight line for the two regions
fit_l = polyfit(F_l, d_l, 1);
fit_s = polyfit(F_s, d_s, 1);
%% Reset displacement based on fit
d = d - fit_l(2);
fit_s(2) = fit_s(2) - fit_l(2);
fit_l(2) = 0;
% The raw data as well as the fit corresponding to the two stiffnesses are shown in Figure ref:fig:test_joints_meas_F_d_lin_fit.
figure;
hold on;
plot(F(1:i_s_stop), 1e3*d(1:i_s_stop), '.k')
plot(F_l, 1e3*(F_l*fit_l(1) + fit_l(2)))
plot(F_s, 1e3*(F_s*fit_s(1) + fit_s(2)))
hold off;
xlabel('Force [N]'); ylabel('Displacement [mm]');
xlim([0,6]);
% #+name: fig:test_joints_meas_F_d_lin_fit
% #+caption: Typical measurement of the diplacement as a function of the applied force with estimated linear fits
% #+RESULTS:
% [[file:figs/test_joints_meas_F_d_lin_fit.png]]
% Then, the bending stroke is estimated as crossing point between the two fitted lines:
d_max = fit_l(1)*fit_s(2)/(fit_l(1) - fit_s(1));
% Bending stiffness and bending stroke of all the flexible joints
% Now, let's estimate the bending stiffness and stroke for all the flexible joints.
%% Initialize variables
kRx = zeros(1,16);
kSx = zeros(1,16);
Rmx = zeros(1,16);
for i = 1:16
%% Load the data
load(['meas_stiff_flex_' num2str(i) '_x.mat'], 't', 'F', 'd');
%% Automatic Zero of the force
F = F - mean(F(t > 0.1 & t < 0.3));
%% Start measurement at t = 0.2 s
d = d(t > 0.2);
F = F(t > 0.2);
t = t(t > 0.2); t = t - t(1);
%% Estimate linear region and "stop" region
i_l_start = find(F > 0.3, 1, 'first');
d = d - d(i_l_start);
[~, i_s_stop] = max(F);
i_l_stop = find(d > 0.9*d(i_s_stop), 1, 'first');
i_s_start = find(F > max(F)-1, 1, 'first');
F_l = F(i_l_start:i_l_stop);
d_l = d(i_l_start:i_l_stop);
F_s = F(i_s_start:i_s_stop);
d_s = d(i_s_start:i_s_stop);
%% Straight line fit
fit_l = polyfit(F_l, d_l, 1);
fit_s = polyfit(F_s, d_s, 1);
%% Reset displacement based on fit
d = d - fit_l(2);
fit_s(2) = fit_s(2) - fit_l(2);
fit_l(2) = 0;
%% Estimated Stroke
d_max = fit_l(1)*fit_s(2)/(fit_l(1) - fit_s(1));
%% Save stiffnesses and stroke
kRx(i) = (h)^2/fit_l(1);
kSx(i) = (h)^2/fit_s(1);
Rmx(i) = atan2(d_max,h);
end
%% Initialize variables
kRy = zeros(1,16);
kSy = zeros(1,16);
Rmy = zeros(1,16);
for i = 1:16
%% Load the data
load(['meas_stiff_flex_' num2str(i) '_y.mat'], 't', 'F', 'd');
%% Automatic Zero of the force
F = F - mean(F(t > 0.1 & t < 0.3));
%% Start measurement at t = 0.2 s
d = d(t > 0.2);
F = F(t > 0.2);
t = t(t > 0.2); t = t - t(1);
%% Estimate linear region and "stop" region
i_l_start = find(F > 0.3, 1, 'first');
d = d - d(i_l_start);
[~, i_s_stop] = max(F);
i_l_stop = find(d > 0.9*d(i_s_stop), 1, 'first');
i_s_start = find(F > max(F)-1, 1, 'first');
F_l = F(i_l_start:i_l_stop);
d_l = d(i_l_start:i_l_stop);
F_s = F(i_s_start:i_s_stop);
d_s = d(i_s_start:i_s_stop);
%% Straight line fit
fit_l = polyfit(F_l, d_l, 1);
fit_s = polyfit(F_s, d_s, 1);
%% Reset displacement based on fit
d = d - fit_l(2);
fit_s(2) = fit_s(2) - fit_l(2);
fit_l(2) = 0;
%% Estimated Stroke
d_max = fit_l(1)*fit_s(2)/(fit_l(1) - fit_s(1));
%% Save stiffnesses and stroke
kRy(i) = (h)^2/fit_l(1);
kSy(i) = (h)^2/fit_s(1);
Rmy(i) = atan2(d_max,h);
end
% Analysis
% The dispersion of the measured bending stiffness is shown in Figure ref:fig:test_joints_bend_stiff_hist and of the bending stroke in Figure ref:fig:test_joints_bend_stroke_hist.
figure;
hold on;
histogram(kRx, 'DisplayName', '$k_{R_x}$')
histogram(kRy, 'DisplayName', '$k_{R_y}$')
hold off;
xlabel('Bending Stiffness [Nm/rad]')
legend();
% #+name: fig:test_joints_bend_stiff_hist
% #+caption: Histogram of the measured bending stiffness
% #+RESULTS:
% [[file:figs/test_joints_bend_stiff_hist.png]]
figure;
hold on;
histogram(1e3*Rmx, 'DisplayName', '$k_{R_x}$')
histogram(1e3*Rmy, 'DisplayName', '$k_{R_y}$')
hold off;
xlabel('Bending Stroke [mrad]')
legend();
% #+name: fig:test_joints_bend_stroke_hist
% #+caption: Histogram of the measured bending stroke
% #+RESULTS:
% [[file:figs/test_joints_bend_stroke_hist.png]]
% The relation between the measured beam thickness and the measured bending stiffness is shown in Figure ref:fig:test_joints_thickness_stiffness.
load('flex_meas_dim.mat', 'meas_flex');
figure;
hold on;
plot((meas_flex(:,1)+meas_flex(:,2))/2, kRx, 'o', 'DisplayName', '$x$')
plot((meas_flex(:,3)+meas_flex(:,4))/2, kRy, 'o', 'DisplayName', '$y$')
hold off;
xlabel('Flexible Beam Thickness [$\mu m$]');
ylabel('Bending Stiffness [Nm/rad]');
legend('location', 'southeast');