Generation of sine wave using samples

Thread Starter

electronicsLearner77

Joined May 26, 2012
127
Really this is one of the questions going in my mind before i implement. This question is regarding generation of sine wave in motor application (Svpwm). if i use a PWM frequency of 20KHz, so if my sine wave frequency to be generated is 1KHz, will i get 20 samples per one cycle? All these calculations seems to be too complicated. How to analyze these calculations? Please advise.
 

MrChips

Joined Oct 2, 2009
22,914
You have many questions in one post:
  • sine wave generation
  • motor application
  • PWM
  • 1kHz sine wave with 20kHz PWM
Take one question at a time.
What is the first question?
 

Ian Rogers

Joined Dec 12, 2012
820
I don't think it really matters... It's a question of resolution.

20Khz PWM -> 1khz sine requires 20 steps ( samples )....
15Khz PWM -> 1 khz sine will require 15 steps ( samples )…

The higher your PWM frequency, the better the sine will be..

Do a bit of research as PWM filtering isn't linear.. Visit Roman Blacks web site,, Herein you will find a "corrected" sine wave sample array... Albeit very large.... I had to tone it down a bit!

http://www.romanblack.com/onesec/Sine1kHz.htm
 

Thread Starter

electronicsLearner77

Joined May 26, 2012
127
Thank you very much for the reply. If i see the waveform



Sorry for the fundamental question but please help me to understand
According to me you varied the duty cycle of pwm so the width of the pulses should change but i am seeing the width constant
Q1. How much the width will be? Is it of importance?
Q2. Why the amplitude is changing?
Q3. If the amplitude is changing, amplitude will be proportional to duty cycle?
Please help.
 

MrChips

Joined Oct 2, 2009
22,914
Ignore that diagram. That shows amplitude modulation, AM, not pulse-width modulation, PWM.
Amplitude and duty-cycle are independent.

If your clock frequency is 20kHz, that translates to a period of 1/20k seconds = 50μs.
For 0% duty-cycle, the pulse-width is 0μs.
For 100% duty-cycle, the pulse-width is 50μs.
Hence your PWM pulse-width can range from 0 to 50μs.
 

danadak

Joined Mar 10, 2018
4,057
Q1) Several considerations. PWM is being used as a DAC, where DC equivalent value
is proportional to duty cycle after filtering it.

Q2) That graph is not showing the whole pic. This graph more accurate representation.

upload_2018-10-26_15-29-40.png

The PWM is a logic output, but its duty cycle controls, after LPF, DC value. Which
will be the sine after appropriate PWM duty cycle modulation.

3) Yes, thats how PWM is acting as a DAC. And modulating in time its
duty cycle will create the sine.


http://www.ti.com/lit/an/spraa88a/spraa88a.pdf

https://web.csulb.edu/~hill/ee470/Lab 2d - Sine_Wave_Generator.pdf


Regards, Dana.
 
Last edited:

Ian Rogers

Joined Dec 12, 2012
820
As Mr chips has already said.... Ignore that graph... It only shows the readings, in excel, needed to create the sine shape...

Read the article thoroughly as there are more graphs to give better accuracy.... Read and digest!

Most micro's will give a decent resolution at 20khz PWM
 
Top