如何使用C#读取S7-300 PLC [英] How to read S7-300 PLC using C#

查看:907
本文介绍了如何使用C#读取S7-300 PLC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨专家,



我是PLC和C#的初学者。您能指导我或提供示例代码来连接和读取PLC数据。 (示例 - PLC db2.real16或db2.dbd16标签)



谢谢

解决方案

作为初学者现在最好的东西(在其他任何事情之前)是如何使用谷歌。例如: Google [ ^ ]



我的gosh接近结果的顶部是CP:使用.NET进行PLC通信 [ ^ ]



另请看: C#Corner:错误显示 [ ^ ]


PLC与客户端之间的直接连接不推荐申请。

大多数P. LC只允许建立一个连接。



通常使用OPC Server作为中间件来处理多个客户端。

Google for支持PLC的OPC服务器。

如果您使用C#,您可以搜索Graybox OPCDA包装器,您可以使用它以安全简便的方式连接到OPC(您还需要本机OPCDA dll )。



如果你选择直接连接到PLC,你必须知道每个PLC(西门子,三菱等)的通信协议是不同的。 PLC必须设置为文本或二进制格式,你必须手动翻译。

有时在PLC中有一个网卡,它有自己的通信协议。



基本上我说的是。使用OPC服务器或尝试使用组件配置PLC并破解通信缓冲区,因为文档几乎永远不对。


带有C#的S7.Net教程
https://www.youtube.com/watch?v=nSnGKm3FSbk&list=PLRCEJ0bGSS1ZlU34IXsIKS62IHH5FcgU1





< iframe width =560height =315src =https://www.youtube.com/embed/nSnGKm3FSbkframeborder =0allowfullscreen>< / iframe> 


Hi Experts,

I am beginner in PLC and C#. Can you guide me or provide sample code to connect and read data from PLC. (example- PLC db2.real16 or db2.dbd16 tags)

Thanks

解决方案

As a beginner the best thing to learn right now (before anything else) is how to use Google. For example: Google[^]

and my gosh right near the top of the results is CP:PLC Communication Using .NET[^]

Also look at: C# Corner : Error Display[^]


Direct connection between PLC and client application is not recommended.
Most PLCs only allow one connection to be established.

Usually one uses an "OPC Server" as middleware to handle multiple clients.
Google for an OPC Server that supports your PLC.
If you are using C# you can search for Graybox OPCDA wrapper which you can use to connect to OPC in a safe and easy way (you also need the native OPCDA dll).

If you do choose to connect straight to PLC, you have to know that the communicationsprotocol is different for every PLC (Siemens,Mitsubishi etc). The PLC have to be set to either text or binary format and you have to translate it manually.
Sometimes there is a networkscard in PLC that have it own communicationsprotocol.

Basically what I´m saying is. Use an OPC Server or work your ass off trying to configure PLC with components and hacking the communications buffer because documentation is almost never right.


S7.Net Tutorial with C#
https://www.youtube.com/watch?v=nSnGKm3FSbk&list=PLRCEJ0bGSS1ZlU34IXsIKS62IHH5FcgU1



<iframe width="560" height="315" src="https://www.youtube.com/embed/nSnGKm3FSbk" frameborder="0" allowfullscreen></iframe>


这篇关于如何使用C#读取S7-300 PLC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆