matlab-simulink中文帮助手册
matlab simulink-实验1-simulink入门说明书

Experiment 1Introduction to Simulink1.1 ObjectiveThe objective of Experiment #1 is to familiarize the students with simulation of power electronic circuits in Matlab/Simulink environment. Please follow the instructions in the laboratory manual.1.2 Simulink Basics TutorialSimulink is a graphical extension to MATLAB for the modeling and simulation of systems. In Simulink, systems are drawn on screen as block diagrams. Many elements of block diagrams are available (such as transfer functions, summing junctions, etc.), as well as virtual input devices (such as function generators) and output devices (such as oscilloscopes). Simulink is integrated with MATLAB and data can be easily transferred between the programs. In this tutorial, we will introduce the basics of using Simulink to model and simulate a system.1.2.1 Starting SimulinkSimulink is started from the MATLAB command prompt by entering the following command: >>simulinkAlternatively, you can click on the "Simulink Library Browser" button at the top of the M ATLAB command window as shown below:The Simulink Library Browser window should now appear on the screen. Most of the blocks needed for modeling basic systems can be found in the subfolders of the main "Simulink" folder (opened by clicking on the "+" in front of "Simulink"). Once the "Simulink" folder has been opened, the Library Browser window should look like:1.2.2 Basic ElementsThere are two major classes of elements in Simulink: blocks and lines. Blocks are used to generate, modify, combine, output, and display signals. Lines are used to transfer signals from one block to another. BlocksThe subfolders underneath the "Simulink" folder indicate the general classes of blocks available for us to use:•Continuous: Linear, continuous-time system elements (integrators, transfer functions, state-space models, etc.)•Discrete: Linear, discrete-time system elements (integrators, transfer functions, state-space models, etc.)•Functions & Tables: User-defined functions and tables for interpolating function values•Math: Mathematical operators (sum, gain, dot product, etc.)•Nonlinear: Nonlinear operators (coulomb/viscous friction, switches, relays, etc.)•Signals & Systems: Blocks for controlling/monitoring signal(s) and for creating subsystems•Sinks: Used to output or display signals (displays, scopes, graphs, etc.)•Sources: Used to generate various signals (step, ramp, sinusoidal, etc.)Blocks have zero to several input terminals and zero to several output terminals. Unused input terminals are indicated by a small open triangle. Unused output terminals are indicated by a small triangular point. The block shown below has an unused input terminal on the left and an unused output terminal on the right.LinesLines transmit signals in the direction indicated by the arrow. Lines must always transmit signals from the output terminal of one block to the input terminal of another block. One exception to this is that a line can tap off of another line. This sends the original signal to each of two (or more) destination blocks, as shown below:Lines can never inject a signal into another line; lines must be combined through the use of a block such as a summing junction.A signal can be either a scalar signal or a vector signal. For Single-Input, Single-Output systems, scalar signals are generally used. For Multi-Input, Multi-Output systems, vector signals are often used, consisting of two or more scalar signals. The lines used to transmit scalar and vector signals are identical. The type of signal carried by a line is determined by the blocks on either end of the line.1.2.3 Building a SystemTo demonstrate how a system is represented using Simulink, we will build the block diagram for a simple model consisting of a sinusoidal input multiplied by a constant gain, which is shown below:This model will consist of three blocks: Sine Wave, Gain, and Scope. The Sine Wave is a Source Block from which a sinusoidal input signal originates. This signal is transferred through a line in the direction indicated by the arrow to the Gain Math Block. The Gain block modifies its input signal (multiplies it by a constant value) and outputs a new signal through a line to the Scope block. The Scope is a Sink Block used to display a signal (much like an oscilloscope).We begin building our system by bringing up a new model window in which to create the block diagram. This is done by clicking on the "New Model" button in the toolbar of the Simulink Library Browser (looks like a blank page).Building the system model is then accomplished through a series of steps:1.The necessary blocks are gathered from the Library Browser and placed in the model window.2.The parameters of the blocks are then modified to correspond with the system we are modeling.3.Finally, the blocks are connected with lines to complete the model.Each of these steps will be explained in detail using our example system. Once a system is built, simulations are run to analyze its behavior.Gathering BlocksEach of the blocks we will use in our example model will be taken from the Simulink Library Browser. To place the Sine Wave block into the model window, follow these steps:1.Click on the "+" in front of "Sources" (this is a subfolder beneath the "Simulink" folder) todisplay the various source blocks available for us to use.2.Scroll down until you see the "Sine Wave" block. Clicking on this will display a shortexplanation of what that block does in the space below the folder list:3. To insert a Sine Wave block into your model window, click on it in the Library Browser and drag the block into your workspace.The same method can be used to place the Gain and Scope blocks in the model window. The "Gain" block can be found in the "Math" subfolder and the "Scope" block is located in the "Sink" subfolder. Arrange the three blocks in the workspace (done by selecting and dragging an individual block to a new location) so that they look similar to the following:Modifying the BlocksSimulink allows us to modify the blocks in our model so that they accurately reflect the characteristics of the system we are analyzing. For example, we can modify the Sine Wave block by double-clicking on it. Doing so will cause the following window to appear:This window allows us to adjust the amplitude, frequency, and phase shift of the sinusoidal input. The "Sample time" value indicates the time interval between successive readings of the signal. Setting this value to 0 indicates the signal is sampled continuously.Let us assume that our system's sinusoidal input has:•Amplitude = 2•Frequency = pi•Phase = pi/2Enter these values into the appropriate fields (leave the "Sample time" set to 0) and click "OK" to accept them and exit the window. Note that the frequency and phase for our system contain 'pi' (3.1415...). These values can be entered into Simulink just as they have been shown.Next, we modify the Gain block by double-clicking on it in the model window. The following window will then appear:Note that Simulink gives a brief explanation of the block's function in the top portion of this window. In the case of the Gain block, the signal input to the block (u) is multiplied by a constant (k) to create the block's output signal (y). Changing the "Gain" parameter in this window changes the value of k.For our system, set k = 5. Enter this value in the "Gain" field, and click "OK" to close the window.The Scope block simply plots its input signal as a function of time, and thus there are no system parameters that we can change for it. We will look at the Scope block in more detail after we have run our simulation.Connecting the BlocksFor a block diagram to accurately reflect the system we are modeling, the Simulink blocks must be properly connected. In our example system, the signal output by the Sine Wave block is transmitted to the Gain block. The Gain block amplifies this signal and outputs its new value to the Scope block, which graphs the signal as a function of time. Thus, we need to draw lines from the output of the Sine Wave block to the input of the Gain block, and from the output of the Gain block to the input of the Scope block.Lines are drawn by dragging the mouse from where a signal starts (output terminal of a block) to where it ends (input terminal of another block). When drawing lines, it is important to make sure that the signal reaches each of its intended terminals. Simulink will turn the mouse pointer into a crosshair when it is close enough to an output terminal to begin drawing a line, and the pointer will change into a double crosshair when it is close enough to snap to an input terminal. A signal is properly connected if its arrowhead is filled in. If the arrowhead is open, it means the signal is not connected to both blocks. To fix an open signal, you can treat the open arrowhead as an output terminal and continue drawing the line to an input terminal in the same manner as explained before.Properly Connected SignalWhen drawing lines, you do not need to worry about the path you follow. The lines will route themselves automatically. Once blocks are connected, they can be repositioned for a neater appearance. This is done by clicking on and dragging each block to its desired location (signals will stay properly connected and will re-route themselves).After drawing in the lines and repositioning the blocks, the example system model should look like:In some models, it will be necessary to branch a signal so that it is transmitted to two or more different input terminals. This is done by first placing the mouse cursor at the location where the signal is to branch. Then, using either the CTRL key in conjunction with the left mouse button or just the right mouse button, drag the new line to its intended destination. This method was used to construct the branch in the Sine Wave output signal shown below:The routing of lines and the location of branches can be changed by dragging them to their desired new position. To delete an incorrectly drawn line, simply click on it to select it, and hit the DELETE key.1.2.4. Running SimulationsNow that our model has been constructed, we are ready to simulate the system. Before starting simulation, we need to set the simulation parameters. To do this, go to the Simulation menu and click on Configuration Parameters. The Configuration Parameters dialog box opens on your desktopEnter desired stop time (e.g. 100 microseconds), and change the Solver Options from Variable-step to fix-step and the step size to 1e-4. The step size specifies the resolution of simulation. Click Apply and OK to close the Configuration Parameters window.Go to the Simulation menu and click on Start, or just click on the "Start/Pause Simulation" button in the model window toolbar (looks like the "Play" button on a VCR). Because our example is a relatively simple model, its simulation runs almost instantaneously. With more complicated systems, however, you will be able to see the progress of the simulation by observing its running time in the lower box of the model window. Double-click the Scope block to view the output of the Gain block for the simulation as a function of time. Once the Scope window appears, click the "Auto scale" button in its toolbar (looks like a pair of binoculars) to scale the graph to better fit the window. Having done this, you should see the following:。
matlab-simulink教程

Simulink仿真环境基础学习Simulink是面向框图的仿真软件。
7.1演示一个Simulink的简单程序【例7.1】创建一个正弦信号的仿真模型。
步骤如下:(1) 在MATLAB的命令窗口运行simulink命令,或单击工具栏中的图标,就可以打开Simulink模块库浏览器(Simulink Library Browser) 窗口,如图7.1所示。
(2)单击工具栏上的图标或选择菜单“File ”——“New ”——“Model ”,新建一个名为“untitled ”的空白模型窗口。
(3) 在上图的右侧子模块窗口中,单击“Source ”子模块库前的“+”(或双击Source),或者直接在左侧模块和工具箱栏单击Simulink 下的Source 子模块库,便可看到各种输入源模块。
(4) 用鼠标单击所需要的输入信号源模块“Sine Wave ”(正弦信号),将其拖放到的空白模型窗口“untitled ”,则“Sine Wave ”模块就被添加到untitled 窗口;也可以用鼠标选中“Sine Wave ”模块,单击鼠标右键,在快捷菜单中选择“add to 'untitled'”命令,就可以将“Sine Wave ”模块添加到untitled 窗口,如图7.2所示。
图7.1 Simulink 界面(5) 用同样的方法打开接收模块库“Sinks”,选择其中的“Scope”模块(示波器)拖放到“untitled”窗口中。
(6) 在“untitled”窗口中,用鼠标指向“Sine Wave”右侧的输出端,当光标变为十字符时,按住鼠标拖向“Scope”模块的输入端,松开鼠标按键,就完成了两个模块间的信号线连接,一个简单模型已经建成。
如图7.3所示。
(7) 开始仿真,单击“untitled”模型窗口中“开始仿真”图标,或者选择菜单“Simulink”——“Start”,则仿真开始。
双击“Scope”模块出现示波器显示屏,可以看到黄色的正弦波形。
Simulink入门教程

Simulink 快速入门要构建模型, 可以使用Simulink® Editor 和Library Browser。
启动 MATLAB 软件启动 Simulink 之前, 请先启动MATLAB®。
请参阅启动和关闭(MATLAB)。
配置 MATLAB 以启动 Simulink您在 MATLAB 会话中打开第一个模型时需要的时间比打开后续模型长, 因为默认情况下, MATLAB 会在打开第一个模型时启动 Simulink。
这种即时启动Simulink 的方法可以缩短 MATLAB 启动时间, 避免不必要的系统内存占用。
•要快速打开第一个模型, 您可以配置 MATLAB, 在它启动时同时启动Simulink。
要启动 Simulink 而不打开模型或 Library Browser, 请使用start_simulink。
•根据 MATLAB 的启动方式, 恰当使用此命令:•在 MATLAB startup.m文件中在操作系统命令行中, 使用matlab 命令和-r 开关例如, 要在运行Microsoft®Windows®操作系统的计算机上启动 MATLAB 时启动 Simulink, 请创建具有以下目标的桌面快捷方式:matlabroot\bin\win64\matlab.exe -r start_simulink在 Macintosh 和Linux®计算机上, 可在启动 MATLAB 时使用以下命令启动Simulink 软件:matlab -r start_simulink打开 Simulink Editor•要打开 Simulink Editor, 您可以:•创建一个模型。
在 MATLAB 的Home 选项卡上, 点击Simulink 并选择一个模型模板。
或者, 如果您已经打开了 Library Browser, 请点击New Model 按钮/。
有关创建模型的其他方法, 请参阅创建模型。
Exp0_Matlab-Simulink_Introduction使用说明

余兆棠 南台科技大學電子系
教育部資通訊科技人才培育先導型計畫
通訊系統模擬 實習零
1
目的
本課程 - 「通訊系統模擬」將使用 MATLAB/Simulink 進行模 擬,其中基礎篇以Simulink內建模組方塊建構模擬系統平台之 方式進行模擬,模擬結果皆以圖解方式說明物理意義;進階篇 以MATLAB撰寫程式碼之方式進行模擬,除了以數值或圖表結 果驗證解說相關理論,也可以做數據資料之定量分析。 本實習主要簡單介紹 MATLAB/Simulink 軟體與其環境,並說 明使用 ( 操作 ) 方式,方便使用者熟悉 MATLAB/Simulink 軟體 / 環境/使用方法後進行本課程規劃之實習的模擬與分析。
指令視窗 (Command Window)
教育部資通訊科技人才培育先導型計畫
實習零 MATLAB/Simulink使用說明
7
MATLAB指令的輸入與執行
MATLAB 程式碼運算採用逐行指令編譯與執行之方式進行。 在「指令視窗」中的提示符號「>>」可以直接輸入指令。例如輸入 9+10,按下Enter鍵,隨即編譯與執行並顯示結果 。
教育部資通訊科技人才培育先導型計畫
4 5 6 7 8 9
>>a (2:3 , 1:2) ,表示取出矩陣中第 二列至第三列裡,第一行與第二行 之元素。
實習零 MATLAB/Simulink使用說明 11
基本繪圖程式範例
繪圖函數plot(x, y)會利用所提供的資料製作出一個連線圖。
指定X軸、Y軸以及線的規格
Example: >> Tstep=0.001; >> t=(0:Tstep:1); >> amp=2; >> freq=10; >> y=amp*sin(2*pi*freq*t); >> plot(t,y);
(13)Matlabsimulink使用篇

使用篇1.以管理员身份运行matlab2.登录后把当前文件夹改成C盘,找到TwinCAT→Functions→TE1400→SetupTwinCATTarget.p3.找到这个文件后右键选择Run,注意:这一步是为了选择matlabsimulink编译的module所需要的编译器种类,是第一次运行使用matlab+TE1400的时候必须执行的,以后就不必每次都操作这一步。
运行后在matlab主窗口提示让你选择是否用本地的编译器因为本地有VS2010的编译器,所以选择y后敲回车随后matlab找到本地有两种编译器,一个是matlab本体的lcc-win32 C2.4.1,另一个是VS2010,选择VS2010所代表的数字,输入2敲回车最后让matlab让你确认编译器的选择,输入y敲回车提示以下信息说明编译器选择完成4.点击工具栏中simulink图标5.弹出simulink编辑界面后,点击工具栏中的打开模型6.找到案例模型TempContrTest.mdl,点击打开7.本次案例模型是一个简单的温度控制External Setpoint是设定温度Feedback Temp是当前温度CoolerON是开关量输出8.打开simulation菜单栏,选择configuration parameters进行参数设定(1)进入参数设定后,选择右边的树形栏中的Solver,把其中的Type改成Fixed-step(2)之后选择树形栏中的Code Generation,把其中的System target file改成TwinCAT.tlc 点击Browse可以进行选择(3)继续选择树形栏中的Tc Module,在Publish module和Publish binaries for platform “TwinCAT RealTime(x86)”前打勾(4)最后选择树形栏中的Tc Advanced,把Task assignment改成Default在Add to cyclic caller,Variable cycle time,Export block digram以及Export block diagram debug information前打勾(5)以上操作完成后点击左下角的Apply(6)选择树形栏中的Code Generation,把Generate code only勾选后点击Generate code,随后matlab就开始把这个模型通过TE1400生成TC3所识别的Module了(7)回到matlab主窗口,等看到以下提示说明Module生成完成(8)我们来看下生成的Module会在什么位置可以发现在TwinCAT/3.1/CustomConfig/Modules路径下会生成名字和案例模型名字一样的文件夹TempContrTest打开可以发现里面其实主要是.tmc文件是TC3所需要的,其他都是一些描述文件,所以可以把.tmc文件拷贝出来,给一些没有Matlab的电脑上用9.打开TC3,并新建项目10.把名称改成英文,例如matlabsimulink,点击确认11.打开SYSTEM,右键TcCOM Objects添加新项12.TC3会自动找到之前生成的.tmc文件,选中后点击OK进行添加13.添加好后我们可以发现TcCOM Objects下出现matlab生成的Module,并且3个变量出现在IO位置,方便和PLC程序或者硬件IO进行变量连接14.右键Tasks添加新项名字可以改成matlab,点击OK添加新的Task15.因为我需要实施做温度计算,所以可以这个Task的优先级提高,修改成1,周期用默认的10ms即可16.双击TcCOM Objects下面的Object1(TempContrTest)Depend On改成Manual Config,并把Task分配成之前创建的名为“matlab”的Task17.右键PLC添加新项18.把名称修改为英文,例如test19.编辑一段模拟程序,模拟温度的升降20.程序写好后右键test Project,选择生成开始编译程序21.编译好后在test Instance自动生成3个变量22.接下来要做的就是把PLC中3个变量和matlab中三个变量链接起来Switch→CoolerONSP→External SetpointPV Feedback Temp23.变量链接完成后开始下传配置和程序,选择菜单栏TwinCAT,点击Activate Configuration弹出窗口点击确定提示切换到运行模式点击确定观察右下角图标是否编程绿色运行状态弹出窗口点击确定提示切换到运行模式点击确定观察右下角图标是否编程绿色运行状态24.打开PLC菜单,选择“登录到”把程序在线25.打开PLC菜单,选择“启动”把程序运行26.观察程序,看到成功利用matlab温度算法运行程序27.打开Object1(TempContrTest),选择Block Diagram也可以同时观察Matlab温度算法实时状态注:上图中可以看到由一个红色字提示说是非商业的,虽然TE1400插件装上了,但用的还是7天试用版,所以对于试用版有一些限制,查询information system可以看到如下:TC3中Scope View简单使用在之前的基础上来看下TC3下Scope View如何使用,装好TC3后Scope View会自动集成在TC3中1.首先右键“解决方案”选择添加,点击新建项目2.选择TwinCAT Measurement中的Measurement Scope Project,名称改成英文,例如tempcontrol,点击确定3.右键Axis,选择Target Browser4.打开小电脑图标下的Port_851(851),点击MAIN5.把MAIN程序中PV和SP分别添加到同一个坐标上6.保证程序在运行后,点击工具栏中的Record开始记录两个变量7.随后就可以观察到当前PV和SP的示波图下图中绿色是PV,蓝色是SP。
matlab-simulink中文帮助手册

北京电子科技学院毕业设计外文资料翻译系别电子信息工程系专业电子信息工程班级0911学生姓名崔琦导师姓名周玉坤起止时间2013年2月至2013年6月北京电子科技学院毕业设计外文翻译20091111崔琦2目录simulink工作原理
北京电子科技学院
毕业设计外文资料翻译
系 别 电子信息工程系
专 业 电子信息工程
用状态工作执行状态 ................................................................................................... 7 连续时间系统 ............................................................................................................... 7 离散时间系统 ............................................................................................................... 8 混合系统建模 ............................................................................................................... 8 模块参数 ..............................................................................................................................9 可调的参数 ..........................................................................................................................9 模块采样时间..................................................................................................................... 10 自定义模块 ........................................................................................................................11 系统和子系统..................................................................................................................... 11 虚拟子系统................................................................................................................. 11 非虚拟子系统............................................................................................................. 11 动态系统仿真 ............................................................................................................................14 模型编译 ............................................................................................................................14 链接阶段 ............................................................................................................................14 方法执行清单 ............................................................................................................. 15 模块优先级 ................................................................................................................. 15 仿真代数回路..................................................................................................................... 15 回路迭代..................................................................................................................... 16 求解 ....................................................................................................................................17 固定步长的解与可变步长的解 ................................................................................. 17
MATLAB 中文手册 中文自带说明

第1章MATLAB 6.5环境1.1MATLAB简介●MATLAB(Matrix Laborator)是MathWorks公司开发科学与工程计算软件;●广泛应用于自动控制、数学运算、信号分析、计算机技术、图像信号处理、财务分析、航天工业、汽车工业、生物医学工程、语音处理和雷达工程等行业;●国内外高校和研究部门科学研究的重要工具;●MATLIB 已成为数学计算工具方面事实上的标准,MATLIB 6.5是最新版本。
1.1.1 MATLAB工具箱●MATLAB由基本部分和功能各异的工具箱组成。
基本部分是MATLAB的核心,工具箱是扩展部分。
●工具箱是用MATLAB的基本语句编成的各种子程序集,用于解决某一方面的专门问题或实现某一类的新算法。
●MATLAB有以下主要的工具箱:▪控制系统工具箱(Control System Toolbox)▪系统辨识工具箱(System Identification Toolbox)▪信号处理工具箱(Signal Processing Toolbox)▪神经网络工具箱(Neural Network Toolbox)▪模糊逻辑控制工具箱(Fuzzy Logic Toolbox)▪小波工具箱(Wavelet Toolbox)▪模型预测控制工具箱(Model Predictive Control Toolbox)▪通信工具箱(Communication Toolbox)▪图像处理工具箱(Image Processing Toolbox)▪频域系统辨识工具箱(Frequency System Identification Toolbox)▪优化工具箱(Optimization Toolbox)▪偏微分方程工具箱(Partial Differential Equation Toolbox)▪财政金融工具箱(Financial Toolbox)▪统计工具箱(Statistics Toolbox)1.1.2 MATLAB功能和特点1.功能强大(1) 运算功能强大●MATLAB的数值运算要素不是单个数据,而是矩阵,每个元素都可看作复数,运算包括加、减、乘、除、函数运算等;●通过MATLAB的符号工具箱,可以解决在数学、应用科学和工程计算领域中常常遇到的符号计算问题。
(13)Matlabsimulink使用篇

使用篇1.以管理员身份运行matlab2.登录后把当前文件夹改成C盘,找到TwinCAT→Functions→TE1400→SetupTwinCATTarget.p3.找到这个文件后右键选择Run,注意:这一步是为了选择matlabsimulink编译的module所需要的编译器种类,是第一次运行使用matlab+TE1400的时候必须执行的,以后就不必每次都操作这一步。
运行后在matlab主窗口提示让你选择是否用本地的编译器因为本地有VS2010的编译器,所以选择y后敲回车随后matlab找到本地有两种编译器,一个是matlab本体的lcc-win32 C2.4.1,另一个是VS2010,选择VS2010所代表的数字,输入2敲回车最后让matlab让你确认编译器的选择,输入y敲回车提示以下信息说明编译器选择完成4.点击工具栏中simulink图标5.弹出simulink编辑界面后,点击工具栏中的打开模型6.找到案例模型TempContrTest.mdl,点击打开7.本次案例模型是一个简单的温度控制External Setpoint是设定温度Feedback Temp是当前温度CoolerON是开关量输出8.打开simulation菜单栏,选择configuration parameters进行参数设定(1)进入参数设定后,选择右边的树形栏中的Solver,把其中的Type改成Fixed-step(2)之后选择树形栏中的Code Generation,把其中的System target file改成TwinCAT.tlc 点击Browse可以进行选择(3)继续选择树形栏中的Tc Module,在Publish module和Publish binaries for platform “TwinCAT RealTime(x86)”前打勾(4)最后选择树形栏中的Tc Advanced,把Task assignment改成Default在Add to cyclic caller,Variable cycle time,Export block digram以及Export block diagram debug information前打勾(5)以上操作完成后点击左下角的Apply(6)选择树形栏中的Code Generation,把Generate code only勾选后点击Generate code,随后matlab就开始把这个模型通过TE1400生成TC3所识别的Module了(7)回到matlab主窗口,等看到以下提示说明Module生成完成(8)我们来看下生成的Module会在什么位置可以发现在TwinCAT/3.1/CustomConfig/Modules路径下会生成名字和案例模型名字一样的文件夹TempContrTest打开可以发现里面其实主要是.tmc文件是TC3所需要的,其他都是一些描述文件,所以可以把.tmc文件拷贝出来,给一些没有Matlab的电脑上用9.打开TC3,并新建项目10.把名称改成英文,例如matlabsimulink,点击确认11.打开SYSTEM,右键TcCOM Objects添加新项12.TC3会自动找到之前生成的.tmc文件,选中后点击OK进行添加13.添加好后我们可以发现TcCOM Objects下出现matlab生成的Module,并且3个变量出现在IO位置,方便和PLC程序或者硬件IO进行变量连接14.右键Tasks添加新项名字可以改成matlab,点击OK添加新的Task15.因为我需要实施做温度计算,所以可以这个Task的优先级提高,修改成1,周期用默认的10ms即可16.双击TcCOM Objects下面的Object1(TempContrTest)Depend On改成Manual Config,并把Task分配成之前创建的名为“matlab”的Task17.右键PLC添加新项18.把名称修改为英文,例如test19.编辑一段模拟程序,模拟温度的升降20.程序写好后右键test Project,选择生成开始编译程序21.编译好后在test Instance自动生成3个变量22.接下来要做的就是把PLC中3个变量和matlab中三个变量链接起来Switch→CoolerONSP→External SetpointPV Feedback Temp23.变量链接完成后开始下传配置和程序,选择菜单栏TwinCAT,点击Activate Configuration弹出窗口点击确定提示切换到运行模式点击确定观察右下角图标是否编程绿色运行状态弹出窗口点击确定提示切换到运行模式点击确定观察右下角图标是否编程绿色运行状态24.打开PLC菜单,选择“登录到”把程序在线25.打开PLC菜单,选择“启动”把程序运行26.观察程序,看到成功利用matlab温度算法运行程序27.打开Object1(TempContrTest),选择Block Diagram也可以同时观察Matlab温度算法实时状态注:上图中可以看到由一个红色字提示说是非商业的,虽然TE1400插件装上了,但用的还是7天试用版,所以对于试用版有一些限制,查询information system可以看到如下:TC3中Scope View简单使用在之前的基础上来看下TC3下Scope View如何使用,装好TC3后Scope View会自动集成在TC3中1.首先右键“解决方案”选择添加,点击新建项目2.选择TwinCAT Measurement中的Measurement Scope Project,名称改成英文,例如tempcontrol,点击确定3.右键Axis,选择Target Browser4.打开小电脑图标下的Port_851(851),点击MAIN5.把MAIN程序中PV和SP分别添加到同一个坐标上6.保证程序在运行后,点击工具栏中的Record开始记录两个变量7.随后就可以观察到当前PV和SP的示波图下图中绿色是PV,蓝色是SP。