关于224226plc源码的信息
本文目录一览:
- 1、哪位有C#与三菱PLC通讯的源码,最好有实例
- 2、您好PLC怎么提供源代码啊?
- 3、西门子PLC的CPU221.222.224226和CPU224XP是一个编程软件吗?
- 4、plc程序源代码用什么程序写的
哪位有C#与三菱PLC通讯的源码,最好有实例
提供一个C#与FX5U以太网通讯224226plc源码的代码:
using System.Collections.Generic;
using System;
using System.Linq;
using System.Drawing;
using System.Diagnostics;
using System.Data;
using System.Xml.Linq;
using Microsoft.VisualBasic;
using System.Collections;
using System.Windows.Forms;
using System.Net;
using System.Runtime.InteropServices;
namespace TCP_CLIENT
{
public partial class Form1
{
public Form1()
{
InitializeComponent();
if (defaultInstance == null)
defaultInstance = this;
}
#region Default Instance
private static Form1 defaultInstance;
public static Form1 Default
{
get
{
if (defaultInstance == null)
{
defaultInstance = new Form1();
defaultInstance.FormClosed += new FormClosedEventHandler(defaultInstance_FormClosed);
}
return defaultInstance;
}
set
{
defaultInstance = value;
}
}
static void defaultInstance_FormClosed(object sender, FormClosedEventArgs e)
{
defaultInstance = null;
}
#endregion
EntFxPlc.PlcClient PLC = new EntFxPlc.PlcClient();
bool EntLink;
long ScanCount;
short ScanRet;
Int32 PlcHand;
[DllImport("winmm.dll", ExactSpelling=true, CharSet=CharSet.Ansi, SetLastError=true)]
public static extern UInt32 timeGetTime();
public void Form1_Load(System.Object sender, System.EventArgs e)
{
this.CenterToScreen();
cmbReadMry.Items.Clear();
cmbReadMry.Items.Add("X");
cmbReadMry.Items.Add("Y");
cmbReadMry.Items.Add("M");
cmbReadMry.Items.Add("D");
cmbWriteMry.Items.Clear();
cmbWriteMry.Items.Add("X");
cmbWriteMry.Items.Add("Y");
cmbWriteMry.Items.Add("M");
cmbWriteMry.Items.Add("D");
cmbBitMry.Items.Clear();
cmbBitMry.Items.Add("X");
cmbBitMry.Items.Add("Y");
cmbBitMry.Items.Add("M");
cmbReadType.Items.Clear();
cmbReadType.Items.Add("INT16");
cmbReadType.Items.Add("UINT16");
cmbReadType.Items.Add("DINT32");
cmbReadType.Items.Add("HEX32");
cmbReadType.Items.Add("REAL32");
cmbReadType.Items.Add("BIN16");
cmbWriteType.Items.Clear();
cmbWriteType.Items.Add("INT16");
cmbWriteType.Items.Add("UINT16");
cmbWriteType.Items.Add("DINT32");
cmbWriteType.Items.Add("HEX32");
cmbWriteType.Items.Add("REAL32");
cmbWriteType.Items.Add("BIN16");
cmbReadMry.SelectedIndex = 3;
cmbWriteMry.SelectedIndex = 3;
cmbBitMry.SelectedIndex = 2;
cmbReadType.SelectedIndex = 0;
cmbWriteType.SelectedIndex = 0;
lstRead.Items.Clear();
txtWrite.Text = "";
cmbCmdType.SelectedIndex = 0;
}
public void butLink_Click(System.Object sender, System.EventArgs e)
{
short re = 0;
string restr = "";
re = PLC.EntLink(txtLocalIP.Text.Trim(), Convert.ToUInt16(txtLocalPort.Text), txtRemoteIP.Text.Trim(), (Convert.ToUInt16(txtRemotePort.Text)), "DEMO", ref PlcHand,Convert .ToUInt16 (1000),Convert .ToBoolean (cmbCmdType .SelectedIndex ));
txtReLink.Text = re.ToString();
if (re == 0)
{
EntLink = true;
MessageBox.Show("PLC联接成功!");
}
else
{
EntLink = false;
MessageBox.Show("PLC联接失败: " + restr);
}
}
public void butClose_Click(System.Object sender, System.EventArgs e)
{
short re = 0;
EntLink = false;
re = PLC.DeLink(PlcHand);
txtReClose.Text = re.ToString();
}
public void butRead_Click(System.Object sender, System.EventArgs e)
{
short i = 0;
object[] RD = null;
RD = new object[Convert.ToUInt16(txtReadCnt.Text)];
if (!EntLink)
{
MessageBox.Show("还未与PLC建立联接224226plc源码!");
return;
}
int var1 = cmbReadType.SelectedIndex + 1;
EntFxPlc.PlcClient.DataType typ = (EntFxPlc .PlcClient.DataType)var1;
switch (cmbReadMry.SelectedIndex)
{
case 0:
ScanRet = PLC.CmdRead(PlcHand,EntFxPlc.PlcClient.PlcMemory.DI, typ, Convert.ToUInt16(txtReadAdd.Text), Convert.ToUInt16(txtReadCnt.Text), ref RD);
break;
case 1:
ScanRet = PLC.CmdRead(PlcHand, EntFxPlc.PlcClient.PlcMemory.DQ, typ, Convert.ToUInt16(txtReadAdd.Text), Convert.ToUInt16(txtReadCnt.Text), ref RD);
break;
case 2:
ScanRet = PLC.CmdRead(PlcHand, EntFxPlc.PlcClient.PlcMemory.MR, typ, Convert.ToUInt16(txtReadAdd.Text), Convert.ToUInt16(txtReadCnt.Text), ref RD);
break;
case 3:
ScanRet = PLC.CmdRead(PlcHand, EntFxPlc.PlcClient.PlcMemory.DR, typ, Convert.ToUInt16(txtReadAdd.Text), Convert.ToUInt16(txtReadCnt.Text), ref RD);
break;
}
txtReRead.Text = ScanRet.ToString();
lstRead.Items.Clear();
for (i = 0; i = (RD.Length - 1); i++)
{
if (!(RD[i] == null))
{
lstRead.Items.Add(RD[i]);
}
else
{
lstRead.Items.Add("0");
}
}
}
public void butWrite_Click(System.Object sender, System.EventArgs e)
{
short i = 0;
string[] temp = null;
object[] WD = null;
if (!EntLink)
{
MessageBox.Show("还未与PLC建立联接!");
return;
}
WD = new object[Convert.ToUInt16(txtWriteCnt.Text)];
temp = txtWrite.Text.Split('\n');
for (i = 0; i = (WD.Length - 1); i++)
{
if (i (temp.Length - 1))
{
WD[i] = 0;
}
else
{
WD[i] = temp[i].Trim();
}
}
int var1 = cmbWriteType.SelectedIndex + 1;
EntFxPlc.PlcClient.DataType typ = (EntFxPlc.PlcClient.DataType)var1;
switch (cmbWriteMry.SelectedIndex)
{
case 0:
ScanRet = PLC.CmdWrite(PlcHand, EntFxPlc.PlcClient.PlcMemory.DI, typ, Convert.ToUInt16(txtWriteAdd.Text), Convert.ToUInt16(txtWriteCnt.Text), ref WD);
break;
case 1:
ScanRet = PLC.CmdWrite(PlcHand, EntFxPlc.PlcClient.PlcMemory.DQ, typ, Convert.ToUInt16(txtWriteAdd.Text), Convert.ToUInt16(txtWriteCnt.Text), ref WD);
break;
case 2:
ScanRet = PLC.CmdWrite(PlcHand, EntFxPlc.PlcClient.PlcMemory.MR, typ, Convert.ToUInt16(txtWriteAdd.Text), Convert.ToUInt16(txtWriteCnt.Text), ref WD);
break;
case 3:
ScanRet = PLC.CmdWrite(PlcHand, EntFxPlc.PlcClient.PlcMemory.DR, typ, Convert.ToUInt16(txtWriteAdd.Text), Convert.ToUInt16(txtWriteCnt.Text), ref WD);
break;
}
txtReWrite.Text = ScanRet.ToString();
}
public void butScan_Click(System.Object sender, System.EventArgs e)
{
if (!EntLink)
{
MessageBox.Show("还未与PLC建立联接!");
return;
}
if (butScan.Text == "Cycle R/W")
{
ScanCount = 0;
Timer1.Enabled = true;
butScan.Text = "Stop R/W";
}
else
{
Timer1.Enabled = false;
butScan.Text = "Cycle R/W";
}
}
public void Timer1_Tick(System.Object sender, System.EventArgs e)
{
Timer1.Enabled = false;
int tim = System.Convert.ToInt32(timeGetTime());
if (!EntLink)
{
MessageBox.Show("还未与PLC建立联接!");
return;
}
//
butRead_Click(null, null);
butWrite_Click(null, null);
//
if ((Convert.ToInt32(txtReRead.Text) 0) || (Convert.ToInt32(txtReWrite.Text) 0))
{
butScan.Text = "Cycle R/W";
return;
}
else
{
ScanCount++;
txtScanCnt.Text = ScanCount.ToString();
txtScanPrd.Text = (System.Convert.ToInt32(timeGetTime()) - tim).ToString() + "ms";
}
Timer1.Enabled = true;
}
public void butBitTest_Click(System.Object sender, System.EventArgs e)
{
if (!EntLink)
{
MessageBox.Show("还未与PLC建立联接!");
return;
}
bool rd = false;
short re = 0;
switch (cmbBitMry.SelectedIndex)
{
case 0:
re = PLC.Bit_Test(PlcHand, EntFxPlc.PlcClient.PlcMemory.DI, Convert.ToUInt16(txtBitAdd.Text), ref rd);
break;
case 1:
re = PLC.Bit_Test(PlcHand, EntFxPlc.PlcClient.PlcMemory.DQ, Convert.ToUInt16(txtBitAdd.Text), ref rd);
break;
case 2:
re = PLC.Bit_Test(PlcHand, EntFxPlc.PlcClient.PlcMemory.MR, Convert.ToUInt16(txtBitAdd.Text), ref rd);
break;
}
txtBitTest.Text = rd.ToString();
txtReBit.Text = re.ToString();
}
public void butBitSet_Click(System.Object sender, System.EventArgs e)
{
if (!EntLink)
{
MessageBox.Show("还未与PLC建立联接!");
return;
}
short re = 0;
switch (cmbBitMry.SelectedIndex)
{
case 0:
re = PLC.Bit_Set(PlcHand, EntFxPlc.PlcClient.PlcMemory.DI, Convert.ToUInt16(txtBitAdd.Text));
break;
case 1:
re = PLC.Bit_Set(PlcHand, EntFxPlc.PlcClient.PlcMemory.DQ, Convert.ToUInt16(txtBitAdd.Text));
break;
case 2:
re = PLC.Bit_Set(PlcHand, EntFxPlc.PlcClient.PlcMemory.MR, Convert.ToUInt16(txtBitAdd.Text));
break;
}
txtReBit.Text = re.ToString();
}
public void butBitRst_Click(System.Object sender, System.EventArgs e)
{
if (!EntLink)
{
MessageBox.Show("还未与PLC建立联接!");
return;
}
short re = 0;
switch (cmbBitMry.SelectedIndex)
{
case 0:
re = PLC.Bit_Reset(PlcHand, EntFxPlc.PlcClient.PlcMemory.DI, Convert.ToUInt16(txtBitAdd.Text));
break;
case 1:
re = PLC.Bit_Reset(PlcHand, EntFxPlc.PlcClient.PlcMemory.DQ, Convert.ToUInt16(txtBitAdd.Text));
break;
case 2:
re = PLC.Bit_Reset(PlcHand, EntFxPlc.PlcClient.PlcMemory.MR, Convert.ToUInt16(txtBitAdd.Text));
break;
}
txtReBit.Text = re.ToString();
}
}
}
您好PLC怎么提供源代码啊?
用编程软件编辑完PLC的程序224226plc源码,保存后224226plc源码,会生成一个文件。(就好比224226plc源码,你用记事本编辑一段文字,然后保存,就生成一个TXT文件一样)。生成的这个文件就是PLC的源代码224226plc源码了,把这个文件提供出去,就是提供源代码224226plc源码了。
望采纳。。。。。。
西门子PLC的CPU221.222.224226和CPU224XP是一个编程软件吗?
是,都是老款S7-200系列PLC,编程软件通用
西门子的PLC最常用的有S7-200、S7-200SMART、S7-300、S7-400、S7-1200、S7-1500、LOGO
其中S7-200是单独一个编程软件,其余系列的PLC程序均无法与之通用或者兼容
S7-200SMART是S7-200的更新换代品,单独一个编程软件,但是S7-200的程序可以直接用200SMART的软件打开,但是无法逆向
300、400、1200、1500均可使用博途软件平台编程,但是300、400除了使用博途平台编程外,还可使用标准版STEP7软件编程,但是1200和1500只能使用博途
标准版STEP7和博途的组件非常庞杂,当然随之而来的功能拓展也是非常之强悍
LOGO,单独一个软件,这个就不说了,用量相比于其他几个系列比较少
除此之外,西门子还有PCS7系统,硬件用的是400系列的冗余CPU,编程软件就叫PCS7
博途包含STEP7和WINCC,但不是简单的STEP7+WINCC(当然还有其他组件,比如START DRIVE)
PCS7也包含STEP7+WINCC,但他也不是简单的STEP7+WINCC
哈哈,总之西门子的软件家族非常庞大,一句两句是概括不了的
plc程序源代码用什么程序写的
源程序是用STL语言写的,可以通过梯形图生成。打开程序块,文件菜单下边有一个生成源文件就可以。最常用到的使用源文件的地方就是给程序块加密(虽然现在可以很容易破解)。
1、在STEP7中打开要加密的程序块,点击菜单“文件/生成源文件(File/Generate source)”,
生成要加密保护的程序块的原代码文件。
2、关闭程序块,在项目管理器中打开“源文件(source)”,打开生成的源文件。
3、在程序块的声明部分,TITLE行下面的一行中输入“KNOW_HOW_PROTECT”。
4、执行菜单命令“文件/保存(File/Save)”然后“文件/编译(File/Compile)”。
5、编译成功后,可在“块”中看到加锁的程序块。
6、解除密码,打开相应的“源文件”,把“KNOW_HOW_PROTECT”删除,然后编译即可。
注意,保存好源文件,否则已加密的程序块将无法打开。