Author Topic: Controlling the speed of a DC motor via PWM  (Read 5945 times)

0 Members and 1 Guest are viewing this topic.

Offline engineheatTopic starter

  • Frequent Contributor
  • **
  • Posts: 267
  • Country: us
Controlling the speed of a DC motor via PWM
« on: April 25, 2023, 12:41:57 am »
Hi,
I would like to control the speed of this DC motor with PWM using an Arduino:

https://www.delta-fan.com/products/BFB0712HD.html

I found the following diagram to use:



Notice the flyback diode D1. When buying a diode, what specs do I need to watch out for in order to ensure it is suitable? Should I also include resistors or capacitors in series with the flyback diode? I'm considering this diode:

https://www.digikey.com/en/products/detail/nte-electronics-inc/1N5401/11644131

But I'm not too clear on what some of the specs mean:

Voltage - DC Reverse (Vr) (Max) 100 V

Current - Average Rectified (Io) 3A

Voltage - Forward (Vf) (Max) @ If 1.2 V @ 3 A

I also want to make sure the MOSFET in the diagram is a N Channel enhancement type.

Thanks
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Controlling the speed of a DC motor via PWM
« Reply #1 on: April 25, 2023, 06:23:56 am »
Nothing is critical about this circuit, your fan only draws 310mA, any N-channel power mosfet rated for at least 30V or so ought to be fine, ideally something that is logic level compatible, I would just search by price and look for the lowest RDSon you can find for a price of a dollar or so in a package style you can work with, really just about any old random N channel mosfet ought to work fine though. The diode is probably not even necessary at all but if you want to put it there for good measure then something like a 1N4007 ought to do.
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8179
  • Country: fi
Re: Controlling the speed of a DC motor via PWM
« Reply #2 on: April 25, 2023, 07:15:29 am »
Your post is contradicting, because you say you are controlling a DC motor, but post a link to a fan, which is not a DC motor, but a complete product which contains a BLDC motor (which is NOT a DC motor despite having DC in its name) and an inverter circuitry to control it.

If you were to control a DC motor:
Notice the flyback diode D1. When buying a diode, what specs do I need to watch out for in order to ensure it is suitable?  I'm considering this diode https://www.digikey.com/en/products/detail/nte-electronics-inc/1N5401/11644131

Having fast or no reverse recovery is essential. Schottky is the correct type as they have no reverse recovery. What you suggest is standard recovery standard Si diode, not suitable. Standard recovery diode won't work because with PWM, the motor current does not decay to zero (except at very low loads or speeds) but works in continuous conduction - i.e., the energy stored in the motor inductance keeps the current flowing, through the diode, during MOSFET off-time. When the MOSFET then turns on, current is still flowing through the diode. The diode has to turn OFF very quickly, otherwise short-circuit current will flow, wasting energy and heating up the diode and MOSFET.

You can see standard recovery diodes suggested in some relay or solenoid circuits, but it's because the controller does not turn the transistor ON again too quickly after turning off - current has time to decay to 0, no short circuit current.

Quote
Should I also include resistors or capacitors in series with the flyback diode?
Absolutely not. The reason for the diode is to provide a continuous, low-impedance path for the motor winding current. This loop needs to be as short as possible, without any unnecessary components. The diode, while schematically in parallel with motor, must be located next to the transistor, not at the motor. You also need to provide low-impedance power supply: capacitance between Vcc and GND, placed physically close to the MOSFET-diode series combination.


Quote
Voltage - DC Reverse (Vr) (Max) 100 V

Diode blows up if it sees voltage more than 100V. Your circuit has 12V over the diode, when the MOSFET is conducting, nowhere near 100V. Though, fast switching of current will produce voltage peaks due to layout parasitic elements, usually in range of 20%-100% depending on how good job you did. I would choose a diode rated for at very least 25V max reverse voltage. The exact same applies to the MOSFET Vds_max, by the way. Chose a MOSFET rated to at very least 25Vds_max, but 30V would be a good idea for a bit more margin.

Quote
Current - Average Rectified (Io) 3A

Average current through the diode. This might be optimistic; you'd need to run thermal calculations too.

Quote
Voltage - Forward (Vf) (Max) @ If 1.2 V @ 3 A

How much voltage is lost over the diode when it conducts (so would be 0V for an ideal diode). 1.2V is already 10% of your 12V supply, meaning that if you run a large DC motor with small duty cycle (small speed) producing a lot of torque (a heavy load, e.g. accelerating a vehicle), diode being in conduction most of the time, the efficiency is limited to 90% by the diode alone. If your motor current were to be 3A, this would mean 1.2V*3A = 3.6W dissipated on the tiny diode. A schottky type with lower Vf would make heatsinking easier and increase the efficiency.

Quote
I also want to make sure the MOSFET in the diagram is a N Channel enhancement type.

Yes, that's the correct type for ground-side switching.

You would also need current sense and pulse-by-pulse current limiting for a motor controller of any larger motor. A tiny motor below some dozen watts does fine without current sense by just overdimensioning the MOSFET and diode to handle the stall current of the motor.


---

Now, for the BLDC fan control - all of this is less critical, because the fan already comes with an inverter, which already has those switching transistors and freewheeling diodes. As james_s says, you probably could get away without any diode.

I would still add a schottky diode, and a power supply capacitor close to the MOSFET-diode combo as explained above, because even with motor inductance handled by the internal inverter bridge of the fan, you still have some parasitic inductance from the wiring, capable of generating some sort of voltage spikes. A small schottky diode does not cost much after all.

Another question is whether it's a good idea to PWM the supply currrent to a fan. Many have done that, me included, but if it's not mentioned in the fan datasheet, it's in principle similar abuse as trying to cut power to your television thousands of times per second. By far, the best option is to get a fan with PWM control input (so-called four-wire fan). But usually standard BLDC fans still work fine when PWM'd if you don't mind audible noise so you can try it out.
« Last Edit: April 25, 2023, 07:19:37 am by Siwastaja »
 

Offline engineheatTopic starter

  • Frequent Contributor
  • **
  • Posts: 267
  • Country: us
Re: Controlling the speed of a DC motor via PWM
« Reply #3 on: April 26, 2023, 05:37:28 am »
Now, for the BLDC fan control - all of this is less critical, because the fan already comes with an inverter, which already has those switching transistors and freewheeling diodes. As james_s says, you probably could get away without any diode.

Thanks for the reply. Learned a lot. I guess I overlooked the fact that it is brushless DC motor which works differently than a DC motor with a brush/commutators. So those switching transistors that it comes with are performing the same function as that of the commutators in a brushed motor - that is - for basic operation of the motor. They are NOT for PWM. For PWM, I would still need my own MOSFET. But you are saying since they already have flyback diodes, I can probably get away with not having diodes. Am I understanding it right?



Another question is whether it's a good idea to PWM the supply currrent to a fan. Many have done that, me included, but if it's not mentioned in the fan datasheet, it's in principle similar abuse as trying to cut power to your television thousands of times per second. By far, the best option is to get a fan with PWM control input (so-called four-wire fan). But usually standard BLDC fans still work fine when PWM'd if you don't mind audible noise so you can try it out.

I'm not sure why the spec of that fan says "2 lead wires", but I actually see 3 actual wires in the photo (blue, black red). So what is the third one for?

Do you know if there are four-wire fans similar to the one I showed when it comes to size, flow rate, etc? I do want to get one from a reputable supplier, as opposed to cheap no-name Chinese stuff. What are some reputable brands in the industry for fans of this size?
Thanks
« Last Edit: April 26, 2023, 05:39:01 am by engineheat »
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Controlling the speed of a DC motor via PWM
« Reply #4 on: April 26, 2023, 05:45:54 am »
In my experience most 2 wire brushless fans respond fairly well to PWM. Not all of them but enough that it's worth trying.
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8179
  • Country: fi
Re: Controlling the speed of a DC motor via PWM
« Reply #5 on: April 26, 2023, 05:55:29 am »
Yes, you got it right. The third wire usually is a tachometer output, giving pulses more frequently the higher the speed. Fourth wire would be PWM control.  That being said, tacho output is usually yellow so if you have just black, red, blue, maybe blue is PWM control?

Fans can be ordered with different options with slightly different part numbers, so it's not weird to see photos with different number of wires. Just read the datasheet carefully, paying attention to the exact part number and every letter and number in it.

https://www.digikey.com/en/products/filter/fans/dc-brushless-fans-bldc/217
Digikey parametric search has this "features" field where "PWM control" is available as a search term. I would go for such a PWM controllable fan instead of "abusing" a normal fan by cutting the power/ground wire with a FET, even if that usually seems to work out just fine.
 

Offline engineheatTopic starter

  • Frequent Contributor
  • **
  • Posts: 267
  • Country: us
Re: Controlling the speed of a DC motor via PWM
« Reply #6 on: May 13, 2023, 01:35:36 am »
Yes, you got it right. The third wire usually is a tachometer output, giving pulses more frequently the higher the speed. Fourth wire would be PWM control.  That being said, tacho output is usually yellow so if you have just black, red, blue, maybe blue is PWM control?

Fans can be ordered with different options with slightly different part numbers, so it's not weird to see photos with different number of wires. Just read the datasheet carefully, paying attention to the exact part number and every letter and number in it.

https://www.digikey.com/en/products/filter/fans/dc-brushless-fans-bldc/217
Digikey parametric search has this "features" field where "PWM control" is available as a search term. I would go for such a PWM controllable fan instead of "abusing" a normal fan by cutting the power/ground wire with a FET, even if that usually seems to work out just fine.

Thanks. I've been doing some research on those fans, and I learned that there are PWM fans with 4 wires. It seems the 4 wire version is a lot easier to implement for a beginner like me as you can just directly hook the PWM pin of the Arduino to the PWM wire of the fan for speed control. And then the power source connects to the power wires. I probably dont even need any additional diode or MOSFET. Right?

 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8179
  • Country: fi
Re: Controlling the speed of a DC motor via PWM
« Reply #7 on: May 13, 2023, 06:53:33 am »
Yes, that's correct. Drive the PWM input directly from microcontroller IO pin.
 

Offline engineheatTopic starter

  • Frequent Contributor
  • **
  • Posts: 267
  • Country: us
Re: Controlling the speed of a DC motor via PWM
« Reply #8 on: May 15, 2023, 02:13:08 am »
Thanks.
The fan I'm talking is actually this:
https://www.mouser.com/datasheet/2/632/BUB0712HD_SM-2948392.pdf

It does say 25kHz for PWM, and after doing some reading on Arduino, it seems the analogWrite function doesn't output anywhere near that frequency. So right now I'm currently reading about using timers to get higher PWM frequency.

But it seems so much easier to just use the analogWrite. I wonder from a theory perspective what's the drawbacks (if any) if one used a much lower PWM frequency?
 

Offline engineheatTopic starter

  • Frequent Contributor
  • **
  • Posts: 267
  • Country: us
Re: Controlling the speed of a DC motor via PWM
« Reply #9 on: May 15, 2023, 02:19:22 am »
As a side question, these 4 wire PWM fans seems to be for computer use. I wonder if they have bigger fans for say, home ventilation use or HVAC use that work similarly (4 wire, PWM, can be controlled via Arduino)?

thanks
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Controlling the speed of a DC motor via PWM
« Reply #10 on: May 18, 2023, 09:07:47 pm »
They certainly do have HVAC fan motors that can be controlled similarly, in that field they're called ECM motors. I think it's a digital interface rather than PWM but I've never actually put a scope on one to find out. Whenever I have time to install the new furnace in my house I might poke around out of curiosity.
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8179
  • Country: fi
Re: Controlling the speed of a DC motor via PWM
« Reply #11 on: May 19, 2023, 05:38:34 am »
Yeah, digital interface or 0-10V analog control signal, which is very easy to generate with a potentiometer if you have more than 10V available, but a bit pain-in-the-ass if the highest voltage available to you is 5 or 3.3V.
 

Offline Algoma

  • Frequent Contributor
  • **
  • Posts: 291
  • Country: ca
Re: Controlling the speed of a DC motor via PWM
« Reply #12 on: May 19, 2023, 09:10:48 pm »
The PWM goes on the Yellow control wire. If you PWM the whole supply voltage, that poor fan controller needs enough time between pulses to wake up and figure out what is going on each cycle.  To that fan, Its like controlling the speed of your car by shutting off its engine every few seconds. Yes, there are fans that are designed to be PWM controlled that way.

In this case you simply power the fan with steady voltage and control the duty cycle of the signal to the yellow wire. The rest of the speed control circuit is already inside the fan.


 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 17819
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Controlling the speed of a DC motor via PWM
« Reply #13 on: May 20, 2023, 09:05:07 am »
These little fans often have a PWM input to set the speed. Another way to do it is to make a crude buck converter. Put an inductor in series with that fan and a capacitor across it and you can regulate the voltage. Those fans can often run off much lower voltages than the nominal. For example I have used "24V" fans running at 5V to slow them right down when blowing air across my soldering desk.
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Controlling the speed of a DC motor via PWM
« Reply #14 on: May 23, 2023, 12:18:50 am »
It really depends on the fan. A lot of them have only two wires, others have 3 wires, often the 3rd wire is a tachometer output, sometimes it's a PWM input, often the same base model fan will be available in several variants with different operating voltages and control schemes. Some fans work very well fed from PWM power, others don't.
 

Offline MathWizard

  • Super Contributor
  • ***
  • Posts: 1432
  • Country: ca
Re: Controlling the speed of a DC motor via PWM
« Reply #15 on: May 24, 2023, 01:34:50 pm »
I've put standard diodes in parallel with with fans, for PMW. Yeah so that's not much good then at 50kHz. Schottky are the ones with a thin metal layer between the PN junction, iirc, and that somehow helps make them so fast.
 

Offline engineheatTopic starter

  • Frequent Contributor
  • **
  • Posts: 267
  • Country: us
Re: Controlling the speed of a DC motor via PWM
« Reply #16 on: June 30, 2023, 01:25:30 am »
https://www.digikey.com/en/products/filter/fans/dc-brushless-fans-bldc/217
Digikey parametric search has this "features" field where "PWM control" is available as a search term. I would go for such a PWM controllable fan instead of "abusing" a normal fan by cutting the power/ground wire with a FET, even if that usually seems to work out just fine.

It's so hard to find a 4 wire centrifugal blower with PWM. The ones I can find are mostly tubeaxial type. The 4 wire brushless blowers are all out of stock. I talked to a manufacturer and was told the 4 wire version requires a special order with a minimum quantity. Wonder why the blowers are not as popular for PWM compared to the axial ones. If I understand correctly, these are all computer fans right?
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9954
  • Country: nz
Re: Controlling the speed of a DC motor via PWM
« Reply #17 on: June 30, 2023, 01:43:42 am »
If you want to PWM a DC fan, like a 2 wire computer one that contains electronics, you will need to pwm it very slowly. Like under 20 Hz.

Another option is to PWM into a large capacitor so its really not pwm'ing the fan at all but producing an adjustable DC voltage to run the fan on. But if you do that you wont be able to spin the fan down to very slow since a 12V fan probably wont even work at under 4V

Its a hacky solution, best to find 4 wire fans as recommended above.
« Last Edit: July 02, 2023, 12:04:02 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline engineheatTopic starter

  • Frequent Contributor
  • **
  • Posts: 267
  • Country: us
Re: Controlling the speed of a DC motor via PWM
« Reply #18 on: June 30, 2023, 06:32:39 am »
For the 12v, I'm curious what's the difference between powering it with, say, a fixed 9V versus PWM with a duty cycle of 75%. The average voltage is the same, but with PWM, during the on time, the voltage is higher.

I wonder what difference there are in terms of air flow rate and static pressure generated. For instance, according to the datasheet of many fans, there is a roughly inverse relationship between static pressure and flow rate. Is it safe to say that max static pressure and max flow rate will decrease in both scenarios?
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 17819
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Controlling the speed of a DC motor via PWM
« Reply #19 on: June 30, 2023, 06:47:01 am »
If you want to PWM a DC fan, like a 2 wire computer one that contains electronics, you will need to pwm it very slowly. Like under 20 Hz.

Another option is to PWM into a large capacitor so its really not pwm'ing the fan at all but producing an adjustable DC voltage to run the fan on. But if you do that you wont be able to spin the fan down to very slow since a 12V fan probably wont even work at under 4V

Its a hacky solution, best to find 4 wire fans as recommended above.

You will just get a hot capacitor if you do that, you need a simple buck, put an inductor in series and diode in parallel, the fan should actually have some capacitance anyway so the inductor is more important.
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 17819
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Controlling the speed of a DC motor via PWM
« Reply #20 on: June 30, 2023, 06:56:01 am »


It's so hard to find a 4 wire centrifugal blower with PWM. The ones I can find are mostly tubeaxial type. The 4 wire brushless blowers are all out of stock. I talked to a manufacturer and was told the 4 wire version requires a special order with a minimum quantity. Wonder why the blowers are not as popular for PWM compared to the axial ones. If I understand correctly, these are all computer fans right?

Axial and centrifugal are very different, Axial is low pressure but high flow, centrifugal will have much more pressure but you loose flow. It depends on what people are trying to cool or if they need to duct the air somewhere. Even on the axials there is a huge range. Actual computer fans do pretty much no pressure, but you can buy a 120mm fan that will do hundreds of pascals in pressure, you just need to feed it 125W rather than the 5W of you more computer variety fans.

Fan laws say that flow follows speed in a linear fashion, pressure follows speed to a square fashion, this means that the power demand on a fan follows a cubic relationship to the speed. Double the speed, 8 times the power. Matching a fan to the requirements in terms of flow and pressure is a thing that with low power computer fans is not even bothered about. coincidentally as your air flow through a duct increases the pressure drop across the duct goes up with a square relationship to flow (fan speed).

Once you get into engine cooling and air conditioning sizes this all really matters but I can imagine some people out there hoovering up all the stock of little centrifugal fans for a particular use.
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8179
  • Country: fi
Re: Controlling the speed of a DC motor via PWM
« Reply #21 on: June 30, 2023, 10:49:49 am »
Another option is to PWM into a large capacitor so its really not pwm'ing the fan at all but producing an adjustable DC voltage to run the fan on. But if you do that you wont be able to spin the fan down to very slow since a 12V fan probably wont even work at under 4V

You surely mean PWM into LC circuit, forming an unregulated buck? (Don't forget the diode.) PWM into a large capacitor will not work and at best, is extremely lossy, and more likely, just blows up within hours.

Even with inductance added, lack of current sense is still a possible issue. A switch mode converter IC would solve all of this in one go.
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9954
  • Country: nz
Re: Controlling the speed of a DC motor via PWM
« Reply #22 on: June 30, 2023, 11:51:06 am »
and more likely, just blows up within hours.

What's going to blow up?  I was not suggesting PWM at mhz, it's just a DC computer fan.
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8179
  • Country: fi
Re: Controlling the speed of a DC motor via PWM
« Reply #23 on: June 30, 2023, 01:27:26 pm »
and more likely, just blows up within hours.

What's going to blow up?  I was not suggesting PWM at mhz,

MOSFET is going to blow up even from single switching event because SOA will be likely exceeded into the large capacitor as there is nothing to limit current except Rds_on + capacitor ESR. This might not happen when testing at lab table, but then happen at elevated temperature (like +40degC after the circuit is warmed up) as the electrolytic cap ESR decreases with temperature while the SOA of MOSFET is squeezed smaller.

Or, it might run "fine" for an hour after you find the room filled with capacitor internals, like I found out the first time I built the very circuit you are describing some 15 years ago.

So even 1 mHz (millihertz) of modulation might be enough to blow it up, it can be a single event. Hundreds of Hz would be enough to severely heat up the large capacitor exceeding the ripple current ratings by orders of magnitude.

You can of course use some massively oversized MOSFET to move the issue into just the capacitor heating or blowing up. Or you can bring the PWM frequency down low enough so that the capacitor survives. But then it does not filter much, and the fan is going on-off-on-off...

Quote
it's just a DC computer fan.
Fan does not care. The problem is switching the capacitor with unlimited current, even without load.
« Last Edit: June 30, 2023, 01:29:53 pm by Siwastaja »
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6266
  • Country: fi
    • My home page and email address
Re: Controlling the speed of a DC motor via PWM
« Reply #24 on: June 30, 2023, 02:42:26 pm »
The fan I'm talking is actually this:
The interface to 4-pin PWM fans used in PCs (Intel, AMD, servers, even SBCs) is standardized here (Intel PDF).

Essentially, they take their power from a 12V rail, determine speed from a 25 kHz (21-28 kHz) PWM input, and return two pulses per rotation as an open collector output (less than 1 kHz: at 1000 RPM, 33.3 Hz).  Note the 5.25/3.3V and 12V pull-up requirements!

Various Arduinos (even cheap ATtiny202s) can do 25 kHz PWM, you just need to reduce the PWM prescaler; at 16 MHz, you could use a prescaler of 4 (instead of 32) and duty cycle between 0 (0%) and 159 (99.375%).  The exact details vary depending on the exact microcontroller.

I personally would use two N-channel MOSFETs (like NX138AKP) to invert and level-shift the PWM and Tach signals; I've already simulated this for 2.5V - 5.5V control logic for a related but separate case.  A single MOSFET each will invert the logic levels, but it is trivial to adjust in software on most microcontrollers.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf