3

I have a pi4 with the "official" fan case and I would like to write my own fan control code. I have looked online for a datasheet for the fan but haven't found it yet. I see on the case fan page that it is controlled by "Pulse width modulation control via user-selectable GPIO pin." Does anyone know the PWM frequency is? Bonus points if anyone knows the duty cycle to RPM mapping.

1

2 Answers 2

1

Ok I think I got the answer: 25kHz

I found this slide deck (download link) from ADDA (the manufacturer) that says the frequency is 25k. To verify this, I hooked up the official fan to a pi 3b+ I use for GPIO testing. I plugged the blue wire into GPIO 12 since the standard pin (GPIO 14) doesn't have the hardware PWM you need to exceed 7kHz. Then I used sysfs to enable PWM control and verified that I could fine-tune the fan speed by changing the duty cycle.

GPIO setup

A couple more notes:

  1. I still don't know the RPM profile of the fan. I am not really concerned about this but still curious in case anyone knows it.

  2. It's interesting that the fan instructions have you use GPIO 14, which is incapable of PWM control other than duty cycles of 0% (off) and 100% (on). This seems to indicate that the fan is not really intended to be used with fine-tuned control, only to be turned on and off by the OS. Simply plugging the blue wire into GPIO 18 two pins over would have enabled this, and I confirmed you can fit the lead there in the official fan and official case, but someone clearly chose not to put that in the instructions, so I think anyone wanting to fine-tune their fan control is clearly going to be on their own!

2
  • Unlikely to need 25kHz. Try the pigs p command on the GPIO.
    – joan
    Commented Dec 20, 2020 at 23:49
  • Do you know how PWM works? You need the correct frequency for it to function properly.
    – mattexx
    Commented Dec 21, 2020 at 1:10
0

You could use piscope or PWM monitor to monitor the PWM frequency being used.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.