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
f50ff25c
Verified
Commit
f50ff25c
authored
2 years ago
by
Thomas Lambert
Browse files
Options
Downloads
Patches
Plain Diff
fix(logg): current calibration
parent
f77c2948
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
controller/controller.ino
+13
-11
13 additions, 11 deletions
controller/controller.ino
controller/sensors.ino
+2
-3
2 additions, 3 deletions
controller/sensors.ino
controller/utils.ino
+3
-2
3 additions, 2 deletions
controller/utils.ino
with
18 additions
and
16 deletions
controller/controller.ino
+
13
−
11
View file @
f50ff25c
...
@@ -45,10 +45,10 @@
...
@@ -45,10 +45,10 @@
#define DIV_RES1 47800.0 // Resistance of R1 in the voltage dividers
#define DIV_RES1 47800.0 // Resistance of R1 in the voltage dividers
#define DIV_RES2 6800.0 // Resistance of R2 in the voltage dividers
#define DIV_RES2 6800.0 // Resistance of R2 in the voltage dividers
#define SEN0098_VCC 5 // Supply voltage of the current sensors
#define SEN0098_VCC 5
// Supply voltage of the current sensors
#define SEN0098_SENSI 40.0 // Chip ACS758LCB-050B-PFF-T
#define SEN0098_SENSI 40.0
// Chip ACS758LCB-050B-PFF-T
#define SEN0098_
VIOUT 0.12 // [FIXME] VERIFY!
#define SEN0098_
QUIESCENT_FACTOR 0.5 // Bidirectional chip-> V_IOUTQ = 0.5*VCC
#define SEN0098_OFFSET 0.007 // [FIXME] VERIFY!
#define SEN0098_OFFSET 0.007
// [FIXME] VERIFY!
#define GEAR_RATIO 0.1 // Gear ratio between motor and wings
#define GEAR_RATIO 0.1 // Gear ratio between motor and wings
...
@@ -75,10 +75,11 @@ const uint16_t gMIN_RPM = 750; // Motor minimum RPM (set in ESC)
...
@@ -75,10 +75,11 @@ const uint16_t gMIN_RPM = 750; // Motor minimum RPM (set in ESC)
const
uint8_t
gMAX_ESC_VAL
=
160
;
// Value at which motor is at max RPM
const
uint8_t
gMAX_ESC_VAL
=
160
;
// Value at which motor is at max RPM
const
uint8_t
gMIN_ESC_VAL
=
40
;
// Min value for ESC to start motor (trial-error)
const
uint8_t
gMIN_ESC_VAL
=
40
;
// Min value for ESC to start motor (trial-error)
const
uint8_t
gCSN_PINS
[]
=
CSN_PINS
;
// Encoder Chip Select pins
const
uint8_t
gCSN_PINS
[]
=
CSN_PINS
;
// Encoder Chip Select pins
const
int8_t
gENC_ORIENT
[]
=
ENC_ORIENT
;
// Encoder orientation
const
int8_t
gENC_ORIENT
[]
=
ENC_ORIENT
;
// Encoder orientation
const
float
gCUR_FACT
=
SEN0098_SENSI
/
1000.0
;
// Factor for current measurement
const
float
gCUR_QOV
=
SEN0098_VIOUT
*
SEN0098_VCC
;
// [FIXME] Verify
const
float
gCUR_FACT
=
SEN0098_SENSI
/
1000.0
;
// Factor for current measurement
const
float
gCUR_QOV
=
SEN0098_QUIESCENT_FACTOR
*
SEN0098_VCC
;
// VIOUT_Q
// Other
// Other
Servo
gEsc1
;
// ESC for front motor
Servo
gEsc1
;
// ESC for front motor
...
@@ -136,8 +137,9 @@ void setup() {
...
@@ -136,8 +137,9 @@ void setup() {
Calibrate
();
Calibrate
();
}
}
delay
(
1000
);
Serial
.
println
(
"[INFO]: Setup OK, starting now..."
);
Serial
.
println
(
"[INFO]: Setup OK, starting now..."
);
delay
(
10
00
);
// Ensure all is properly initialized
delay
(
5
00
);
}
}
...
@@ -265,9 +267,9 @@ void SerialPrint(String mode, int potent, int esc_val, unsigned int wing_angles[
...
@@ -265,9 +267,9 @@ void SerialPrint(String mode, int potent, int esc_val, unsigned int wing_angles[
Serial
.
print
(
freq
);
Serial
.
print
(
freq
);
for
(
int
i
=
0
;
i
<
sizeof
(
gCSN_PINS
);
i
++
)
{
for
(
int
i
=
0
;
i
<
sizeof
(
gCSN_PINS
);
i
++
)
{
Serial
.
print
(
","
);
Serial
.
print
(
","
);
Serial
.
print
(
PosToDeg
(
wing_angles
[
i
]
)
-
gMaxWingPos
[
i
]
+
TRUE_MAX_ANGLE
);
Serial
.
print
(
PosToDeg
(
(
wing_angles
[
i
]
-
gMaxWingPos
[
i
]
)
%
ENC_PRECISION
)
+
TRUE_MAX_ANGLE
-
360
);
}
}
for
(
int
i
=
0
;
i
<
sizeof
(
psu_vol
)
/
sizeof
(
psu_vol
[
0
])
;
i
++
)
{
for
(
int
i
=
0
;
i
<
2
;
i
++
)
{
Serial
.
print
(
","
);
Serial
.
print
(
","
);
Serial
.
print
(
psu_vol
[
i
]);
Serial
.
print
(
psu_vol
[
i
]);
Serial
.
print
(
","
);
Serial
.
print
(
","
);
...
...
This diff is collapsed.
Click to expand it.
controller/sensors.ino
+
2
−
3
View file @
f50ff25c
...
@@ -28,7 +28,7 @@ unsigned int ReadSensor(uint8_t csn, int8_t orient, int8_t offset) {
...
@@ -28,7 +28,7 @@ unsigned int ReadSensor(uint8_t csn, int8_t orient, int8_t offset) {
}
}
digitalWrite
(
csn
,
HIGH
);
//deselects the encoder from reading
digitalWrite
(
csn
,
HIGH
);
//deselects the encoder from reading
return
(
1
-
orient
)
/
2
*
ENC_PRECISION
+
orient
*
ret
-
offset
*
ENC_PRECISION
/
2
;
return
(
1
-
orient
)
/
2
*
ENC_PRECISION
+
orient
*
ret
-
(
offset
*
ENC_PRECISION
/
2
)
;
}
}
// Get the tension and current of a PSU
// Get the tension and current of a PSU
...
@@ -38,8 +38,7 @@ void GetPsu(byte vol_pin, byte cur_pin, float &vol, float &cur) {
...
@@ -38,8 +38,7 @@ void GetPsu(byte vol_pin, byte cur_pin, float &vol, float &cur) {
}
}
// Measure current consumed by module
// Measure current consumed by module
// https://www.youtube.com/watch?v=SiHfjzcqnU4
// From https://www.youtube.com/watch?v=SiHfjzcqnU4
// [FIXME] Check properly
float
GetCurrent
(
byte
cur_pin
)
{
float
GetCurrent
(
byte
cur_pin
)
{
float
volt_raw
=
(
5.0
/
1023.0
)
*
analogRead
(
cur_pin
);
float
volt_raw
=
(
5.0
/
1023.0
)
*
analogRead
(
cur_pin
);
...
...
This diff is collapsed.
Click to expand it.
controller/utils.ino
+
3
−
2
View file @
f50ff25c
...
@@ -37,10 +37,11 @@ float PosToDeg(unsigned int pos) {
...
@@ -37,10 +37,11 @@ float PosToDeg(unsigned int pos) {
}
}
void
PrintArray
(
int
array
[])
{
void
PrintArray
(
int
array
[])
{
for
(
int
i
=
0
;
i
<
sizeof
(
array
)
/
sizeof
(
array
[
0
])
;
i
++
)
{
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
Serial
.
print
(
array
[
i
]);
Serial
.
print
(
array
[
i
]);
if
(
i
<
sizeof
(
array
)
-
1
)
{
if
(
i
<
4
-
1
)
{
Serial
.
print
(
", "
);
Serial
.
print
(
", "
);
}
}
}
}
Serial
.
println
();
}
}
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