• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Sine look up table for generating sine wave using pwm..

Thread starter #1
Hi to all!!!
I am designing 3-phase AC induction motor speed controller drive using PWM inverter method.
In that application I need to store sine look up table so that at every instant my 3 phases are seperated 120 degree with respect to each other,,,

I read a particular 256 value sine table , but I don't know how this value comes??

I am following microchip application note for this project..
http://www.electro-tech-online.com/custompdfs/2009/08/00843a.pdf

Can any one help out how to crack this??


Sine table example
// C 8-bit Sine Table
const unsigned char sinetable[256] = {
128,131,134,137,140,143,146,149,152,156,159,162,165,168,171,174,
176,179,182,185,188,191,193,196,199,201,204,206,209,211,213,216,
218,220,222,224,226,228,230,232,234,236,237,239,240,242,243,245,
246,247,248,249,250,251,252,252,253,254,254,255,255,255,255,255,
255,255,255,255,255,255,254,254,253,252,252,251,250,249,248,247,
246,245,243,242,240,239,237,236,234,232,230,228,226,224,222,220,
218,216,213,211,209,206,204,201,199,196,193,191,188,185,182,179,
176,174,171,168,165,162,159,156,152,149,146,143,140,137,134,131,
128,124,121,118,115,112,109,106,103,99, 96, 93, 90, 87, 84, 81,
79, 76, 73, 70, 67, 64, 62, 59, 56, 54, 51, 49, 46, 44, 42, 39,
37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 18, 16, 15, 13, 12, 10,
9, 8, 7, 6, 5, 4, 3, 3, 2, 1, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 3, 4, 5, 6, 7, 8,
9, 10, 12, 13, 15, 16, 18, 19, 21, 23, 25, 27, 29, 31, 33, 35,
37, 39, 42, 44, 46, 49, 51, 54, 56, 59, 62, 64, 67, 70, 73, 76,
79, 81, 84, 87, 90, 93, 96, 99, 103,106,109,112,115,118,121,124
};
 

Attachments

ericgibbs

Well-Known Member
Most Helpful Member
#2
hi,:)
A quick look at the table, shows that 128 represents the 0deg point on the sine curve, it increases to 255 which is 90degs then decreases thru 128 down to 0 which represents 270deg and then back upto 128 0deg.

There is a tabulation printing error in the rightside of the data, and added 'space' that should be removed.


16 5,.... 2 09 etc etc
OK.?
 
Last edited:
Thread starter #3
What is the logic behind these resulting values??
How 128 refers to zero..???
And how this value can be used to decide pwm frequency in software program?
 

ericgibbs

Well-Known Member
Most Helpful Member
#4
What is the logic behind these resulting values??
How 128 refers to zero..???
And how this value can be used to decide pwm frequency in software program?
hi,
The 128 numeric value is 80hex or 10000000 in 8 bit format.

So in this application any hex value with bit 7 set to '1' is considered a positive value [0deg thru 180deg] and any hex value with bit7 set to '0' is a negative value [180deg thru 360deg].

The program would read the decimal values as hex values and output the 8 bit data pattern onto a PIC dataport.
This 8 bit output would drive a 8 bit digital to analog convertor to produce the required sine waveform.

The frequency of the D2A sinewave is determined by the rate at which the table values are read and output.

The faster the read/output rate the higher the frequency.

For 3 phase operation, a 120deg phase shift is obtained by adding equal to 120deg or 240deg, to the value read from the table.

OK.

EDIT:
Looking at the microchip datasheet, shows in this application the output drives the motor using a PWM signal derived from the table values and not an D2A.

The datasheet explains how the program achieves this PWM signal.
 

Attachments

Last edited:
Thread starter #5
ya, its not d2a, but your interpretation sounds correct regarding 8 bit...however how can we say it is providing 120 degree phase shift?
I am not able to understand how to interpret equation 4 given in the datasheet??
timer reload value= [FFFFh- ({Fosc/4}/sine samples per cycle *ADC)]
I am not getting the logic behind this....
 

ericgibbs

Well-Known Member
Most Helpful Member
#6
ya, its not d2a, but your interpretation sounds correct regarding 8 bit...however how can we say it is providing 120 degree phase shift?
I am not able to understand how to interpret equation 4 given in the datasheet??
timer reload value= [FFFFh- ({Fosc/4}/sine samples per cycle *ADC)]
I am not getting the logic behind this....
hi,
I read the formula components as:

Fosc is the PIC crystal frequency, dividing this by 4 gives the internal clcok cycle for the PIC.

Sine samples/cycle, is the number of elements in the sine table.

Timer0 prescaler is the value loaded by the program into the Timer0 prescaler.

The ADC is the output from the 10bit adc pot speed control.

Look at this image, it explains 120deg offset.

Is this what you mean.?
 

Attachments

Last edited:
Thread starter #7
See, I understand the terms, but this derivation that I am not able to digest...see my aim is to produce these sine waves using similar concept..for that I need to program chip...as far as my understanding is concern , the sine table's respected values can be considered as variable for calculating on time of pwm...And at particular instant my 3 phase should be such that they should be having a on-time which lead them 120 degree phase shift.
the question remains , how the value of sine table associated with calculation of pwm on time??
 

ericgibbs

Well-Known Member
Most Helpful Member
#8
the question remains , how the value of sine table associated with calculation of pwm on time??
hi,
Its all explained in the last image I posted.

I have extracted the details in this image.
 

Attachments

Thread starter #9
ok...I read that before, but...lets take one value..
say value=128 and half value of ADC=512...
Fosc=20Mhz, prescalar=1,sine samples=256
now timer0 reload value= 38.14
this is the time period between two states...
now what about on time of pwm which will be applied during above time period..
After every Timer0 overflow interrupt, the value pointed
to by the offset registers on the sine table is read. The
value read from the table is scaled based on the motor
frequency input,
by multiplying by the frequency input
value to find the ratio of PWM, with respect to the maximum
DC bus. This value is loaded to the corresponding
PWM duty cycle registers.


what is other input???Is that ADC value???
 

ericgibbs

Well-Known Member
Most Helpful Member
#10
what is other input???Is that ADC value???
Its in datasheet and my earlier image, its the output from a speed pot thats digitised by the PIC adc input, giving a 10bit resolution value.
 

Attachments

ericgibbs

Well-Known Member
Most Helpful Member
#12
If it's any help, I work out this kind of problem using Microsoft Excel.
hi marc,:)
I think is a case of the OP not reading the datasheet carefully and trying to use the applications data on a different project.
 

tcmtech

Banned
Most Helpful Member
#13
For what its worth there are many three phase driver IC's that do all of this for you!
 
#15
I am trying to do a project similar to yours

Controlling a 3-phase AC induction motor with a PIC18f2331.

I am able to generate simple PWM. But I don't know how to to generate the sine with the PWM and how to dephase them.

Can you send me your code please ?
 
#16
Dear frens,
I am trying to generate 3-phase sine wave using the AD7226 Quad DAC..In the circuit have eprom 2716...

I dunno hw to write program..will u help me...
wht kind of programmer i need to use to program eprom 2716 ?

tq :)
 

Latest threads

EE World Online Articles

Loading

 
Top