Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • am-dept/tlambert/MR-arduino-controller
1 result
Show changes
Commits on Source (4)
controller/build/
...@@ -17,6 +17,30 @@ to [Semantic Versioning][sem_ver]. ...@@ -17,6 +17,30 @@ to [Semantic Versioning][sem_ver].
### Fixed ### Fixed
## [v2.0.2] - 2023-07-13
### Added
### Changed
- Tweaks to serial studio display and logging
- Changed calibration values to fit Q3 2023 tests
### Deprecated
### Removed
### Fixed
- Issues with calibration (integer overflow offset)
- Issues with conversion between integer value to degree
## [v2.0.1] - 2022-11-23
### Added
- Pipeline for automatic release
## [v2.0.0] - 2022-11-23 ## [v2.0.0] - 2022-11-23
### Added ### Added
...@@ -46,6 +70,8 @@ to [Semantic Versioning][sem_ver]. ...@@ -46,6 +70,8 @@ to [Semantic Versioning][sem_ver].
[sem_ver]:<https://semver.org/spec/v2.0.0.html> [sem_ver]:<https://semver.org/spec/v2.0.0.html>
[keep_chglog]: <https://keepachangelog.com/en/1.0.0/> [keep_chglog]: <https://keepachangelog.com/en/1.0.0/>
[Unreleased]: https://gitlab.uliege.be/thlamb/mecharaptor-controller/-/compare/v2.0.0...main [Unreleased]: https://gitlab.uliege.be/thlamb/mecharaptor-controller/-/compare/v2.0.2...main
[v2.0.2]: https://gitlab.uliege.be/thlamb/mecharaptor-controller/-/compare/v2.0.1...v2.0.2
[v2.0.1]: https://gitlab.uliege.be/thlamb/mecharaptor-controller/-/compare/v2.0.0...v2.0.1
[v2.0.0]: https://gitlab.uliege.be/thlamb/mecharaptor-controller/-/compare/v1.0.0...v2.0.0 [v2.0.0]: https://gitlab.uliege.be/thlamb/mecharaptor-controller/-/compare/v1.0.0...v2.0.0
[v1.0.0]: https://gitlab.uliege.be/thlamb/mecharaptor-controller/-/tags/v1.0.0 [v1.0.0]: https://gitlab.uliege.be/thlamb/mecharaptor-controller/-/tags/v1.0.0
...@@ -18,8 +18,9 @@ electrical components of the setup. ...@@ -18,8 +18,9 @@ electrical components of the setup.
- Manual (potentiometer) or automatic (serial) control of the BLDCs. - Manual (potentiometer) or automatic (serial) control of the BLDCs.
- Both BLDCs run at the same speed (same flapping frequency on each module). - Both BLDCs run at the same speed (same flapping frequency on each module).
- Phase difference manually set before the experiment by changing the initial - It is impossible for the BLDCs to keep an exact constant rotation speed during
position of the wings. the entire run. The phase offset cannot be set precisely and will evolve
during the entire run.
_Note: A maximum rotation speed is imposed to the BLDC by the ESC. This value _Note: A maximum rotation speed is imposed to the BLDC by the ESC. This value
has been manually set for each ESC using the ESC's terminal (JETIBOX). The has been manually set for each ESC using the ESC's terminal (JETIBOX). The
...@@ -107,7 +108,7 @@ measured and deactivate the calibration procedure altogether by putting ...@@ -107,7 +108,7 @@ measured and deactivate the calibration procedure altogether by putting
## Schematics ## Schematics
To Do (in January 2023) To Do
------- -------
[^1]: Discontinued by manufacturer. [^1]: Discontinued by manufacturer.
......
...@@ -7,8 +7,11 @@ ...@@ -7,8 +7,11 @@
Then we determine the maximum position so we can make it match the maximum Then we determine the maximum position so we can make it match the maximum
angle attainable. angle attainable.
WARNING: Not sure if this function is working properly or not. The second test
campaign (Q3 2023) did not require any special offset as all encoders were
staying within 12 bit without overflowing.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
(c) Copyright 2022 University of Liege (c) Copyright 2022-2023 University of Liege
Author: Thomas Lambert <t.lambert@uliege.be> Author: Thomas Lambert <t.lambert@uliege.be>
ULiege - Aeroelasticity and Experimental Aerodynamics ULiege - Aeroelasticity and Experimental Aerodynamics
MIT License MIT License
...@@ -96,6 +99,10 @@ void GetAngleOffset(uint32_t calibTime) { ...@@ -96,6 +99,10 @@ void GetAngleOffset(uint32_t calibTime) {
} }
// Determine if offset is needed // Determine if offset is needed
// We know that the overall amplitude is approx 60deg -> ENC_PREICSION / 6
// If we measure a difference between the min and max that is more than the
// preicsion/2, we are sure that we have an over/under flow somewhere.
// Therefore, we conclude that we need to offset everything.
for (int i = 0; i < sizeof(gCSN_PINS); i++) { for (int i = 0; i < sizeof(gCSN_PINS); i++) {
if (maxPos[i] - minPos[i] > ENC_PRECISION / 2) { if (maxPos[i] - minPos[i] > ENC_PRECISION / 2) {
gAngleOffset[i] = 1; gAngleOffset[i] = 1;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
wings flap at the same frequency. The phase between the two sets will be wings flap at the same frequency. The phase between the two sets will be
adjusted manually by setting their initial positions as desired. adjusted manually by setting their initial positions as desired.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
(c) Copyright 2022 University of Liege (c) Copyright 2022-2023 University of Liege
Author: Thomas Lambert <t.lambert@uliege.be> Author: Thomas Lambert <t.lambert@uliege.be>
ULiege - Aeroelasticity and Experimental Aerodynamics ULiege - Aeroelasticity and Experimental Aerodynamics
MIT License MIT License
...@@ -56,9 +56,9 @@ ...@@ -56,9 +56,9 @@
// Calibration of encoders // Calibration of encoders
#define ENC_PRECISION 4096 // 12-Bits encoders (nb of points per rot) #define ENC_PRECISION 4096 // 12-Bits encoders (nb of points per rot)
#define ENC_ORIENT \ #define ENC_ORIENT \
{ 1, -1, 1, -1 } // Encoder orientation { 1, -1, -1, 1 } // Encoder orientation
#define MAX_WING_POS \ #define MAX_WING_POS \
{ 4095, 1317, 0, 1494 } // Maximum wing angle (returned by encoder value) { 3166, 2374, 1290, 1135 } // Maximum wing angle (returned by encoder value)
#define TRUE_MAX_ANGLE 38.07 // Maximum wing angle (measured on setup) #define TRUE_MAX_ANGLE 38.07 // Maximum wing angle (measured on setup)
...@@ -89,7 +89,7 @@ Servo gEsc2; // ESC for aft motor ...@@ -89,7 +89,7 @@ Servo gEsc2; // ESC for aft motor
uint8_t gEsc_val = 0; // ESC angle (to use with the Servo library) [0-180] uint8_t gEsc_val = 0; // ESC angle (to use with the Servo library) [0-180]
String gMode; // Mode of operation String gMode; // Mode of operation
uint16_t gAngleOffset[] = { 0, 0, 1, 0 }; // Encoder offset (prevent wrap-around) uint16_t gAngleOffset[] = { 0, 0, 0, 0 }; // Encoder offset (prevent wrap-around)
uint16_t gMaxWingPos[] = MAX_WING_POS; // Encoder maximum recorder position uint16_t gMaxWingPos[] = MAX_WING_POS; // Encoder maximum recorder position
int gStartTime; // Loop start time int gStartTime; // Loop start time
...@@ -275,7 +275,7 @@ void SerialPrint(String mode, int potent, int esc_val, unsigned int wing_angles[ ...@@ -275,7 +275,7 @@ void SerialPrint(String mode, int potent, int esc_val, unsigned int wing_angles[
} }
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]) % ENC_PRECISION) + TRUE_MAX_ANGLE - 360); Serial.print(PosToDeg(int(wing_angles[i]) - int(gMaxWingPos[i])) + TRUE_MAX_ANGLE);
} }
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
Serial.print(","); Serial.print(",");
......
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
"title": "ESC val", "title": "ESC val",
"units": "°", "units": "°",
"value": "%4", "value": "%4",
"widget": "gauge" "widget": ""
}, },
{ {
"alarm": 15, "alarm": 15,
...@@ -78,12 +78,46 @@ ...@@ -78,12 +78,46 @@
"title": "Desired freq.", "title": "Desired freq.",
"units": "Hz", "units": "Hz",
"value": "%5", "value": "%5",
"widget": "gauge" "widget": ""
} }
], ],
"title": "Inputs", "title": "Inputs",
"widget": "" "widget": ""
}, },
{
"datasets": [
{
"alarm": 0,
"fft": false,
"fftSamples": 1024,
"graph": false,
"led": false,
"log": false,
"max": 0,
"min": 0,
"title": "Front",
"units": "°",
"value": "%10",
"widget": ""
},
{
"alarm": 0,
"fft": false,
"fftSamples": 1024,
"graph": false,
"led": false,
"log": false,
"max": 0,
"min": 0,
"title": "Aft",
"units": "°",
"value": "%12",
"widget": ""
}
],
"title": "Flapping angles",
"widget": "multiplot"
},
{ {
"datasets": [ "datasets": [
{ {
......
...@@ -3,8 +3,12 @@ ...@@ -3,8 +3,12 @@
Functions for sensors and acquisition. Functions for sensors and acquisition.
WARNING: Not sure if the application of an offset to prevent integer overflow
is working properly or not. The second test campaign (Q3 2023) did not require
any special offset as all encoders were staying within 12 bit without
overflowing.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
(c) Copyright 2022 University of Liege (c) Copyright 2022-2023 University of Liege
Author: Thomas Lambert <t.lambert@uliege.be> Author: Thomas Lambert <t.lambert@uliege.be>
ULiege - Aeroelasticity and Experimental Aerodynamics ULiege - Aeroelasticity and Experimental Aerodynamics
MIT License MIT License
...@@ -30,7 +34,19 @@ unsigned int ReadSensor(uint8_t csn, int8_t orient, int8_t offset) { ...@@ -30,7 +34,19 @@ 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); // Flip the function if needed
ret = (1 - orient) / 2 * ENC_PRECISION + orient * ret;
// Apply offset to prevent overflow if needed
// FIXME: Check. It is probably not correct
if (offset == 1) {
if (ret >= 0 and ret < ENC_PRECISION / 2) {
ret = ret + ENC_PRECISION / 2;
} else {
ret = ret - ENC_PRECISION / 2;
}
}
return ret;
} }
// Get the tension and current of a PSU // Get the tension and current of a PSU
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
Miscellaneous utilities. Miscellaneous utilities.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
(c) Copyright 2022 University of Liege (c) Copyright 2022-2023 University of Liege
Author: Thomas Lambert <t.lambert@uliege.be> Author: Thomas Lambert <t.lambert@uliege.be>
ULiege - Aeroelasticity and Experimental Aerodynamics ULiege - Aeroelasticity and Experimental Aerodynamics
MIT License MIT License
...@@ -32,7 +32,7 @@ float RpmToFreq(int rpm) { ...@@ -32,7 +32,7 @@ float RpmToFreq(int rpm) {
// Convert encoder position to degree // Convert encoder position to degree
float PosToDeg(unsigned int pos) { float PosToDeg(int pos) {
return pos * 360.0 / ENC_PRECISION; return pos * 360.0 / ENC_PRECISION;
} }
......