-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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
Fix PWM/Oneshot calibration #21711
Fix PWM/Oneshot calibration #21711
Conversation
to make them easy to search for and check the arguments.
- Change timings for a more reliable calibration. - Make sure there's an error message when battery measurement is not available also when it gets disabled after system boot in the power just above the calibration button. - Safety check if measured electrical current goes up after issuing the high calibration value for the case the user did not unplug power and the detection either fails or is not enforced.
Some ESCs e.g. Gaui enter the menu relatively quickly if the signal is high for too long. To solve that it's kept high shorter. Also all tested ESCs detect the low signal within a shorter time so no need to wait longer.
Before this the ESC calibration aborts if battery detection doesn't work. The problem is if the user still connects the battery as he gets instructed and the calibration aborts then the ESCs are in calibration mode and after abortion calibrate to the wrong value. Also I realized there's no additional safety by aborting the calibration if the battery cannot be detected during the timeout because a pixhawk board without power module will report a battery status from the ADC driverand in it that no battery is connected which is the best it can do. In this situation the motors will still spin if the ESCs are powered.
69ea5be
to
e83363f
Compare
I did testing on 5 different PWM ESCs and adjusted the timing to work with all of them. Also I allowed ESC calibration without battery detection see my edit in the "Alternatives" section above. |
This pull request has been mentioned on Discussion Forum for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink. There might be relevant details there: https://discuss.px4.io/t/px4-maintainers-call-june-13-2023/32587/1 |
battery_status_sub.update(); | ||
|
||
if ((now - timeout_start) < 1_s && (battery_status_sub.get().current_a > current_before_calibration + 1.f)) { | ||
// Safety termination, current rises immediately, user didn't unplug power before |
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.
Did you test this case?
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 I did with multiple setups. If the current is picked up by the power module it reacts very fast, aborts and the motor(s) don't have time to spin up. It also triggered with a single small motor and no propeller attached. I made it only trigger in the first second because there can be a 1A current spike measured during a normal calibration later on which makes finding a safe threshold much harder.
It can't provide a guarantee because the user could be powering the ESC independently of the power module and then no current is measured. But in my eyes it's a worthwhile safety layer because it would have caught point 1. in #21634.
Here's a plot from one of my tests. The current spike leads to an immediate abortion and basically just a stutter of the motors:
I should probably change the timeout check for this one too then ⚙️
Co-authored-by: Beat Küng <beat-kueng@gmx.net>
67bc737
to
24c9ee0
Compare
Thanks a lot for the review @bkueng ! I think I don't completely understand the timestamp wrapping. Let me know if it's better now with the last commit. |
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 think I don't completely understand the timestamp wrapping.
It's only a problem in certain cases, because unsigned int is used: if you have a-b and b>a, it wraps. Specifically it happens when taking the current time, then doing an orb copy which was published after the current time. That can't happen in your case, but there's various places where it can, and so it's better to be consistent everywhere.
For the 1.14 release because we already changed the actuator configuration and users will need to go through their setups I also corrected the PWM calibration and the default PWM values. See PX4/PX4-Autopilot#21711 and PX4/PX4-Autopilot#21513 This is the documentation change with it. And needs to be referenced by the release notes.
Here's the documentation change for this together with the new PWM defaults (#21513): PX4/PX4-user_guide#2599 |
For the 1.14 release because we already changed the actuator configuration and users will need to go through their setups I also corrected the PWM calibration and the default PWM values. See PX4/PX4-Autopilot#21711 and PX4/PX4-Autopilot#21513 This is the documentation change with it. And needs to be referenced by the release notes.
For the 1.14 release because we already changed the actuator configuration and users will need to go through their setups I also corrected the PWM calibration and the default PWM values. See PX4/PX4-Autopilot#21711 and PX4/PX4-Autopilot#21513 This is the documentation change with it. And needs to be referenced by the release notes.
Solved Problem
When testing #21513 I found (again) that PWM calibration does not do what I expect and leads to it almost being impossible to configure PWM outputs consistently once a calibration was performed. That's why I opened #21634 and want to fix that first.
Fixes #21634
Solution
Changelog Entry
For release notes:
Alternatives
I want to also allow PWM calibration when the battery detection is not possible e.g. because the user has no power module or it needs to stay connected to power the autopilot. I suggest we take this PR without additional functionality together with #21513 first for the 1.14 release and deal with the manual calibration with the corresponding UI as a next step. The problem right now is the tight integration with the QGC UI being very limited. The first step would be to at least have a backward-compatible MAVLink shell way of doing that.EDIT: I allowed to calibrate without battery detection because of the following reasons:
So the only disadvantage is that the UI does not show when the user did actually not plug the battery which is much less bad than not allowing a calibration at all and aborting in the worst moment which makes the ESC calibrate to the wrong value. So I suggest this as the in-between step and fixing the UI next.
Test coverage
I'm testing with more ESCs now.