Controlling PWM Fan/Read Sensor from PIC16F18877

Thread Starter

dmarciano84

Joined Oct 1, 2023
36
I am working on a controller based around the PIC16F18877 which will need to control a 4-wire 12V DC Fan, as well as read the signal from the sensor wire. The PWM signal needs to be somewhere between 18KHz and (I think) 30KHz, so I am planning on using a 20KHz. Since the MCU runs on 5V and the fan needs a 12V signal, I will obviously need some kind of level switching. Also, the signal will need to travel about 6-10 feet from the control unit to the fan.

I was doing some research online and found some conflicting information. Some sources said I should be able to run the fan directly from a MOSET, something like this:
1699469633198.png

However, other sources said about using a circuit similar to this:
1699469686692.png

Can only suggest which one would be better and meet all my needs, specifically:

1) 20KHz signal
2) PWM_Out wire will be approximately 6-10 feet long
3) PWM signal being generated from a PIC16F18877

Also, along the same lines, since I need to read the speed back, and convert the 12V signal from the fan back to 5V as an input to the MCU, whichever circuit I use to send the PWM signal to the fan, I am assuming I can just flip it around and use it in reverse, correct?

Any suggestions/guidance would be appreciated. TIA.
 

Thread Starter

dmarciano84

Joined Oct 1, 2023
36
NOTE: I forgot to add the pull-down resistor on the PWM_Out line for when the MOSEFT is off in the first schematic.
 

cmartinez

Joined Jan 17, 2007
8,178
I am working on a controller based around the PIC16F18877 which will need to control a 4-wire 12V DC Fan, as well as read the signal from the sensor wire. The PWM signal needs to be somewhere between 18KHz and (I think) 30KHz, so I am planning on using a 20KHz. Since the MCU runs on 5V and the fan needs a 12V signal, I will obviously need some kind of level switching. Also, the signal will need to travel about 6-10 feet from the control unit to the fan.

I was doing some research online and found some conflicting information. Some sources said I should be able to run the fan directly from a MOSET, something like this:
View attachment 307052

However, other sources said about using a circuit similar to this:
View attachment 307053

Can only suggest which one would be better and meet all my needs, specifically:

1) 20KHz signal
2) PWM_Out wire will be approximately 6-10 feet long
3) PWM signal being generated from a PIC16F18877

Also, along the same lines, since I need to read the speed back, and convert the 12V signal from the fan back to 5V as an input to the MCU, whichever circuit I use to send the PWM signal to the fan, I am assuming I can just flip it around and use it in reverse, correct?

Any suggestions/guidance would be appreciated. TIA.
You can run the fan directly from an nFet if you use a logic-level transistor for that. I've successfully used this transistor in the past for a similar application. Just make sure you install an inverse parallel diode snubber with the fan. You need to change the circuit so that the transistor is placed on the low side of the load, though.
 

Jon Chandler

Joined Jun 12, 2008
986
This reference has a good explanation of driving a 4 wire fan – this type of fan has internal switching, and only needs a low-current PWM signal to control the speed. I think this key point has been overlooked in the replies here.

"The 4-wire fans have a PWM input, which is used to control the speed of the fan. Instead of switching the power to the entire fan on and off, only the power to the drive coils is switched. The PWM signal drives the fan directly; the drive FET is integrated inside the fan. Since the PWM drive signal is applied directly to the coils of the fan, the fan’s electronics are always powered on, and the tach signal is always available. This eliminates the need for pulse stretching which’s ineluctable in 3-wire fan PWMs (Excerpts from Analog Dialogue 38-02, February 2004)."

Check out the link.
 

PointTwoPA

Joined Jan 28, 2021
4
Can you identify the specific fan you are using?
I used a fan similar to the reference provided by Jon Chandler with 4 inputs +, -, Tach, PWM
It was a "JARO" fan for an HVAC product similar to the following

https://jarothermal.com/wp-content/uploads/2022/05/JHD1203812HBBA015500_20220412.pdf
Note the schematic on page 11 of this PDF. The fan has 4 inputs +,-, Tach, PWM.
If you hooked it up to +12Vdc & gnd and then pulled PWM High, you get 100% speed.
The Tach signal is a check on speed and a fault check.
The HVAC product used an International Rectifier IR3316 high side switch just to turn on the 12V to the fan so that it was not always energized. The PWM signal came from a 5V micro sharpened through a schmitt trigger inverter.
We typically had 3-5 foot lengths on the fan cable.
 

tumbleweed

Joined Jun 27, 2023
15
Since the MCU runs on 5V and the fan needs a 12V signal, I will obviously need some kind of level switching.
In a lot of cases with a 4-wire fan, the fan PWM input can be driven from a logic-level signal output, and the TACH signal from the fan is an open-collector/open-drain so all you need there is a pullup to your logic VDD.

All depends on the fan...
 

Thread Starter

dmarciano84

Joined Oct 1, 2023
36
Thank you everyone for the feedback. I decided to go with a Noctua fan. I know they are considered pretty good CPU fans and turns out that they actually have a technical document specifically about using the PWM/Tach features outside of normal CPU usage. Part of my issue was that a lot of the fans I was checking out on Digikey were from overseas and either had no documentation, poor documentation, or half of it wasn't in English. The fan should be delivered tomorrow so I can start experimenting with it and see how it goes. Thanks again.
 
Top