Skip to content

Commit 1e6f07c

Browse files
author
Auralius Manurung
committed
Documenting
1 parent 0f7e908 commit 1e6f07c

File tree

3 files changed

+27
-11
lines changed

3 files changed

+27
-11
lines changed

demo1.m

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@
8888
[F(j), z] = lugref(z, v(j), Fc, Fs, vs, sigma_0, sigma_1, sigma_2, ts);
8989
end
9090

91-
% Start from t = 5, at the begining, the F response is unconsistent
92-
% since we don't know hwo to initialize z.
91+
% Start from t = 5, at the begining, the F response is inconsistent
92+
% since we don't know how to initialize z. Here, we initialize z with 0.
9393
plot(v(5/ts:end), F(5/ts:end), color(i));
9494
end
9595

@@ -112,21 +112,23 @@
112112

113113
M = 1; % a unit mass
114114

115-
u_max = 0.95 * Fs;
115+
u_max = 0.95 * Fs; % 95 %
116116
u1 = generate_ramp_signal(0, u_max, 10, ts);
117117
u2 = generate_ramp_signal(u_max, u_max, 5, ts);
118118
u3 = generate_ramp_signal(u_max, -u_max, 20, ts);
119119
u4 = generate_ramp_signal(-u_max, -u_max, 5, ts);
120120
u5 = generate_ramp_signal(-u_max, u_max, 20, ts);
121121
u6 = generate_ramp_signal(u_max, u_max, 5, ts);
122122

123-
u = [u1 u2 u3 u4 u5 u6];
123+
u = [u1 u2 u3 u4 u5 u6]; % put them together
124124

125+
% Some initializations
125126
F = 0;
126127
z = 0;
127128
x_0 = 0;
128129
v = 0;
129130

131+
% Do the simulation for all input u
130132
for i = 1:length(u)
131133
[F(i), z] = lugref(z, v, Fc, Fs, vs, sigma_0, sigma_1, sigma_2, ts);
132134

@@ -151,19 +153,24 @@
151153

152154
clear F v u u1 u2 u3 u4 u5 u6;
153155

154-
k = 2;
156+
k = 2; % stiffness k = 2 N/m
155157

156-
ts = 1e-6; % 1e-4 fails!, very stiff system, needs a better ODE solver
158+
ts = 1e-6; % 1e-4 fails, this is very stiff system, we need a better ODE solver
157159
time_span = 30;
158160
t = 0 : ts : time_span;
159161

162+
% generate_ramp_signal(min_val, max_val, t_max, ts)
163+
% The velocity is 0.1 m/s, it means if we start from t=0 to t=time_span
164+
% then our travel distace is 0.1*time_span
160165
y = generate_ramp_signal(0, time_span*0.1, time_span, ts);
161-
x = 0;
162166

167+
% Some initializations
168+
x = 0;
163169
z = 0;
164170
x_0 = 0;
165171
v = 0;
166172

173+
% Do the simulation
167174
for i = 1:length(y)
168175
[F(i), z] = lugref(z, v, Fc, Fs, vs, sigma_0, sigma_1, sigma_2, ts);
169176
u_spring = k*(y(i) - x(i));
@@ -175,7 +182,7 @@
175182
x_0 = x(i+1);
176183
end
177184

178-
% compute the speed of the unit-mass
185+
% Compute the speed of the unit-mass
179186
x_dot = gradient(x)/ts;
180187

181188
figure
@@ -218,16 +225,18 @@
218225
% As soon as we detect the first negative gradient of the force, we must
219226
% stop.
220227

221-
ts = 1e-6; % very stiff system, needs a better ODE solver
228+
ts = 1e-6; % very stiff system, we need a better ODE solver
222229
time_span = 2;
223230
t = 0 : ts : time_span;
224231

225232
M = 1; % a unit mass
226233

234+
% I am just guessing from Fig. 4
227235
F_rate = [1 2 3 4 5 10 20 30 40 45 50];
228236

229237
for j = 1 : length(F_rate)
230238

239+
% Always clear up the old values
231240
clear F v x x_dot
232241

233242
u = generate_ramp_signal(0, F_rate(j)*time_span, time_span, ts);
@@ -246,6 +255,8 @@
246255

247256
x_0 = x(i);
248257

258+
% When motion occurs, the resulting force suddenly drops
259+
% See Fig. 6 (bottom figure)
249260
if i > 1 && (F(i)-F(i-1)) < 0
250261
break;
251262
end
@@ -278,11 +289,13 @@
278289
% Desired position for the mass, its intial position is x = 0
279290
xd = 1;
280291

292+
% Some initializations
281293
z = 0;
282294
x_0 = 0;
283295
v = 0;
284296
x = x_0;
285297

298+
% The integral of error with respect to time
286299
int_e = 0;
287300

288301
for i = 1:length(t)

demo2.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@
189189
zdot = q_sol(k,2) - ( (q_sol(k,3)*abs(q_sol(k,2))*sigma_0) / ...
190190
(Fc+(Fs-Fc)*exp(-(q_sol(k,2)/vs)^2)) );
191191
F(k) = sigma_0*q_sol(k,3) + sigma_1 * zdot + sigma_2*q_sol(k,2);
192+
193+
% When motion occurs, the resulting force suddenly drops
194+
% See Fig. 6 (bottom figure)
192195
if (k>1) && (F(k)-F(k-1)<0)
193196
break;
194197
end

sim_stick_slip.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function xdot = sim_stick_slip(t, q, M, Fs, Fc, sigma_0, sigma_1, sigma_2, vs)
2-
k = 2; % stiffness of the spring
3-
y = 0.1*t; % 0.1 m/s
2+
k = 2; % stiffness of the spring
3+
y = 0.1*t; % y is moving with 0.1 m/s of speed
44
u = k * (y - q(1)); % force by the spring
55

66
zdot = q(2) - ( (q(3)*abs(q(2))*sigma_0) / (Fc+(Fs-Fc)*exp(-(q(2)/vs)^2)) );

0 commit comments

Comments
 (0)