Intelligent Fan Controller
As a bonus, while waiting for the computer to heat up, I give you a basic intro to the concept of a PID controller.
Computer fans typically come in two varieties; three pin and four pin.
- Three pin fans have, in order, a ground, a 12V supply, and a tachometer pin. By applying a pull-up resistor to the tach pin, the fan outputs two pulses per rotation, so the MSP430 can count these pulses and know how fast each fan is spinning. To adjust the speed of the fan, the MSP430 pulse-width-modulates the 12V pin at 32Hz.
- Four pin fans are backwards compatible with three pin fans, with the addition of a fourth pin for speed control. Instead of requiring the pair of transistors to switch the 12V line as in the case of the three pin fans, you can instead simply apply the 3.3V PWM signal to this fourth pin and the fan will use it to modulate its power itself.
One thing to appreciate when reading my code is that I have very deliberately left the control code weak. It is currently a purely integral controller, which has many disadvantages which can be improved via switching to a PI controller and implementing integral spool-up prevention. I'm considering revisiting this project with another hardware revision and some controller algorithm refinements, but alas the hazard of having this one "mostly-working" means that may take a while... I'll leave programming a faster temperature control loop as an exercise for the reader.