Turn-key PCB assembly services in prototype quantities or low-volume to mid-volume production runs

Consider PWM signal

When using microcontroller and want to drive motor control or control led intensity you can use DAC to generate analog output voltage. But there is an easier way of doing this. You can use digital output to reach same results. This technique is known as PWM -Pulse Width Modulation.


In this picture you can see 50% duty cycle square wave form. The width of ‘0’ is equal to ‘1’ level, this means if signal amplitude is 5V, then average voltage over one cycle is 2.5V. It is as though  of hawing constant 2.5V voltage.

If you have 10% duty cycle, then your average voltage would be 0.5V.

You should use low pass filter to convert pulses to analog voltage:

RC passive filter

This is like digital to analog converter without DAC.

You can use PWM to drive LED to change light intensities. Also it can be used to generate audio by changing frequency of duty cycle. DC motors can also be controlled effectively by PWM.


  1. I am hoping to use this idea for a project. I want to send a PWM signal from a microprocessor, and, through the duty cycle, create a corresponding analog voltage. This is straight out of the article. The problem is, this analog voltage has to be a constant voltage, it cannot be varying (ie from your example of a 50% duty cycle and a 5V amplitude we would see an average 2.5V analog voltage, but i need this 2.5V to be effectively constant instead of just averaged). I dont know if the low pass filters can effectively achieve this or what. Any help would be greatly appreciated!

  2. You may try to look at so called
    And of course Wikipedia

    I hope this gives some idea…

  3. Hi,
    if i want to generate analogue waveform (sin of frequency f) then what is the value of C and R required to get undistorted output.

  4. You can calculate the cut-off frequency (fc) of the filter (the frequency at which the power halves or the voltage is reduced to about 70%) from

    fc =1/(2PI*R*C) (where PI is 3.14)

    The higher frequency will be rolled off at 6dB/octave Every time you double the frequency, the power will be attenuated by a factor of four or the voltage attenuated by a factor of two.

    If you pick a value of C , and you transpose the formula , you can work out R

    R = 1/(2PI*C*fc)

    To get better attenuation of noise & harmonics you can go for a Sallen-Key low pass filter, which uses two caps , two resistors & an OP AMP
    and an attenuation of 12 dB/octave


Leave a Reply

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