-
Notifications
You must be signed in to change notification settings - Fork 205
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
Hardware pwm #442
Open
wmonzel
wants to merge
2
commits into
vitormhenrique:master
Choose a base branch
from
wmonzel:HardwarePWM
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Hardware pwm #442
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
this import forces all users of this plugin to install/import pigpio, even though the majority of the users won't use it.
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.
Right. This also assumes that that the only case for using hardware pwm is a fan linked to a temperature sensor. A better way to do this is change the UI (ninja2?) to have the user choose either hardware pwm or software pwm as an output type and not just pwm. I'm willing to figure out how to do that if there is enough interest,
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 agree with @wmonzel on this one, lack of hardware PWM support is a problem for me unfortunately, and means I have to resort to a separate plugin just to run the fans, meaning I lose the benefits of controlling the fan based on temperature, which is critical for maintaining a controlled temperature for printing within the enclosure.
Personally I think adding
pigpio
as an optional dependency would be nice, so those that need hardware PWM can install it, while those who don't need it, don't have to install additional software on the host. If it's possible to add support for this without makingpigpio
a required dependency, that would be absolutely amazing.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 am having the same issues with a Noctua fan and also agree with @wmonzel that having a hardware PWM option would be helpful as I cannot get the current PWM option to work reliability at the moment.
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've tested with pigpio and it's quite heavyweight using a chunk of resources scanning all the GPIO pins many times per second. I'm going to try and see if a lighter weight alternative is suitable: https://github.com/Pioreactor/rpi_hardware_pwm and allow this to be configured via the UI so that only users that want to use a hardware PWM will need to install this extra module. Not sure it will work, but it might address the concerns raised in the comment on this PR.
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.
@wmonzel It sounds like your system is configured to have Python 2.7 as the default version of pip. This library needs Python 3. Assuming you have Python3 installed, check you have the Python3 version installed:
sudo apt-get install python3-pip
and/or see if you have pip but need to update it:python3 -m pip install --upgrade pip
By installing a python package with
sudo
it makes it available to everything, if you have OctoPrint running inside a venv then you can activate that and just install the package withoutsudo
.The rpi-hardware-pwm package is on pypi.org: https://pypi.org/project/rpi-hardware-pwm/
Not sure, but you may also find it useful to be able to change the default version of Python you have using
update-alternatives
see: https://raspberry-valley.azurewebsites.net/Python-Default-Version/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.
@shortbloke Thanks for your help. Changing the default version of Python did allow me to install rpi-hardware-pwm. But setting update-alternatives to auto mode (with python3.7 as the default) renders the MCP9808 temperature sensor unreadable. It appears to be dependent on python2.x since manually setting to python2.x fixes the temperature sensor but breaks rpi-hardware-pwm.
I'm learning as I go...
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.
Looking at MCP9808.py it just uses smbus. Would be interested in what errors you get. But maybe track that in a new issue specific to python3 and that sensor.
FYI Octoprint will require Python3 as of version 1.8 - https://octoprint.org/blog/2022/01/31/octoprint-1.8.0-will-require-python-3/
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.
@shortbloke There already is an open issue for this: #302 It appears that multiple sensors are affected. After doing some digging, I've come to the conclusion that using pigpio is a better choice for the following reasons:
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.
Sorry for the delay in responding @wmonzel I agree pigpio has its advantages. There is a disadvantage in that is requires a little bit more setup and modification to the installed service. I was aiming to keep it simple and not place any requirements on those that didn't want to use any hardware pwm.
I could look to extend my PR further and offer support for multiple hardware pwm libraries, though that would create some added complexity in the UI.
Given the lack of progress of either of our PRs, it seems demand for this support is rather low ;-)