如何使用system.net.sockets与PLC通信以及如何读取数据. [英] How Do I Communicate to a PLC using system.net.sockets and how do i read the data.

查看:281
本文介绍了如何使用system.net.sockets与PLC通信以及如何读取数据.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如问题中提到的,我需要找到一种方法来使用

As mentioned in the question, i need to find a way to use

system.net.sockets

与PLC通信并读取数据,并将其放入列表框中.我已经尝试了许多示例,但到目前为止它们对我不起作用,只有Winsock可以使用,但我不打算使用VB6或更低版本. Winsock ActiveX或其他任何ActiveX控件都是不可能的

请帮助,新手在这里.非常紧急


P.S PLC是可编程逻辑控制器,我需要通过MODBUS TCP/IP进行通信


Travis

to communicate with the PLC and read the data, placing it into the listbox. I have tried many samples and they so far do not work for me, only Winsock does but i am not intending to us VB6 or below. The Winsock ActiveX or any other ActiveX Control out of the question

Pls help, newbie here. Very Urgent


P.S PLC is progammable logic controller and i need to communicate via MODBUS TCP/IP


Travis

推荐答案

您正在处理的是Modbus TCP/IP或Modbus over TCP(又称RTU/IP),这是不一样的.这是您需要在文档中找到的第一件事,如果您知道的话,您可以学习基于Modbus RTU与Modbus ASCII的另一本书.

从这里开始: http://en.wikipedia.org/wiki/Modbus [ http://msdn.microsoft.com/en-us/library/system .net.sockets.tcpclient.aspx [ ^ ].在单独的线程中执行.

这是您可以使用的Modbus协议的C#实现.所有这一切都需要在基本的编程技术方面有相当好的经验,而在网络编程和线程化方面则需要一些经验,这非常简单.

祝你好运,
-SA
You are dealing with Modbus TCP/IP or Modbus over TCP (a.k.a. RTU/IP), which is not the same. This is the first thing you need to find in your documentation, If you know one you can learn another one based on Modbus RTU vs Modbus ASCII.

Start from here: http://en.wikipedia.org/wiki/Modbus[^].

This is a detailed description of Modbus TCP: and robust, it has since become one of the de facto standard communications protocols in the industry, and it is now amongst.

Your operation using C# is fairy simple: you connect to Modbus server using System.Net.Sockets.TcpClient and perform the communication using Modbus protocol. Essentially, you sequentially write/read to/from a network stream available from your instance of TcpClient after connection: send request — get response. See http://msdn.microsoft.com/en-us/library/system.net.sockets.tcpclient.aspx[^]. Do it in a separate thread.

This is a C# implementation of Modbus protocol you can use. All this requires pretty good experience with basic programming techniques and some with network programming and threading, which is fairly simple.

Good luck,
—SA


看看这篇文章: Modbus TCP类 [ ^ ]

最好的问候
Espen Harlinn
Take a look at this article:Modbus TCP class[^]

Best regards
Espen Harlinn


尊敬的SAKryukovv,

多谢!!这些信息确实有所帮助.有一个问题,我可以建立连接,但是我似乎无法从PLC写入/读取数据.非常感谢您的帮助,能否请您显示一些示例代码让我开始使用

特拉维斯·辛格

附言:我将尝试将我的代码在线放置,以便您查看它

尊敬的Santosh,

谢谢,它非常有用,我了解有关通过RTU或串行端口连接到PLC的信息,但是我正在寻找TCP/IP通讯.您的帮助仍然非常有用,我完全理解了

再次感谢

特拉维斯·辛格(Travis Singh)
Dear SAKryukovv,

Thanks A lot!! The information has really helped. There is a problem,I can get a connection but i can''t seem to write/read data from the PLC. Your help is greatly appreciated and could you show some example code for me to get started

Travis Singh

P.S i will try to place my code online so you can take a look at it

Dear Santosh,

Thanks, it was very informative and i understood about about connecting to PLC via RTU or serial port but i am looking for a TCP/IP communication. Your help was still very useful and i understood all of it

Thanks Again

Travis Singh


这篇关于如何使用system.net.sockets与PLC通信以及如何读取数据.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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