Using a programmable system-on-chip for fan control -

Using a programmable system-on-chip for fan control


Editor’s Note: In this Product How-To article Sanjeev Kumar of Cypress Semiconductor provides a tutorial on everything a developer will need, from basic PID algorithms to physical component placement, to implement the electronics for 2-, 3-, and 4-wire fan motor controllers using the company’s PSoC components.

We are in an an era of a revolution in electronics demanding high performance and circuit miniaturization. This dual increase in performance and reduction in size causes an increase in power consumption and heat dissipation. Thus, thermal management is an issue in applications ranging from personal computers to high-end servers, making cooling/thermal management a critical part of every high performance electronic system.

Thermal management is done by forced convection where heat dissipation is increased by moving the air inside and around the heat source. This is commonly achieved using brushless DC (BLDC) fans. The speed of these fans depends on the incoming RMS voltage.

Thermal management can be done by running these fans at full speed. However, running at high speed results in the following problems:

  • Increased audible noise
  • Increased power consumption
  • Decreased lifetime from mechanical wear and tear
  • Increased clogging (dust collection)

Alternatively, operating the fan below the required speed leads to inefficient cooling and potential overheating of components and component failures. In order to overcome these problems, fan speed needs to be controlled according to environmental conditions (i.e., temperature).

Fan speed can be controlled in the following ways:

  • Direct pulse width modulation (PWM): Increasing or decreasing the pulse width (that is, modifying the duty cycle) controls the fan speed.
  • Linear regulation: Tthe DC voltage across the fan controls the fan speed.
  • DC-DC regulation: Similar to linear regulation, a switching regulator is used instead of a linear regulator.

Direct PWM is commonly used because of advantages such as reduced power dissipation, low cost, and ease-of-design. Most commonly, the BLDC fans used in thermal management have four wires, although older designs may have three or two wires.

4-wire fan basics
The four wires of a BLDC fan are power, ground, tachometer output, and PWM input. A typical 4-wire brushless DC fan is shown in Figure 1 .

Figure 1 : Typical 4-wire DC fan

4-wire DC fans include hall-effect sensors that sense magnetic fields generated by the rotor as it spins. The output of the hall-effect sensor is a pulse train that has a period inversely proportional to the rotational speed of the fan. The number of pulses that are produced per revolution depends on the number of poles in the fan. For the most common 4-pole brushless DC fan, the tachometer output from the hall-effect sensor will generate two pulses per fan revolution. If the fan stops rotating due to mechanical failure or other fault, the tachometer output signal remains static at either a logic low or logic high level. The speed of this fan is measured in rotations per minute (RPM). The tachometer output for one such fan is shown in Figure 2 .

Figure 2: Tachometer output of fan

Fans come in standard sizes; 40 mm, 80 mm, and 120 mm are common. The most important specification when selecting a fan for a cooling application is how much air the fan can move. This is specified either as cubic feet per minute (CFM) or cubic meters per minute (m3/min). The size, shape, and pitch of the fan blades all contribute to the fan’s capacity to move air. Smaller fans need to run at a higher speed than larger fans to move the same volume of air in a given time.

Applications that are space constrained and need smaller fans due to physical dimension limitations generate significantly more acoustic noise. To manage acoustic noise generation, the fan controller can be configured to drive fans at the minimum possible speed, simultaneously maintaining safe operating temperature limits. This also extends the operating life of the fan compared to systems that run all fans at full speed all of the time.

Fan manufacturers specify the duty cycle to RPM relationship in their datasheets, with tolerances as high as ± 20%. To guarantee a fan will run at the desired speed, system designers need to run the fans at speeds 20% higher than nominal to ensure that any fan from that manufacturer provides sufficient cooling. This can result in excessive acoustic noise and higher power consumption.

Fan manufacturers specify how the PWM duty-cycle relates to nominal fan speed. This is provided either through a table of data points or a graph that shows the relationship. An example of this information is shown in Figure 3 , with the PWM control duty cycle shown as a percentage on the horizontal axis and fan speed in RPM shown on the vertical axis.

Figure 3: Example duty cycle to speed chart

It is important to note that at low duty cycles on the PWM pin, not all fans behave the same way. Some fans stop rotating as the duty cycle on the PWM pin approaches 0%, while others still rotate at a low RPM. In both cases, the duty-cycle-to-RPM relationship can be nonlinear or not specified. Similarly, two identical fans can run at different speeds for the same duty cycle. When using duty-cycle-to-RPM information, two data points from the linear region where the behavior of the fan is well-defined should be used. For example, Figure 4 shows that with a zero PWM duty cycle, the fan speed is non-zero. Figure 4 also shows that for a given PWM duty cycle, the speeds of identical fans are different.

Click on image to enlarge.

Figure 4: Speed vs duty cycle of identical fans

Fan cables and connectors
At the cabling level, wire color coding is not consistent across manufacturers, although the connector pin assignment is standard. Figure 5 shows the bottom view of the connector. Note that connectors are keyed to prevent incorrect insertion into the fan controller board. Generally, 4-wire fans are BLDC motors with permanent magnet rotors and electromagnetic stators. The commutation of the BLDC motor is done by an application-specific integrated circuit (ASIC) in the fan itself. Figure 6 shows the tear down of a 4-wire fan where you can see the stator, rotor, and motor control ASIC.

Figure 5: 4-Wire DC fan connector pin assignment

Figure 6: Tear down of a 4-wire fan

3-wire and 2-wire fan basics
The terminals of a 3-wire fan are:

  • DC input power (12V, 24V or 48V)
  • Ground
  • Tachometer output
  • Permanent magnet Rotor

Because there is no PWM pin, the speed of the fan has to be controlled through PWM modulation of the DC input power. This varies the fan speed by controlling the current through the fan. The tachometer circuitry is powered directly from the DC power input that also energizes the motor windings; thus, the tachometer circuit is only enabled when the motor is energized. As a result, a correct tachometer reading can only be obtained when the PWM duty cycle is in the ‘on’ state and power is being delivered to the fan. The lack of a PWM pin and measurement of tachometer during PWM ON cycle are the primary differences between 3-wire and 4-wire fans.

The terminals of a 2-wire fan are:

  • DC input power (12V, 24V or 48V)
  • Ground

Here the speed has to be regulated by regulating the DC power of the fan. This type of fans lacks tachometer feedback.

3-wire and 2-wire fans are outdated, and designers typically use 4-wire fans. The keying scheme chosen also enables 4-wire fans to connect to control boards that were designed to support 3-wire fans (with no PWM speed control signal) without modification. The rest of this article concentrates on 4-wire fans and their control methods.

4-wire fan controller
The fan controller can be defined as a device that reads and controls the speed of the fan through PWM duty cycle variation. Figure 7 show the block diagram of a simple fan controller:

Figure 7: Fan controller block diagram

The basic blocks of the fan controller are PWM, timer, hysteresis comparator, and speed control firmware. The details of the underlying basic blocks are shown below in Figure 8 .

In designs where more than one fan needs to be controlled by a single fan controller, a multiplexer can be used to multiplex tachometer signals from the fans to the hysteresis comparator/glitch filter block. The multiplexer will connect one fan’s tachometer signal at a time to the hysteresis comparator/glitch filter block. In some fans, the tachometer signal might not be clean and might need the hysteresis comparator/glitch filter to clean it.

The timer will measure the frequency of the filtered tachometer signal. Its RPM will be calculated based on Equation 1. After the calculation of RPM for Fan1, Fan2 will be connected using the multiplexer for speed measurement and the sequence will continue. Usually the timer measures the time of one cycle.

The timer is continuously incremented by a clock frequency fclock and latched by the input signal finput; i.e., the frequency of the tachometer signal. The double latches enable the old count value to be subtracted from the new count value, resulting in the new accumulated value for each sample period. Equation 2 shows how the measured frequency is calculated.

The fclock is selected in such a way that the timer will not overflow for the lowest frequency/seed that has to be measured. A stuck fan will give either a high or low state, resulting in a timer overflow. Usually an overflow is an indication of a stuck fan. Different fan controllers use PWM with different resolutions to control the fan. High resolution will give finer speed control. The PWM resolution will be selected based on the resolution of speed control the system demands.
Fan speed control
Due to the high tolerances, when using thedirect PWM method the speed of fans has to be controlled. Maintainingthe nominal speed of the fan can be done through open loop and closedloop control.

With open-loop speed control, the fan controlleradjusts the PWM duty cycle and sends fan speed information to thehost/main controller based on commands from the host. The host hasdesired speed versus duty cycle information. The host will use theactual speed from the fan controller and adjust the duty cycle toachieve the desired speed. The flow chart in Figure 9 and block diagram in Figure 10 illustrate the open loop method of speed control.

Figure 9 : Open loop speed control

Figure 10 : The fan controller doing open loop speed control

Withclosed loop speed control, the fan controller ensures that the fan isrunning at the desired speed by measuring the actual speed and adjustingthe duty cycle accordingly. Here the host specifies the desired speedand tolerance to the fan controller. Some parameters in closed loopspeed control are:

  • Desired speed – The speed at which host wants the fans to run.
  • Actual speed – For example, the fan data sheet may say that the fan will run at RPM1 at Duty Cycle1 but due to high tolerances, the fan will actually run at RPM1 ± Delta. The RPM1 ± Delta is the actual speed of the fan and RPM1 is the desired speed of fan. Usually due to wear and tear plus aging of the fan will cause the Delta to increase significantly over time.
  • Tolerance – This parameter sets the acceptable tolerance when specifying desired fan speed targets. The tolerance is specified as a percentage relative to the desired speed setting. Tolerance of closed loop control is defined as follows:
  • Proportional, integral, derivative (PID) parameters – PID parameters affect the way the fan responds to speed change requests. The output response can be analyzed for rise time, peak overshoot, steady state error, and stability. Proper tuning of PID constants can provide the best combination suited for an application. Figure 11 shows PID closed loop speed control.

Figure 11: Closed-loop fan PID speed control

Each of the PID parameters – proportional, integral, and derivative – affects the output response in a particular way.

  • The proportional parameter helps to achieve faster response but a very high value leads to high overshoot and instability.
  • The integral parameter is similar to the proportional parameter but one major advantage is that it makes the steady state error go to zero. However, a higher integral parameter leads to overshoot.
  • The derivative parameter helps to reduce the overshoot and settling time. It is usually minimized because it tends to amplify the noise in the error signal, leading to instability.

There is a tradeoff between fastresponsiveness and stability. In general, it is typically better to havea stable fan response as opposed to having a fast response time. Thisis because the temperature of a system does not change rapidly.

As Figure 12 shows, there is a huge error because of the absence of an integral control and the low value of the proportional parameter.

Click on image to enlarge.

Figure 12: PID tuning P = 30, I = 0, D=0

With the introduction of an integral control, the error is reduced to 0, but there is also a high overshoot, as Figure 13 shows.

Click on image to enlarge.

Figure 13: PID tuning P = 30, I = 30, D = 0

Reducing the integral parameter reduces the peak overshoot, as Figure 14 shows.

Click on image to enlarge.

Figure 14: PID tuning P = 30, I = 20, D = 0

As shown in Figure 15 , with further reduction of the integral parameter, peak overshoot becomes nil but the settling time increases.

Click on image to enlarge.

Figure 15: PID tuning P = 30, I = 5, D = 0

A reduction in the proportional parameter slows down speed response, as shown in Figure 16 .

Click on image to enlarge.

Figure 16: PID tuning P = 15, I = 5, D = 0

A reduction in the integral parameter increases the settling time, as shown in Figure 17 .

Click on image to enlarge.

Figure 17: PID tuning P = 15, I = 2, D = 0

The PID speed control can be implemented in firmware or hardware logic. Figure 18 and Figure 19 showa closed-loop implementation in hardware and firmware respectively.With closed-loop speed control, the duty cycle vs RPM information isstored in the fan controller in the form of a look-up table or transferfunction. In a hardware implementation of closed-loop speed control,speed control will be done in hardware, freeing the CPU for other tasks.This type of implementation is used in designs where the CPU isrequired for other processes apart from fan control.

Figure 18: Closed loop implemented in hardware

Ina firmware implementation of closed-loop speed control, speed controlis performed in firmware and is CPU-intensive. This type ofimplementation is used in designs where fan control is the main or onlyprocess the microcontroller performs.

Figure 19: Closed loop implemented in firmware

There are a few other parameters that are involved in the fan controller, explained below.

Fan banks In a fan bank, multiple fans share the same PWM drive signal; however,all of the individual tachometer feedback signals are connected onindividual terminals to enable speed measurement.

Alerts There are various types of alerts in the fan controller. The most important of them are:

  • Fan fault alert This alert is generated when the fan stalls (i.e., the fan is not rotating).
  • Speed regulation fault alert Speed regulation faults can occur if the automatic control algorithm is not able to get the fans to reach the desired speed. This could occur if the PWM drive is already set at 100% but the actual speed is still below the desired speed. This could also occur if the PWM drive is already set to 0% but the actual speed is still above the desired speed. In real-world applications, this could mean that the fan is suffering a mechanical problem and is no longer able to rotate at rated speeds.

Staggered PWMs In designs that involve more fans, the design will require that all thefans do not to start at same time. This is to avoid a sudden increaseof current consumption and to reduce acoustic noise. To achieve this,the PWMs have their rising edges staggered by a small delay. Figure 20 shows the staggered PWMs in a 14-fan design.

Figure 20: Staggered PWMs in a 14-Fan design

Suitability of SoC (system on chip) architecture for the fan controller design
Fancontrol of 3-wire or 4-wire fans is implemented via firmwareinstructions in an MCU utilizing a timer-driven PWM interface to adjustthe duty cycle of the PWM period and modify the fan’s actual speed. Oncethe fans outnumber the quantity of discrete PWMs, the control andoptimizations through independent fan control are limited.

Tocalculate the actual fan speed, each of the fans outputs a tachometersignal that is then interfaced with a timer to determine the RPM speedof the fan. While in some applications the exact RPM of a given fandoesn’t matter, this signal is extremely important in detecting a fanstall or rotor lock failure. More advanced fan control applications canuse this tachometer fan response to closely control the fan speeds insystems to implement fan noise reduction techniques or otherwiseminimize power consumed by the fans in a system.

With the newgeneration of system-on-chip (SoC) processors, all the abovefunctionality can be implemented on a single chip. For example, CypressSemiconductor offers a portfolio of entry-, mid-, and high-level fancontroller MCUs for different price points. The portfolio consists ofPSoC1, PSoC3, PSoC4, and PSoC5 families.

The integratedprogrammable logic of PSoC3 and PSoC5 removes the constraints a typicalMCU implementation may have by enabling the ability to independentlycontrol up to 16 fans. Additionally, with the ability to independentlycontrol and monitor each fan in a given system, you gain the ability to:

  • Implement hardware/logic-based closed-loop speed control.
  • Optimize each fan’s speed, thereby controlling the level of acoustic noise and energy consumption for exactly what the system needs to maintain a target temperature.
  • Implement advanced predictive fan failure and fan-aging algorithms.

PSoC3and PSoC5 can serve as viable high-level fan controllers with hardwareimplemented, closed-loop speed control; support for up to 16 fans,offloading the CPU for other tasks; and configurable analog resourcesfor temperature measurement (RTD, thermistor, thermocouple, andtemperature diode). Figure 21 shows a complete fan controller system implemented using PSoC3 or PSoC5.

Click on image to enlarge.

Figure 21: PSoC3- or PSoC5-based fan controller with hardware closed-loop control

PSoC4serves as an entry level, single-chip fan controller with hardwareimplemented, closed-loop speed control; support for between 2 and14 fans; and configurable analog resources for temperature measurement(RTD, thermistor, thermocouple and temperature diode). Figure 22 shows a complete fan controller system implemented using PSoC4.

Click on image to enlarge.

Figure 22: PSoC4 based fan controller with hardware closed-loop control

PSoC1serves as an entry-level fan controller with software implemented,closed-loop speed control; support for between 2 to 8 fans; andconfigurable analog resources for temperature measurement (RTD,thermistor, thermocouple and temperature diode). Figure 23 shows a complete fan controller system implemented using PSoC1.

Click on image to enlarge.

Figure 23: PSoC1-based fan controller with software closed-loop control

Selectionof a particular family of PSoC for a fan control/thermal managementsolution can be made based on cost and other parameters as described in Table 1 .

Table 1: PSoC thermal management solution

Thetools supplied with modern system on chips (SoCs) such as Cypress’PSoCs can significantly simplify the development of these fan controlsystems. For example, PSoC creator (for PSoC3-, PSoC4- and PSoC5-baseddesigns) and PSoC designer (for PSoC1-based designs) enable designers toquickly and easily develop their fan controller. Libraries havesystem-level modules/components that encapsulate all necessary hardwareblocks including PWMs, tachometer input capture timer, controlregisters, and status registers, thus reducing development time andeffort. These modules/components are accessed using an easy-to-useapplication programming interface (API). API routines allow us tointeract with the component using firmware. Table 2 lists and describes the interface to each function.

Table 2: Easy to use APIs

Figure 24: The fan controller design wizard of PSoC Creator for PSoC 3, PSoC 4, and PSoC 5 designs

Figure 24 above shows the fan controller design wizard of PSoC Creator and Figure 25 below shows the fan controller design wizard of PSoC designer. Eachcomponent or user module is customizable through a graphical userinterface, enabling designers to enter fan electromechanical parameterssuch as duty-cycle-to-RPM mapping and physical fan bank organization.Performance parameters, including PWM frequency and resolution as wellas open or closed loop control methodology, can be configured throughthe same user interface.

Click on image to enlarge.

Figure 25: The fan controller wizard of PSoC Designer for PSoC1 designs

Oncethe system parameters are entered, the component/user module deliversthe optimal implementation, conserving resources within the PSoC deviceand enabling integration of other thermal management and systemmanagement functionality onto the same MCU. Easy-to-use APIs areprovided to enable firmware developers to get up and running quickly.

Sanjeev Kumar is currently a Staff Applications Engineer with Cypress Semiconductor.He has a bachelor’s degree in Electronics and Communication fromthe College of Engineering, Guindy, Chennai, India. His interestsinclude designing embedded system applications in C and assemblylanguages, working with analog and digital circuits, developing userinterfaces in C#, and designing robots for home. You can follow him inhis blog .

AN66627 – PSoC 3 and PSoC 5LP Intelligent Fan Controller.

Video on PSoC Intelligent Fan Control.

AN89346 – PSoC 4 Intelligent Fan Controller.

AN78692 – PSoC 1 – Intelligent Fan Controller.

The PSoC Thermal Management Expansion Board Kit with BLDC fans.

Cypress thermal management solutions.

1 thought on “Using a programmable system-on-chip for fan control

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.