diff --git a/controller/calibration.ino b/controller/calibration.ino index a1ad945a8d006abbe87a014863e5cc10fba0d9e2..7386153133e0573051358f93baae5b07454abdc4 100644 --- a/controller/calibration.ino +++ b/controller/calibration.ino @@ -50,7 +50,7 @@ void Calibrate() { gEsc2.write(0); Serial.println("[INFO]: Calibration done."); - Serial.println("Maxium wing posiions are: "); + Serial.println("Maximum wing positions are: "); PrintArray(gMaxWingPos); Serial.println("Offsets are: "); @@ -60,6 +60,10 @@ void Calibrate() { } } + Serial.println("[INPUT]: Start acquisition then press 'y' to begin."); + while (Serial.available() == 0) {} // Wait for serial input + + // Flush Serial before continuing while (Serial.available()) { Serial.read(); diff --git a/controller/controller.ino b/controller/controller.ino index 83808bacb3946d885cb18a071c3f984e2d8f46ab..f37e6d36ab2e65fc44d0d26e374c48c6e12a19b3 100644 --- a/controller/controller.ino +++ b/controller/controller.ino @@ -58,14 +58,14 @@ #define ENC_ORIENT \ { 1, -1, 1, -1 } // Encoder orientation #define MAX_WING_POS \ - { 222.1, 117.77, 117, 117 } // Maximum wing angle (returned by encoder value) -#define TRUE_MAX_ANGLE 38.07 // Maximum wing angle (measured on setup) + { 4095, 1317, 0, 1494 } // Maximum wing angle (returned by encoder value) +#define TRUE_MAX_ANGLE 38.07 // Maximum wing angle (measured on setup) /******************************************************************************* Globals (for things that I can change manually) *******************************************************************************/ -const boolean gSKIP_CALIB = false; // Skip calibration or not +const boolean gSKIP_CALIB = true; // Skip calibration or not // Constant values that can be tweaked here or in the ESC before run const uint16_t gMAX_SIG = 2000; // Max signal to the ESC [ms] @@ -75,7 +75,7 @@ const uint16_t gMAX_RPM = 3000; // Motor maximum RPM (set in ESC) 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 gMIN_ESC_VAL = 40; // Min value for ESC to start motor (trial-error) -const uint8_t gESC_OFFSET = 4; // Offset to add to ESC 2 to sync them +const uint8_t gESC_OFFSET = 1; // Offset to add to ESC 1 to sync them const uint8_t gCSN_PINS[] = CSN_PINS; // Encoder Chip Select pins const int8_t gENC_ORIENT[] = ENC_ORIENT; // Encoder orientation @@ -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] String gMode; // Mode of operation -uint16_t gAngleOffset[] = { 0, 0, 0, 0 }; // Encoder offset (prevent wrap-around) +uint16_t gAngleOffset[] = { 0, 0, 1, 0 }; // Encoder offset (prevent wrap-around) uint16_t gMaxWingPos[] = MAX_WING_POS; // Encoder maximum recorder position @@ -172,8 +172,8 @@ void loop() { } // Write value to ESCs - gEsc1.write(gEsc_val); - gEsc2.write(gEsc_val + gESC_OFFSET); + gEsc1.write(gEsc_val + gESC_OFFSET); + gEsc2.write(gEsc_val); // Read value from rotary encoders for (int i = 0; i < sizeof(gCSN_PINS); i++) { @@ -234,7 +234,7 @@ void StopMotor(int old_esc_val) { Serial.println("[INFO] MOTOR STOP INITIATED"); - if (old_esc_val > gMIN_ESC_VAL) { + if (old_esc_val > gMIN_ESC_VAL + 10) { Serial.println("[INFO] Slowing down motor for 3 sec..."); gEsc1.write(gMIN_ESC_VAL); gEsc2.write(gMIN_ESC_VAL);