-
Notifications
You must be signed in to change notification settings - Fork 13.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Dev dshot #12634
[WIP] Dev dshot #12634
Conversation
Released stream 5 from USARTs in board.h Added drv_dshot header and source. Added more registers to config for the Advance timer in drv_io_timer.
How were you testing this? |
src/drivers/stm32/drv_io_timer.c
Outdated
unsigned timer = channels_timer(channel); | ||
|
||
rARR(timer) = DSHOT_MOTOR_PWM_BIT_WIDTH; | ||
rPSC(timer) = ((int)(io_timers[timer].clock_freq / dshot_pwm_freq)/DSHOT_MOTOR_PWM_BIT_WIDTH) - 1;; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rPSC(timer) = ((int)(io_timers[timer].clock_freq / dshot_pwm_freq)/DSHOT_MOTOR_PWM_BIT_WIDTH) - 1;; | |
rPSC(timer) = ((int)(io_timers[timer].clock_freq / dshot_pwm_freq)/DSHOT_MOTOR_PWM_BIT_WIDTH) - 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With calling init function with different DSHOT frequencies.
example:
up_dshot_init(channel_mask, DSHOT1200);
up_dshot_init(channel_mask, DSHOT600);
up_dshot_init(channel_mask, DSHOT300);
up_dshot_init(channel_mask, DSHOT150);
And then sending the arming command:
up_dshot_arm(true);
Setting throttle value:
uint16_t throttle = 100;
up_dshot_motor_data_prepare(0,throttle, true);
And triggering the message:
up_dshot_trigger();
I've connected logic analyzer on dshot (servo wire) to see frequencies.
ESC was working for my setup Pixracer at 168 MHz on all Dshots modes. It was able to arm and to spin the motors.
For each Dshot message, frequency needs to be near selected.
For example dshot 1200, the frequency will be around 1.2 MHz. It depends on the selected system frequency, and this formula will calculate the closest one by rounding it down because of the integer.
Realistically will a user need/want to configure the equivalent of PWM_{MIN, MAX, DISARMED} when using dshot? |
@dagar Nope. Edit: Maybe only for setting the threshold for when motors start spinning, etc. (varies) |
At the moment I'm thinking a simple dshot "driver" that you optionally run in place of px4fmu is going to make the most sense. That should also work well as a place to handle telemetry. |
Code cleaning. Co-Authored-By: Daniel Agar <[email protected]>
If you mean by the whole driver, I added some extra code inside boards/px4/fmu-v4/init.c at the end of int board_app_initialize(uintptr_t arg) function. At that point, I'm sure Nuttx initialized all NVIC and DMA2 so you can start using stream5 and code for nuttx will handle interrupts. This is the code which I use for testing drivers At the beginning of the file: At the end of the board_app_initialize function
|
Reopening pull request because accidentally removed branch. |
Released stream 5 from USARTs in board.h Added drv_dshot header and source. Added more registers to config for the Advance timer in drv_io_timer.
Code cleaning. Co-Authored-By: Daniel Agar <[email protected]>
…ge 0-1999 And check if the board provides a valid dshot config
Code style update 2. Proper address casting style. Code style update 3.
We'll need to go through each board and get the DMA map under control. This was a bit of a pain for SPI. #12436 |
Thanks @Igor-Misic . I have created a docs page to track here PX4/PX4-user_guide#560 That sounds like a good plan. Sounds like we don't need work on this until "end user support" is in. Please ping me when you think we're ready for that. |
For ESC support, I believe BLHELI_S also supports DShot up to 600kHz, but not bidirectional. |
Continued in #12854. |
Describe problem solved by the proposed pull request
This PR adds drivers for Dshot protocol. (This is not full support for Dshot protocol, only drivers.)
Test data / coverage
Dshot protocol was tested on Pixracer. This still needs to be integrated into the whole system and tested.
Describe your preferred solution
We have discussed on a slack channel to add this driver support.
Describe possible alternatives
No alternative, at the moment this is how other PWM drivers work.