//【Tag2】料盘右仓初始位置 public static void S3_MotionPos0(ref bool Status, int m, int n) { switch (Manual_Step[m, n]) { case 0: Status = true; Manual_Step[m, n] = Manual_Step[m, n] + 1; break; case 1: Gg.AbsMotion(0, Axis.料仓右Z轴, mFunction.Pos.TeachAxis1[m, n], PVar.ParAxis.Speed[Axis.料仓右Z轴]); Manual_Step[m, n] = Manual_Step[m, n] + 1; break; case 2: if (Gg.ZSPD(0, Axis.料仓右Z轴)) { Manual_Step[m, n] = Manual_Step[m, n] + 1; } break; case 3: Manual_Step[m, n] = 1000; break; case 1000: Manual_Step[m, n] = 0; Status = false; break; } }
public static void AutoRun(ref PVar.WorkType StaWork) { try { switch (StaWork.Step) { case 10: if (PVar.Stop_Flag == false) { StaWork.Result = false; StaWork.State = false; PressTime.InitialTime(); StaWork.Step = 20; } break; case 20: if (StaWork.State == false && StaWork.Enable) { AddList("保压开始!"); StaWork.Enable = false; StaWork.State = true; PressTime.InitialTime(); StaWork.Step = 30; } break; case 30: if (EpsonRobot.RobotLivePos.Y > -200) //判断机械手是否在流水线外 { AddList("保压无杆气缸向左移动!"); Gg.SetExDo(0, 0, Gg.OutPut1.保压无杆气缸左, 1); Gg.SetExDo(0, 0, Gg.OutPut1.保压无杆气缸右, 0); Command.Com1_Send(Command.压力控制打开); PressTime.InitialTime(); StaWork.Step = 40; } break; case 40: if (Gg.GetExDi(0, Gg.InPut1.保压无杆气缸左) == 1 && Gg.GetExDi(0, Gg.InPut1.保压无杆气缸右) == 0) { PressTime.InitialTime(); StaWork.Step = 50; } else if (PressTime.TimeIsUp(8000)) { AddList("保压无杆气缸左信号感应异常!"); ShowList("保压无杆气缸左信号感应异常!"); PressTime.InitialTime(); BufferStep = 40; StaWork.Step = 8000; } break; case 50: if (PressTime.TimeIsUp(200)) { BVar.ProData[2, 6] = Frm_Engineering.fEngineering.Press1_Text.Text; //获取自重的压力值 Gg.AbsMotion(0, Axis.保压Z轴, mFunction.Pos.TeachAxis1[Axis.tTag.保压, Axis.Point保压.保压位置], PVar.ParAxis.Speed[Axis.保压Z轴]); PressTime.InitialTime(); StaWork.Step = 60; } break; case 60: if (Gg.ZSPD(0, Axis.保压Z轴)) { PressTime.InitialTime(); StaWork.Step = 70; } break; case 70: if (PressTime.TimeIsUp((int)PVar.ParList.Data[44] * 1000)) //配重块保压时间 { AddList("保压时间为:" + PVar.ParList.Data[44] * 1000 + "S"); Gg.AbsMotion(0, Axis.保压Z轴, mFunction.Pos.TeachAxis1[Axis.tTag.保压, Axis.Point保压.初始位置], PVar.ParAxis.Speed[Axis.保压Z轴]); PressTime.InitialTime(); StaWork.Step = 80; } break; case 80: //保压轴和气缸复位 if (Gg.ZSPD(0, Axis.保压Z轴) && Gg.GetHomeDi(0, Axis.保压Z轴) == 1) { //保压站无杆气缸双头电磁阀向右 AddList("保压无杆气缸向右移动!"); Gg.SetExDo(0, 0, Gg.OutPut1.保压无杆气缸左, 0); Gg.SetExDo(0, 0, Gg.OutPut1.保压无杆气缸右, 1); PressTime.InitialTime(); StaWork.Step = 90; } break; case 90: if (Gg.GetExDi(0, Gg.InPut1.保压无杆气缸左) == 0 && Gg.GetExDi(0, Gg.InPut1.保压无杆气缸右) == 1) { AddList("保压工作完成!"); PressTime.InitialTime(); StaWork.Step = 100; } else if (PressTime.TimeIsUp(5000)) { AddList("保压无杆气缸右信号感应异常!"); ShowList("保压无杆气缸右信号感应异常!"); BufferStep = 90; StaWork.Step = 8000; } break; case 100: //复位流水线2等待状态 PVar.Sta_Work[(int)BVar.工位.流水线2].IsReady = false; PressTime.InitialTime(); StaWork.Step = 800; break; case 800: StaWork.Enable = false; StaWork.State = false; StaWork.Step = 10; break; case 1000: StaWork.Enable = false; StaWork.Result = false; StaWork.State = false; StaWork.Step = 10; break; //遇到异常,设备先暂停,确定后处理************************ case 8000: PVar.IsSystemOnPauseMode = true; PVar.MacHold = true; StaWork.StaHold = true; PVar.Stop_Flag = false; Frm_Main.fMain.Btn_Start.Enabled = false; Frm_Main.fMain.Btn_Pause.Enabled = true; Frm_Main.fMain.Btn_Stop.Enabled = false; Frm_Main.fMain.Btn_Start.BZ_BackColor = PVar.BZColor_UnselectedBtn; Frm_Main.fMain.Btn_Pause.BZ_BackColor = PVar.BZColor_SelectedEndBtn; Frm_Main.fMain.Btn_Stop.BZ_BackColor = PVar.BZColor_UnselectedBtn; Frm_Engineering.fEngineering.Auto_Timer.Enabled = false; PVar.LampStatus = 20; StaWork.Step = BufferStep; break; } } catch (Exception exc) { string Error_Str = ""; string Error_Str1 = ""; Frm_Engineering.fEngineering.MacStop(); MessageBox.Show(exc.Message); Error_Str = PVar.BZ_LogPath + DateTime.Now.ToString("yyyyMMdd") + "\\" + DateTime.Now.ToString("yyyyMMdd") + "_代码异常记录" + ".txt"; Error_Str1 = "\r\n" + "※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※" + "\r\n" + "[" + DateTime.Now.ToString("HH:mm:ss") + "]" + "\r\n" + exc.ToString(); FileRw.WriteDattxt(Error_Str, Error_Str1); } }
public static void AutoRunTB(ref PVar.WorkType StaWork, String Name, String testpos) { try { switch (StaWork.Step) { case 10: StaWork.Result = false; StaWork.State = true; ClearList2(""); //清空list TestCount = 1; string fileFinalData = "E:\\BZ-Data\\DAB\\TestData\\" + DateTime.Now.ToString("yyyyMM") + "\\" + Name + DateTime.Now.ToString("yyyyMMdd") + ".csv"; Path = fileFinalData; Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 0); InitTime.InitialTime(); StaWork.Step = 20; break; case 20: if (Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸上) == 1 && Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸下) == 0) { Gg.AbsMotion(0, Axis.PSA搬运Y轴, mFunction.Pos.TeachAxis1[Axis.tTag.PSA供料, Axis.Point供料PSA.PSA_Y轴吸料位置], 20); InitTime.InitialTime(); StaWork.Step = 30; } break; case 30: if (Frm_Engineering.fEngineering.Rbt_SendCmd("Step", RobotPosName.待机位置, "20", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "20") == false) { InitTime.InitialTime(); StaWork.Step = 1000; return; } InitTime.InitialTime(); StaWork.Step = 30; break; case 40: if (EpsonRobot.sRobot_Status == "Step" + RobotPosName.待机位置) { AddList2("机械手回待机位置OK!"); InitTime.InitialTime(); StaWork.Step = 50; } else if (InitTime.TimeIsUp(6000)) { AddList2("机械手回待机位置超时!"); ShowList("机械手回待机位置超时!"); InitTime.InitialTime(); StaWork.Step = 1000; return; } break; case 50: if (Frm_Engineering.fEngineering.Rbt_SendCmd("Step", testpos, "20", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "20") == false) { InitTime.InitialTime(); StaWork.Step = 1000; return; } InitTime.InitialTime(); StaWork.Step = 60; break; case 60: if (EpsonRobot.sRobot_Status == "Step" + testpos) { AddList2("机械手位置OK!"); InitTime.InitialTime(); StaWork.Step = 70; } else if (InitTime.TimeIsUp(6000)) { AddList2("机械手运动超时!"); ShowList("机械手运动超时!"); InitTime.InitialTime(); StaWork.Step = 1000; return; } break; case 70: if (InitTime.TimeIsUp(500)) //等待机械手停稳 { InitTime.InitialTime(); StaWork.Step = 80; } break; case 80: if (Name == "相机1动态") { CCD_CMD = "Send: T11," + DateTime.Now.ToString("yyyyMMdd") + "0,0,0"; } if (Name == "相机2动态") { CCD_CMD = "Send: T21," + DateTime.Now.ToString("yyyyMMdd") + "0,0,0"; } sRtn = Command.TCP_CCD_Send(CCD_CMD); AddList2("CCD命令 ->> " + CCD_CMD); AddList2("动态测试拍照第" + TestCount + "次"); TestCount += 1; if (sRtn == 1) //命令发送成功 { InitTime.InitialTime(); StaWork.Step = 90; } else { AddList2("命令发送失败!"); ShowList("命令发送失败!"); InitTime.InitialTime(); StaWork.Step = 1000; } break; case 90: if (Command.CCD_Resule) { AddList2("<<- Recevied:" + PVar.CCD_StrData); //时间,CCD判断值,X,Y,R string TestData = Convert.ToString(DateAndTime.TimeOfDay.TimeOfDay) + "," + PVar.CCD_Data[1] + "," + PVar.CCD_Data[2] + "," + PVar.CCD_Data[3] + "," + PVar.CCD_Data[4]; BVar.FileRorW.WriteTestDataCsv(TestData, Path); InitTime.InitialTime(); StaWork.Step = 100; } else { if (InitTime.TimeIsUp(5000)) { AddList2("等待CCD数据超时!"); ShowList("等待CCD数据超时!"); InitTime.InitialTime(); StaWork.Step = 1000; } } break; case 100: if (TestCount <= Convert.ToInt16(Frm_Engineering.fEngineering.TextBox_Num.Text)) { InitTime.InitialTime(); StaWork.Step = 30; } else { AddList2("测试完成!"); ShowList("测试完成!"); InitTime.InitialTime(); StaWork.Step = 800; } break; case 800: StaWork.Result = true; StaWork.State = false; StaWork.Step = 0; break; case 1000: AddList2("测试失败!"); ShowList("测试失败!"); StaWork.Result = false; StaWork.State = false; StaWork.Step = 0; break; //严重错误,急停处理 case 10000: Frm_Engineering.fEngineering.MacStop(); break; } } catch (Exception exc) { string Error_Str = ""; string Error_Str1 = ""; AddList2("标定失败!"); ShowList("标定失败!"); StaWork.Result = false; StaWork.State = false; StaWork.Step = 0; Frm_Engineering.fEngineering.MacStop(); MessageBox.Show(exc.Message); Error_Str = PVar.BZ_LogPath + DateTime.Now.ToString("yyyyMMdd") + "\\" + DateTime.Now.ToString("yyyyMMdd") + "_代码异常记录" + ".txt"; Error_Str1 = "\r\n" + "※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※" + "\r\n" + "[" + DateTime.Now.ToString("HH:mm:ss") + "]" + "\r\n" + exc.ToString(); FileRw.WriteDattxt(Error_Str, Error_Str1); } }
public static void AutoRun(ref PVar.WorkType StaWork) { try { switch (StaWork.Step) { case 10: if (PVar.Stop_Flag == false) { StaWork.State = false; LoadPSATime.InitialTime(); StaWork.Step = 20; } break; case 20: if (PVar.空跑) { if (StaWork.State == false && StaWork.IsLoadPSA == false && Gg.GetExDi(1, Gg.InPut2.PSA载台真空吸检测信号) == 0 && (PVar.Sta_Work[(int)BVar.工位.流水线0].IsHaveFix || PVar.Sta_Work[(int)BVar.工位.流水线1].IsHaveFix || PVar.Sta_Work[(int)BVar.工位.流水线2].IsHaveFix)) { AddList("PSA上料开始!"); StaWork.State = true; PickUpNumber = 0; Gg.SetExDo(0, 1, Gg.OutPut2.搬运PSA破真空, 0); Gg.SetExDo(0, 1, Gg.OutPut2.搬运PSA真空吸, 0); Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 0); LoadPSATime.InitialTime(); StaWork.Step = 30; } else if (LoadPSATime.TimeIsUp(50)) { StaWork.Step = 10; } } else //***************************************************** { if (StaWork.State == false && StaWork.IsLoadPSA == false && Gg.GetExDi(0, Gg.InPut1.PSA料仓夹紧气缸伸出) == 1 && Gg.GetExDi(1, Gg.InPut2.PSA料仓到位感应信号) == 1 && Gg.GetExDi(1, Gg.InPut2.PSA载台真空吸检测信号) == 0 && (PVar.Sta_Work[(int)BVar.工位.流水线0].IsHaveFix || PVar.Sta_Work[(int)BVar.工位.流水线1].IsHaveFix || PVar.Sta_Work[(int)BVar.工位.流水线2].IsHaveFix)) { AddList("PSA上料开始!"); StaWork.State = true; PickUpNumber = 0; Gg.SetExDo(0, 1, Gg.OutPut2.搬运PSA破真空, 0); Gg.SetExDo(0, 1, Gg.OutPut2.搬运PSA真空吸, 0); Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 0); LoadPSATime.InitialTime(); StaWork.Step = 30; } else if (LoadPSATime.TimeIsUp(50)) { StaWork.Step = 10; } } break; case 30: if (Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸上) == 1 && Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸下) == 0) { AddList("PSA搬运Y轴运动到取料位置!"); Gg.AbsMotion(0, Axis.PSA搬运Y轴, mFunction.Pos.TeachAxis1[Axis.tTag.PSA供料, Axis.Point供料PSA.PSA_Y轴吸料位置], PVar.ParAxis.Speed[Axis.PSA搬运Y轴]); LoadPSATime.InitialTime(); StaWork.Step = 40; } else if (LoadPSATime.TimeIsUp(5000)) { AddList("PSA吸嘴升降气缸上感应信号异常!"); ShowList("PSA吸嘴升降气缸上感应信号异常!"); LoadPSATime.InitialTime(); StaWork.Step = 8000; } break; case 40: if (Gg.ZSPD(0, Axis.PSA搬运Y轴) == false && Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸上) == 0) { AddList("PSA吸嘴升降气缸上信号异常!"); ShowList("PSA吸嘴升降气缸上信号异常!"); LoadPSATime.InitialTime(); StaWork.Step = 10000; } if (Gg.ZSPD(0, Axis.PSA搬运Y轴)) { LoadPSATime.InitialTime(); StaWork.Step = 50; } else if (LoadPSATime.TimeIsUp(5000)) { AddList("PSA搬运Y轴运动超时!"); ShowList("PSA搬运Y轴运动超时!"); LoadPSATime.InitialTime(); StaWork.Step = 10000; } break; case 50: if (PVar.空跑) { AddList("PSA料仓上层感应到物料!"); Gg.SetExDo(0, 1, Gg.OutPut2.搬运PSA破真空, 0); Gg.SetExDo(0, 1, Gg.OutPut2.搬运PSA真空吸, 1); Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 1); AddList("PSA吸嘴升降气缸下降取料!"); LoadPSATime.InitialTime(); StaWork.Step = 90; } else { if (Gg.GetExDi(1, Gg.InPut2.PSA料仓上层感应) == 1) { AddList("PSA料仓上层感应到物料!"); LoadPSATime.InitialTime(); StaWork.Step = 60; } else { //当前位置已经到达最高处 if (Gg.GetPrfPosmm(0, Axis.PSA供料Z轴) >= mFunction.Pos.TeachAxis1[Axis.tTag.PSA供料, Axis.Point供料PSA.PSA_Z轴单片位置]) { //回到供料初始位置 Gg.AbsMotion(0, Axis.PSA供料Z轴, mFunction.Pos.TeachAxis2[Axis.tTag.PSA供料, Axis.Point供料PSA.PSA_Z轴初始位置], PVar.ParAxis.Speed[Axis.PSA供料Z轴]); AddList("PSA物料用完,运动到初始位置!"); ShowList("PSA物料用完,运动到初始位置!"); Gg.SetExDo(0, 1, Gg.OutPut2.搬运PSA破真空, 0); Gg.SetExDo(0, 1, Gg.OutPut2.搬运PSA真空吸, 0); Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 0); LoadPSATime.InitialTime(); StaWork.Step = 1000; } else { //继续顶PSA物料 Gg.AbsMotion(0, Axis.PSA供料Z轴, mFunction.Pos.TeachAxis2[Axis.tTag.PSA供料, Axis.Point供料PSA.PSA_Z轴单片位置], PVar.ParAxis.Speed[Axis.PSA供料Z轴]); AddList("PSA料仓向上顶料!"); LoadPSATime.InitialTime(); StaWork.Step = 60; } } } break; case 60: if (Gg.GetExDi(1, Gg.InPut2.PSA料仓上层感应) == 1) { gts.GT_Stop(0, 1 << (Axis.PSA供料Z轴 - 1), 0); AddList("感应到PSA物料,顶料轴停止!"); } if (Gg.ZSPD(0, Axis.PSA供料Z轴) && Gg.GetExDi(1, Gg.InPut2.PSA料仓上层感应) == 0) { Gg.AbsMotion(0, Axis.PSA供料Z轴, mFunction.Pos.TeachAxis2[Axis.tTag.PSA供料, Axis.Point供料PSA.PSA_Z轴初始位置], PVar.ParAxis.Speed[Axis.PSA供料Z轴]); AddList("PSA物料用完,运动到初始位置!"); ShowList("PSA物料用完,运动到初始位置!"); LoadPSATime.InitialTime(); StaWork.Step = 1000; } else if (Gg.ZSPD(0, Axis.PSA供料Z轴) && Gg.GetExDi(1, Gg.InPut2.PSA料仓上层感应) == 1) { Gg.AbsMotion(0, Axis.PSA供料Z轴, mFunction.Pos.TeachAxis2[Axis.tTag.PSA供料, Axis.Point供料PSA.PSA_Z轴初始位置], PVar.ParAxis.Speed[Axis.PSA供料Z轴]); AddList("PSA料仓上层感应到物料!"); LoadPSATime.InitialTime(); StaWork.Step = 70; } else if (Gg.ZSPD(0, Axis.PSA供料Z轴) == false && LoadPSATime.TimeIsUp(5000)) { AddList("PSA供料Z轴运动超时!"); ShowList("PSA供料Z轴运动超时!"); LoadPSATime.InitialTime(); StaWork.Step = 10000; } break; case 70: if (mFunction.Pos.TeachAxis1[Axis.tTag.PSA供料, Axis.Point供料PSA.PSA_Z轴单片位置] - Gg.GetPrfPosmm(0, Axis.PSA供料Z轴) > 2) { //2mm/s的速度,按比例向上顶,防止料是倾斜的 Gg.AbsMotion(0, Axis.PSA供料Z轴, Gg.GetPrfPosmm(0, Axis.PSA供料Z轴) + (mFunction.Pos.TeachAxis2[Axis.tTag.PSA供料, Axis.Point供料PSA.PSA_Z轴单片位置] - Gg.GetPrfPosmm(0, Axis.PSA供料Z轴)) * 0.08, 2); } PickUpNumber += 1; Gg.SetExDo(0, 1, Gg.OutPut2.搬运PSA破真空, 0); Gg.SetExDo(0, 1, Gg.OutPut2.搬运PSA真空吸, 1); Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 1); AddList("PSA吸嘴升降气缸下降取料!"); LoadPSATime.InitialTime(); StaWork.Step = 80; break; case 80: if (Gg.GetExDi(1, Gg.InPut2.搬运PSA真空吸检测信号) == 1) { gts.GT_Stop(0, 1 << (Axis.PSA供料Z轴 - 1), 1); LoadPSATime.InitialTime(); StaWork.Step = 90; } else { if (Gg.ZSPD(0, Axis.PSA供料Z轴)) { LoadPSATime.InitialTime(); StaWork.Step = 90; } } break; case 90: if (Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸上) == 0 && Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸下) == 1) { Gg.SetExDo(0, 1, Gg.OutPut2.搬运PSA真空吸, 1); LoadPSATime.InitialTime(); StaWork.Step = 100; } else if (LoadPSATime.TimeIsUp(3000)) { AddList("PSA吸嘴升降气缸下降超时!"); ShowList("PSA吸嘴升降气缸下降超时!"); LoadPSATime.InitialTime(); StaWork.Step = 8000; } break; case 100: if (LoadPSATime.TimeIsUp(500)) { LoadPSATime.InitialTime(); StaWork.Step = 120; } break; case 120: if (Gg.ZSPD(0, Axis.PSA供料Z轴)) { AddList("PSA吸嘴升降气缸上升!"); Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 0); LoadPSATime.InitialTime(); StaWork.Step = 130; } break; case 130: if (Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸上) == 1 && Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸下) == 0) { LoadPSATime.InitialTime(); StaWork.Step = 140; } else if (LoadPSATime.TimeIsUp(3000)) { AddList("PSA吸嘴升降气缸上升超时!"); ShowList("PSA吸嘴升降气缸上升超时!"); LoadPSATime.InitialTime(); StaWork.Step = 8000; } break; case 140: if (LoadPSATime.TimeIsUp(500)) { if (PVar.空跑) { AddList("PSA吸嘴升降气缸上升到位,真空吸OK!"); PickUpNumber = 0; Gg.AbsMotion(0, Axis.PSA搬运Y轴, mFunction.Pos.TeachAxis1[Axis.tTag.PSA供料, Axis.Point供料PSA.PSA_Y轴放料位置], PVar.ParAxis.Speed[Axis.PSA搬运Y轴]); LoadPSATime.InitialTime(); StaWork.Step = 150; } else { if (Gg.GetExDi(1, Gg.InPut2.搬运PSA真空吸检测信号) == 1) { AddList("PSA吸嘴升降气缸上升到位,真空吸OK!"); PickUpNumber = 0; Gg.AbsMotion(0, Axis.PSA搬运Y轴, mFunction.Pos.TeachAxis1[Axis.tTag.PSA供料, Axis.Point供料PSA.PSA_Y轴放料位置], PVar.ParAxis.Speed[Axis.PSA搬运Y轴]); LoadPSATime.InitialTime(); StaWork.Step = 150; } else { if (PickUpNumber > 1) { PickUpNumber = 0; AddList("PSA吸料真空异常,请检查!"); ShowList("PSA吸料真空异常,请检查!"); ErrName = "Foam吸料真空异常,请确认后继续"; LoadPSATime.InitialTime(); StaWork.Step = 6000; } else { Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 1); LoadPSATime.InitialTime(); StaWork.Step = 70; } } } } break; case 150: if (Gg.ZSPD(0, Axis.PSA搬运Y轴)) { LoadPSATime.InitialTime(); StaWork.Step = 160; } break; case 160: if (LoadPSATime.TimeIsUp(100)) { AddList("吸嘴移动到中转台上方!"); Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 1); LoadPSATime.InitialTime(); StaWork.Step = 170; } break; case 170: //取料和载具平台很难保证统一平面,这里不判断气缸下信号 if (LoadPSATime.TimeIsUp(1500) && Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸上) == 0) { AddList("PSA吸嘴升降气缸下降到位!"); LoadPSATime.InitialTime(); StaWork.Step = 180; } break; case 180: if (LoadPSATime.TimeIsUp(200)) { Gg.SetExDo(0, 1, Gg.OutPut2.搬运PSA破真空, 1); Gg.SetExDo(0, 1, Gg.OutPut2.搬运PSA真空吸, 0); Gg.SetExDo(0, 1, Gg.OutPut2.PSA载台破真空, 0); Gg.SetExDo(0, 1, Gg.OutPut2.PSA载台真空吸, 1); LoadPSATime.InitialTime(); StaWork.Step = 190; } break; case 190: if (LoadPSATime.TimeIsUp(1000)) { if (PVar.空跑) { AddList("PSA载台真空吸检测信号OK!"); Gg.SetExDo(0, 1, Gg.OutPut2.PSA载台真空吸, 0); Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 0); LoadPSATime.InitialTime(); StaWork.Step = 200; } else { if (Gg.GetExDi(1, Gg.InPut2.PSA载台真空吸检测信号) == 1) { AddList("PSA载台真空吸检测信号OK!"); Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 0); LoadPSATime.InitialTime(); StaWork.Step = 200; } else { AddList("PSA载台真空吸检测信号异常,请检查!"); Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 0); ErrName = "Foam承接平台真空异常,请确认后继续"; LoadPSATime.InitialTime(); StaWork.Step = 7000; } } } break; case 200: if (Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸上) == 1 && Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸下) == 0) { LoadPSATime.InitialTime(); StaWork.Step = 210; } else if (LoadPSATime.TimeIsUp(3000)) { AddList("PSA吸嘴升降气缸上升超时!"); ShowList("PSA吸嘴升降气缸上升超时!"); LoadPSATime.InitialTime(); StaWork.Step = 8000; } break; case 210: if (LoadPSATime.TimeIsUp(300)) { Gg.SetExDo(0, 1, Gg.OutPut2.搬运PSA破真空, 0); Gg.SetExDo(0, 1, Gg.OutPut2.搬运PSA真空吸, 0); Gg.AbsMotion(0, Axis.PSA搬运Y轴, mFunction.Pos.TeachAxis1[Axis.tTag.PSA供料, Axis.Point供料PSA.PSA_Y轴吸料位置], PVar.ParAxis.Speed[Axis.PSA搬运Y轴]); LoadPSATime.InitialTime(); StaWork.Step = 220; } break; case 220: if (Gg.ZSPD(0, Axis.PSA搬运Y轴) == false && Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸上) == 0) { AddList("PSA吸嘴升降气缸上信号异常!"); ShowList("PSA吸嘴升降气缸上信号异常!"); LoadPSATime.InitialTime(); StaWork.Step = 10000; } if (Gg.ZSPD(0, Axis.PSA搬运Y轴)) { StaWork.IsHavePSA = true; //给取PSA信号 LoadPSATime.InitialTime(); StaWork.Step = 300; } else if (LoadPSATime.TimeIsUp(5000)) { AddList("PSA搬运Y轴运动超时!"); ShowList("PSA搬运Y轴运动超时!"); LoadPSATime.InitialTime(); StaWork.Step = 10000; } break; case 300: LoadPSATime.InitialTime(); StaWork.Step = 310; break; case 310: if (StaWork.IsHavePSA == false) { LoadPSATime.InitialTime(); StaWork.Step = 800; } break; case 800: StaWork.Enable = false; StaWork.Result = true; StaWork.State = false; StaWork.Step = 10; break; case 1000: StaWork.Enable = false; StaWork.Result = false; StaWork.State = false; StaWork.Step = 10; break; case 6000: if (MessageBox.Show(ErrName, "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK) { LoadPSATime.InitialTime(); StaWork.Step = 6010; } else { Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 0); Gg.AbsMotion(0, Axis.PSA供料Z轴, mFunction.Pos.TeachAxis2[Axis.tTag.PSA供料, Axis.Point供料PSA.PSA_Z轴初始位置], PVar.ParAxis.Speed[Axis.PSA供料Z轴]); LoadPSATime.InitialTime(); StaWork.Step = 1000; } break; case 6010: if (Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸上) == 1 && Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸下) == 0) { Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 1); LoadPSATime.InitialTime(); StaWork.Step = 70; } else { Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 1); LoadPSATime.InitialTime(); StaWork.Step = 6020; } break; case 6020: if (Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸上) == 1 && Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸下) == 0) { Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 1); LoadPSATime.InitialTime(); StaWork.Step = 70; } else if (LoadPSATime.TimeIsUp(3000)) { AddList("PSA吸嘴升降气缸上升超时!"); ShowList("PSA吸嘴升降气缸上升超时!"); LoadPSATime.InitialTime(); StaWork.Step = 8000; } break; case 7000: if (MessageBox.Show(ErrName, "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK) { LoadPSATime.InitialTime(); StaWork.Step = 160; } else { LoadPSATime.InitialTime(); StaWork.Step = 10; } break; case 8000: Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 0); StaWork.Enable = false; StaWork.Result = false; StaWork.State = false; StaWork.Step = 10; Frm_Engineering.fEngineering.MacStop(); break; //遇到异常,设备先暂停,确定后处理************************ case 8800: if (Manual.AutoMotionFlag[3]) { if (Manual.HoldFlag[3]) { Manual.HoldFlag[3] = false; Frm_Engineering.fEngineering.CmdHoldPress.Text = "暂停"; Frm_Engineering.fEngineering.CmdHoldPress.BackColor = Color.BurlyWood; ShowList("运动已继续"); } else { Manual.HoldFlag[3] = true; Frm_Engineering.fEngineering.CmdHoldPress.Text = "继续"; Frm_Engineering.fEngineering.CmdHoldPress.BackColor = Color.Red; ShowList("运动已暂停"); } } else { PVar.IsSystemOnPauseMode = true; PVar.MacHold = true; StaWork.StaHold = true; PVar.Stop_Flag = false; Frm_Main.fMain.Btn_Start.Enabled = false; Frm_Main.fMain.Btn_Pause.Enabled = true; Frm_Main.fMain.Btn_Stop.Enabled = false; Frm_Main.fMain.Btn_Start.BZ_BackColor = PVar.BZColor_UnselectedBtn; Frm_Main.fMain.Btn_Pause.BZ_BackColor = PVar.BZColor_SelectedEndBtn; Frm_Main.fMain.Btn_Stop.BZ_BackColor = PVar.BZColor_UnselectedBtn; Frm_Engineering.fEngineering.Auto_Timer.Enabled = false; } PVar.LampStatus = 20; StaWork.Step = BufferStep; break; //严重错误,急停处理 case 10000: Frm_Engineering.fEngineering.MacStop(); break; } } catch (Exception exc) { string Error_Str = ""; string Error_Str1 = ""; Frm_Engineering.fEngineering.MacStop(); MessageBox.Show(exc.Message); Error_Str = PVar.BZ_LogPath + DateTime.Now.ToString("yyyyMMdd") + "\\" + DateTime.Now.ToString("yyyyMMdd") + "_代码异常记录" + ".txt"; Error_Str1 = "\r\n" + "※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※" + "\r\n" + "[" + DateTime.Now.ToString("HH:mm:ss") + "]" + "\r\n" + exc.ToString(); FileRw.WriteDattxt(Error_Str, Error_Str1); } }
public static void AutoRun(ref PVar.WorkType StaWork) { try { switch (StaWork.Step) { case 10: if (PVar.Stop_Flag == false) { StaWork.State = false; StaWork.Result = false; Line2Time.InitialTime(); StaWork.Step = 20; } break; case 20: if (PVar.空跑) { if (StaWork.State == false && StaWork.Enable && StaWork.IsHaveFix) { AddList("组装开始!"); StaWork.State = true; StaWork.Enable = false; BVar.ProData[2, 1] = BVar.ProData[1, 1]; //Bezel条码 BVar.ProData[2, 3] = BVar.ProData[1, 3]; //载具条码 Frm_Engineering.fEngineering.Lab_Station2.Text = BVar.ProData[2, 1]; Gg.SetExDo(0, 0, Gg.OutPut1.载具夹紧气缸, 1); Gg.SetExDo(0, 1, Gg.OutPut2.载具上产品真空吸, 1); Gg.SetExDo(0, 1, Gg.OutPut2.载具上产品破真空, 0); Line2Time.InitialTime(); StaWork.Step = 30; } else { if (Line2Time.TimeIsUp(20)) { Line2Time.InitialTime(); StaWork.Step = 10; } } } else //******************************************** { if (StaWork.State == false && StaWork.Enable && StaWork.IsHaveFix) { AddList("组装开始!"); StaWork.State = true; StaWork.Enable = false; BVar.ProData[2, 1] = BVar.ProData[1, 1]; //Bezel条码 BVar.ProData[2, 3] = BVar.ProData[1, 3]; //载具条码 Frm_Engineering.fEngineering.Lab_Station2.Text = BVar.ProData[2, 1]; Gg.SetExDo(0, 0, Gg.OutPut1.载具夹紧气缸, 1); Gg.SetExDo(0, 1, Gg.OutPut2.载具上产品真空吸, 1); Gg.SetExDo(0, 1, Gg.OutPut2.载具上产品破真空, 0); Line2Time.InitialTime(); StaWork.Step = 30; } else if (StaWork.State == false && StaWork.Enable == false && StaWork.IsHaveFix) { AddList("没有条码,跳过组装!"); StaWork.Result = false; Line2Time.InitialTime(); StaWork.Step = 5000; //等待放行 } else { StaWork.Step = 10; } } break; case 30: AddList("保压Z轴回初始位置!"); Gg.AbsMotion(0, Axis.保压Z轴, mFunction.Pos.TeachAxis1[Axis.tTag.保压, Axis.Point保压.初始位置], PVar.ParAxis.Speed[Axis.保压Z轴]); Line2Time.InitialTime(); StaWork.Step = 40; break; case 40: //保压轴和气缸复位 if (Gg.ZSPD(0, Axis.保压Z轴) && Gg.GetHomeDi(0, Axis.保压Z轴) == 1) { //保压站无杆气缸双头电磁阀向右 AddList("保压Z轴OK!"); Gg.SetExDo(0, 0, Gg.OutPut1.保压无杆气缸左, 0); Gg.SetExDo(0, 0, Gg.OutPut1.保压无杆气缸右, 1); Line2Time.InitialTime(); StaWork.Step = 50; } else if (Line2Time.TimeIsUp(8000)) { AddList("保压Z轴运动到初始位置超时!"); ShowList("保压Z轴运动到初始位置超时!"); StaWork.Result = false; Line2Time.InitialTime(); StaWork.Step = 10000; } break; case 50: if (Gg.GetExDi(0, Gg.InPut1.保压无杆气缸左) == 0 && Gg.GetExDi(0, Gg.InPut1.保压无杆气缸右) == 1) { if (EpsonRobot.RobotLivePos.Y > -150) //判断机械手是否在流水线外 { Gg.SetExDo(0, 0, Gg.OutPut1.光源旋转气缸, 1); } Line2Time.InitialTime(); StaWork.Step = 60; } else if (Line2Time.TimeIsUp(5000)) { AddList("保压无杆气缸右信号感应异常!"); ShowList("保压无杆气缸右信号感应异常!"); StaWork.Result = false; Line2Time.InitialTime(); StaWork.Step = 5000; //等待放行 } break; case 60: if (Gg.GetExDi(0, Gg.InPut1.载具夹紧气缸缩回) == 0 && Gg.GetExDi(0, Gg.InPut1.载具夹紧气缸伸出) == 1) { AddList("载具夹紧气缸伸出信号OK!"); AddList("等待光源旋转气缸伸出信号感应!"); Line2Time.InitialTime(); StaWork.Step = 70; } else if (Line2Time.TimeIsUp(2000) && Gg.GetExDi(0, Gg.InPut1.载具夹紧气缸缩回) == 0) { AddList("保载具夹紧气缸伸出信号感应异常!"); Line2Time.InitialTime(); StaWork.Step = 70; //小异常忽略 } break; case 70: if (Gg.GetExDi(0, Gg.InPut1.光源旋转气缸缩回) == 0 && Gg.GetExDi(0, Gg.InPut1.光源旋转气缸伸出) == 1) { AddList("光源旋转气缸伸出信号感应OK!"); Line2Time.InitialTime(); StaWork.Step = 200; } else { if (EpsonRobot.RobotLivePos.Y > -200) //判断机械手是否在流水线外 { Gg.SetExDo(0, 0, Gg.OutPut1.光源旋转气缸, 1); } } break; //相机拍照 case 200: CCD_CMD = "T31" + "," + BVar.ProData[2, 1] + "," + EpsonRobot.RobotLivePos.X + "," + EpsonRobot.RobotLivePos.Y + "," + EpsonRobot.RobotLivePos.U; sRtn = Command.TCP_CCD_Send(CCD_CMD); AddList("Bezel定位拍照"); if (PVar.空跑) { Line2Time.InitialTime(); StaWork.Step = 210; } else { if (sRtn == 1) //命令发送成功 { Line2Time.InitialTime(); StaWork.Step = 210; } else { AddList("T31命令发送失败!"); ShowList("T31命令发送失败!"); Line2Time.InitialTime(); StaWork.Step = 1000; } } break; case 210: if (PVar.空跑) { if (Line2Time.TimeIsUp(2000)) { AddList("<<- Recevied:" + PVar.CCD_StrData); Gg.SetExDo(0, 0, Gg.OutPut1.光源旋转气缸, 0); Line2Time.InitialTime(); StaWork.Step = 220; } } else //**************************************************** { if (Command.CCD_Resule && PVar.CCD_Data[0] == "T31") { AddList("<<- Recevied:" + PVar.CCD_StrData); Gg.SetExDo(0, 0, Gg.OutPut1.光源旋转气缸, 0); Line2Time.InitialTime(); StaWork.Step = 220; } else { if (Line2Time.TimeIsUp(5000)) { AddList("等待CCD T31数据超时!"); ShowList("等待CCD T31数据超时!"); Line2Time.InitialTime(); StaWork.Step = 1000; } } } break; case 220: if (PVar.空跑) { AddList("拍照OK,开始等待机械手开始工作结束"); Gg.SetExDo(0, 1, Gg.OutPut2.载具上产品真空吸, 0); PVar.Sta_Work[(int)BVar.工位.机械手].Enable = true; //允许机械手开始工作,目前不考虑CT,后续提前并行 Line2Time.InitialTime(); StaWork.Step = 230; } else { if (PVar.CCD_Data[1] == "1") { AddList("拍照OK,开始等待机械手开始工作结束"); PVar.Sta_Work[(int)BVar.工位.机械手].Enable = true; //允许机械手开始工作,目前不考虑CT,后续提前并行 Line2Time.InitialTime(); StaWork.Step = 230; } else { AddList("Bezel拍照NG,异常直接流出"); StaWork.Result = false; Line2Time.InitialTime(); StaWork.Step = 5000; } } break; case 230: if (Gg.GetExDi(0, Gg.InPut1.光源旋转气缸缩回) == 1 && Gg.GetExDi(0, Gg.InPut1.光源旋转气缸伸出) == 0) { AddList("光源旋转气缸缩回信号感应OK!"); StaWork.IsReady = true; //所有准备就绪,等待机械手完成 Line2Time.InitialTime(); StaWork.Step = 300; } else if (Line2Time.TimeIsUp(5000)) { AddList("光源旋转气缸缩回超时!"); ShowList("光源旋转气缸缩回超时!"); Line2Time.InitialTime(); StaWork.Step = 5000; } break; //************************************************************************************************ //等待机械手装配完成 case 300: if (StaWork.IsReady == false) { AddList("装配完成,开始复检!"); Line2Time.InitialTime(); StaWork.Step = 310; } break; case 310: if (Gg.GetExDi(0, Gg.InPut1.光源旋转气缸缩回) == 0 && Gg.GetExDi(0, Gg.InPut1.光源旋转气缸伸出) == 1) { AddList("光源旋转气缸伸出信号感应OK!"); Line2Time.InitialTime(); StaWork.Step = 320; } else { if (EpsonRobot.RobotLivePos.Y > -150) //判断机械手是否在流水线外 { Gg.SetExDo(0, 0, Gg.OutPut1.光源旋转气缸, 1); } } break; case 320: CCD_CMD = "T33" + "," + BVar.ProData[2, 1] + "," + EpsonRobot.RobotLivePos.X + "," + EpsonRobot.RobotLivePos.Y + "," + EpsonRobot.RobotLivePos.U; sRtn = Command.TCP_CCD_Send(CCD_CMD); AddList("Bezel下相机复检拍照"); if (PVar.空跑) { Line2Time.InitialTime(); StaWork.Step = 330; } else { if (sRtn == 1) //命令发送成功 { Line2Time.InitialTime(); StaWork.Step = 330; } else { AddList("T33命令发送失败!"); ShowList("T33命令发送失败!"); Line2Time.InitialTime(); StaWork.Step = 1000; } } break; case 330: if (PVar.空跑) { if (Line2Time.TimeIsUp(1000)) { AddList("<<- Recevied:" + PVar.CCD_StrData); Line2Time.InitialTime(); StaWork.Step = 340; } } else { if (Command.CCD_Resule && PVar.CCD_Data[0] == "T33") { AddList("<<- Recevied:" + PVar.CCD_StrData); Line2Time.InitialTime(); StaWork.Step = 340; } else { if (Line2Time.TimeIsUp(5000)) { AddList("等待CCD T33数据超时!"); ShowList("等待CCD T33数据超时!"); Line2Time.InitialTime(); StaWork.Step = 1000; } } } break; case 340: if (PVar.空跑) { AddList("拍照OK"); Line2Time.InitialTime(); StaWork.Step = 350; } else { if (PVar.CCD_Data[1] == "1") { AddList("拍照OK"); Line2Time.InitialTime(); StaWork.Step = 350; } else { AddList("Bezel拍照NG,异常直接流出"); StaWork.Result = false; Line2Time.InitialTime(); StaWork.Step = 5000; } } break; case 350: CCD_CMD = "T41" + "," + BVar.ProData[2, 1] + "," + EpsonRobot.RobotLivePos.X + "," + EpsonRobot.RobotLivePos.Y + "," + EpsonRobot.RobotLivePos.U; sRtn = Command.TCP_CCD_Send(CCD_CMD); AddList("Bezel上相机复检拍照"); if (PVar.空跑) { Line2Time.InitialTime(); StaWork.Step = 360; } else { if (sRtn == 1) //命令发送成功 { Line2Time.InitialTime(); StaWork.Step = 360; } else { AddList("T41命令发送失败!"); ShowList("T41命令发送失败!"); Line2Time.InitialTime(); StaWork.Step = 1000; } } break; case 360: if (PVar.空跑) { if (Line2Time.TimeIsUp(1000)) { AddList("<<- Recevied:" + PVar.CCD_StrData); Line2Time.InitialTime(); StaWork.Step = 370; } } else { if (Command.CCD_Resule && PVar.CCD_Data[0] == "T41") { AddList("<<- Recevied:" + PVar.CCD_StrData); Line2Time.InitialTime(); StaWork.Step = 370; } else { if (Line2Time.TimeIsUp(5000)) { AddList("等待CCD T41数据超时!"); ShowList("等待CCD T41数据超时!"); Line2Time.InitialTime(); StaWork.Step = 1000; } } } break; case 370: if (PVar.空跑) { AddList("拍照OK,开始上传PDCA"); Line2Time.InitialTime(); StaWork.Step = 380; } else { if (PVar.CCD_Data[1] == "1") { AddList("拍照OK,开始上传PDCA"); Line2Time.InitialTime(); StaWork.Step = 380; } else { AddList("Bezel拍照NG,异常直接流出"); StaWork.Result = false; Line2Time.InitialTime(); StaWork.Step = 5000; } } break; case 380: Line2Time.InitialTime(); StaWork.Step = 505; break; //复检检测输出值 //*********************************************** case 505: Gg.SetDo(0, Gg.OutPut0.阻挡气缸3, 0); Gg.SetExDo(0, 0, Gg.OutPut1.载具夹紧气缸, 0); Gg.SetExDo(0, 1, Gg.OutPut2.载具上产品真空吸, 0); Gg.SetExDo(0, 1, Gg.OutPut2.载具上产品破真空, 1); Line2Time.InitialTime(); StaWork.Step = 510; break; case 510: if (Gg.GetExDi(0, Gg.InPut1.载具夹紧气缸缩回) == 1 && Gg.GetExDi(0, Gg.InPut1.载具夹紧气缸伸出) == 0) { AddList("装配完成,等待放行!"); Line2Time.InitialTime(); StaWork.Step = 600; } else if (Line2Time.TimeIsUp(3000)) { AddList("保载具夹紧气缸伸出信号感应异常!"); Line2Time.InitialTime(); StaWork.Step = 400; } break; case 600: if (PVar.空跑) { if (PVar.Stop_Flag == false && Linechange.LineOut() == 0 && PVar.Sta_Work[(int)BVar.工位.流水线3].State == false) { AddList("载具开始放行,等待流水线3接收!"); Gg.SetExDo(0, 1, Gg.OutPut2.载具上产品破真空, 0); Frm_Engineering.fEngineering.Txt_BarCode.Text = ""; Linechange.SetMotor2(true, PVar.ParList.Data[43]); Linechange.SetMotor3(true, PVar.ParList.Data[43]); Line2Time.InitialTime(); StaWork.Step = 610; } else { if (PVar.Stop_Flag) { StaWork.State = false; Line2Time.InitialTime(); StaWork.Step = 10; } } } else //****************************************************** { //等待放行***************************** if (PVar.Stop_Flag == false && Linechange.LineOut() == 0 && PVar.Sta_Work[(int)BVar.工位.流水线3].State == false) { AddList("载具开始放行,等待流水线3接收!"); Frm_Engineering.fEngineering.Txt_BarCode.Text = ""; Linechange.SetMotor2(true, PVar.ParList.Data[43]); Linechange.SetMotor3(true, PVar.ParList.Data[43]); Line2Time.InitialTime(); StaWork.Step = 610; } } break; case 610: if (PVar.空跑) { if (Line2Time.TimeIsUp(1000)) { AddList("载具开始放行!"); Line2Time.InitialTime(); StaWork.Step = 620; } } else { if (Gg.GetExDi(1, Gg.InPut2.流水线对射感应4) == 0) { AddList("载具开始放行!"); Line2Time.InitialTime(); StaWork.Step = 620; } else if (Line2Time.TimeIsUp(5000)) { AddList("流水线2放行载具超时!"); ShowList("流水线2放行载具超时!"); Line2Time.InitialTime(); StaWork.Step = 620; } } break; case 620: if (PVar.空跑) { if (Line2Time.TimeIsUp(1000)) { AddList("流水线2载具开始放行完成!"); //*********************************************************应该可以开始接受上站载具 PVar.Sta_Work[(int)BVar.工位.流水线3].IsHaveFix = true; Line2Time.InitialTime(); StaWork.Step = 630; } } else { if (Gg.GetExDi(1, Gg.InPut2.流水线对射感应5) == 0) { AddList("流水线2载具开始放行完成!"); //*********************************************************应该可以开始接受上站载具 PVar.Sta_Work[(int)BVar.工位.流水线3].IsHaveFix = true; Gg.SetDo(0, Gg.OutPut0.阻挡气缸3, 1); Line2Time.InitialTime(); StaWork.Step = 630; } else if (Line2Time.TimeIsUp(5000)) { AddList("流水线2放行载具超时!"); ShowList("流水线2放行载具超时!"); Line2Time.InitialTime(); StaWork.Step = 630; } } break; case 630: if (Line2Time.TimeIsUp(500)) { AddList("流水线2载具放行完成!"); Gg.SetDo(0, Gg.OutPut0.阻挡气缸3, 1); PVar.Sta_Work[(int)BVar.工位.流水线2].IsHaveFix = false; PVar.Sta_Work[(int)BVar.工位.流水线3].IsHaveFix = true; Linechange.SetMotor2(false, PVar.ParList.Data[43]); Line2Time.InitialTime(); StaWork.Step = 650; } break; case 650: if (Line2Time.TimeIsUp(200)) { Line2Time.InitialTime(); StaWork.Step = 800; } break; case 800: StaWork.Enable = false; StaWork.Result = true; StaWork.State = false; Manual.AutoMotionFlag[2] = false; StaWork.Step = 10; break; case 1000: StaWork.Enable = false; StaWork.Result = false; StaWork.State = false; Manual.AutoMotionFlag[2] = false; StaWork.Step = 10; break; } } catch (Exception exc) { string Error_Str = ""; string Error_Str1 = ""; Frm_Engineering.fEngineering.MacStop(); MessageBox.Show(exc.Message); Error_Str = PVar.BZ_LogPath + DateTime.Now.ToString("yyyyMMdd") + "\\" + DateTime.Now.ToString("yyyyMMdd") + "_代码异常记录" + ".txt"; Error_Str1 = "\r\n" + "※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※" + "\r\n" + "[" + DateTime.Now.ToString("HH:mm:ss") + "]" + "\r\n" + exc.ToString(); FileRw.WriteDattxt(Error_Str, Error_Str1); } }
/// <summary> /// GotoHome(short CardNum[卡号], short Axis[轴号], double homeToLimitFDist[极限到原点距离], double searchHomeDist[原点搜索距离], double offsetPos[感应宽度], double homeoffset[原点偏移距离], double vel[搜索原点速度]) /// </summary> /// <param name="CardNum"></param> /// <param name="Axis"></param> /// <param name="homeToLimitFDist"></param> /// <param name="searchHomeDist"></param> /// <param name="offsetPos"></param> /// <param name="homeoffset"></param> /// <param name="vel"></param> public static void GotoHome(short CardNum, short Axis, double homeToLimitFDist, double searchHomeDist, double offsetPos, double homeoffset, double vel) { uint temp_pClock = 0; if (GoHome.AxisHome[CardNum, Axis].Step != 0) { Frm_Engineering.fEngineering.textBox3.Text = GoHome.AxisHome[CardNum, Axis].Step.ToString(); GoHome.AxisHome[CardNum, Axis].State = true; switch (GoHome.AxisHome[CardNum, Axis].Step) { case 10: InitTimeH[CardNum, Axis] = new Tool.Delay(); gts.GT_ClrSts(CardNum, Axis, (short)1); //清除报警 gts.GT_SetPrfPos(CardNum, Axis, 0); //规划器置零 gts.GT_SetEncPos(CardNum, Axis, 0); //编码器置零 gts.GT_SynchAxisPos(CardNum, 1 << (Axis - 1)); //将当前轴进行位置同步 GoHome.AxisHome[CardNum, Axis].Counter = 0; //回原点计数 GoHome.AxisHome[CardNum, Axis].Step = 20; break; case 20: GoHome.AxisHome[CardNum, Axis].Capture = 0; if (Gg.GetHomeDi(CardNum, Axis) == 0) //判断是否在原点上 { if (GoHome.AxisHome[CardNum, Axis].Counter > 1) { GoHome.AxisHome[CardNum, Axis].Step = 140; } else { GoHome.AxisHome[CardNum, Axis].Counter = GoHome.AxisHome[CardNum, Axis].Counter + 1; GoHome.AxisHome[CardNum, Axis].Step = 30; //开始搜索原点 } } else { GoHome.AxisHome[CardNum, Axis].Step = 200; //偏离原点,方向与搜索原点方向相反 } break; case 30: gts.GT_ClrSts(CardNum, Axis, (short)1); gts.GT_SetCaptureMode(CardNum, Axis, gts.CAPTURE_HOME); //第一次原点搜索 GoHome.AxisHome[CardNum, Axis].TempPos = 0; Gg.AbsMotion(CardNum, Axis, System.Convert.ToDouble(Gg.GetPrfPosmm(CardNum, Axis) + searchHomeDist), vel); //启动运动,开始搜索原点 GoHome.AxisHome[CardNum, Axis].Step = 40; break; case 40: gts.GT_ClrSts(CardNum, Axis, (short)1); gts.GT_GetSts(CardNum, Axis, out GoHome.AxisHome[CardNum, Axis].status, (short)1, out temp_pClock); gts.GT_GetCaptureStatus(CardNum, Axis, out GoHome.AxisHome[CardNum, Axis].Capture, out GoHome.AxisHome[CardNum, Axis].TempPos, (short)1, out temp_pClock); //获取当前轴原点捕获的状态及捕获的当前位置 if (GoHome.AxisHome[CardNum, Axis].Capture == 1) //判断当前轴是否原点捕获触发 { //Gg.AxisStop(CardNum, Axis); //当前轴停止 gts.GT_Stop(CardNum, 1 << (Axis - 1), 1 << (Axis - 1)); InitTimeH[CardNum, Axis].InitialTime(); GoHome.AxisHome[CardNum, Axis].Capture = 0; GoHome.AxisHome[CardNum, Axis].Step = 50; } else if (Gg.GetLimitDi_Z(CardNum, Axis) == 1) //判断当前轴是否触发正极限 { //Gg.AxisStop(CardNum, Axis); //当前轴停止 gts.GT_Stop(CardNum, 1 << (Axis - 1), 1 << (Axis - 1)); InitTimeH[CardNum, Axis].InitialTime(); GoHome.AxisHome[CardNum, Axis].Step = 170; } else if (Gg.GetLimitDi_F(CardNum, Axis) == 1) //判断当前轴是否触发负极限 { //Gg.AxisStop(CardNum, Axis); //当前轴停止 gts.GT_Stop(CardNum, 1 << (Axis - 1), 1 << (Axis - 1)); InitTimeH[CardNum, Axis].InitialTime(); GoHome.AxisHome[CardNum, Axis].Step = 150; } else if (System.Convert.ToBoolean(GoHome.AxisHome[CardNum, Axis].status & 0x400) == false) //判断当前轴规划器是否运动停止(原点搜索距离太小) { InitTimeH[CardNum, Axis].InitialTime(); GoHome.AxisHome[CardNum, Axis].Step = 140; } break; case 50: if (InitTimeH[CardNum, Axis].TimeIsUp(500)) { GoHome.AxisHome[CardNum, Axis].Step = 52; } break; case 52: //Gg.AbsMotion(CardNum, Axis, System.Convert.ToDouble(GoHome.AxisHome[CardNum, Axis].TempPos / Gg.PlusPerUnit(CardNum, Axis)) / Tools.GeerRate[CardNum, Axis] + 1, 2); //Gg.AbsMotion(CardNum, Axis, System.Convert.ToDouble(Gg.GetPrfPosmm(CardNum, Axis) + offsetPos), 10); //启动运动,原点反向运动 Gg.AbsMotion(CardNum, Axis, System.Convert.ToDouble(Gg.GetPrfPosmm(CardNum, Axis) + 2), 5); //启动运动,原点反向运动 GoHome.AxisHome[CardNum, Axis].Step = 60; break; case 60: gts.GT_ClrSts(CardNum, Axis, (short)1); gts.GT_GetSts(CardNum, Axis, out GoHome.AxisHome[CardNum, Axis].status, (short)1, out temp_pClock); //获取当前轴的状态 if (System.Convert.ToBoolean(GoHome.AxisHome[CardNum, Axis].status & 0x400) == false) //判断当前轴是否运动停止 { GoHome.AxisHome[CardNum, Axis].Step = 70; } break; case 70: if (InitTimeH[CardNum, Axis].TimeIsUp(500)) { GoHome.AxisHome[CardNum, Axis].Step = 72; } break; case 72: gts.GT_SetCaptureMode(CardNum, Axis, gts.CAPTURE_HOME); //第二次原点搜索 //hRtn = gts.GT_SetCaptureMode(CardNum, Axis,gts. CAPTURE_INDEX); //启动当前轴的Z相脉冲捕获 Gg.AbsMotion(CardNum, Axis, System.Convert.ToDouble(Gg.GetPrfPosmm(CardNum, Axis) - offsetPos * 2), 1); //以1mm/s速度找原点 GoHome.AxisHome[CardNum, Axis].Step = 80; //跳转到下一步 break; case 80: gts.GT_ClrSts(CardNum, Axis, (short)1); gts.GT_GetSts(CardNum, Axis, out GoHome.AxisHome[CardNum, Axis].status, (short)1, out temp_pClock); //获取当前轴的状态 gts.GT_GetCaptureStatus(CardNum, Axis, out GoHome.AxisHome[CardNum, Axis].Capture, out GoHome.AxisHome[CardNum, Axis].TempPos, (short)1, out temp_pClock); //获取当前轴Z相脉冲捕获的状态及捕获的当前位置 if (GoHome.AxisHome[CardNum, Axis].Capture == 1) //判断当前轴是否Z相脉冲捕获触发 { //Gg.AxisStop(CardNum, Axis); //当前轴停止 gts.GT_Stop(CardNum, 1 << (Axis - 1), 1 << (Axis - 1)); GoHome.AxisHome[CardNum, Axis].Capture = 0; //捕获触发标志清零 GoHome.AxisHome[CardNum, Axis].Step = 90; } else if (System.Convert.ToBoolean(GoHome.AxisHome[CardNum, Axis].status & 0x400) == false) { GoHome.AxisHome[CardNum, Axis].Step = 140; //跳转到第110步(或脉冲未捕获,回原点结束,回原点失败) } break; case 90: if (InitTimeH[CardNum, Axis].TimeIsUp(500)) { GoHome.AxisHome[CardNum, Axis].Step = 92; } break; case 92: Gg.AbsMotion(CardNum, Axis, System.Convert.ToDouble(Gg.GetPrfPosmm(CardNum, Axis) + homeoffset), 2); //if (homeoffset < 3) // { // Gg.AbsMotion(CardNum, Axis, System.Convert.ToDouble(GoHome.AxisHome[CardNum, Axis].TempPos / Gg.PlusPerUnit(CardNum, Axis) / Tools.GeerRate[CardNum, Axis]) + homeoffset, 2); // } //else // { // Gg.AbsMotion(CardNum, Axis, System.Convert.ToDouble(GoHome.AxisHome[CardNum, Axis].TempPos / Gg.PlusPerUnit(CardNum, Axis) / Tools.GeerRate[CardNum, Axis]) + homeoffset, 5); // } GoHome.AxisHome[CardNum, Axis].Step = 100; break; case 100: gts.GT_ClrSts(CardNum, Axis, (short)1); gts.GT_GetSts(CardNum, Axis, out GoHome.AxisHome[CardNum, Axis].status, (short)1, out temp_pClock); if (System.Convert.ToBoolean(GoHome.AxisHome[CardNum, Axis].status & 0x400) == false) //判断当前轴是否运动停止 { InitTime.InitialTime(); InitTimeH[CardNum, Axis].InitialTime(); GoHome.AxisHome[CardNum, Axis].Step = 110; } break; case 110: if (InitTimeH[CardNum, Axis].TimeIsUp(200)) { GoHome.AxisHome[CardNum, Axis].Step = 120; } break; case 120: gts.GT_SetPrfPos(CardNum, Axis, 0); //将当前轴规划器位置修改为零点 gts.GT_SetEncPos(CardNum, Axis, 0); //将当前轴编码器位置修改为零点 gts.GT_SynchAxisPos(CardNum, 1 << (Axis - 1)); //将当前轴进行位置同步 InitTimeH[CardNum, Axis].InitialTime(); GoHome.AxisHome[CardNum, Axis].Step = 130; break; case 130: if (InitTimeH[CardNum, Axis].TimeIsUp(50)) { if (Gg.GetEncPos(CardNum, Axis) == 0 && Gg.GetPrfPos(CardNum, Axis) == 0) { GoHome.AxisHome[CardNum, Axis].Result = true; GoHome.AxisHome[CardNum, Axis].State = false; GoHome.AxisHome[CardNum, Axis].Step = 0; } else { InitTimeH[CardNum, Axis].InitialTime(); GoHome.AxisHome[CardNum, Axis].Step = 110; } } break; case 140: GoHome.AxisHome[CardNum, Axis].Result = false; GoHome.AxisHome[CardNum, Axis].State = false; GoHome.AxisHome[CardNum, Axis].Step = 0; break; //********************************************************************************************************************* case 150: //负极限和原点之间距离 gts.GT_ClrSts(CardNum, Axis, (short)1); Gg.AbsMotion(CardNum, Axis, System.Convert.ToDouble(Gg.GetPrfPosmm(CardNum, Axis) + homeToLimitFDist), vel); GoHome.AxisHome[CardNum, Axis].Step = 160; break; case 160: gts.GT_ClrSts(CardNum, Axis, (short)1); gts.GT_GetSts(CardNum, Axis, out GoHome.AxisHome[CardNum, Axis].status, (short)1, out temp_pClock); if (System.Convert.ToBoolean(GoHome.AxisHome[CardNum, Axis].status & 0x400) == false) { GoHome.AxisHome[CardNum, Axis].Step = 20; //重新搜索原点 } break; //********************************************************************************************************************* case 170: //offsetPos大于感应片的宽度 gts.GT_ClrSts(CardNum, Axis, (short)1); Gg.AbsMotion(CardNum, Axis, System.Convert.ToDouble(Gg.GetPrfPosmm(CardNum, Axis) - offsetPos), vel); GoHome.AxisHome[CardNum, Axis].Step = 180; break; case 180: gts.GT_ClrSts(CardNum, Axis, (short)1); gts.GT_GetSts(CardNum, Axis, out GoHome.AxisHome[CardNum, Axis].status, (short)1, out temp_pClock); if (System.Convert.ToBoolean(GoHome.AxisHome[CardNum, Axis].status & 0x400) == false) { GoHome.AxisHome[CardNum, Axis].Step = 20; //重新搜索原点 } break; //********************************************************************************************************************* case 200: //offsetPos大于感应片的宽度 Gg.AbsMotion(CardNum, Axis, System.Convert.ToDouble(Gg.GetPrfPosmm(CardNum, Axis) + offsetPos), vel); GoHome.AxisHome[CardNum, Axis].Step = 201; break; case 201: if (Gg.GetHomeDi(CardNum, Axis) == 0) //判断是否在原点上 { Gg.AbsMotion(CardNum, Axis, System.Convert.ToDouble(Gg.GetPrfPosmm(CardNum, Axis) + 1), vel); InitTimeH[CardNum, Axis].InitialTime(); GoHome.AxisHome[CardNum, Axis].Step = 210; } else { gts.GT_ClrSts(CardNum, Axis, (short)1); gts.GT_GetSts(CardNum, Axis, out GoHome.AxisHome[CardNum, Axis].status, (short)1, out temp_pClock); if (System.Convert.ToBoolean(GoHome.AxisHome[CardNum, Axis].status & 0x400) == false) { InitTimeH[CardNum, Axis].InitialTime(); GoHome.AxisHome[CardNum, Axis].Step = 140; } } break; case 210: gts.GT_ClrSts(CardNum, Axis, (short)1); gts.GT_GetSts(CardNum, Axis, out GoHome.AxisHome[CardNum, Axis].status, (short)1, out temp_pClock); if (System.Convert.ToBoolean(GoHome.AxisHome[CardNum, Axis].status & 0x400) == false) { InitTimeH[CardNum, Axis].InitialTime(); GoHome.AxisHome[CardNum, Axis].Step = 220; } break; case (short)220: if (InitTimeH[CardNum, Axis].TimeIsUp(200)) { if (Gg.GetHomeDi(CardNum, Axis) == 1) { GoHome.AxisHome[CardNum, Axis].Step = 140; } else { GoHome.AxisHome[CardNum, Axis].Step = 20; } } break; } } }
public static void HomeSub() { switch (StepHome) { case 10: GoHome.Reset.State = true; AddList("设备初始化开始,请等待!"); //停止流水线 Linechange.SetMotor1(false, 0); // Linechange.SetMotor2(false, 0); Linechange.SetMotor3(false, 0); AddList("关闭传送带电机"); if (EpsonRobot.IsRobotAlarm) { AddList("机械手报警,初始化失败,请检查!"); ShowList("机械手报警,初始化失败,请检查!"); StepHome = 1000; return; } Gg.SetDo(0, Gg.OutPut0.启动按钮指示灯, 0); Gg.SetDo(0, Gg.OutPut0.日光灯继电器, 0); Gg.SetDo(0, Gg.OutPut0.步进电机使能, 0); Gg.SetDo(0, Gg.OutPut0.阻挡气缸1, 1); Gg.SetDo(0, Gg.OutPut0.阻挡气缸2, 1); Gg.SetDo(0, Gg.OutPut0.阻挡气缸3, 1); Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 0); Gg.SetExDo(0, 0, Gg.OutPut1.光源旋转气缸, 0); Gg.SetExDo(0, 0, Gg.OutPut1.撕膜夹爪气缸, 0); Gg.SetExDo(0, 0, Gg.OutPut1.机械手滑台气缸, 0); Gg.SetExDo(0, 0, Gg.OutPut1.机械手撕膜升降气缸, 0); Gg.SetExDo(0, 0, Gg.OutPut1.机械手撕膜针型气缸, 0); Gg.SetExDo(0, 0, Gg.OutPut1.载具夹紧气缸, 0); Gg.SetExDo(0, 1, Gg.OutPut2.NG指示灯, 0); Gg.SetExDo(0, 1, Gg.OutPut2.OK指示灯, 0); Gg.SetExDo(0, 1, Gg.OutPut2.PSA载台破真空, 0); Gg.SetExDo(0, 1, Gg.OutPut2.PSA载台真空吸, 0); Gg.SetExDo(0, 1, Gg.OutPut2.搬运PSA破真空, 0); Gg.SetExDo(0, 1, Gg.OutPut2.搬运PSA真空吸, 0); Gg.SetExDo(0, 1, Gg.OutPut2.机械手吸嘴破真空, 0); Gg.SetExDo(0, 1, Gg.OutPut2.机械手吸嘴真空吸, 0); Gg.SetExDo(0, 1, Gg.OutPut2.机械手夹爪吸膜破真空, 0); Gg.SetExDo(0, 1, Gg.OutPut2.机械手夹爪吸膜真空吸, 0); Gg.SetExDo(0, 1, Gg.OutPut2.机械手排线破真空, 0); Gg.SetExDo(0, 1, Gg.OutPut2.机械手排线真空吸, 0); Gg.SetExDo(0, 1, Gg.OutPut2.右料盘吸电磁铁, 1); Gg.SetExDo(0, 1, Gg.OutPut2.左料盘吸电磁铁, 1); Gg.SetExDo(0, 1, Gg.OutPut2.载具上产品破真空, 0); Gg.SetExDo(0, 1, Gg.OutPut2.载具上产品真空吸, 0); Gg.SetExDo(0, 2, Gg.OutPut3.离子风扇, 0); RobotHomeNum = 0; ////界面 Frm_Main.fMain.Btn_Stop.Enabled = false; Frm_Main.fMain.Btn_Pause.Enabled = false; Frm_Main.fMain.Btn_Stop.BZ_BackColor = PVar.BZColor_UnselectedBtn; Frm_Main.fMain.Btn_Pause.BZ_BackColor = PVar.BZColor_UnselectedBtn; Frm_ProgressBar.IsShowProgresBar(true); InitTime.InitialTime(); StepHome = 20; break; //机械手回初始位置 case 20: RobotHomeNum += 1; AddList("机械手停止!"); Gg.SetDo(0, Gg.OutPut0.机械手停止, 1); WinAPI.Wait(200); Gg.SetDo(0, Gg.OutPut0.机械手停止, 0); WinAPI.Wait(100); InitTime.InitialTime(); StepHome = 22; break; case 22: AddList("机械手复位!"); Gg.SetDo(0, Gg.OutPut0.机械手复位, 1); WinAPI.Wait(200); Gg.SetDo(0, Gg.OutPut0.机械手复位, 0); WinAPI.Wait(100); InitTime.InitialTime(); StepHome = 24; break; case 24: AddList("机械手启动!"); Gg.SetDo(0, Gg.OutPut0.机械手启动, 1); WinAPI.Wait(200); Gg.SetDo(0, Gg.OutPut0.机械手启动, 0); WinAPI.Wait(100); InitTime.InitialTime(); StepHome = 30; break; case 30: if (Gg.GetDi(0, Gg.InPut0.机械手运动中) == 1) { AddList("机械手启动成功!"); InitTime.InitialTime(); StepHome = 40; } else if (InitTime.TimeIsUp(2000)) { if (RobotHomeNum < 3) { InitTime.InitialTime(); StepHome = 20; } else { AddList("机械手启动失败!"); ShowList("机械手启动失败!"); StepHome = 1000; return; } } break; case 40: if (Frm_Engineering.fEngineering.Tcp_Robot.IsStart) { AddList("机械手网络链接OK!"); InitTime.InitialTime(); StepHome = 50; } else if (InitTime.TimeIsUp(5000)) { if (RobotHomeNum < 3) { InitTime.InitialTime(); StepHome = 20; } else { AddList("机械手网络链接失败!"); ShowList("机械手网络链接失败!"); StepHome = 1000; return; } } break; case 50: AddList("获取机械手程序版本!"); if (Frm_Engineering.fEngineering.Rbt_SendCmd("GetVersion", "0", "0", "0", "0", "0", "0", "0", "DAB-SV(1.0.0)_20180505", "0", "0", "0", "0", "0") == false) { StepHome = 1000; return; } InitTime.InitialTime(); StepHome = 60; break; case 60: if (EpsonRobot.sRobot_Status == "GetVersionOK") { AddList("机械手程序版本匹配OK!"); InitTime.InitialTime(); StepHome = 100; } else if (EpsonRobot.sRobot_Status == "GetVersionNG") { AddList("机械手版本不匹配!"); ShowList("机械手版本不匹配!"); StepHome = 1000; return; } else if (InitTime.TimeIsUp(3000)) { AddList("获取机械手程序版本超时!"); ShowList("获取机械手程序版本超时!"); StepHome = 1000; return; } break; case 100: AddList("机械手回初始位置开始!"); if (Frm_Engineering.fEngineering.Rbt_SendCmd("Step", RobotPosName.待机位置, "20", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "20") == false) { StepHome = 1000; return; } InitTime.InitialTime(); StepHome = 110; break; case 110: if (EpsonRobot.sRobot_Status == "Step" + RobotPosName.待机位置) { AddList("机械手回待机位置OK!"); InitTime.InitialTime(); StepHome = 200; } else if (InitTime.TimeIsUp(10000)) { AddList("机械手回待机位置超时!"); ShowList("机械手回待机位置超时!"); StepHome = 1000; return; } break; case 200: Frm_ProgressBar.SetValueProgressBar(30); //初始化进度条的进度更新显示 if (Gg.GetDi(0, Gg.InPut0.阻挡气缸1伸出) == 1 && Gg.GetDi(0, Gg.InPut0.阻挡气缸2伸出) == 1 && Gg.GetDi(0, Gg.InPut0.阻挡气缸3伸出) == 1 && Gg.GetExDi(0, Gg.InPut1.光源旋转气缸缩回) == 1 && Gg.GetExDi(0, Gg.InPut1.光源旋转气缸伸出) == 0 && Gg.GetExDi(0, Gg.InPut1.载具夹紧气缸缩回) == 1 && Gg.GetExDi(0, Gg.InPut1.载具夹紧气缸伸出) == 0 && Gg.GetExDi(0, Gg.InPut1.机械手撕膜升降气缸缩回) == 1 && Gg.GetExDi(0, Gg.InPut1.机械手撕膜升降气缸伸出) == 0 && Gg.GetExDi(0, Gg.InPut1.机械手滑台气缸缩回) == 1 && Gg.GetExDi(0, Gg.InPut1.机械手滑台气缸伸出) == 0 && Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸上) == 1 && Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸下) == 0) { InitTime.InitialTime(); StepHome = 210; } if (InitTime.TimeIsUp(6000)) { if (Gg.GetDi(0, Gg.InPut0.阻挡气缸1伸出) == 0) { AddList("阻挡气缸1伸出信号异常,请检查!"); ShowList("阻挡气缸1伸出信号异常,请检查!"); } if (Gg.GetDi(0, Gg.InPut0.阻挡气缸2伸出) == 0) { AddList("阻挡气缸2伸出信号异常,请检查!"); ShowList("阻挡气缸2伸出信号异常,请检查!"); } if (Gg.GetDi(0, Gg.InPut0.阻挡气缸3伸出) == 0) { AddList("阻挡气缸3伸出信号异常,请检查!"); ShowList("阻挡气缸3伸出信号异常,请检查!"); } if (Gg.GetExDi(0, Gg.InPut1.光源旋转气缸缩回) == 0 || Gg.GetExDi(0, Gg.InPut1.光源旋转气缸伸出) == 1) { AddList("光源旋转气缸缩回信号异常,请检查!"); ShowList("光源旋转气缸缩回回信号异常,请检查!"); } if (Gg.GetExDi(0, Gg.InPut1.载具夹紧气缸缩回) == 0 || Gg.GetExDi(0, Gg.InPut1.载具夹紧气缸伸出) == 1) { AddList("载具夹紧气缸缩回信号异常,请检查!"); ShowList("载具夹紧气缸缩回信号异常,请检查!"); } if (Gg.GetExDi(0, Gg.InPut1.机械手撕膜升降气缸缩回) == 0 || Gg.GetExDi(0, Gg.InPut1.机械手撕膜升降气缸伸出) == 1) { AddList("机械手撕膜升降气缸缩回信号异常,请检查!"); ShowList("机械手撕膜升降气缸缩回信号异常,请检查!"); } if (Gg.GetExDi(0, Gg.InPut1.机械手滑台气缸缩回) == 0 || Gg.GetExDi(0, Gg.InPut1.机械手滑台气缸伸出) == 1) { AddList("机械手滑台气缸缩回信号异常,请检查!"); ShowList("机械手滑台气缸缩回信号异常,请检查!"); } if (Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸上) == 0 || Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸下) == 1) { AddList("PSA吸嘴升降气缸上信号异常,请检查!"); ShowList("PSA吸嘴升降气缸上信号异常,请检查!"); } StepHome = 1000; } break; case 210: AddList("料仓左Z轴开始回原点…"); AddList("料仓右Z轴开始回原点…"); AddList("PSA供料Z轴开始回原点…"); AddList("保压Z轴开始回原点…"); AddList("PSA搬运Y轴开始回原点…"); GoHome.AxisHome[0, Axis.料仓左Z轴].Result = false; GoHome.AxisHome[0, Axis.料仓右Z轴].Result = false; GoHome.AxisHome[0, Axis.PSA供料Z轴].Result = false; GoHome.AxisHome[0, Axis.保压Z轴].Result = false; GoHome.AxisHome[0, Axis.PSA搬运Y轴].Result = false; GoHome.AxisHome[0, Axis.料仓左Z轴].Enable = true; GoHome.AxisHome[0, Axis.料仓右Z轴].Enable = true; GoHome.AxisHome[0, Axis.PSA供料Z轴].Enable = true; GoHome.AxisHome[0, Axis.保压Z轴].Enable = true; GoHome.AxisHome[0, Axis.PSA搬运Y轴].Enable = true; GoHome.AxisHome[0, Axis.料仓左Z轴].Step = 10; GoHome.AxisHome[0, Axis.料仓右Z轴].Step = 10; GoHome.AxisHome[0, Axis.PSA供料Z轴].Step = 10; GoHome.AxisHome[0, Axis.保压Z轴].Step = 10; GoHome.AxisHome[0, Axis.PSA搬运Y轴].Step = 10; InitTime.InitialTime(); Frm_ProgressBar.SetValueProgressBar(30); StepHome = 220; break; case 220: GotoHome(0, Axis.料仓左Z轴, 30, -1000, 10, 1, 5); GotoHome(0, Axis.料仓右Z轴, 30, -1000, 10, 1, 5); GotoHome(0, Axis.PSA供料Z轴, 30, -1000, 10, 1, 5); GotoHome(0, Axis.保压Z轴, 30, -90, 20, -3, 5); GotoHome(0, Axis.PSA搬运Y轴, 30, -1000, 10, 1, 10); if (GoHome.AxisHome[0, Axis.PSA搬运Y轴].Step != 0 && Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸上) == 0) { AddList("PSA吸嘴升降气缸上信号异常!"); ShowList("PSA吸嘴升降气缸上信号异常!"); StepHome = 1000; } if (GoHome.AxisHome[0, Axis.料仓左Z轴].Step == 0 && GoHome.AxisHome[0, Axis.料仓左Z轴].Enable) { GoHome.AxisHome[0, Axis.料仓左Z轴].Enable = false; if (GoHome.AxisHome[0, Axis.料仓左Z轴].Result) { AddList("料仓左Z轴回原点成功!"); } else { AddList("料仓左Z轴回原点失败!"); ShowList("料仓左Z轴回原点失败!"); StepHome = 1000; } } if (GoHome.AxisHome[0, Axis.料仓右Z轴].Step == 0 && GoHome.AxisHome[0, Axis.料仓右Z轴].Enable) { GoHome.AxisHome[0, Axis.料仓右Z轴].Enable = false; if (GoHome.AxisHome[0, Axis.料仓右Z轴].Result) { AddList("料仓右Z轴回原点成功!"); } else { AddList("料仓右Z轴回原点失败!"); ShowList("料仓右Z轴回原点失败!"); StepHome = 1000; } } if (GoHome.AxisHome[0, Axis.PSA供料Z轴].Step == 0 && GoHome.AxisHome[0, Axis.PSA供料Z轴].Enable) { GoHome.AxisHome[0, Axis.PSA供料Z轴].Enable = false; if (GoHome.AxisHome[0, Axis.PSA供料Z轴].Result) { AddList("PSA供料Z轴回原点成功!"); } else { AddList("PSA供料Z轴回原点失败!"); ShowList("PSA供料Z轴回原点失败!"); StepHome = 1000; } } if (GoHome.AxisHome[0, Axis.保压Z轴].Step == 0 && GoHome.AxisHome[0, Axis.保压Z轴].Enable) { GoHome.AxisHome[0, Axis.保压Z轴].Enable = false; if (GoHome.AxisHome[0, Axis.保压Z轴].Result) { AddList("保压Z轴回原点成功!"); } else { AddList("保压Z轴回原点失败!"); ShowList("保压Z轴回原点失败!"); StepHome = 1000; } } if (GoHome.AxisHome[0, Axis.PSA搬运Y轴].Step == 0 && GoHome.AxisHome[0, Axis.PSA搬运Y轴].Enable) { GoHome.AxisHome[0, Axis.PSA搬运Y轴].Enable = false; if (GoHome.AxisHome[0, Axis.PSA搬运Y轴].Result) { AddList("PSA搬运Y轴回原点成功!"); } else { AddList("PSA搬运Y轴回原点失败!"); ShowList("PSA搬运Y轴回原点失败!"); StepHome = 1000; } } if (GoHome.AxisHome[0, Axis.料仓左Z轴].Result && GoHome.AxisHome[0, Axis.料仓右Z轴].Result && GoHome.AxisHome[0, Axis.PSA供料Z轴].Result && GoHome.AxisHome[0, Axis.保压Z轴].Result && GoHome.AxisHome[0, Axis.PSA搬运Y轴].Result) { Frm_ProgressBar.SetValueProgressBar(50); InitTime.InitialTime(); StepHome = 300; } break; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 300: AddList("各轴开始回待机位置…"); //料仓 Gg.AbsMotion(0, Axis.料仓左Z轴, mFunction.Pos.TeachAxis1[Axis.tTag.左料仓, Axis.Point左料仓.初始位置], 20); Gg.AbsMotion(0, Axis.料仓右Z轴, mFunction.Pos.TeachAxis1[Axis.tTag.右料仓, Axis.Point右料仓.初始位置], 20); //PSA供料 Gg.AbsMotion(0, Axis.PSA供料Z轴, mFunction.Pos.TeachAxis2[Axis.tTag.PSA供料, Axis.Point供料PSA.PSA_Z轴初始位置], 20); Gg.AbsMotion(0, Axis.PSA搬运Y轴, mFunction.Pos.TeachAxis1[Axis.tTag.PSA供料, Axis.Point供料PSA.PSA_Y轴吸料位置], 20); //保压站 Gg.AbsMotion(0, Axis.保压Z轴, mFunction.Pos.TeachAxis1[Axis.tTag.保压, Axis.Point保压.初始位置], 20); InitTime.InitialTime(); StepHome = 310; break; case 310: if (Gg.ZSPD(0, Axis.PSA搬运Y轴) == false && Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸上) == 0) { AddList("PSA吸嘴升降气缸上信号异常!"); ShowList("PSA吸嘴升降气缸上信号异常!"); StepHome = 1000; } if (Gg.ZSPD(0, Axis.料仓左Z轴) && Gg.ZSPD(0, Axis.料仓右Z轴) && Gg.ZSPD(0, Axis.PSA供料Z轴) && Gg.ZSPD(0, Axis.PSA搬运Y轴) && Gg.ZSPD(0, Axis.保压Z轴)) { AddList("整机回待机位置完成!"); InitTime.InitialTime(); StepHome = 350; } else { if (InitTime.TimeIsUp(10000)) { if (Gg.ZSPD(0, Axis.料仓左Z轴) == false) { AddList("料仓左Z轴回待机位置失败!"); ShowList("料仓左Z轴回待机位置失败!"); } if (Gg.ZSPD(0, Axis.料仓右Z轴) == false) { AddList("料仓右Z轴回待机位置失败!"); ShowList("料仓右Z轴回待机位置失败!"); } if (Gg.ZSPD(0, Axis.PSA供料Z轴) == false) { AddList("PSA供料Z轴回待机位置失败!"); ShowList("PSA供料Z轴回待机位置失败!"); } if (Gg.ZSPD(0, Axis.PSA搬运Y轴) == false) { AddList("PSA搬运Y轴回待机位置失败!"); ShowList("PSA搬运Y轴回待机位置失败!"); } if (Gg.ZSPD(0, Axis.保压Z轴) == false) { AddList("保压Z轴回待机位置失败!"); ShowList("保压Z轴回待机位置失败!"); } StepHome = 1000; } } break; case 350: //平移气缸回到左边 Gg.SetExDo(0, 2, Gg.OutPut3.料盘平移无杆气缸左, 1); Gg.SetExDo(0, 2, Gg.OutPut3.料盘平移无杆气缸右, 0); //保压无杆气缸向右复位 Gg.SetExDo(0, 0, Gg.OutPut1.保压无杆气缸左, 0); Gg.SetExDo(0, 0, Gg.OutPut1.保压无杆气缸右, 1); AddList("料盘平移无杆气缸向左复位!"); InitTime.InitialTime(); StepHome = 360; break; case 360: if (Gg.GetExDi(2, Gg.InPut3.料盘平移无杆气缸左) == 1 && Gg.GetExDi(2, Gg.InPut3.料盘平移无杆气缸右) == 0 && Gg.GetExDi(0, Gg.InPut1.保压无杆气缸右) == 1 && Gg.GetExDi(0, Gg.InPut1.保压无杆气缸左) == 0) { AddList("料盘平移无杆气缸向左复位OK!"); InitTime.InitialTime(); StepHome = 370; } else { if (InitTime.TimeIsUp(6000)) { if (Gg.GetExDi(2, Gg.InPut3.料盘平移无杆气缸左) == 0 || Gg.GetExDi(2, Gg.InPut3.料盘平移无杆气缸右) == 1) { AddList("料盘平移无杆气缸左信号异常!"); InitTime.InitialTime(); StepHome = 1000; } } if (Gg.GetExDi(0, Gg.InPut1.保压无杆气缸左) == 1 || Gg.GetExDi(0, Gg.InPut1.保压无杆气缸右) == 0) { AddList("保压无杆气缸右信号异常!"); InitTime.InitialTime(); StepHome = 1000; } } break; case 370: InitTime.InitialTime(); StepHome = 800; break; case 800: AddList("初始化完成"); ShowList("初始化完成"); PVar.LampStatus = 20; PVar.Stop_Flag = true; PVar.AutoRunFlag = false; PVar.MacHold = false; PVar.CPKDoneCounts = 0; PVar.WorkMode = 0; Frm_Main.fMain.Panel_CPK.Visible = false; //按钮初始化 Frm_Main.fMain.Btn_Start.Enabled = true; Frm_Main.fMain.Btn_Pause.Enabled = false; Frm_Main.fMain.Btn_Stop.Enabled = true; Frm_Main.fMain.Btn_Start.BZ_BackColor = PVar.BZColor_SelectedBtn; //'主页面初始化和自动运行按钮 Frm_Main.fMain.Btn_Pause.BZ_BackColor = PVar.BZColor_UnselectedBtn; Frm_Main.fMain.Btn_Stop.BZ_BackColor = PVar.BZColor_UnselectedBtn; Frm_Engineering.fEngineering.TabPage3.Parent = Frm_Engineering.fEngineering.TabControl1; Frm_Engineering.fEngineering.TabPage4.Parent = Frm_Engineering.fEngineering.TabControl1; Frm_ProgressBar.IsShowProgresBar(false); //'初始化进度条显示 Frm_Engineering.fEngineering.Home_Timer.Enabled = false; for (int i = 0; i <= 10; i++) { PVar.Sta_Work[i].State = false; PVar.Sta_Work[i].Result = false; PVar.Sta_Work[i].IsHaveHSG = false; PVar.Sta_Work[i].Step = 0; } Mod_ErrorCode.CheckSystemTimeStep = 0; GoHome.Reset.State = false; GoHome.Reset.Result = true; StepHome = 0; break; case 1000: PVar.LampStatus = 10; PVar.MacHold = false; PVar.Stop_Flag = true; //按钮初始化 Frm_Main.fMain.Btn_Start.Enabled = true; Frm_Main.fMain.Btn_Pause.Enabled = false; Frm_Main.fMain.Btn_Stop.Enabled = false; Frm_Main.fMain.Btn_Start.BZ_BackColor = PVar.BZColor_UnselectedBtn; //主页面初始化和自动运行按钮 Frm_Main.fMain.Btn_Pause.BZ_BackColor = PVar.BZColor_UnselectedBtn; Frm_Main.fMain.Btn_Stop.BZ_BackColor = PVar.BZColor_SelectedEndBtn; PVar.Rtn = gts.GT_Stop(0, 255, 255); //紧急停止0号卡所有轴 Frm_Engineering.fEngineering.Home_Timer.Enabled = false; Frm_ProgressBar.IsShowProgresBar(false); //初始化进度条显示 GoHome.Reset.Result = false; GoHome.Reset.State = false; StepHome = 0; break; } //string tempStr = ""; //if (Gg.GetDi(0, Gg.InPut0.安全门) == 0) // { // tempStr = "安全门"; // } //if (!string.IsNullOrEmpty(tempStr)) // { // AddList("请关闭" + tempStr + "再初始化"); // ShowList("请关闭" + tempStr + "再初始化"); // StepHome = 1000; // return; // } }