Skip to content
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

Send PWM_MIN value after a PWM_MAX value while calibrating ESCs #11663

Closed
wants to merge 1 commit into from

Conversation

dusan19
Copy link
Contributor

@dusan19 dusan19 commented Mar 15, 2019

When the ESC calibration is performed through QGC, the PWM_MIN value is not written appropriately. This can be verified by connecting to the ESC directly through BlHeli Suite.
ESC calibration should be done using the following procedure: Send PWM_MAX value for at least 3 seconds, followed by the PWM_MIN value for at least 3 more seconds. Instead the current implementation sends PWM_MAX value followed by the PWM_DISARMED value.
On the ESCs that I tested, this results in setting the PWM_MIN esc setting to 1012 regardless of the PX4's PWM_MIN value.
The following fix is proposed. Note: PWM values are being sent for 5 seconds, since 3 second long signals weren't detected reliably.
Using this fix, the values written in the ESC (checked with BlHeli Suite) matched PX4 PWM_MIN and PWM_MAX parameter values.
Following plots provide PWM output values during calibration, before and after the fix
pwm_bad
pwm_fixed

@dusan19 dusan19 force-pushed the upstream_fix_esc_calibration branch from e21b14a to 82cb33a Compare March 15, 2019 17:36
@dusan19 dusan19 closed this Mar 15, 2019
@dusan19 dusan19 reopened this Mar 15, 2019
@LorenzMeier
Copy link
Member

Thanks! I have a couple of questions:

  • For common ESCs, is the min where they do not spin or where they spin? Because the "min" in PX4 is the minimum where the motor should still spin, "disarmed" is the value where the propeller should stop spinning.

  • The change goes deep into the PWM driver architecture and lacks generality with the calibration sequence. This needs to be changed to not change the output driver. However, given the first point, I'm not even sure it does what is required.

@dusan19
Copy link
Contributor Author

dusan19 commented Mar 18, 2019

Yes, you are right, they dont' spin with min pwm, you would have to increase the throttle just a bit to make them spin. So probably something smaller should be sent as a min pwm, like 0.9*min_pwm.
Anyway the way it works at the moment is not right because, the ESC min-max and px4 min-max ranges are not the same, so the mapping between PX4 outputs and motor inputs is not correct.

Regarding the driver changes, I didnt change the way it is used. It already checks if the calibration is active and sends the pwm max signal. I just added sending the pwm min signal next to that, depending on the calibration phase. Perhaps instead we should use set min and set max pwm ioctl definitions, and remove any calibration logic from the driver.

@dusan19 dusan19 force-pushed the upstream_fix_esc_calibration branch from 82cb33a to e3d5df1 Compare April 1, 2019 11:13
@dusan19
Copy link
Contributor Author

dusan19 commented Apr 2, 2019

With the latest change, there is a small range of pwm values between the one sent to the ESC and the PWM MIN value, to allow the motors to spin when armed with PWM MIN setting.

@mcsauder
Copy link
Contributor

Hi @dusan19 , if you can resolve merge conflicts here and rebase I would be happy to take a look at your code!

@dusan19
Copy link
Contributor Author

dusan19 commented Oct 15, 2019

Hi @mcsauder, I could do that, but check out the discussion here #12759
In the end a suggestion to solving the problem was setting the PWM_MIN, PWM_MAX and PWM_DISARMED such that they match the ESC input range. Basically the disarmed is the low calibration end, and the pwm_min is a bit higher such that it spins the motors, but it doesnt set the esc min calibration setting.
This PR handles the problem in the opposite way, it calibrates the low end to be a bit smaller than pwm_min such that the motors still spin at pwm_min, and the disarmed is lower than all of that such that it is lower than minimum configurable value for min pwm in the esc. This way there is a clear separation between disarmed and min-max range configured in the esc.

If you still think this change is worth pursuing, I could solve the conflicts, rebase and push

@stale
Copy link

stale bot commented Feb 9, 2020

This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.

@mrpollo mrpollo requested a review from dagar February 3, 2021 16:26
@junwoo091400 junwoo091400 added the Drivers 🔧 Sensors, Actuators, etc label Mar 5, 2023
@MaEtUgR
Copy link
Member

MaEtUgR commented Aug 7, 2023

I assume this is superseded by #21711
Motor calibration now always runs between 1000 and 2000us independently of the PWM configuration.
Please reopen and state the use case where the implementation on PX4 1.14 does not work then we can improve further.

@MaEtUgR MaEtUgR closed this Aug 7, 2023
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Drivers 🔧 Sensors, Actuators, etc Multirotor 🛸
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants