PLC通讯实现-C#实现AB-CIP以太网通讯

  • 背景
  • AB-CIP以太网通讯实现
  • 引用库下载

背景

本人近十年的工作都与工业软件相关、其中工控系统开发过程中有一个必要环节就是跟各大厂商的PLC进行通讯,而对于从互联网行业跨入工业互联网行业的从业人员来说要实现各型号PLC通讯还是需要一个过程的,本人在此对主流型号PLC通讯实现进行总结以便大家参考。

AB-CIP以太网通讯实现

1、开发语言
开发语言为C#
2、通讯库封装
所有通讯的关键代码封装到Wongoing.Plc.Communication.dll中
3、在项目引用Wongoing.Plc.Communication.dll
4、实现PLC的读写测试的代码如下:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Wongoing.Plc.Communication;namespace WinTestApp
{public partial class Form1 : Form{private Wongoing.Plc.Communication.Profinet.AllenBradley.AllenBradleyNet equip = new Wongoing.Plc.Communication.Profinet.AllenBradley.AllenBradleyNet("192.168.4.200");public Form1(){InitializeComponent();}private void button1_Click(object sender, EventArgs e){OperateResult result = this.equip.ConnectServer();if (result.IsSuccess){Console.WriteLine("连接成功!");}else{Console.WriteLine("连接失败!");Console.WriteLine(result.ToMessageShowString());}}private void button2_Click(object sender, EventArgs e){#region uint16//string tagName = "UpCmd_M[0]";//OperateResult<UInt16[]> result = this.equip.ReadUInt16(tagName, 1);//if (result.IsSuccess)//{//    foreach (UInt16 value in result.Content)//    {//        Console.WriteLine(value);//    }//    Console.WriteLine();//}//else//{//    Console.WriteLine("读取失败!");//    Console.WriteLine(result.ToMessageShowString());//}#endregion#region int16string tagName = "UpCmd_M[0]";OperateResult<Int16[]> result = this.equip.ReadInt16(tagName, 5);if (result.IsSuccess){foreach (Int16 value in result.Content){Console.Write(value + "\t");}Console.WriteLine();}else{Console.WriteLine("读取失败!");Console.WriteLine(result.ToMessageShowString());}#endregion#region UInt32//string tagName = "EM_Back_Stitcher_SFC_A[0]";//OperateResult<UInt32[]> result = this.equip.ReadUInt32(tagName, 1);//if (result.IsSuccess)//{//    foreach(UInt32 value in result.Content)//    {//        Console.WriteLine(value);//    }//    Console.WriteLine();//}//else//{//    Console.WriteLine("读取失败!");//    Console.WriteLine(result.ToMessageShowString());//}#endregion#region int32//string tagName = "Operating_Status_HMI_S";//OperateResult<Int32[]> result = this.equip.ReadInt32(tagName, 4);//if (result.IsSuccess)//{//    foreach(Int32 value in result.Content)//    {//        Console.WriteLine(value + "\t");//    }//    Console.WriteLine();//}//else//{//    Console.WriteLine("读取失败!");//    Console.WriteLine(result.ToMessageShowString());//}#endregion#region bool//string tagName = "EM_Back_Stitcher_SFC_A[0]";//OperateResult<bool[]> result = this.equip.ReadBoolArray(tagName);//if (result.IsSuccess)//{//    foreach (bool value in result.Content)//    {//        Console.WriteLine(value);//    }//    //Console.WriteLine(result.Content);//}//else//{//    Console.WriteLine("读取失败!");//    Console.WriteLine(result.ToMessageShowString());//}#endregion#region string//string tagName = "Recipe_D"; //OperateResult<string> result = this.equip.ReadString(tagName);//if (result.IsSuccess)//{//    Console.WriteLine(result.Content);//}//else//{//    Console.WriteLine("读取失败!");//    Console.WriteLine(result.ToMessageShowString());//}#endregion#region byte//for(int i = 0; i < 50; i++)//{//    string tagName = String.Format("NL_Stitching_Auto_Action[{0}]", i);//    //OperateResult<SFC_ACTION> result = this.equip.ReadCustomer<SFC_ACTION>(tagName);//    //if (result.IsSuccess)//    //{//    //    Console.WriteLine(result.Content); //    //}//    //else//    //{//    //    Console.WriteLine("读取失败!");//    //    Console.WriteLine(result.ToMessageShowString());//    //}//    OperateResult<byte[]> result = this.equip.Read(tagName, 1);//    if (result.IsSuccess)//    {//        //Console.WriteLine(result.Content);//        foreach (byte value in result.Content)//        {//            Console.Write(value + "\t");//        }//        Console.WriteLine();//        Console.WriteLine("-----------------------------------------------------");//        Console.WriteLine( i + " Length = " + result.Content.Length);//    }//    else//    {//        Console.WriteLine("读取失败!");//        Console.WriteLine(result.ToMessageShowString());//    }//}#endregion}private void button3_Click(object sender, EventArgs e){#region uint16//string tagName = "UpCmd_M[0]";//OperateResult result = this.equip.Write(tagName, new UInt16[] { 1 });//if (result.IsSuccess)//{//    Console.WriteLine("写入成功!");//}//else//{//    Console.WriteLine("写入失败");//    Console.WriteLine(result.ToMessageShowString());//}#endregion#region int16string tagName = "UpCmd_M[0]";OperateResult result = this.equip.Write(tagName, new Int16[] { 6, 7, 8, 9, 10 });if (result.IsSuccess){Console.WriteLine("写入成功!");}else{Console.WriteLine("写入失败!");Console.WriteLine(result.ToMessageShowString());}#endregion#region Int32//string tagName = "EM_Back_Stitcher_SFC_A[0]";//OperateResult result = this.equip.Write(tagName, new int[] { 1 });//if (result.IsSuccess)//{//    Console.WriteLine("写入成功!");//}//else//{//    Console.WriteLine("写入失败");//    Console.WriteLine(result.ToMessageShowString());//}#endregion#region UInt32//string tagName = "EM_Back_Stitcher_SFC_A";//OperateResult result = this.equip.Write(tagName, new Int32[] { 1, 192 });//if (result.IsSuccess)//{//    Console.WriteLine("写入成功!");//}//else//{//    Console.WriteLine("写入失败");//    Console.WriteLine(result.ToMessageShowString());//}#endregion#region bool//string tagName = "DB200";//OperateResult result = this.equip.Write(tagName, false);//if (result.IsSuccess)//{//    Console.WriteLine("写入成功!");//}//else//{//    Console.WriteLine("写入失败");//    Console.WriteLine(result.ToMessageShowString());//}//string tagName = "EM_Back_Stitcher_SFC_A[0].0";//OperateResult result = this.equip.Write(tagName, true);//if (result.IsSuccess)//{//    Console.WriteLine("写入成功!");//}//else//{//    Console.WriteLine("写入失败");//    Console.WriteLine(result.ToMessageShowString());//}#endregion#region string//string tagName = "Recipe_D";//OperateResult result = this.equip.Write(tagName, "67001259P");//if (result.IsSuccess)//{//    Console.WriteLine("写入成功!");//}//else//{//    Console.WriteLine("写入失败!");//    Console.WriteLine(result.ToMessageShowString());//}#endregion}private void button4_Click(object sender, EventArgs e){OperateResult result = this.equip.ConnectClose();if (result.IsSuccess){Console.WriteLine("关闭成功");}else{Console.WriteLine("关闭失败");Console.WriteLine(result.ToMessageShowString());}}private void button5_Click(object sender, EventArgs e){byte[] content = { 0, 0, 32, 0 };Int32 value = BitConverter.ToInt32(content, 0);Console.WriteLine(value);}}
}

引用库下载

Wongoing.Plc.Communication.dll下载

PLC通讯实现-C#实现AB-CIP以太网通讯相关推荐

  1. Omorn - NJ301-1100 AND NX102-9000 - CIP - UCMM 通讯

    目录 Omorn - NJ301-1100 AND NX102-9000 - CIP - UCMM 通讯 测试案例IP 创建变量类型 指令编写加数据测试 Omorn - NJ301-1100 AND ...

  2. PLC通讯实现-C#实现AB5000 PLC以太网通讯DTL32(八)

    PLC通讯实现-C#实现AB5000 PLC以太网通讯DTL32(八) 背景 抽象设计 背景 本人近十年的工作都与工业软件相关.其中工控系统开发过程中有一个必要环节就是跟各大厂商的PLC进行通讯,而对 ...

  3. 信捷xd5接线图_信捷XD5E系列以太网通讯型PLC

    产品特点 XD5E系列以太网PLC,包含24.30.48.60点规格. 兼容XD5的所有功能,支持以太网通讯 速度是XC系列的12倍,具备更大的内部资源空间 输入类型:NPN 输出类型:晶体管(T) ...

  4. PLC通讯实现-C#实现欧姆龙以太网通讯FINS(二)

    PLC通讯实现-C#实现欧姆龙以太网通讯FINS(二) 背景 抽象设计 欧姆龙以太网通讯实现FINS 背景 本人近十年的工作都与工业软件相关.其中工控系统开发过程中有一个必要环节就是跟各大厂商的PLC ...

  5. Profinet高速协议下,PLC之间如何实现无线以太网通讯?

    本文以西门子S7-200SMART为例,介绍两台S7-200Smart PLC的无线 Profinet通信实现过程.无需更改网络参数和原有程序,也不必了解Profinet协议细节,只需要采用西门子PL ...

  6. PLC通讯实现-C#实现西门子PLC以太网通讯Sharp7(六)

    PLC通讯实现-C#实现西门子PLC以太网通讯Sharp7(六) 背景 抽象设计 西门子以太网通讯实现Sharp7 背景 本人近十年的工作都与工业软件相关.其中工控系统开发过程中有一个必要环节就是跟各 ...

  7. 三菱FX系列PLC以太网通讯

    三菱FX系列PLC以太网通讯 BCBet-FX用于三菱FX1N/1S/2N/3U/3G/3S等系列PLC,以及汇川.禾川.士林等品牌PLC. BCBet-FX 以太网模块采用三通设计,不占用PLC通讯 ...

  8. WINCC软件与西门子PLC以太网通讯

    摘要 SIMATIC WinCC(Windows Control Center)--视窗控制中心,它是系统过程控制系统及其它西门子控制系统中的人机界面组件,具有良好的开放性和灵活性.Wincc可以监视 ...

  9. 汇川HnU系列PLC以太网通讯解决方案

    描述: 汇川H0U/H1U/H2U/H3U等系列PLC以及一体机的422通讯和485通讯的以太网扩展解决方案. 桥接器采用三通设计,不占用PLC通讯口,不对原系统做任何硬件和软件修改,即可通过模块的网 ...

  10. 施耐德PLC与西门子PLC以太网通讯

    摘要 施耐德PLC(如:Quantum系列)需要和西门子S7300.S7200等PLC进行以太网数据通讯..本文通过通讯桥接器NET30,实现西门子PLC与施耐德PLC进行modbusTCP以太网通讯 ...

最新文章

  1. 1-runtime的Method,IMP,Property,ivar
  2. Linux-Load Average解析
  3. 传智播客--WPF基础视频学习--sender解释(小白内容)
  4. 如何将git上的代码迁移到Coding上
  5. Node.js中的常用工具类util
  6. Python实用小技能,一个比一个高级!
  7. python拼图游戏_乐趣无穷的Python课堂
  8. 【渝粤教育】国家开放大学2018年秋季 0653-21T机电控制与可编程控制技术 参考试题
  9. 前端面试技巧和注意事项_前端面试百分之九十九过的技巧
  10. python基础之“换行符”的应用
  11. python计算蛋白质的质量
  12. java中list里面存放map,根据map中的某一个字段进行排序
  13. c+字符串数组_了解C ++字符串数组
  14. 用CentOS 6快速配置一台企业级Web代理服务器
  15. Web前端:前12个易于Web开发的前端开发工具
  16. 回归分析中,证明:总离差平方和=回归平方和+误差平方和。
  17. 原型链面向对象----多态
  18. OllyDebug破解第一个 CM 程序 《Acid burn.exe》
  19. python这个怎么读-python怎么读(python怎么读中文)
  20. A Strong Baseline and Batch Normalization Neck for Deep Person Re-identification(论文笔记)(2019CVPR)

热门文章

  1. 游戏引擎与游戏开发入门介绍
  2. 圣诞节用代码写一颗圣诞树【html5写的3D逼真圣诞树外加python无延迟的豪华圣诞树】
  3. 开始topcoder
  4. 计算机应用基础评价手册,中职计算机应用基础教案【精选】.doc
  5. 程序员眼中看到的网页是如何制作出来的?
  6. Cortex-M3概览
  7. 【游戏引擎Easy2D】一篇打通引擎进阶类型,Keycode+MouseCode+Image
  8. 【计算机网络】计算机网络、互联网、互连网、因特网、万维网
  9. 论坛php board,Crossday Discuz! Board 论坛系统Discuz!
  10. Python 数据扩充(亮度、翻转、噪声)