Temperature controlled PWM Fan


I am looking for a way to control a PWM fan depending on a measured temperature.

Fan is a Noctua NF A12 PWM which is connected via a PCA9685 with the Raspberry. Temperaturesensor is a DS18S20.
So I know that there are PID nodes but unfortunately I do not really understand this.

The fan cools a housing and should keep the target temperature in it. I know roughly how I could do this with an if / then circuit but the fan will probably not survive long. The fan must find the right rpm to hold the temperature.

Can somebody help me with that?


Fan RPM-Signal readout

Probably would help to describe how sensitive/critical the temperature control needs to be. There have been quite a lot of discussion of this kind of thing in the old Google Group so you might want to look there too for the PID stuff if that is really what you need.

If it isn't so critical, you could simply mess with the settings until it is about right.



its a Housing for a 3D-Printer so its not so critical.
But this PID blocks only give on or of and not for example 30% pwm to hold it or i am wrong with that?



Sorry, I've never really got my head around PID (to me it means "Personally Identifiable Data" which doesn't help my understanding!).

I think that I would just set up a simple feedback loop such that increasing temperature increases fan speed and then tweak parameters till you get something sensible.

Parameters something like:

  • min temp - below this, I don't care
  • max temp - above this, I may need to shut down
  • min/max pwm - 0-1024?


No, that is wrong. node-red-contrib-pid gives a linear output between 0 and 1 to indicate the 'power' required (which in your case is speed). You have probably been confused by the use of the node in conjuction with node-red-contrib-timeprop which converts the linear output to a time proportioned (ie pulse width modulated signal) for controlling a heater, compressor or whatever that does not have a linear control.
If it is of interest then do a bit of googling to get the basic idea of what pid is all about then have a look at this blog [1]. It has a flow with process simulator and you can play with the pid setup and see what effect it has on the control.

[1] http://blog.clanlaw.org.uk/2018/01/09/PID-tuning-with-node-red-contrib-pid.html



Ok, thanks i think i got it.



If accurate temperature control is not required and just switching the fan on when it goes above a setpoint and off when below (with some hysteresis to stop it switching too rapidly) then node-red-contrib-ramp-thermostat may well do what you want. You can just ignore the ramp part of it if you don't need it.



Look at this link maybe it could help.



It is not clear to me which contrib node that uses for the pid control. It is not node-red-contrib-pid. I can't see it noted anywhere.



it uses node-red-node-pidcontrol as per install instructions



I still can't see it, but it doesn't really matter.



If you only need a temperature-control including hysteresis but without the node-red-contrib-ramp-thermostat 's profile feature , have a look at the use case Hysteresis in the Wiki:



Thanks, i made eit with the PID Controller.
Just have a fine-tuning to do now.



Hey Gummix,

first of all: Hi to everybody! I'm all new to this forum. And I need you already :wink:

I try something quite similiar to that. I have a lowboard with all my receiver stuff and a NAS inside, which I can't power on while it's closed. So I installed fans (Arctic F14 PWM), a raspberry is working in there anyway.

My question to you. Have you realized a readout of the fan speed? With my solution, no readout seems to make any sense (e.g. the count of Impulses decreases while the RPM is increasing). That drives me crazy right now. That, and the PWM-Pinout which produces an annoying noise within the fan depending on the frequency.
Do you have a basic hint on how you did that? Did that even occur to you at all?




i dont need to read out the Speed, but i know that this is tricky^^



Yeah... well... There's no real need for that, that's true. But then there is this abandoned pin with an unused signal :wink:
Maybe it's a topic for another thread then!