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 driver: pca9685_pwm_out improvement #14269

Conversation

SalimTerryLi
Copy link
Contributor

@SalimTerryLi SalimTerryLi commented Mar 1, 2020

Describe problem solved by this pull request
Fixed some bugs about that driver. Listed here:

  • Switched CDev name so that "/dev/pca9685" is pointed to I2C driver and "/dev/pwm_outputX" is pointed to the function wrapper
  • Parameters doesn't take effect when change back to default -1.

Added new features:

  • Now supports esc calibration executed from QGC(not being tested, for that my new ADC driver is not merged into upstream).But it works only if the driver is the only one that registered "/dev/pwm_outputX" due to commander logic.

Some critical changes:
-New parameters are defined. this will make PCA9685 able to run together with other PWM output devices.

Note this driver allows parameters to be changed run-time without reboot, which will lead to some performance issue. But it is not critical on embed Linux.

Test data / coverage
This driver still works properly on my RPi.

Additional context
This driver has a "wrapper" layer which is abstracted from the real driver. Those code can be easily picked up and quickly be deployed with other pwm drivers, such as Navio2, BBB and OCPOC. I mean, we are able to purge linux_pwm_out by setting up board specific pwm drivers in their board folder. This driver can be the template.

@SalimTerryLi SalimTerryLi force-pushed the pr-pca9685_pwm_out_driver-improvement branch 2 times, most recently from 6f7471b to 66f350d Compare March 1, 2020 10:08
@SalimTerryLi
Copy link
Contributor Author

Ready.

@SalimTerryLi
Copy link
Contributor Author

SalimTerryLi commented Mar 1, 2020

BTW, I have figured out how we can purge src/drivers/pca9685 safely. That implement can be fully replaced with this driver. I'd like to start another PR for that once this gets merged. @dagar

@SalimTerryLi SalimTerryLi force-pushed the pr-pca9685_pwm_out_driver-improvement branch from bebfa46 to 4292d34 Compare March 2, 2020 17:24
@dagar
Copy link
Member

dagar commented Mar 2, 2020

Generally looks good, but I'm hesitating on the parameter change. Doesn't it make the simple case (only output is pca9685) more complicated from a user perspective?

I was considering extending the mixer module lib for the PWM case.

In terms of the pca9685 as an additional output (or having multiple) aren't we just missing visibility into the mapping (MAIN, AUX, etc)?

@SalimTerryLi
Copy link
Contributor Author

SalimTerryLi commented Mar 2, 2020

Generally looks good, but I'm hesitating on the parameter change. Doesn't it make the simple case (only output is pca9685) more complicated from a user perspective?

I was considering extending the mixer module lib for the PWM case.

In terms of the pca9685 as an additional output (or having multiple) aren't we just missing visibility into the mapping (MAIN, AUX, etc)?

It will. But currently no board depends on it as the only output. Those parameters are already defined here. I just implemented them. Of course, users can simply ignore those parameters if they don't need them.

PWM channel mapping is done though mixer files, as it always be. Simply bind the mixer to this driver with mixer command should work.

How MAIN and AUX are defined? I don't think we should split them up, as they both are common PWM output interfaces.

@SalimTerryLi SalimTerryLi requested a review from dagar March 3, 2020 16:57
@mrpollo mrpollo requested review from MaEtUgR and davids5 March 4, 2020 17:40
@LorenzMeier
Copy link
Member

@SalimTerryLi Couldn't we just use the PWM_MAIN parameters for this? All the user documentation explains how to use them and the ground station software knows how to set them. That is a lot better for an end user than having a new set of parameters.

Why did you introduce new ones and what problem are you trying to solve?

Copy link
Member

@LorenzMeier LorenzMeier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because these new parameters make it very hard to set up the system through a GCS and they are not documented, I'm not convinced this is an improvement. I would retain the PWM_MAIN parameter mapping instead.

@SalimTerryLi
Copy link
Contributor Author

@SalimTerryLi Couldn't we just use the PWM_MAIN parameters for this? All the user documentation explains how to use them and the ground station software knows how to set them. That is a lot better for an end user than having a new set of parameters.

Why did you introduce new ones and what problem are you trying to solve?

This driver may have two use case:

  1. as the only output device for some new boards( actually I'm in this way
  2. as an extra pwm output device, to extends the boards which has limited pwm channels( most people is in this way.

It is OK to reuse old parameters if I try to use it on my own board. but definitely can not if someone want to extend PWM channels because of conflicts. There is already a person who want to use PCA9685 on Pixhawk Cube to extend max PWM channels to control a complex VTOL.

@SalimTerryLi
Copy link
Contributor Author

Because these new parameters make it very hard to set up the system through a GCS and they are not documented, I'm not convinced this is an improvement. I would retain the PWM_MAIN parameter mapping instead.

I'm willing to update those document, although there may be not too much people will use this driver.

@LorenzMeier
Copy link
Member

You can't update the GCS source code and it doesn't make sense for us to carry documentation that a low number of users are actually using.

Back to the question you haven't answered: Why can't you just use the existing PWM_MAIN parameters and read those? Why do you need your own?

@SalimTerryLi
Copy link
Contributor Author

You can't update the GCS source code and it doesn't make sense for us to carry documentation that a low number of users are actually using.

Back to the question you haven't answered: Why can't you just use the existing PWM_MAIN parameters and read those? Why do you need your own?

That will lead to conflicts if I want to use this driver on standard Pixhawk which has its own outputting driver.

@LorenzMeier
Copy link
Member

Are you using the driver on a Pixhawk? Because the better solution would be to go straight to UAVCAN (albeit not instant).

@SalimTerryLi
Copy link
Contributor Author

SalimTerryLi commented Mar 8, 2020

Are you using the driver on a Pixhawk? Because the better solution would be to go straight to UAVCAN (albeit not instant).

I propose these changes on behalf of at least two people.

For myself, it is ok to just read old parameters. as I use PCA9685 as the primary PWM out.
There is also someone on slack who want to use it with Pixhawk Cude to extend maximum available PWM channels. For him, new parameters are necessary.

Moreover, a badly designed pca9685 driver already exists in PX4, named src/drivers/pca9685. I want to make this new driver a better replacement of that driver. Also this driver has a developed wrapper which can be ported to other similar devices, such as linux_pwm_out. @ dagar expects to purge it, as this PR maybe a part of that action.

@SalimTerryLi SalimTerryLi force-pushed the pr-pca9685_pwm_out_driver-improvement branch 2 times, most recently from 86d0409 to b829b7c Compare March 19, 2020 09:44
@SalimTerryLi SalimTerryLi force-pushed the pr-pca9685_pwm_out_driver-improvement branch from b829b7c to 2f0d42d Compare March 23, 2020 05:12
@SalimTerryLi SalimTerryLi force-pushed the pr-pca9685_pwm_out_driver-improvement branch 2 times, most recently from 0f1383c to 753585d Compare April 11, 2020 19:54
@stale
Copy link

stale bot commented Jul 11, 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 Jul 11, 2020
@stale stale bot removed the stale label Aug 5, 2020
@SalimTerryLi SalimTerryLi force-pushed the pr-pca9685_pwm_out_driver-improvement branch from 98d0dee to 1a25c74 Compare August 5, 2020 09:49
@SalimTerryLi
Copy link
Contributor Author

Switch back to original parameter names. Please review it.

@davids5 davids5 requested a review from mhkabir August 5, 2020 11:23
@SalimTerryLi SalimTerryLi force-pushed the pr-pca9685_pwm_out_driver-improvement branch from 97abc97 to 70b624d Compare August 17, 2020 18:37
@SalimTerryLi SalimTerryLi force-pushed the pr-pca9685_pwm_out_driver-improvement branch from 70b624d to a0da314 Compare September 16, 2020 00:56
@SalimTerryLi SalimTerryLi deleted the pr-pca9685_pwm_out_driver-improvement branch April 24, 2023 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants