Home     Contact     Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science     RSS     Terms of services     Privacy policy  
 Home      Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science   

27 April 2010
Author: Giorgos Lazaridis
Closed Loop high frequency PWM PC Fan Controller

This circuit is the natural evolution of the previous High Frequency PWM Fan Controller and the PIC 3-Wire Fan RPM Controller. In a first glance, the circuit appears to control the duty cycle of high frequency PWM pulses with a potentiometer. Yet this is not the actual operation of this circuit.

The Circuit

I use a 4-wire fan and i do not need an external switching component such as a MOSFET. Therefore, the circuit is minimal. An 8-pin PIC, a trimmer, the potentiometer and a couple of resistors is everything it needs. Maybe an .1uF capacitor across the power supply (as always) would be useful. Here is the schematic diagram:

The potentiometer R3 sends the control voltage level to the PIC's A/D converter. The R2 sets the minimum voltage that can be adjusted by the R3 - as you will see later on, this is the maximum rpm setting. The RPM feedback from the fan tacho comes in the GP5 input of the PIC, with a pull-up resistor as required. GP2 generates the PWM pulses (this is the CCP1 output of the PIC). The PWM pulses are driven to the fan control wire directly. A Pull-up resistor is used in the case that the PIC fails.

The operation

The circuit mounted on a breadboard for test-run

The operation is a little bit more complicated as it looks. The potentiometer will set the control voltage level. This voltage is translated into a binary number. Unlike the High Frequency PWM Fan Controller that will use this number to set the PWM duty cycle, in this circuit the PIC will use this number as an RPM reference point. Then, from the rpm feedback of the fan, the PIC will read the current rotation speed. According to the position of the potentiometer, it will increase or decrease the PWM duty cycle accordingly, so that the fan speed is matched to the potentiometer value! In other words, the potentiometer sets directly an RPM value that we want the fan to rotate with.

What is the point to this? Well, as we all know, if a fan is powered with PWM pulses of constant duty cycle, it will gradually tend to decrease its rotation speed, mainly due to dust. If for example a fan runs at 800rpm with 40% duty cycle, after one month of operation, it will run with 700rpm at 40% duty cycle! This circuit, will adjust the duty cycle all the time, so that the rpm are steady!

I have set the sampling rate to 250 mSec. This is a rather fast reaction. I did this on purpose, because i want the operator to 'feel' the rpm change when rotating the potentiometer. But the fan usually changes the speed rather slow. Thus, in a large change, the fan will overspeed (if the change is from lower rpm to higher rpm). It will run a few setup cycles before it is centered. This is shown in the following graph. The operator changes the speed from 800rpm to 1300rpm. The fan overspeeds and after a few ups and downs, it is centered to the required speed.

Adjusting the circuit

The minimum speed of the fan is fixed, and this is around 450rpm. To change this, you need to mess with the code. The only thing to adjust is the maximum speed - because not all fans have the same maximum speed. The maximum speed can be adjusted with the R2 resistor. Here is how to do it:

First of all, set R2 somewhere in the middle. Then, rotate R3 so that the fan rotates at full speed. Most probably, that will NOT be the fan's max speed. Instead, that will be the max speed that is currently set by the R2! Do not worry, all you need to do right now is to rotate R3 completely to the direction that the fan runs faster. Now you need to be smooth and gentle. Slowly turn R2. you will notice that the speed of the fan is changing. Find the direction that the fan rotates faster. Keep rotating to this direction. There will be a point that the fan does not run any faster. This is the point that you need to find. You may use a contactless speed-meter or an oscilloscope to find this position. Or, you can simply put a piece of paper against the fins of the fan to hear noise. You do not need to be very accurate after all.

Here is another idea. Suppose that you have a noisy fan with nominal speed 3200rpm. But you never run this fun at that speed. You can then follow the previous steps and adjust R2 NOT at full speed, but at the speed you wish to have as full. For example you can set it at about 2400rpm. If you do so, you have just extend the range of the potentiometer. The potentiometer will now control the fan from 450rpm to 2400rpm!

The Program

Here is the full assembly listing, if you wish to change and re-compile the code:

 Closed loop fan controller - Assembly listing

If you only want to upload the program as-is, then download this file:

 Closed loop fan controller - Binary file

There are 3 parameters (constants) that you may wish to change:

  • GLMaxDC: This is the value for the CCPR1L register. This value will set the duty cycle to 100%. I do not find any particular reason why someone would want to change this.

  • GLMinDC: This is the minimum value for the CCPR1L register. Increase this value if the fan stalls at very low speeds.

  • GLStartDC: This is the value that the CCPR1L will carry after a reset or a power up. This value will immediately change according to the potentiometer's position.

  • You should keep in mind that the above parameter values does NOT correspond to a number %. For example, 40 does not mean 40%. There is an algorithm that calculates the duty cycle. The whole calculation can be found in the datasheet of the PIC (look the Bill Of Materials bellow).

    The GLMaxDC GLMinDC values are used as limits. The PIC is allowed to change the duty cycle only within the range GLMinDC <= DutyCycle <= GLMaxDC. Be very careful if you change these values, as the fan may stall or the program may malfunction.

    Bill Of Materials (Second circuit)
    R1Resistor 1 KOhm 1/4 Watt 5% Carbon Film 
    R25 KOhm potentiometer
    R35 KOhm potentiometer
    R4Resistor 1 KOhm 1/4 Watt 5% Carbon Film 
    Integrated Circuits
    IC2PIC12F615 Microcontroller 

    Relative pages
  • Frequency measuring techniques
  • How PC Fans Work
  • PWM signal theory
  • Learn about the most popular PC Cooling methods
  • PC fan failure alarm circuit
  • Why and How to control PC Fans
  • A simple thermostat circuit with a 741
  • Create PWM pulses with variable duty cycle controlled by a DC voltage input
  • How to make a PWM fan controller / LED dimmer using a 555
  • An intelligent self-tunned fan PWM controller
  • Control a 3-wire Fan with PWM pulses and use the Pulse Stretching method to get clear rpf feedback
  • The simplest DC motor linear rpm controller
  • A 2-speed PWM temperature fan controller

  • Comments


      Email (shall not be published)


    Notify me of new posts via email

    Write your comments below:
    BEFORE you post a comment:You are welcome to comment for corrections and suggestions on this page. But if you have questions please use the forum instead to post it. Thank you.


  • At 16 May 2013, 13:26:04 user Giorgos Lazaridis wrote:   [reply @ Giorgos Lazaridis]
    • @safoor ramjan i'd say 20KHz to be just above acoustic

  • At 15 May 2013, 15:00:58 user safoor ramjan wrote:   [reply @ safoor ramjan]
    • Thanks for these tips, and they are very interesting circuits.
      What is the ideal frequency for a motor control with pwm?
      Thanks again

  • At 21 March 2011, 17:06:41 user Michael wrote:   [reply @ Michael]
    • Giorgos,

      Very well done! I have been looking for a circuit just like this.
      You are a great presenter!
      Thanks for your effort!


  • At 28 April 2010, 0:34:59 user Tom Hargrave wrote:   [reply @ Tom Hargrave]
    • Nice solution and actually very simple - simpler than most of your other fan controlers since it's all software.

    reddit this Reddit this

     HOT in heaven!

    NEW in heaven!

    New Theory: AC electric motor working principle

     Contact     Forum     Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science     RSS   

    Site design: Giorgos Lazaridis
    © Copyright 2008
    Please read the Terms of services and the Privacy policy