- cleaned up
git-svn-id: http://moon:8086/svn/projects/HendiControl@126 fda53097-d464-4ada-af97-ba876c37ca34
This commit is contained in:
+1
-38
@@ -46,7 +46,6 @@ theta_ist = params.theta_amb;
|
||||
theta_last = params.theta_amb;
|
||||
thetas = varargin{nargin}
|
||||
heatRate = 0;
|
||||
heatRate_f = 0;
|
||||
heatRateMeasureInterval = 1.0; % seconds
|
||||
heatRateMeasureCount = 0; % seconds
|
||||
n = 0;
|
||||
@@ -54,15 +53,6 @@ nSteps = params.P_max / params.P_q;
|
||||
|
||||
N = 2*fix(length(thetas)*params.T/params.dt);
|
||||
|
||||
maz = 7;
|
||||
lp_N = 5;
|
||||
[lp_b, lp_a] = butter (lp_N-1, 0.25);
|
||||
lp_z = zeros(1, length(lp_b)-1);
|
||||
|
||||
lp_rate_N = 17;
|
||||
[lp_rate_b, lp_rate_a] = butter (lp_rate_N-1, 0.125);
|
||||
lp_rate_z = zeros(1, length(lp_rate_b)-1);
|
||||
|
||||
P_cont = 0;
|
||||
y_rate = 0;
|
||||
y = 0;
|
||||
@@ -178,10 +168,9 @@ for k=1:length(thetas)
|
||||
theta_last = theta_ist;
|
||||
end
|
||||
heatRateMeasureCount = heatRateMeasureCount - params.dt;
|
||||
[heatRate_f, lp_rate_z] = filter(lp_rate_b, lp_rate_a, heatRate, lp_rate_z);
|
||||
n = n + 1;
|
||||
theta_ist = theta_ist;
|
||||
heatRate_(n) = heatRate_f;
|
||||
heatRate_(n) = heatRate;
|
||||
theta_(n) = theta_ist;
|
||||
err_(n) = err0_hold;
|
||||
p_(n) = P;
|
||||
@@ -235,38 +224,12 @@ s.e = s.e + s.x;
|
||||
theta = s.e/(M*C);
|
||||
endfunction
|
||||
|
||||
function [y, y_clamped, s] = pid(si, kp, ki, kd, kleak, x)
|
||||
s = si;
|
||||
if ~isstruct(si)
|
||||
s = struct('p', 0, 'i', 0, 'd', 0, 'x', 0, 'y_min', -0.0, 'y_max', 1.0, 'diff_aw', 0.0);
|
||||
end
|
||||
|
||||
s.d = kd*(x - s.x);
|
||||
s.i = kleak*s.i + ki*x + s.diff_aw;
|
||||
s.p = kp*x;
|
||||
s.x = x;
|
||||
|
||||
y = s.p + s.i + s.d;
|
||||
y_clamped = max(s.y_min, min(s.y_max, y));
|
||||
|
||||
if (y < s.y_min)
|
||||
s.diff_aw = abs(y - s.y_min);
|
||||
end
|
||||
|
||||
if (y > s.y_max)
|
||||
s.diff_aw = -abs(y - s.y_max);
|
||||
end
|
||||
|
||||
|
||||
endfunction
|
||||
|
||||
function [y, z] = isStable(zi, v, maxErr)
|
||||
z = zi;
|
||||
if ~isstruct(zi)
|
||||
z = struct('v', 0, 'cnt', 3, 'cnt_reload', 3);
|
||||
end
|
||||
|
||||
|
||||
if z.cnt > 0
|
||||
z.cnt = z.cnt - 1;
|
||||
endif
|
||||
|
||||
Reference in New Issue
Block a user