About the author

  • nilehs pathak

    thanks Uamang ji… for this post… it will help me in my project… thanks once again…. one more request Umang ji… can you pls tell me how to show the sine wave on graphic lcd it will be very helpful to me if you post one tutorial on the same…. and thanks once again….

  • Pratik

    thanks for nice article,
    how to generate wave of 1kHz?

    I have tried changing values in this statement


    I am getting 750Hz and 1.5kHz waves.

    • Hi Pratik , firstly sorry for the late reply. To get a 1KHz Sinewave you’ll need to use a more finer resolution and also decrease the number of divisions accordingly. For example you can use a resolution of 0.05us(50ns) i.e. PWMPRESCALE with a value of 3. Since the Sinewave is in KHz range the PWM Period will also need to be decreased correspondingly. For 100 divisions new PWM Period will be 5us. Lastly the Lowpass RC filter also needs to be re-designed properly as mentioned in the article.

      Its better if we can discuss this in detail on forums under this section : http://www.ocfreaks.com/forums/f93/

  • bibek

    how to give phase shift to the above sine pwm say 120 degrees or 240 degrees ,so that i can generate 3 phase shifted sine wave pwm..kindly guide me..

    • You just need to shift the Sine lookup table in a looping fashion =or= just add a specific value to the index of the sine lookup table like : ‘SineLUT[i+6]’. This will shift the sinewave as required.


    Can u plz explain how to build a low pass filter if ur frequency is varying.

    • In the simplest implementation that will depend upon cut-off frequency. Can you explain a bit in detail about your implementation ?