performance 使用 OPC 标签提高性能

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39996/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 16:37:40  来源:igfitidea点击:

Improving performance with OPC tags

performanceautomationopc

提问by Tanj

I am working with a PC based automation software package called Think'n'Do created by Phoenix ContactIt does real time processing, read inputs/ control logic / write outputs all done in a maximum of 50ms. We have an OPC server that is reading/writing tags from a PLC every 10ms. There is a long delay in writing a tag to the PLC and reading back the written value (Think'n'Do (50ms) > OPC Server (10ms) > PLC (10ms) > OPC Server (10ms) > Think'n'Do (50ms) ) that process takes up to 6 seconds to complete when it should by my math only take 130ms.

我正在使用由Phoenix Contact创建的名为 Think'n'Do 的基于 PC 的自动化软件包,它进行实时处理、读取输入/控制逻辑/写入输出,所有这些都在最多 50 毫秒内完成。我们有一个 OPC 服务器,它每 10 毫秒从 PLC 读取/写入标签。将标签写入 PLC 并读回写入的值存在较长延迟 (Think'n'Do (50ms) > OPC Server (10ms) > PLC (10ms) > OPC Server (10ms) > Think'n'Do (50ms) ) 这个过程最多需要 6 秒才能完成,而我的数学计算应该只需要 130 毫秒。

Any ideas of where to look or why it might be taking so much longer would be helpful.

关于在哪里查看或为什么可能需要更长的时间的任何想法都会有所帮助。

回答by Garo Yeriazarian

It depends on how you have your OPC client configured to pull data. When you subscribe to a group in OPC, you get to specify a refresh rate. This might default to 1s or even 5s, depending on the OPC client. There's also a limit the OPC server might put on the frequency of updated data. This only applies if you have your OPC client subscribing to data change events.

这取决于您如何将 OPC 客户端配置为提取数据。当您订阅 OPC 中的组时,您可以指定刷新率。这可能默认为 1 秒甚至 5 秒,具体取决于 OPC 客户端。OPC 服务器对更新数据的频率也有限制。这仅适用于您的 OPC 客户端订阅数据更改事件的情况。

The other way you can go is to do async or sync reads / writes to the OPC server. There are several reading modes as well. Since you are using OPC, you can use any OPC compatible client to test your server, this will tell you if the problem is with a setting in Think'n'Do or is it something with the PLC / server.

您可以采用的另一种方法是对 OPC 服务器进行异步或同步读取/写入。还有多种阅读模式。由于您使用的是 OPC,您可以使用任何与 OPC 兼容的客户端来测试您的服务器,这将告诉您问题是出在 Think'n'Do 中的设置还是出在 PLC/服务器上。

The best general purpose OPC client I've used is OPC Quick Client. You can get it with TOP Server here: http://www.toolboxopc.com/Features/Demo/demo.shtml. Just grab the TOP Server demo and install the OPC Quick Client. You can use it to connect to your OPC server and browse the tags and see what the data looks like. The second best OPC client I've used is from ICONICS (called OPC Data Spy) available here: http://www.iconics.com/support/free_tools.asp.

我用过的最好的通用 OPC 客户端是 OPC Quick Client。您可以在此处使用 TOP Server 获取它:http: //www.toolboxopc.com/Features/Demo/demo.shtml。只需获取 TOP Server 演示并安装 OPC Quick Client。您可以使用它连接到您的 OPC 服务器并浏览标签并查看数据的外观。我用过的第二个最好的 OPC 客户端来自 ICONICS(称为 OPC Data Spy),这里提供:http: //www.iconics.com/support/free_tools.asp

Use the OPC client to see how fast you can read the data. Make sure you set the group refresh rate correctly. I think the tools might provide some timing information for you as well (but you'll be able to figure out a 6 second delay pretty easily).

使用 OPC 客户端查看读取数据的速度。确保正确设置组刷新率。我认为这些工具也可能为您提供一些时间信息(但您可以很容易地计算出 6 秒的延迟)。

回答by AndersK

It sounds as if you are not using the cache in the OPC server. Normally OPC servers have a cache, if your client connects and doesn't specify that it wants to use the cache you don't get the performance that you may need. The OPC server is responsible for refreshing the cache from the device although the criteria for refreshing may differ from OPC server to OPC server.

听起来好像您没有使用 OPC 服务器中的缓存。通常 OPC 服务器有一个缓存,如果您的客户端连接并且没有指定它要使用缓存,您将无法获得您可能需要的性能。OPC 服务器负责从设备刷新缓存,尽管刷新标准可能因 OPC 服务器而异。

回答by Rhys

If the system does syncronous reads (blocking I/O call), then implements the logic of your application then syncronous writes (again blocking) then you need to consider that there are multiple round-trips to the PLC.

如果系统执行同步读取(阻塞 I/O 调用),然后实现应用程序的逻辑,然后同步写入(再次阻塞),那么您需要考虑到 PLC 的多次往返。

A syncronous read involves App(request)->OPCServer->PLC->OPCServer->App(result). That is just the read for one item (although you can ask for a group of items in one go).

同步读取涉及 App(request)->OPCServer->PLC->OPCServer->App(result)。这只是对一个项目的读取(尽管您可以一次性要求一组项目)。

Then a similar sync write also involves App(Write)->OPCServer->PLC->OPCServer->App(Done).

那么类似的同步写也涉及到App(Write)->OPCServer->PLC->OPCServer->App(Done)。

Asyncronous reads & writes and group reads & writes can help reduce blocking of the application, but be careful that your aplication can cope with this ansyncronous behavior

异步读取和写入和组读取和写入可以帮助减少应用程序的阻塞,但请注意您的应用程序可以处理这种异步行为

The other thing to look at is the PLC configuration, On Allen-Bradley PLC's there is an interscan delay setting that is used to service I/O requests over external networks. If that time is short and you have a high bandwidth of data then this will slow things down.

要查看的另一件事是 PLC 配置,在 Allen-Bradley PLC 上有一个扫描间延迟设置,用于为外部网络上的 I/O 请求提供服务。如果那段时间很短并且您拥有高带宽的数据,那么这会减慢速度。

回答by Rhys

Here are a few places to look: OPC Client configuration, OPC Client itself, OPC Server, or the PLC itself.

这里有几个地方可以查看:OPC 客户端配置、OPC 客户端本身、OPC 服务器或 PLC 本身。

Here are things you should check:

以下是您应该检查的事项:

  1. OPC Client configuration - The OPC Group you've added the OPC tags to should have a fast scan rate (ie. 100 ms to 1 sec depending on what you use it for). With the act of writing values, do you notice if the values come in faster? If not, then there might be a DCOM or network configuration issue.
  2. OPC Client - Download a free OPC Client software(probably from the OPC Foundation website or major OPC Server software vendors) to see if you get the values back faster. If so, there might be a problem with your client.
  3. OPC Server - Some OPC Server have diagnostic tools. Turn those on and see what is the time the writes actually occur and what time the reads actually take place. If you can answer those questions, you can probably identify whether the culprit of the delay is from the PLC or the OPC Server. Also observe the CPU usage of the OPC Server, if you notice it is using more CPU than normal, it probably means that the OPC Server is loaded down which might deteriorate performance.
  4. Others - Finally check PLC, network are working properly.
  1. OPC 客户端配置 - 您已添加 OPC 标签的 OPC 组应具有快速扫描速率(即 100 毫秒到 1 秒,具体取决于您的用途)。通过写入值的行为,您是否注意到值的输入速度是否更快?如果不是,则可能存在 DCOM 或网络配置问题。
  2. OPC 客户端 - 下载免费的 OPC 客户端软件(可能来自 OPC 基金会网站或主要的 OPC 服务器软件供应商)以查看是否能更快地恢复值。如果是这样,您的客户可能有问题。
  3. OPC Server - 一些 OPC Server 具有诊断工具。打开它们,看看实际写入的时间和读取实际发生的时间。如果您能回答这些问题,您或许可以确定延迟的罪魁祸首是来自 PLC 还是来自 OPC 服务器。还要观察 OPC Server 的 CPU 使用率,如果您发现它使用的 CPU 比正常情况多,则可能意味着 OPC Server 已加载,这可能会降低性能。
  4. 其他 - 最后检查 PLC,网络是否正常工作。