..使用LabVIEWFPGA模块开发可编程自动化控制器学院:通信与电子工程学院班级:电子071学号:2007131010:欧洪材..BuildingProgrammableAutomationControllerswithLabVIEWFPGAOverviewProgrammableAutomationControllers(PACs)aregainingacceptancewithintheindustrialcontrolmarketastheidealsolutionforapplicationsthatrequirehighlyintegratedanaloganddigitalI/O,floating-pointprocessing,andseamlessconnectivitytomultipleprocessingnodes.NationalInstrumentsoffersavarietyofPACsolutionspoweredbyonecommonsoftwaredevelopmentenvironment,NILabVIEW.WithLabVIEW,youcanbuildcustomI/Ointerfacesforindustrialapplicationsusingadd-onsoftware,suchastheNILabVIEWFPGAModule.WiththeLabVIEWFPGAModuleandreconfigurableI/O(RIO)hardware,NationalInstrumentsdeliversanintuitive,accessiblesolutionforincorporatingtheflexibilityandcustomizabilityofFPGAtechnologyintoindustrialPACsystems.YoucandefinethelogicembeddedinFPGAchipsacrossthefamilyofRIOhardwaretargetswithoutknowinglow-levelhardwaredescriptionlanguages(HDLs)orboard-levelhardwaredesigndetails,aswellasquicklydefinehardwareforultrahigh-speedcontrol,customizedtimingandsynchronization,low-levelsignalprocessing,andcustomI/Owithanalog,digital,andcounterswithinasingledevice.YoualsocanintegrateyourcustomNIRIOhardwarewithimageacquisitionandanalysis,motioncontrol,and..industrialprotocols,suchasCANandRS232,torapidlyprototypeandimplementacompletePACsystem.TableofContents1.Introduction2.NIRIOHardwareforPACs3.BuildingPACswithLabVIEWandtheLabVIEWFPGAModule4.FPGADevelopmentFlow5.UsingNISoftMotiontoCreateCustomMotionControllers6.Applications7.ConclusionIntroductionYoucanusegraphicalprogramminginLabVIEWandtheLabVIEWFPGAModuletoconfiguretheFPGA(field-programmablegatearray)onNIRIOdevices.RIOtechnology,themergingofLabVIEWgraphicalprogrammingwithFPGAsonNIRIOhardware,providesaflexibleplatformforcreatingsophisticatedmeasurementandcontrolsystemsthatyoucouldpreviouslycreateonlywithcustom-designedhardware.AnFPGAisachipthatconsistsofmanyunconfiguredlogicgates.Unlikethefixed,vendor-definedfunctionalityofanASIC(application-specificintegratedcircuit)chip,youcanconfigureandreconfigurethelogiconFPGAs..foryourspecificapplication.FPGAsareusedinapplicationswhereeitherthecostofdevelopingandfabricatinganASICisprohibitive,orthehardwaremustbereconfiguredafterbeingplacedintoservice.Theflexible,software-programmablearchitectureofFPGAsofferbenefitssuchashigh-performanceexecutionofcustomalgorithms,precisetimingandsynchronization,rapiddecisionmaking,andsimultaneousexecutionofparalleltasks.Today,FPGAsappearinsuchdevicesasinstruments,consumerelectronics,automobiles,aircraft,copymachines,andapplication-specificcomputerhardware.WhileFPGAsareoftenusedinindustrialcontrolproducts,FPGAfunctionalityhasnotpreviouslybeenmadeaccessibletoindustrialcontrolengineers.DefiningFPGAshashistoricallyrequiredexpertiseusingHDLprogrammingorcomplexdesigntoolsusedmorebyhardwaredesignengineersthanbycontrolengineers.Withinthetest-fixturethetxoutputofthetransmittermoduleisloopedbacktotherxinputofthereceivermodule.Thisallowsthetransmittermoduletobeusedastestsignalgeneratorforthereceivermodule.Datacanbewritteninparallelformattothetransmittermoduleandloopedbackinserialformattotherxinputofthereceivermodule,anddatareceivedcanfinallybereadoutinparallelformatfromthereceivermodule.InordertoautomatethetestingoftheUARTasmuchaspossible,treeindependentVerilogtaskswerewrittenasfollows.TheVerilogtask“write_to_transmitter”holdsallnecessarystatementsrequiredtogenerat..easingleparalleldatawritesequencetothetransmittermodule.Datathatarewrittentothetransmitteruponexecutionofthe“write_to_transmitter”task,getlatchedinternaltothetest-fixtureforlateranalysis.TheVerilogtask“read_out_receiver”holdsallnecessarystatementsrequiredtogenerateasingleparalleldatareadoutsequencefromthereceivermodule.Datathatarereadoutofthereceiveruponexecutionofthe“read_out_receiver”task,getlatchedinternaltothetest-fixtureforlateranalysis.TheVerilogtask“compare_data”holdsallnecessarystatementsrequiredtocomparethepreviousdatawrittentothetransmittermodule,tothecorrespondingandmostrecentdatareceivedandreadoutfromthereceivermodule.Ifanydiscrepancyoccurs,the“compare_data”taskflagsforanerrorbywritingoutthedatavaluesthatwerewrittentothetransmittermodule,aswellasthecorrespondingdatavaluesthatwerereceivedbyandreadoutfromthereceivermodule.Thesimulationisimmediatelystoppedbythe“compare_data”taskifanydiscrepancyoccurs.BesidesthetreeabovementionedVerilogtasks,thetest-fixtureholdsthestatementstogeneratethemclkx16,themasterresetsignalsaswellasthe“txtorx”loopbackfeature.Thestatementsareconsideredtrivial,andwillnotbeillustratedhere,butcanbereferredtowithinthetest-fixtureitself.Thecoreofthetest-fixtureisabehaviorallevel“forloop”thatexecutesthetreeabovementionedVerilogtasksinordertowriteallpossibledatacombinationstothetransmitterandverifythatsamedatagetsproperlyreceived..bythereceiver.Theforloopisshowedbelowinfigure21.Nexttoportdefinitionscomesportdirections.Directionsarespecifiedasinput,outputorinout(bidirectional),andcanbereferredtointable1.Nexttothespecificationofportdirectionscomesd