20
3 Phase Wave 3 Phase Wave Generation Generation 3 Phase waveform 3 Phase waveform generation using generation using Timer/Counter1 and 3 on Timer/Counter1 and 3 on atmega128 atmega128

3 Phase Wave Generation

Embed Size (px)

DESCRIPTION

3 Phase Wave Generation. 3 Phase waveform generation using Timer/Counter1 and 3 on atmega128. Topics. Sinusoidal Wave Generation Theory Atmega128 setup and considerations Results. 3 Phase line to line voltages. uC used to control switch states +E or 0 is shown to the load on each phase - PowerPoint PPT Presentation

Citation preview

Page 1: 3 Phase Wave Generation

3 Phase Wave 3 Phase Wave GenerationGeneration

3 Phase waveform generation 3 Phase waveform generation using Timer/Counter1 and 3 using Timer/Counter1 and 3

on atmega128on atmega128

Page 2: 3 Phase Wave Generation

TopicsTopics

►Sinusoidal Wave Generation TheorySinusoidal Wave Generation Theory►Atmega128 setup and considerationsAtmega128 setup and considerations►ResultsResults

Page 3: 3 Phase Wave Generation

3 Phase line to line voltages3 Phase line to line voltages

►uC used to control switch statesuC used to control switch states►+E or 0 is shown to the load on each +E or 0 is shown to the load on each

phasephase Depends on if upper or lower switch is onDepends on if upper or lower switch is on

Page 4: 3 Phase Wave Generation

3 Phase line to line voltages3 Phase line to line voltages

►2/3 on switching scheme used2/3 on switching scheme used►Allowing switches to be off for 1/3 of Allowing switches to be off for 1/3 of

the time reduces switching power the time reduces switching power losseslosses

►Line to neutral voltages are not Line to neutral voltages are not sinusoidal, but line to line are!!!sinusoidal, but line to line are!!!

*U, V, W are the desired line to neutral voltages

Page 5: 3 Phase Wave Generation

TopicsTopics

► Sinusoidal Wave Generation TheorySinusoidal Wave Generation Theory

►Atmega128 setup and Atmega128 setup and considerationsconsiderations

► Results

Page 6: 3 Phase Wave Generation

uC Sinusoidal PWMuC Sinusoidal PWM

►Line to neutral voltages approximated Line to neutral voltages approximated using PWM switchingusing PWM switching

►Average output voltage controlled by Average output voltage controlled by duty cycleduty cycle

►uC duty cycle = OCRnA:C/TopuC duty cycle = OCRnA:C/Top►Top and pre-scaler are set so switching Top and pre-scaler are set so switching

frequency is at 20kHzfrequency is at 20kHz

Page 7: 3 Phase Wave Generation

Lookup Table GenerationLookup Table Generation► Using Excel duty cycle of was approximatedUsing Excel duty cycle of was approximated► One cycle broken up into 192 stepsOne cycle broken up into 192 steps► Sin(2*PI*i/192), i = 0..191Sin(2*PI*i/192), i = 0..191► OCRnA:C = Round(Sin(2*PI*i/192)*TOP)OCRnA:C = Round(Sin(2*PI*i/192)*TOP)► TOP value is 400 for my 20kHz switching TOP value is 400 for my 20kHz switching

frequencyfrequency► Looking up values frees up uC for other Looking up values frees up uC for other

taskstasks

Page 8: 3 Phase Wave Generation

sine Look-Up Tablesine Look-Up Table

sin(2*PI*i/192) Round(U*TOP)

i

0-63

64-127128-191

i

Page 9: 3 Phase Wave Generation

Sin lookup table arraySin lookup table array

const uint16_t sin_lookup[192*3] = {

//OCRnA, OCRnB, OCRnC

0, 0, 346,

13, 0, 353,

26, 0, 359,

39, 0, 364,

52, 0, 370,

65, 0, 374,

78, 0, 379,

}

Page 10: 3 Phase Wave Generation

Timer/Counter 1/3 SetupTimer/Counter 1/3 Setup

►Phase & Frequency correct PWMPhase & Frequency correct PWM►Dual Slope OperationDual Slope Operation►Used to control switchesUsed to control switches

Timer/Counter1 Upper SwitchesTimer/Counter1 Upper Switches Timer/Counter3 Lower SwitchesTimer/Counter3 Lower Switches

►Timer/Counter 3 switches inverse of Timer/Counter 3 switches inverse of Timer/Counter 1Timer/Counter 1

►Output bit is set or cleared on Output bit is set or cleared on compare matchcompare match

Page 11: 3 Phase Wave Generation

Timer/Counter 2Timer/Counter 2

►Updates Timer/Counter1/3 Updates Timer/Counter1/3 OCRnA,OCRnB,OCRnC to control duty cycleOCRnA,OCRnB,OCRnC to control duty cycle

►Counter variable incremented by 3 every Counter variable incremented by 3 every time Timer/Counter 2 interruptstime Timer/Counter 2 interrupts

►OCRnA:C value generated from lookup OCRnA:C value generated from lookup tabletable OCRnA = sin_lookup[counter]OCRnA = sin_lookup[counter] OCRnB = sin_lookup[counter+1]OCRnB = sin_lookup[counter+1] OCRnC = sin_lookup[counter+2]OCRnC = sin_lookup[counter+2]

► Interrupts occur fInterrupts occur fdesireddesired*192 times per *192 times per secondsecond

Page 12: 3 Phase Wave Generation

My epiphanyMy epiphany

+ +≈

•One output port of uC looks like one switching stage

•Switches between 0 and Vcc

•Upper and Lower switches never on at same time (no shoot-thru)

•Using OCR1A:C of one Timer/Counter1 and the counters three output pins a three phase waveform can be generated

•**Bonus** I don’t have to buy anything to implement the design

Page 13: 3 Phase Wave Generation

Viewing Wave formsViewing Wave forms

RC filters and Resistive loads were used to view the waveforms

PortB.5

PortB.6

PortB.7

Page 14: 3 Phase Wave Generation

TopicsTopics

► Sinusoidal Wave Generation TheorySinusoidal Wave Generation Theory► Atmega128 setup and considerations

►ResultsResults

Page 15: 3 Phase Wave Generation

ResultsResults

Waveform growth

Page 16: 3 Phase Wave Generation

ResultsResults

CBA

A-B

Page 17: 3 Phase Wave Generation

Shoot ThruShoot Thru

If SIf S++ and S and S-- on at on at same time the same time the circuit would shortcircuit would short

Page 18: 3 Phase Wave Generation

Shoot ThruShoot Thru

To avoid shoot-thru add a switching To avoid shoot-thru add a switching delaydelay

Amount to increment or decrement by Amount to increment or decrement by depends on switching frequencydepends on switching frequency

OCR1A = OCRA-1 (cleared sooner)OCR1A = OCRA-1 (cleared sooner)

OCR3A = OCRA+1 (set later)OCR3A = OCRA+1 (set later)

Page 19: 3 Phase Wave Generation

Setting TSM, asserts a reset signal to PSR0 and PSR321. Upon clearing TSM PSR0 and PSR321 are set to zero and timers/counters begin counting synchronously

Other ConsiderationsOther ConsiderationsMake sure TCCR1 and TCCR3 are synchronous

Using SFIOR

Stop pre-scalers (stop the clocks)

Set TCCR1 and TCCR3 to zero

Restart prescalers

Page 20: 3 Phase Wave Generation

ReferencesReferences

Generate advanced PWM signals using 8-bit mCsGenerate advanced PWM signals using 8-bit mCsMichael Copeland, Infineon

http://www.edn.com/article/CA52686.html

AP16097: Different PWM Waveforms Generation for 3-Phase AC AP16097: Different PWM Waveforms Generation for 3-Phase AC Induction Motor with XC164CSInduction Motor with XC164CSInfineonInfineon http://www.infineon.com/cms/en/product/channel.html?channel=ff80808112ab681d0112ab6b2dfc0756

AVR447: Sinusoidal driving of three-phase permanent magnet motor AVR447: Sinusoidal driving of three-phase permanent magnet motor using ATmega48/88/168using ATmega48/88/168

AVR494: AC Induction Motor Control Using the constant V/f Principle and AVR494: AC Induction Motor Control Using the constant V/f Principle and a Natural PWM Algorithma Natural PWM Algorithm

AVRAVRhttp://www.atmel.com/products/AVR/mc/?family_id=607