Pulse-width modulation control works by switching the power supplied to the motor on and off very rapidly. The DC voltage is converted to a square-wave signal, alternating between fully on (nearly 12V) and zero, giving the motor a series of power "kicks".
If the switching frequency is high enough, the motor runs at a steady speed due to its fly-wheel momentum.
By adjusting the duty cycle of the signal (modulating the width of the pulse, hence the 'PWM') ie, the time fraction it is "on", the average power can be varied, and hence the motor speed.
An oscillator is used to generate a triangle or sawtooth waveform (green line). At low frequencies the motor speed tends to be jerky, at high frequencies the motor's inductance becomes significant and power is lost. Frequencies of 30-200Hz are commonly used.
A potentiometer is used to set a steady reference voltage (blue line).
A comparator compares the sawtooth voltage with the reference voltage. When the sawtooth voltage rises above the reference voltage, a power transistor is switched on. As it falls below the reference, it is switched off. This gives a square wave output to the fan motor.
If the potentiometer is adjusted to give a high reference voltage (raising the blue line), the sawtooth never reaches it, so output is zero. With a low reference, the comparator is always on, giving full power.
This uses the LM324, a 14-pin DIL IC containing four individual op-amps and running off a single-rail power supply. The sawtooth is generated with two of them (U1A and U1B), configured as a Schmitt Trigger and Miller Integrator, and a third (U1C) is used as a comparator to compare the sawtooth with the reference voltage and switch the power transistor.
Rather than have the fourth op-amp sat there doing nothing, it's used as a voltage follower to buffer the reference potential divider. The high input and low output impedance of this draws very little current from the PD, so high value thermistors can be used in the thermal version of this controller.
Here's the very neat saw-tooth wave coming from the output pin on U1B. Frequency is about 130Hz with the components as shown, with the amplitude swinging between 3.5V and 9.5V on a 12V supply.
The reference voltage system is designed to apply a level ranging from 3V to 7.5V to the comparator. At 3V the fan is getting power all the time, at 7.5V about 30% of the time (when the sawtooth wave goes over 7.5V). Below is the pulse power applied to the fan at the minimum setting, which was just enough to keep my test fan spinning.
|U1||LM324 quad op-amp, 14-pin DIL socket|
|Q1||IRF530 n-channel mosfet (see below)|
|R1, R2, R6||100k (all resistors 0.25W 5% or better)|
|VR1||100k 16mm lin PCB pot|
|C1||33n mylar film or ceramic disc|
|C2||220u 16V radial electrolytic|
|C3||100n ceramic disc|
|C4||4u7 16V radial electrolytic (kick-start option)|
The circuit can be built on stripboard as shown, I've used a piece 24 holes by 15 strips but you could go a bit smaller.
Start by marking out where the IC is going, then you can "dry" fit the links and other components to check fits.
Make the track breaks (there are the seven breaks between the IC legs plus two track breaks shown by the red blobs in line with the pot's outer legs) then start soldering with the lowest components first (the wire links) so you can lay the board down with them pressed against the surface to solder.
Fit the resistors (leaving those that need to be mounted vertically till later) then the ic socket (the notch is near pin #1) and the other taller components and power and fan leads. Crop the excess leads as you go.
There are two capacitors across the +12V and 0V power supply lines, a 220uF 16V electrolytic and a 100nF ceramic type. These remove any noise on the supply, particularly useful with longer leads. Check the negative on the electrolytic capacitor goes to the ground rail.
Check carefully that none of the stripboard tracks have solder bridges and that all connections are correct. A multimeter is useful for this. Plug in the ic (the notch is at the pin#1 end), connect power and a fan, test.
For the switching transistor I used a MOSFET IRF530. They're easy to find, not expensive (cost me 45p), and can carry up to 14A. Spec "On" resistance is only 0.11R, so you lose very little from the 12V supply at full speed (I measured my loss as 40mV with a 200mA fan). Providing you take the usual precautions for handling cmos, static electricity is not going to zap it. Most n-channel MOSFETs will do, look for a low RDS(on) and adequate current-handling ability.
Using a n-channel MOSFET, R8 can just be a link wire between the op-amp output and gate.
Mosfets can generate RFI when switching, so for heavy loads, or if you get any evidence of RFI, this can be damped with a low-value resistor (anything handy between 10R and 100R or so) with (if you have one) a small ferrite bead threaded onto the resistor lead nearest the gate.
With "brushless" computer fan motors it's not necessary AFAIK to fit the usual protection diode across the load, as they have transistors switching the supply around the right motor windings, with any needed protection already in-fan. Leastways, I've not broken anything so far...
Another option is to use a bipolar NPN transistor as shown below.
Using a NPN transistor, look for one that will carry your load current together with enough gain not to overload the op-amp output (40mA max). A 2N2222A with a (saturated) gain of around 40 will easily run fans rated up to its 800mA limit. For higher loads go for a darlington power transistor such as the TIP120, 121 or 122, rated to 5A.
With an ordinary bipolar transistor, using 270R - 330R for R8 will limit the base current to a safe maximum, though with a 2N2222A you can go as high as 470R and still get the full 800mA output. With the very-high gain darlington types use a 1k base resistor.
Using a bipolar transistor you might lose 200-400mV from the 12V supply to the fan, double that for a darlington type.
Check the transistor or mosfet pin-outs, base or gate to R8, emitter or source to ground, collector or drain to the fan negative. A heatsink is not necessary at moderate loads.
At the minimum setting my test fan ran fine, but wouldn't start from a standstill (well, according to the meter, fan voltage was only 3V, so no surprise). A capacitor connected between the pot wiper and ground will initially run the fan at full speed, then as it charges up the speed will gradually fall to that set. A 4.7uF 16V electrolytic worked well, started from cold every time. 2.2uF and 10uF also worked OK, use too high a value and the speed control gets a bit slow to react to turning the knob, as the capacitor has to charge or discharge a bit to suit.
There's room to fit the capacitor between rows 9 & 10, column 18 or 19, on the above board, negative side to row 10 as shown in red on the construction chart.
There's a variation on the above controller here that has a few slight advantages in some cases (or if you just like building circuits).
A different approach is adopted in a PWM controller from Nomad using little more than a 555 and a PNP switching transistor. A neat trick with steering diodes gives a wide range of pulse duty cycle, and he even finds room for a kick-start to get the fan running on low speed settings.
Visit his webpage for his original circuit and an explanation, all I'm adding here (with his OK) is a stripboard layout and construction chart, with a few minor mods and comments based on the units I've built.
One minor mod to Nomad's original was to fit a fixed resistor (R1) in series with the pot to give a minimum voltage that still ran the fan. I've also added a 1k resistor (R2) to limit current when the pot is at the zero resistance end of travel, straddling a track break on row 6 between the 555 output pin and the pot wiper .
Stripboard Magic insisted on 26 holes x 10 rows of stripboard, but you can cut that down a bit by ignoring some of the empty columns 2, 6, 9 and 23.
There are 9 track-breaks (the red dots, one is hidden behind the lower diode on row 3 and one between R2 connections on row 6), including the 4 between the 555 legs.
|U1||555 Timer, 8-pin DIL socket (optional)|
|Q1||BD140 PNP transistor|
|VR1||47k 16mm lin pot|
|R1, R6||47k 0.25W|
|C2||220uF 16V electrolytic|
|C3, C4||100n (0.1uF) ceramic disk or mylar|
|C5||220uF 16V electrolytic|
The BD140 will run fans up to 1A current rating. If you want to go over that, with low-gain transistors you'll need a lower value base resistor (R5) and there's a danger of overloading the 555 discharge pin circuitry used to drive this transistor. A high-gain PNP power Darlington, such as the TIP125, 126 or 127, with a 1k base resistor, would be a better choice for high fan currents.
Note the pins differ, so the BD140 label side faces right, TIP12x label side left on the stripboard above, and the TIP tab is connected to its collector so don't let it touch any grounded metal or sparks will fly.
The timing components (VR1, R1 and C1) give a PWM frequency of around 125Hz, and gave me a minimum voltage of about 5V. Using a 100k pot and linking out R1, it will go down to virtually zero.
C4 and C5 remove any noise on long power leads, 47uF to 470uF for C5 would be OK in most circumstances.
Cost of the build was about two quid, (still under three at Maplin prices;) and all the parts are readily available.
Using my 200mA 80mm test fan and a 11.8V regulated supply, I measured an output voltage range up to 11.6V. This simple 555 circuit can't give a 100% duty cycle, but shorting out the controller at max setting gave no apparent change in fan pitch.
The 200mA fan ran fine, even at 3.4V, with a bit of growl noise at the lowest speed typical of other PWM circuits I've used - I put it down to the pulsing kicks to the fan bearings, and it clears at higher revs.
A low-power (100mA) Panaflo 80mm L1A didn't work so well, growling at 7V and coming to a halt at about 5V. Nomad comments on similar results with his 60mm CPU fan, so give this circuit a bit of load and it's very happy to oblige! I don't see the problem with low-power fans as a detriment, PWM control is most appropriate for more powerful fans that produce a lot of waste heat with linear control.
The output transistors ran cool with no heatsink at 300mA but may need a small sink if you approach their limit.
The kick-start worked very well, with a second or so at full speed before the set speed came into effect.
Here's another 555 PWM controller, a simpler variation on Nomad's aimed at 12V DC motor or lighting control, but still fine for PC fans. It covers virtually the full 0–12V range without kick-start.
Another simple PWM circuit at Bit-Tech uses a custom fan-control ic, the MIC502. Both pot and thermistor-controlled versions can be built.