You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/01.Quadcopter/01.Quadcopter.ino
+9-8Lines changed: 9 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -97,15 +97,16 @@ void setup() {
97
97
//setup madflight components: Serial.begin(115200), imu, rcin, led, etc. See src/madflight/interface.h for full interface description of each component.
98
98
madflight_setup();
99
99
100
-
// Uncomment ONE line - select output type
101
-
int out_hz = 400; int min_us = 950; int max_us = 2000; //Standard PWM: 400Hz, 950-2000 us
102
-
//int out_hz = 2000; int min_us = 125; int max_us = 250; //Oneshot125: 2000Hz, 125-250 us
Available modes: Dshot150, Dshot300, Dshot600, Dshot1200. The number is the bit rate in kHz.
28
+
29
+
Frame Structure
30
+
31
+
11 bit throttle: 2048 possible values. 0 is reserved for disarmed. 1-47 are reserved for special commands. Leaving 48 to 2047 (2000 steps) for the actual throttle value
32
+
1 bit telemetry request - if this is set, telemetry data is sent back via a separate channel
33
+
4 bit CRC: (Cyclic Redundancy) Check to validate data (throttle and telemetry request bit)
34
+
35
+
Resulting in a frame with the following structure:
36
+
37
+
SSSSSSSSSSSTCCCC (16 bits, MSB transmitted first)
38
+
39
+
Pause (output low) between frames: 21 bits recommended, 2 minimum
40
+
41
+
Bit Structure
42
+
43
+
A bit period (6.667 us for Dshot150) is split in 8 equal parts. A zero-bit is encoded as 3H 5L, and a one-bit is encoded as 6H 2L.
44
+
45
+
*/
46
+
47
+
48
+
#pragma once
49
+
50
+
#include"dshot_parallel.pio.h"
51
+
52
+
classDshotParallel {
53
+
private:
54
+
bool setup_done = false;
55
+
uint8_t pin_count;
56
+
PIO pio;
57
+
uint sm;
58
+
uint offset;
59
+
uint32_t write_ts = 0; //last write timestamp
60
+
61
+
public:
62
+
uint32_t interval_us = 0; //minimal interval between two writes in us (16 bits transmission + 21 bits pause)
63
+
64
+
~DshotParallel() {
65
+
end();
66
+
}
67
+
68
+
boolbegin(int pin, uint8_t pin_count, int rate_khz) {
0 commit comments