Read fan frequency from FAN_TACH signal

Hi
I would like to read fan frequency from FAN_TACH signal.

So far, I am able to set fan pwm under /sys/devices/pwm-fan/, but I am not able to read fan frequency from FAN_TACH signal.

I have tried reading /sys/devices/pwm-fan/rpm_measured, and it’s always zero. Could you let me know how I can read the fan frequency? Thank you.

That seems to be where jtop reads it, too, though I don’t know where does it output it. Does another fan give output on the tach pin or may you scope the tach pin?

Okay, exploring a bit further myself, I think you have to set the value in tach_enable from 0 to 1. I’m getting values in rpm_measured when I do that. There probably is a L4T reference manual somewhere that details this, so I’ll take a gander.

Thank you. I have tried setting tach_eanble to 1, but rpm_measured is still always 0

hello judy.wang,

please check this through hardware monitor, you may read rpm from tachometer as below.
for example,

# First check which hwmon* is for tach
$ cat /sys/class/hwmon/hwmon*/name

# please use pwm_tach nodes to read rpm
$ cat /sys/class/hwmon/hwmon1/rpm

Hi Jerry,

Thank you. I only find hwmon0 which is for thermal-fan-est on my side. I don’t have hwmon1, Could you let me know how to add that? I have reviewed my dts file regarding the fan, and I think they look fine. Below is the snippet.
pwm-fan {
vdd-fan-supply = <0xa4>;
compatible = “pwm-fan”;
status = “okay”;
pwms = <0xa5 0x3 0xb116>;
shared_data = <0xa6>;
active_pwm = <0x0 0x50 0x78 0xa0 0xff 0xff 0xff 0xff 0xff 0xff>;
};

pfsd {
	num_resources = <0x0>;
	secret = <0x2f>;
	active_steps = <0xa>;
	active_rpm = <0x0 0x3e8 0x7d0 0xbb8 0xfa0 0x1388 0x1770 0x1b58 0x2710 0x2af8>;
	active_rru = <0x28 0x2 0x1 0x1 0x1 0x1 0x1 0x1 0x1 0x1>;
	active_rrd = <0x28 0x2 0x1 0x1 0x1 0x1 0x1 0x1 0x1 0x1>;
	state_cap_lookup = <0x2 0x2 0x2 0x2 0x3 0x3 0x3 0x4 0x4 0x4>;
	pwm_period = <0xb116>;
	pwm_id = <0x3>;
	step_time = <0x64>;
	state_cap = <0x7>;
	active_pwm_max = <0xff>;
	tach_gpio = <0x56 0xca 0x1>;
	pwm_gpio = <0x56 0x27 0x1>;
	pwm_polarity = <0x0>;
	suspend_state = <0x0>;
	tach_period = <0x3e8>;
	linux,phandle = <0xa6>;
	phandle = <0xa6>;
};

Could you let me know if there is anything missing here? Thank you

hello judy.wang,

may I know which JetPack release you’re working with?
I’m able to see tegra_pwmfan on l4t-r32.4.4/ Jetson-Nano.
for example,

$ cat /etc/nv_tegra_release
# R32 (release), REVISION: 4.4, GCID: 23942405, BOARD: t210ref, EABI: aarch64, DATE: Fri Oct 16 19:44:43 UTC 2020
$ cat /sys/class/hwmon/hwmon*/name
thermal-fan-est
tegra_pwmfan

HI Jerry,

I am currently using l4t-r32.3.1 (Jetpack 4.3). Is this a new feature released recently?

Thanks,
Judy

I’m not who you asked, but I’m also using L4T R32.4.4 (Jetpack 4.4.1), and I cannot test older versions, since I’m running a Jetson Nano 2GB (Jetpack 4.4.1 is the first supported version for me).

I suppose we could sift our way though the publicly provided L4T sources for 4.3 and 4.4 to figure it out.

hello judy.wang,

please moving to the latest JetPack release if possible.

you may also refer to automatic fan control solution, https://github.com/Pyrestone/jetson-fan-ctl .
please also check Topic 144363 for more details of Nano’s fan control device tree settings.
thanks

Hi Jerry,

I found out this is a new change on pwm_fan.c file after Jetpack 4.4, so after I upgraded the Jetpack version, I am able to see hwmon1. However, I set tach_enable to 1, but rpm_measured is till 0. I can read cur_pwm successfully. I have used jetson-fan-ctl solution, but it doesn’t read rpm_measured either.

So my suggestion still remains; can your scope or probe see any activity on the tach line?
Should be two pulses per revolution (so 800 RPM speed should give 1600 pulses per second).

That being said, my scope is reading ~78.5Hz for a rpm_measured of 2355. I’ll have to look into this further. I wish I had my probes with me, and not just a bunch of jumper leads.

hello judy.wang,

this is a known issue that rpm_measured is return zero even it’s running at full speed.
for example,

# cat /sys/class/hwmon/hwmon1/cur_pwm
255
# cat /sys/class/hwmon/hwmon1/rpm_measured
0

that’s due to fan driver is looking-up pwm_rpm_table to configure PWM signals to determine the fan speed; please check cur_pwm for its RPM values.
for example, the RPM is 11000 while PWM is 255.

$ cat /sys/class/hwmon/hwmon1/pwm_rpm_table 
(Index, RPM, PWM, RRU, RRD)
(0, 0, 0, 40, 40)
(1, 1000, 80, 2, 2)
(2, 2000, 120, 1, 1)
(3, 3000, 160, 1, 1)
(4, 4000, 255, 1, 1)
(5, 5000, 255, 1, 1)
(6, 6000, 255, 1, 1)
(7, 7000, 255, 1, 1)
(8, 10000, 255, 1, 1)
(9, 11000, 255, 1, 1)

HI Jerry,

Thank you for your explanation. Is there a way to measure the current rpm from the tachometer itself? not just from the pwm_rpm_table?
We would like to monitor the actual rpm for our system.
Also, is there any plan to fix the known issue that rpm_measured returns zero? Thank you.

hello judy.wang,

you should use fan with 5V regulator,
please also make sure you had proper pin connections.
for example,

Pin-1 -> GND
Pin-2 -> 5V
Pin-3 -> Tach
Pin-4 -> PWM

the RPM measurement should works with proper fan device and also with proper pin connections,
it can be read by enabling tach from SW commands,
for example,

# echo 1 > /sys/class/hwmon/hwmon1/tach_enable
# cat /sys/class/hwmon/hwmon1/rpm_measured