visual studio C#和PLC之间的通信 [英] Communication between visual studio C # and a PLC

查看:2371
本文介绍了visual studio C#和PLC之间的通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello,

I need to make a system in Visual Studio (C #) that allows me to communicate with the PLC, I am using Delta PLC DVP28SV and Delta module DVPEN01.


I was reading the MODBUS TCP / IP communication, I can not understand.

How would you send the information to a specific PLC register from C # and how to identify that registry?

I would appreciate if someone could guide me on the subject.

Greetings.





我尝试过:





What I have tried:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using ModbusTcp;


namespace Console_ping_Sr2_Electronico
{
    class Program
    {
        static void Main(string[] args)
        {

            System.Net.NetworkInformation.Ping Pings = new System.Net.NetworkInformation.Ping();
            int timeout = 1000;
            int i = 0;
            while (i != 1)
            {
                {
                    if (Pings.Send("192.168.178.111", timeout).Status == IPStatus.Success)
                    {
                        Console.WriteLine("Exito");
                        Thread.Sleep(2000);
                        Console.Clear();
                    }
                    else
                    {
                        
                            Console.WriteLine("Error");
                        Thread.Sleep(2000);
                        Console.Clear();

                    }
                }
            }
        }

推荐答案

你应该与创建它的人交谈 - Delta [ ^ ] - 他们应该提供技术支持,并且会比我们更了解他们的产品。如果他们不这样做,那么找另一个供应商并要求退款!

很可能他们已经有了可以用作基础的工作示例代码。
You should talk to the people who created it - Delta[^] - they should provide technical support and will know more about their product than we will. If they don't, then find another supplier and demand your money back!
Chances are they already have working sample code you can use as a basis.


Modbus TCP / IP是一种非常非常简单的协议。它不需要显式的应用级连接 - 只需要套接字级连接。这意味着您可以向其发送消息并响应该消息,这就是您真正需要担心的事情。当然,如果断开连接,你必须重新连接,但每个插座都是一样的。



还有相当多的示例代码可用,其中一些这也是在这里。只需在文章中搜索关键字modbus,它就会发现:搜索 [ ^ ]
Modbus TCP/IP is a very, very simple protocol. It does not require an explicit, app-level connection - only a socket level connection. This means you can send it a message and it responds to that message and that is really all you have to worry about. Of course, if the connection is dropped you have to reconnect but that is the same with every socket.

There is also quite a bit of sample code available, some of which is here too. Just search the articles for the keyword "modbus" and here is what it finds : Search[^]


这篇关于visual studio C#和PLC之间的通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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