Silicon ChipAn Intelligent 12V Fan Controller - July 2010 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Today's TV - brilliant pictures, mediocre sound
  4. Feature: Electronics Goes Boating by Kevin Poulter
  5. Feature: 3DTV: From Stadium To Living Room by Nicholas Vinen
  6. Feature: Programming PIC Microcontrollers: How It’s Done by Mauro Grassi
  7. Project: An Intelligent 12V Fan Controller by Geoff Graham
  8. PICAXE Project Development System by Jeff Monegal
  9. Project: Lab-Standard 16-Bit Digital Potentiometer by Jim Rowe
  10. Project: Dual-Tracking ±19V Power Supply, Pt.2 by Nicholas Vinen
  11. Vintage Radio: Reflex receivers: why they were necessary by Rodney Champness
  12. Advertising Index
  13. Outer Back Cover

This is only a preview of the July 2010 issue of Silicon Chip.

You can view 28 of the 104 pages in the full issue, including the advertisments.

For full access, purchase the issue for $10.00 or subscribe for access to the latest issues.

Items relevant to "An Intelligent 12V Fan Controller":
  • Intelligent 12V Fan Controller PCB [18107101] (AUD $5.00)
  • PIC18F2550-I/SP programmed for Intelligent 12V Fan Controller [1810710A.HEX] (Programmed Microcontroller, AUD $20.00)
  • Firmware and PC software plus source code for the Intelligent 12V Fan Controller [1810710A.HEX] (Free)
  • Intelligent 12V Fan Controller PCB pattern (PDF download) [18107101] (Free)
Items relevant to "PICAXE Project Development System":
  • BASIC source code for the PICAXE Project Development System (Software, Free)
Items relevant to "Lab-Standard 16-Bit Digital Potentiometer":
  • Lab-Standard 16-Bit Digital Potentiometer PCB [04107101] (AUD $20.00)
  • PIC16F877A-I/P programmed for the 16-Bit Digital Potentiometer [0410710A.HEX] (Programmed Microcontroller, AUD $20.00)
  • PIC16F877A firmware and source code for the Lab-standard 16-bit Digital Potentiometer [0410710A.HEX] (Software, Free)
  • Lab-Standard 16-bit Digital Potentiometer PCB pattern (PDF download) [04107101] (Free)
  • Lab-Standard 16-bit Digital Potentiometer front panel artwork/drilling template (PDF download) (Free)
Items relevant to "Dual-Tracking ±19V Power Supply, Pt.2":
  • Dual Tracking ±0-19V Power Supply PCB [04206101] (AUD $15.00)
  • Dual Tracking ±0-19V Power Supply front panel PCB [04206102] (AUD $5.00)
  • Dual Tracking ±0-19V Bench Supply PCB patterns (PDF download) [04206101/2/3] (Free)
  • Dual Tracking ±0-19V Supply panel artwork/drilling templates (mains-powered) (PDF download) (Free)
  • Dual Tracking ±0-19V Supply panel artwork/drilling templates (plugpack-powered) (PDF download) (Free)
Articles in this series:
  • Dual-Tracking ±19V Power Supply, Pt.1 (June 2010)
  • Dual-Tracking ±19V Power Supply, Pt.1 (June 2010)
  • Dual-Tracking ±19V Power Supply, Pt.2 (July 2010)
  • Dual-Tracking ±19V Power Supply, Pt.2 (July 2010)

Purchase a printed copy of this issue for $10.00.

An Intelligent 12 Does your computer make more noise than it should? It’s probably mostly fan noise! Slowing the fans down will reduce the noise but if you go too far, you could end up with fricassee of CPU! I n a typical personal computer most of the noise – and it can be significant – comes from the cooling fans. That’s because they run at full tilt all the time, regardless of the temperature, inside the case or out. You may need to run the fans at full speed when you are encoding home movies on a 40°C day but most of the time they just blow air around, creating a lot of noise. This can be especially bad if you have a Media Centre PC in an otherwise quiet lounge room or home theatre. If you would like to hear the “sounds of silence” then this project could be just what you need. Using just two ICs and a handful of components this intelligent fan controller will regulate the speed of up to eight 12V fans. It will measure up to four temperature points and use this data to smoothly control the speed of the fans, from completely off to fully on. There are other ways to control the speed of fans but they tend to be rather crude. That is why we called this project an Intelligent Fan Controller. One of the crude methods, unfortunately far too common, is to simply wire the fans to 5V rather than 12V. They will then run much quieter but more importantly, they will not be able to do their job on a hot day – and you risk incurring the damage that the fans were supposed to avoid. Another simple method of control is to wire a variable resistor in series with the fans. You can buy some fancy looking controls that will mount on your computer’s front panel; some even include a temperature display. But that That’s not a fan, that’s a FAN! One out of the archives – and we’re not even sure our Intelligent Fan Controller would be able to power it! 30  Silicon Chip siliconchip.com.au 2V Fan Controller The High Points • • • • • • Control up to eight computer fans based on the measured temperature Windows software for configuration and display of temperatures and fan speeds Stand alone (does not need the Windows software or computer to run) Monitor up to four temperature points Works with most fans (2, 3 and 4 wire) Audible alarm on fan or sensor failure By Geoff Graham requires you to be constantly monitoring the temperature inside your computer and adjusting the resistor accordingly. You may be fortunate enough to own a computer with a motherboard that has a fan controller but even they have limitations, mostly in the number of fans that they can control. Not just computer fans While computer fans are the obvious target, this Fan Controller is certainly not limited to computers. Because it can run independently (without being connected to a computer) it could control the fans in a greenhouse, home brewery or just about anything else that uses small (12V) fans. Just bear in mind the current limitations mentioned later in this article. The details The Intelligent Fan Controller is built on an 100 x 80mm PC board, designed to fit in a spare 3½ or 5¼-inch drive Fig.1: the Windows program running on your computer. This is optional but it will show you the measured temperatures (in °C or °F) and the speed of the fans in RPM. If a sensor or fan fails the entry will be coloured red and an audible alarm sounds. siliconchip.com.au Fig.2: an example of the setup screen for a pair of fans. You can select the type of fan, what sensors are used to control the speed and the characteristics of that control. In this case the fan is controlled by the difference in two temperatures which would be the inlet and exhaust air temperatures. July 2010  31 Buck Converters Explained A buck converter is an efficient way of converting a higher voltage to a lower voltage without throwing away the excess energy as heat. Most battery operated gadgets (mobile phones, iPods, etc) will use one or more buck converters in an effort to get the best use of the energy in the battery while supplying the various voltages required in the device. A buck converter consists of a switch (always a semiconductor switch), a diode, inductor and capacitor as shown below. The load is represented by the resistor. At the start of a cycle (first phase) the switch is closed and current will flow through the inductor into the capacitor as shown by the red arrow in the drawing. L S1 (CLOSED) FIRST PHASE + – K BATTERY D1 C LOAD A This current will be limited by the inductance of the inductor and the longer the switch is closed the higher the resultant energy stored in the capacitor. In the Fan Controller we hold the semiconductor switch closed for up to 170µS. When the switch is opened (second phase, as shown below) the magnetic field in the inductor will collapse causing a spike of current which is conducted by the diode to further add to the charge in the capacitor. In the Fan Controller this phase lasts for up to 230µS. S1 (OPEN) L – SECOND PHASE + K BATTERY D1 C LOAD A Finally there is an idle period before the cycle restarts. The overall effect is that the capacitor is topped up with “blips” of current while the load continuously draws current from it. If you open and close the switch very rapidly (eg, >300kHz) you can get efficiencies up to 95% and a very smooth output voltage. In the Fan Controller we switch at 2.5kHz, which is easier to implement but results in a lot of ripple on the output. This does not matter as a fan will happily ignore quite high levels of ripple. This ’scope grab shows the switch control voltage at the top and the switch voltage (at D1’s cathode) at the bottom. 32  Silicon Chip bay or any other handy spot inside your computer’s case. It has a USB 2.0 interface which works with software running on a Windows-based computer. Using this software you can monitor the various temperatures and the speed of the fans under control. It also provides an interface for configuring the controller for different types of fans. Fig.1 shows the software in its monitoring mode, with the various measured temperatures (in °C or °F) and the speed of the fans in RPM (if they are fitted with a tachometer output). If a fan or a temperature sensor fails its entry will be highlighted in red and an alarm on the Fan Controller PC board will sound. Fig.2 shows the software in its setup mode. As you can see, you can select the type of each fan, the temperature sensor used, the fan’s minimum speed and the range of temperatures that will control the speed of the fan. As well as selecting any one of the temperature sensors (numbered A to D), you can also select the difference between one of the first three sensors (A, B or C) and the last sensor (D). This allows you to control the fan speed based on the difference between the ambient (or incoming air) temperature and the exhaust temperature. Incidentally, in most cases the Fan Controller will only need to monitor one or two temperatures. The provision for four inputs is intended for those with very complicated requirements. Similarly, most people will have far less than eight fans in their computer (although we’ve seen some with many more!). The controller will accommodate most types of the fans found in computers these days. These include the standard 2 and 3‑wire fans and the newer 4‑wire fans that are controlled by a pulse width modulated (PWM) signal. The sidebar “Know Your Fans” describes all these fans in detail. The design can independently control four pairs of fans or a total of eight fans. Each pair is independent and can be separately configured for different control characteristics. Buck converter The speed of 2 and 3-wire fans is controlled by varying their supply voltage using a circuit called a buck converter. To understand how this is done, refer to the circuit diagram as shown in Fig.3. Taking the components associated with fans 4A and 4B as an example, the microcontroller generates a continuous string of pulses on its pin 7 (RA5) output. The frequency of the pulses is 2.5kHz and the microcontroller can control the output voltage of the buck converter by varying the width of each pulse from zero to 170µs. The output from pin 7 is connected to two drivers within IC2, here wired in parallel. IC2 is an octal source driver, once used to drive the hammers in old style dot matrix printers (remember them?). This economical chip is suited to our task as it is designed to drive an inductive load and as an added bonus, includes a diode for our buck converter. The source driver acts as a switch so that when its input is high (ie, above 2.4V) the output will be connected to 12V and when the input is low the output will be disconnected. We parallel two drivers to get the maximum possible drive current. It is the combination of the source driver, its built-in diode, the inductor and the output capacitor that forms the buck converter. Each output can supply 250mA which is ample as a typisiliconchip.com.au siliconchip.com.au July 2010  33 2 1 2 1 2 1 2010 SC 100k 100nF PIEZO BUZZER +5V 22pF + 4.7k 220nF 22pF X1 20MHz 3.3V 14 11 16 15 1 10 9 5 4 8 Vss Vusb RC0 D+ D– MCLR RC6 RC7 RA4 RA5 17 18 6 7 TACHO TACHO TACHO TACHO TACHO 8 8B 7 7B 10 8C 11 7C 12 6C 13 5C 14 5 5B 6 6B 4C 15 4 4B 2C 17 1C 18 3C 16 GND 9 100nF 3 3B 2 2B 1 1B IC2 UDN2981A 4b 4a 3a 2a 1a TACHO 2b TACHO 3b TACHO 1b F2 PWM F1 PWM 10 F 16V +12V 2-CORE CABLE 2 1 470 F 25V L1 100 H 470 F 25V L2 100 H 470 F 25V L3 100 H 470 F 25V L4 100 H 1a 2a 3a 4a 1b 2b 3b 4b HEADER SOCKET 8x FAN CONNECTORS TEMPERATURE SENSORS AND CONNECTIONS – ADJ LM335Z + Fig.3: the circuit for the Intelligent Fan Controller is quite simple given its capabilities. Most of the work is done by the microcontroller (IC1) while IC2 and its associated components form buck converters. There are four variable voltage outputs, one for each pair of fans making a total of eight fans that can be controlled. 19 Vss IC1 PIC18F2550I/P OSC2 OSC1 13 12 28 RB7 26 RB5 24 RB3 22 RB1 21 RB0 23 RB2 25 RB4 27 RB6 RC2/CCP1 AN2/RA2 AN3/RA3 RC1/CCP2 AN0/RA0 Vdd 20 AN1/RA1 INTELLIGENT 12V FAN CONTROLLER * MOLEX 8981 SERIES MALE + ADJ LM335Z USB TYPE B – 1 2 3 4 1.8k 3 1.8k 2 1.8k 2 1.8k 1 CON2 SENSOR D INPUT SENSOR C INPUT SENSOR B INPUT SENSOR A INPUT 2-PIN SIL HEADERS +5V CON1 PC POWER CONNECTOR* Fig.4: you can configure the controller for five different types of computer fan. The 3 wire fans differ in the number of pulses per revolution produced by the tachometer output so, for example, the “3-wire – x2 tacho” should be used with a fan that produces two pulses per revolution. If no fan is connected the entry should be set to “Not Used”. Fig.5: you can select the temperature sensor that will be used to control the speed of each pair of fans. You can also select the difference between a sensor and sensor D for responding to the difference between inlet and outlet temperatures. The “Manual” entry lets you select a fixed speed for testing. cal fan will draw 120mA. However, if you are connecting two fans in parallel as a pair, you should check their total current draw - just to be on the safe side. The main advantage of a buck converter is that it will deliver a stable DC voltage while generating little heat. Another method of voltage control would be to use a linear voltage regulator but that would generate a lot of heat forcing us to use heat sinks and a more complex circuit. A completely different approach to speed control is to switch the power to the fan rapidly off and on, so that the overall average voltage is low but this has the side effect of rendering the tachometer output useless. This is because the tachometer signal is generated by electronics within the fan and the pulsed supply voltage messes up the output. Not so with a buck converter; you get the benefits of low heat generation and a useable tachometer signal. means that we need to provide a pull-up resistor so that the fan can pull the line low. This resistor is internal to the microcontroller and this feature saves us having to use a bunch of external resistors. The speed of each fan is sent by the microcontroller to the Windows program via the USB interface and is also used to trigger an alarm if the fan stops. This alarm consists of a one second “beep” repeated every minute. The sound is generated by the piezo buzzer connected to pin 11 of the microcontroller. Progressing around IC1 in a counter-clockwise direction, pins 2, 3, 4 and 5 of the microcontroller are analog inputs that are used to measure the outputs of the LM335Z temperature sensors. The LM335Z is an easy-to-use device that simply generates a voltage proportional to the temperature. An output of 2.73V represents 0°C and a change of 10mV is equivalent to a 1°C change. If you verify the temperatures reported by the sensors you might find an error of up to a few degrees. This is a combination of inaccuracy in the LM335Z and variations in the computer’s 5V supply, which is used as the reference for measuring the output voltage of the sensor. The error should be small and will be of little consequence in this type of application. The microcontroller also checks the temperature sensors for a sensible reading and if any of them are shorted PWM controlled fans The more modern 4-wire fans use a Pulse Width Modulation (PWM) signal to tell the fan what speed to run at. The frequency of this control signal must be 25 kHz and a 100% duty cycle tells the fan to run at full speed while a zero duty cycle will slow or stop the fan. The Fan Controller will support four PWM controlled fans on the connectors labelled 1A, 1B, 2A and 2B. When the controller is set up for this type of fan it will hold the buck converter output voltage at the maximum and control the speed of the fan by varying the PWM signal from pins 12 and 13 of IC1. The connectors for PWM controlled fans are backwardscompatible with the more common voltage controlled fans so you can always plug a 2 or 3-wire fan into these outputs. Tachometer signal The tachometer signal from each fan is connected back to the microcontroller, which uses it to measure the fan’s rotational speed. As the fan rotates it will generate a square wave with the frequency proportional to rotation speed. This signal is driven by an open collector output, which 34  Silicon Chip What is Pulse Width Modulation (PWM)? PWM simply means that the signal is a continuous string of pulses at a fixed frequency. By varying the ratio of the pulse width to the gap between the pulses we can vary the speed of a fan. This ratio is called the Duty Cycle. When it is high (approaching 100%) the pulses will be wide and the fan will run at full speed. A low duty cycle (narrow pulses) will cause the fan to spin slowly. siliconchip.com.au or disconnected it will sound the alarm. As a safety measure it will also run any fans dependent on the faulty temperature sensor at full speed until the fault is corrected. The firmware running in the microcontroller is designed to be stable but there may be a case where it has been set to an “impossible” configuration. To correct this you can reset the micro to its initial default condition by temporarily placing a wire link that shorts the connector pins for Sensor A together while you apply power to the circuit. Continuing around IC1, the crystal connected to pins 9 and 10 provides the main clock to the microcontroller while the USB interface is connected to pins 1, 15 and 16. Pin 1 is used by the microcontroller to sense when the controller is plugged into a USB host so that it can commence communication. The capacitor on pin 14 provides smoothing for the internal 3.3V supply used by the USB interface. Power is supplied by a standard 4-pin Molex connector of the type used with ATA hard disks and CD/DVD drives. Most computers have plenty of these connectors so finding power should not be a problem. The Fan Controller uses two completely separate ground systems, one for the 5V components (IC1 and USB) and the other for the 12V components (IC2 and the fans). These are connected to separate ground pins on the power connector and only meet somewhere inside the computer’s power supply. This reduces the effects of current spikes in the buck converters which could interfere with the operation of the microcontroller. The software application With a device like this you always have the challenge of how to set the various operating parameters. We could have used a large number of DIP switches but as the controller will be mounted in a computer, we thought “why not give it a USB interface and modern software for the setup?” The Fan Controller implements a serial interface over USB and it appears on your computer as a communications or COM port. This means that it is easy to send and receive commands to/ from the controller (see the box “Communicating with the Fan Controller”). To get started you need to install the “Silicon Chip USB Serial Port Driver. siliconchip.com.au Know Your Fans Most fans in today’s computers are powered by a 12V brushless DC motor that typically draws 100mA to 130mA. Brushless simply means that the DC voltage is commutated electronically. You can expect to see three different types of fans: 2-wire Fans As the name suggests, this type of fan has just two wires. The connector type varies but normally it will be a 3 pin header plug with pin 1 being the ground, pin 2 the +12V supply and pin 3 vacant. By varying the supply voltage you can vary the speed of the fan. 3-wire Fans These are the same as 2-wire fans with the addition of a tachometer output which is connected to pin 3 (vacant in a 2-wire fan). Unfortunately there is little standardisation on the tachometer output. Most fans generate two pulses per revolution but some fans generate one or four pulse(s) per revolution. For this reason the setup program will let you configure three different types of 3-wire fans with one, two or four pulses per revolution. If you do not know the specifications of your fan’s tachometer you should select an entry that results in approximately 3000 RPM at full speed as this is the typical top speed of most computer fans. 4-wire Fans The 4-wire standard was recently developed by Intel and is mostly used for the fans that Intel and AMD provide with their high performance CPUs. Other than this they are still quite rare. The standard uses a 4-pin connector which is designed to be compatible with the 3-pin connectors used for 3-wire fans - so pins 1, 2 and 3 are the normal ground, power and tachometer output. Thankfully the tachometer output is standardised at two pulses per revolution. Pin 4 is a Pulse Width Modulated (PWM) input that is used to control the speed of the fan. A 100% duty cycle (voltage mostly high) will make the fan run at full speed while a zero duty cycle (no pulses or zero volts) will stop the fan. Despite this, most 4-wire fans will not let you completely stop the fan; the minimum they will run at is generally 20% of full speed. The connector is a special type (see the illustration above) that allows it to be plugged into a 3-pin plug. In this case the fan will act as a standard 3-wire fan and can be controlled by varying the supply voltage. A 4-wire fan works best when it is controlled by the PWM input so, if you have this type of fan, it should be plugged into the sockets for Fans 1A, 1B, 2A or 2B which fully support the Intel 4-wire fan specification. July 2010  35 LK1 10170181 470 F 100k X1 1 2 22pF 1.8k SENSOR B + + LK3 PIEZO BUZZER LK5 FAN 3A FAN 3B 100 H FAN 4A FAN 4B 10 F CON1 1 + IC2 UDN2981A CON2 USB TYPE B 100 H 470 F LK4 4.7k 3 2 1 2 + 220nF 4 1 1.8k SENSOR D FAN 2A FAN 2B 470 F 1.8k SENSOR C 1 2 100 H 470 F 100nF 22pF 20MHz 1 2 FAN 1A FAN 1B IC1 PIC18F2550 1.8k SENSOR A LK2 + 1 100nF 12V POWER INPUT 5V 100 H modify and recompile the program to suit your own needs at no cost. The source code for the firmware running on the microcontroller is also available from the website and is also built using a free development environment, in this case Microchip’s C18 Student Edition (or “Lite”) compiler and the MPLAB development environment. So you can modify this too if you wish. The device driver, the Windows program and both development environments will work with all modern versions of Windows (XP, Vista and Windows 7) in both 32 and 64-bit modes. When you first run the Windows program you will be presented with a blank window and you need to set the COM port for the Fan Controller by selecting Setup ‑> Communications Port. To discover what port the controller is on you could try the listed COM ports at random (the software will tell you if it has found the Fan Controller) or you could use Device Manager to identity what COM port number was allocated to the Fan Controller. Once the port number has been set the software will remember the number and automatically use that to establish communications the next time the program is started. When communications have been established the program will display the temperatures and fan speeds measured by the Fan Controller. It will also download the current configuration settings from the controller and you can change these by selecting Setup ‑> Fans and Sensors… Changing the settings In the setup window you can select what temperature sensors are installed and the detailed configuration for each pair of fans. Fig.4 shows a drop-down list of the types of fans that can be connected. As you can see, the 3-wire fans come in three different types depending on the number of pulses per revolution produced by the tachometer. Fig.5 shows the choices that you have for selecting the temperature sensor. These include any Fig.6 (top): the component layout with same-size photo of the completed one of the four sensors or the difference between PC board underneath. As explained in the text, you only need to include two sensors. Control of the fan’s speed is made the output components for the number of fans you wish to control. by adjusting the speed based on the temperature zip” available from the SILICON CHIP website. This driver measured by the sensor. Fig.2 shows the detail of this setup was also used in the GPS Car Computer (January 2010) so, section. The minimum power for a fan is determined by the lowif you have already installed it for that project, you will not have to install it again. Regardless, full instructions are est speed that it can dependably run at. To determine this included with the device driver and it is not hard to install. speed, select manual control and progressively increase The Windows program can also be downloaded from the the power setting until the fan starts spinning. Then add a SILICON CHIP website and installed by running the Setup 10% safety margin – eg, if the fan starts spinning at 25%, program. When you do this, you should be connected to set the minimum to 35%. In most cases you will want to leave the fan spinning at the Internet as the installation package will also need to download some components of the .NET framework from its minimum speed even when the temperature is cool, to ensure that there is always some circulation of air within the Microsoft website to complete the installation. This program is written in Microsoft’s VB Express 2008 the computer’s case. However, by ticking the box under which is a free development environment provided by the temperature settings, you can instruct the controller Microsoft. The source code will also be available for down- to completely stop the fan when the temperature is low. A load from the SILICON CHIP website so you can, if you wish, fan that is stationary is a very silent fan! 36  Silicon Chip siliconchip.com.au When the controller needs to start a fan that has been stopped it will run it for a few seconds at near full speed before it drops the power down to the minimum specified in the setup window. The same happens when power is first applied to the controller. This brief spin up ensures that a fan is not stuck in the stopped condition. Any changes that you make to the setup are copied to the microcontroller in the Fan Controller, which saves them in its non-volatile memory. This means that you can disconnect the USB cable and even uninstall the Windows program and it will not affect the operation of the controller. This feature can also be used to set up the Fan Controller for another computer that does not have a USB port. Construction Construction of the Fan Controller is straightforward. All components sit on a single PC board measuring 80mm x 100mm and coded 18107101. The component overlay is shown in Fig.6. The PIC18F2550 I/SP microcontroller needs to be programmed with the hex file (1810710A.hex) that will be available on the SILICON CHIP website. You should use IC sockets for both IC1 and IC2 as this will make it easier to do any fault-finding. The inductors are high frequency chokes with a current rating of 1A or more. We used single ended “barrel style” chokes but the board will also accept the more common type of chokes wound on a toroid (or ring) core. The 4-pin header connectors need a little explanation. The Intel standard for 4-wire fans specifies that the connector should have a narrow tongue which is the width of 3 pins (see Fig.7). This will allow you to plug in either a 3‑wire fan using a 3 pin plug or a 4‑wire fan using a 4 pin plug. 4-wire connectors for a PC board are harder to find than the proverbial “hen’s teeth” so you will have to make your own from a normal 4 pin PC board connector by using a sharp knife to cut away 3mm of the plastic tongue behind pin 4. Fig. 7 shows what the connectors should look like. On our prototype we only populated the first line of fan connectors (1A, 2A, etc) as we were unlikely to have more than four fans in our computers. You can also vary the components used. For example, if you were only going to use three fans you could omit the components (inductor, Parts List – Intelligent 12V Fan Controller 1 PC board, code 18107101, 100mm x 80mm 1 20MHz crystal 4 100H HF choke (1A or higher rating) (Jaycar LF-1272 or Altronics L6222) 1 mini buzzer, PCB mounting (Jaycar AB-3459 or Altronics S6105) 1 4-pin disk drive power socket (Jaycar PP-0744 or Altronics P5671A) 1 USB type-B socket, PCB mount (Jaycar PS-0920 or Altronics P1304) 1 28-pin IC socket (0.3” pitch) 1 18-pin IC socket 4 2-pin header plug 4 2-pin header connector, PCB mount 4 3-pin header connector, PCB mount 4 4-pin header connector, PCB mount Figure 8 (two core) flexible wire 100mm 0.7mm tinned copper wire (for links) Semiconductors 1 PIC18F2550-I/SP microcontroller (IC1) programmed with 1810710A.hex 1 UDN2981A octal source driver (IC2) 4 LM335Z temperature sensor All are available from www.futurlec.com or www.farnell.com.au Capacitors 4 470F 25V electrolytic 1 10F 16V tantalum 1 220nF MKT 2 100nF monolithic 2 22pF ceramic Resistors (0.25W 5%) 1 100kΩ 1 4.7kΩ 4 1.8kΩ capacitor, etc) associated with fans 4A and 4B. Similarly, if you only need two temperature sensors you can make up just two sensor cable assemblies and leave out the connector and resistor associated with Sensors C and D. Each temperature sensor consists of an LM335Z sensor on one end of a length of lightweight figure-8 (two core) cable and a 2-pin header plug on the other end. You need to cut off the temperature compensation pin on the LM335Z as that is not needed and solder the wires to the remaining pins. Polarity is important so follow the diagram in Fig. 9. Before you solder the joints, slide heatshrink tubing onto the wires and shrink it over the joints after you have completed the soldering. This will insulate the joints and provide a neat finish. Installation We mounted the Intelligent Fan Controller in a spare 3½inch drive bay but there are many other places that you can mount it. You may need to fabricate a mounting bracket or use screws and spacers to keep it secure. siliconchip.com.au We installed the Fan Controller in a vacant 3½” drive bay but it could be situated almost anywhere inside your computer. Depending on the chosen location you will probably need to make up a mounting bracket or use screws and spacers to hold the PC board securely. Ideally the temperature sensor should be placed near the area that the associated fan will be ventilating. For July 2010  37 Communicating with the Fan Controller The details for sending commands and receiving data from the Fan Controller are included in the source code which can be downloaded from the SILICON CHIP website. The following is a summary to give you the flavour of how it works. The Fan Controller implements a serial interface over USB and every second it sends on this interface a string which looks like: FCD,42,45,40,38,40,40,40,40… etc. The letters FCD form an identifying signature which is followed by 16 comma separated numbers. The first four are the measured temperatures (in °C), the next four are the output from the buck converters (in the range of 0 to 100) and the last eight are the speed of each fan in RPM. You can set the various parameters of the Fan Controller by sending a command that starts with FCS followed by a sequence of comma separated numbers which are the new settings. You can also query the controller for its current settings with the command FCQ and you will receive back a string that starts with FCR followed by the current settings. All these commands are simple strings of ASCII characters. So, it you don’t like the software that we have written, you can easily write your own program or use batch/shell scripts to interact with the Fan Controller. example, if you have a fan mounted in the top of the case, the associated temperature sensor should also be in the top part of the case. If you want to keep it simple you can also control a number of fans with a single sensor mounted somewhere centrally in the case. The Fan Controller is designed mainly for controlling general case fans but it can also be used to control the fans on your graphics card, power supply and/or CPU. In the case of a graphics card or CPU each should have a dedicated temperature sensor that is clamped directly to Fig.7 (right): the four-pin connector for fans 1A, 1B, 2A and 2B need 3mm of the locating tongue behind pin 4 to be trimmed, as shown in this diagram (and below). This will allow either a 4-wire or a 3-wire fan to be plugged onto the connector. PIN 1 Fig.8 (left): this shows our home-made 4-wire connector (labelled FAN 2A) and a standard 3 wire connector (labelled FAN 3A). When you trim the plastic tongue on the 4-wire connector you need to make sure that a 3 pin plug can be fitted onto pins 1, 2 and 3 of the connector while leaving pin 4 free. Fig.9: wiring diagram for the temperature sensor, cable and connector. The left-hand pin of the LM335Z is the temperature compensation pin and should be trimmed off. Note that the flat side of the sensor is uppermost in this diagram. Slide heatshrink tubing over the wires and shrink over the soldered joints on the sensor. 38  Silicon Chip the heatsink with some thermally conductive paste between the sensor and heatsink. This is because the temperature in a graphics card or CPU can rise rapidly depending on the processing load and a good thermal connection for the sensor will ensure that the Fan Controller can respond quickly. You should also set the minimum speed of the fan to be reasonably fast (say 35%) so that there will always be some air passing over the heatsink. If the fan you wish to control is inside the computer power supply, it must be approached with caution. Many of the components in these devices sit at the full 230V mains potential and, if you are not careful, you could run the risk of electrocution or fire. Never open the computer power supply case without disconnecting the mains plug (usually an IEC connector); in fact, we caution against opening up the power supply unless you know what you are doing and have had prior experience with this type of device. The safety-first adage “if in doubt, don’t” is never more applicable than inside computer power supplies. To control the speed of a fan in a power supply the best approach is to run the fan leads directly out of the power supply through a convenient hole in its cover. The leads should be firmly secured away from the other circuitry in the power supply so that they will not move around after you replace the cover. The power supply should also have its own dedicated temperature sensor and, for safety reasons, this should be mounted outside of the case in the exhaust airflow from the power supply. The fan should be configured to keep slowly spinning, even at cold temperatures, so that the sensor can detect a temperature rise in the air exiting the power supply. Fault finding The firmware of the Fan Controller has a default setup which assumes four 2-wire fans (1A, 2A, 3A and 4A) controlled by Sensor A. So, as a first test, you can simply connect the controller to +5V and after 5 seconds you should hear a beep from the piezo buzzer indicating that it has detected a faulty sensor (because Sensor A is not plugged in). This tells you that the microcontroller (IC1) and its firmware are running OK. As a more extensive test you should connect the controller via USB to your computer, load the driver and Windows program, and experiment with changing the settings of the controller. If you cannot get this working you should check the driver installation as this is the most likely failure point. If the Fan Controller does not respond to either of these tests you should check that there is 5V between pins 19 and 20 of IC1. Also check for 12V between pins 9 and 10 of IC2. If you have an oscilloscope check for a 20MHz signal on pins 9 and 10 of IC2. This is the main clock for the micro and if it is not there nothing will work. If the microcontroller is working and you have trouble with driving a fan you should check the buck converter circuit. There should be a string of pulses from the micro and also at the output of IC2 and finally, a voltage on the associated capacitor. So that’s it. Now all you need to do is build your own Intelligent Fan Controller and you too can sit back and enjoy the “sound of silence” from your computer! For errata, notes and new firmware related to the Intelligent Fan Controller go to http://geoffg.net/fancontroller.html SC siliconchip.com.au