Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alberto Ruiz Garcia
Firmware
Commits
86970eea
Commit
86970eea
authored
10 years ago
by
Lorenz Meier
Browse files
Options
Downloads
Patches
Plain Diff
Matlab tools: Motor transfer function curves
parent
f2b2c55a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Tools/Matlab/motors.m
+58
-0
58 additions, 0 deletions
Tools/Matlab/motors.m
with
58 additions
and
0 deletions
Tools/Matlab/motors.m
0 → 100644
+
58
−
0
View file @
86970eea
clear
all
;
close
all
;
% Measurement data
% 1045 propeller
% Robbe Roxxy Motor (1100 kV, data collected in 2010)
data
=
[
45
,
7.4
;
...
38
,
5.6
;
...
33
,
4.3
;
...
26
,
3.0
;
...
18
,
2.0
;
...
10
,
1.0
];
% Normalize the data, as we're operating later
% anyways in normalized units
data
(:,
1
)
=
data
(:,
1
)
.
/
max
(
data
(:,
1
));
data
(:,
2
)
=
data
(:,
2
)
.
/
max
(
data
(:,
2
));
% Fit a 2nd degree polygon to the data and
% print the x2, x1, x0 coefficients
p
=
polyfit
(
data
(:,
2
),
data
(:,
1
),
2
)
% Override the first coffefficient for testing
% purposes
pf
=
0.62
;
% Generate plotting data
px1
=
linspace
(
0
,
max
(
data
(:,
2
)));
py1
=
polyval
(
p
,
px1
);
pyt
=
zeros
(
size
(
data
,
1
),
1
);
corr
=
zeros
(
size
(
data
,
1
),
1
);
% Actual code test
% the two lines below are the ones needed to be ported to C:
% pf: Power factor parameter.
% px1(i): The current normalized motor command (-1..1)
% corr(i): The required correction. The motor speed is:
% px1(i)
for
i
=
1
:
size
(
px1
,
2
)
% The actual output throttle
pyt
(
i
)
=
-
pf
*
(
px1
(
i
)
*
px1
(
i
))
+
(
1
+
pf
)
*
px1
(
i
);
% Solve for input throttle
% y = -p * x^2 + (1+p) * x;
%
end
plot
(
data
(:,
2
),
data
(:,
1
),
'*r'
);
hold
on
;
plot
(
px1
,
py1
,
'*b'
);
hold
on
;
plot
([
0
px1
(
end
)],
[
0
py1
(
end
)],
'-k'
);
hold
on
;
plot
(
px1
,
pyt
,
'-b'
);
hold
on
;
plot
(
px1
,
corr
,
'-m'
);
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