/teensyshot

DSHOT communication with ESC using a teensy MCU

Primary LanguageC++GNU General Public License v3.0GPL-3.0

teensySHOT

  • DSHOT communication with ESC using Teensy 3.5 or Teensy 4.0 development boards
  • DSHOT600 is generated using DMA
  • Telemetry is received through UART at 115200bps
  • Velocity PID control running at 500Hz is implemented for up to 6 motors

File Description

  • ESCPID: code running on the Teensy
    • DSHOT.cpp: DSHOT600 communication.
    • AWPID.cpp: Anti-Windup PID.
    • ESCCMD.cpp: Bidirectional communication between Teensy and ESC.
    • ESCPID.ino: main program.
  • host: code running on a Linux platform connected to the teensy.
  • docs: useful documentation (MCU datasheets, DSHOT command description, telemetry protocol explanation, PID description...).

API Description

Incoming data

Velocity reference and PID parameters.

Out-coming Data

Data structure containing telemetry data, error code and last DSHOT command.

Tunable Macros

  • ESCCMD_ESC_EMULATION (ESCCMD.cpp): flag to enable or disable ESC emulation. When enabled, the telemetry data is emulated. Packet loss can also be emulated. This helps to debug the code without ESC.
  • ESCPID_NB_ESC (ESCPID.h): define the number of ESCs that are handled by teensySHOT.
  • ESCPID_PID_MAX (ESCPID.h): Maximum PID control value. The maximum allowed is 999. A lower value may limit the motor maximum RPM in case of controller instability. Start testing with a low value and when everything is ok, raise it to the max.

Wiring

teensySHOT can communicate with up to 6 ESCs. The following pins are to be used with the current version. It is possible to change some DSHOT pins using muxing options of the MCU (tutorial in progress).

Teensy 3.5 Teensy 4.0
DSHOT TLM/RX DSHOT TLM/RX
1 22 0 4 0
2 23 9 8 7
3 6 7 24 15
4 20 31 22 16
5 21 34 23 21
6 5 47 9 25

Authors