Comunicacion进入Visual Studio C#y un PLC [英] Comunicacion entre visual studio C # y un PLC

查看:101
本文介绍了Comunicacion进入Visual Studio C#y un PLC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



您如何将信息从C#发送到特定的PLC寄存器以及如何识别该注册表?



我正在使用EASYbodbus库



你给我一个错误我希望你能帮我看看它的含义:



EasyModbus.Exceptions.FunctionCodeNotSupportedException:



'主人不支持的功能代码'



我尝试过:



使用系统;

使用System.Collections.Generic;

使用System.Linq;

使用System.Text;

使用System.Threading.Tasks;

使用EasyModbus;









namespace comunicacion_tcp

{

class program

{

private string IpAddress =192.168.178.111;

private int port = 502;

private ushort startAd dres = 0;

私人ushort数量= 2;

私人ModbusClient modbustcp;

公共计划()

{

modbustcp = new ModbusClient(IpAddress,port);

modbustcp.Connect();

int [] response = modbustcp.ReadInputRegisters( startAddres,quantity);

modbustcp.Disconnect();

Console.WriteLine(输入寄存器1的值+响应[0] .ToString());

Console.WriteLine(输入寄存器2的值+响应[1] .ToString());

}

static void Main( string [] args)

{

Program _program = new Program();

Console.ReadKey();

}

}

}

Hello,

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

I'm using the EASYbodbus library

You are giving me an error I would like you to help me to what it refers to:

EasyModbus.Exceptions.FunctionCodeNotSupportedException:

'Function code not supported by master'

What I have tried:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EasyModbus;




namespace comunicacion_tcp
{
class Program
{
private string IpAddress = "192.168.178.111";
private int port = 502;
private ushort startAddres = 0;
private ushort quantity = 2;
private ModbusClient modbustcp;
public Program()
{
modbustcp = new ModbusClient(IpAddress, port);
modbustcp.Connect();
int[] response = modbustcp.ReadInputRegisters(startAddres, quantity);
modbustcp.Disconnect();
Console.WriteLine("value of input register 1" + response[0].ToString());
Console.WriteLine("value of input register 2" + response[1].ToString());
}
static void Main(string[] args)
{
Program _program = new Program();
Console.ReadKey();
}
}
}

推荐答案

假设您使用的是EEIP.NET版本,为什么不呢?在这里问一个问题:[ ^ ]
Assuming you are using the EEIP.NET version, why not ask a question here: [^]


您已在 visual studio C#与PLC之间的通信 [ ^ ] 。请不要重新发布相同的问题。
You already posted this at Communication between visual studio C # and a PLC[^]. Please do not repost the same question.


这篇关于Comunicacion进入Visual Studio C#y un PLC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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