diff --git a/MATLAB/momentOfInertia/getAverageMomentOfInertia.m b/controls/MATLAB/momentOfInertia/getAverageMomentOfInertia.m similarity index 100% rename from MATLAB/momentOfInertia/getAverageMomentOfInertia.m rename to controls/MATLAB/momentOfInertia/getAverageMomentOfInertia.m diff --git a/MATLAB/momentOfInertia/getMomentOfInertia.m b/controls/MATLAB/momentOfInertia/getMomentOfInertia.m similarity index 100% rename from MATLAB/momentOfInertia/getMomentOfInertia.m rename to controls/MATLAB/momentOfInertia/getMomentOfInertia.m diff --git a/MATLAB/momentOfInertia/getMomentOfInertiaFinalData.m b/controls/MATLAB/momentOfInertia/getMomentOfInertiaFinalData.m similarity index 100% rename from MATLAB/momentOfInertia/getMomentOfInertiaFinalData.m rename to controls/MATLAB/momentOfInertia/getMomentOfInertiaFinalData.m diff --git a/MATLAB/thrustAndDragConstant/calc_drag_constant.m b/controls/MATLAB/thrustAndDragConstant/calcDragConstant.m similarity index 96% rename from MATLAB/thrustAndDragConstant/calc_drag_constant.m rename to controls/MATLAB/thrustAndDragConstant/calcDragConstant.m index 53a7cc6b4ccef432358e58831223b90ad6125e7c..1a888d4f683e4fee08aba806366e258a91a1617e 100644 --- a/MATLAB/thrustAndDragConstant/calc_drag_constant.m +++ b/controls/MATLAB/thrustAndDragConstant/calcDragConstant.m @@ -1,4 +1,4 @@ -function [ Kd ] = calc_drag_constant( data, Pmin, Pmax, Rm, Kv, Kq, If ) +function [ Kd ] = calcDragConstant( data, Pmin, Pmax, Rm, Kv, Kq, If ) %CALC_DRAG_CONSTANT % Calculates the drag constant (Kd) given experimental data. The drag % constant is described in detail in sections 4.2.5, 4.2.6, and 5.5.4.1 diff --git a/MATLAB/thrustAndDragConstant/calc_thrust_constant.m b/controls/MATLAB/thrustAndDragConstant/calcThrustConstant.m similarity index 95% rename from MATLAB/thrustAndDragConstant/calc_thrust_constant.m rename to controls/MATLAB/thrustAndDragConstant/calcThrustConstant.m index 202b41eaafa54eec47d1237e9febcb7dca3db5fa..c69b9fe88f1fb5775e384733d3e4ffc02cac2208 100644 --- a/MATLAB/thrustAndDragConstant/calc_thrust_constant.m +++ b/controls/MATLAB/thrustAndDragConstant/calcThrustConstant.m @@ -1,4 +1,4 @@ -function [ Kt ] = calc_thrust_constant( data ) +function [ Kt ] = calcThrustConstant( data ) %CALC_THRUST_CONSTANT % Calculates the thrust constant (Kt) given experimental data. The thrust % constant is described in detail in sections 4.2.1.1 and 5.5.1 of diff --git a/MATLAB/thrustAndDragConstant/thrust_drag_constant_calculations.m b/controls/MATLAB/thrustAndDragConstant/thrustDragConstantCalculations.m similarity index 76% rename from MATLAB/thrustAndDragConstant/thrust_drag_constant_calculations.m rename to controls/MATLAB/thrustAndDragConstant/thrustDragConstantCalculations.m index 1f8caf84b5df55c3bff5f34dd0bcab6f1ad14b66..1ef35479243d2f50a2f1e4b015a50bcff2650a3d 100644 --- a/MATLAB/thrustAndDragConstant/thrust_drag_constant_calculations.m +++ b/controls/MATLAB/thrustAndDragConstant/thrustDragConstantCalculations.m @@ -1,9 +1,12 @@ +% Add path to zeroLoadCurrent() function +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'); filePath_noLoadCurrentData = 'C:\Users\Andy\Documents\MATLAB\MicroCART\Zero Load Current\No Load Friction Current.csv'; -[I_0, I_1, I_2] = zero_load_current(filePath_noLoadCurrentData); +[I_0, I_1, I_2] = zeroLoadCurrent(filePath_noLoadCurrentData); rotor_speed_0 = data.(2) * (pi/30); rotor_speed_1 = data.(3) * (pi/30); @@ -23,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 = calc_thrust_constant(data); +Kt = calcThrustConstant(data); % Call the calc_drift_constant() function. -Kd = calc_drag_constant(data, Pmin, Pmax, Rm, Kv, Kq, If ); +Kd = calcDragConstant(data, Pmin, Pmax, Rm, Kv, Kq, If ); diff --git a/MATLAB/zeroLoadCurrent/Kd_error.m b/controls/MATLAB/zeroLoadCurrent/Kd_error.m similarity index 75% rename from MATLAB/zeroLoadCurrent/Kd_error.m rename to controls/MATLAB/zeroLoadCurrent/Kd_error.m index 8ecec2bdca8036db3f4c3e0e651a436d94ad5585..9e087f5394d289bce2eba3bc3b920af917d8ef2f 100644 --- a/MATLAB/zeroLoadCurrent/Kd_error.m +++ b/controls/MATLAB/zeroLoadCurrent/Kd_error.m @@ -1,15 +1,15 @@ +% Read in data data = readtable('C:\Users\Andy\Documents\MATLAB\MicroCART\Thrust and Drag Constant\Thrust and Drag Constant Data.xlsx'); filePath_noLoadCurrentData = 'C:\Users\Andy\Documents\MATLAB\MicroCART\Zero Load Current\No Load Friction Current.csv'; -[I_0, I_1, I_2, dutyCycle_error, error, residual_error, residual_error_withIfConstant] = zero_load_current(filePath_noLoadCurrentData); +[I_0, I_1, I_2, dutyCycle_error, error, residual_error, residual_error_ConstantIf] = zeroLoadCurrent(filePath_noLoadCurrentData); Pmin = 0.40; Pmax = 0.8; Rm = 0.2308; Kv = 96.3422; Kq = 96.3422; -If = 0.44; % Convert RPM to angular speed of each rotor. rotor_speed_0 = data.(2) * (pi/30); @@ -31,18 +31,13 @@ figure() hold on plot(duty_cycle_percentage, w); grid() plot(duty_cycle_percentage, rotor_speed_0); -plot(duty_cycle_percentage, rotor_speed_1); -plot(duty_cycle_percentage, rotor_speed_2); -plot(duty_cycle_percentage, rotor_speed_3); +%plot(duty_cycle_percentage, rotor_speed_1); +%plot(duty_cycle_percentage, rotor_speed_2); +%plot(duty_cycle_percentage, rotor_speed_3); xlabel('Duty Cycle Percentage'); ylabel('Rotor Speed (rad/s)') -figure() -plot(dutyCycle_error, error); grid() -xlabel('Duty Cycle Percentage'); -ylabel('Error'); - residual_error -residual_error_withIfConstant \ No newline at end of file +residual_error_ConstantIf \ No newline at end of file diff --git a/MATLAB/zeroLoadCurrent/zero_load_current.m b/controls/MATLAB/zeroLoadCurrent/zeroLoadCurrent.m similarity index 92% rename from MATLAB/zeroLoadCurrent/zero_load_current.m rename to controls/MATLAB/zeroLoadCurrent/zeroLoadCurrent.m index a9ec2e607b5bfcfa866c0000f4f296b5af103104..5ce2636122b937a2396a507ad8acb374a07d73cd 100644 --- a/MATLAB/zeroLoadCurrent/zero_load_current.m +++ b/controls/MATLAB/zeroLoadCurrent/zeroLoadCurrent.m @@ -1,4 +1,4 @@ -function [I_0, I_1, I_2, dutyCycle, error, residual_error, residual_error_withIfConstant] = zero_load_current(absoluteFilePath) +function [I_0, I_1, I_2, dutyCycle, error, residual_error, residual_error_constantIf] = zeroLoadCurrent(absoluteFilePath) %This function takes in an absolute file path to a .csv or Excel file with %the following format: % Second column should be the motor speed in revolutions per minute @@ -48,10 +48,10 @@ function [I_0, I_1, I_2, dutyCycle, error, residual_error, residual_error_withIf If_constant = 0.511; error_withIfConstant = A*[If_constant; 0; 0] - b; - %Get the residual (?) + %Get the residual error residual_error = sum(error.^2); - residual_error_withIfConstant = sum(error_withIfConstant.^2); + residual_error_constantIf = sum(error_withIfConstant.^2); %Extract the components of the vector I_0 = I_vector(1); diff --git a/controls/dataCollection/Moment of Inertia 10-25-16.xlsx b/controls/dataCollection/Moment of Inertia 10-25-16.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..22029fa973c512776a1f5bd522d59ffad64a2aa1 Binary files /dev/null and b/controls/dataCollection/Moment of Inertia 10-25-16.xlsx differ diff --git a/controls/dataCollection/No Load Friction Current.xlsx b/controls/dataCollection/No Load Friction Current.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..bfe2f49b8b4a86f826c3194214df2bad0254cd61 Binary files /dev/null and b/controls/dataCollection/No Load Friction Current.xlsx differ diff --git a/controls/dataCollection/Thrust and Drag Constant Data.xlsx b/controls/dataCollection/Thrust and Drag Constant Data.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..f3ea1c03e98dcf630ae6ffb3278e55479389def3 Binary files /dev/null and b/controls/dataCollection/Thrust and Drag Constant Data.xlsx differ diff --git a/Model/Quadcopter_Model.slx b/controls/model/Quadcopter_Model.slx similarity index 100% rename from Model/Quadcopter_Model.slx rename to controls/model/Quadcopter_Model.slx diff --git a/controls/parameterIdentification/ModelingParameters.docx b/controls/parameterIdentification/ModelingParameters.docx new file mode 100644 index 0000000000000000000000000000000000000000..0dcc977533f1c133a95ff775eac36f0a635f071b Binary files /dev/null and b/controls/parameterIdentification/ModelingParameters.docx differ