PLC Programing in C# .NET [closed]

前提是你 提交于 2019-12-09 04:56:56

问题


Can I Write Programs for PLC Controlling in C#? How?


回答1:


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.




回答2:


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:

  1. Deterministic behaviour
  2. 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.

Cheers,

LazzMaTazz




回答3:


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)




回答4:


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.




回答5:


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.




回答6:


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.




回答7:


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




回答8:


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.




回答9:


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.




回答10:


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)

  • OPC DA via COM
  • OPC UA via TCP or webservices



回答11:


What about unitronics. There are communication drivers with source code for all plc model of unitronics




回答12:


C# is not used in PLC world. The closest you can get is something like FEZ Domino with .NET Micro Framework.



来源:https://stackoverflow.com/questions/3302450/plc-programing-in-c-sharp-net

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!