程序引用S7.NET.dll文件
程序主要实现与S71500一个整数的读写示例。
程序界面
程序
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 S7.Net; namespace WindowsFormsApplication1 { public { Plc s71500; public Form1() { InitializeComponent(); } private { s71500 = new s71500.Open(); } private { s71500.Close(); } private { short MyPlcData= ((ushort)s71500.Read(“DB” + txtDB.Text + “.” + “DBW” + txtStart.Text)).ConvertToShort(); txtValue.Text= MyPlcData.ToString(); } private { s71500.Write(“DB” + txtDB.Text + “.” + “DBW” + txtStart.Text, Convert.ToInt16(txtValue.Text)); } } } |
PLC程序