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

Mk2 controller with indicator led

Yet more Variable Electronics...

PWM Control MkII

This is a variation on the LM324 circuit shown here with, I think, a few advantages. Changing a single resistor will alter the minimum speed available, and the wide tolerance range on pots doesn't interfere so much. It's also a tad smaller board.

LM324 circuit 2

As before, two sections of the quad op-amp form a triangle-wave generator, but now the third section is used as a low-gain amplifier, bringing the trough of the wave to just above zero volts and the peak to about 10v.

triangle wave before & after amp

The traces above show the triangle wave as-generated at pin 7 (curve A, yellow) and at pin 8 (curve B, green) after the amplifier, which has also inverted the wave signal and centralised it in the 0-10.5v output range of the LM324 when on a 12v supply.

The fourth op-amp section is connected as a comparator, comparing the wave voltage with a reference voltage set by the potential divider R8 & VR1. When the wave voltage goes above the voltage at the pot wiper, the comparator output goes high, turning on the transistor switch and power to the fan (or any other load).

With the pot turned fully clock-wise the wiper voltage is below about 0.5v and the load is on 100% of the time. Increasing the wiper voltage (by turning the pot anti-clockwise) reduces the duty cycle, and it's easy to set a minimum speed just by changing the value of R8.

Traces below show the amplified triangle wave at pin 12 (curve A, blue), the reference voltage from the pot wiper at pin 13 (curve B, yellow) and the comparator output from pin 14 (curve C, green).

Low reference voltage

Above is the effect of a low reference voltage, with the output "on" for most of the time, and below the reference voltage is near maximum giving a low duty cycle.

High reference voltage


stripboard layout

Construction Guide – Component side view

1     LEDc   Rd                                  
2 Fan+   LEDa j1         R4     C2(+)               R8    
3                             (br) R9   Q1b/g   (br)    
4 Fan–   D1a   Rd                         Q1c/d        
5 0V             R5   C3   C2(–)     j4     Q1e/s       VR1b
6           R2 R1       U1#1 (br)   U1#14   R9            
7         j3       R4   U1#2 (br)   U1#13               VR1w
8           R2     R3   U1#3 (br)   U1#12     R7 j5        
9 12V   D1c j1           C3 U1#4 (br)   U1#11 j4       (br) R8   VR1a
10         j3     R5     U1#5     U1#10                
11           C1 R1       U1#6 (br)   U1#9   R6 R7          
12       j2             U1#7 (br)   U1#8       j5        
13       j2   C1     R3             R6            

The circuit can be built on stripboard as shown, I've used a piece 22 holes by 13 strips.

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 shown by the red blobs and on the guide (note there are only six breaks between the seven pairs of IC legs, pin 5 connects to pin 10) then start soldering with the lowest components first (the wire links) so you can lay the board down with them pressed against a flat 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, I've used 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, that all track breaks are completely broken, 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.

LM324 pin connections (top view)

LM324 pinout 2N2222A pin-out
Parts List
U1 LM324 quad op-amp, 14-pin DIL socket
Q1 IRF530 n-channel mosfet or 2N2222A NPN bipolar (see below)
D1 1N4001 or similar (optional, see below)
R1 47k (all resistors 0.25W 5% or better)
R2 22k
R3–R6 10k
R7 20k
R8 1k – 10k (see below)
R9 1k
VR1 10k 16mm lin PCB pot
C1 100nF mylar or polyester film, 5mm pitch
C2 100uF-470uF 16v radial electrolytic
C3 100nF ceramic disc

Comments on alternative parts.

Q1 – For load currents up to about 600mA a 2N2222A NPN transistor is recommended. It comes in a TO-18 metal can with the leads as shown, but it's easy to adjust them to suit the guide positions, especially if you put the collector lead in column 17 instead of 18.

For higher loads go for a darlington power transistor such as the TIP120, 121 or 122, rated to 5A, or a power mosfet. The IRF530 is easy to find, not expensive, and can carry up to 14A. 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. Both darlingtons and mosfets are in the TO-220 case as shown on the stripboard layout.

Using the 2N2222A bipolar transistor you might lose 200-400mV from the 12v supply to the fan, double that for one of the darlington types; with the IRF530 I measured the loss at only 40mV with a 200mA fan.

Check the transistor or mosfet pin-outs, base or gate to R9, emitter or source to ground, collector or drain to the fan negative. A heatsink is not necessary at moderate loads.

D1 – The diode prevents back-emf from inductive loads such as brushed motors from damaging the switching transistor. With "brushless" computer fan motors it's not necessary to fit this diode across the load, as they have any needed protection already in-fan.

R8 – This sets the minimum speed. With the 10k pot, a 1k resistor will give 0–100% control which is OK for model motors or lighting, 10k will give around 5v–12v range, more suitable for cooling fans.

VR1 can be changed to a 47k pot if it suits you better, changing R8 to 4k7–47k depending on your required minimum.

C1 – This is the timing capacitor, and with the 47k timing resistor R1 and wave amplitude control resistors R2 (22k) & R3 (10k) gives a PWM frequency of around 117Hz according to the formula

frequency = R2 / (4 x R3 x R1 x C1)

Don't change R2 or R3, but you can alter R1 and/or C1 if you want to try different frequencies.

A 5mm lead pitch fits the board spacing, so a fair selection of miniature polyester types (or the cheaper mylar) will fit.

Indicator LED – On the model shown in the photo above I added an LED indicator, mounting as shown in red on the chart. The dropper resistor Rd is 1k.

LM358 pin connections (top view)

For a multi-channel controller, just one 2-opamp triangle wave generator (U1A & U1B) and x2 buffer amplifier (U1C) shown in the above circuit can be used, taking several connections from the U1C output each to its own comparator section on a second chip as shown below. The fourth "spare" opamp in the original chip, U1D, is shown used as a unity-gain buffer on the 'virtual earth' point between R4 & R5, giving a more stable mid-voltage. So a 4 channel controller can be built with two LM324 chips, for 6 channels you could add an LM358 dual opamp, pinout shown left.

Note the '+' (non-inverting input) and '-' (inverting input) symbols on the op-amps in the schematic and check they match the appropriate IC pins when designing your layout.