Anda di halaman 1dari 10

7/2/2015

50HzSinePWMUsingTMS320F2812DSP

MemberLogin
|
AboutUs
|
BecomeaMember
|
ContactUs
|
Dealership
Search

Home
Products
ProjectKits
Components
Articles
Customers
Forum
Blog
Jobs
Training
MicrocontrollerBoards
CPLD/FPGABoards
DSP
Sensors
RaspberryPi&Accessories
0

50HzSinePWMUsingTMS320F2812DSP
50HzSinePWMUsingTMS320F2812DSP
Tags:Programtogenerate50HzsinePWMUSINGTMS320F2812,PWMGENERATIONUSING
TMS320F2812,SINEPWMGENEARTION,
DownloadSourcecode

229

Ratethis(Logintoaddarating)
Overallrating
https://www.pantechsolutions.net/projectkits/generating50hzsinepwmusingtms320f2812

1/10

7/2/2015

50HzSinePWMUsingTMS320F2812DSP

50HzSINEPWMUSINGTMS320F2812DSP

Aim

ToGeneratethe50HzSINEPWMusinglookuptablein
TMS320F2812KIT.

Requirements

CCSv3.3
TMS320F2812KIT
USBCable
5VAdapter

Theory

PulseWidthModulation(PWM),isacommonlyusedtechniqueforcontrollingpowertoinertial
electricaldevices,madepracticalbymodernelectronicpowerswitches.
InTMS320F2812kit,TheF2812processorcorehaveanEventManagertogeneratethePWMs.The
Corehasa2Eventmanager,EVA&EVB.UptoeightPWMwaveforms(outputs)canbegenerated
simultaneouslybyeacheventmanager.So,totally16PWMsgetatF2812processorWhichismorethan
enoughtocontrolafivephasedevicecontrol.EVhavecertainRegisterstoperform.
TherearetwoGPtimersineachEVmodule.TheGPtimerx(x=1or2forEVA,x=3or4forEVB)
includes
A16bittimer,up/downcounter,TxCNT,forreadsorwrites
A16bittimercompareregister,TxCMPR(doublebufferedwithshadowregister),forreadsor
writes
A16bittimerperiodregister,TxPR(doublebufferedwithshadowregister),forreadsorwrites
A16bittimercontrolregister,TxCON,forreadsorwrites
Thesefourregistersareveryimportantandneededtogeneratethepwm.,somemore
register(GPTCONA,DBTCONA,COMCONA,ACTRA,CMPR1,CMPR2,CMPR3,CAPCONA)are
availabletoControlthePWM.
Example:Calculatingtheperiodvaluefor1Khzpwm
https://www.pantechsolutions.net/projectkits/generating50hzsinepwmusingtms320f2812

2/10

7/2/2015

50HzSinePWMUsingTMS320F2812DSP

Where,
SYSCLKOUT=125Mhz
HISPCP2
TPS1(LoadtheTPSValueinT1conregister).
TIPWM1000(1khZ).
T1PR=F424for1Khzperiodvalue.
T1CMPR=7A12.(50%DutyCycle)

SPWM

Sinusoidalpulsewidthmodulationisamethodofpulsewidthmodulationusedininverters.An
inverterproducesanACoutputvoltagefromaDCinputbyusingswitchingcircuitstosimulateasine
wavebyproducingoneormoresquarepulsesofvoltageperhalfcycle.Ifthewidthsofthepulsesare
adjustedasameansofregulatingtheoutputvoltage,theoutputissaidtobepulsewidthmodulated.
Withsinusoidalorsineweightedpulsewidthmodulation,severalpulsesareproducedperhalfcycle.The
pulsesneartheedgesofthehalfcyclearealwaysnarrowerthanthepulsesnearthecenterofthehalf
cyclesuchthatthepulsewidthsareproportionaltothecorrespondingamplitudeofasinewaveatthat
portionofthecycle.Tochangetheeffectiveoutputvoltage,thewidthsofallpulsesareincreasedor
decreasedwhilemaintainingthesinusoidalproportionality.Withpulsewidthmodulation,onlythe
widths(ontime)ofthepulsesaremodulated.Theamplitudes(voltage)duringthe"ontime"isconstant
unlessamultistepcircuitisused.Thelinetoneutralvoltageofa3phaseinverterhastwovoltagelevels.

https://www.pantechsolutions.net/projectkits/generating50hzsinepwmusingtms320f2812

3/10

7/2/2015

50HzSinePWMUsingTMS320F2812DSP

Procedure

Note:OnceyouinstalltheCodeComposerStudiov3.3software,thetwoiconswilldisplayindesktop
SetupCodeComposerStudiov3.3
CodeComposerStudio
1.OpenSetupCodeComposerStudiov3.3.
2.InSystemConfiguration,selecttheboardthenRemoveallyes
Infamily,selectC28xx.
Inplatform,selectxds100usbemulator.
InEndianness,selectlittle.
SelectF2812XDS100USBEmulatoraddsave&quitno.
Note:TheabovetwostepsonlyforfirsttimetosetuptheprocessorinCCS.
3.OpenCodeComposerStudiov3.3.
4.ProjectNew.
https://www.pantechsolutions.net/projectkits/generating50hzsinepwmusingtms320f2812

4/10

7/2/2015

50HzSinePWMUsingTMS320F2812DSP

Projectname:typetheprojectname.
Location:Browse,selecttheprojectlocation.
ProjectType:Executable(.out)
Target:TMS320C28XX.Finish.
5.FileNewSourcefile.
Typetheprograminuntitledwindow.
6.FileSave.
Browseourprojectlocationthentypeourprojectname.c(.cextensionismust)save.
Pastethefollowingtwocmdfilesinourprojectfolder.
F2812_EzDSP_RAM_lnk.cmd
DSP281x_Headers_nonBIOS.cmd
DSP281x_GlobalVariableDefs.c
DSP281x_DefaultIsr.c
DSP281x_PieCtrl.c
DSP281x_PieVect.c
8.ProjectAddfilestoproject.
Infileoftype:Allfiles
Ctrl+Selectthefollowingfiles
projectname.c
DSP281x_GlobalVariableDefs.c
DSP281x_DefaultIsr.c
DSP281x_PieCtrl.c
DSP281x_PieVect.
F2812_EzDSP_RAM_lnk.cmd
DSP281x_Headers_nonBIOS.cmd open.
9.ProjectBuildOption.
Incompilertab,selectPreprocessor
Includesearchpath(i):C:\tidcs\c28\DSP281x\v120\DSP281x_headers\include
https://www.pantechsolutions.net/projectkits/generating50hzsinepwmusingtms320f2812

5/10

7/2/2015

50HzSinePWMUsingTMS320F2812DSP

Inlinkertab,selectlibraries
Searchpath(i):C:\CCStudio_v3.3\C2000\cgtools\lib
Incllibraries(l):rts2800_ml.lib.
Inlinkertab,selectBasic
StackSize(stack):0x400ok.
10.ProjectBuild(or)Rebuildall.
11.ConnectionsforTMS320F2812KIT
Connect5vadptertoTMS320F2812kit.
ConnectusbcabletoTMS320F2812kitfrompc.
PowerontheTMS320F2812kit.
12.Debugconnect.
13.FileLoadProgramBrowseandselecttheprojectname.outfileopen
14.DebugGomain.
15.DebugRun.
16.SeetheoutputatCRObyconnectingprobepositiveterminalto(PortA)PWMpins&probe
negativeterminaltoGround.
17.DebugHalt.

Program

#include"DSP281x_Device.h"
voidInitSystem(void)
voidInitPieCtrl()
voidInitPieVectTable()
interruptvoidT1_Compare_isr(void)
unsignedintIndex1=0
signedintSine_Value1=0,Value1=0,Sine_Loc1=0
signedintlookup[256]=
https://www.pantechsolutions.net/projectkits/generating50hzsinepwmusingtms320f2812

6/10

7/2/2015

50HzSinePWMUsingTMS320F2812DSP

{0,807,1614,2420,3224,4027,4827,5624,6417,7207,7992,8773,9548,
10317,11080,11837,12586,13328,14061,14786,15502,16208,16905,

17592,18267,18932,19585,20226,20855,21472,22075,22665,23241,

23803,24351,24883,25401,25903,26390,26860,27315,27752,28173,

28577,28963,29332,29683,30016,30330,30627,30904,31163,31403,

31624,31826,32008,32171,32315,32439,32543,32627,32692,32737,

32761,32766,32751,32717,32662,32587,32493,32379,32246,32092,

31920,31728,31516,31286,31036,30768,30481,30175,29851,29510,

29150,28772,28377,27965,27536,27090,26627,26149,25654,25144,

24619,24079,23524,22955,22372,21775,21165,20542,19907,19260,

18601,17931,17250,16558,15856,15145,14425,13695,12958,12212,

11459,10700,9933,9161,8383,7600,6813,6021,5226,4427,3626,2822,

2017,1211,404,404,1211,2017,2822,3626,4427,5226,6021,

6813,7600,8383,9161,9933,10700,11459,12212,12958,13695,

14425,15145,15856,16558,17250,17931,18601,19260,19907,

20542,21165,21775,22372,22955,23524,24079,24619,25144,

25654,26149,26627,27090,27536,27965,28377,28772,29150,

29510,29851,30175,30481,30768,31036,31286,31516,31728,

31920,32092,32246,32379,32493,32587,32662,32717,32751,

32766,32761,32737,32692,32627,32543,32439,32315,32171,

32008,31826,31624,31403,31163,30904,30627,30330,30016,

29683,29332,28963,28577,28173,27752,27315,26860,26390,

25903,25401,24883,24351,23803,23241,22665,22075,21472,

20855,20226,19585,18932,18267,17592,16905,16208,15502,

14786,14061,13328,12586,11837,11080,10317,9548,8773,

7992,7207,6417,5624,4827,4027,3224,2420,1614,807,0
https://www.pantechsolutions.net/projectkits/generating50hzsinepwmusingtms320f2812

7/10

7/2/2015

50HzSinePWMUsingTMS320F2812DSP

}
voidmain()
{
InitSystem()
EALLOW
GpioMuxRegs.GPAMUX.all=0x0040
EDIS
InitPieCtrl()
InitPieVectTable()
EALLOW
PieVectTable.T1CINT=&T1_Compare_isr
EDIS
PieCtrlRegs.PIEIER2.bit.INTx5=1//enablePIEGP
Timer1compareinterrupt
IER=2
EINT
ERTM

EvaRegs.T1CNT=0x0000
EvaRegs.T1PR=0x186A
EvaRegs.T1CMPR=0x0C35
EvaRegs.GPTCONA.bit.TCMPOE=1//DriveT1/T2PWMbycompare
logic
EvaRegs.GPTCONA.bit.T1PIN=1//PolarityofGPTimer1Compare=
Activelow
EvaRegs.EVAIMRA.bit.T1CINT=1
EvaRegs.T1CON.all=0x1042
for()
}
voidInitSystem()
{
EALLOW
SysCtrlRegs.WDCR=0x0068//Setupthewatchdog
//0x0068todisabletheWatchdog,
Prescaler=1
//0x00AFtoNOTdisablethe
Watchdog,Prescaler=64
SysCtrlRegs.SCSR=0//WatchdoggeneratesaRESET
SysCtrlRegs.PLLCR.bit.DIV=10//SetuptheClockPLLtomultiply
by5
SysCtrlRegs.HISPCP.all=0x1//SetupHighspeedClockPrescalerto
divideby2
SysCtrlRegs.LOSPCP.all=0x2//SetupLowspeedCLockPrescalerto
divideby4
//Peripheralclockenablessetfortheselectedperipherals.
SysCtrlRegs.PCLKCR.bit.EVAENCLK=1
SysCtrlRegs.PCLKCR.bit.EVBENCLK=0
SysCtrlRegs.PCLKCR.bit.SCIAENCLK=0
SysCtrlRegs.PCLKCR.bit.SCIBENCLK=0
SysCtrlRegs.PCLKCR.bit.MCBSPENCLK=0
https://www.pantechsolutions.net/projectkits/generating50hzsinepwmusingtms320f2812

8/10

7/2/2015

50HzSinePWMUsingTMS320F2812DSP

SysCtrlRegs.PCLKCR.bit.SPIENCLK=0
SysCtrlRegs.PCLKCR.bit.ECANENCLK=0
SysCtrlRegs.PCLKCR.bit.ADCENCLK=0
EDIS
}
voidT1_Compare_isr(void)
{
Index1=Index1+327//////////////Step_freq=327
frequency
if(Index1>65536)Index1=0
Sine_Loc1=Index1>>8
Sine_Value1=lookup[Sine_Loc1]
Value1=(Sine_Value1*(long)2812)>>15
//////amplitude
EvaRegs.T1CMPR=Value1+0x0c35
EvaRegs.EVAIFRA.bit.T1CINT=1//ResetT1Compare
InterruptFlag

PieCtrlRegs.PIEACK.all=PIEACK_GROUP2//Acknowledgethis
interrupttoreceivemoreinterruptsfromgroup2
}

Result

Thus,the50HzSPWMwasgeneratedusingsinelookuptableinTMS320F2812Kit.
JointheWorld'sLargestTechnicalCommunity

SignUp

werespectyourprivacy.
StayConnected...Followus!

Resources
Blog
Videos
Presentations
BuyingGuides
Newsletters
AcrosstheWeb

https://www.pantechsolutions.net/projectkits/generating50hzsinepwmusingtms320f2812

9/10

7/2/2015

50HzSinePWMUsingTMS320F2812DSP

Twitter
Facebook
Linkedin
Google+
YouTube
Slideshare
Scribd
Stumbleupon
Pinterest
MoreInformation
WarrantyInformation
ReturnPolicy
CancellationOrder
Holidays
TermsforSoftwares
RoHS
Dealership
ShippingPolicy
Company
AboutUs
Termsofuse
Privacypolicy
Terms&Conditions
Careers
Events
SiteMap
Contactus
PantechProLabsTeam
CRMLogin
Copyright2015PantechProLabsIndiaPvtLtd
ContentonthissiteislicensedunderaCreativeCommonsAttributionNonCommercialNoDerivs3.0
UnportedLicense

https://www.pantechsolutions.net/projectkits/generating50hzsinepwmusingtms320f2812

10/10

Anda mungkin juga menyukai