Pulse Width Modulation (PWM) is very common technique for controlling cooling fan speed in Desktop PC. In this project PIC16F877A
A standard PWM Fan
The schematic includes an LCD
Fan RPM is shown on the LCD , update rate is 1 sec. Pressing SW1 (see schematic) will change the Fan speed. As with all other projects assembly source code is available at the bottom of the page. I’ve tried to add clear comments explaining each function. Basically 4 subroutines are used. One for calculating the Sense wire frequency, second function to translate from revolution per second to RPM. The third function converts the result to Unpacked BCD, and the last one to send the data to LCD display