DriveMaster is a common library designed to simplify the implementation of RC protocol decoding in Arduino projects. It provides a modular and extensible architecture that allows for easy integration of various RC protocols.
Supported Protocol
DShot
Frame Structure
The DShot frame consists of 16 bits and follows a specific structure:
- Throttle: 11 bits representing throttle values ranging from 48 to 2047.
- Telemetry Request: 1 bit indicating whether telemetry data is requested.
- CRC: 4 bits for error checking using a cyclic redundancy check.
DShot Versions and Bitrates
Different versions of DShot support varying bitrates and durations for high and low signal times:
DShot Version | Bitrate (bps) | T1H (µs) | T0H (µs) | Bit Length (µs) | Frame Length (µs) |
DShot150 | 150,000 | 5.00 | 2.50 | 6.67 | 106.72 |
DShot300 | 300,000 | 2.50 | 1.25 | 3.33 | 53.28 |
DShot600 | 600,000 | 1.25 | 0.625 | 1.67 | 26.72 |
DShot1200 | 1,200,000 | 0.625 | 0.313 | 0.83 | 13.28 |
Getting Started
Installation
Arduino Installation
To use the DriveMaster library in your Arduino projects, follow these installation steps:
- Download the DriveMaster library from the GitHub repository.
- Extract the downloaded ZIP file.
- Copy the extracted folder to the
libraries
directory in your Arduino sketchbook.
- Restart the Arduino IDE.
- You should now be able to include the DriveMaster library in your Arduino sketches.
PlatformIO Installation
If you are using PlatformIO, you can install the DriveMaster library directly from the PlatformIO Library Manager. Add the following line to your platformio.ini
file:
lib_deps = Witty-Wizard/DriveMaster
Tutorial
Using DriveMaster Library for Motor Control
To control motors in your Arduino project using the DriveMaster library, follow these steps:
- Include Necessary Libraries
Include the required library at the beginning of your sketch:
Header file for the DriveMaster class.
- Instantiate DriveMaster Object Create an instance of the DriveMaster class, specifying the pin connected to the motor:
Base class for motor control.
Definition DriveMaster.h:16
- Initialize Motor Control Call the begin() method to initialize motor control:
void setup() {
}
virtual void begin()
Initialize the motor control.
Definition DriveMaster.cpp:9
- Send Commands or Values You can use the sendCommand() or sendValue() methods to send specific commands or values to the motor:
virtual void sendCommand(uint16_t value)
Send a command to the motor.
Definition DriveMaster.cpp:14
virtual void sendValue(uint16_t value)
Send a value to the motor.
Definition DriveMaster.cpp:15
Examples
DShot Example
#define MOTOR_PIN 9
void setup() {
}
void loop() {
delay(1000);
}
License
This library is distributed under the GNU General Public License version 3.0.