Help with driving 24VDC Sunon fan digitally - Page 1
Forum section: electronics / beginners

author: czbaterka
author_rank: Contributor
timestamp: March 13, 2025, 04:33:44 pm
content: Hi everyone,I'm at the end with my skills on one small project I am currently working on.I have SUNON MF60252VX-1000U-G99 fan (24VDC 2.04W fan with tachometer) which I am trying to drive digitally (set speed of the fan by Arduino).Issue is, that the fan has internal driver that is not accepting PWM signals (and also there is no 4th wire for PWM).There is some PWM (4 wire) version of this fan, but it costs like 5 times more for some reason and I only have those fans available atm.What I've tried:1) Logic gate N channel MOSFET driven by PWM from ArduinoThis did not worked well. Fan is buzzing on any PWM frequency I've tried (even like 20kHz) and starts spinning around 20VDC which is almost full speed2) Logic gate N channel MOSFET driven by PWM from Arduino + RC filter to smooth out the PWMThis did not worked as well. Almost the same behavior as with 1)3) Logic gate N channel MOSFET driven by BJT, driven by PWM from Arduino + RC filter to smooth out the PWMSame as 1) and 2)Items below were tests without digital control, to test the behavior of the fan without it.4) N channel MOSFET driven by simple voltage divider, in MOSFET's linear rangeThis worked littlebit better, but still not acceptable. Fan was buzzing (while rotating a little) until around 18V and then started spinning correctly, but again, almost at full speed.5) BJT driven by simple voltage dividerSame result as 4)6) Finally I tried simple LM317 setupThis is working perfectly fine. I am able to control the fan from basically 0 to 100%. Fan starts spinning at around 3V without any buzzing.I am not quite sure what is hapenning here or how to solve it. Using LM317 with digital potentiometer (or some OP amp setup, or buck converter) is last resort as LM317 and digital pot (or buck converter) will cost as much as the fan itself and I am trying to build it on a budget.Anyone have any ideas how I can drive the fan with same result as in 6)? I dont need that of a big speed control. Something like 40%-100% would be sufficient for my usecase.

author: ahsrabrifat
author_rank: Regular Contributor
timestamp: March 13, 2025, 05:20:58 pm
content: Since the fan responds well to pure DC voltage, you can use an RC low-pass filter + an Op-Amp buffer to convert the Arduino PWM into an analog voltage. This will be the workflow of the circuit:PWM from Arduino > RC Filter > Op-Amp Buffer> Fan

author: fzabkar
author_rank: Super Contributor
timestamp: March 13, 2025, 05:47:47 pm
content: Maybe something like this?Code:Q L___Vcc o---+^+--------+---UUU----+---o Vout||| | |=== | || D - --- CPWM | ^ ---| | |.-------. | ||Arduino| === ==='-------' GND GNDQ = P-channel logic-level MOSFETD = high speed Schottky diodeEdit:The Arduino would need an additional N-channel MOSFET to control the P-ch MOSFET because of the difference in voltage levels. The P-ch MOSFET would then be a regular part, not logic level.

author: John B
author_rank: Frequent Contributor
timestamp: March 13, 2025, 07:37:38 pm
content: Quote from: czbaterka on March 13, 2025, 04:33:44 pmThis wouldn't work in a few ways. RC filtering is only practical when you are dealing with low power signals, rather than powering a device. You would need a very small value of R and a huge value of C.Generally you would use an LC filter instead. Did you modify the arduino PWM timers to run off a different clock division? Normally they run around 960Hz, which makes LC filtering impractical as you need large values of L and C.20kHz with an LC filter should be practical.

author: czbaterka
author_rank: Contributor
timestamp: March 14, 2025, 09:50:50 pm
content: Quote from: fzabkar on March 13, 2025, 05:47:47 pmAnd do you think that the LC filter will do a good job on whole (or at least most of the) range of PWM?

author: oPossum
author_rank: Super Contributor
timestamp: March 14, 2025, 10:48:22 pm
content: Quote from: czbaterka on March 13, 2025, 04:33:44 pmhttps://www.eevblog.com/forum/projects/pc-motherboard-pwm-4-pins-to-3-pins-digital-converter/msg25642/#msg25642https://www.eevblog.com/forum/projects/pc-motherboard-pwm-4-pins-to-3-pins-digital-converter/msg24415/#msg24415

author: wraper
author_rank: Unknown
timestamp: March 14, 2025, 11:06:20 pm
content: You can use RC filter to drive LM317 adj pin with smoothed PWM. You don't need digital pot, not to say it's a wrong part even if you do not care about cost. None of the brushless fans with built-in driver can be PWMed (except through dedicated PWM wire some fans have), they need DC.

author: bingo600
author_rank: Super Contributor
timestamp: March 15, 2025, 07:23:15 am
content: I have been driving a 3-Pin fan with pwm + R/C smoothing, from an AVR M8.But since i didn't want to disturb the tacho signal. I used a P-Fet setup, in order not to disturb the GND signal.

author: czbaterka
author_rank: Contributor
timestamp: March 15, 2025, 07:08:50 pm
content: Quote from: wraper on March 14, 2025, 11:06:20 pmHow? That would require sensing feedback with the MCU and changing the duty cycle, wouldn't it?

author: wraper
author_rank: Unknown
timestamp: March 15, 2025, 07:39:02 pm
content: Quote from: czbaterka on March 15, 2025, 07:08:50 pmNo, you don't need to sense anything because smoothed voltage is proportional to PWM duty cycle. You'll need to add a BJT, MOSFET or opamp to translate MCU out to 0-24V range. For example, this simple circuit will give you about 2-23V regulation range. Minimum requiredC2EDIT: C1 capacitance depends on PWM frequency and R3, R2.

author: czbaterka
author_rank: Contributor
timestamp: March 19, 2025, 07:11:12 am
content: Quote from: wraper on March 15, 2025, 07:39:02 pmThat works like a charmOfc the output voltage depends on the load but I guess that it is not very important at this use-case.With values you provided, I am getting saw-like wave at around 180mVpp which seems to be ok for the fan (no buzzing).Would it make sense to use high frequency pwm (like 10kHz instead of Arduino's default 480Hz-ish) to further smooth out the output?

author: wraper
author_rank: Unknown
timestamp: March 19, 2025, 01:43:08 pm
content: Quote from: czbaterka on March 19, 2025, 07:11:12 amIt should not as long as 24V supply is stable and the load in not less than 10mA (LM317 requires minimum load).QuoteYes

author: czbaterka
author_rank: Contributor
timestamp: April 21, 2025, 01:15:38 pm
content: Quote from: wraper on March 15, 2025, 07:39:02 pmI originally went with your solution, but I realized that I can also use op-amp as I switched from using Atmega328P to LGT8F328P that has 8-bit DAC output built in. I tested both options in reality and it seems that both work fine.I just want to ask if one of them is better than the other, while ignoring fact that in case of RC filter, the changes to the set voltage are not very fast (I dont mind that as I dont need fast changes to the fan speeds).Is there anything to consider in case of the op-amp variant?

author: wraper
author_rank: Unknown
timestamp: April 21, 2025, 01:39:56 pm
content: Does not really matter which one you use.

author: Zero999
author_rank: Super Contributor
timestamp: April 21, 2025, 01:42:09 pm
content: Your fan will never run at full speed, because the LM315 will drop a couple of volts.The op-amp's gain is too high, at 5.8, which will cause its output to saturate with 5V in. Lower it to something more reasonable, say 4.1, so 47k and 15k.The op-amp circuit needs to have a low pass filter on the input, to convert the PWM to a DC voltage at the ADJ pin.

author: czbaterka
author_rank: Contributor
timestamp: April 21, 2025, 02:32:53 pm
content: Quote from: Zero999 on April 21, 2025, 01:42:09 pmI am well aware of that, but thats issue of both variants, right? I actually feed the circuit using 25VDC from SMPS, so the fans are running at around 23.8V.Quote from: Zero999 on April 21, 2025, 01:42:09 pmOh yeah, thanks. You are right, bad math from my side...Quote from: Zero999 on April 21, 2025, 01:42:09 pmDoes it? I am feeding DC voltage into the op-amp from real 8bit DAC. I am feeding PWM only in the first case (with BJT).

author: Zero999
author_rank: Super Contributor
timestamp: April 21, 2025, 04:43:19 pm
content: Quote from: czbaterka on April 21, 2025, 02:32:53 pmI missed the DAC. Yes it will work.Note the PWM version inverts, but that's fine too.

author: wraper
author_rank: Unknown
timestamp: April 21, 2025, 05:00:19 pm
content: Quote from: Zero999 on April 21, 2025, 01:42:09 pmIt does not matter that LM358 output does not go up to exactly positive power rail because there is LM317 1.25V vref and its dropout voltage anyway. Also adj pin current should somewhat help as well. But czbaterka should increase resistance of feedback divider at least a few times because it creates way too much load, that will somewhat limit opamp max output voltage as well.

author: Zero999
author_rank: Super Contributor
timestamp: April 21, 2025, 05:03:10 pm
content: Quote from: wraper on April 21, 2025, 05:00:19 pmThat wasn't the issue. The problem is it's not optimal, because there's a huge dead band, at the positive end, when the LM358 will saturate. It's better to configure it so its output only swings up to a few volts below 24V.Quote from: wraper on April 21, 2025, 05:00:19 pmI agree. That's why I suggested 47k and 15k, although he could easily go up to 470k and 150k.

author: wraper
author_rank: Unknown
timestamp: April 21, 2025, 05:22:53 pm
content: Well, it does not really matter if opamp saturates because there is no AC voltage amplification here.

author: Zero999
author_rank: Super Contributor
timestamp: April 21, 2025, 06:40:42 pm
content: Quote from: wraper on April 21, 2025, 05:22:53 pmYou're missing the point.The op-amp's output saturates at about 2V less than the supply, giving a range of 0 to 23V, with a 25V supply. The input voltage is between 0V and 5V. With a gain of 5.8, the useful input voltage range is only 0 to 4V, if the input voltage is higher, then the output saturates. If the gain is reduced slightly, then the full 0 to 5V range of the DAC can be used. Yes I know it's not a huge deal, but it's always best practice to minimise dead band, so the full range of the DAC can be used,

author: czbaterka
author_rank: Contributor
timestamp: April 21, 2025, 08:41:50 pm
content: Quote from: Zero999 on April 21, 2025, 04:43:19 pmYeah... Can be fixed in swQuote from: wraper on April 21, 2025, 05:00:19 pmOh yeah. The original values are like ~4mA at 24V. Can I use like hundreds of kilo ohm resistor divider? Wouldn't that introduce offset (and if yes, is that even important in my usecase)?Quote from: Zero999 on April 21, 2025, 06:40:42 pmSo I can do e.g. 560k and 150k which gets me gain of 4.733 (so around 23,65V at 5V)?

author: wraper
author_rank: Unknown
timestamp: April 21, 2025, 08:50:02 pm
content: Quote from: czbaterka on April 21, 2025, 08:41:50 pmDepends on op-amp input bias/offset current. You can calculate it based on datasheet specs. It usually becomes a problem in high gain or precision circuits.