How to connect 4-wire PWM FAN to the Raspberry Pi PWM output?

Thread Starter

Marus780

Joined Jan 11, 2023
81
Hi ! I have a 4-wire PWM FAN and I want to control it with a Raspberry Pi 4B. The PWM pin on the FAN seems to be pulled-up to 12V with a 47k ohm resistor. Now, with this pin floating, it has almost 12V on it. And this pin must be connected to the RPi PWM output. How is it possible that this voltage does not destroy the RPi pins if they work at 3.3V ? Because I have already made the connection and it works perfectly. When I connect those two, on the PWM pin I read 0 or 3.3V, depending on which state the PWM is in, even if before it had almost 12V on it. Does the RPi has some zener protection on it's pins, or what happens ? Should I leave it connected directly ? Or should I make a zener protection like this ?

screenshot.2.png
 

BobTPH

Joined Jun 5, 2013
9,276
The 47K pullup plus the protection diodes on the input.

If you measure the voltage once connected it will be about 3.6V.
 

sghioto

Joined Dec 31, 2017
5,430
Because the output of the GPIO pin has a much lower resistance to the 3.3 volt supply then the 47K resistor to 12 volts.
Reducing the value of the 47K resistor will increase the voltage at the junction of R1 and R2 with D1 removed. Conclusion , R1 and D1 can be eliminated.
 
Last edited:

BobTPH

Joined Jun 5, 2013
9,276
The inputs of microcontrollers typically have a Schottky diode, reversed biased, to both ground and the Vdd. This sets the maximum voltage range of the input to Vss - 0.3V to Vdd + 0.3V.

All assuming the current is within the range the diode can handle, which us probably a few mA.

So the input pin is at the junction of 3.6V and a resistor to 12V. Voltage across the resistor is:

12 - 3.6 = 8.4V

Current is:

8.4 / 47K = 179 uA.

Which will be well within spec.

Change the resistor to 10 Ohms and you got a problem.
 

Thread Starter

Marus780

Joined Jan 11, 2023
81
I found here some documentation about the Raspberry GPIO pins: http://www.mosaic-industries.com/em...spberry-pi/gpio-pin-electrical-specifications

raspberry-pi-circuit-gpio-input-pins.png

They say:

The internal diodes shown in the figure are not really substrate diodes, but they are actually parasitic FETs. Electrically, their I-V characteristic looks like a diode's, but with a greater forward drop and a more gradual knee. They may protect against low current transient events caused by transient out-of-range voltages applied to the pins, but they are not intended to protect against the application of voltages greater than the supply voltage or less than ground, even with an external series resistor. In brief, you should never deliberately forward bias those "diodes". Consequently, you can not safely place an external pull-up resistor to 5V on the I/O pin. That would forward bias a parasitic FET and owing to its poor internal impedance to the chip's internal power rail it may overheat, or worse, it may bias up parts of the chip to voltages greater than they can handle. So, don't do it!

:rolleyes:
 

Thread Starter

Marus780

Joined Jan 11, 2023
81
With that schematic the pwm signal is distorted :

screenshot.5.png

Only if I do a push-pull configuration it works well. But I think I am complicating myself too much...
I think it would be better to use an external schottky diode...

screenshot.6.png
 

BobTPH

Joined Jun 5, 2013
9,276
No circuitry or diode required as explained in post #4 and 5. Connect directly to the fan pwm input.
From post #4:
Because the output of the GPIO pin has a much lower resistance to the 3.3 volt supply then the 47K resistor to 12 volts.
Huh? The connection is to an input, not an output. To clamp the 12V down to 3.6V, the the current needed us 179uA, which is likely way more than the input leakage.

The TS then quoted the datasheet saying the internal diode was not to be used to clamp the voltage. That is why I recommended the external diode, which is still the simplest solution that does not violate the recommendations of the datasheet.
 

BobTPH

Joined Jun 5, 2013
9,276
I'm speaking of the output of the Raspberry where the pwm is generated.
Of course, my mistake. But the output would have to be open drain to preserve the 12V logic signal in the PWM input. I now think an external transistor is needed.
 

Thread Starter

Marus780

Joined Jan 11, 2023
81
I already show you in the previous comment that adding one transistor it distort the pwm signal on one side.

I added an external clamp diode, SS14, from RPi pwm out to +3.3V, and then a 470R resistor to FAN pwm imput.
I hope it is ok. It is working fine...
 

sghioto

Joined Dec 31, 2017
5,430
But the output would have to be open drain to preserve the 12V logic signal in the PWM input.
I don't think so. I've seen several examples where the pwm from the micro is tied directly to the pwm input on a 4 wire fan. No diodes or transistors used as the TS has confirmed. The push pull output from the micro clamps the voltage at 3.3 volts.
It's a LOW input at the proper frequency that operates the fan motor.
 

sghioto

Joined Dec 31, 2017
5,430
As wired in post #8, it won't do any harm but useless.
From your post: "When I connect those two, on the PWM pin I read 0 or 3.3V, depending on which state the PWM"
That verifies the push pull output from the Raspberry is clamping the input to the fan control at 3.3 volts.
 
Last edited:
Top