neggles / cm4io-fan

CM4 IO board PWM fan controller driver
GNU General Public License v2.0
79 stars 17 forks source link

wrong speed? #8

Open GitHobi opened 2 years ago

GitHobi commented 2 years ago

Hi, may be you can help: I've installed your cm4io-fan - basically it works, but somehow the fan speed seems to be wrong.

In my /boot/config.txt I have the following line: dtoverlay=cm4io-fan,minrpm=500,maxrpm=2000 There are no other configuration settings. With these settings I had expected the fan to be at about 500 rpm if the CPU is < 50° The CPU is at 37° ... but the fan is at about 900rpm ( cat /sys/class/hwmon/hwmon2/fan1_input ---> 897). And this seems to be the lower limit, too. If I program the fan manually I can reach the 500 rpm ...

Am I doing something wrong?

Further question: Is it possible to have the fan stopped?

geerlingguy commented 2 years ago

On my Pi, I'm always seeing:

$ cat /sys/class/hwmon/hwmon2/fan1_input
480

Using a Noctua NF-A6x25 60mm fan. I wonder, would this script need any different tuning for different types of fans?

dmesg log:

[   22.677501] emc2301 10-002f: Have 1 fans configured in DT

/boot/config.txt contents:

[all]
# Control fan speeds.
dtoverlay=cm4io-fan,minrpm=1000,maxrpm=3000

(Note: I also tried minrpm 100 and maxrpm 500 just to see what would happen—still stuck at:

$ cat /sys/class/hwmon/hwmon2/fan1_input
480
twoseascharlie commented 2 years ago

@geerlingguy The min speed for the chip is 480, which is probably why you are always seeing that (see page 4 of the chip sheet). Also, it looks like the min speed/rpm for your fan is 550 with a pwm signal (although it does support off via 0% pwm duty cycle):

@GitHobi

Further question: Is it possible to have the fan stopped?

Unfortunately no, the emc chip does not allow for the fan to be off, only set to the minimum speed (I also wish it could be shut completely off). It seems like it should be possible from the driver level, but it would have to be enhanced to switch the fan registers to direct setting mode and then set the fan setting 1 register (0x30) to 0, which should set the fan off.

geerlingguy commented 2 years ago

@twoseascharlie - Indeed, I can manually set the fan to spin down with i2cset -y 10 0x2f 0x30 0x00. I wrote up my notes (after months of sitting on most of them just waiting for time to finally test this driver ;) and posted this today: Controlling PWM fans with the Raspberry Pi CM4 IO Board's EMC2301.

geerlingguy commented 2 years ago

@twoseascharlie - After working with the folks from Alftel, it also looks like they found the hardware implementation of their EMC2301 chip had a flaw—tachometer readings were not coming back accurately, which seems to have led to the error condition.

I put a 10K resistor between 3.3v and the tach line, and now it's reading the proper speeds, and the driver seems to be working correctly. I tested down to 500 rpm and tested a few different temp curves, and it all seems good now!

(Note: They mentioned there might also be a flaw present on the official IO Board, too, so I'm following up to see if they can give more input there.)

twoseascharlie commented 2 years ago

@geerlingguy Wow, well that sounds super impressive! I know I've been surprised by the lack of an officially supported driver for this chip. So far this one has worked pretty good for me, but I haven't had a need/desire to monitor the speed, aside from hearing it slow down and speed up as I would expect. I would be very interested to hear if there's a hardware bug in the official IO board.

neggles commented 2 years ago

The hardware bug in question is probably a lack of sufficient pull-up strength on the TACH line - it's pulled up to 3.3V via a 36K resistor. Intel's spec for 4-pin fans (the de facto industry standard) calls for a pull-up to 12V, and on most PC motherboards you'll find a pull-up to 3.3V/5V via the usual 10K resistor. I've not had any trouble with the various fans I've tried, but evidently Noctua's implementation needs a stronger pull-up than most - hence @geerlingguy's resistor mod fixing the problem 😄

For reference, the pull-up resistor on the CM4IO board is R21 - changing it out for a 10K (or just soldering a 15K-or-so on top) should do the job for a more permanent fix.

There's some discussion of the chip's limitations w.r.t. minimum and maximum RPM in #3 that's relevant here as well. The chip does throw an alert if the rpm input is below the minimum reading, but implementing that is somewhat beyond my current abilities. I could probably modify things so the fan turns off when target RPM is set to 0, though.