本帖最后由 lm12041204a 于 2019-12-4 16:08 编辑
NI Scan Engine Performance
Publish Date: 二月 14, 2018 | 4 评级 | 3.75 out of 5 | Print
Overview
The NI Scan Engine enables efficient single-point access to sets of data channels, such as I/O channels, using a scan that stores data in a global memory map and updates all values at a single rate, known as the scan period. The scan period must include the time for the scan itself, as well as the time for the application logic. It is valuable to understand how the scan engine performs its scans and the factors outside application logic that can affect performance.
This document provides key considerations when analyzing the performance of CompactRIO hardware with the NI Scan Engine installed, and introduce the Real-Time Execution Trace Toolkit as a method for estimating NI Scan Engine cost in a CompactRIO system.
NI扫描引擎性能
发布日期:二月14,2018 | 4评分| 5中的3.75 | 打印
总览
NI扫描引擎使用一种将数据存储在全局内存映射中并以单一速率(即扫描周期)更新所有值的扫描,来实现对I / O通道等数据通道集的高效单点访问。 扫描周期必须包括扫描本身的时间以及应用程序逻辑的时间。 了解扫描引擎如何执行其扫描以及应用程序逻辑外部可能影响性能的因素非常有价值。
本文档提供了在分析安装了NI Scan Engine的CompactRIO硬件性能时的主要注意事项,并介绍了实时执行跟踪工具包,作为估算CompactRIO系统中NI Scan Engine成本的一种方法。
Table of Contents
Understanding NI Scan Engine Performance
I/O Scan Thread
I/O Variable Nodes
CPU Usage Considerations When Using Scan Mode
Estimating NI Scan Engine Cost For Your System
Related Resources
1. Understanding NI Scan Engine Performance
NI Scan Engine performance is primarily determined by two key elements. The first element is the I/O Scan Thread: this is tied to hardware resources and is affected by the type and number of C Series Modules used, if timestamps are acquired, and other factors. The second element is the I/O Variable node. This is tied to software resources and is affected by the number of nodes in a LabVIEW VI, how nodes are accessed, and other factors. The next two sections will cover these topics in more detail.
Note: The benchmarks provided in this document (CPU and execution time) were run on a legacy CompactRIO 9012 controller. While useful to illustrate the effects of certain variables on NI Scan Engine performance, they should not be used to predict performance for newer CompactRIO controllers.
2. I/O Scan Thread
I/O Scan Time is the first major consideration when understanding NI Scan Engine performance. The main factor that controls I/O Scan execution time is the type and number of C Series Modules used in a CompactRIO system. Figure 3 compares the I/O scan execution times of a selected set of NI-RIO digital (NI-94xx) and analog (NI-92xx) I/O modules. All I/O modules, except NI-9264, used in this test support 32 I/O channels.
Figure 1. I/O Scan thread cost for different I/O module types (Above Time-Critical Priority)
Based on this data, we can make the following assumptions when trying to understand the I/O Scan time for a given hardware setup:
Digital modules (NI-94xx) consume less I/O Scan time than analog modules (NI-92xx). This is because digital modules don’t require any scaling or calibration.
Input-only modules for a given data type (NI-9205 voltage input module) take less time than output modules of the same data type (NI-9264 voltage output module), as there is no processing needed to write output data.
Depending on the type and number of modules used, the total execution time of the I/O Scan thread generally ranges from 200 to 500 μs.
Figure 3 shows ~60 μs of overhead with no I/O modules in use. This represents the fixed I/O Scan thread overhead. If you are not using any of the Scan Mode features, NI recommends that you uninstall Scan Mode software from the real-time target to avoid this fixed cost.
Another key element that affects the I/O Scan Time is timestamping. Each I/O variable allows you to enable or disable the timestamp feature. Enabling timestamps on any I/O variable under a module adds overhead to the I/O Scan time for that module. Figure 2 shows the difference in I/O Scan time for NI 9205 modules with and without timestamp enabled.
Figure 2. I/O Scan time for NI 9205 with timestamp feature enabled/disabled
The timestamp cost varies by module. In general, enabling timestamps can add 10-15% overhead to the I/O scan time of a given module. The timestamp feature is disabled by default.
目录
了解NI扫描引擎性能
I / O扫描线程
I / O变量节点
使用扫描模式时的CPU使用注意事项
估算系统的NI扫描引擎成本
相关资源
1.了解NI扫描引擎性能
NI Scan Engine的性能主要由两个关键要素决定。第一个元素是I / O扫描线程:它与硬件资源相关,并且受所使用的C系列模块的类型和数量,是否获取时间戳以及其他因素的影响。第二个元素是“ I / O变量”节点。这与软件资源有关,并受LabVIEW VI中节点数,节点访问方式以及其他因素的影响。接下来的两个部分将更详细地介绍这些主题。
注意:本文档中提供的基准(CPU和执行时间)在
旧式CompactRIO 9012控制器上运行。尽管有助于说明某些变量对NI Scan Engine性能的影响,但不应将其用于预测新型CompactRIO控制器的性能。
2. I / O扫描线程
了解NI Scan Engine性能时,I / O扫描时间是首要考虑因素。控制I / O扫描执行时间的主要因素是CompactRIO系统中使用的C系列模块的类型和数量。图3比较了一组选定的NI-RIO数字(NI-94xx)和模拟(NI-92xx)I / O模块的I / O扫描执行时间。本测试中使用的所有I / O模块(NI-9264除外)均支持32个I / O通道。
图1.不同I / O模块类型的I / O扫描线程成本(时间优先级以上)
基于此数据,在尝试了解给定硬件设置的I / O扫描时间时,我们可以做出以下假设:
数字模块(NI-94xx)消耗的I / O扫描时间少于模拟模块(NI-92xx)。这是因为数字模块不需要任何缩放或校准。
给定数据类型的仅输入模块(NI-9205电压输入模块)比相同数据类型的输出模块(NI-9264电压输出模块)花费的时间更少,因为无需执行任何处理即可写入输出数据。
根据所用模块的类型和数量,I / O扫描线程的总执行时间通常为200到500μs。
图3显示了大约60μs的开销,没有使用I / O模块。这表示固定的I / O扫描线程开销。如果您没有使用任何扫描模式功能,NI建议您从实时目标中卸载扫描模式软件,以避免固定费用。
影响I / O扫描时间的另一个关键因素是时间戳。每个I / O变量都允许您启用或禁用时间戳功能。在模块下的任何I / O变量上启用时间戳会增加该模块的I / O扫描时间的开销。图2显示了启用和不启用时间戳的NI 9205模块的I / O扫描时间的差异。
图2.启用/禁用时间戳功能的NI 9205的I / O扫描时间
时间戳成本因模块而异。通常,启用时间戳会给给定模块的I / O扫描时间增加10-15%的开销。默认情况下,时间戳功能是禁用的。
3. I/O Variable Nodes
In addition to the execution time of the I/O Scan thread, each evaluation of an I/O variable node in a LabVIEW VI takes time to execute. Figure 3 shows the total execution time of Boolean and Double I/O variable nodes for both read and write operations. The trend for the total I/O variable node access time is clearly linear.
Figure 3. Total execution time of I/O Variable nodes
Figure 4 shows the average execution time of each I/O variable node for the same setup used to collect data for figure 3. As shown below, the execution time per node varies from 7 μs to 9 μs, with the average execution time around 8 μs. This data is an approximation of the average execution time per I/O variable node as the number of nodes on the block diagram increases. This data is based on averages collected over several thousand iterations and is adjusted to account for system jitter and benchmarking overhead. In general, 10 μs per I/O variable node is a reasonable estimate of execution time using scanned access mode.
Figure 4. Average execution time per I/O variable node
As the number of Variable Nodes increases, the execution time slightly increases.
I/O variable nodes execute faster using scanned access mode than direct access mode. When you access an I/O variable using direct access mode, LabVIEW must traverse the software stack all the way down to the hardware driver, whereas scanned access simply involves accessing local memory. Figure 5 below compares scanned versus direct mode execution times for I/O variable nodes of the Double data type.
Figure 5. Average I/O variable execution time for scanned versus direct access mode
Use scanned access mode for synchronous access to a group of I/O channels. Use direct access mode to access an I/O channel asynchronously from the I/O scan. Although the execution time of direct access mode is slower than that of scanned access mode, you can take advantage of the asynchronous quality of direct access mode to access individual I/O channels at either a faster or a slower rate than the I/O scan.
3. I / O变量节点
除了I / O扫描线程的执行时间外,LabVIEW VI中对I / O变量节点的每次评估还需要花费一些时间来执行。图3显示了布尔和双I / O变量节点的读写操作总时间。 I / O变量节点总访问时间的趋势显然是线性的。
图3. I / O变量节点的总执行时间
图4显示了用于与图3收集数据相同的设置的每个I / O变量节点的平均执行时间。如下所示,每个节点的执行时间从7μs到9μs不等,平均执行时间约为8 s。微秒随着框图上节点数量的增加,该数据近似于每个I / O变量节点的平均执行时间。此数据基于数千次迭代收集的平均值,并进行了调整以考虑系统抖动和基准测试开销。通常,使用扫描访问模式,每个I / O变量节点10μs是执行时间的合理估计。
图4.每个I / O变量节点的平均执行时间
随着变量节点数量的增加,执行时间会稍微增加。
与直接访问模式相比,使用扫描访问模式的I / O变量节点执行速度更快。当您使用直接访问模式访问I / O变量时,LabVIEW必须一直遍历软件堆栈直至硬件驱动程序,而扫描访问仅涉及访问本地内存。下面的图5比较了Double数据类型的I / O变量节点的扫描时间与直接模式执行时间。
图5.扫描和直接访问模式下平均I / O变量执行时间
使用扫描访问模式来同步访问一组I / O通道。使用直接访问模式从I / O扫描异步访问I / O通道。尽管直接访问模式的执行时间比扫描访问模式的执行时间慢,但是您可以利用直接访问模式的异步质量以比I / O扫描更快或更慢的速率访问单个I / O通道。
4. CPU Usage Considerations When Using Scan Mode
CPU usage is an important metric of system performance, and certain factors can have a big impact on scan engine performance, without much application logic. Table 1 below details a simple PID loop run on a legacy CompactRIO 9012 Controller. As the number of channels used increases, the CPU usage increases. This effect is compounded as the controller's Scan Rate is increased. At 1000Hz, the CompactRIO 9012 was not able to read/write to more than 16 AI/AO pairs without reaching maximum CPU usage.
Note: More modern CompactRIO Controllers will not have this problem - these benchmarks are provided to show the effect that increasing channel counts and sample rates have on CPU usage.
Number of Channels (AI/AO pair) 100 Hz 500 Hz 1000 Hz
1 10% 32% 55%
16 16% 47% 95%
32 18% 67% n/a
64 27% 96% n/a
80 29% n/a n/a
Table 1. CPU usage for Scan Mode PID application at various scan rates
Another key factor affecting CPU usage is network publishing of data. I/O variables support network publishing for remote data access and monitoring, but using this network publishing can have significant CPU overhead, based on the publishing period selected. Figure 6 compares the system CPU usage for various network publishing rates.
Figure 6. Network publishing overhead for analog I/O variables at various publishing rates
The test setup used for the network publishing benchmarks included continuously changing analog input data from NI 9205 modules. The test used NI Distributed System Manager probes to monitor the input data on all the I/O modules and to record the total CPU usage for each scenario. The results reflect the total CPU usage with the I/O scan running at the default period of 10 ms and network publishing either disabled for all I/O variables or enabled at various network publishing rates.
Network publishing overhead is typically negligible if no remote client is connected to the target or if the I/O data is not changing quickly. But as figure 8 shows, the CPU usage can become significant when monitoring a large number of continuously changing analog I/O channels. Network publishing is enabled by default for I/O variables. However, you can disable network publishing for the individual I/O variables using the Shared Variable Properties dialog box. You also can disable network publishing for multiple I/O variables at once using the Multiple Variable Editor. The “Publishing Disabled” series in figure 8 represents the baseline CPU usage of the system with only the I/O scan running and network publishing disabled for all I/O variables.
To optimize your system’s CPU usage, you can either slow down the network publishing rate by adjusting the Network Publishing Period on the Scan Engine page of the RT Target Properties dialog box, disabling network publishing for I/O variables that you are not monitoring remotely, or making sure you don’t have a remote client connected to any I/O module unless it is using the I/O data for remote access or monitoring.
4.使用扫描模式时的CPU使用注意事项
CPU使用率是衡量系统性能的重要指标,并且在没有太多应用程序逻辑的情况下,某些因素可能会对扫描引擎性能产生重大影响。下表1详细说明了在旧版CompactRIO 9012控制器上运行的简单PID回路。随着使用的通道数增加,CPU使用率增加。随着控制器的“扫描速率”的增加,这种影响更加严重。在1000Hz频率下,CompactRIO 9012不能读取/写入超过16个AI / AO对,而未达到最大CPU使用率。
注意:更现代的
CompactRIO控制器将不会出现此问题-提供这些基准测试是为了显示增加通道数和采样率对CPU使用率的影响。
通道数(AI / AO对)100 Hz 500 Hz 1000 Hz
1 10%32%55%
16 16%47%95%
32 18%67%不适用
64 27%96%不适用
80 29%不适用不适用
表1.各种扫描速率下的扫描模式PID应用程序的CPU使用率
影响CPU使用率的另一个关键因素是数据的网络发布。 I / O变量支持用于远程数据访问和监视的网络发布,但是根据所选的发布时间,使用此网络发布会产生大量的CPU开销。图6比较了各种网络发布速率下的系统CPU使用率。
图6.不同发布速率下模拟I / O变量的网络发布开销
用于网络发布基准测试的测试设置包括不断更改NI 9205模块的模拟输入数据。该测试使用NI Distributed System Manager探针监视所有I / O模块上的输入数据,并记录每种情况下的CPU使用总量。结果反映了I / O扫描在默认时间段10毫秒运行并且对所有I / O变量禁用了网络发布或以各种网络发布速率启用了网络发布时的总CPU使用率。
如果没有远程客户端连接到目标或I / O数据没有快速更改,则网络发布开销通常可以忽略不计。但是如图8所示,当监视大量不断变化的模拟I / O通道时,CPU使用率可能会变得很高。默认情况下,I / O变量启用网络发布。但是,可以使用“共享变量属性”对话框为单个I / O变量禁用网络发布。您也可以使用“多变量编辑器”同时禁用多个I / O变量的网络发布。图8中的“发布已禁用”系列表示仅运行I / O扫描并且已禁用所有I / O变量的网络发布的系统的基准CPU使用率。
为了优化系统的CPU使用率,您可以通过调整“ RT Target属性”对话框的“扫描引擎”页面上的“网络发布时间”来降低网络发布速度,从而对不进行远程监视的I / O变量禁用网络发布,或确保您没有将远程客户端连接到任何I / O模块,除非该客户端正在使用I / O数据进行远程访问或监视。
5. Estimating NI Scan Engine Cost For Your System
As noted in the previous sections, I/O Scan thread overhead depends on the number and type of I/O modules used in your system.
An I/O variable node itself can take around 10 μs or less of execution time. The total cost of I/O variable nodes depends on the number of nodes present in your application and the rates of the loops containing the nodes.
You can use the Real-Time Execution Trace Toolkit to estimate the total execution time of the I/O Scan thread for you system. See figure 8 for an example trace session showing the I/O Scan running at Above Time Critical priority. The data shown in figure 3 and figure 4 is an average of several iterations of the data collected from similar traces and is adjusted to account for system jitter and benchmarking overhead.
Figure 7. I/O Scan Execution trace for a system with eight NI-9205 modules
6. Related Resources
C Series Modules Supported by CompactRIO Scan Mode
Using NI CompactRIO Scan Mode with NI LabVIEW Software
Recommended Practices for Using the LabVIEW I/O Variable and NI Scan Engine
The RIO Scan Interface Under the Hood
5.估算系统的NI扫描引擎成本
如前几节所述,“ I / O扫描”线程的开销取决于系统中使用的I / O模块的数量和类型。
I / O变量节点本身可以花费大约10μs或更短的执行时间。 I / O变量节点的总成本取决于应用程序中存在的节点数以及包含这些节点的循环的速率。
您可以使用实时执行跟踪工具包来估计系统的I / O扫描线程的总执行时间。请参阅图8,以获取示例跟踪会话,该会话显示以“高于时间上限”优先级运行的I / O扫描。图3和图4中显示的数据是从类似迹线收集的数据的几次迭代的平均值,并进行了调整以考虑系统抖动和基准测试开销。
图7.具有八个NI-9205模块的系统的I / O扫描执行轨迹
6.相关资源
CompactRIO扫描模式支持的C系列模块
通过NI LabVIEW软件使用NI CompactRIO扫描模式
使用LabVIEW I / O变量和NI扫描引擎的推荐实践
引擎盖下的RIO扫描界面
继续将就看。
本帖最后由 lm12041204a 于 2019-12-4 16:08 编辑
NI Scan Engine Performance
Publish Date: 二月 14, 2018 | 4 评级 | 3.75 out of 5 | Print
Overview
The NI Scan Engine enables efficient single-point access to sets of data channels, such as I/O channels, using a scan that stores data in a global memory map and updates all values at a single rate, known as the scan period. The scan period must include the time for the scan itself, as well as the time for the application logic. It is valuable to understand how the scan engine performs its scans and the factors outside application logic that can affect performance.
This document provides key considerations when analyzing the performance of CompactRIO hardware with the NI Scan Engine installed, and introduce the Real-Time Execution Trace Toolkit as a method for estimating NI Scan Engine cost in a CompactRIO system.
NI扫描引擎性能
发布日期:二月14,2018 | 4评分| 5中的3.75 | 打印
总览
NI扫描引擎使用一种将数据存储在全局内存映射中并以单一速率(即扫描周期)更新所有值的扫描,来实现对I / O通道等数据通道集的高效单点访问。 扫描周期必须包括扫描本身的时间以及应用程序逻辑的时间。 了解扫描引擎如何执行其扫描以及应用程序逻辑外部可能影响性能的因素非常有价值。
本文档提供了在分析安装了NI Scan Engine的CompactRIO硬件性能时的主要注意事项,并介绍了实时执行跟踪工具包,作为估算CompactRIO系统中NI Scan Engine成本的一种方法。
Table of Contents
Understanding NI Scan Engine Performance
I/O Scan Thread
I/O Variable Nodes
CPU Usage Considerations When Using Scan Mode
Estimating NI Scan Engine Cost For Your System
Related Resources
1. Understanding NI Scan Engine Performance
NI Scan Engine performance is primarily determined by two key elements. The first element is the I/O Scan Thread: this is tied to hardware resources and is affected by the type and number of C Series Modules used, if timestamps are acquired, and other factors. The second element is the I/O Variable node. This is tied to software resources and is affected by the number of nodes in a LabVIEW VI, how nodes are accessed, and other factors. The next two sections will cover these topics in more detail.
Note: The benchmarks provided in this document (CPU and execution time) were run on a legacy CompactRIO 9012 controller. While useful to illustrate the effects of certain variables on NI Scan Engine performance, they should not be used to predict performance for newer CompactRIO controllers.
2. I/O Scan Thread
I/O Scan Time is the first major consideration when understanding NI Scan Engine performance. The main factor that controls I/O Scan execution time is the type and number of C Series Modules used in a CompactRIO system. Figure 3 compares the I/O scan execution times of a selected set of NI-RIO digital (NI-94xx) and analog (NI-92xx) I/O modules. All I/O modules, except NI-9264, used in this test support 32 I/O channels.
Figure 1. I/O Scan thread cost for different I/O module types (Above Time-Critical Priority)
Based on this data, we can make the following assumptions when trying to understand the I/O Scan time for a given hardware setup:
Digital modules (NI-94xx) consume less I/O Scan time than analog modules (NI-92xx). This is because digital modules don’t require any scaling or calibration.
Input-only modules for a given data type (NI-9205 voltage input module) take less time than output modules of the same data type (NI-9264 voltage output module), as there is no processing needed to write output data.
Depending on the type and number of modules used, the total execution time of the I/O Scan thread generally ranges from 200 to 500 μs.
Figure 3 shows ~60 μs of overhead with no I/O modules in use. This represents the fixed I/O Scan thread overhead. If you are not using any of the Scan Mode features, NI recommends that you uninstall Scan Mode software from the real-time target to avoid this fixed cost.
Another key element that affects the I/O Scan Time is timestamping. Each I/O variable allows you to enable or disable the timestamp feature. Enabling timestamps on any I/O variable under a module adds overhead to the I/O Scan time for that module. Figure 2 shows the difference in I/O Scan time for NI 9205 modules with and without timestamp enabled.
Figure 2. I/O Scan time for NI 9205 with timestamp feature enabled/disabled
The timestamp cost varies by module. In general, enabling timestamps can add 10-15% overhead to the I/O scan time of a given module. The timestamp feature is disabled by default.
目录
了解NI扫描引擎性能
I / O扫描线程
I / O变量节点
使用扫描模式时的CPU使用注意事项
估算系统的NI扫描引擎成本
相关资源
1.了解NI扫描引擎性能
NI Scan Engine的性能主要由两个关键要素决定。第一个元素是I / O扫描线程:它与硬件资源相关,并且受所使用的C系列模块的类型和数量,是否获取时间戳以及其他因素的影响。第二个元素是“ I / O变量”节点。这与软件资源有关,并受LabVIEW VI中节点数,节点访问方式以及其他因素的影响。接下来的两个部分将更详细地介绍这些主题。
注意:本文档中提供的基准(CPU和执行时间)在旧式CompactRIO 9012控制器上运行。尽管有助于说明某些变量对NI Scan Engine性能的影响,但不应将其用于预测新型CompactRIO控制器的性能。
2. I / O扫描线程
了解NI Scan Engine性能时,I / O扫描时间是首要考虑因素。控制I / O扫描执行时间的主要因素是CompactRIO系统中使用的C系列模块的类型和数量。图3比较了一组选定的NI-RIO数字(NI-94xx)和模拟(NI-92xx)I / O模块的I / O扫描执行时间。本测试中使用的所有I / O模块(NI-9264除外)均支持32个I / O通道。
图1.不同I / O模块类型的I / O扫描线程成本(时间优先级以上)
基于此数据,在尝试了解给定硬件设置的I / O扫描时间时,我们可以做出以下假设:
数字模块(NI-94xx)消耗的I / O扫描时间少于模拟模块(NI-92xx)。这是因为数字模块不需要任何缩放或校准。
给定数据类型的仅输入模块(NI-9205电压输入模块)比相同数据类型的输出模块(NI-9264电压输出模块)花费的时间更少,因为无需执行任何处理即可写入输出数据。
根据所用模块的类型和数量,I / O扫描线程的总执行时间通常为200到500μs。
图3显示了大约60μs的开销,没有使用I / O模块。这表示固定的I / O扫描线程开销。如果您没有使用任何扫描模式功能,NI建议您从实时目标中卸载扫描模式软件,以避免固定费用。
影响I / O扫描时间的另一个关键因素是时间戳。每个I / O变量都允许您启用或禁用时间戳功能。在模块下的任何I / O变量上启用时间戳会增加该模块的I / O扫描时间的开销。图2显示了启用和不启用时间戳的NI 9205模块的I / O扫描时间的差异。
图2.启用/禁用时间戳功能的NI 9205的I / O扫描时间
时间戳成本因模块而异。通常,启用时间戳会给给定模块的I / O扫描时间增加10-15%的开销。默认情况下,时间戳功能是禁用的。
3. I/O Variable Nodes
In addition to the execution time of the I/O Scan thread, each evaluation of an I/O variable node in a LabVIEW VI takes time to execute. Figure 3 shows the total execution time of Boolean and Double I/O variable nodes for both read and write operations. The trend for the total I/O variable node access time is clearly linear.
Figure 3. Total execution time of I/O Variable nodes
Figure 4 shows the average execution time of each I/O variable node for the same setup used to collect data for figure 3. As shown below, the execution time per node varies from 7 μs to 9 μs, with the average execution time around 8 μs. This data is an approximation of the average execution time per I/O variable node as the number of nodes on the block diagram increases. This data is based on averages collected over several thousand iterations and is adjusted to account for system jitter and benchmarking overhead. In general, 10 μs per I/O variable node is a reasonable estimate of execution time using scanned access mode.
Figure 4. Average execution time per I/O variable node
As the number of Variable Nodes increases, the execution time slightly increases.
I/O variable nodes execute faster using scanned access mode than direct access mode. When you access an I/O variable using direct access mode, LabVIEW must traverse the software stack all the way down to the hardware driver, whereas scanned access simply involves accessing local memory. Figure 5 below compares scanned versus direct mode execution times for I/O variable nodes of the Double data type.
Figure 5. Average I/O variable execution time for scanned versus direct access mode
Use scanned access mode for synchronous access to a group of I/O channels. Use direct access mode to access an I/O channel asynchronously from the I/O scan. Although the execution time of direct access mode is slower than that of scanned access mode, you can take advantage of the asynchronous quality of direct access mode to access individual I/O channels at either a faster or a slower rate than the I/O scan.
3. I / O变量节点
除了I / O扫描线程的执行时间外,LabVIEW VI中对I / O变量节点的每次评估还需要花费一些时间来执行。图3显示了布尔和双I / O变量节点的读写操作总时间。 I / O变量节点总访问时间的趋势显然是线性的。
图3. I / O变量节点的总执行时间
图4显示了用于与图3收集数据相同的设置的每个I / O变量节点的平均执行时间。如下所示,每个节点的执行时间从7μs到9μs不等,平均执行时间约为8 s。微秒随着框图上节点数量的增加,该数据近似于每个I / O变量节点的平均执行时间。此数据基于数千次迭代收集的平均值,并进行了调整以考虑系统抖动和基准测试开销。通常,使用扫描访问模式,每个I / O变量节点10μs是执行时间的合理估计。
图4.每个I / O变量节点的平均执行时间
随着变量节点数量的增加,执行时间会稍微增加。
与直接访问模式相比,使用扫描访问模式的I / O变量节点执行速度更快。当您使用直接访问模式访问I / O变量时,LabVIEW必须一直遍历软件堆栈直至硬件驱动程序,而扫描访问仅涉及访问本地内存。下面的图5比较了Double数据类型的I / O变量节点的扫描时间与直接模式执行时间。
图5.扫描和直接访问模式下平均I / O变量执行时间
使用扫描访问模式来同步访问一组I / O通道。使用直接访问模式从I / O扫描异步访问I / O通道。尽管直接访问模式的执行时间比扫描访问模式的执行时间慢,但是您可以利用直接访问模式的异步质量以比I / O扫描更快或更慢的速率访问单个I / O通道。
4. CPU Usage Considerations When Using Scan Mode
CPU usage is an important metric of system performance, and certain factors can have a big impact on scan engine performance, without much application logic. Table 1 below details a simple PID loop run on a legacy CompactRIO 9012 Controller. As the number of channels used increases, the CPU usage increases. This effect is compounded as the controller's Scan Rate is increased. At 1000Hz, the CompactRIO 9012 was not able to read/write to more than 16 AI/AO pairs without reaching maximum CPU usage.
Note: More modern CompactRIO Controllers will not have this problem - these benchmarks are provided to show the effect that increasing channel counts and sample rates have on CPU usage.
Number of Channels (AI/AO pair) 100 Hz 500 Hz 1000 Hz
1 10% 32% 55%
16 16% 47% 95%
32 18% 67% n/a
64 27% 96% n/a
80 29% n/a n/a
Table 1. CPU usage for Scan Mode PID application at various scan rates
Another key factor affecting CPU usage is network publishing of data. I/O variables support network publishing for remote data access and monitoring, but using this network publishing can have significant CPU overhead, based on the publishing period selected. Figure 6 compares the system CPU usage for various network publishing rates.
Figure 6. Network publishing overhead for analog I/O variables at various publishing rates
The test setup used for the network publishing benchmarks included continuously changing analog input data from NI 9205 modules. The test used NI Distributed System Manager probes to monitor the input data on all the I/O modules and to record the total CPU usage for each scenario. The results reflect the total CPU usage with the I/O scan running at the default period of 10 ms and network publishing either disabled for all I/O variables or enabled at various network publishing rates.
Network publishing overhead is typically negligible if no remote client is connected to the target or if the I/O data is not changing quickly. But as figure 8 shows, the CPU usage can become significant when monitoring a large number of continuously changing analog I/O channels. Network publishing is enabled by default for I/O variables. However, you can disable network publishing for the individual I/O variables using the Shared Variable Properties dialog box. You also can disable network publishing for multiple I/O variables at once using the Multiple Variable Editor. The “Publishing Disabled” series in figure 8 represents the baseline CPU usage of the system with only the I/O scan running and network publishing disabled for all I/O variables.
To optimize your system’s CPU usage, you can either slow down the network publishing rate by adjusting the Network Publishing Period on the Scan Engine page of the RT Target Properties dialog box, disabling network publishing for I/O variables that you are not monitoring remotely, or making sure you don’t have a remote client connected to any I/O module unless it is using the I/O data for remote access or monitoring.
4.使用扫描模式时的CPU使用注意事项
CPU使用率是衡量系统性能的重要指标,并且在没有太多应用程序逻辑的情况下,某些因素可能会对扫描引擎性能产生重大影响。下表1详细说明了在旧版CompactRIO 9012控制器上运行的简单PID回路。随着使用的通道数增加,CPU使用率增加。随着控制器的“扫描速率”的增加,这种影响更加严重。在1000Hz频率下,CompactRIO 9012不能读取/写入超过16个AI / AO对,而未达到最大CPU使用率。
注意:更现代的CompactRIO控制器将不会出现此问题-提供这些基准测试是为了显示增加通道数和采样率对CPU使用率的影响。
通道数(AI / AO对)100 Hz 500 Hz 1000 Hz
1 10%32%55%
16 16%47%95%
32 18%67%不适用
64 27%96%不适用
80 29%不适用不适用
表1.各种扫描速率下的扫描模式PID应用程序的CPU使用率
影响CPU使用率的另一个关键因素是数据的网络发布。 I / O变量支持用于远程数据访问和监视的网络发布,但是根据所选的发布时间,使用此网络发布会产生大量的CPU开销。图6比较了各种网络发布速率下的系统CPU使用率。
图6.不同发布速率下模拟I / O变量的网络发布开销
用于网络发布基准测试的测试设置包括不断更改NI 9205模块的模拟输入数据。该测试使用NI Distributed System Manager探针监视所有I / O模块上的输入数据,并记录每种情况下的CPU使用总量。结果反映了I / O扫描在默认时间段10毫秒运行并且对所有I / O变量禁用了网络发布或以各种网络发布速率启用了网络发布时的总CPU使用率。
如果没有远程客户端连接到目标或I / O数据没有快速更改,则网络发布开销通常可以忽略不计。但是如图8所示,当监视大量不断变化的模拟I / O通道时,CPU使用率可能会变得很高。默认情况下,I / O变量启用网络发布。但是,可以使用“共享变量属性”对话框为单个I / O变量禁用网络发布。您也可以使用“多变量编辑器”同时禁用多个I / O变量的网络发布。图8中的“发布已禁用”系列表示仅运行I / O扫描并且已禁用所有I / O变量的网络发布的系统的基准CPU使用率。
为了优化系统的CPU使用率,您可以通过调整“ RT Target属性”对话框的“扫描引擎”页面上的“网络发布时间”来降低网络发布速度,从而对不进行远程监视的I / O变量禁用网络发布,或确保您没有将远程客户端连接到任何I / O模块,除非该客户端正在使用I / O数据进行远程访问或监视。
5. Estimating NI Scan Engine Cost For Your System
As noted in the previous sections, I/O Scan thread overhead depends on the number and type of I/O modules used in your system.
An I/O variable node itself can take around 10 μs or less of execution time. The total cost of I/O variable nodes depends on the number of nodes present in your application and the rates of the loops containing the nodes.
You can use the Real-Time Execution Trace Toolkit to estimate the total execution time of the I/O Scan thread for you system. See figure 8 for an example trace session showing the I/O Scan running at Above Time Critical priority. The data shown in figure 3 and figure 4 is an average of several iterations of the data collected from similar traces and is adjusted to account for system jitter and benchmarking overhead.
Figure 7. I/O Scan Execution trace for a system with eight NI-9205 modules
6. Related Resources
C Series Modules Supported by CompactRIO Scan Mode
Using NI CompactRIO Scan Mode with NI LabVIEW Software
Recommended Practices for Using the LabVIEW I/O Variable and NI Scan Engine
The RIO Scan Interface Under the Hood
5.估算系统的NI扫描引擎成本
如前几节所述,“ I / O扫描”线程的开销取决于系统中使用的I / O模块的数量和类型。
I / O变量节点本身可以花费大约10μs或更短的执行时间。 I / O变量节点的总成本取决于应用程序中存在的节点数以及包含这些节点的循环的速率。
您可以使用实时执行跟踪工具包来估计系统的I / O扫描线程的总执行时间。请参阅图8,以获取示例跟踪会话,该会话显示以“高于时间上限”优先级运行的I / O扫描。图3和图4中显示的数据是从类似迹线收集的数据的几次迭代的平均值,并进行了调整以考虑系统抖动和基准测试开销。
图7.具有八个NI-9205模块的系统的I / O扫描执行轨迹
6.相关资源
CompactRIO扫描模式支持的C系列模块
通过NI LabVIEW软件使用NI CompactRIO扫描模式
使用LabVIEW I / O变量和NI扫描引擎的推荐实践
引擎盖下的RIO扫描界面
继续将就看。
举报