Skip to content

Dshot 3D mode, allowing for both forward and reverse rotation - #3139

Merged
CapnBry merged 7 commits into
ExpressLRS:masterfrom
frank26080115:feat-dshot-3d
Nov 11, 2025
Merged

CapnBry merged 7 commits into
ExpressLRS:masterfrom
frank26080115:feat-dshot-3d

Conversation

@frank26080115

Copy link
Copy Markdown
Contributor

DShot does not work linearly, when controlling a ESC configured for "3D", the values are not linear

The stop value is 0, but the lowest throttle value for forward rotation is 1048, the highest throttle forward is 2047. The lowest throttle while reversing is 49, and the highest throttle while reversing is 1047.

But this is also completely different for a ESC configured for single-direction rotation, where 0 means stop, 48 means low throttle, and 2047 means max throttle.

This PR adds a 3D mode for DShot, the user can choose this from the drop-down menu within the Wi-Fi web page user interface. The code in lib\ServoOutput\devServoOutput.cpp has been edited to remap the throttle values properly for the selected mode.

@pitts-mo

pitts-mo commented Mar 15, 2025 •

Copy link
Copy Markdown
Contributor

WARNING: Both PR #3139 and PR #3126 are sending dshot 0000 disarm command prior to ELRS link!

This PR (#3139) does allow user to send the disarmed/zero throttle command which is required for use of AM32 ESCs. And I am now able to use 3d mode with an AM32 esc by setting the RX to use normal DSHOT output and using an EdgeTX curve to trick sending 0000 at center with inverted reverse throttle and normal forward throttle ranges. However, it seems there is something weird with the throttle scale conversions in general that has been causing unexpected output behavior and in the case of dshot3d mode it will complete stop/hang an AM32 ESC.

dshot data from boot->low->high->low test :

dshot3d data from boot->mid>low->high->mid test :

draft EdgeTX dshot to dshot3d test curve:
EdgeTX-dshot-to-dshot3d-test-curve.txt

*Updated to remove invalid data due to a dirty pot and loose connection in my test setup. -fixed now :-)

@pitts-mo

Copy link
Copy Markdown
Contributor

New test of PR#3139 normal dshot along with the RX set to mirror the same channel out on another PWM pin captured with pulseview.
PR3139-PulseView-DSHOT-vs-PWM.zip

This data set clearly shows that the RX is outputting the dshot 0000 disarm command immediately on power up without awaiting link and user input to send dshot 0000 while the PWM pin does not output any signal until after link has been established as to allow the user to safely arm a PWM ESC.

I do notice the output I collected for this test is much cleaner. I am starting to suspect my MT12 P2 knob tainted my prior tests and P2 knob just needed a bit more exercise to clean up the potentiometer wipe path.

When I have more time I will:
-re-test PR #3139 dshot3d mode on AM32 ESC
-refine my EdgeTX test curve to convert dshot to dshot3d

@pitts-mo

Copy link
Copy Markdown
Contributor

I just ran a quick Dshot-3D test and find this does behave as expected.

Currently I think this Just need to leave the dshot pins floating at boot and wait for ELRS link to send dshot packets.

@pitts-mo

pitts-mo commented Mar 17, 2025 •

Copy link
Copy Markdown
Contributor

Commenting this single line will restore arming safety to user control.

dshotInstances[ch]->send_dshot_value(0); // Set throttle low so the ESC can continue initialsation

@frank26080115

frank26080115 commented Mar 17, 2025 •

Copy link
Copy Markdown
Contributor Author

that was there before I started modification, I thought that was the desired behavior

the original code would've armed BLHeli32 ESCs, but not AM32

I'm fine with removing the line that you are pointing out as long as everybody is in agreement

@pitts-mo

Copy link
Copy Markdown
Contributor

Summary understanding:
In ELRS releases versions DShotRMT had nullified 0 command but that has since been fixed in master PR #3126 which has now resulted in the RX removing arming safety from the user. Commenting this line restores arming safety to the user to result in a behavior similar to a PWM ESC.

@pkendall64

Copy link
Copy Markdown
Collaborator

@frank26080115 is it ok with you if I rebase this to master, with a few updates for the config, and push your branch?
I'de like to get this moving for V4

@frank26080115

Copy link
Copy Markdown
Contributor Author

@frank26080115 is it ok with you if I rebase this to master, with a few updates for the config, and push your branch? I'de like to get this moving for V4

Sure go ahead. Is there anything for me to do?

@pitts-mo

Copy link
Copy Markdown
Contributor

I look forward to test this again :-)

Using an EdgeTX curve can allow 3D DSHOT but it's a bit too exciting to switch between PWM / DSHOT modes without remembering to enable/disable the curve :-)

@pkendall64
pkendall64 force-pushed the feat-dshot-3d branch 2 times, most recently from 71e3036 to 395cd67 Compare October 18, 2025 18:22
@pkendall64

Copy link
Copy Markdown
Collaborator

@frank26080115 is it ok with you if I rebase this to master, with a few updates for the config, and push your branch? I'de like to get this moving for V4

Sure go ahead. Is there anything for me to do?

Nothing for you to do. Thanks. They are all updated and ready for testing and hopefully merging soon.

@pitts-mo

Copy link
Copy Markdown
Contributor

Built MT12, ER3C-i, RP4TD, and a gerneric EPW5. All servos and ESCs are working with PWM, DSHOT, and DSHOT 3D as expected. Thank you, -p

@ExpressLRS ExpressLRS deleted a comment from sonarqubecloud Bot Oct 27, 2025

@CapnBry CapnBry left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I merged master and moved the dshot stuff from servoWrite() to its own function. The RX config updater isn't working right but who would expect that anyone could ever do that correctly? I'll fix it in #3391

Behavior change: This PR applied DSHOT-3D with an input range of 988-2012, but existing DSHOT used 1000-2000. We should not have confusingly slightly different ranges so they both now use 1000-2000.

@CapnBry
CapnBry merged commit aa42bc2 into ExpressLRS:master Nov 11, 2025
@pitts-mo

Copy link
Copy Markdown
Contributor

@frank26080115 have you had time to test Dshot3D since CapnBry's updates and merge to master?

After updating my test gear with new builds from master today I appear to observe an issue with Dshot3D center position and/or scaling. Reverting my RX to builds for this PR on 2025-10-19 restored Dshot3D to expected behavior.

I should be able to run more Dshot & Dshot3D tests as well as capture an output sample in the next few days.

@pitts-mo

pitts-mo commented Nov 22, 2025 •

Copy link
Copy Markdown
Contributor

The recent changes have left both Dshot and Dshot3D broken.

PR3302_gaps-in-dshot-data.sr.zip
D3 = Dshot left at 0000 throttle
D4 = Dshot3D cycling center, full forward, center, full reverse.

Notes:
-RX no longer outputs consistent timing of Dshot or Dshot3D packets (see D3 and D4 samples).
-normal Dshot (D3) does not appear to allow the user to send 0000 at low throttle. Depending on the ESC and exact conditions this effectively prevents arming or removes arming safety. This also prevents the user from stopping the motor when using a full resolution Dshot ESC (eg AM32).

PR3302-2025-11-21-gaps in dshot data

@pitts-mo

Copy link
Copy Markdown
Contributor

I have begun to suspect changes made in #3139 reverted user ability to command normal Dshot to 0000 resulting in removal of arming/arming safety when using normal Dshot. While changes in #3140 have introduced the failure of Dshot packet timing consistency.

@CapnBry

CapnBry commented Nov 22, 2025

Copy link
Copy Markdown
Member

Oh lovely, thanks for the report @pitts-mo

Can you try aa42bc2 which is master right after this PR was merged and see if that has the correct DShot 3D output you had verified earlier? We need to narrow down which PR broke it. Hopefully, this one checks out and it is just #3140 messing with the dshot output.

The behavior is extremely different after 3140 by design but it should work. I only reviewed the code itself in both of these PRs, and did not grab any captures to verify their operation.

@pitts-mo

pitts-mo commented Nov 22, 2025 •

Copy link
Copy Markdown
Contributor

I now suspect this data set was in erroneous.

Wow, Great. aa42bc make things look even more weird. I don't see any valid output for normal Dshot and no output at all for Dshot3D.

I also now notice gaps/errors in normal PWM timing in both this data set and the prior one.

aa42bc2-output.sr.zip

aa42bc-output

@mha1

mha1 commented Nov 22, 2025

Copy link
Copy Markdown
Contributor

I'm just looking at PWM using the latest master (2775774). I can't see any major gaps or errors. The scatter plot shows 333Hz packet rate / 333Hz PWM frequency sampled for one minute on CH4., CH5 is on DShot, CH6 is on DShot 3D (to make sure they don't interfere with PWM).

I can't see gaps (all pulses are with 3ms period) and there's hardly any jitter, at worst some quantization noise from ETX (all duty cycle are either 50.03% or 49.96%). What exactly is your setup and what are you looking at?

image

@mha1

mha1 commented Nov 22, 2025

Copy link
Copy Markdown
Contributor

But I can confirm the irregular timing on DShot (3) and DShot 3D (1)

image

@pitts-mo

pitts-mo commented Nov 22, 2025 via email

Copy link
Copy Markdown
Contributor

@pitts-mo

Copy link
Copy Markdown
Contributor

I did forget to clear the uart pin assignments on my RP4TD after I reset it to verify problematic signal ... but clearing them did not make a difference ... testing with aa42bc I still see periodic gaps in PWM signaling, no valid Dshot packets on Dshot output and no output at all for Dshot3D.

@pitts-mo

Copy link
Copy Markdown
Contributor

Test with PR3302 ddd12d ~2025-10-19. All devices appear to work but I do notice some noise on channel 1.

PWM pins = 1,3,18,5

ddd12d_working-but-noise-on-ch1.sr.zip

ddd12d-working but noise on ch1

@mha1

mha1 commented Nov 23, 2025

Copy link
Copy Markdown
Contributor

now repeat the same with master

@pitts-mo

pitts-mo commented Nov 23, 2025 via email

Copy link
Copy Markdown
Contributor

@pitts-mo

Copy link
Copy Markdown
Contributor

master 277577 still notice issues of:
-noise on ch1 (unnoticed long standing issue?)
-gaps in Dshot and Dshot3D signal (regression since PR3139 ~2025-10-19)
-normal dshot commanding 0048 at zero throttle instead of allowing user to command 0000 at zero throttle then transitioning to 0048 above zero throttle (regression since PR3139 ~2025-10-19)

master-2025-11-22_ch1-noise_dshot-gaps.sr.zip

master-2025-11-22_ch1-noise_dshot-gaps

@pitts-mo

Copy link
Copy Markdown
Contributor

ok, I have tested back and forth a couple times now to verify this.

14872ae introduces DSHOT 0048 @min throttle and gaps in DSHOT and DSHOT3D signal

aa42bc2 still functions with PWM, DSHOT 0000 @min throttle, no notable gap in DSHOT or DSHOT 3D data signal.

-Not sending DSHOT 0000 @min throttle makes sense as I notice a hack in DshotRMT.cpp to translate 0048 to 0000 was removed. I will submit a PR to propose a better fix.

-I do not yet understand the issue with gaps in DSHOT data signal.

extra thought:
Curios about the minor noise observed during normal operation on ch1 and ch3 of my RP4TD (pwm pins 1,3,18,5).

@CapnBry

CapnBry commented Nov 23, 2025

Copy link
Copy Markdown
Member

Well the DShot gaps I can say are a function of how #3140 changes how the dshot packets are scheduled now. The old system used a separate piece of hardware for each channel, but the replacement cycles through each one and should be sending a DShot command, switch to next output, send a dshot command, etc. I'm not sure it appears to be doing that properly though.

From the post right above this one though, it appears as you are saying now that aa42bc2 works fine, is this correct?

@pitts-mo

Copy link
Copy Markdown
Contributor

yes aa42bc2 is working. I must have failed to verify firmware update on my early attempt to test aa42bc2.

@CapnBry

CapnBry commented Nov 24, 2025 •

Copy link
Copy Markdown
Member

@pitts-mo I greatly appreciate your testing! Can you try #3417

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement 🪄 New feature or request V4.0 🍔

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants