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
94ce40ad
Verified
Commit
94ce40ad
authored
2 years ago
by
Thomas Lambert
Browse files
Options
Downloads
Patches
Plain Diff
refact: minor changes and doc improvements
parent
21848595
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
+9
-8
9 additions, 8 deletions
controller/controller.ino
controller/sensors.ino
+4
-2
4 additions, 2 deletions
controller/sensors.ino
controller/utils.ino
+3
-2
3 additions, 2 deletions
controller/utils.ino
with
16 additions
and
12 deletions
controller/controller.ino
+
9
−
8
View file @
94ce40ad
...
...
@@ -26,8 +26,9 @@
#define BAUD_RATE 115200 // baud rate for serial
// Pins
#define ESC1_PIN 10 // ESC Front motor
#define ESC2_PIN 9 // ESC Aft motor
#define ESC1_PIN 10 // ESC Front motor
#define ESC2_PIN 9 // ESC Aft motor
#define SWITCH_PIN 7 // ON/OFF switch (mode control)
#define POT_PIN A0 // Potentiometer
...
...
@@ -42,17 +43,17 @@
#define TENS2_PIN A1 // Tension measurement for Aft motor
// Values
#define DIV_RES1 48254.0 // Resistance of R1 in the voltage dividers
#define DIV_RES1 48254.0 // Resistance of R1 in the voltage dividers
(calibrated so voltage matches)
#define DIV_RES2 6800.0 // Resistance of R2 in the voltage dividers
#define SEN0098_VCC 5 // Supply voltage of the current sensors
#define SEN0098_SENSI 40.0 // Chip ACS758LCB-050B-PFF-T
#define SEN0098_QUIESCENT_FACTOR 0.5 // Bidirectional chip-> V_IOUTQ = 0.5*VCC
#define SEN0098_OFFSET 0.0122 //
Manually set
so current is 0 when no current
#define SEN0098_QUIESCENT_FACTOR 0.5 // Bidirectional chip
-> V_IOUTQ = 0.5*VCC
#define SEN0098_OFFSET 0.0122 //
Calibrated
so current is 0 when no current
#define GEAR_RATIO 0.1 // Gear ratio between motor and wings
// Calibration of encoders
(NEEDS TO BE REDONE WHEN ENCODERS ARE MOVED)
// Calibration of encoders
#define ENC_PRECISION 4096 // 12-Bits encoders (nb of points per rot)
#define ENC_ORIENT \
{ 1, -1, 1, -1 } // Encoder orientation
...
...
@@ -118,10 +119,10 @@ void setup() {
// Initialize modes
int
switch_state
=
digitalRead
(
SWITCH_PIN
);
if
(
switch_state
==
LOW
)
{
gMode
=
"MANUAL"
;
Serial
.
println
(
"[WARNING]: Control motors using potentiometer"
);
}
else
{
gEsc1
.
write
(
0
);
// Must be initialized at 0 otherwise will not start
gEsc2
.
write
(
0
);
...
...
@@ -137,7 +138,7 @@ void setup() {
Calibrate
();
}
delay
(
1000
);
delay
(
1000
);
// Ensure proper initialization
Serial
.
println
(
"[INFO]: Setup OK, starting now..."
);
delay
(
500
);
}
...
...
This diff is collapsed.
Click to expand it.
controller/sensors.ino
+
4
−
2
View file @
94ce40ad
...
...
@@ -11,7 +11,8 @@
Repo: https://gitlab.uliege.be/thlamb/mecharaptor-controller
*******************************************************************************/
//Read 12-bit rotary encoder (RobinL modified by linarism on forum.arduino.cc)
// Read 12-bit rotary encoder
// Inspired from RobinL modified by linarism on forum.arduino.cc
unsigned
int
ReadSensor
(
uint8_t
csn
,
int8_t
orient
,
int8_t
offset
)
{
unsigned
int
ret
=
0
;
...
...
@@ -28,6 +29,7 @@ unsigned int ReadSensor(uint8_t csn, int8_t orient, int8_t offset) {
}
digitalWrite
(
csn
,
HIGH
);
//deselects the encoder from reading
return
(
1
-
orient
)
/
2
*
ENC_PRECISION
+
orient
*
ret
-
(
offset
*
ENC_PRECISION
/
2
);
}
...
...
@@ -46,7 +48,7 @@ float GetCurrent(byte cur_pin) {
return
volt
/
gCUR_FACT
;
// Actual current
}
// Measure the tension provided by the PSU
// Measure the tension provided by the PSU
using the voltage divider
float
GetTension
(
byte
vol_pin
)
{
float
vol_raw
=
analogRead
(
vol_pin
)
*
(
5.0
/
1023.0
);
...
...
This diff is collapsed.
Click to expand it.
controller/utils.ino
+
3
−
2
View file @
94ce40ad
...
...
@@ -36,10 +36,11 @@ float PosToDeg(unsigned int pos) {
return
pos
*
360.0
/
ENC_PRECISION
;
}
// Print an array
void
PrintArray
(
int
array
[])
{
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
for
(
int
i
=
0
;
i
<
sizeof
(
gCSN_PINS
)
;
i
++
)
{
Serial
.
print
(
array
[
i
]);
if
(
i
<
4
-
1
)
{
if
(
i
<
sizeof
(
gCSN_PINS
)
-
1
)
{
Serial
.
print
(
", "
);
}
}
...
...
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