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

Updated zeroLoadCurrent scripts to incorporate new motor command ranges

parent 7b2c7279
No related branches found
No related tags found
No related merge requests found
% Read in data
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\noLoadCurrentv2.xlsx';
[I_0, I_1, I_2, dutyCycle_error, error, residual_error, residual_error_ConstantIf] = zeroLoadCurrent(filePath_noLoadCurrentData);
[I_0, I_1, I_2, motorCommand_error, error, residual_error, residual_error_ConstantIf] = zeroLoadCurrent(filePath_noLoadCurrentData);
Pmin = 0.40;
Pmax = 0.8;
Pmin = 1e5;
Pmax = 2e5;
Rm = 0.2308;
Kv = 96.3422;
Kq = 96.3422;
Kd = 1.0317e-7;
% Convert RPM to angular speed of each rotor.
rotor_speed_0 = data.(2) * (pi/30);
......@@ -17,10 +18,10 @@ rotor_speed_1 = data.(3) * (pi/30);
rotor_speed_2 = data.(4) * (pi/30);
rotor_speed_3 = data.(5) * (pi/30);
duty_cycle_percentage = data.(1);
motorCommand = data.(1);
Vb = data.(6);
u = ((data.(1)/100) - Pmin)/(Pmax - Pmin);
u = ((data.(1)) - Pmin)/(Pmax - Pmin);
If = I_0 * sign(rotor_speed_0) + I_1 * rotor_speed_0 + I_2 * rotor_speed_0.^2;
w_num = -1 + sqrt( 1 - 4*Rm*Kv*Kq*Kd*(Kv*Rm*If - Kv*u.*Vb));
......@@ -29,13 +30,10 @@ w = w_num / w_den;
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(motorCommand, w); grid()
plot(motorCommand, rotor_speed_0);
xlabel('Duty Cycle Percentage');
xlabel('Motor Command');
ylabel('Rotor Speed (rad/s)')
residual_error
......
function [I_0, I_1, I_2, dutyCycle, error, residual_error, residual_error_constantIf] = zeroLoadCurrent(absoluteFilePath)
function [I_0, I_1, I_2, motorCommand, 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
......@@ -9,7 +9,7 @@ function [I_0, I_1, I_2, dutyCycle, error, residual_error, residual_error_consta
data = readtable(absoluteFilePath);
%Extract the motor speed column and convert it to radians per second
dutyCycle = data.(1);
motorCommand = data.(1);
motorSpeed_rpm = data.(2);
motorSpeed_radPerSec = motorSpeed_rpm * pi/30;
......
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