CGetting Started.docx

上传人:b****5 文档编号:7029518 上传时间:2023-01-16 格式:DOCX 页数:17 大小:1.20MB
下载 相关 举报
CGetting Started.docx_第1页
第1页 / 共17页
CGetting Started.docx_第2页
第2页 / 共17页
CGetting Started.docx_第3页
第3页 / 共17页
CGetting Started.docx_第4页
第4页 / 共17页
CGetting Started.docx_第5页
第5页 / 共17页
点击查看更多>>
下载资源
资源描述

CGetting Started.docx

《CGetting Started.docx》由会员分享,可在线阅读,更多相关《CGetting Started.docx(17页珍藏版)》请在冰豆网上搜索。

CGetting Started.docx

CGettingStarted

C2000GettingStarted

Introduction

TheTexasInstrumentsC28xfamilyofdigitalsignalprocessorshasbeendesignedtoimplementcontrolapplications,forexample,digitalmotorcontrolandun-interruptiblepowersupplies.ThischapterdescribesabasicapplicationusingtheTMS320F2812.

Objectives

∙DesignaverysimpleprojectfortheTexasInstrumentsC28xfamilyofDSPdevicesusingMATLAB®andSimulink®.

∙Runtheprojectinreal-timeontheTexasInstrumentsF2812ezDSP.

Requirements

IndevelopingthisLaboratory,thefollowinghardwareandsoftwarewereused:

∙MATLABR2006bwithEmbeddedTargetforTIC2000.

∙CodeComposerStudio(CCS)3v1.

∙SpectrumDigitalezDSPF2812Hardware

∙A1kOhmresistor

StartingaNewProject

Thereareseveralstagestofollowinordertoimplementaproject.Thesearenowexplained.

ConnectingtheF2812ezDSP

ForMATLABandSimulinktoruncorrectly,youneedtoruntheF2812ezDSP.

1.ConnecttheF2812hardwaretotheparallelportofthecomputerandturnonthesupplytotheboard.Whentheboardispowered,thetwogreenLEDlightsontheboardwillcomeonduringself-test.

2.StartCodeComposerStudioforF2812ezDSPanduseDebug->Connect

 

Figure1–StartupScreenforCodeComposerStudio(CCS)

CreatinganewMATLABModel

3.StartMATLAB7.3.0R2006b.InthetoplefthandcorneroftheMATLABscreen,selectFile->New->Model.

Figure2–ANewMATLABModel

Thefollowingscreenwillappear.

Figure3–AnEmptyMATLABModel

SavingtheNewModel

4.Savethenewmodelas“my_model.mdl”.

Figure4-Savingthenewmodel

OpeningtheLibraryBrowser

5.SelectView->LibraryBrowser

Figure5–SelectingtheLibraryBrowser

TheSimulinkLibraryBrowser

6.Alistofavailableblockswillappear.Weareparticularlyinterestedinthe“EmbeddedTargetforTIC2000DSP”.Clickonthisselection.

Figure6-TheSimulinkLibraryBrowser

SelectingTargetPreferences

7.FromtheC2000TargetPreferences,select“F2812ezDSP”.Drag-and-droptheiconontothenewmodel.

Figure7–SelectingTargetPreferences

Whenthefollowingscreenappears,itisimportanttoselect“Yes”.

Figure8-InitializingSimulationParameters

AddingC281xChipSupport

8.ReturntotheSimulinkLibraryBrowser.Select“C281xDSPChipSupport”.ThisliststheinternalblockswithintheC281x.

Figure9–C281xDSPChipSupport

AddingaDigitalOutput

9.Drag-and-dropthe“DigitalOutput”blockontothemodel.

Figure10–AddingtheDigitalOutputBlock

SettingtheOutputParameters

10.Doubleclickonthe“GPIOD0”block.

Figure11–SettingtheOutputBlockParameters

SettingtheOutputPortBits

11.Select“IOPort”GPIOFfromthepull-downmenu.Deselect“Bit0”(removethefromthebox).Select“Bit14”sothatawillappearinthebox.Clickon“OK”.

Figure12–SettinguptheOutputPortBits

AddingaConstant

12.Fromthe“SimulinkLibraryBrowser”,select“CommonlyUsedBlocks”.Highlight“Constant”.Drag-and-dropthe“Constant”blockontothemodel.

Figure13–AddingaConstant

SettingtheConstantParameters

13.Doubleclickonthe“Constant”block.Selectthe“SignalDataTypes”tab.Makethedatatype“Boolean”.Clickon“OK”.HereaBooleanvariablehasoneoftwovalues,0or1.

Figure14–SettingtheConstantType

14.

Selectthe“Main”tab.Changethe“Constantvalue”to0.Clickon“OK”.

Figure15–SettingtheConstantValue

FinishingtheFirstModel

15.Clickontherighthandsideofthe“Constant”block,thendragthecursortothe“GPIOD0”block.Thiswillconnectthetwoblockstogether.

Figure16–ConnectingtheBlocks

YourfirstSimulinkmodelisnowcomplete!

YouarenowreadytoconvertitintoaformthatyoucanrunontheezDSPF2812.

BuildingtheModel

SelectTools->Real-TimeWorkshop->BuildModel.

Figure17–BuildingtheModel

BuildinProgress

MATLABwillcreateanewprojectinCodeComposerStudioandgeneratethecodeforit.Thereisnoneedtodoanyprogramming!

Figure18–BuildinProgress

RunningtheModel

ThemodelhasnowbeenbuiltandisrunningontheF2812EZDSP.TheDS2LEDontheezDSPboardshouldnowbeoff.

Figure19–RunningtheApplication

CheckingtheGeneratedCode

Expandthe“my_project.pjt(Custom_MW)window.Clickon“my_model.c”.Thiscontainsthegeneratedcodefortheproject.CanyouseethelinewheretheconstantisfedintoGPIO?

Figure20–CheckingtheGeneratedCode

ModifyingtheModel

Sofar,wehaveonlyimplementedaverybasicmodel.Letusnowaddtoit.

TurningtheDS2LEDonagain

ToturntheDS2LEDonagain,changethevalueofthe“Constant”inthemodel.

ChangingtheConstant

Returnto“my_model.mdl”.Doubleclickonthe“Constant”block.Changethe“Constantvalue”to1thenclickon“OK”.

Figure21–ChangingtheConstantto1

BuildtheModelAgain

SelectTools->Real-TimeWorkshop->BuildModel.Thiswillbuildthemodelandrunit.

 

Figure22–Re-buildingtheModel

AddinganInputLine

Sofar,theLEDhasbeenactivatedcontinuously,becauseitwasbeingdrivenbyaconstant.WewillnowaddadigitalinputportthatwillcontrolthestateoftheLEDusingexternalhardware.

OpeningtheLibraryBrowser

SelectView->LibraryBrowser->C281xDSPChipSupport.Highlightdigitalinput.

Figure23–SelectingtheDigitalInputBlock

Drag-and-dropthe“DigitalInput”blockontothemodel.

SettingtheInputParameters

Drag-and-dropthe“product”blockontothemodel.

Setthe“IOPort”fieldto“GPI0A”.

Select“Bit0”byputtingainthebox.

Figure24–SettingtheInputParameters

Checkthatthe“Sampletime”is“inf”.

Makethe“Datatype”to“Boolean”.

Clickon“OK”.

AddingSomeSignalProcessing

Atthemomentwehaveaverysimplesystemthatdirectlyfeedstheinputstraighttotheoutput.Itisnowtimetoaddsomesimplesignalprocessing.

AddingtheNOTOperator

Thelogical“NOT”operatorturnstheinputupside-down

∙Wheninput=0,output=1

∙Wheninput=1,output=0.

SelectView->CommonlyUsedBlocks.Highlightthe“LogicOperator”

Figure25–AddingaLogicalOperator(NOT)

Drag-and-dropthe“LogicalOperator”blockontothemodel.

SettingtheOperatorType

Doubleclickonthe“LogicalOperator”block.Changethe“Operator”typetoNOT.Clickon“OK”.

Figure26–ChangingtheLogicOperatorType

CompletingtheModel

Jointheblockstogethertocompletethemodel.

Figure27–CompletingtheModel

Re-buildingtheModel

Re-buildthemodelusingTools->Real-TimeWorkshop->Build.

RunningtheModel

Connecta1kOhmresistorbetweenConnectorP8pin9(GPIOAbit0)andConnectorP8pin19(Ground).TheDS2LEDwillnowbeoff.

RemovetheresistorfromtheezDSPF2812board.TheDS2LEDwillnowbeon.

Figure28–PlugginginaResistorintotheezDSPF2812

Congratulations!

YouhavenowimplementedyourfirstprojectusingSimulinkandtheTexasInstrumentsC28x.

Youmaybewonderingwhyyouhaveuseda1kOhmresistortocontroltheinput.Itwouldbepossibletoconnectthedigitalinputtogroundviaa0Ohmlink(apieceofwire).Thisisnotrecommended.TheGPIOontheF2812canbeconfiguredasbothinputsandoutputs.Ifyouputa0Ohmlinkonadigitaloutputitcanbedamagedbecauseitwilltaketoomuchcurrent.However,a1kOhmresistorlimitsthecurrenttoafewmAandpreventsdamagetotheF2812.

ThingstoTry

UseaDifferentInputPin

Useadifferentinputpintoconnecttheinputresistor.Itwillbenecessarytomakechangestothe“DigitalInput”block.

UseMultipleInputs

UsetwoinputpinsandturntheDS2LEDonifeitherinputislow.Youwillneedtousealogicaloperator.

References

[1]SpectrumDigitalIncorporated,"eZdspTMF2812TechnicalReference"Rev.F,September2003.()

MATLABandSimulinkareregisteredtrademarksofTheMathWorks,Inc.Seeforalistofadditionaltrademarks.Otherproductorbrandnamesmaybetrademarksorregisteredtrademarksoftheirrespectiveholders.

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 初中教育 > 语文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1