From 003c12358ec267275c00616ba967f7cdc96a383e Mon Sep 17 00:00:00 2001 From: benjaminwp18 <90342856+benjaminwp18@users.noreply.github.com> Date: Wed, 19 Jun 2024 16:26:07 -0400 Subject: [PATCH 1/5] Don't get commands while moving motor --- src/float/float_transceiver/float_transceiver.ino | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/float/float_transceiver/float_transceiver.ino b/src/float/float_transceiver/float_transceiver.ino index a86cb77f..3ec233f4 100644 --- a/src/float/float_transceiver/float_transceiver.ino +++ b/src/float/float_transceiver/float_transceiver.ino @@ -138,7 +138,10 @@ void setup() { } void loop() { - bool submergeReceived = receiveCommand(); + bool submergeReceived = false; + if (!stageIs(StageType::Suck) && !stageIs(StageType::Pump)) { + submergeReceived = receiveCommand(); + } if (overrideState == OverrideState::Suck) { if (digitalRead(LIMIT_FULL) == HIGH) { From 718d691a11b5bd509c0ee9f7338b71bc2848e4a5 Mon Sep 17 00:00:00 2001 From: ROV Laptop Date: Wed, 19 Jun 2024 20:18:08 -0400 Subject: [PATCH 2/5] Update schedule --- src/float/float_transceiver/float_transceiver.ino | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/float/float_transceiver/float_transceiver.ino b/src/float/float_transceiver/float_transceiver.ino index 3ec233f4..e78c64ce 100644 --- a/src/float/float_transceiver/float_transceiver.ino +++ b/src/float/float_transceiver/float_transceiver.ino @@ -35,13 +35,13 @@ const uint32_t PROFILE_SEGMENT = 60000; #endif // Schedule (all delays in ms) -const uint32_t RELEASE_MAX = 300000; +const uint32_t RELEASE_MAX = 8 * 60000; const uint32_t SUCK_MAX = PROFILE_SEGMENT; const uint32_t DESCEND_TIME = PROFILE_SEGMENT; const uint32_t PUMP_MAX = PROFILE_SEGMENT; const uint32_t ASCEND_TIME = 0; // Disable ascend times now that we're properly ballasted -const uint32_t TX_MAX = 60000; -const uint32_t ONE_HOUR = 360000; +const uint32_t TX_MAX = 2 * 60000; +const uint32_t CODA = 2 * 60000; const size_t SCHEDULE_LENGTH = 12; @@ -78,7 +78,7 @@ Stage SCHEDULE[SCHEDULE_LENGTH] = { {StageType::Pump, PUMP_MAX }, {StageType::WaitProfiling, ASCEND_TIME }, - {StageType::WaitTransmitting, ONE_HOUR }, + {StageType::WaitTransmitting, CODA }, }; uint32_t stageStartTime; @@ -255,7 +255,7 @@ void loop() { // If we signal a third profile, restart the schedule if (currentStage >= SCHEDULE_LENGTH) { - currentStage = 1; + currentStage = 2; } // Switch to sucking/pumping depending on the stage we're entering From 67f476b86eb17ca3ebc1ab2e9378add1e8132ec0 Mon Sep 17 00:00:00 2001 From: benjaminwp18 <90342856+benjaminwp18@users.noreply.github.com> Date: Fri, 21 Jun 2024 17:24:29 -0400 Subject: [PATCH 3/5] Add constants & abstraction function --- .../float_transceiver/float_transceiver.ino | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/float/float_transceiver/float_transceiver.ino b/src/float/float_transceiver/float_transceiver.ino index e78c64ce..3d090a16 100644 --- a/src/float/float_transceiver/float_transceiver.ino +++ b/src/float/float_transceiver/float_transceiver.ino @@ -34,14 +34,15 @@ const uint32_t PRESSURE_READ_INTERVAL = 5000; const uint32_t PROFILE_SEGMENT = 60000; #endif +const uint32_t ONE_SECOND = 60000; + // Schedule (all delays in ms) -const uint32_t RELEASE_MAX = 8 * 60000; +const uint32_t RELEASE_MAX = 8 * ONE_SECOND; const uint32_t SUCK_MAX = PROFILE_SEGMENT; const uint32_t DESCEND_TIME = PROFILE_SEGMENT; const uint32_t PUMP_MAX = PROFILE_SEGMENT; const uint32_t ASCEND_TIME = 0; // Disable ascend times now that we're properly ballasted -const uint32_t TX_MAX = 2 * 60000; -const uint32_t CODA = 2 * 60000; +const uint32_t TX_MAX_TIME = 2 * ONE_SECOND; const size_t SCHEDULE_LENGTH = 12; @@ -57,7 +58,7 @@ struct Stage { OverrideState overrideState = OverrideState::NoOverride; uint8_t currentStage = 0; -Stage SCHEDULE[SCHEDULE_LENGTH] = { +const Stage SCHEDULE[SCHEDULE_LENGTH] = { // Pump immediately in case we just rebooted at the bottom of the pool {StageType::Pump, PUMP_MAX }, @@ -70,7 +71,7 @@ Stage SCHEDULE[SCHEDULE_LENGTH] = { {StageType::Pump, PUMP_MAX }, {StageType::WaitProfiling, ASCEND_TIME }, - {StageType::WaitTransmitting, TX_MAX }, + {StageType::WaitTransmitting, TX_MAX_TIME }, // Profile 2 {StageType::Suck, SUCK_MAX }, @@ -78,7 +79,7 @@ Stage SCHEDULE[SCHEDULE_LENGTH] = { {StageType::Pump, PUMP_MAX }, {StageType::WaitProfiling, ASCEND_TIME }, - {StageType::WaitTransmitting, CODA }, + {StageType::WaitTransmitting, TX_MAX_TIME }, }; uint32_t stageStartTime; @@ -139,7 +140,10 @@ void setup() { void loop() { bool submergeReceived = false; - if (!stageIs(StageType::Suck) && !stageIs(StageType::Pump)) { + + // Disable command Rx when the motor is moving + // Otherwise the motor can overrun the limit switch + if (!isMotorMoving()) { submergeReceived = receiveCommand(); } @@ -394,6 +398,10 @@ MotorState getMotorState() { } } +bool isMotorMoving() { + return getMotorState() == MotorState::Pump && getMotorState() == MotorState::Suck; +} + bool stageIs(StageType type) { return SCHEDULE[currentStage].type == type; } bool isSurfaced() { From 3cf882ee22235d3294adaba1822e1bbc068e90eb Mon Sep 17 00:00:00 2001 From: benjaminwp18 <90342856+benjaminwp18@users.noreply.github.com> Date: Fri, 21 Jun 2024 17:27:39 -0400 Subject: [PATCH 4/5] Change time typo --- src/float/float_transceiver/float_transceiver.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/float/float_transceiver/float_transceiver.ino b/src/float/float_transceiver/float_transceiver.ino index 3d090a16..0ec90c36 100644 --- a/src/float/float_transceiver/float_transceiver.ino +++ b/src/float/float_transceiver/float_transceiver.ino @@ -34,15 +34,15 @@ const uint32_t PRESSURE_READ_INTERVAL = 5000; const uint32_t PROFILE_SEGMENT = 60000; #endif -const uint32_t ONE_SECOND = 60000; +const uint32_t ONE_MINUTE = 60000; // Schedule (all delays in ms) -const uint32_t RELEASE_MAX = 8 * ONE_SECOND; +const uint32_t RELEASE_MAX = 8 * ONE_MINUTE; const uint32_t SUCK_MAX = PROFILE_SEGMENT; const uint32_t DESCEND_TIME = PROFILE_SEGMENT; const uint32_t PUMP_MAX = PROFILE_SEGMENT; const uint32_t ASCEND_TIME = 0; // Disable ascend times now that we're properly ballasted -const uint32_t TX_MAX_TIME = 2 * ONE_SECOND; +const uint32_t TX_MAX_TIME = 2 * ONE_MINUTE; const size_t SCHEDULE_LENGTH = 12; From 7334cf618d8d893cc38ddad2fd802eb84c72dcdb Mon Sep 17 00:00:00 2001 From: benjaminwp18 <90342856+benjaminwp18@users.noreply.github.com> Date: Fri, 21 Jun 2024 17:30:49 -0400 Subject: [PATCH 5/5] Fix isMotorMoving --- src/float/float_transceiver/float_transceiver.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/float/float_transceiver/float_transceiver.ino b/src/float/float_transceiver/float_transceiver.ino index 0ec90c36..18a53fac 100644 --- a/src/float/float_transceiver/float_transceiver.ino +++ b/src/float/float_transceiver/float_transceiver.ino @@ -399,7 +399,8 @@ MotorState getMotorState() { } bool isMotorMoving() { - return getMotorState() == MotorState::Pump && getMotorState() == MotorState::Suck; + const MotorState motorState = getMotorState(); + return motorState == MotorState::Pump || motorState == MotorState::Suck; } bool stageIs(StageType type) { return SCHEDULE[currentStage].type == type; }