实时仿真和测试

Real-time simulation and testing is used in two ways, differing only in whether the design or the prototype is being modeled in Simulink®software.

  • 快速控制原型(RCP)- 通过使用模型设计Simulink Real-Time™软件并通过使用目标计算机将其连接到物理系统。您可以在投资物理原型之前制定设计缺陷并揭示新应用的要求。

  • Hardware-in-the-loop (HIL) simulation- 连接A.Simulink Real-Timemodel that is a physical prototype of the design to a software plant model that represents the hardware system. You can test the prototype for safety and performance without expensive downtime for the rest of the system. You can test operation and failure conditions that are difficult to replicate and substitute for unavailable parts of the hardware system.

实时仿真和测试Workflow

用于实时仿真和测试的工作流程,从模型创建到回归和压力测试。

创建一个万博1manbetx要么Stateflowmodel.

  1. 在Simuli万博1manbetxnk编辑器中,在模拟tab, from, select模型

  2. 从“Simulin万博1manbetxk Start”页面中,选择模型模板或单击Blank Model

  3. Create block diagrams in Simulink by dragging blocks to your model. If possible, set model and block parameters to use a fixed-step solver and specify a sample time compatible with the real-time requirements of your model.

模拟模型作为非实时应用程序。

Simulink uses a computed time vector to step the model. After computing the outputs for a given time value, Simulink immediately repeats the computation for the next time value until it reaches the stop time.

因为计算的时间向量未连接到物理时钟,所以输出按计算机运行时快速计算。模拟的经过时间可以从真实系统的经过时间显着差异。

您可以记录仿真结果以供以后比较。

配置the development and target computers.

  1. 配置开发和目标计算机之间的通信方法。

  2. 配置the development and target computers by using:

Prepare the model for real-time execution. Configure the build environment.

  1. 将模型配置参数设置为与实时执行兼容的值:

    • On theAppstab, clickSimulink Real-Time。这个选择设置了System target file模型参数到slrt.tlc并套装类型模型参数到Fixed-step

    • On theReal-Timetab, click硬件设置。InConfiguration Parameters>求解器>Fixed-step sizeselect a step size that is compatible with the real-time requirements of your model.

    • On theReal-Timetab, click硬件设置。选择选项Configuration Parameters>Code Generation>万博1manbetxSimulink实时选项

  2. AddSimulink Real-TimeI/O blocks representing your I/O boards to the model.

  3. 要可视化模拟结果,请使用模拟数据检查器标记模型中的信号。看到View Data with the Simulation Data Inspector(万博1manbetxSimulink)。

Connect to the physical hardware. Restart the target computer. Configure the build environment.

  1. 将开发计算机连接到SpeedGoat目标机器。将目标计算机中的IO模块连接到适用的物理硬件。

  2. 用它重新启动目标计算机Simulink Real-Time使用的实时内核:

连接到目标计算机。构建并下载实时应用程序。

  1. On theReal-Timetab, toggle theToggle target computer connectionto连接然后点击Run on Target。有关构建和下载实时应用的更多信息,请参阅:

执行real-time application.

  1. 执行从开发计算机的命令下执行实时应用程序,或通过在独立模式下重新启动目标计算机。

    TheSimulink Real-Timesoftware uses real-time resources on the target computer. Based on your sample rate, theSimulink Real-Time软件使用中断以按采样速率执行模型。通过每个新中断,实时应用程序计算模型中的块输出。

  2. Execute using:

Visualize signals.

  1. 创建实时范围和Simulink Real-Time资源管理器仪器。采用them to acquire and display signal data from the real-time application. You can filter and group hierarchical signals in Explorer.

  2. 由实时范围块创建的范围根据Simulink示例时间规则获取数据。万博1manbetx范围可以在顶级或启用或触发子系统中收集数据。动态创建的范围(来自Matlab®Command Window or the API) sample at the base rate, irrespective of the sample time of their signals.

  3. To create instrument panels, useSimulink Real-TimeExplorer to create instrument panels. You can drag graphical instruments to the instrument panels and drag signals to the instruments to display signal data.

    Visualize signals using:

Tune parameters.

  1. 调谐可观察参数,例如时间延迟,输入和输出幅度,以及输入和输出频率。您可以在Simulink实时资源管理器中过滤和分层信号。万博1manbetx

    Note

    Simulink Real-Timedoes not support parameters of multiword data types.

  2. 调谐参数使用:

Prepare regression and stress tests.

Write MATLAB scripts that perform parameter sweep and extreme-value testing in a repeatable manner, accumulating results as known good data.

Special Purpose Tasks

In addition to the typical real-time simulation and testing workflow process steps, some special purpose tasks could support your development process.

  • 用来可视化模型Simulink Real-Time资源管理器仪器。

    配置Simulink Real-TimeExplorer by using instrument panels configured with real-time scopes and with signal display and parameter tuning graphical instruments.

  • Run the model where the physical device runs.

    配置要在外部MATLAB中运行的实时应用程序,例如在移动车辆中。出口Simulink Real-TimeExplorer configuration as a standalone control program.

  • 准备回归和产品测试万博1manbetxSimulink Test™

    Extend the regression and stress tests to cover functionality over the full parameter range.

  • 将模型集成到第三方测试环境中。

    采用马铃薯Coder™to translate MATLAB regression test scripts into C for integration into a third-party test environment.

相关话题