Repository navigation
motor_srxl2: link an ESC powered together with the board - #12085
sensei-hacker merged 4 commits into
Conversation
An Avian powered with the board announces itself 43 to about 345 ms after the board's reset, links only once those handshakes are over and only if control frames are still coming, and never links if left unanswered. The ports opened at 325 ms, after the USB wait, and the driver first ran from the task at about 6 s, so a battery connected to board and ESC together left the motor dead until it was unplugged and plugged in again. Timer and serial init move ahead of the USB wait, and a board set to SRXL2 opens its ports there and runs the driver until every ESC has replied to a telemetry request (349 ms on the bench), gives up on one that has not spoken by 200 ms, and stops at 700 ms whatever happens. Init's fixed waits keep the ESCs answered instead of sleeping, so one powered a little after the board links too. Other motor protocols only see the two calls move. The keepalive answer waits 500 ms into a link: answered again during its handshakes, the Avian did not link when they ended. The rest of init leaves the ESC without frames for about 4 s. The Avian announces itself through them and the task links it again; one still starting begins its startup anew, so the arming check counts its readiness again from when the frames return. The check also asks for a recent telemetry reply rather than any frame, since an ESC that has lost its frames still sends handshakes. The docs and two comments said a board restarting under a powered ESC never gets it back: a linked Avian that loses its frames announces itself again, and the task links it.
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
PR Summary by QodoLink SRXL2 ESCs during flight-controller power-up
AI Description
Diagram
High-Level Assessment
Files changed (5)
|
Code Review by Qodo
1.
|
|
RAM / Flash usage vs. base branch — commit
See RAM/flash optimization guide for techniques to reduce usage. |
|
Test firmware build ready — commit Download firmware for PR #12085 251 targets built. Find your board's
|
|
I tested on avian 100A esc with nexus XR with both this fix and 12084 and I am correctly initializing esc with telemetry when powering up both together (power via esc bec). I confirm motor responds |
|
@UltraFly thanks, that is the case my bench could only stand in for: the board powered by the ESC's own BEC, both starting together, and here on a real NEXUS XR with an Avian other than my 70A. I've added it to the description. |
# Conflicts: # docs/Spektrum Smart ESC.md # src/main/io/motor_srxl2.c
…tarts A 150 ms gap in the board's frames restarted the 10 s arming wait whatever the ESC's state, so a pause of the board's own, long after the ESC had started, blocked arming again for 10 s with the OSD's hardware warning. Only an Avian still starting when its frames stop starts over; one already started takes the throttle back at once. The state is judged when the frames stopped, so a gap that begins during the startup restarts the wait however long it is.
|
Tested on a second airframe: an E-flite T-28 with its own TBS Lucid H7 Wing and its Avian Smart ESC on UART8, 4S LiPo, propeller off.
|
|
Thanks for this. Merging. Just an FYI heads up since you're doing a lot of SRXL2 work -- Control and telemetry protocols like srxl2 may be the first group that I do that with. So the goal will be all the HoTT stuff lives only in HoTT-specific files, all the CRSF stuff in CRSF-specific files, etc. It may be SRXL2 will be one of the first ones I work on. As you do any other work on control and telemetry protocols, it may be helpful to keep that in mind and start moving that direction. |
iNavFlight#12085 moved timerInit() and serialInit() ahead of the USB wait; serialPadsInit() goes right before serialInit() there, so the UARTs are on their pads before any port opens, the SRXL2 one included.
An Avian powered from the same battery as the flight controller never linked: arming stayed blocked with HWFAIL until the battery was unplugged and plugged in again. That is the power-up case @UltraFly reported in #11184.
This builds on #12084 (ready delay), now merged.
Why
Measured on a Lucid H7 Wing with an Avian 70A, both on one bench supply, times from the board's reset:
An Avian left unanswered never speaks again. After its handshakes I sent it 17 kinds of frame: handshakes to 0x40 with baud 0 and 1, from source IDs 0x31, 0x21, 0x10 and 0x30, to 0x00, broadcasts, control data with telemetry requests with and without a handshake before them, all of it again at 400000 baud, and a long low. Not one byte came back.
Answering it early is not enough either. It ignores any answer while it is still sending its handshakes, with the answer 0.17, 1, 3, 5 or 10 ms after each one, and it only links once they are over, if control frames are still coming then:
A linked Avian that loses its frames announces itself again, and answers the task: over a board restart of about 6 s, and through a firmware flash with the battery connected.
The change
fc_init.c:timerInit()andserialInit()move ahead of the USB init. Nothing between the two positions uses them or is affected by them; that is the only change for other motor protocols.srxl2MotorInitialize()does nothing the second time, so the existing call sites keep the link.BRUSHED_MOTORSstart as before: they force brushed motors, so SRXL2 never drives them.Related
srxl2MotorInitialize()and the same doc. It is independent of this one and merges with it without conflicts; I built the two together too.Cost
Boot, on SRXL2 boards only: the first wait ends when the ESC replies, 349 ms after reset on the bench and never later than 700 ms; 110 ms after a restart with a linked ESC; about 185 ms when no ESC is powered. The later waits keep their length, unless an ESC starts linking during one: then that wait lasts up to 700 ms more.
Against #12084 (ready delay):
Tested
On the Lucid H7 Wing with an Avian 70A: both powered together (with the USB unplugged, the board read afterwards), a restart and a firmware flash with the ESC powered and linked, and SRXL2 set with the ESC unpowered. Builds: F405, F722, F745 (KAKUTEF7, KAKUTEF7HDV), H743, AT32F435, SITL, and ALIENFLIGHTF4 for the brushed case.
The later waits with an ESP32 that plays the Avian's power-up as measured above, powered at steps after a restart:
The Avian driving its motor (no propeller, 6S battery) through the 4 s without frames, 1.4 to 5.8 s after the ESC's power-up, as the start-up leaves it. A bench build logged the ESC's telemetry, which reports the throttle it takes and its rpm. For the first three rows it silenced the driver, which sent nothing and dropped what arrived; for the last one it stopped the driver's task, as init does:
By @UltraFly on a NEXUS XR (F722) with an Avian 100A, together with srxl2: wait for the Avian's startup tones before allowing arming #12084: the board powered by the ESC's BEC, both starting together. The ESC links with its telemetry and the motor responds.
Not tested, testing wanted