




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
MATALAB 混合仿真平臺控制算法的概述MATALB 混合仿真平臺,即為將硬件引入到仿真回路里的半實物仿真系統(tǒng),可用于過程控制器的開發(fā)與測試。平臺提供了三種控制器的嵌入方法,尤其能用Matlab語言編寫,大大提高了平臺的靈活性。為了建立過程控制混合仿真試驗系統(tǒng),必須解決 PC機作為虛擬控制器設(shè)計環(huán)境的實現(xiàn)和在Windows 操作系統(tǒng)中實時控制的實現(xiàn)這兩個問題。我們先詳細闡述過程控制混合仿真試驗系統(tǒng)的實現(xiàn)原理;最后介紹平臺控制算法的嵌入方法,并通過實驗仿真驗證平臺的有效性。過程控制混合仿真平臺實現(xiàn)原理:(1)數(shù)值計算,MATLAB 提供了大約600多個數(shù)學(xué)和工程上常用的函數(shù)。這些函數(shù)的數(shù)值運算是針對矩陣操作優(yōu)化過的,可以使用它來代替底層編程語言。在保持同樣性能的情況下,編程工作量非常小,數(shù)值計算采用了LAPACK,BLAS,F(xiàn)FTW等優(yōu)秀數(shù)學(xué)函數(shù)庫,使得計算效率得到進一步的提升。MATLAB包含的主要數(shù)學(xué)函數(shù)有線性代數(shù)和矩陣運算、傅立葉變換和統(tǒng)計分析、微分方程求解、稀疏矩陣運算以及三角和其他初等數(shù)學(xué)運算等;除此之外,隨著Matlab的應(yīng)用領(lǐng)域不斷的擴大,補充了用于許多特定領(lǐng)域的函數(shù)。(2)算法開發(fā),強大的計算能力,方便易用的編程語言和豐富的數(shù)學(xué)函數(shù)使MATLAB最適于用于算法開發(fā)工作。典型的應(yīng)用包括:數(shù)據(jù)分析,信號處理,圖像處理,系統(tǒng)建模和高級算法研究等。不管用戶是使用已有的算法,還是自行開發(fā),MATLAB提供了一個通用的平臺。使用MATLAB 進行算法開發(fā)就像平時書寫數(shù)學(xué)表達式一樣。將用戶在 MATLAB中開發(fā)的算法結(jié)合到外部運行的系統(tǒng)中。一旦用戶的算法和仿真經(jīng)過了編寫和調(diào)試,MATLABCompiler和C/C++MathLibrary會將MATLAB應(yīng)用自動轉(zhuǎn)換成可移植C和C++代碼的工具。對于信號處理,控制系統(tǒng)設(shè)計和其他一些應(yīng)用,MATLAB工具箱提供了一系列先進的技術(shù)。工具箱遠遠超出了提供一些基本算法的范疇:他們提供了一個學(xué)習(xí),研究,創(chuàng)新前沿理論和技術(shù)的舞臺。提供的算法工具箱有NeuralNetworkToolbox、OptimizationToolbox、SystemIdentificationToolbox、RobustControlToolbox、ModelPredictiveControlToolbox、ControlSystemToolbox,F(xiàn)uzzylogicToolbox等。(3)數(shù)據(jù)分析與可視化,通過MATLAB,用戶可以分析所有類別的數(shù)據(jù)包括信號,圖像,多項式,時間歷程,多變量數(shù)據(jù)和線性系統(tǒng)等。從分析中總結(jié)出來的結(jié)9果可以作為將來進一步的算法和模型開發(fā)的基礎(chǔ)。 此外,用戶可以快速地將代碼片段和知識轉(zhuǎn)換成可以重復(fù)使用的自動分析例程, 不需要變量聲明和維數(shù)定義,可很快編寫出程序。MATLAB 提供了方便的數(shù)據(jù)訪問工具。例如, DataAcquisition Toolbox 允許用戶將實時的測量數(shù)據(jù)直接傳送到 MATLAB 進行分析,DatabaseToolbox 允許用戶訪問符合 ODBC和JDBC的數(shù)據(jù)庫,而M文件,C和Fortran程序中的處理文本和二進制文件的I/O函數(shù),則允許用戶處理任何格式的數(shù)據(jù)。MATLAB和相關(guān)的工具箱包含了科學(xué)計算中需要的專業(yè)圖形功能。從2-D原始數(shù)據(jù)的曲線圖到帶標(biāo)記的等值線圖和交互式的GUI,這些工具提供了模型可視化的能力,幫助用戶理解復(fù)雜的系統(tǒng)。特別是MATLAB提供了對3-D標(biāo)量和矢量可視化的能力,包括顯示等值面和流圖。這個能力使科學(xué)家和工程師們能夠?qū)Υ罅?、?fù)雜和多維的數(shù)據(jù)進行可視化。Matlab 實時仿真環(huán)境,RTW是MATLAB 提供的一個實時開發(fā)環(huán)境,是MathWork系列軟件的重要組成部分。RTW與MATLAB其他組成軟件的無縫連接,既滿足了設(shè)計者在系統(tǒng)概念與方案設(shè)計等方面的需求,也為系統(tǒng)的技術(shù)實現(xiàn)或完成不同功能的系統(tǒng)實時操作實驗提供了方便,并且為并行工程的實現(xiàn)創(chuàng)造了一個良好的環(huán)境。它能直接從Simulink的模型中產(chǎn)生優(yōu)化的、可移植的和個性化的代碼,并根據(jù)目標(biāo)配置自動生成多種環(huán)境下的程序,在硬件上運行動態(tài)系統(tǒng)模型,同時還支持基于模型的調(diào)試。使用RTW進行實時硬件的設(shè)計測試,用戶可以縮短開發(fā)周期,降低成本。當(dāng)用戶在Simulink環(huán)境下建模,并得到較滿意的仿真結(jié)果后,就可將RTW與一個快速原型化目標(biāo)(例如RTWT目標(biāo))聯(lián)合使用。該快速原型化目標(biāo)與用戶的物理系統(tǒng)連接在一起。用戶可使用Simulink模型作為連接物理目標(biāo)的接口,完成對系統(tǒng)的測試。RTW的實現(xiàn)機制是一個復(fù)雜的過程,這里僅從RTW自動構(gòu)建應(yīng)用程序的過程這一方面進行分析。RTW生成應(yīng)用程序的過程圖(modle為建立的simulink 模型的名稱)。RTW構(gòu)造應(yīng)用程序的過程由一個 M-file 的命令來控制,對于大多數(shù)目標(biāo),缺省命令是 make.rtw。其過程如下:1.模型分析,首先分析 Simulink 模型,分析的過程包括以下一些主要任務(wù)(1)數(shù)值化仿真參數(shù)和??騾?shù);(2)傳遞信號寬度和采樣時間;10(3)確定模塊中框圖的執(zhí)行次序;(4)計算工作向量的大小(主要是針對S-Functions ???。在這個過程中,RTW讀取模型文件modle.mdl,然后把它編譯為模型的內(nèi)部描述。這個描述存儲是與語言無關(guān)的 ASCII 文件,名稱為 model.rtw。我們可以把這個文件看作是下個過程的輸入,它將會在代碼生成后被自動刪除。2.調(diào)用TLC程序來生成C代碼,在這個階段,TLC把存儲在modle.rtw中的內(nèi)部模型描述轉(zhuǎn)換為特定的目標(biāo)代碼。TLC是一種解釋性的程序語言,設(shè)計這個程序語言的唯一的目的就是把模型描述轉(zhuǎn)變成代碼。在編譯過程中TLC執(zhí)行包含多個目標(biāo)文件(TLC腳本文件)和TLC函數(shù)庫的程序。目標(biāo)文件分為兩種:一種是系統(tǒng)目標(biāo)文件,一種是模塊目標(biāo)文件。這些目標(biāo)文件指定如何把 modle.rtw 用作輸入,從modle 中生成代碼。Real-Time Workshop 綁定了用于各種目標(biāo)環(huán)境下的系統(tǒng)目標(biāo)文件,圖3.5給出了所有可用的系統(tǒng)目標(biāo)文件。在本系統(tǒng)中,我們的目標(biāo)環(huán)境是windows,選定的快速原型化目標(biāo)為RTWT,那么在構(gòu)建程序前,指定rtwin.tlc作為我們在編譯過程用到的TLC腳本文件。3.生成定制Makefile,在這一步中,將產(chǎn)生定制的模板文件 (makefile),文件名稱是model.mk.。生成的makefi1e用來指導(dǎo)makeutility 編譯和鏈接模型,從而生成源代碼。 RTW 是從一個系統(tǒng)生成模板 (system templatemakefile)中生成modle.mk的,這個模板文件名稱是system.tmf(syetem是指被選擇目標(biāo)名稱),例如在上一步中,我們選擇了rtwin.tlc作為我們的系統(tǒng)目標(biāo)文件,那么同時也選定了一個叫做rtwin.tmf作為了我們的系統(tǒng)模板文件。模板文件(makefile)允許用戶定制編譯器、編譯器的選項和程序建立期間其他的信息,如果所用的編譯器不同,那么makefile文件也將不同,例如當(dāng)目標(biāo)為Windows時,系統(tǒng)目標(biāo)文件是rtwin.tlc,但是如果用visualC\C++的編譯器時,系統(tǒng)模板文件就是win_vc.tmf,而選用watcom時,系統(tǒng)的模板文件就是win_watc.tmf。molde.mk只是system.tmf的一個拷貝,可以修改此文件來定制構(gòu)建程序的過程。RTWT(Real-Time Windows Target)是MATLAB 提供和發(fā)行的一個基于RTW體系框架的附加產(chǎn)品,它可將PC機轉(zhuǎn)變?yōu)橐粋€實時系統(tǒng),其目的是引入一種快速原型設(shè)計的方法,用于控制器的實時測試和開發(fā)。在這個環(huán)境里,一臺PC機既作為宿主機,又作為目標(biāo)機存在。對于 RTWT,Simulink 和所11生成的代碼都運行在同一個 PC機上,其運行界面可使用戶 PC機的處理器運行在Windows NT 或者Windows 95/98/2000/XP 操作系統(tǒng)的同時采用RTW生成的代碼。RTWT 支持許多類型的 I/O 設(shè)備板卡(包括ISA和PCI兩種類型)。用戶只需要安裝相關(guān)的軟件、一個編譯器和 I/O 設(shè)備板卡,就可將一個 PC機用作實時系統(tǒng)并通過 I/O 設(shè)備與外部設(shè)備進行連接。內(nèi)核通過 I/Odriver 模塊作為接口,與 I/O 硬件進行通訊,并且檢查 I/Oboard 安裝的正確性。Simulink與實時程序之間的通訊是通過 Simulink的外部模式下的模塊來實現(xiàn)的。這個模塊直接與實時內(nèi)核建立通訊,來開始和終止可執(zhí)行程序的運行。Simulink模型和實時應(yīng)用程序之間保持著一個校驗機制,實時內(nèi)核使用這個校驗機制來判斷Simulink模型結(jié)構(gòu)在代碼生成的自動中是否和實時應(yīng)用程序的結(jié)構(gòu)保持一致。這就確保了在線修改模型參數(shù)的時候,Simulink模型的參數(shù)可以正確地映射到實時應(yīng)用程序相應(yīng)的參數(shù)上。RTWT對I/0board的支持,在混合仿真試驗系統(tǒng)中,數(shù)據(jù)的物理采集和物理控制輸出是靠I/O板卡完成的,那么實時應(yīng)用程序必須在軟件上具備數(shù)據(jù)采集和控制輸出的能力,也就說程序必須要和I/O板卡建立連接。這一功能的實現(xiàn)需要RTWT的支持。在Simulink模型中加入輸入輸出模塊,設(shè)置與實際板卡一致的參數(shù),然后編譯連接就可以了,需要說明的是,板卡的驅(qū)動程序并不真的參與編譯,而只是在程序運行期間,需要采集數(shù)據(jù)或者輸出數(shù)據(jù)時,進行動態(tài)連接。RTWT支持標(biāo)準(zhǔn)的I/Oboards。當(dāng)Simulink模型的運行期間,RTWT從一個或多個輸入通道獲得采樣數(shù)據(jù)作為模型的輸入,然后快速的處理數(shù)據(jù),再通過I/Oboards的輸出通道輸送到外部。RTWT提供了一個通用的Simulinkblocklibrary-I/Odriverblocklibrary.在Matlab命令中輸入rtwinlib便可以查看,I/Odriverblocklibrary提供了RTWT所支持的I/Oboard的驅(qū)動程序。通過各個block可以很方便的設(shè)置I/Oboards。這些block和其他的Simulinkblock一樣,都支持拖放操作。對于RTWT不支持的板卡,可利用S-function模塊自行開發(fā)板卡的驅(qū)動程序。I/Oboards是由其廠商提供,往往通過Switches或者Jumpers和廠商提供的軟件來設(shè)定baseddresses,voltagelevels和unipolarorbipolarmodes。在Real-TimeWindowsTarget 也提供了參數(shù)設(shè)定的功能,這個功能12的應(yīng)用與廠商提供的軟件有相同的靈活性。Simulink外部模式下實現(xiàn)參數(shù)傳遞的機制,在外部模式下Simutink不再對框圖表示的系統(tǒng)模型進行仿真,而是把當(dāng)前的參數(shù)值下載到目標(biāo)系統(tǒng)。在初始下載完成后,Simulink 保持在等待狀態(tài),只有在框圖中的參數(shù)發(fā)生改變或者接收到來自目標(biāo)機的參數(shù)才開始動作。當(dāng)框圖的參數(shù)發(fā)生改變, Simulink 調(diào)用一個外部接口 Mex文件,把新的參數(shù)值和其他一些信號傳遞給外部 Mex文件。外部接口 Mex 文件執(zhí)行InterProcessCommunication(IPC)通道一端的代碼,這個通道把Simulink過程(Mex文件執(zhí)行的過程)和外部可執(zhí)行性程序的過程連接在一起。Mex文件通過這個通道,把新的參數(shù)傳遞給外部程序。通道的另一端在外部程序中執(zhí)行,這一端把新的參數(shù)值寫到目標(biāo)參數(shù)結(jié)構(gòu)中。Simulink通過發(fā)送一個含有參數(shù)信息的訊息初始化下載操作。在C/S結(jié)構(gòu)中,Simulink作為客戶端,外部程序為服務(wù)端。兩個過程可以是遠程的,也可以是當(dāng)?shù)氐?。?dāng)客戶端和服務(wù)端是遠程的時候,通過TCP/IP方式傳遞數(shù)據(jù),當(dāng)客戶端與服務(wù)端是當(dāng)?shù)氐臅r候,采用共享內(nèi)存的方式傳送數(shù)據(jù),在本系統(tǒng)中采用的就是后一種方式。過程控制算法的實現(xiàn)方法,一個通用的仿真平臺,必須能夠方便的讓用戶加入自己的控制算法或控制系統(tǒng)設(shè)計方案,此過程控制混合仿真平臺提供了以下三種控制算法的嵌入方法:應(yīng)用Simulink提供的模塊搭建控制器模型,Simulink提供了各種各樣的模塊集合,在Simulink提供的圖形用戶界面上,只要進行簡單拖拉操作,就可利用這些模塊集合構(gòu)造出復(fù)雜的控制器模型。此外Simulink還提供了諸如模糊邏輯工具箱與神經(jīng)網(wǎng)絡(luò)工具箱之類的高級算法控制工具箱,利用這些工具箱,結(jié)合其他模塊,可搭建出各種與之相關(guān)的控制算法模型,如模糊PID、神經(jīng)網(wǎng)絡(luò)PID等,如以模糊PID控制器模型。利用工具箱的圖形用戶界面編輯控制器,可方便地設(shè)計智能控制器的直觀圖式系統(tǒng)。利用Simulink模塊搭建控制器模型靈活方便,它外表以方塊圖形式呈現(xiàn),且采用分層結(jié)構(gòu)。應(yīng)用Simulink模型作為控制器的可視化界面,不僅能讓用戶知道控制器具體環(huán)節(jié)的動態(tài)細節(jié),而且能讓用戶清晰地了解控制器中各器件、各子系統(tǒng)的信息交換,掌握各部分間的交互影響,為進一步分析改善控制器提供了便利條件。編寫C語言的S-函數(shù)實現(xiàn)控制算法,在實際應(yīng)用中,通常會發(fā)現(xiàn)有些算13法用普通的Simulink模塊不容易搭建,對此可以使用Simulink支持的S-函數(shù)格式,S-函數(shù)作為Simulink的擴展工具有固定的程序格式,可采用MATLAB、C/C++、Fortran等語言編寫。但由于在實時仿真過程中需要將Simulink模型轉(zhuǎn)化為C代碼并生成獨立文件,只有C/C++語言編寫的S-函數(shù)支持這一功能,因此在算法擴展中必須采用 C/C++語言編寫的S-函數(shù)。S-函數(shù)的工作原理和 Simulink 的仿真原理基本類似,每一個 Simulink模塊都具有輸入 u、輸出y、狀態(tài)x三個向量和其他一些對應(yīng)仿真各階段的方法。Simulink 通過循環(huán)調(diào)用模型中的各模塊的特定方法來完成諸如計算輸出值、更新離散狀態(tài)值、計算連續(xù)狀態(tài)微分等任務(wù)。在 S-函數(shù)中提供了與Simulink仿真不同階段相對應(yīng)的回調(diào)函數(shù)。初始化階段包括mdlInitializeSizes,mdlInitializeSampleTimes和mdlInitializeCondi模塊它們分別起初始化系統(tǒng)輸入維數(shù)輸出維數(shù)、狀態(tài)變量個數(shù),定義仿真采樣時間和初始化狀態(tài)變量的作用。輸出階段mdlOutputs模塊計算系統(tǒng)輸出。循環(huán)仿真階段mdlUpdate模塊計算更新系統(tǒng)當(dāng)前狀態(tài)變量的值。C語言S函數(shù)不僅可以將具有C語言描述功能的代碼嵌入Simulink模塊,以便于在Simulink中仿真,而且可以很容易的將C語言S-函數(shù)模塊功能代碼轉(zhuǎn)換成純C代碼。14MATALABhybridsimulationplatformcontrolalgorithmoverviewMATLABHybridsimulationplatform,thatis,thehardwareputintothesimulationloopintheloopsimulationsystemforprocesscontrolofthedevelopmentandtesting.Platformembeddedcontrollerprovidesthreemethods,inparticular,canuseMATLABlanguagehasgreatlyenhancedtheflexibilityoftheplatform.InordertobuildsimulationsystemforprocesscontrolsystemsmustbeaddressedasavirtualcontrollerPC,theenvironmentandintheWindowsoperatingsystemtoachievereal-timecontroltoachievethesetwoproblems.Wefirstelaboratesimulationsystemforprocesscontrolsystemprinciple,andfinallyintroducedtheembeddedplatformcontrolalgorithmmethodandtheexperimentresultsverifytheeffectivenessoftheplatform.Hybridsimulationplatformprocesscontroltheory:(1)numericalcalculation,basedonmorethan600MATLABprovidessomecommonlyusedmathematicalandengineeringfunctions.Thenumericalcomputationofthesefunctionsareoptimizedformatrixoperations,youcanuseittoreplacetheunderlyingprogramminglanguage.Maintainthesameperformanceinthecase,theprogrammingeffortisverysmall,valuecalculatedusingtheLAPACKandBLAS,FFTWotherexcellentmathlibrary,sothecalculationefficiencyisfurtherimproved.MATLABcontainsthemainmathematicalfunctionsarelinearalgebraandmatrixoperations,Fouriertransformandstatisticalanalysis,solvingdifferentialequations,sparsematrixoperations,andtrigonometricandotherelementarymathematics,etc.Inaddition,useofMATLABapplicationswithcontinuousexpandedtoaddafunctionforanumberofspecificareas.(2)Algorithmdevelopment,computingpower,easytouseprogramminglanguageand15richmathematicalfunctionstothemostsuitableforMATLABforalgorithmdevelopment.Typicalapplicationsinclude:dataanalysis,signalprocessing,imageprocessing,systemmodelingandadvancedalgorithmresearch.Whethertheuserisusingtheexistingalgorithmsordevelopingtheirown,basedonMATLABprovidesacommonplatform.MATLABforalgorithmdevelopmentusingthemathematicalexpressionofthesamewritingasusualUser-basedalgorithmsdevelopedinMATLABintegrationtoexternalsystemsrunning.Oncetheuser'salgorithmsandsimulationthroughthewritinganddebugging,MATLABcompilerandtheC/C++MathLibraryMATLABapplicationwillbeautomaticallyconvertedtoportable?andC+codetool.Forsignalprocessing,controlsystemdesignandotherapplications,MATLABtoolboxprovidingarangeofadvancedtechnology.Toolboxfarbeyondthescopeofprovisionofsomebasicalgorithms:theyprovidealearning,research,innovationandcutting-edgetheoryandtechnologyarena.Algorithmtoolboxtoprovideaneuralnetworktoolbox,optimizationtoolbox,systemidentificationtoolbox,robustcontroltoolbox,modelpredictivecontroltoolbox,thecontrolsystemtoolbox,fuzzylogictoolbox.(3)Dataanalysisandvisualization,throughtheMATLABsoftware,userscananalyzealltypesofdata,includingsignal,image,polynomials,timecourse,dataandmulti-variablelinearsystems.Fromtheanalysisresultscanbesummedupasamodelforthefurtherdevelopmentofthealgorithmandthebase.Inaddition,userscanquicklyconvertthecodefragmentandknowledgecanbereusedinautomatedanalysisroutines,novariabledeclarationsandthedefinitionofdimension,canwriteprogramsquickly.BasedonMATLABprovidesaconvenientdataaccesstools.Forexample,thedataacquisitiontoolboxallowsuserstosendreal-timemeasurementdatadirectlyintoMATLABforanalysis,databasetoolkittoallowuserstoaccessconsistentwiththeODBCandJDBCinthedatabase,whileMcandtheFortranlanguagedocumentsandproceduresinhandlingtextandbinaryfileI/Ofunction,thenallowtheusertohandleanyformat.16AndrelatedMATLABtoolboxcontainsascientificcomputingneedofprofessionalgraphics.Therawdatafromthetwo-dimensionalcurvetothecontourmapwithmarkersandinteractivegraphicaluserinterface,thesetoolsprovideamodelvisualizedcapabilitiestohelpusersunderstandcomplexsystems.Inparticular,providesaMATLAB-basedthree-dimensionalscalarandvectorvisualizationcapabilities,includingdisplayequivalencefaceandflowdiagram.Thiscapabilityenablesscientistsandengineerstoalargenumberofcomplexandmultidimensionaldatavisualization.MATLABreal-timesimulationenvironment,RTWistoprovideareal-timebasedonMATLABothercomponentsofthesoftwareforseamlessconnection,notonlytomeetthedesignersinthesystemconceptandprogramdesignneeds,thetechnologyforthesystemorperformdifferentfunctionsinreal-timeoperatingsystemprovidestheconvenienceofexperiments,andforimplementationofconcurrentengineeringtocreateagoodenvironment.ItdirectlyfromtheSIMULINKsimulationmodelproducesoptimized,portableandpersonalizedcode,andautomaticallygenerateavarietyofconfigurationsdependingonthetargetundertheprogramenvironment,thehardwarerunningdynamicsystemmodelalsosupportsmodel-baseddebug.Real-timeusingtheRTWofthedesignoftesthardware,userscanshortenthedevelopmentcycleandreducecosts.WhentheusermodelinSIMULINKenvironmentandgetsatisfactorysimulationresults,canbeaRTWwiththegoalofrapidprototyping(suchasRTWTtarget)jointuse.Thegoalofrapidprototypingofphysicalsystemsandusersconnected.UserscanusetheSIMULINKmodelastheinterfacetoconnectthephysicaltargettocompletesystemtesting.RTWimplementationmechanismisacomplexprocess,whereonlyfromtheRTWprocessautomatedbuildingapplicationsthatwereanalyzed.RTWgeneratedapplicationprocessdiagram(modelfortheestablishment17oftheSIMULINKname).RTWconstructionapplicationprocessbyanM-fileinordertocontrolformostofthetarget,thedefaultcommandismake.rtw.Theprocessisasfollows:1.model,firstanalyzestheSIMULINKmodeltoanalyzetheprocessincludesthefollowingmaintasksNumericalsimulationparametersandmoldingparameters;(2)Passingthesignalwidthandsamplingtime;determinethemoduleblockdiagramoftheimplementationoftheorder;Calculationofthesizeofthevector(mainlyforS-Functionsmodulebox).Inthisprocess,RTWreadthemodelfilemodle.mdl,andthencompileitasamodelofinternaldescription.ThisdescriptionisstoredinASCIIfilesandlanguage-independent,namemodel.rtw.Wecanusethatfileasinputforthenextprocess,itwillbeautomaticallydeletedafterthecodegeneration.2.callTLCprogramtogenerateCcode,atthisstage,TLCstoredinmodle.rtwintheinternalmodeldescriptionintoaspecificobjectcode.TLCisaninterpretedprogramminglanguage,programminglanguagedesignthattheonlypurposeistomodeldescriptionintothecode.TLCinthecompilationprocessoftheimplementationofmultipleobjectfiles(TLCscriptfile),andTLClibraryprocedures.Objectfileisdividedintotwotypes:oneisthetargetfilesystem,oneisthemoduleobjectfile.Thetargetfiletospecifyhowtomodle.rtwusedasaninput,generatecodefrommodle.Real-TimeWorkshoptargetbindingenvironmentforavarietyoftargetfilesystem,Figure3.5showsalltheavailablesystemtargetfile.Inthissystem,ourtargetenvironmentiswindows,theselectedtargetrapidprototypingRTWT,thenthebuildingprocessbefore,wespecifyrtwin.tlcasTLCusedinthecompilationprocessscriptfile.3.GeneratecustomizedM-file,inthisstep,willhaveacustomtemplate18file(M-file),thefilenameismodel.mk..Generatedmakefi1eusedtoguidethemakeutilitytocompileandlinkmodel,whichgeneratessourcecode.RTWisasystem-generatedtemplate(systemtemplateM-file)generatedmodle.mk,thistemplatefilenameissystem.tmf(syetemisthetargetnameisselected),suchasinthepreviousstep,weselectedrtwin.tlcasOursystemtargetfile,alsocalledrtwin.tmfselectedoursystemasatemplatefile.Templatefile(M-file)allowsuserstocustomizethecompiler,compileroptionsandotherinformationduringtheprocesstoestablish,ifthecompilerusedindifferent,thenthemakefilefilewillbedifferent,suchaswhenthetargetisWindows,thesystemtargetfileisrtwin.tlc,butwiththevisualC\C++compiler,thesystemtemplatefileiswin_vc.tmf,andchoosewatcom,thesystemofthetemplatefileiswin_watc.tmf.molde.mkonlysystem.tmfacopy,youcanmodifythisfiletocustomizethebuildprocessoftheprocess.RTWT(Real-TimeWindowsTarget)istoprovideanddistributeaMATLABRTWsystemframeworkbasedontheadditionalproductsareshipping將turnitsmachinesintoasaPCsystemwiththeaimofrapidprototypingonekindofmethodsforKongreal-timetestinganddevelopment.Inthisenvironment,aPC,bothasahost,butalsoasthetargetmachinethere.ForRTWT,SIMULINKandthegeneratedcoderunningonthesamePC,theinterfaceallowsuserstorunPC-processorrunningonWindowsNTorWindows95/98/2000/XPoperatingsystem,whilethecodegeneratedbyRTW.RTWTsupportsmanytypesofI/Odeviceboards(includingthetwotypesofISA andPCI). Usersonly needto install related software, acompiler andI/Odevicecard,aPCmachine canbeusedforreal-timesystemandthrough I/Odevicesandexternal devicestoconnect.Corethrough theI/ Odriver module astheinterface andI/ Ohardware,communication,andtocheckI/Oboardinstallationiscorrect.SIMULINK and Real-time communication between processes is19throughtheSIMULINKexternalmode,themoduletoachieve.Thismoduleistoestablishcommunicationdirectlywiththereal-timekerneltostartandterminatetheoperationofanexecutableprogram.SIMULINKmodelsandreal-timeapplicationshavemaintainedacheckingmechanismtocheckreal-timekerneltousethismechanismtodeterminetheSIMULINKmodelstructureintheautomaticcodegenerationandreal-timewhetherthestructureoftheapplicationconsistent.Thisensuresthatthelinechangeswhenthemodelparameters,SIMULINKmodelparameterscanbecorrectlymappedtothereal-timeapplication,thecorrespondingparameters.RTWTontheI/0board'ssupport,inamixedsimulationsystems,datacollectionandphysicalcontrolofthephysicaloutputbyI/Oboardtocomplete,thenthereal-timeapplicationsmusthavethesoftwareoutputdataacquisitionandcontrolcapability,alsosaidthatprocedureshavetobe,andI/Oboardtoestablishaconnection.TherealizationofthisfunctionrequiresRTWTsupport.SIMULINKmodel,addinginputandoutputmodules,settingandactualcardYiDi,andthenbuildtheconnectionisavailable,andneedtobeexplainedthattheboardsproceduredoesnotitisinvolvedincompilation,butonlyduringtheprogram,needtodataoroutputdatacollectedwhenthedynamicconnection.RTWTsupportstandardI/Oboards.WhentheSIMULINKmodeltoruntime,RTWTfromoneormoreinputchannelsweresampleddataasmodelinput,andthenprocessthedataquickly,andthenthroughtheI/Oboardstotheexternaloutputchanneldelivery.RTWTprovidesagenericSIMULINKblocklibrary-I/Odriverblocklibrary.IntheMATLABcommandinputcansee,I/OdriverblocklibraryprovidesRTWTsupportedI/Oboarddriver.EachblockcanbeeasilybysettingI/Oboards.Theblockand,likeotherSIMULINKblock,supportdraganddrop.DonotsupporttheboardforRTWTcanuseS-functionmodulesdevelopedbyboarddriver.I/Oboardsisprovidedbycompanies,oftenthroughtheSwitchesor20Jumpersandsoftwarevendorstosetbaseddresses,voltagelevels,andbipolarmodes.InReal-TimeWindowsTargetalsooffersthefunctionsoftheparametersset,thefunctionofapplicationandsoftwarevendorshavethesameflexibility.SIMULINKexternalmode,parameterpassingmechanismstoachieveintheexternalmodeSIMULINKnolongerasystemblockdiagrammodelsimulation,butthecurrentvalueoftheparameterdownloadtothetargetsystem.Aftertheinitialdownloadiscomplete,SIMULINKtokeepwaitingforthestate,onlyintheblockdiagramoftheparameterschangeorreceiveparametersfromthetargetmachinebegantomove.Whentheparameterschangediagram,SIMULINKcallsanexternalinterfaceM-file,thenewparametervaluesandsomeothersignaltoanexternalM-file.ExternalinterfaceM-fileexecutionInterProcessCommunication(IPC)channelatoneendofthecode,theaccesstoSIMULINKprocess(M-fileexecutionprocess)andexternalproceduresexecutableprocesstogether.M-filethroughthischannel,thenewparametertotheexternalprogram.Channeltheotherendoftheexternalprogramexecution,theclientwritesthenewvalueoftheparameterobjectparameterstructure.SIMULINKinformationbysendingamessagecontainingtheinitializationparameterdownloadoperation.IntheC/Sstructure,SIMULINKasaclient,server-sideexternalprocedures.Twoprocessescanberemote,itcanbelocal.Whentheclientandserverisremote,when,throughtheTCP/IPmodetransmissionofdata,whentheclientandtheserverislocaltime,usesharedmemory,transmissionofdata,thesystemisusedinthelatterway.Implementationofprocesscontrolalgorithms,acommonsimulationplatform,toJean-userstoeasilyaddtheirowncontrolalgorithmorcontrolsystemdesign,processcontrolhybridsimulationplatformprovidesthefollowingthreecontrolalgorithmembeddedmethods:21AppliedSIMULINKcontrollermodelprovidesamodulestructure,SIMULINKprovidesawiderangeofmodulessetintheSIMULINKprovidesagraphicaluserinterface,aslongasasimpledraganddropoperation,youcanusethesemodulestoconstructacomplexsetofcontrollermodel.Inaddition,SIMULINKalsoprovidesatoolbox,suchasfuzzylogicandneuralnetworktoolboxoftheseniorclassofalgorithmcontroltoolbox,usethetoolbox,incombinationwithothermodules,canbuildavarietyofassociatedcontrolalgorithmmodel,suchasfuzzyPID,PIDneuralnetwork,etc.,suchasthefuzzyPIDcontrollermodel.Usegraphicaluserinterfacetoolkiteditcontroller,intelligentcontrol
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 創(chuàng)意廣告長期合同范本
- 二手房自行購買合同范本
- 買賣企業(yè)房產(chǎn)合同范例
- 農(nóng)民種地出租合同范本
- 包裝木箱供貨合同范本
- 北京政府采購合同范本
- 出售轉(zhuǎn)讓凍干機合同范本
- 分攤費用合同范本
- 企業(yè)生產(chǎn)訂單合同范本
- 分期購車購車合同范本
- 幕墻工程項目管理方案手冊施工管理方案標(biāo)準(zhǔn)化手冊
- 常用臨床檢驗
- VDA6.3 基本知識培訓(xùn)教材
- 人類行為與社會環(huán)境全套課件
- 上課用03工程中的價值利益與公正課件
- 司機安全培訓(xùn)課件
- 公司年度虧損專項治理方案
- 鋼結(jié)構(gòu)施工進度計劃保障措施
- 低鉀血癥與橫紋肌溶解綜合征
- 交通運輸設(shè)備整套課件匯總完整版電子教案(全)
- 《汽車概論》第二版全套電子課件完整版ppt整本書電子教案最全教學(xué)教程整套課件
評論
0/150
提交評論