Fan Speed Regulation PWM GPIO

Hi,

I want to regulate the fan speed of my Noctua fans through PWM & GPIO.

The fans are supplied by an external 12V power supply.

I have tried to control the speed through a GPIO-out node and a slider sending a 0 - 100 PWM signal.

What am I doing wrong? Are there any example flows available? I would highly appreciate any help!

You don't say, but I assume you are using a Raspberry Pi.
Be VERY CAREFUL with the GPIO pins on the Pi as they work at 3V3 logic levels.
DO NOT connect them to anything higher than +3.3V otherwise you will destroy the device.

The best way to control a fan is with an H-bridge module. The inputs would accept a PWM signal as well a direction signal (although that isn't needed for your fans). Here's one example out of many.
h-bridge-2

Here's a link to my slot-car racing project.
This used a PWM pin driving a power transistor.

Is it the pwm that is not working? If so, then show us how you have configured the GPIO node.

Hi Colin,

I have just connected at 0-100 slider sending a PWM signal to a GPIO-out node. I would like to control the fan from 0% to 100% RPM.

So which bit isn't working?

The is going at full speed all the time, its not responding to the slider so I do not know how to achieve the desired fan speed.

A circuit digram would be useful to see how you have connected things together.
You could also try controlling an LED (rather than your set of fans) to just make sure the Pi is working.

I dont really know which GPIO pins I need to connect the 2 PWMs on that are not the power supply

As the others have stated we will need a wiring diagram.

Do the fans have 3 or 4 wires going to them ?

Do you have any external hardware (i.e.an external PWM controller as noted below) or are you trying to do this all with the native RPi components ?

Craig

As others have said, we need a wiring diagram from you - just a rough sketch would help.

I've quickly looked up Noctua fans and it would seem they have some circuitry built inside them.
I found this whitepaper that describes Noctua's PWM specification. On the very last page is a suggested 'Driving' circuit using PMOS and NMOS transistors. This is needed to protect the microcontroller (your Raspberry Pi) and act as a level shifter. The paper seems to suggest you could use the output pin of a microcontroller. I've never allowed my IoT students to drive a fan in that way - as it too easy to mess things up and destroy an expensive RPi. Maybe other people on the forum will share their experiences.

Note:
My responses at the top of this thread related to using an H-bidge to control a simple DC fan.
It would appear the range of Noctua fans are far more sophisticated devices (than the humble DC fan).

Hi Dave,

It's a 4-pin fan and that is my current flow. Please take a look.

[{"id":"8000c717.f75478","type":"tab","label":"PWM","disabled":false,"info":""},{"id":"efcea890.a8b378","type":"ui_slider","z":"8000c717.f75478","name":"","label":"slider","tooltip":"","group":"b1d154fe.797058","order":10,"width":0,"height":0,"passthru":true,"outs":"all","topic":"topic","topicType":"str","min":"0","max":"100","step":"10","className":"","x":160,"y":460,"wires":[["e27f416c.25704","512269b4.61e768"]]},{"id":"e27f416c.25704","type":"rpi-gpio out","z":"8000c717.f75478","name":"","pin":"32","set":"","level":"0","freq":"100","out":"pwm","x":780,"y":320,"wires":},{"id":"512269b4.61e768","type":"ui_gauge","z":"8000c717.f75478","name":"","group":"b1d154fe.797058","order":11,"width":0,"height":0,"gtype":"gage","title":"gauge","label":"units","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":780,"y":200,"wires":},{"id":"dedaf0d8.7d8b8","type":"rpi-gpio in","z":"8000c717.f75478","name":"","pin":"36","intype":"up","debounce":"25","read":true,"x":400,"y":720,"wires":[["63f8225a.5ab11c","5d59222d.793e3c"]]},{"id":"63f8225a.5ab11c","type":"debug","z":"8000c717.f75478","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":660,"y":720,"wires":},{"id":"5d59222d.793e3c","type":"ui_chart","z":"8000c717.f75478","name":"","group":"b1d154fe.797058","order":11,"width":0,"height":0,"label":"chart","chartType":"line","legend":"true","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"60","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":630,"y":640,"wires":[]},{"id":"63e9723e.f1146c","type":"ui_switch","z":"8000c717.f75478","name":"","label":"switch","tooltip":"","group":"b1d154fe.797058","order":12,"width":0,"height":0,"passthru":false,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"100","onvalueType":"str","onicon":"","oncolor":"","offvalue":"0","offvalueType":"str","officon":"","offcolor":"","animate":false,"className":"","x":520,"y":460,"wires":[["e27f416c.25704"]]},{"id":"e6137c50.e671d","type":"comment","z":"8000c717.f75478","name":"Noctua min frequency 18 kHz","info":"","x":870,"y":400,"wires":},{"id":"ab4b26aa.d7cdb8","type":"comment","z":"8000c717.f75478","name":"GPIO 32 - PWM ","info":"","x":840,"y":500,"wires":},{"id":"db8ecb7b.d53f48","type":"comment","z":"8000c717.f75478","name":"GPIO 36 - SPEED","info":"","x":850,"y":540,"wires":},{"id":"55ab8732.4e95d8","type":"comment","z":"8000c717.f75478","name":"Frequency 100 Hz ?","info":"","x":830,"y":440,"wires":},{"id":"b1d154fe.797058","type":"ui_group","name":"PWM","tab":"74da6fee.87ce6","order":1,"disp":true,"width":"15","collapse":false,"className":""},{"id":"74da6fee.87ce6","type":"ui_tab","name":"PWM","icon":"dashboard","disabled":false,"hidden":false}]

Hi Craig,

It's a 4-pin fan and that is my current flow. Please take a look.

[{"id":"8000c717.f75478","type":"tab","label":"PWM","disabled":false,"info":""},{"id":"efcea890.a8b378","type":"ui_slider","z":"8000c717.f75478","name":"","label":"slider","tooltip":"","group":"b1d154fe.797058","order":10,"width":0,"height":0,"passthru":true,"outs":"all","topic":"topic","topicType":"str","min":"0","max":"100","step":"10","className":"","x":160,"y":460,"wires":[["e27f416c.25704","512269b4.61e768"]]},{"id":"e27f416c.25704","type":"rpi-gpio out","z":"8000c717.f75478","name":"","pin":"32","set":"","level":"0","freq":"100","out":"pwm","x":780,"y":320,"wires":},{"id":"512269b4.61e768","type":"ui_gauge","z":"8000c717.f75478","name":"","group":"b1d154fe.797058","order":11,"width":0,"height":0,"gtype":"gage","title":"gauge","label":"units","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":780,"y":200,"wires":},{"id":"dedaf0d8.7d8b8","type":"rpi-gpio in","z":"8000c717.f75478","name":"","pin":"36","intype":"up","debounce":"25","read":true,"x":400,"y":720,"wires":[["63f8225a.5ab11c","5d59222d.793e3c"]]},{"id":"63f8225a.5ab11c","type":"debug","z":"8000c717.f75478","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":660,"y":720,"wires":},{"id":"5d59222d.793e3c","type":"ui_chart","z":"8000c717.f75478","name":"","group":"b1d154fe.797058","order":11,"width":0,"height":0,"label":"chart","chartType":"line","legend":"true","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"60","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":630,"y":640,"wires":[]},{"id":"63e9723e.f1146c","type":"ui_switch","z":"8000c717.f75478","name":"","label":"switch","tooltip":"","group":"b1d154fe.797058","order":12,"width":0,"height":0,"passthru":false,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"100","onvalueType":"str","onicon":"","oncolor":"","offvalue":"0","offvalueType":"str","officon":"","offcolor":"","animate":false,"className":"","x":520,"y":460,"wires":[["e27f416c.25704"]]},{"id":"e6137c50.e671d","type":"comment","z":"8000c717.f75478","name":"Noctua min frequency 18 kHz","info":"","x":870,"y":400,"wires":},{"id":"ab4b26aa.d7cdb8","type":"comment","z":"8000c717.f75478","name":"GPIO 32 - PWM ","info":"","x":840,"y":500,"wires":},{"id":"db8ecb7b.d53f48","type":"comment","z":"8000c717.f75478","name":"GPIO 36 - SPEED","info":"","x":850,"y":540,"wires":},{"id":"55ab8732.4e95d8","type":"comment","z":"8000c717.f75478","name":"Frequency 100 Hz ?","info":"","x":830,"y":440,"wires":},{"id":"b1d154fe.797058","type":"ui_group","name":"PWM","tab":"74da6fee.87ce6","order":1,"disp":true,"width":"15","collapse":false,"className":""},{"id":"74da6fee.87ce6","type":"ui_tab","name":"PWM","icon":"dashboard","disabled":false,"hidden":false}]

Sorry I can't import your flow.
Have a look at this link that explains how to do it...

And as asked a number of times please post a wiring diagram so we can see how you are hooking this all up

Craig

[
    {
        "id": "8000c717.f75478",
        "type": "tab",
        "label": "PWM",
        "disabled": false,
        "info": ""
    },
    {
        "id": "efcea890.a8b378",
        "type": "ui_slider",
        "z": "8000c717.f75478",
        "name": "",
        "label": "slider",
        "tooltip": "",
        "group": "b1d154fe.797058",
        "order": 10,
        "width": 0,
        "height": 0,
        "passthru": true,
        "outs": "all",
        "topic": "topic",
        "topicType": "str",
        "min": "0",
        "max": "100",
        "step": "10",
        "className": "",
        "x": 160,
        "y": 460,
        "wires": [
            [
                "e27f416c.25704",
                "512269b4.61e768"
            ]
        ]
    },
    {
        "id": "e27f416c.25704",
        "type": "rpi-gpio out",
        "z": "8000c717.f75478",
        "name": "",
        "pin": "32",
        "set": "",
        "level": "0",
        "freq": "100",
        "out": "pwm",
        "x": 780,
        "y": 320,
        "wires": []
    },
    {
        "id": "512269b4.61e768",
        "type": "ui_gauge",
        "z": "8000c717.f75478",
        "name": "",
        "group": "b1d154fe.797058",
        "order": 11,
        "width": 0,
        "height": 0,
        "gtype": "gage",
        "title": "gauge",
        "label": "units",
        "format": "{{value}}",
        "min": 0,
        "max": "100",
        "colors": [
            "#00b500",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "",
        "seg2": "",
        "className": "",
        "x": 780,
        "y": 200,
        "wires": []
    },
    {
        "id": "dedaf0d8.7d8b8",
        "type": "rpi-gpio in",
        "z": "8000c717.f75478",
        "name": "",
        "pin": "36",
        "intype": "up",
        "debounce": "25",
        "read": true,
        "x": 400,
        "y": 720,
        "wires": [
            [
                "63f8225a.5ab11c",
                "5d59222d.793e3c"
            ]
        ]
    },
    {
        "id": "63f8225a.5ab11c",
        "type": "debug",
        "z": "8000c717.f75478",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 660,
        "y": 720,
        "wires": []
    },
    {
        "id": "5d59222d.793e3c",
        "type": "ui_chart",
        "z": "8000c717.f75478",
        "name": "",
        "group": "b1d154fe.797058",
        "order": 11,
        "width": 0,
        "height": 0,
        "label": "chart",
        "chartType": "line",
        "legend": "true",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "removeOlder": 1,
        "removeOlderPoints": "",
        "removeOlderUnit": "60",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 630,
        "y": 640,
        "wires": [
            []
        ]
    },
    {
        "id": "e6137c50.e671d",
        "type": "comment",
        "z": "8000c717.f75478",
        "name": "Noctua min frequency 18 kHz",
        "info": "",
        "x": 870,
        "y": 400,
        "wires": []
    },
    {
        "id": "ab4b26aa.d7cdb8",
        "type": "comment",
        "z": "8000c717.f75478",
        "name": "GPIO 32 - PWM ",
        "info": "",
        "x": 840,
        "y": 500,
        "wires": []
    },
    {
        "id": "db8ecb7b.d53f48",
        "type": "comment",
        "z": "8000c717.f75478",
        "name": "GPIO 36 - SPEED",
        "info": "",
        "x": 850,
        "y": 540,
        "wires": []
    },
    {
        "id": "55ab8732.4e95d8",
        "type": "comment",
        "z": "8000c717.f75478",
        "name": "Frequency 100 Hz ?",
        "info": "",
        "x": 830,
        "y": 440,
        "wires": []
    },
    {
        "id": "b1d154fe.797058",
        "type": "ui_group",
        "name": "PWM",
        "tab": "74da6fee.87ce6",
        "order": 1,
        "disp": true,
        "width": "15",
        "collapse": false,
        "className": ""
    },
    {
        "id": "74da6fee.87ce6",
        "type": "ui_tab",
        "name": "PWM",
        "icon": "dashboard",
        "disabled": false,
        "hidden": false
    }
]

OK - managed to import your flow.
pwm_flow
On the face of it, it looks as if the flow should work, however, I don't use the GPIO pins on my RPi so I can't test it. Like Craig said, a hook-up diagram would be useful.

Some things you could try...

  1. I assume you have a GND connection between the RPi and the 4-pin plug.
  2. I assume you have installed the Python library that is mentioned in the Help panel.
  3. You could try using an LED and a series resistor (any value between 220 ohms to 1k should work) instead of the fan and see if you can control its illumination. That way you can rule out issues with the fan.

I'll see if I can find an old RPi later today and try your flow.

I've just found an old RPi-Zero-H and connected an LED to pin 40 (GPIO-21) and GND to pin 39.
Your PWM flow works fine with the LED, so you need to check some of the other things I suggested.


my_pwm

Hi Dave,

Thanks for your help. Since I have an external 12V power supply for the fans there's no GND connection between the RPI and the 4-pin plug. Is this neccessary? And if so do you have any solution?

YES it is necessary to tie the grounds together (otherwsie everything floats and nothing works!!).
How are you connecting the output pin of the RPi to the 4-pin plug?

If you had shown us your connection diagram, as requested, we could have got to this point much faster.