Author Topic: DIY 2ch PWM Fan Controller (PIC)  (Read 3160 times)

0 Members and 1 Guest are viewing this topic.

Offline ElMech_ProtoTopic starter

  • Newbie
  • Posts: 7
  • Country: hu
DIY 2ch PWM Fan Controller (PIC)
« on: July 24, 2025, 08:11:56 am »
DIY 2ch PWM Fan Controller (PIC)

The device is capable of controlling two independent PWM FAN output channels either in manual or auto mode. The sensors are TCN75A type, or anything else with similar I2C data format and initializing scheme. The code is compatible with 0.91in, SSD1306, 128x32px OLED displays.



Specifications:
Input Voltage: 12VDC ±5%
Current consumption: cca 20mA, plus fans
Outputs: max 300mA/ch
Temperature range: 0-99.9°C,
Measurement resolution: 0.1°C
Setting base unit: 1.0°C

Beside the mandatory min/max temperature points, you can set an additional one in between, with its related PWM values. The graph max. steepness is moderately restricted by code, though you can override it in the .hex file.
Officially a PWM fan can behave three distinctive ways when the received PWM value is below 30%. Sometimes a hard swith-off is not achievable, unless its 12V power rail is severed. That is why that extra NPN/P-ch combo is implemented.



We tried to use ordinary, radioshack components with extended leniency in terms of given values, therefore it can be used for clean-up our jelly bean comp. containers as well.
Only two elements are somewhat critical. C40 (and C50) are on the open collector TACH output line of the fan, therefore take the suggested 10nF as a max. value. Actually, less than 2.2nF is pretty  adequate for most cases.
The other is the output FET. Double check its max gate-source voltage value and  power dissipation when you substitute them.

Our implementation of PWM topology in a small scale deviates from the white paper at one point. The TACH pull-up resistor should be on 12V, but we rather tied it to the 5V rail, as it is a bit more safe. (Never run into any problem doing so.)

Sharing the I2C bus between display and temperature sensors is bringing a couple of paradoxical issues. First and foremost, the OLED modul has its own pull-up resistors tied to inner 3V3. To achieve  seamless operation beyond the lab bench, the TCN75As got their own 3V3 VREG to avoid the otherwise mandatory level shifters. The uC port has set to SMBUS mode, therefore it is able to handle 'reduced logic levels' perfectly fine. The other issue is with bus speed. For smooth, lag-free appearance, it is preferable to clock it with 400kHz, though the temp.sensors would be happy with much less. The increased self heating effect is not a big deal in our case, but as a potential RF emitter with its elongated wire harness would be benefited with a much slower clock.
Just for fun, we carried out a hasty ’RF immunity compliance test’ with a hand held radio transmitter, setting 5W output power @ 434MHz. With distance more than 15cm between the wires and the transmitter antenna, the I2C communiation went without any hiccup. At about half a watt, we had to wind the cable around the antenna to be able to corrupt the data (ribbon cable lengths was 20cm + 100cm).

All passives are 0603in size, unless noted otherwise. The VREGs are legacy types, their thermal pads are on 0V, so the ground plane is utilized as heatsink. Before you are planning to supply anything else from their power rails, please take into considerations their curbed capabilities.

The programming header is a 1.27mm  pitch pinheader from Preci-dip (850-10-050-10-001101 ). Its mating receptacle is not necessarily populated on the PCB, just simple inserting the pinheader into the bare footprint will do the job (tested thousand times). For our average purpose, it takes up the least amount of real estate around the uC…

The PCB artwork contains no features with extra charges. It is a humble, 2ly, 6/6mil design with 0.4/0.85mm VIAs, nothing beyond the basic capabilities in Asia.


Top layer designators for assembly. The D21 Error-LED is on the opposite side, not shown here. 
(The bottom layer is almost exclusively a 0V reference plane)


Mechanical considerations:
The four mounting holes at the corners are for M2 fasteners (D2.3mm). The PCB should be standard 1.6mm (62mil) to avoid flexing when buttons are pressed.
The reduced overall size of the device allows to built it onto many small-ish  enclosures.
Tactiles intended to use as they are, without added caps/buttons, providing the frontplate thickness is around 1.5-2.0mm. Tactile actuator stem diameter is usually around 3.5mm, and comes with 9.5/13/17mm length (B) measured from the PCB, as most common.


Suggested mechanical stack-up


PCB-related  mech. dimensions

Misc:
If you press all three buttons at once during power up, two additional service menu items can be reached. The first one determines the default display orientation (0° or 180°), with 4 additional corner grapic element, serving as helpers to measure back the display useful area for precise front plate cutout position. (Time to time manufacturers change it a bit.)
The other one is swapping the up/down tactiles function.

As the display utilizes OLED technology (and because of its origin and price), it can wear out quickly. Hence using the display timeout feature in the menu is advisable.


Error handling:
If either Temp.Sens unit ceased to provide data, the other one will take the lead and sources data for both PWM control algorithm. In case of both TCNs are unoperational, the device goes back to manual mode.
If the display loose its conection, the uC tries to reinitialize it. Till then, the 'hidden' D21 LED is flashing. (Additional PTH pads are provided for wiring if you wish to mount it on the front plate.)
During normal operation, try not to disconnect neither display nor sensors.

Those who are concerned about nearby electrostatic discharge or direct hit via the tactiles (because of certain mounting technique in mechanical implementation), use the shielded version of 6x6mm FSM series switches, the footprint accomodates that fifth grounding/shielding terminal too. (Especially when decide to use the shortest, 0.7mm stem length version (A) with added metal buttons!)


TempSense PCB:
MSOP package and 0603 passives are chosen for small overall size. 0402 are a bit too finicky to solder by hand in a streamlined fashion. To save space further, setting its address is confined to 0x000 or 0x001.
The flooded bottom layer together with the sole M3 mounting hole are isolated from the active circuit area. (Creepage distance is only about 1.2mm w/o washer.) They provide better heat transfer and a more rapid response.


BOM:
The values of passives are subject to change at your wish (way beyond their average 5-20% tolerance) without paying the penalty.
A few exceptions are:
• R23/24/25 which tame the max current through the clamping diodes of the uC inputs
• R41/51, as with reduced values will increase the burden on VR1 when the given chanel is ON
• substituting the D1 Si diode with schottky, please be aware that some device has ridiculously high reverse current
• and the aforementioned C40/50

There are certain modifiable areas in the EEPROM where we can slightly alter the overall behavior. Since they are not subject to change during everyday use, we thought it is better to save space not placing them into the user menu structure.

(This content is under Creative Common licence.)

Gerber and BOM download: Link
« Last Edit: July 24, 2025, 08:33:13 am by ElMech_Proto »
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6847
  • Country: es
Re: DIY 2ch PWM Fan Controller (PIC)
« Reply #1 on: July 24, 2025, 09:02:04 am »
Why release everythign but the soruce code for people to modify to their needs?
My advice it to upload the project to Github..
Also, given the OLED display, you could add a graphical curve mode!
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline ElMech_ProtoTopic starter

  • Newbie
  • Posts: 7
  • Country: hu
Re: DIY 2ch PWM Fan Controller (PIC)
« Reply #2 on: July 24, 2025, 10:41:05 am »
On 32px heigth it is not worth the effort and the uC is only 16kW. I am not saying it is impossible on this implementation, but seems a bit pointless.
 

Offline d-el

  • Regular Contributor
  • *
  • Posts: 161
  • Country: ua
Re: DIY 2ch PWM Fan Controller (PIC)
« Reply #3 on: July 24, 2025, 02:59:04 pm »
I think that a huge advantage would be support for 2 pin fan.
For this, you can build a simple synchronous Buck converter.
I did a similar task, but in my task the fan controller was configured once via RS485 and then works autonomously.
Schematic:
2623965-0

UPD:
It is also better to be able to support more than one temperature sensor.
« Last Edit: July 24, 2025, 03:06:57 pm by d-el »
 

Offline ElMech_ProtoTopic starter

  • Newbie
  • Posts: 7
  • Country: hu
Re: DIY 2ch PWM Fan Controller (PIC)
« Reply #4 on: July 25, 2025, 04:11:36 am »
I thoght no one wants to use 2/3 wire fans anymore, at least not in this small power regime. What we were tinkering about is a simple linear (opamp+pass t.) adapter, but your approach is pretty eye-opening! Creating less heat so the adapter can be way smaller in size. I will mull it over with my coleague (he is the real McCoy in terms of HW+code, I am just a locksmith with layout tendencies). Thanks the input!
 

Offline ElMech_ProtoTopic starter

  • Newbie
  • Posts: 7
  • Country: hu
Re: DIY 2ch PWM Fan Controller (PIC)
« Reply #5 on: July 25, 2025, 01:33:43 pm »
d-el:
I have never expected, that a FET-driver could work as a 'step-down SMPS', but looks legit for a modest load like-2 pin Fan!
Did you use analog output temp.sense devices because of long distance? (az least too long for I2C)

//to yout UPD: it handles 2 independent temp.sensors
 

Offline d-el

  • Regular Contributor
  • *
  • Posts: 161
  • Country: ua
Re: DIY 2ch PWM Fan Controller (PIC)
« Reply #6 on: July 28, 2025, 10:55:04 am »
I have never expected, that a FET-driver could work as a 'step-down SMPS'

The MOSFET driver is a buffer with a complementary output power stage. Therefore, it is suitable for building simple DC-DC. The output voltage will be approximated as Vout = Vin * Kpwm. You can calculate the inductor and PWM frequency using the online calculator.

Did you use analog output temp.sense devices because of long distance? (az least too long for I2C)

Analog sensors are more preferable for power electronics, in the mode of strong noise. Since the moise is easy to filter out by hardware/software.
I2C is an in-circuit interface, when the chips are located very close, about several centimeters.
The 1Wire sensor (DS18B20) works well in the three-wire connection mode. But it has become problematic to buy original DS18B20, there are a lot of fakes.

it handles 2 independent temp.sensors

I need two temperature sensors to monitor two power components.

Offline oldrev

  • Contributor
  • Posts: 21
  • Country: cn
Re: DIY 2ch PWM Fan Controller (PIC)
« Reply #7 on: September 20, 2025, 12:11:33 pm »
A super simple 2-wire fan speed control circuit, all you need is a buck converter with adjustable output voltage.

« Last Edit: September 20, 2025, 12:20:22 pm by oldrev »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf