Bonrui编程路 2020-05-06
这里采用的工控组态控件是PCHMI.DLL,使用语言是C#,在其它语言里面叫函数的在c#里面都叫方法。下面列出的是控制PLC的一些方法。
//控制PLC方法
//PLC或设备编号, 设备地址, 操作方法, 值
PCHMI.DCON.Send_Control(0, "U0.0", "置位", "");
PCHMI.DCON.Send_Control(0, "U0.0", "复位", "");
PCHMI.DCON.Send_Control(0, "U0.0", "瞬动", "");
PCHMI.DCON.Send_Control(0, "U0.0", "反转", "");
PCHMI.DCON.Send_Control(0, "U00", "字加", "1");
PCHMI.DCON.Send_Control(0, "U00", "字减", "1");
PCHMI.DCON.Send_Control(0, "U00", "双字加", "1");
PCHMI.DCON.Send_Control(0, "U00", "双字减", "1");
PCHMI.DCON.Send_Control(0, "U00", "字写入", "1");
PCHMI.DCON.Send_Control(0, "U00", "双字写入", "1");
PCHMI.DCON.Send_Control(0, "U00", "多字写入", "1,2,3");
测试方法,参考"工业组态"系列视频教程,选择你要控制的PLC,然后按照视频教程连接好PLC的通讯。再到主界面上拖出一个button按钮控件,在button按钮控件的Click事件里面复制上面其中一行代码,点击按钮就可以看到PLC输出点Y0的指示灯发生变化。
例子:
private void button_Click(object sender, EventArgs e)
{
PCHMI.DCON.Send_Control(0, "Y0", "反转", "");
}