-
Notifications
You must be signed in to change notification settings - Fork 204
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 frequency for Noctua fans #349
Comments
Interesting. I have just connected Noctua fan (via 74AHCT125 - QUAD LEVEL-SHIFTER) to GPIO19 (it is supposed to be one of the hardware PWM pins), and it seems to work well. I haven't attached the scope, but there's clear difference between say 20% and 100% duty cycle. I can turn off the fan with 0% duty cycle, so everything seems to be working fine. What does it do in your case? |
In my case when set to anything greater than 0% the fan does not maintain a constant speed but by the sound seems to run close to 100%, it "revs" - runs high than slows down. I didn't use a 74AHCT125 since the Noctua PWM specifications white paper indicates that one isn't needed. I did not connect a scope probe to the fan's tach output. I stuck with the default pwm hardware pins to hopefully maximize my success..... |
I'm convinced that the quad level shifter is not necessary. I did some more readings this morning. These tests were performed using HardwarePWM with a Noctua NF-A14 iPPC-3000 PWM in circuit: |
So, today I'm basically using https://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/, no changes what so ever.... not a custom driver or anything... Could you please write a small script and test if that can make your pi
It might be a limitation on that library.... I'm adding support on PWM from I2C chips on python 3... so need to find a chip that has 25kHz.... |
Guys, you are forcing me to buy a scope and check what's going on with my fan that it works :-) Anyway, people recommend to use https://github.com/joan2937/pigpio, that should be capable of the desired frequency. Some information here: |
I saw that library, never used, will install and run some tests, I'm interested to see if requires sudo or any special permission because that is also a major issue with the enclosure and setup for most users... if @wmonzel could test hist pi, default library, and measure the frequency would be nice.... I'll work more on the plugin tonight... |
@haplm : hardwarePWM does use PiGPIO, so I think you're on to something. I didn't realize that octoprint-enclosure did not. Thank you both for your help. |
@vitormhenrique I haven't taught myself python yet, so I'm probably doing something wrong. My test script pwmtest.py: Results: What basic steps have I missed? I looked into raspberry-gpio-python and there is a ticket: https://sourceforge.net/p/raspberry-gpio-python/tickets/173/ that indicates that gpio-python implements software pwm only. Software pwm doesn't seem like a good idea at higher frequencies. |
@vitormhenrique OK, I figured out that some initialization was in order: Import RPi.GPIO, GPIO.setmode, GPIO.setup. I can provide the updated test script if you like.
This generally agrees with my earlier observations with Enclosure. |
@wmonzel my bad, my script was more a pseudo code than a copy paste and run, but glad to know that you figured it out how to get it running... as I thought the issue is more on the library than actually on the enclosure plugin... We need to test with User guide here: http://abyz.me.uk/rpi/pigpio/python.html#set_PWM_frequency and the circuit python Adafruit library that I planed to use for python 3 port: |
@vitormhenrique no worries regarding pseudo code. I could use to learn python. Since hardwarePWM uses pigpio, the tests I've run with hardwarePWM should be good enough to validate pigpio's effectiveness. The output waveform with hardwarePWM is very stable and accurate. I have not compared CPU load but it's a safe bet that using hardware pwm beats software pwm in this area - another advantage for using the hardware pwm gpio pins. I strongly suspect that the waveform stability of a software implemented pwm will further suffer as the CPU load increases, especially at higher frequencies. I use hardwarePWM as a work around to control my enclosure fan. But I've yet to figure out a way to use hardwarePWM to control fan speed based on some other variable, like temperature. That's where your plug in shines. Right now I periodically monitor the enclosure temperature and adjust the fan speed accordingly. I'm not sure what you gain by using the circuit python Adafruit library (hardwarePWM doesn't seem to use it), but I do know that hardware based pwm is only available on GPIO12, 13, 18, and 19. |
It is weird. The enclosure plugin suddenly lost the ability to control the fan, and I had to install pigpio + hardwarePWM. That works just fine... |
Hi @vitormhenrique, I've modified handle_pwm_linked_temperature to use PiGPIO instead of raspberry-gpio-python and have run a few prints with good results. The change within handle_pwm_linked_temperature is to call a new function write_hwpwm instead of write_pwm. Within init.py I also added the necessary "import pigpio" and two small functions (modules? Sorry, I'm still learning Python so I may not be using the right terms) write_hwpwm and startHWPWM. All other sections of your code are unchanged and continue to use RPi.GPIO. I didn't even have to disable the hardwarePWM plugin, I just left the duty cycle at 0. I plan to do some more testing but wanted your input since you mentioned that you are working on a major rewrite. Is this something your are interested in? At the moment I've made the changes outside of Git, so I would either need to attach the file here or go through the normal Git process. |
@wmonzel could you please share your changes? |
Hello @darkcheater, sorry for the delayed response. I just noticed it last night. Notes:
|
@wmonzel I would like to see all the hardware pwm pin available to use PIGPIO Library with the Enclosure plugin in future updates. |
Hello @ahmaddxb I'll have a look at possibly expanding what I've done within my own branch (wmonzel/OctoPrint-Enclosure) and will let you know if I have something worth testing. |
Describe the bug
Noctua PWM fans typically require a target frequency of 25kHz. Regardless of the PWM frequency specified, the maximum frequency is 5.367 kHz as measured with an oscilloscope. Testing done using a Raspberry Pi 4 (4GB), PWM0 (GPIO12) and PWM1 (GPIO13)
octoprint (3).log
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A stable 25kHz square wave with a 50% duty cycle should be observable on the scope.
Additional context
See attached log. Note: hardwarePWM does provide expected results.
The text was updated successfully, but these errors were encountered: