Skip to content
Snippets Groups Projects
Commit bdd57ece authored by burneykb's avatar burneykb
Browse files
parents 8c8cbcfd d1929714
No related branches found
No related tags found
No related merge requests found
Showing
with 17 additions and 19 deletions
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
......
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
......
% 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 );
% 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
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);
......
File added
File added
File added
File moved
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