View Full Version : 3-ph sinewave generation using pwm in 89c51rd2

Hi all,

Well i want to generate sinewave using pwm module in 89c51rd2.Could anyone help please.I know how to generate pwm but i am not able to generate a sine wave. I used fosc/4 for clk. and used to reload the new counter value and but i am not able to get required stepped sinewave on CRO. Plz help its urgent.

First write a routine that genetaes PWM. calculate sin(t) and pass it to the PWM routine. add some delay and pass the next sin(t) value. At the o/p pin connect a resistor and a capacitor in parallel with their other ends grounded, this would smoothen the waveform. Choose a small value for the capacitor.

Alternatively, write a function which would generate a integer value between 0 and 255 corresponding to sine values -1 and 1. you may do this by adding an offset value of 1 to the result of sin(t) and then multiplying it by 127.

write this value on the port.

On the port make a R-2R Ladder network.

You may also use 16 or more bits if you want a smoother curve.

nmittal

03-28-2006, 12:11 AM

Hi,

Alternatively what you can do is make a table of 64 values of PWM. You will be consuming 64 bits in it, and then use this table to make the sinusoidal PWMs. ACtually the 8051 is not godd at processing math routines, so better make a look up table. This way you will reduce the computation time and thus reduce the error in PWM.

You can also apply the same approach if you are connecting an digital to analog converter. Please elaborate more on the application may be we can help you in a better way.

Are you using it for an induction motor.

Thanks Ihx and mittal

I will try out the things that u have said. Uptill now i had written the routine to generate pwm, than at every pca register CL overflow i used to reload a new value to CCAP0H regs.corresponding to new duty cycle. Thus for a 50hz waveform i was able to get a 59samples for a quater of a cycle as clk increments were fosc/4 and the crystal is of 12Mhz.

I have to run a 1hp induction for my project using pwm.I have already completed the driver circuit, but the pwm generation is not proper and i would like to know how would be waveform on the CRO.

please help.

-ankit

nmittal

03-28-2006, 10:40 PM

Hi Boya,

I tried to observe my sinusoidal PWM on a CRO, but if you will not be able to obseve the signal if you do not use a storage CRO. Try using a storage CRO and then magnify the signals.

Thanks a lot guys. I was able to obtain the required sinusoidal waveform.

-Ankit

(boya)

nmittal

03-29-2006, 11:45 PM

Hi,

Please tell us what did you do, I ll love to hear about your work. It can surely give us inputs for our mistakes.

PradeepKumar

05-26-2016, 12:21 PM

You can generate any required voltage with proper filter circuits through modulating the width of a pulse in a period of the wave of a PWM.

Powered by vBulletin® Version 4.2.0 Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.