- Easy to use
- No need for timers, interrupts or DMA
- Low setup and usage complexity
- ERPM packets are decoded in this library
- Fast bidirectional communication
- Bidirectional and normal DShot up to 4800 (tested up to DShot 1200)
- Speed only limited by DShot protocol
- Fully asynchronous: no CPU intervention needed for sending or receiving
- Oversampling with edge detection
- Telemetry unaffected by jitter/aliasing or clock differences between ESC and MCU
- Low CPU overhead: Edge detection is done on the PIO
- Low usage of PIO hardware
- Bidirectional DShot needs 28 instructions and 1 state machine per ESC => max 8/12 ESCs
- Normal DShot needs 4 instructions and 1 state machine per 4 ESCs => max 30/48 ESCs
- Extended DShot Telemetry support
- Read ESC temperature, voltage, current and more: all integrated
- See here for more information
This is essentially a bare minimum example for the Arduino IDE. For more details, check the integrated examples or the Wiki.
#include <PIO_DShot.h>
#define MOTOR_POLES 14
BidirDShotX1 *esc;
void setup() {
esc = new BidirDShotX1(10, 600); // pin 10, DShot600
}
void loop() {
delayMicroseconds(200); // keep packets spaced out
uint32_t rpm = 0;
esc->getTelemetryErpm(&rpm);
rpm /= MOTOR_POLES / 2; // eRPM = RPM * poles/2 <=> RPM = eRPM / (poles/2)
esc->sendThrottle(0); // 0-2000
}
Not calling getTelemetryErpm
is fine if you don't care about that, but you definitely need to call sendThrottle
regularly (recommended >500Hz), or else the ESC will time out because it thinks the main controller died.
- Open the Arduino IDE and go to
Sketch
->Include Library
->Manage Libraries...
- In the Library Manager, search for
Pico_Bidir_DShot
and install it
Append this repo to your lib_deps in your platformio.ini
:
lib_deps = https://github.com/bastian2001/pico-bidir-dshot.git
The code is written to use no Arduino.h for regular usage, so it can be used with the bare Pico SDK as well. Only the debug info uses Arduino's Serial class, so you can't enable those error hints without it. I personally never used CMake (manually), so sadly I can't help you with the installation.
- Refactor code into library
- Add example code and test on RP2040
- Add documentation
- Adjust and test code for RP2350 (more PIOs)
- Release to Arduino Library Manager
- Add more setups (e.g. DShotX1 - more efficient and versatile, DShotX8 - less PIOs needed)
- Add more features (command queue, sendAll etc.)
If you feel like a feature is missing or something is broken, feel free to open an issue. I'm happy to help you with any questions you might have.
If you have the experience to fix the issue yourself, feel free to open a pull request. I'm happy to review and merge it.
- DShot - The missing handbook: The only source I could find for bidirectional DShot
- Decoding a DShot eRPM packet: Thanks for some sample code
- Extended DShot Telemetry