Not likely. C# requires an implementation of the Common Language Runtime (CLR) to run applications developed in that language or any .NET language. I would say it is very unlikely that any PLC will ever be manufactured which supports this for various reasons.
Now what you can do is have your C# application read and write data from the PLC using the OPC protocol. There are a few different libraries for using OPC that are available for the .NET Framework.
Here is a pretty good website for laying out the options.
Beckhoff actually provide an interface (ADS) for direct manipulation of variables in the PLC program using C# (and other languages), that can be used for TwinCAT 2 or 3. As Ahmed Yazan Tibi also correctly said, you can use C++ directly in your PLC program in TC3 too.
You would still need to create variables within the PLC program, and 'connect' them to physical interfaces using Beckhoff's system manager software before this would be useful though.
While this is entirely possible, you would be overlooking and ignoring some of the key strengths of programming directly in the PLC environment by going down this route:
Deterministic behaviour
Run-time safety
Having said that, it has many benefits - from being able to very simply interface any kind of front end technology to logging data directly into databases and everything in between.
TwinCAT from Beckhoff is the way! In orther way you must use IEC 6113-3 with it's 5 styles of programming including the "Structured Text" code that is the nearest "Text code looklike".
Warning, never create a program with a constant loop (while( 1 ) ) it would be detected as a fault. The loop is global and is validated.
No, at least not now. As for the future? Almost certainly not then either, IMO.
PLC's are just too hardware specific to have a program written using the CLR.
If you are interested in writing code that is portable across different types of PLC's, the closest you will get right now is by using IEC 6113-3 Structured Text code.
Most, if not all the leading PLC manufacturers are able to use this now, including Omron, Siemens, Allen Bradley, Mitsubishi, Telemecanique and probably more.
I am currently doing it, in a live environment. We are using the Modbus protocol, over TCP.
I am not going to say that its easy going, or the best option for PLC programming, but it does work, and we have live machines out there in the world, working and running in hospitals near you :)
It doesn't even have to be C#, you can use any language that can communicate over TCP, you just have to program a Modbus interface that works over TCP, which is surprisingly easy. Then you need to get hold of some Slave Controllers that take Modbus TCP and translate the commands over to other parts of the setup.
Many people will frown at this point and say rubbish like, "not a deterministic environment", or "memory management" or my favourite one "not running on a RTOS". All these are rubbish. Very few environments out there require RTOS, or deterministic programming to make it work, in fact 200ms response time is fine, which we have found c# to do most capably. If your environment requires RTOS, I would not recommend using C# but if like the most environments, you just need to control stuff in a human perceptive time, then C# [fill you language choice here] is fine.
Oh and stay clear of ladder programming, or whatever that crap is, its stupid, designed for electrical engineers, to make their transition easier.
Yes, you can definitely write software to read and write to a PLC using C#. However, it may take a lot of work. If you're lucky you can track down a .NET libraries for your PLCs of interest. In my case that was an DirectLogic PLC EBC module where I found a VB.NET library here and an Allen Bradley SLC Micro where I found another VB.NET library here. Both cases I had to refactor the code a bit and then reference it from my C# application.
If you can't find a .NET library you can usually get hold of some C/C++ code and then port it yourself. Then if worse comes to worst and there is only a precompiled library, there is always native interop.
It's been a long time since I did any PLC programming, but isn't a PLC just a set of logic gates that make decisions based upon inputs, timers etc and post an output? So why can't vb or c# or any .Net language carry out this logic?
it's not a question of instructing a plc, it's more a question of can it replace a plc if the hardware,drivers and dll's where available.
Surely this will come soon if not already available.
You can communicate from a.net application towards a plc by retrieving or storing data from the memory in the plc, this is called a DB. Then you can use these variables to manipulate the code of the plc.
TCPIP communication with plc can be done with an opensource api snap7 that is only compatible with siemens plc.
Perhaps a bit more reliable setup is the communication over an opc server. This can be done by kepware or SNMP SIEMENS
There are several .net API that can be bought allowing to communication over an opc by these protocols (there are other protocols)
发布评论
评论(12)
不太可能。 C# 需要公共语言运行时 (CLR) 的实现才能运行用该语言或任何 .NET 语言开发的应用程序。我想说,由于各种原因,不太可能制造出任何支持这一点的 PLC。
现在您可以做的是让 C# 应用程序使用 OPC 协议从 PLC 读取和写入数据。有几个不同的库可用于 .NET Framework 使用 OPC。
这里是一个非常好的用于列出选项的网站。
Not likely. C# requires an implementation of the Common Language Runtime (CLR) to run applications developed in that language or any .NET language. I would say it is very unlikely that any PLC will ever be manufactured which supports this for various reasons.
Now what you can do is have your C# application read and write data from the PLC using the OPC protocol. There are a few different libraries for using OPC that are available for the .NET Framework.
Here is a pretty good website for laying out the options.
Beckhoff 实际上提供了一个接口 (ADS),用于使用 C#(和其他语言)直接操作 PLC 程序中的变量,该接口可用于 TwinCAT 2 或 3。正如 Ahmed Yazan Tibi 也正确地说的那样,您可以直接在您的程序中使用 C++。 PLC程序也在TC3中。
请参见此处:http://www.beckhoff.com/english.asp?twincat/twincat_ads_communication_library.htm
您仍然需要在 PLC 程序中创建变量,并使用 Beckhoff 的系统管理器软件将它们“连接”到物理接口,然后才能发挥作用。
虽然这是完全可能的,但如果按照以下路线,您将忽略直接在 PLC 环境中编程的一些关键优势:
话虽如此,它有很多好处 - 从能够非常只需连接任何类型的前端技术即可将数据直接记录到数据库及其之间的所有内容中。
干杯,
拉兹玛塔兹
Beckhoff actually provide an interface (ADS) for direct manipulation of variables in the PLC program using C# (and other languages), that can be used for TwinCAT 2 or 3. As Ahmed Yazan Tibi also correctly said, you can use C++ directly in your PLC program in TC3 too.
See here: http://www.beckhoff.com/english.asp?twincat/twincat_ads_communication_library.htm
You would still need to create variables within the PLC program, and 'connect' them to physical interfaces using Beckhoff's system manager software before this would be useful though.
While this is entirely possible, you would be overlooking and ignoring some of the key strengths of programming directly in the PLC environment by going down this route:
Having said that, it has many benefits - from being able to very simply interface any kind of front end technology to logging data directly into databases and everything in between.
Cheers,
LazzMaTazz
Twincat 版本 3(倍福 PLC 开发环境)除了支持 C# 之外,还将支持 C++ 编程语言
EN | TwinCAT 3:Visual Studio 集成、语言支持 (SPS/IPC/DRIVES 2010)
Twincat version 3 (which is Beckhoff PLC developing environment) will support C++ programming language in addition to C#
EN | TwinCAT 3: Visual Studio integration, language support (SPS/IPC/DRIVES 2010)
Beckhoff 的 TwinCAT 就是这样!否则,您必须使用 IEC 6113-3 及其 5 种编程风格,包括最接近“文本代码外观”的“结构化文本”代码。
警告,切勿创建带有常量循环 (while(1)) 的程序,否则会被检测为错误。该循环是全局的并且经过验证。
享受PLC编程。
TwinCAT from Beckhoff is the way! In orther way you must use IEC 6113-3 with it's 5 styles of programming including the "Structured Text" code that is the nearest "Text code looklike".
Warning, never create a program with a constant loop (while( 1 ) ) it would be detected as a fault. The loop is global and is validated.
Enjoy PLC programming.
不,至少现在不是。至于未来?在我看来,几乎肯定也不会。
PLC 的硬件特定性太强,无法使用 CLR 编写程序。
如果您有兴趣编写可在不同类型的 PLC 之间移植的代码,那么您现在最接近的方法是使用 IEC 6113-3 结构化文本代码。
大多数(如果不是全部)领先的 PLC 制造商现在都能够使用它,包括 Omron、Siemens、Allen Bradley、Mitsubishi、Telemecanique 等。
No, at least not now. As for the future? Almost certainly not then either, IMO.
PLC's are just too hardware specific to have a program written using the CLR.
If you are interested in writing code that is portable across different types of PLC's, the closest you will get right now is by using IEC 6113-3 Structured Text code.
Most, if not all the leading PLC manufacturers are able to use this now, including Omron, Siemens, Allen Bradley, Mitsubishi, Telemecanique and probably more.
是的,你可以。
我目前正在现场环境中这样做。我们使用基于 TCP 的 Modbus 协议。
我不会说它很容易操作,或者是 PLC 编程的最佳选择,但它确实有效,而且我们在世界各地都有现场机器,在您附近的医院工作和运行:)
它甚至没有对于 C#,您可以使用任何可以通过 TCP 进行通信的语言,您只需编写一个通过 TCP 工作的 Modbus 接口即可,这非常简单。然后,您需要获取一些采用 Modbus TCP 的从属控制器,并将命令转换为设置的其他部分。
许多人此时会皱起眉头,说一些垃圾话,比如“不是确定性环境”、“内存管理”或我最喜欢的“不在 RTOS 上运行”。所有这些都是垃圾。很少有环境需要 RTOS 或确定性编程来使其工作,事实上 200 毫秒的响应时间就足够了,我们发现 C# 最能做到这一点。如果您的环境需要 RTOS,我不建议使用 C#,但如果像大多数环境一样,您只需要在人类感知时间内控制内容,那么 C# [在此处填写您的语言选择] 就可以了。
哦,远离梯形图编程,或者无论什么垃圾,它是愚蠢的,专为电气工程师设计的,以使他们的过渡更容易。
yes you can.
I am currently doing it, in a live environment. We are using the Modbus protocol, over TCP.
I am not going to say that its easy going, or the best option for PLC programming, but it does work, and we have live machines out there in the world, working and running in hospitals near you :)
It doesn't even have to be C#, you can use any language that can communicate over TCP, you just have to program a Modbus interface that works over TCP, which is surprisingly easy. Then you need to get hold of some Slave Controllers that take Modbus TCP and translate the commands over to other parts of the setup.
Many people will frown at this point and say rubbish like, "not a deterministic environment", or "memory management" or my favourite one "not running on a RTOS". All these are rubbish. Very few environments out there require RTOS, or deterministic programming to make it work, in fact 200ms response time is fine, which we have found c# to do most capably. If your environment requires RTOS, I would not recommend using C# but if like the most environments, you just need to control stuff in a human perceptive time, then C# [fill you language choice here] is fine.
Oh and stay clear of ladder programming, or whatever that crap is, its stupid, designed for electrical engineers, to make their transition easier.
是的,许多 PLC 制造商提供了 DLL 文件来与基于 PC 的软件(如 VB、C#、VB.NET)进行通信。
在 DELTA PLC 网站上,您将找到与 Delta PLC 通信的 C# 代码。
要了解如何使用 VB 进行 PLC 通信,您可以访问
http://plc-scada-dcs.blogspot.com/2013/06/plc-visual-basic-60-communication-using.html
yes number of PLC manufacturer provides DLL files to communicate with PC based softwares Like VB, C # ,VB.NET.
On DELTA PLC Site you will find Code for C# to comm with Delta PLC.
To see how to communicate PLC with VB you can visit
http://plc-scada-dcs.blogspot.com/2013/06/plc-visual-basic-60-communication-using.html
是的,您绝对可以使用 C# 编写软件来读写 PLC。然而,这可能需要做很多工作。如果幸运的话,您可以为您感兴趣的 PLC 找到 .NET 库。就我而言,这是一个 DirectLogic PLC EBC 模块,我在此处找到了 VB.NET 库和 Allen Bradley SLC Micro,我在此处找到了另一个 VB.NET 库。在这两种情况下,我都必须稍微重构代码,然后从我的 C# 应用程序中引用它。
如果找不到 .NET 库,通常可以获取一些 C/C++ 代码,然后自行移植。然后,如果情况变得更糟并且只有预编译库,则始终有 本机互操作。
Yes, you can definitely write software to read and write to a PLC using C#. However, it may take a lot of work. If you're lucky you can track down a .NET libraries for your PLCs of interest. In my case that was an DirectLogic PLC EBC module where I found a VB.NET library here and an Allen Bradley SLC Micro where I found another VB.NET library here. Both cases I had to refactor the code a bit and then reference it from my C# application.
If you can't find a .NET library you can usually get hold of some C/C++ code and then port it yourself. Then if worse comes to worst and there is only a precompiled library, there is always native interop.
我已经很久没有进行过 PLC 编程了,但是 PLC 不就是一组根据输入、定时器等做出决策并发布输出的逻辑门吗?那么为什么 vb 或 c# 或任何 .Net 语言不能执行此逻辑呢?
这不是指导PLC的问题,更多的是如果硬件、驱动程序和DLL可用的话它能否取代PLC的问题。
当然,如果还没有的话,它很快就会实现。
It's been a long time since I did any PLC programming, but isn't a PLC just a set of logic gates that make decisions based upon inputs, timers etc and post an output? So why can't vb or c# or any .Net language carry out this logic?
it's not a question of instructing a plc, it's more a question of can it replace a plc if the hardware,drivers and dll's where available.
Surely this will come soon if not already available.
您可以通过从 plc 内存中检索或存储数据来从 .net 应用程序与 plc 进行通信,这称为DB。然后你就可以使用这些变量来操作plc的代码。
与plc的TCPIP通信可以使用仅与siemens plc兼容的开源api snap7来完成。
也许更可靠的设置是通过 opc 服务器进行通信。这可以通过 kepware 或 SNMP SIEMENS 来完成。
可以购买多种 .net API,允许通过这些协议(还有其他协议)通过 opc 进行通信。
You can communicate from a.net application towards a plc by retrieving or storing data from the memory in the plc, this is called a DB. Then you can use these variables to manipulate the code of the plc.
TCPIP communication with plc can be done with an opensource api snap7 that is only compatible with siemens plc.
Perhaps a bit more reliable setup is the communication over an opc server. This can be done by kepware or SNMP SIEMENS
There are several .net API that can be bought allowing to communication over an opc by these protocols (there are other protocols)
unitronics 怎么样。有unitronics所有plc型号的通讯驱动程序和源代码
What about unitronics. There are communication drivers with source code for all plc model of unitronics
PLC 领域不使用 C#。您可以获得的最接近的是带有 .NET Micro Framework 的 FEZ Domino 。
C# is not used in PLC world. The closest you can get is something like FEZ Domino with .NET Micro Framework.