這里采用的工控組態控件是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", "反轉", "");
}