blog

Driving LED And Fan With PWM

PWM封面图1200

What is PWM?

    PWM stands for Pulse-Width Modulation. It is a mature technology that uses the digital output of a microcontroller to control analog circuits.
    PWM controls the frequency and duty cycle of the output square wave through programming to obtain the required signal.
    Cycle: It is a complete cycle of the PWM signal output, including one high-level signal and one low-level signal. The reciprocal of the cycle is the frequency of the PWM.
    Pulse Width: The duration of the high level is the pulse width.

ChatGPT Image 2025年11月4日 10 08 04

    Frequency: It refers to the  number of complete cycles of high and low levels that occur within 1 second. For example, 60kHz means 60,000 cycles occur within 1 second.
    Duty Cycle: It refers to the ratio of the duration of the high level to the duration of one cycle, usually expressed as a percentage. For example, a duty cycle of 60% means the high level occupies 60% of the duration of one cycle, and the low level occupies the remaining 40%.

ChatGPT Image 2025年11月4日 10 09 30

PWM Application Principle

    Take the Arduino UNO microcontroller as an example. Its I/O ports can only output high and low levels.In general use, the high level output by the Arduino UNO is 5V, and the low level is 0V. If you want to output different analog voltages, you need to use PWM. By changing the duty cycle and frequency of the square wave output by the I/O port, you can use digital voltage signals to achieve the effect of analog voltage signals.

    When using PWM, the voltage is applied to the analog load in the form of a pulse sequence. When the I/O port is turned on, the output is 1; when it is turned off, the output is 0. By controlling the on-time and off-time, in theory, an analog signal with an output not exceeding 5V can be obtained.For example, a 50% duty cycle means the high level occupies 50% of a cycle, with half the time for the high level and half for the low level. Then, at a certain frequency, an analog voltage of 2.5V can be obtained. If the duty cycle is 75%, the voltage will be 3.75V.

07ef1294b747be0e886b0927995cf37f

   In other words, at a certain frequency, different output analog voltages can be obtained through different duty cycles. PWM converts digital signals to analog signals based on this principle..

PWM Application

    So what are the practical applications of PWM and how is it applied?

LED Light Control

    The simplest and most intuitive application of PWM is in LED light control. Generally, the human eye has no sense of flicker for refresh frequencies above 80Hz. For the LED lights we usually use, when the frequency is higher than 50Hz, due to the effect of visual persistence, basically no flicker is visible, and people will mistakenly think the light is constant.

    Therefore, if we output a high-frequency PWM signal and control its duty cycle, we will find that the higher the duty cycle, the brighter the LED light, and the lower the duty cycle, the dimmer the LED light. Just like the diagram above, generally speaking, it is equivalent to simulating different voltage levels. 
    Based on this principle, you can fix the frequency and change the size of the duty cycle to achieve the effect of a breathing light.

LED control demo:

A PWM adjustment module and a LED were used for the demonstration.

002

PWM Fan (Motor) Application

    PWM is widely used in the motor field. For example, the fans we often use can use PWM technology to simulate the effect of different gears.

        For a DC motor, it only needs to be connected to a power supply to rotate. When a high level is input, the motor will quickly increase its speed. When the high level is suddenly converted to a low level, the motor will not stop immediately due to the inductance preventing sudden changes in current, but will maintain its original speed. Therefore, we can conclude that the speed of the motor is the average voltage value output within this cycle (Figure 1). Therefore, the essential principle of PWM speed regulation is to adjust the speed by keeping the motor in a state of incomplete rotation.

    So we only need to adjust the frequency to the application range of the motor and change the duty cycle to set different gears. For example, if we set three gears, we only need to adjust the duty cycle to 33%, 66%, and 100% to simulate the required effect.

    The frequency of motors is not the same; specific frequencies need to refer to the datasheet of the specific model. Too low a frequency will lead to unstable operation, and if the frequency is just within the human hearing range, a whistling sound will be heard. If the frequency is too high, the fan may not respond in time, resulting in unsmooth operation. Generally, the motor frequency is between 6 – 16kHz.

PWM fan control Video:

    A PWM adjustment module and a small 5V fan were used for the demonstration.

Application Fileds

     PWM has a very wide range of application fields. This demonstration only focuses on its application principles. The most common application fields include the automotive industry (motors, LED lighting), the consumer electronics industry (power management, audio amplifiers), the home appliance industry (temperature control, fan control), industrial automation (servo motor control, such as robotic arms), and the lighting industry.

The advantages of PWM

    The advantage of PWM over direct analog signal output is its higher energy conversion efficiency. PWM adjusts the power output by modifying the duty cycle of the signal, rather than directly altering the current or voltage, which reduces energy loss. Additionally, PWM offers higher precision than analog signal output. For example, when controlling motors or LEDs, PWM technology enables very accurate adjustments.
    Due to the simplicity of its output principle, PWM is highly compatible. It is suitable not only for low-power devices but also for high-power devices (such as using PWM technology to adjust the speed of high-power fans).

The disadvantages of PWM

    There are also many drawbacks to using PWM technology compared to analog signals.
    Firstly, there is the issue of electromagnetic interference (EMI). Due to the relatively high frequency of PWM, the rapid switching operation can easily cause electromagnetic interference, especially in high-frequency PWM, where the interference can be more noticeable. This can affect surrounding electronic devices, so additional shielding and filtering designs are necessary.
    Next, there is the filtering problem. Since PWM signals are inherently digital, the output may produce high-frequency noise, particularly in applications that require analog signals. Therefore, PWM signals typically need to be passed through a low-pass filter to stabilize the signal and ensure proper operation.
    Finally, there is the heat management issue. Due to the frequent switching of PWM signals, especially in high-current circuits, the PWM control circuitry may generate heat, and the switching components inside the circuit may overheat. Therefore, additional heat dissipation measures are generally required in high-current circuits.

FAQ

Is PWM AC or DC?

    PWM is neither DC nor AC. In use, it can be used in both DC and AC, depending on the usage scenario and conditions.

How do you generate a PWM signal?

    Generally, a microcontroller is used to generate PWM signals. Some modules can output PWM signals after being connected to a power supply, but essentially, they are still controlled by a microcontroller chip.    

Can I run a PWM fan without PWM?

    Yes, a PWM fan can be directly connected to a power supply, but in this case, you cannot adjust its speed. It will only run at full power, which is equivalent to the PWM duty cycle reaching 100%.

Leave a Reply

Your email address will not be published. Required fields are marked *