Carbon225 / esp32-dshot

DSHOT600 driver with command support for ESP-IDF
MIT License
18 stars 1 forks source link

Reversing direction of bldc motor #1

Closed lukemagdalin closed 1 year ago

lukemagdalin commented 1 year ago

I know this project is probably abandoned since it has not been updated in over 2 years, But this is the only library I have managed to find that successfully controls an ESC using DShot for the ESP32. The main reason why I am using DShot is that it offers the ability to reverse the direction as opposed to PWM.

I see there is a setReversed() method, but when I invoke it, the motor does not change direction. I have tried calling setReversed() both while the motor is moving, and while stopped, but it appears to have no effect.

Carbon225 commented 1 year ago

Don't worry, I'm still alive so I can take a look at it. Reversing direction definitely works. You might try idling the motor for some time and then sending the reverse direction command multiple times until the motor beeps. I might set up a test bench over the weekend to test stuff but I don't guarantee that.

lukemagdalin commented 1 year ago

Thank you for responding so quickly.

After some thinking, I came to the realization that the blheli_s ESCs I am using offers bidirectional mode (3d mode) as a configurable setting. This splits the input throttle range into 2 sections for both directions, and I am able to reverse the motor direction by just sending a regular throttle value. This will probably be faster than sending an additional 10 packets to set the reverse direction, then start up the motor again.

The only question I have now is if this library supports rpm telemetry back. I see there is a way to detect if a packet is a telemetry or not in the library, but no way of reading it.

Thanks.

Carbon225 commented 1 year ago

Telemetry is sent over a separate UART cable, not dshot itself. I haven't investigated the packet format of telemetry but it should be readable even without dshot. On quad ESCs it's usually one common UART TX signal for all motors.

Carbon225 commented 1 year ago

Meaning you can just use the standard UART api and figure out the packet format.

lukemagdalin commented 1 year ago

Sorry for the confusion, by telemetry, I was talking about the bi-directional DShot protocol, which should send telemetry packets back from the ESC over the same signal wire.

At least that is what it is according to the betaflight repo on bi-directional DShot. https://github.com/betaflight/betaflight/wiki/Bidirectional-DSHOT-and-RPM-Filter

Carbon225 commented 1 year ago

I did not implement bidirectional DShot.