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

pwm rates can not be set more than 400hz #13762

Open
feemi opened this issue Dec 18, 2019 · 5 comments
Open

pwm rates can not be set more than 400hz #13762

feemi opened this issue Dec 18, 2019 · 5 comments

Comments

@feemi
Copy link

feemi commented Dec 18, 2019

Describe the bug
pwm rate parameters range is -1 to 2000 however you can not set more than 400hz. It sets to 400 if you try to set more than this value.

To Reproduce
Steps to reproduce the behavior:

  1. open mavlink console

  2. run pwm rate -r 600 -c 1234 command

  3. run pwm info command

  4. See values limited to 400 hz

Expected behavior
pwm rates should be set as desired.

Log Files and Screenshots
Screen Shot 2019-12-18 at 16 27 18
Screen Shot 2019-12-18 at 16 25 03

Add screenshots to help explain your problem.

Drone (please complete the following information):

  • pixhawk cube 2.1 fmu v3
  • px4 v1.9.2
@feemi
Copy link
Author

feemi commented Dec 18, 2019

It seems that solution can apply this chunk of code in registers.c file
But I dont think this values should be hardcoded like this.
Is it okay to add min max values to drv_pwm_output.h ?

		case PX4IO_P_SETUP_PWM_DEFAULTRATE:
			if (value < 25) {
				value = 25;
			}

			if (value > 400) {
				value = 400;
			}

			pwm_configure_rates(r_setup_pwm_rates, value, r_setup_pwm_altrate);
			break;

		case PX4IO_P_SETUP_PWM_ALTRATE:

			/* For PWM constrain to [25,400]Hz
			 * For Oneshot there is no rate, 0 is therefore used to select Oneshot mode
			 */
			if (value != 0) {
				if (value < 25) {
					value = 25;
				}

				if (value > 400) {
					value = 400;
				}
			}

			pwm_configure_rates(r_setup_pwm_rates, r_setup_pwm_defaultrate, value);
			break;

@mwiatt
Copy link
Contributor

mwiatt commented Dec 18, 2019

The standard in RC PWM control is a 1ms pulse indicating "low" and a 2 ms pulse indicating "high". A 400 Hz update rate gives a 2.5 ms period. Anything much more than a 400 Hz update rate would not allow a 2ms pulse to get through. That is why the PWM refresh rate is capped at 400 Hz.

@stale
Copy link

stale bot commented Mar 18, 2020

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

@stale stale bot added the stale label Mar 18, 2020
@FlavioTonelli
Copy link
Contributor

FlavioTonelli commented Jun 23, 2021

I'm right now facing the same issue trying to use a 500Hz esc on our multicopter. I mainly tried every possible workaround without finding a solution.
Do you guys know where the 400 Hz cap is enforced? Even removing the code pointed by feemi has no effect on the final rate. @julianoes any tips on hint?

@stale stale bot removed the stale label Jun 23, 2021
@FlavioTonelli
Copy link
Contributor

My bad. I confirm the Pam rate is capped in the code showed by feemi.
I got crazy for two days just for a make clean. PX4iofirmware is not recompiling without cleaning the build folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants