PLC,Modbus,引擎和传感器... [英] PLC, Modbus, engines and sensors...

查看:114
本文介绍了PLC,Modbus,引擎和传感器...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通过ModbusRTU与PLC通信,并基于从某些传感器收集的数据来控制某些引擎,但是我不知道如何使用C#进行操作.我之前已经做过一些C#应用程序(所以我知道基础知识),但是却没有那样的东西,所以我对这种编程还是陌生的.

知道我该怎么办吗?

预先感谢

I need to comunicate to a PLC via ModbusRTU and control some engines based on the data collected from some sensors, but I have no idea how to do it using C#. I have done some C# aplications before( so I know the basics), but nothing like that, so I''m new to that kind of programming.

Any idea how could I do it?

Thanks in advance

推荐答案

如Collin所说,请使用串行端口与MODBUS设备进行通信.但是,您可能需要一个适配器,因为通常的实现是RS-485,而不是PC上提供的RS-232端口.当您在Google周围搜寻时会发现,MODBUS使用一些奇怪的数据类型,尤其是位数据,这些数据类型已映射到RTU中的特定内存地址. RTU/PLC处理器读取和写入这些内存地址以获得配置设置,接收命令和记录数据.您的应用程序应该能够写入这些内存位,并能够从RTU内存中选择指定的数据片.

根据设备的不同,它可能会生成警报,在这种情况下,您需要密切监视端口.我会将功能粘贴在一个单独的线程中,当出现警报时,该线程可以中断应用程序的其余部分.否则,在RTU从机模式下,设备将仅执行其PLC程序,直到您对其进行轮询为止.

几个月前,我花了很多时间研究这个问题,因为我公司拥有57个下水道升降站,这些站由艾伦·布拉德利(Allen Bradley)PLC使用MODBUS协议进行控制.我的目标是有一天通过无线电链接它们,并编写一个SCADA系统来从办公室监视和控制它们.我期待着您一定会在完成时为我们写的文章,并计划从中学习如何正确地完成它.:-)
As Collin has said, use the serial port to communicate with the MODBUS device. You''ll probably need an adapter, though, as the usual implementation is RS-485, not the RS-232 port provided on a PC. As you''ll discover when you Google around, MODBUS uses some weird data types, especially bit data, which are mapped to specific memory addresses in the RTU. The RTU/PLC processor reads and writes to these memory addresses to obtain configuration settings, receive commands, and record data. Your application should be able to write to these memory bits and to select specified slices of data from the RTU memory.

Depending on the device, it might be able to generate alarms, in which case you''ll want to monitor the port closely. I''d stick that function in a separate thread that can interrupt the rest of the application when an alarm comes in. Otherwise, in the RTU slave mode, the device will simply execute its PLC program until you poll it.

This is something I spent a lot of time looking into a few months back, as my company has 57 sewer lift stations which are controlled by Allen Bradley PLCs using a MODBUS protocol for control. My goal is to one day link them via radio, and write a SCADA system to monitor and control them from the office. I''ll look forward to the article you''ll surely be writing for us when it''s done, and plan to learn from it how this is done properly.:-)


只是好奇为什么要这样做?

为什么不使用PLC语言控制引擎?通过使用C#应用程序,您有冒险使引擎最终陷入故障状态的危险.如您所知,PC喜欢关闭并断开通信.这可能会导致引擎空转甚至使引擎加速运转.

过去我做过类似的事情,最好让PLC具有用于状态控制的基本逻辑.然后,如果您不喜欢UI或只想在标准PC(而不是Windows CE或其他设备)上工作,则可以通过TCP/IP进行通信(如果可能).

如果您仍然需要,我猜您将需要使用串行通信端口连接到Modbus.您将需要查看如何执行此操作的协议.

[ ^ ]应该可以帮助您入门.同样,尽管出于状态控制的原因,我还是建议不要这样做. PLC更加健壮,应该完全控制状态.外部应用程序仅应请求"状态更改.
Just curious why you want to do this?

Why not control the engines using the PLC language? By using a C# app you are risking that the engine ends up in a bad state. PCs like to shut down and drop communication as you may know. This could do something such as leave the engine running dry or even worse ramp it up.

I have done similar things in the past and it is really best to have the PLC have base logic, for state control. Then if you are not liking the UI or want to simply work from a standard PC (not a Windows CE or something) you communicate via TCP/IP (if possible).

If you still need to I am guessing you will need to use a serial communication port to connect to the Modbus. You will need to look at the protocols of how to do this.

This[^] should get you started. Again, I would recomend not doing it though for state control reasons. PLCs are more robust and should have full control over the state. External apps should merely ''request'' state change.


这篇关于PLC,Modbus,引擎和传感器...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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