Skip to content
Snippets Groups Projects
Commit ee02a2b2 authored by Andy Snawerdt's avatar Andy Snawerdt
Browse files

Updated scripts for calculating thrust and drag constant

parent 14263cf9
No related branches found
No related tags found
No related merge requests found
...@@ -30,22 +30,22 @@ rotor_speed_3 = data.(5) * (pi/30); ...@@ -30,22 +30,22 @@ rotor_speed_3 = data.(5) * (pi/30);
% done by stacking the data of each motor in a single array and performing % done by stacking the data of each motor in a single array and performing
% a least squares approximation of all of the data. % a least squares approximation of all of the data.
% %
% u: Defined in section 4.2.5 % u: Defined in section 4.2.5
% omega: vector of each rotors speed in rad/s % omega: vector of each rotors speed in rad/s
% A: column vector of each rotors speed squared % A: column vector of each rotors speed squared
% b: Defined in section 5.5.4.1 % b: Defined in section 5.5.4.1
% Kd_vector: Vector containing all experimental Kd values % Kd_vector: Vector containing all experimental Kd values
% Vb: Battery voltage % Vb: Battery voltage
u1 = ((data.(1)/100) - Pmin)/(Pmax - Pmin); u1 = ((data.(1)) - Pmin)/(Pmax - Pmin);
u2 = ((data.(1)/100) - Pmin)/(Pmax - Pmin); u2 = ((data.(1)) - Pmin)/(Pmax - Pmin);
u3 = ((data.(1)/100) - Pmin)/(Pmax - Pmin); u3 = ((data.(1)) - Pmin)/(Pmax - Pmin);
u4 = ((data.(1)/100) - Pmin)/(Pmax - Pmin); u4 = ((data.(1)) - Pmin)/(Pmax - Pmin);
u = [u1; u2; u3; u4]; u = [u1; u2; u3; u4];
Vb = [data.(6); data.(6); data.(6); data.(6)]; Vb = [data.(6); data.(6); data.(6); data.(6)];
omega = [rotor_speed_0; rotor_speed_1; rotor_speed_2; rotor_speed_3]; omega = [rotor_speed_0; rotor_speed_1; rotor_speed_2; rotor_speed_3];
A = omega.^2; A = omega.^2;
b = ((u.*Vb)/(Rm*Kq))-omega./(Rm*Kq*Kv)-If/Kq; b = ((u.*Vb)/(Rm*Kq))-omega./(Rm*Kq*Kv)-If/Kq;
Kd = ((A'*A)^-1)*A'*b Kd = ((A'*A)^-1)*A'*b;
end end
...@@ -21,11 +21,11 @@ A = (rotor_speed_0.^2 + rotor_speed_1.^2 + rotor_speed_2.^2 + rotor_speed_3.^2); ...@@ -21,11 +21,11 @@ A = (rotor_speed_0.^2 + rotor_speed_1.^2 + rotor_speed_2.^2 + rotor_speed_3.^2);
% multiplying by the acceleration of gravity. % multiplying by the acceleration of gravity.
T = (data.Scale_g_/1000)*9.8; T = (data.Scale_g_/1000)*9.8;
% Calculate the thrust constant (Kt) through the following % Calculate the thrust constant (Kt) through least squares approximation
% equation: Kt = (A'A)^-1.*A'.*T as defined on page 65 of "Model % Kt = (A'A)^-1.*A'.*T as defined on page 65 of "Model
% development, system identification, and control of a quadrotor % development, system identification, and control of a quadrotor
% helicopter" (Matt Rich's Thesis). % helicopter" (Matt Rich's Thesis).
Kt = ((A'*A)^(-1))*(A'*T) Kt = ((A'*A)^(-1))*(A'*T);
end end
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
addpath('C:\Users\Andy\Documents\School\MicroCART\GitRepo\MicroCART_17-18\controls\MATLAB\zeroLoadCurrent') addpath('C:\Users\Andy\Documents\School\MicroCART\GitRepo\MicroCART_17-18\controls\MATLAB\zeroLoadCurrent')
% Import data as a table. % Import data as a table.
data = readtable('C:\Users\Andy\Documents\MATLAB\MicroCART\Thrust and Drag Constant\Thrust and Drag Constant Data.xlsx'); data = readtable('C:\Users\Andy\Documents\School\MicroCART\GitRepo\MicroCART_17-18\controls\dataCollection\Thrust and Drag Constant Data v2.xlsx');
filePath_noLoadCurrentData = 'C:\Users\Andy\Documents\MATLAB\MicroCART\Zero Load Current\No Load Friction Current.csv'; filePath_noLoadCurrentData = 'C:\Users\Andy\Documents\School\MicroCART\GitRepo\MicroCART_17-18\controls\dataCollection\No Load Friction Current.xlsx';
[I_0, I_1, I_2] = zeroLoadCurrent(filePath_noLoadCurrentData); [I_0, I_1, I_2] = zeroLoadCurrent(filePath_noLoadCurrentData);
...@@ -14,8 +14,8 @@ rotor_speed_2 = data.(4) * (pi/30); ...@@ -14,8 +14,8 @@ rotor_speed_2 = data.(4) * (pi/30);
rotor_speed_3 = data.(5) * (pi/30); rotor_speed_3 = data.(5) * (pi/30);
% Define Pmin and Pmax, as well as the motor parameters Rm, Kv, Kq, and If % Define Pmin and Pmax, as well as the motor parameters Rm, Kv, Kq, and If
Pmin = 0.40; Pmin = 1e5;
Pmax = 0.8; Pmax = 2e5;
Rm = 0.2308; Rm = 0.2308;
Kv = 96.3422; Kv = 96.3422;
Kq = 96.3422; Kq = 96.3422;
...@@ -26,8 +26,8 @@ If3 = I_0 * sign(rotor_speed_3) + I_1 * rotor_speed_3 + I_2 * rotor_speed_3.^2; ...@@ -26,8 +26,8 @@ If3 = I_0 * sign(rotor_speed_3) + I_1 * rotor_speed_3 + I_2 * rotor_speed_3.^2;
If = [If0; If1; If2; If3]; If = [If0; If1; If2; If3];
% Call the calc_thrust_constant() function. % Call the calc_thrust_constant() function.
Kt = calcThrustConstant(data); Kt = calcThrustConstant(data)
% Call the calc_drift_constant() function. % Call the calc_drift_constant() function.
Kd = calcDragConstant(data, Pmin, Pmax, Rm, Kv, Kq, If ); Kd = calcDragConstant(data, Pmin, Pmax, Rm, Kv, Kq, If)
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment