I have an external Ethernet enabled hard drive that is connected to my LAN and it gets lots of use. I have noticed that after a few hours of hard use the case is quite hot to the touch. I’m sure the design is fine and the heat that is generated is within the tolerance of the drive but I wanted to give it some ventilation and some forced air cooling. This project adds a cooling feature that only functions when it’s needed.
The heart of the PWM Fan Controller is a PIC 12F675 microcontroller. This microcontroller is reading the analog output of a LM35 temperature sensor using a ADC (analog to digital converter) . The resulting digital value is converted to a temperature and a fan is powered proportionally to how hot the sensor is. The sensor is mounted against the hard drive chassis so it is measuring the actual drive temperature and not just the air temperature inside the housing.
Video 1 of 4 – Intro and LM35 Sensor Overview
The system is quite simple, a temperature sensor will be connected to the input of a microcontroller. There will be two outputs, one for operating the fan and one for operating a status LED. During construction a serial output will also be used for debugging purposes.
LM35 Temperature Sensor
The LM35 temperature sensor package being used is the TO-92, it is small enough for this project and is leaded so that we can easily connect it to some wires. It is also nice since we can extend it by simply plugging it into a 0.1 inch female wire harness. This is a Celsius device and since the output is 10mV per degree it is very simple to calculate the temperature. It is even nice and simple to directly view the temperature on a multimeter as can be seen in the video.
Video 2 of 4 – Reading Data with the Microcontroller
Analog to Digital Temperature Conversion
The LM35 outputs 10mV per degree Celsius, this can be read very easily on the meter but unfortunately is isn’t quite that simple to read it within the microcontroller. The output of the LM35 is connected to an ADC (analog to digital converter) so that we can get a usable reading from it, but first we need to do a small calculation.
The analog input has a range of 0 to 5 volts and the digital resolution is 10 bits. This means that the 0 to 5 volt range will be represented by a number from 0 to 1023 in the microcontroller. If we divide 5 volts by 1024 we get the number of volts per digital increment. In this case it is 0.004883 volts per increment. So if the voltage was 1 volt on the microcontroller pin we would expect to have a reading of around 204 as the digital number (1/0.004883).
To convert the digital value to a degrees Celsius number we need to do a bit of math. If we take the digital result and multiply it by 49 then divide it by 100 we will get a result that is very close to the correct result. The calculation looks a bit weird since we are working with integer math. With integer math the information after the decimal is lost. For example 25/3 would be 8 (not 8.333).
Here is a full example. If we have a temperature of 15 degrees Celsius the voltage out of the LM35 would be around 10mV * 15 = 0.15V we know that each 0.004883 volts is one count for the digital side of the ADC therefore 0.15V / 0.004883 V = 30.73 this would provide a value of simple 30. Finally if we use the formula 30 * 49 / 100 = 14.7 but it would be stored as 14.
Video 3 of 4 – PWM Control Setup
Fan PWM Temperature Range
The intent of this project is to keep the fan off when the drive is cool and since the drive spins down after about 5 minutes of inactivity the drive is allowed to naturally cool down. Also when the temperature is moderate the fan speed should be slow which will be as quiet as it can be. To come up with the temperature range of just running slow to running at full fan speed I used the data from the Google hard drive failure report.
Here is the table of fan speeds based on temperature that was used.
|Temperature (deg C)
||Fan PWM Value
There is no speed of 10% and 20% since many fans don’t like to be run with that little power. In this design 30% is the lowest amount of power used. When the fan initially gets powered up from an off state it gets about 1 second of full power to ensure it starts up properly.
Video 4 of 4 – Completion
The air will enter an exit the enclosure through a series of holes. There were done on my V90 CNC machine but it could have just as easily been completed using a drill press. Ensure that there is enough holes that air can easily pass but there is still some structure.
Perf Board Circuit Assembly
The final circuit was built onto a perf board. The circuit had to be kept quite small so that it would fit in the small area beside the fans in the fan enclosure. A piece of a business card was attached to the bottom of the perf board to prevent the circuit from shorting out to the metal case of the hard drive enclosure. Hot glue was used to isolate some parts of the circuit as well as providing some strain relief in other areas. Hot glue isn’t conductive which makes it perfect for these quick and dirty applications.
The cooling fan that is being used is a hard drive fan, it would normally be bolted to an internal hard drive and provide constant cooling. In this normal state it would always be running as long as the computer is on. In my case that was definitely not an option since the external drive is always powered up meaning the fan would be running 24 hours a day. The cooling is provided through a series of holes that were drilled into the the external hard drive enclosure. One of the fans was also turned around so that one fan would blow into the enclosure and the other would suck the hot air out.
The code is very simple. A temperature reading is taken and based on the table shown in the Fan PWM Temperature Range the correct PWM value is output to the fan and the indicator LED.
Click on the image for a large version of the schematic.
We have most of the items available in the online store.
- Pre-programmed PWM Fan microcontroller
- 0.1 uF Bypass Capacitor
- Blue LED
- 330 Ohm Resistor (2 required)
- NPN Transistor
- LM35 Temperature Sensor