-
Notifications
You must be signed in to change notification settings - Fork 13.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add DShot module #12854
Add DShot module #12854
Conversation
@bkueng, first congrats on this amazing work you have done so far, and for the first DShot PX4 flight :) I went through F7 DMA drivers (Nuttx DMA for F7) and I think this may work just as it is. F4 and F7 share the same registers for DMA. As you helped me on Slack to understand FMUv5 boards I added defines to skip that unsupported IO Processor (F1 MCUs) building Dshot for them. Firmware is building for F7 boards, and it should use their own drivers (nuttx/arch/arm/src/stm32f7/smt32_dma.h) for DShot drivers. |
One idea I was going to explore was continue splitting all the px4fmu functionality into separate minimal modules and rely on the underlying channel allocations in io_timer to prevent conflicts. Pin ownership would then become first come, first served.
Instead of modes the fmu module (now simply pwm) would try to take the required pins when loading a mixer. If there's a conflict we can tell the user exactly what's happening (trying to load a mixer with 6 outputs and pins 5 & 6 already taken for gpio, etc) and either completely abort, or only use a subset. Pros
Cons
|
@bkueng Can you please ping me when Dshot is in a documentable form - I presume this is not going into PX4 v1.10? In the docs we we explicitly state that we don't support it in the docs - so we would need to remove that. If there is any explicit config or different hardware set up we'd want to capture that too. |
ce17e99
to
23003e9
Compare
Thanks! The larger portion of the credits goes to you, without the lower level parts it would not be possible.
Indeed, it does! I expected more work would be needed. @dagar yes that might work. @hamishwillee sure. The short answer: as soon as this goes in it's usable (we need to enable it on all boards though). Updates
Known IssuesProblems I came across while testing:
|
And the long answer? :-) Because I take that to mean that these instructions will work without any change http://docs.px4.io/master/en/peripherals/pwm_escs_and_servo.html |
ca321e4
to
51763a8
Compare
This can be tested on Pixracer now, e.g. by setting |
51763a8
to
ea90eae
Compare
@bkueng How can we get this working on Pixhawk 4? |
ea90eae
to
4ffbe0c
Compare
I enabled it on v5, but only for the first 4 outputs (the next ones conflict with px4io |
OK, let me have a look , thanks :) |
049b662
to
b8710af
Compare
I've flown this quite a bit on Pixracer and KakuteF7 (Kopis 2 frame with telemetry), so that I'm confident it's working. Flight PerformanceOn both vehicles I've flown (250 size), I noticed considerably smoother flight performance - both audibly and visibly. Prop-wash handling is noticeably improved. BoardsDShot is enabled on these boards:
IssuesIssues from above:
The problem is the flash-based param saving: in some cases the entire CPU stalls for ~300ms, which causes DShot not to update anymore (on PWM and Oneshot, the timers continue to trigger). If in-air, the motors might stop, so the param auto-saving is now deferred until disarming for flash-based param storage.
Fixed by updating the timer config before triggering the DMA update. LogsWith a Pixracer:
Other
@PX4/testflights can you test this on Pixhawk (v3), Pixracer and Pixhawk 4 on vehicles with ESCs that support DShot? You can follow the instructions here: https://github.com/PX4/px4_user_guide/pull/578/files#diff-58ea316b3b439c16b17ab4f924adc37a. Be careful, the vehicle might need some re-tuning. I'm not sure if we want to pull this into v1.10? |
We're currently using non-DMA capable memory in the heap on F7.
It would be interesting to compare a few flights at different loop rates. You can do this now with the |
And handle failures of up_dshot_init(). On Omnibus: reduces memory usage if dshot is enabled by ~1.0KB. The buffer is roughly 1KB in size.
No other functional change, just restructuring.
This reloads the timer configuration before triggering DMA. Without that, in rare cases, there were 17 bits sent instead of 16. The 1. bit (1. pulse) was always wrong (too much), the rest of the bits were the correct DShot packet that was meant to be sent.
But only on the first 4 FMU outputs, as the next ones conflict with px4io serial dma (UART8_RX) RX DMA is disabled on the GPS port as well (conflicts with TIM1).
This is especially important for DShot, that does not update when the CPU stalls.
Disables RX DMA on TEL4 and IO debug serial port
0a96148
to
69a5561
Compare
This is so awesome!!! 🚀 I come from flying the Holybro Kopis 2 with the new DSHOT support and it flies that good now! It's really confidence-inspiring. Thanks a lot to @bkueng @dagar @Igor-Misic and everyone else who helped for doing all these low-level improvements that will drastically improve any low latency actuated vehicle's flight performance! |
Since being spoiled from flying racing-quadrocopters with DSHOT and telemetry for quite some time i am very happy to see those features being implemented into PX4. Thank you! I'm currently building a VTOL with the CUAV V5 Nano Flight Controller. It has 3 Motors and 5 Servos, wich is also exactly the number of PWM outputs of the FC. It is similar to the Convergence-airframe, but i can also tilt the rear Motor.
Doas that mean if i enable DSHOT the first 4 outputs are going to use DSHOT or doas it depend on the motor-count. If it is enabled on the first 4 outputs, i could not use nr. 4, but then im missing an PWM output for one of my Servos. The second question is regarding logging. Is it possible to log the ESC telemetry data and add it to the logfiles? That could help with analysis a lot. |
@thomasderflieger Docs are here: http://docs.px4.io/master/en/peripherals/dshot.html. You wire according to your mixer file/airframe reference: http://docs.px4.io/master/en/airframes/airframe_reference.html. Ie it is enabled for whatever motors you have connected, but not for servos. @bkueng Would need to comment on logging. |
It's indepenent on the motor count and the current implementation does not allow for mixing DShot with PWM outputs on the FMU pins (on a board with an IO you could use PWM on the IO pins and DShot on the FMU pins).
It already is. It is the |
Thats a pitty, was looking forward to using dshot for my VTOL, my current flight controller just has main-ports though. I assume that the Telemetry wont work without using dshot either, since the ESC's need a "telemetry-request message"?
Great, thanks! |
Exactly. Yeah, that's a drawback, but with all configuration options and timer restrictions, it would become really complex. |
Just do be sure, does that mean that it's not possible to use camera triggering (GPIO) on a PixRacer together with DShot? |
That is possible. Do you have a setup where you can test it? |
yes we could probably test that pretty easily |
} | ||
|
||
// publish when motor index wraps (which is robust against motor timeouts) | ||
if (motor_index < _telemetry->last_motor_index) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we were testing dshot with just one ESC connected we could not get telemetry info on esc_status
because of this line. I don't know if 1 ESC is an actual use case (planes?), but if it is, would the following be better?
if (motor_index <= _telemetry->last_motor_index) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I don't see any issues with that. Can you do a PR?
A quick bench test with camera triggering configured on pins 56 on a PixRacer (GPIO, active low) appears to work just fine. |
Thanks for confirming |
This brings #12634 from @Igor-Misic and adds a new output module that uses the low-level DShot interface. The PR includes the commits from #12790.
The dshot module is implemented as drop-in replacement for fmu, which means it handles the same modes so that other functionality is not lost - the duplication is however not nice.
I've flown this on the Omnibus BetaFPV tiny whoop with DShot600.
DShot is enabled on OmnibusF4SD and Pixracer.
Caution: Before flying this on a Pixracer, we need to double-check that there are no DMA resource conflicts.
Missing/next steps: