z4gunn / OctoPrint-GpioFanController

8 stars 2 forks source link

Direct 5V fan pinout #5

Open andremalenfant opened 3 years ago

andremalenfant commented 3 years ago

Hi, not an issue, but I couldn't find a way to post comments.

Note that you can use a 5V PWM fan like a noctua straight without additional electronics. Plug the 5V an ground to the pi, and the PWM wire to GPIO 18. Then set 25,000 khz for the frequency (for noctuas at least). Your plugin will work no issue!

sethmay commented 2 years ago

You need to enable PWM by adding the following line to /boot/config.txt: dtoverlay=pwm

You can verify that PWM is enabled after rebooting by checking that the sysfs folder exists: /sys/class/pwm/pwmchip0

This enables PWM on GPIO 18 (pin 12). After that, everything worked like a charm.

justbennett commented 2 years ago

I'm trying this with a 12v fan (4-pin). It has it's own power supply, but I'm trying to drive the PWM with Octoprint. I've enabled PWM and confirmed as @sethmay suggested. It's attached on pin12/GPIO18. I've tried both pin 12 and 18 in the plugin settings, but I can't control the fan yet. I entered 25000000, for the frequency, but that didn't work. I also tried 25000 and 25 in case the frequency is in different units.

I was able to control this same fan from an Arduino with this setup, so it should theoretically work.

Is the frequency input in Hz? And does the pin naming follow the chip structure or the board structure?

andremalenfant commented 2 years ago

The frequency is in hertz, so it should be 25000 for 25kz.

The pin config field refers to the GPIO pin. Your issue might be voltage. The GPIO outputs 3.3 volts, not all fans will be happy with that for the PWM signal. You might need a transistor to switch a 5V source (can be from the Pi) to satisfy the fan specs. My noctua works on 3.3v, but maybe yours doesn’t and your arduino is 5V. Just a thought…

andremalenfant commented 2 years ago

You need to enable PWM by adding the following line to /boot/config.txt: dtoverlay=pwm

You can verify that PWM is enabled after rebooting by checking that the sysfs folder exists: /sys/class/pwm/pwmchip0

This enables PWM on GPIO 18 (pin 12). After that, everything worked like a charm.

Thanks for that, I am using a Fluidd disto that had this enabled by default, so I overlooked this step.

justbennett commented 2 years ago

Your issue might be voltage. The GPIO outputs 3.3 volts, not all fans will be happy with that for the PWM signal. You might need a transistor to switch a 5V source (can be from the Pi) to satisfy the fan specs. My noctua works on 3.3v, but maybe yours doesn’t and your arduino is 5V. Just a thought…

I bet you're right. I should have thought of that. I'll try a level shifter or transistor as you suggested.

milmber commented 2 years ago

Works great with a Noctua 5V PWM fan. Followed the guide here to set it up - https://blog.driftking.tw/en/2019/11/Using-Raspberry-Pi-to-Control-a-PWM-Fan-and-Monitor-its-Speed/

Default Pin (following the guide pin assignment): 18 Frequency: 25000

Only thing missing is the display of the actual fan speed as opposed to the percentage value which would be a nice addition.