>(1)程序设计 注意互锁和自锁;
’(2)C#界面设计 (3)C#代码设计 //读正反转驱动状态 bool a,b; a = ((bool)plc.Read("M1.3")); b = ((bool)plc.Read("M1.4")); if(a) { drive_stat.Text = "正转运行中"; } if (b) { drive_stat.Text = "反转运行中"; } if (!(a || b))
{ drive_stat.Text = "设备停止中"; } == private void btn_正转启动_Click(object sender, EventArgs e) { if (plc.IsConnected == false) { MessageBox.Show("未连接PLC!", "连接提示", MessageBoxButtons.OK); } else { try { plc.Write("M1.0", 1); plc.Write("M1.0", 0); } catch (Exception Ex) { MessageBox.Show("请检查输入的“地址”或“值”是否错误!" + Ex, "输入提示", MessageBoxButtons.OK); } } } private void btn_停止_Click(object sender, EventArgs e) { if (plc.IsConnected == false) { MessageBox.Show("未连接PLC!", "连接提示", MessageBoxButtons.OK); } else { try { plc.Write("M1.2", 1); plc.Write("M1.2", 0); } catch (Exception Ex) { MessageBox.Show("请检查输入的“地址”或“值”是否错误!" + Ex, "输入提示", MessageBoxButtons.OK); } } } private void btn_反转启动_Click(object sender, EventArgs e) { if (plc.IsConnected == false) { MessageBox.Show("未连接PLC!", "连接提示", MessageBoxButtons.OK); } else { try { plc.Write("M1.1", 1); plc.Write("M1.1", 0); } catch (Exception Ex) { MessageBox.Show("请检查输入的“地址”或“值”是否错误!" + Ex, "输入提示", MessageBoxButtons.OK); } } } (4)演示
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作! |