了解CRBasic程序编译模式:顺序和管道

by珍妮特艾尔斯|更新时间:2017年10月25日|评论:2

搜索博客


订阅博客

Set up your preferences for receiving email notifications when new blog articles are posted that match your areas of interest.


区域/应用

产品分类

Activity

Corporate / News

输入您的电子邮件地址:



建议文章

您要了解更多信息吗?让我们知道。请尽可能具体。

Leave this field empty

用块说明的顺序和管道模式

你有没有注意到一条消息,说你的CRBasic计划编制了PipelineMode要么顺序显示器还这是什么意思?而且,什么时候重要?在本文中,我们将查看这两种模式。

Sequential Mode

Let’s start with the more straightforward mode:顺序显示器。CRBasic编辑器有助于提供此描述:“按顺序模式,数据记录器按顺序执行指令,因为它们在程序中发生。”换句话说,您的程序从上到下运行。您还可以考虑这样的顺序模式,其中一个指令被沿另一个指令执行:

Sequential mode represented by boxes with arrows

顺序模式可为您控制执行指令的顺序,并且使您的程序易于遵循。当您在程序控制下为传感器供电时,顺序模式可能是特别有用的,以确保传感器在正确的时间打开。

在sequential mode, each measurement is followed by the processing tasks it requires. In other words, measurements and processing do not occur concurrently. Instead, processing always follows the measurement. Because measurements and processing are carried out in sequential order, there is no buffer for processing.

在the figure below, there are three measurements: A, B, and C. Each measurement needs processing—denoted by PA, PB, and PC, respectively. In this simple example, processing includes applying multipliers and offsets, and performing output calculations. We also see that there is some idle time in the scan, which is denoted by the unlabeled squares.

Sequential mode with three scans taking 10 seconds each

单击上面的图像。

I’ll use seconds as the unit of measurement for the scan rate to make the figures easier to understand. (In practice, Campbell Scientific measurements and processing happen much faster.) In the figure above, we could say that the scan rate is 10 seconds.

在下一个数字中,我们在扫描中删除了空闲时间。在顺序模式下,这组测量和处理的最快可以运行将是六秒钟的扫描速率。

Sequential mode with five scans taking six seconds each

单击上面的图像。

尝试以顺序模式更快地运行扫描将导致跳过扫描。根据此速度,如果偶尔的处理任务需要比您所考虑的更长时间,您仍然可能会跳过扫描。

To better understand skipped scans, watch the illustrative video below.
(注意:此视频没有音频。)

Note:CR300系列数据转换器始终以顺序模式运行。

管道模式

现在,什么是PipelineMode还CRBasic编辑器有助于此说明:“在管道模式下,测量任务和处理任务单独处理并同时执行。”在管道模式下,测量任务赋予最高优先级,使得它们首先执行每次扫描中的精确定时。如果数据记录器具有紧张时间表,则处理任务可以滞后,即使在不同的扫描期间也可以稍后完成。使用扫描缓冲区完成这些同步任务,该扫描缓冲区允许处理任务以在后台进行队列,同时进行测量。

在the figure below, the same program that we looked at in the sequential mode example is run in pipeline mode instead. Once again, there are three measurements (A, B, and C) with the processing of the measurements (denoted by PA, PB, and PC, respectively). Because we’re using pipeline mode, the measurement and processing tasks are handled separately, but can occur concurrently.

Pipeline mode with three scans taking 10 seconds each

单击上面的图像。

现在,让我们加快速度。在连续模式下,the fastest we could run the program without getting skipped scans was six seconds. In pipeline mode, measurements and processing happen concurrently, as needed, allowing us to increase the scan rate to five seconds.

管道模式,六次扫描每次花五秒钟

单击上面的图像。

题:该程序在管道模式下运行的最快最快是什么?

Answer:通过删除所有空闲时间,它可以每三秒钟运行一次。

Processing tasks that take a variable amount of time, require retries, or only happen occasionally can increase the required scan time, which could result in skipped scans. The scan buffer (set in the CRBasic扫描()指令允许将要存储在队列中的处理任务,然后在处理器可用时处理。

警告:If the data logger doesn’t complete the tasks and the buffer overflows, it will drop all the tasks in the buffer at once, which will cause a skipped scan for every buffer. If you see your skipped scans increase by the same number regularly, you are likely experiencing this. To eliminate skipped scans, you can increase the number of buffers, increase the scan rate, or change the structure of the program.

有助于了解跳过扫描和缓冲区,请观看下面的短视频。

有关最佳观看,请单击视频控件右侧的全屏按钮。

在the video example, using two buffers instead of one would have eliminated the skipped scans.

Note:PipelineMode,数据记录器使用至少两个缓冲区。

Themaxbuffdepth.value in the data logger’s Status table can be monitored to help understand the optimum number of buffers to allocate for a program.

推荐的佛r You:For more information about the Status table, watch the“连接 - 站状态”视频

在模式之间切换

By default, your CRBasic program will try to compile in pipeline mode. That gives you the most precise measurement timing and usually more efficient processing and power consumption. CRBasic will automatically switch to sequential mode when necessary. Most notably, a program will compile in sequential mode when measurements will not be made every scan (for example, in an如果...那样statement) or when measurements need to be set up externally (for example, the sensor needs to be powered by the SW12 port).

For More Information

请参阅CRBasic编辑器帮助PipelineMode要么顺序显示器更多细节。要访问此资源,请按照下列步骤操作:

  1. SelectPipelineMode要么顺序显示器in the instruction list of the CRBasic Editor.
  2. 点击帮助button above the instruction list.

推荐的佛r You:有关CRBasic编辑器帮助的更多信息,请注意“CRBasic | Help System” video

Credits: John Markham, Product Test Engineer at Campbell Scientific, Inc., contributed to this article.

如果您对如何使用PipelIneMode或SequentialMode有任何疑问,请在下面发布。


Share This Article



关于作者

janet albers珍妮特阿尔伯尔斯持有技术通信经理的标题;她的办公室门以上的标志说,“教练”。她将分享提示,简化概念,并指导您成功的项目。她一直在Campbell S万博matex网页登录cientific,Inc。比CR1000更长,但不仅仅是CR10X。下班后,珍妮特和她的男孩和狗一起享受户外活动。

查看本作者的所有文章。


Comments

minh t.|12/05/2018在08:29 AM

嗨珍妮特,用户如何确定内置(或用户定义)Crbasic子程序或功能是`测量或`processing`任务吗?是否可以查看缓冲区内容?

jra|12/05/2018在08:41 AM

谢谢你的问题minh。

在CRBasic Editor中,从指令列表中选择PipelIneMode,单击“帮助”按钮。在备注下的第一段中,有一个链接到运行作为测量或处理任务的指令列表。

否 - 无法查看缓冲区内容。

I hope that helps. Let me know if you need more informations.

Pleaselog in or register评论。

我们在社交媒体上活跃起来!
Stay informed with our latest updates by following us on these platforms:

Baidu