diff --git a/controls/MATLAB/thrustAndDragConstant/calcDragConstant.m b/controls/MATLAB/thrustAndDragConstant/calcDragConstant.m index 1a888d4f683e4fee08aba806366e258a91a1617e..5f46efe50f2a9ebb931ce426f09bbe8121c80a3f 100644 --- a/controls/MATLAB/thrustAndDragConstant/calcDragConstant.m +++ b/controls/MATLAB/thrustAndDragConstant/calcDragConstant.m @@ -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 % a least squares approximation of all of the data. % -% u: Defined in section 4.2.5 -% omega: vector of each rotors speed in rad/s -% A: column vector of each rotors speed squared -% b: Defined in section 5.5.4.1 -% Kd_vector: Vector containing all experimental Kd values -% Vb: Battery voltage -u1 = ((data.(1)/100) - Pmin)/(Pmax - Pmin); -u2 = ((data.(1)/100) - Pmin)/(Pmax - Pmin); -u3 = ((data.(1)/100) - Pmin)/(Pmax - Pmin); -u4 = ((data.(1)/100) - Pmin)/(Pmax - Pmin); +% u: Defined in section 4.2.5 +% omega: vector of each rotors speed in rad/s +% A: column vector of each rotors speed squared +% b: Defined in section 5.5.4.1 +% Kd_vector: Vector containing all experimental Kd values +% Vb: Battery voltage +u1 = ((data.(1)) - Pmin)/(Pmax - Pmin); +u2 = ((data.(1)) - Pmin)/(Pmax - Pmin); +u3 = ((data.(1)) - Pmin)/(Pmax - Pmin); +u4 = ((data.(1)) - Pmin)/(Pmax - Pmin); u = [u1; u2; u3; u4]; Vb = [data.(6); data.(6); data.(6); data.(6)]; omega = [rotor_speed_0; rotor_speed_1; rotor_speed_2; rotor_speed_3]; A = omega.^2; b = ((u.*Vb)/(Rm*Kq))-omega./(Rm*Kq*Kv)-If/Kq; -Kd = ((A'*A)^-1)*A'*b +Kd = ((A'*A)^-1)*A'*b; end diff --git a/controls/MATLAB/thrustAndDragConstant/calcThrustConstant.m b/controls/MATLAB/thrustAndDragConstant/calcThrustConstant.m index c69b9fe88f1fb5775e384733d3e4ffc02cac2208..91e8e7618bae382a640791dec7340c84db3369d4 100644 --- a/controls/MATLAB/thrustAndDragConstant/calcThrustConstant.m +++ b/controls/MATLAB/thrustAndDragConstant/calcThrustConstant.m @@ -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. T = (data.Scale_g_/1000)*9.8; -% Calculate the thrust constant (Kt) through the following -% equation: Kt = (A'A)^-1.*A'.*T as defined on page 65 of "Model +% Calculate the thrust constant (Kt) through least squares approximation +% Kt = (A'A)^-1.*A'.*T as defined on page 65 of "Model % development, system identification, and control of a quadrotor % helicopter" (Matt Rich's Thesis). -Kt = ((A'*A)^(-1))*(A'*T) +Kt = ((A'*A)^(-1))*(A'*T); end diff --git a/controls/MATLAB/thrustAndDragConstant/thrustDragConstantCalculations.m b/controls/MATLAB/thrustAndDragConstant/thrustDragConstantCalculations.m index 1ef35479243d2f50a2f1e4b015a50bcff2650a3d..827ae3c87799d2b781fec882baa4cb24acaa780a 100644 --- a/controls/MATLAB/thrustAndDragConstant/thrustDragConstantCalculations.m +++ b/controls/MATLAB/thrustAndDragConstant/thrustDragConstantCalculations.m @@ -2,9 +2,9 @@ addpath('C:\Users\Andy\Documents\School\MicroCART\GitRepo\MicroCART_17-18\controls\MATLAB\zeroLoadCurrent') % 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); @@ -14,8 +14,8 @@ rotor_speed_2 = data.(4) * (pi/30); rotor_speed_3 = data.(5) * (pi/30); % Define Pmin and Pmax, as well as the motor parameters Rm, Kv, Kq, and If -Pmin = 0.40; -Pmax = 0.8; +Pmin = 1e5; +Pmax = 2e5; Rm = 0.2308; Kv = 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; If = [If0; If1; If2; If3]; % Call the calc_thrust_constant() function. -Kt = calcThrustConstant(data); +Kt = calcThrustConstant(data) % Call the calc_drift_constant() function. -Kd = calcDragConstant(data, Pmin, Pmax, Rm, Kv, Kq, If ); +Kd = calcDragConstant(data, Pmin, Pmax, Rm, Kv, Kq, If) diff --git a/controls/dataCollection/Thrust and Drag Constant Data v2.xlsx b/controls/dataCollection/Thrust and Drag Constant Data v2.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..b187c4f2eb2211604727e86c58726f207be56ae4 Binary files /dev/null and b/controls/dataCollection/Thrust and Drag Constant Data v2.xlsx differ