Quick jumps: LM324 PWM Controller – Nomad's 555 PWM Controller – Simple 555 PWM Controller – LM324 PWM Controller MkII

Yet more Variable Electronics...

PWM Control

Duty cycle waveforms

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.


Advantages are,

  1. The output transistor is either on or off, not partly on as with normal regulation, so less power is wasted as heat and smaller heat-sinks can be used.
  2. With a suitable circuit there is little voltage loss across the output transistor, so the top end of the control range gets nearer to the supply voltage than linear regulator circuits.
  3. The full-power pulsing action will run fans at a much lower speed than an equivalent steady voltage.

Disadvantages:

  1. Without adding extra circuitry, any fan speed signal is lost, as the fan electronics' power supply is no longer continuous.
  2. The 12V "kicks" may be audible if the fan is not well-mounted, especially at low revs. A clicking or growling vibration at PWM frequency can be amplified by case panels. A way of overcoming this by "blunting" the square-wave pulse is described in Application Note #58 from Telcom. (a 58k pdf file, right-click to download). I've tried this, it works, but some of advantage #3 is lost.
  3. Some authorities claim the pulsed power puts more stress on the fan bearings and windings, shortening its life.

How It Works


PWM waveforms

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.


A Practical PWM Circuit

PWM circuit with op-amps
LM324 pinout

LM324 pin connections (top view)

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.

Sawtooth from U1B pin 7

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.

Fan Power on minimum setting


Construction


324PWM stripboard
Parts List
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)
R3 56k
R4, R5 47k
R7 68k
R8 (see below)
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)

Construction Guide – Component side view

 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
1                                                
2                         Q1(g/b)   R8                  
3   Fan–                     Q1(d/c)                      
4 0V       R5     C3         Q1(s/e)       j7   C2(–)     R7    
5 12V Fan+ j2       R4 C3                     C2(+)   R6      
6                                                
7       R2   R1     U1#1 (br)   U1#14 j4 j5           (br)   R7   VR1(a)
8 j1       R5       U1#2 (br)   U1#13   j5                    
9       R2 R3       U1#3 (br)   U1#12         C4(+)         VR1(w)
10     j2           U1#4 (br)   U1#11         j7   C4(–)          
11 j1           R4   U1#5 (br)   U1#10   j6           (br) R6     VR1(b)
12     C1     R1     U1#6 (br)   U1#9 j4                      
13     C1   R3     j3 U1#7 (br)   U1#8     R8                  
14               j3           j6                    
15                                              

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.

Prototype 324 Controller

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.

Q1 and R8

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.

2N2222A pin-out

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.

Adding a Kick-Start

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).


Nomad's 555 Circuit

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.

Nomad's PWM circuit with mods

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 .

veroboard layout

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.


 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
1     D2(c) R1                                            
2                   j3     j4         C4 (br) R6 R5     Q1(b)    
3                                               Q1(c)   Fan(+)
4 VR1(b)     R1       (br)   j3   C1   U1#1 (br)   U1#8 C4   R6   j5   Q1(e)    
5     D2(a) D1(c) j2             C1   U1#2 (br)   U1#7       R5          
6 VR1(w)                 R2 (br) R2   U1#3 (br)   U1#6             j6    
7               C2+     R3 R4   U1#4 (br)   U1#5 C3                
8 VR1(a)   j1 (br) j2                                     j6    
9               C2–       R4 j4         C3   C5–         0V Fan–
10     j1 D1(a) (br)           R3                 C5+   j5       12V

Parts List
U1 555 Timer, 8-pin DIL socket (optional)
Q1 BD140 PNP transistor
D1, D2 1N4148
VR1 47k 16mm lin pot
R1, R6 47k 0.25W
R2 1k 0.25W
R3 150k 0.25W
R4 33k 0.25W
R5 470R 0.25W
C1 100n (0.1uF)
C2 220uF 16V electrolytic
C3, C4 100n (0.1uF) ceramic disk or mylar
C5 220uF 16V electrolytic
BD140 pin-out
TIP126 pin-out

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.


Comments

nomad #2

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.