Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MicroCART
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Distributed Autonomous Networked Control Lab
MicroCART
Commits
c7a60e5f
Commit
c7a60e5f
authored
8 years ago
by
Andy Snawerdt
Browse files
Options
Downloads
Patches
Plain Diff
Updated zeroLoadCurrent scripts to incorporate new motor command ranges
parent
7b2c7279
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
controls/MATLAB/zeroLoadCurrent/Kd_error.m
+11
-13
11 additions, 13 deletions
controls/MATLAB/zeroLoadCurrent/Kd_error.m
controls/MATLAB/zeroLoadCurrent/zeroLoadCurrent.m
+2
-2
2 additions, 2 deletions
controls/MATLAB/zeroLoadCurrent/zeroLoadCurrent.m
with
13 additions
and
15 deletions
controls/MATLAB/zeroLoadCurrent/Kd_error.m
+
11
−
13
View file @
c7a60e5f
% 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
...
...
This diff is collapsed.
Click to expand it.
controls/MATLAB/zeroLoadCurrent/zeroLoadCurrent.m
+
2
−
2
View file @
c7a60e5f
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
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment