Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MechaRaptor - Arduino Controller
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Aerospace and Mechanical Engineering
tlambert
MechaRaptor - Arduino Controller
Commits
e83dfb35
Verified
Commit
e83dfb35
authored
2 years ago
by
Thomas Lambert
Browse files
Options
Downloads
Patches
Plain Diff
fix(calib): error in maxWingPos
parent
c5f940b5
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
controller/calibration.ino
+9
-12
9 additions, 12 deletions
controller/calibration.ino
with
9 additions
and
12 deletions
controller/calibration.ino
+
9
−
12
View file @
e83dfb35
...
...
@@ -17,6 +17,7 @@
void
Calibrate
()
{
String
input
;
uint32_t
calibTime
=
6000
;
// Calibration time in ms
Serial
.
println
(
"[INPUT]: Calibrate angles? (Y/n)"
);
...
...
@@ -28,7 +29,9 @@ void Calibrate() {
}
else
{
Serial
.
println
(
"[WARNING]: Setup will run for 8s to get the offset and maximum value."
);
Serial
.
print
(
"[WARNING]: Setup will run for "
);
Serial
.
print
(
calibTime
/
1000
);
Serial
.
print
(
"s to get the offset and maximum value."
);
Serial
.
println
(
"[INPUT]: Type 'Y' to begin."
);
while
(
Serial
.
available
()
==
0
)
{}
// Wait for serial input
...
...
@@ -39,8 +42,8 @@ void Calibrate() {
gEsc1
.
write
(
40
);
gEsc2
.
write
(
40
);
GetAngleOffset
();
GetMaxWingPos
();
GetAngleOffset
(
calibTime
/
2
);
GetMaxWingPos
(
calibTime
/
2
);
// Stop ESC
gEsc1
.
write
(
0
);
...
...
@@ -64,9 +67,7 @@ void Calibrate() {
}
// Determine if wing position needs to be offset to prevent wrap-around
void
GetAngleOffset
()
{
uint16_t
calibTime
=
4000
;
void
GetAngleOffset
(
uint32_t
calibTime
)
{
unsigned
int
maxPos
[
4
];
unsigned
int
minPos
[
4
];
...
...
@@ -99,12 +100,8 @@ void GetAngleOffset() {
}
unsigned
int
GetMaxWingPos
()
{
uint16_t
calibTime
=
4000
;
unsigned
int
GetMaxWingPos
(
uint32_t
calibTime
)
{
unsigned
int
maxPos
[
4
];
unsigned
int
minPos
[
4
];
unsigned
int
newPos
;
for
(
uint32_t
tStart
=
millis
();
(
millis
()
-
tStart
)
<
calibTime
;)
{
...
...
@@ -112,7 +109,7 @@ unsigned int GetMaxWingPos() {
// Find max and min wing position
for
(
int
i
=
0
;
i
<
sizeof
(
gCSN_PINS
);
i
++
)
{
newPos
=
ReadSensor
(
gCSN_PINS
[
i
],
gENC_ORIENT
[
i
],
gAngleOffset
[
i
]);
if
(
newPos
>
max
Pos
[
i
])
{
if
(
newPos
>
gMaxWing
Pos
[
i
])
{
gMaxWingPos
[
i
]
=
newPos
;
}
}
...
...
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