feat: update float ESP-NOW runtime flow#5
Open
Skeitt wants to merge 6 commits into
Open
Conversation
- add runtime profile, PID, balance and motor settings with persisted ESPA config and ESPB parser support - log and stream normalized syringe position alongside pressure and float depth - require acknowledged command handling, centralize LED states and clean obsolete espA_pool/build artifacts - update firmware docs and protocol/parser/storage tests for the current command contract
home (motor_pos=0) pushes water out → floats; negative positions move toward the TOF and take on water → sinks. Simplify uToMotorPos to map u in [0,1] onto negative travel, dropping the unused MOTOR_INVERT_LOGICAL flag, and update balance() comments accordingly.
Mission log survives a power-cycle (cleared only at the start of a new mission, no longer at boot), so a failed pool test can be read afterwards over USB. Add a DUMP_LOG serial command to re-read it on demand without clearing — solves the case where the monitor connects after boot. emergencyStop() records reason + TOF distance to the flash log the instant it fires (idempotent single write) instead of a posteriori in loop(), where it was missed when measure() exited on phase timeout. Expose lastStopReason()/lastStopTofMm(). TOF safety now debounces with TOF_SAFETY_STOP_SAMPLES consecutive out-of-range reads to ignore single glitches (bubbles, reflections) in water, and clamps the PID output to [PID_U_MIN, PID_U_MAX] so the syringe never reaches the TOF safety limits. Enable monitor echo + LF EOL so serial commands are visible and terminated as the parser expects.
Default PID gains iterated against pool tests: Kp 0.17 was too weak (the float barely moved), Kp 2.0 / Kd 0.13 oscillated (±15cm pumping). Settle on Kp 1.0 / Ki 0 / Kd 0.5 as a damped starting point; fine-tune further at runtime via PID_CONFIG_SET. Reduce the descent kick-start from u=0.979 (near-full syringe, which drove the float straight to the bottom before the PID could brake, ~26cm overshoot) to PID_DESCENT_KICK_U=0.30, so the descent starts gently and the PID takes over before overshooting the target.
Validated in the pool: the float converges on the target depth with ~±1cm final oscillation. Ki vinces the buoyancy offset (recovery), Kd damps the overshoot. Replaces the previous 1.0/0/0.5 starting point.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
add runtime profile, PID, balance and motor settings with persisted ESPA config and ESPB parser support
log and stream normalized syringe position alongside pressure and float depth
require acknowledged command handling, centralize LED states and clean obsolete espA_pool/build artifacts
update firmware docs and protocol/parser/storage tests for the current command contract