-
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
RPM sensing from GPIO (PWM pin) pulses #24041
base: main
Are you sure you want to change the base?
Conversation
@sfuhrer |
🔎 FLASH Analysispx4_fmu-v5x [Total VM Diff: 148 byte (0.01 %)]
px4_fmu-v6x [Total VM Diff: 40 byte (0 %)]
Updated: 2024-12-12T14:45:05 |
I rebased on main, fixed the screw up with the unwanted, unused
Here's the plot from the small RC heli spinning the motor without blades open loop: |
/** | ||
* RPM Capture Enable | ||
* | ||
* Enables the RPM capture module on FMU channel 5. |
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.
Before merging, shall we check if we could use other channels different from 5? If so, we should update the comment accordingly.
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.
Yes definitely. I always used 5 so far because of that comment...
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.
I quickly asked the ST experts and the interrupt should be independent of timers and configuring the pin for input interrupt should be possible on most pins but probably depends on the board. So the assumption is it should work also on the other FMU PWM pins.
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.
Confirmed on v5x FMU 👌
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.
@bkueng are you aware of other boards in which only channel 5 would work? Otherwise, would you be ok with removing the channel 5 part of the description?
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.
Channel 5 has history reasons. This is now more flexible as any pin can be configured, so the comment does not apply anymore.
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.
LGTM once we check if we can do RPM sensing in other channels that are not 5.
I confrimed that RPM capture works on other AUX GPIO pins. It's not available in the MAIN pins. I also played around with the parameters of the alpha and medium filters:
Find attached the logs for:
|
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.
Just a bit of nitpicking, otherwise looks good
Such that we can continue development on this part. The implementation was already used before porting things into the RPM capture module.
Not timing out based on a random interval but based on the time after the last inerrupt.
Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
…pe -> use module params
…utput channels and rpm filter time constant
…to work with all these drivers
@bresch Thanks for the thorough review 👍 I rebased on main, addressed all your comments in new commits (not one each but they're referenced) and added 375cd55 on top because I saw that was only necessary before 15fece7#diff-21b8564105b699e09127da22888e7b35b845e53be24c30a6f921ea1f9e82f821L84. |
Solved Problem
When wokring on helicopter rpm control I found that RPM sensing is "easily" possible but requires work. @bkueng provided the nice configurable capture part for that effort and I used the output directly in the heli-specific controller. But now I think we should enable generic RPM capturing for use in control, log, UI reporting.
Solution
As a draft, I added the hardcoded logic we used to process the RPM.Note: This doesn't work well out of the box because it cannot detect a timeout if the interrupt is never called anymore.
The solution in the meantime has:
Thanks for all the help from @oravla5, @sfuhrer and @bresch behind the scenes.
Changelog Entry
Test coverage
This logic was used on a heli to control RPM before porting it to latest main and moving the processing to the rpm capture driver. EDIT: and changing it completely again.
We need to follow up with further testing, settling the interface, implementing the timeout... FYI @sfuhrerWe did testing on an RC helicopter with high pulse per revolution count + noisy signal and a combustion engine with outliers.