资源简介
上位机与PLC通讯软件(C#),里面包含所需要的三菱DLL,引用后直接使用,已经经过调试,接口可用,需要用MX_Component 软件进行链接配置
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
namespace PLCconnect
{
public class ConnectPLC
{
public bool isPLCConnected = false;
System.String[] arrData = new string[32]; //Array for ‘Data‘
public short[] arrDeviceValue = new short[32]; //Data for ‘DeviceValue‘
public int iReturnCode = 0;
object plcLock = new object();
/*The declaration of instance value for ACT controls************************/
// When you use Dot controls by ‘References‘ you should program as follows;
public ActUtlTypeLib.ActUtlType lpcom_ReferencesUtlType = new ActUtlTypeLib.ActUtlType();
//public ConnectPLC()
//{
// /* Create instance for ACT Controls*************************************/
// lpcom_ReferencesUtlType = new ActUtlTypeLib.ActUtlType();
// /* Set EventHandler for ACT Controls************************************/
// // Create EventHandler(ActUtlType)
// /**************************************************************************/
//}
///
/// 断开PLC连接
///
public void ClosePLC()
{
int iReturnCode; //Return code
//Displayed output data is cleared.
//
//Processing of Close method
//
try
{
//When ActProgType is selected by the radio button
//The Close method is executed.
iReturnCode = lpcom_ReferencesUtlType.Close();
//When The Close method is succeeded enable the TextBox of ‘LogocalStationNumber‘.
if (iReturnCode == 0)
{
isPLCConnected = false;
}
lpcom_ReferencesUtlType = null;
//The return code of the method is displayed by the hexadecimal.
}
//Exception processing
catch (Exception exception)
{
MessageBox.Show(exception.Message ““ MessageBoxButtons.OK MessageBoxIcon.Error);
return;
}
}
#region “PLC连接“
public void connectPLC()
{
int iReturnCode; //Return code
int iLogicalStationNumber = 0; //LogicalStationNumber for ActUtlType
//
//Processing of Open method
//
try
{
//Set the value of ‘LogicalStationNumber‘ to the property.
lpcom_ReferencesUtlType.ActLogicalStationNumber = iLogicalStationNumber;
相关资源
- C# Winform,FX3U-32M,FX3u-ENET-ADP,MC协议
- C#与三菱PLC通讯.rar
- C#与三菱Q系列PLC通讯
- 通过KEPServer opc与PLC通讯程序。
- AB PLC 连接源码c#
- C#对三菱PLC的以太网和串口通讯以及台
- C# 三菱PLC FX5U 通信DEMO
- c#通过MX component连接三菱PLC源代码
- C# 基于以太网使用MX Component控件读写
- C#与西门子PLC测试DOME.rar
- C#与三菱Q系列PLC通过MC协议通信
- C# 写的欧姆龙PLC通讯程序源码
- 上位机与PLC通讯源码
- C#winform与三菱Q系列PLC通讯
- stm32f103rct6仿三菱plc
- C#winform与西门子1200、1500系列PLC通讯
- C#和西门子PLC通讯源码C# VB都有
- C#编写OMRON Fins TCP协议与OMRON PLC通讯
- C#与PLC通讯
- C#与三菱PLC通讯源码 串口通讯
- C#连接三菱PLC
- C#通过TCP/IP和PLC通讯
- C#和西门子PLC通讯
- VS2005 C# MX控件 与PLC通讯
- 三菱FX PLC 串口通讯开关量输入/输出
- 通过串口与三菱PLC进行通讯,能读取
- 基于C#与台达PLC通讯例程
-
C# PLC通讯(hostli
nk) - C#上位机与PLC通讯PanasonicPLC/三菱PLC
- C# 与三菱PLC 通讯源码
评论
共有 条评论