Controlling two 12V fans is what this little project is about. Something a case modder would slobber on, and any self-respecting geek dad should try with his daughter, as soon as she can hold a perfboard the right way up and can refrain from putting those brightly coloured resistors in her sparsely toothed mouth.
I know. As of May 2012, there are already projects on the net along the same lines. Just google and you'll find some in the first few hits. Unfortunately they seem to be mostly incomplete, poorly documented, or just wrong. So I set off to brew my own.
An ATtiny45 monitors an NTC and starts a fan once a certain temperature is reached. Using PWM it varies the fan speed according to the temperature. When the top speed is reached, a second fan is started and its speed is changed according to the temperature, just like the first, but for the upper range.
There are two potentiometers, one to set the minimum temperature threshold for the first fan, the other one to set the temperature range. That is, how much hotter than the threshold temperature it must get before both fans is run at top speed. In other words, the fan1 is started at the temperature set by pot1 and fan2 is started at pot1+pot2. Fan1 reaches top speed at pot1+pot2, and fan2 reaches top speed at pot1+2*pot2.
If you are rather more familiar with PID controllers (who isn't? my grandma used to run a blast furnace in her backyard!) this circuit can be seen roughly as implementing a controller of type P (Ki = Kd = 0), where the first pot selects the SP and the second pot lets you choose the Kp. Similarities end there, as this circuit doesn't strive to keep the SP; anything below the SP is fine.
A couple of details have been taken care of, to make it interesting:
SWAP_FANSthat you can define to zero.
It is possible to use the circuit with just one fan, but if you don't intend to ever use the second header, you may want to get rid of one MOSFET (and related components), and you'll have a more compact board.
At the beginning of the source file there are some constants you may want to fiddle with. Especially:
FAN_MIN_DC, the minimum duty cycle, which is different for every fan
SPINUP, the larger the fan, the longer the spin-up phase required
MIN_TEMP, that depends on the use you'll make of this device
As you may have guessed from the picture above, my prototype employs a 7805 voltage regulator in TO-220 packaging, which is way too big for the job, and two MOSFETs that could easily drive industrial motors the size of my fist. Those were the parts I had at hand. You are free to use more reasonably sized components that would waste less room on your board.
is on GitHub. You'll also need
and, of course, an ISP programmer. If C programming is not your cup
of tea, you may try to upload a
pre-compiled image I had laying around.
make upload and good luck.
After struggling for a couple of weeks trying to cram this circuit onto a stripboard, you will start appreciating those little contraptions made in Chinese sweatshops for few cents and sold to you for an arm and a leg.
No, not the same arm or leg the little Chinese boy injured while making your device.