//【Tag3】顶片料起始位置、顶片料结束位置 public static void S0_MotionPos4(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, BVar.S2G_Z, mFunction.Pos.TeachAxis2[m, n], 20); Manual_Step[m, n] = Manual_Step[m, n] + 1; break; case 2: if (Gg.ZSPD(0, BVar.S2G_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; } }
//【Tag1】到待机位置、保压位置 public static void S3_MotionPos0(ref bool Status, int m, int n) { switch (Manual_Step[m, n]) { //Z轴原点位置=>X/Y/R轴初始位置=>Z轴初始位置 case 0: Status = true; Manual_Step[m, n] = Manual_Step[m, n] + 1; break; case 1: Gg.AbsMotion(0, BVar.S3_Z, mFunction.Pos.TeachAxis1[m, n], 20); Manual_Step[m, n] = Manual_Step[m, n] + 1; break; case 2: if (Gg.ZSPD(0, BVar.S3_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; } }
//【Tag0】拍HSG角度位置、装配位置 public static void S2_MotionPos3(ref bool Status, int m, int n) { switch (Manual_Step[m, n]) { //Z轴原点位置=>X/Y/R轴初始位置=>Z轴初始位置 case 0: Status = true; Manual_Step[m, n] = Manual_Step[m, n] + 1; break; case 1: Gg.AbsMotion(0, BVar.S2_Z, 0, PVar.ParAxis.Speed[BVar.S2_Z]); Manual_Step[m, n] = Manual_Step[m, n] + 1; break; case 2: if (Gg.ZSPD(0, BVar.S2_Z)) { Manual_Step[m, n] = Manual_Step[m, n] + 1; } break; case 3: Gg.AbsMotion(0, BVar.S2_X, mFunction.Pos.TeachAxis1[m, n], PVar.ParAxis.Speed[BVar.S2_X]); Gg.AbsMotion(0, BVar.S2_Y, mFunction.Pos.TeachAxis2[m, n], PVar.ParAxis.Speed[BVar.S2_Y]); Gg.AbsMotion(0, BVar.S2_R, mFunction.Pos.TeachAxis4[m, n], PVar.ParAxis.Speed[BVar.S2_R]); Manual_Step[m, n] = Manual_Step[m, n] + 1; break; case 4: if (Gg.ZSPD(0, BVar.S2_X) && Gg.ZSPD(0, BVar.S2_Y) && Gg.ZSPD(0, BVar.S2_Z) && Gg.ZSPD(0, BVar.S2_R)) { Manual_Step[m, n] = Manual_Step[m, n] + 1; } break; case 5: Gg.AbsMotion(0, BVar.S2_Z, mFunction.Pos.TeachAxis3[m, n], PVar.ParAxis.Speed[BVar.S2_Z]); Manual_Step[m, n] = Manual_Step[m, n] + 1; break; case 6: if (Gg.ZSPD(0, BVar.S2_Z)) { Manual_Step[m, n] = Manual_Step[m, n] + 1; } break; case 7: 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) { if (Once == false) { if (BVar.FileRorW.ReadINI("Material_index", "是否片料", "有", PVar.PublicParPath) == "有") { StaWork.IsHavePianliao = true; } else { StaWork.IsHavePianliao = false; } } StaWork.State = false; TimeOut = API.GetTickCount(); //StaWork.Step = 20; } break; case 20: if (StaWork.State == false && StaWork.Enable) { StaWork.State = true; TimeOut = API.GetTickCount(); StaWork.Step = 30; } else { if (API.GetTickCount() - TimeOut > 500) { TimeOut = API.GetTickCount(); StaWork.Step = 10; } } break; case 30: Once = true; if (StaWork.IsHavePianliao) { TimeOut = API.GetTickCount(); StaWork.Step = 10; } else { TimeOut = API.GetTickCount(); StaWork.Step = 40; } break; case 40: //判断料仓有无物料 if (Gg.GetDi(0, Gg.InPut0.片料到位检测) == 1) { TimeOut = API.GetTickCount(); StaWork.Step = 60; } else { } break; case 60: Gg.SetExDo(0, 0, Gg.OutPut2.夹上摸气缸, 1); Gg.SetExDo(0, 0, Gg.OutPut2.撕摸升降气缸, 0); Gg.SetExDo(0, 0, Gg.OutPut2.片料夹紧气缸左, 1); Gg.SetExDo(0, 0, Gg.OutPut2.片料夹紧气缸右, 1); Gg.SetExDo(0, 0, Gg.OutPut2.拉料无杆干气缸, 0); TimeOut = API.GetTickCount(); StaWork.Step = 70; break; case 70: if (Gg.GetExDi(0, Gg.InPut2.夹上摸气缸伸出) == 1 && Gg.GetExDi(0, Gg.InPut2.夹上摸气缸缩回) == 0 && Gg.GetExDi(0, Gg.InPut2.撕摸升降气缸缩回) == 1 && Gg.GetExDi(0, Gg.InPut2.撕摸升降气缸伸出) == 0 && Gg.GetExDi(0, Gg.InPut2.片料夹紧气缸左伸出) == 1 && Gg.GetExDi(0, Gg.InPut2.片料夹紧气缸右伸出) == 1 && Gg.GetExDi(0, Gg.InPut2.拉料无杆干气缸左) == 1 && Gg.GetExDi(0, Gg.InPut2.拉料无杆干气缸右) == 0) { TimeOut = API.GetTickCount(); StaWork.Step = 80; } if (API.GetTickCount() - TimeOut > 2000) { if (Gg.GetExDi(0, Gg.InPut2.夹上摸气缸伸出) == 0 || Gg.GetExDi(0, Gg.InPut2.夹上摸气缸缩回) == 1) { AddList("夹上摸气缸伸出信号异常,请检查!"); ShowList("夹上摸气缸伸出信号异常,请检查!"); } if (Gg.GetExDi(0, Gg.InPut2.撕摸升降气缸缩回) == 0 || Gg.GetExDi(0, Gg.InPut2.撕摸升降气缸伸出) == 1) { AddList("撕摸升降气缸缩回信号异常,请检查!"); ShowList("撕摸升降气缸缩回信号异常,请检查!"); } if (Gg.GetExDi(0, Gg.InPut2.片料夹紧气缸左伸出) == 0) { AddList("片料夹紧气缸左伸出信号异常,请检查!"); ShowList("片料夹紧气缸左伸出信号异常,请检查!"); } if (Gg.GetExDi(0, Gg.InPut2.片料夹紧气缸右伸出) == 0) { AddList("片料夹紧气缸右伸出信号异常,请检查!"); ShowList("片料夹紧气缸右伸出信号异常,请检查!"); } if (Gg.GetExDi(0, Gg.InPut2.拉料无杆干气缸左) == 0 || Gg.GetExDi(0, Gg.InPut2.拉料无杆干气缸右) == 1) { AddList("拉料无杆干气缸左信号异常,请检查!"); ShowList("拉料无杆干气缸左信号异常,请检查!"); } TimeOut = API.GetTickCount(); BufferStep = 70; StaWork.Step = 8000; } break; case 80: //取片料马达和拉料马达回到初始位置 Gg.AbsMotion(0, BVar.S2G_Y, mFunction.Pos.TeachAxis1[3, 0], PVar.ParAxis.Speed[BVar.S2G_Y]); Gg.AbsMotion(0, BVar.S2L_Z, mFunction.Pos.TeachAxis3[3, 3], PVar.ParAxis.Speed[BVar.S2L_Z]); TimeOut = API.GetTickCount(); StaWork.Step = 90; break; case 90: if (Gg.ZSPD(0, BVar.S2G_Y) && Gg.ZSPD(0, BVar.S2L_Z)) { TimeOut = API.GetTickCount(); StaWork.Step = 100; } break; case 100: Gg.SetExDo(0, 0, Gg.OutPut2.撕摸升降气缸, 1); TimeOut = API.GetTickCount(); StaWork.Step = 110; break; case 110: if (Gg.GetExDi(0, Gg.InPut2.撕摸升降气缸缩回) == 0 && Gg.GetExDi(0, Gg.InPut2.撕摸升降气缸伸出) == 1) { Gg.SetExDo(0, 0, Gg.OutPut2.取底膜破真空, 0); Gg.SetExDo(0, 0, Gg.OutPut2.取片料真空吸, 1); TimeOut = API.GetTickCount(); StaWork.Step = 120; } else { if (API.GetTickCount() - TimeOut > 2000) { AddList("撕摸升降气缸伸出信号异常,请检查!"); TimeOut = API.GetTickCount(); BufferStep = 110; StaWork.Step = 8000; } } break; case 120: if (Gg.GetDi(0, Gg.InPut0.取片料真空检测) == 1) { Gg.SetExDo(0, 0, Gg.OutPut2.夹上摸气缸, 0); TimeOut = API.GetTickCount(); StaWork.Step = 130; } else { if (API.GetTickCount() - TimeOut > 2000) { AddList("取片料真空检测信号异常,请检查!"); TimeOut = API.GetTickCount(); BufferStep = 120; StaWork.Step = 8000; } } break; case 130: if (Gg.GetExDi(0, Gg.InPut2.夹上摸气缸缩回) == 1 && Gg.GetExDi(0, Gg.InPut2.夹上摸气缸伸出) == 0) { Gg.SetExDo(0, 0, Gg.OutPut2.撕摸升降气缸, 0); TimeOut = API.GetTickCount(); StaWork.Step = 140; } else { if (API.GetTickCount() - TimeOut > 2000) { AddList("夹上摸气缸缩回测信号异常,请检查!"); TimeOut = API.GetTickCount(); BufferStep = 130; StaWork.Step = 8000; } } break; case 140: if (Gg.GetExDi(0, Gg.InPut2.撕摸升降气缸缩回) == 1 && Gg.GetExDi(0, Gg.InPut2.撕摸升降气缸伸出) == 0) { Gg.AbsMotion(0, BVar.S2G_Y, mFunction.Pos.TeachAxis1[3, 1], PVar.ParAxis.Speed[BVar.S2G_Y]); TimeOut = API.GetTickCount(); StaWork.Step = 150; } else { if (API.GetTickCount() - TimeOut > 2000) { AddList("撕摸升降气缸缩回信号异常,请检查!"); TimeOut = API.GetTickCount(); BufferStep = 140; StaWork.Step = 8000; } } break; case 150: if (Gg.ZSPD(0, BVar.S2G_Y)) { Gg.SetExDo(0, 0, Gg.OutPut2.撕摸升降气缸, 1); TimeOut = API.GetTickCount(); StaWork.Step = 160; } break; case 160: if (Gg.GetExDi(0, Gg.InPut2.撕摸升降气缸缩回) == 0 && Gg.GetExDi(0, Gg.InPut2.撕摸升降气缸伸出) == 1) { Gg.SetExDo(0, 0, Gg.OutPut2.取底膜破真空, 0); Gg.SetExDo(0, 0, Gg.OutPut2.取片料真空吸, 1); TimeOut = API.GetTickCount(); StaWork.Step = 120; } else { if (API.GetTickCount() - TimeOut > 2000) { AddList("撕摸升降气缸伸出信号异常,请检查!"); TimeOut = API.GetTickCount(); BufferStep = 110; StaWork.Step = 8000; } } break; case 23320: TimeOut = API.GetTickCount(); StaWork.Step = 100; break; case 800: StaWork.State = false; StaWork.Step = 10; break; case 1000: StaWork.Result = false; StaWork.State = false; StaWork.Step = 10; break; //遇到异常,设备先暂停,确定后处理************************ case 8000: PVar.IsSystemOnPauseMode = true; PVar.MacHold = 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 AutoRun(ref PVar.WorkType StaWork) { try { switch (StaWork.Step) { case 10: if (PVar.Stop_Flag == false) { StaWork.State = false; TimeOut = API.GetTickCount(); StaWork.Step = 20; } break; case 20: //本站工作状态,工站使能,本站是否有产品,转盘工作状态 if (PVar.ParList.CheckSts[17] == false) { if (StaWork.State == false && StaWork.Enable && StaWork.Result && StaWork.IsHaveHSG && PVar.Sta_Work[1].State == false) { StaWork.State = true; StaWork.Result = false; //清空缓存的压力值 for (int i = PVar.Press.Count() - 1; i > 0; i--) { PVar.Press[i] = 0; } Command.Com2_Send(Command.压力控制打开); Gg.SetExDo(0, 0, Gg.OutPut2.保压升降气缸, 1); AddList("复检开始开始!"); TimeOut = API.GetTickCount(); StaWork.Step = 30; } else { StaWork.Step = 10; } } else { if (StaWork.State == false && StaWork.Enable && StaWork.IsHaveHSG && PVar.Sta_Work[1].State == false) { StaWork.State = true; StaWork.Result = false; //清空缓存的压力值 for (int i = PVar.Press.Count() - 1; i > 0; i--) { PVar.Press[i] = 0; } Command.Com2_Send(Command.压力控制打开); Gg.SetExDo(0, 0, Gg.OutPut2.保压升降气缸, 1); AddList("复检开始开始!"); TimeOut = API.GetTickCount(); StaWork.Step = 30; } } break; case 30: if (Gg.GetExDi(0, Gg.InPut2.保压升降气缸缩回) == 0 && Gg.GetExDi(0, Gg.InPut2.保压升降气缸伸出) == 1) { //AddList("保压升降气缸复位OK!"); Frm_Production.fProduction.Chart_Time.Enabled = true; TimeOut = API.GetTickCount(); StaWork.Step = 40; } else { if (API.GetTickCount() - TimeOut > 2000) { AddList("保压升降气缸伸出信号异常!"); ShowList("保压升降气缸伸出信号异常!"); TimeOut = API.GetTickCount(); StaWork.Step = 1000; } } break; case 40: if (API.GetTickCount() - TimeOut > 100) { Gg.AbsMotion(0, 8, mFunction.Pos.TeachAxis1[1, 1], PVar.ParAxis.Speed[BVar.S3_Z]); TimeOut = API.GetTickCount(); StaWork.Step = 50; } break; case 50: if (Gg.ZSPD(0, BVar.S3_Z)) { Gg.SetExDo(0, 0, Gg.OutPut2.保压升降气缸, 0); TimeOut = API.GetTickCount(); StaWork.Step = 60; } break; case 60: if (PVar.IsCOM2_Working) { //**保压位置+偏移值=终点最大行程 Gg.AbsMotion(0, 8, mFunction.Pos.TeachAxis1[1, 1] + PVar.ParList.Data[22], PVar.ParList.Data[23]); TimeOut = API.GetTickCount(); StaWork.Step = 70; } else { AddList("保压站压力传感器异常!"); ShowList("保压站压力传感器异常!"); TimeOut = API.GetTickCount(); StaWork.Step = 1000; } break; case 70: if (Gg.ZSPD(0, BVar.S3_Z)) { TimeOut = API.GetTickCount(); StaWork.Step = 80; } break; case 80: if (API.GetTickCount() - TimeOut > PVar.ParList.Data[41] * 1000) { Gg.AbsMotion(0, 8, mFunction.Pos.TeachAxis1[1, 0], PVar.ParAxis.Speed[BVar.S3_Z]); TimeOut = API.GetTickCount(); StaWork.Step = 90; } break; case 90: if (Gg.ZSPD(0, BVar.S3_Z)) { TimeOut = API.GetTickCount(); StaWork.Step = 800; } break; case 800: Frm_Production.fProduction.Chart_Time.Enabled = false; 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 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); } }
/// <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.Instance.AxisHome[CardNum, Axis].Step != 0) { GoHome.Instance.AxisHome[CardNum, Axis].State = true; switch (GoHome.Instance.AxisHome[CardNum, Axis].Step) { case 10: 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.Instance.AxisHome[CardNum, Axis].Counter = 0; //回原点计数 GoHome.Instance.AxisHome[CardNum, Axis].Step = 20; break; case 20: GoHome.Instance.AxisHome[CardNum, Axis].Capture = 0; if (Gg.GetHomeDi(CardNum, Axis) == 0) //判断是否在原点上 { if (GoHome.Instance.AxisHome[CardNum, Axis].Counter > 1) { GoHome.Instance.AxisHome[CardNum, Axis].Step = 140; } else { GoHome.Instance.AxisHome[CardNum, Axis].Counter = GoHome.Instance.AxisHome[CardNum, Axis].Counter + 1; GoHome.Instance.AxisHome[CardNum, Axis].Step = 30; //开始搜索原点 } } else { GoHome.Instance.AxisHome[CardNum, Axis].Step = 200; //偏离原点,方向与搜索原点方向相反 } break; case 30: gts.GT_ClrSts(CardNum, Axis, (short)1); gts.GT_SetCaptureMode(CardNum, Axis, gts.CAPTURE_HOME); //第一次原点搜索 GoHome.Instance.AxisHome[CardNum, Axis].TempPos = 0; Gg.AbsMotion(CardNum, Axis, System.Convert.ToDouble(Gg.GetPrfPosmm(CardNum, Axis) + searchHomeDist), vel); //启动运动,开始搜索原点 GoHome.Instance.AxisHome[CardNum, Axis].Step = 40; break; case 40: gts.GT_ClrSts(CardNum, Axis, (short)1); gts.GT_GetSts(CardNum, Axis, out GoHome.Instance.AxisHome[CardNum, Axis].status, (short)1, out temp_pClock); gts.GT_GetCaptureStatus(CardNum, Axis, out GoHome.Instance.AxisHome[CardNum, Axis].Capture, out GoHome.Instance.AxisHome[CardNum, Axis].TempPos, (short)1, out temp_pClock); //获取当前轴原点捕获的状态及捕获的当前位置 if (GoHome.Instance.AxisHome[CardNum, Axis].Capture == 1) //判断当前轴是否原点捕获触发 { Gg.AxisStop(CardNum, Axis); //当前轴停止 GoHome.Instance.AxisHome[CardNum, Axis].Capture = 0; GoHome.Instance.AxisHome[CardNum, Axis].Step = 50; } else if (Gg.GetLimitDi_Z(CardNum, Axis) == 1) //判断当前轴是否触发正极限 { Gg.AxisStop(CardNum, Axis); //当前轴停止 GoHome.Instance.AxisHome[CardNum, Axis].Step = 170; } else if (Gg.GetLimitDi_F(CardNum, Axis) == 1) //判断当前轴是否触发负极限 { Gg.AxisStop(CardNum, Axis); //当前轴停止 GoHome.Instance.AxisHome[CardNum, Axis].Step = 150; } else if (System.Convert.ToBoolean(GoHome.Instance.AxisHome[CardNum, Axis].status & 0x400) == false) //判断当前轴规划器是否运动停止(原点搜索距离太小) { GoHome.Instance.AxisHome[CardNum, Axis].Step = 140; } break; case 50: Gg.AbsMotion(CardNum, Axis, System.Convert.ToDouble(GoHome.Instance.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); //启动运动,原点反向运动 GoHome.Instance.AxisHome[CardNum, Axis].Step = 60; break; case 60: gts.GT_ClrSts(CardNum, Axis, (short)1); gts.GT_GetSts(CardNum, Axis, out GoHome.Instance.AxisHome[CardNum, Axis].status, (short)1, out temp_pClock); //获取当前轴的状态 if (System.Convert.ToBoolean(GoHome.Instance.AxisHome[CardNum, Axis].status & 0x400) == false) //判断当前轴是否运动停止 { GoHome.Instance.AxisHome[CardNum, Axis].Step = 70; } break; case 70: 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.Instance.AxisHome[CardNum, Axis].Step = 80; //跳转到下一步 break; case 80: gts.GT_ClrSts(CardNum, Axis, (short)1); gts.GT_GetSts(CardNum, Axis, out GoHome.Instance.AxisHome[CardNum, Axis].status, (short)1, out temp_pClock); //获取当前轴的状态 gts.GT_GetCaptureStatus(CardNum, Axis, out GoHome.Instance.AxisHome[CardNum, Axis].Capture, out GoHome.Instance.AxisHome[CardNum, Axis].TempPos, (short)1, out temp_pClock); //获取当前轴Z相脉冲捕获的状态及捕获的当前位置 if (GoHome.Instance.AxisHome[CardNum, Axis].Capture == 1) //判断当前轴是否Z相脉冲捕获触发 { Gg.AxisStop(CardNum, Axis); //当前轴停止 GoHome.Instance.AxisHome[CardNum, Axis].Capture = 0; //捕获触发标志清零 GoHome.Instance.AxisHome[CardNum, Axis].Step = 90; } else if (System.Convert.ToBoolean(GoHome.Instance.AxisHome[CardNum, Axis].status & 0x400) == false) { GoHome.Instance.AxisHome[CardNum, Axis].Step = 140; //跳转到第110步(或脉冲未捕获,回原点结束,回原点失败) } break; case 90: if (homeoffset < 5) { Gg.AbsMotion(CardNum, Axis, System.Convert.ToDouble(GoHome.Instance.AxisHome[CardNum, Axis].TempPos / Gg.PlusPerUnit(CardNum, Axis) / Tools.GeerRate[CardNum, Axis]) + homeoffset, 2); } else { Gg.AbsMotion(CardNum, Axis, System.Convert.ToDouble(GoHome.Instance.AxisHome[CardNum, Axis].TempPos / Gg.PlusPerUnit(CardNum, Axis) / Tools.GeerRate[CardNum, Axis]) + homeoffset, 30); } GoHome.Instance.AxisHome[CardNum, Axis].Step = 100; break; case 100: gts.GT_ClrSts(CardNum, Axis, (short)1); gts.GT_GetSts(CardNum, Axis, out GoHome.Instance.AxisHome[CardNum, Axis].status, (short)1, out temp_pClock); if (System.Convert.ToBoolean(GoHome.Instance.AxisHome[CardNum, Axis].status & 0x400) == false) //判断当前轴是否运动停止 { GoHome.Instance.AxisHome[CardNum, Axis].oldtime = API.GetTickCount(); GoHome.Instance.AxisHome[CardNum, Axis].Step = 110; } break; case 110: if (API.GetTickCount() - GoHome.Instance.AxisHome[CardNum, Axis].oldtime > 200) { GoHome.Instance.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)); //将当前轴进行位置同步 GoHome.Instance.AxisHome[CardNum, Axis].oldtime = API.GetTickCount(); GoHome.Instance.AxisHome[CardNum, Axis].Step = 130; break; case 130: if (API.GetTickCount() - GoHome.Instance.AxisHome[CardNum, Axis].oldtime > 50) { if (Gg.GetEncPos(CardNum, Axis) == 0 && Gg.GetPrfPos(CardNum, Axis) == 0) { GoHome.Instance.AxisHome[CardNum, Axis].Result = true; GoHome.Instance.AxisHome[CardNum, Axis].State = false; GoHome.Instance.AxisHome[CardNum, Axis].Step = 0; } else { GoHome.Instance.AxisHome[CardNum, Axis].oldtime = API.GetTickCount(); GoHome.Instance.AxisHome[CardNum, Axis].Step = 110; } } break; case 140: GoHome.Instance.AxisHome[CardNum, Axis].Result = false; GoHome.Instance.AxisHome[CardNum, Axis].State = false; GoHome.Instance.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 * 0.5); GoHome.Instance.AxisHome[CardNum, Axis].Step = 160; break; case 160: gts.GT_ClrSts(CardNum, Axis, (short)1); gts.GT_GetSts(CardNum, Axis, out GoHome.Instance.AxisHome[CardNum, Axis].status, (short)1, out temp_pClock); if (System.Convert.ToBoolean(GoHome.Instance.AxisHome[CardNum, Axis].status & 0x400) == false) { GoHome.Instance.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.Instance.AxisHome[CardNum, Axis].Step = 180; break; case 180: gts.GT_ClrSts(CardNum, Axis, (short)1); gts.GT_GetSts(CardNum, Axis, out GoHome.Instance.AxisHome[CardNum, Axis].status, (short)1, out temp_pClock); if (System.Convert.ToBoolean(GoHome.Instance.AxisHome[CardNum, Axis].status & 0x400) == false) { GoHome.Instance.AxisHome[CardNum, Axis].Step = 20; //重新搜索原点 } break; //********************************************************************************************************************* case 200: //offsetPos大于感应片的宽度 Gg.AbsMotion(CardNum, Axis, System.Convert.ToDouble(Gg.GetPrfPosmm(CardNum, Axis) + offsetPos), vel); GoHome.Instance.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); GoHome.Instance.AxisHome[CardNum, Axis].oldtime = API.GetTickCount(); GoHome.Instance.AxisHome[CardNum, Axis].Step = 210; } else { gts.GT_ClrSts(CardNum, Axis, (short)1); gts.GT_GetSts(CardNum, Axis, out GoHome.Instance.AxisHome[CardNum, Axis].status, (short)1, out temp_pClock); if (System.Convert.ToBoolean(GoHome.Instance.AxisHome[CardNum, Axis].status & 0x400) == false) { GoHome.Instance.AxisHome[CardNum, Axis].oldtime = API.GetTickCount(); GoHome.Instance.AxisHome[CardNum, Axis].Step = 140; } } break; case 210: gts.GT_ClrSts(CardNum, Axis, (short)1); gts.GT_GetSts(CardNum, Axis, out GoHome.Instance.AxisHome[CardNum, Axis].status, (short)1, out temp_pClock); if (System.Convert.ToBoolean(GoHome.Instance.AxisHome[CardNum, Axis].status & 0x400) == false) { GoHome.Instance.AxisHome[CardNum, Axis].oldtime = API.GetTickCount(); GoHome.Instance.AxisHome[CardNum, Axis].Step = 220; } break; case (short)220: if (API.GetTickCount() - GoHome.Instance.AxisHome[CardNum, Axis].oldtime > 200) { if (Gg.GetHomeDi(CardNum, Axis) == 1) { GoHome.Instance.AxisHome[CardNum, Axis].Step = 140; } else { GoHome.Instance.AxisHome[CardNum, Axis].Step = 20; } } break; } } }
public void HomeSub() { switch (StepHome) { case 10: Reset.State = true; AddList("设备初始化开始,请等待!"); Gg.SetDo(0, Gg.OutPut0.载具真空吸1, 0); Gg.SetDo(0, Gg.OutPut0.载具真空吸2, 0); Gg.SetDo(0, Gg.OutPut0.载具真空吸3, 0); Gg.SetDo(0, Gg.OutPut0.载具真空吸4, 0); Gg.SetDo(0, Gg.OutPut0.载具破真空1, 0); Gg.SetDo(0, Gg.OutPut0.载具破真空2, 0); Gg.SetDo(0, Gg.OutPut0.载具破真空3, 0); Gg.SetDo(0, Gg.OutPut0.载具破真空4, 0); Gg.SetDo(0, Gg.OutPut0.保压站刹车继电器, 0); Gg.SetDo(0, Gg.OutPut0.警示蜂鸣器, 0); Gg.SetDo(0, Gg.OutPut0.装配站刹车继电器, 0); Gg.SetDo(0, Gg.OutPut1.取料吸嘴破真空, 0); Gg.SetDo(0, Gg.OutPut1.取料吸嘴真空吸, 0); Gg.SetExDo(0, 0, Gg.OutPut2.NG蜂鸣器, 0); Gg.SetExDo(0, 0, Gg.OutPut2.NG指示灯, 0); Gg.SetExDo(0, 0, Gg.OutPut2.OK指示灯, 0); Gg.SetExDo(0, 0, Gg.OutPut2.保压升降气缸, 0); Gg.SetExDo(0, 0, Gg.OutPut2.除底摸平移气缸, 0); Gg.SetExDo(0, 0, Gg.OutPut2.除底膜吸嘴气缸, 0); Gg.SetExDo(0, 0, Gg.OutPut2.检气缸, 0); Gg.SetExDo(0, 0, Gg.OutPut2.拉料无杆干气缸, 0); Gg.SetExDo(0, 0, Gg.OutPut2.片料夹紧气缸右, 0); Gg.SetExDo(0, 0, Gg.OutPut2.片料夹紧气缸左, 0); Gg.SetExDo(0, 0, Gg.OutPut2.取底膜破真空, 0); Gg.SetExDo(0, 0, Gg.OutPut2.取底膜真空吸, 0); Gg.SetExDo(0, 0, Gg.OutPut2.取片料破真空, 0); Gg.SetExDo(0, 0, Gg.OutPut2.取片料真空吸, 0); Gg.SetExDo(0, 0, Gg.OutPut2.撕摸升降气缸, 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); InitTimeOut = API.GetTickCount(); StepHome = 20; break; case 20: Frm_ProgressBar.SetValueProgressBar(10); //初始化进度条的进度更新显示 if (Gg.GetDi(0, Gg.InPut0.载具真空检测1) == 0 && Gg.GetDi(0, Gg.InPut0.载具真空检测2) == 0 && Gg.GetDi(0, Gg.InPut0.载具真空检测3) == 0 && Gg.GetDi(0, Gg.InPut0.载具真空检测4) == 0 && Gg.GetExDi(0, Gg.InPut2.撕摸升降气缸缩回) == 1 && Gg.GetExDi(0, Gg.InPut2.撕摸升降气缸伸出) == 0 //&& Gg.GetExDi(0, Gg.InPut2.复检气缸缩回) == 1 && Gg.GetExDi(0, Gg.InPut2.复检气缸伸出) == 0 && Gg.GetExDi(0, Gg.InPut2.保压升降气缸缩回) == 1 && Gg.GetExDi(0, Gg.InPut2.保压升降气缸伸出) == 0 && Gg.GetExDi(0, Gg.InPut2.除底摸平移气缸缩回) == 1 && Gg.GetExDi(0, Gg.InPut2.除底摸平移气缸伸出) == 0 && Gg.GetExDi(0, Gg.InPut2.除底膜吸嘴气缸缩回) == 1 && Gg.GetExDi(0, Gg.InPut2.除底膜吸嘴气缸伸出) == 0) { InitTimeOut = API.GetTickCount(); StepHome = 30; } if (API.GetTickCount() - InitTimeOut > 2000) { if (Gg.GetDi(0, Gg.InPut0.载具真空检测1) == 1) { AddList("1#载具真空检测1异常,请检查!"); ShowList("1#载具真空检测1异常,请检查!"); } if (Gg.GetDi(0, Gg.InPut0.载具真空检测2) == 1) { AddList("2#载具真空检测2异常,请检查!"); ShowList("2#载具真空检测2异常,请检查!"); } if (Gg.GetDi(0, Gg.InPut0.载具真空检测3) == 1) { AddList("3#载具真空检测3异常,请检查!"); ShowList("3#载具真空检测3异常,请检查!"); } if (Gg.GetDi(0, Gg.InPut0.载具真空检测4) == 1) { AddList("4#载具真空检测3异常,请检查!"); ShowList("4#载具真空检测3异常,请检查!"); } if (Gg.GetExDi(0, Gg.InPut2.撕摸升降气缸缩回) == 0 || Gg.GetExDi(0, Gg.InPut2.撕摸升降气缸伸出) == 1) { AddList("撕摸升降气缸缩回信号异常,请检查!"); ShowList("撕摸升降气缸缩回信号异常,请检查!"); } //if (Gg.GetExDi(0, Gg.InPut2.复检气缸缩回) == 0 || Gg.GetExDi(0, Gg.InPut2.复检气缸伸出) == 1) // { // AddList("复检气缸缩回信号异常,请检查!"); // ShowList("复检气缸缩回信号异常,请检查!"); // } if (Gg.GetExDi(0, Gg.InPut2.保压升降气缸缩回) == 0 || Gg.GetExDi(0, Gg.InPut2.保压升降气缸伸出) == 1) { AddList("保压升降气缸缩回信号异常,请检查!"); ShowList("保压升降气缸缩回信号异常,请检查!"); } if (Gg.GetExDi(0, Gg.InPut2.除底摸平移气缸缩回) == 0 || Gg.GetExDi(0, Gg.InPut2.除底摸平移气缸伸出) == 1) { AddList("除底摸平移气缸缩回信号异常,请检查!"); ShowList("除底摸平移气缸缩回信号异常,请检查!"); } if (Gg.GetExDi(0, Gg.InPut2.除底膜吸嘴气缸缩回) == 0 || Gg.GetExDi(0, Gg.InPut2.除底膜吸嘴气缸伸出) == 1) { AddList("除底膜吸嘴气缸缩回信号异常,请检查!"); ShowList("除底膜吸嘴气缸缩回信号异常,请检查!"); } StepHome = 1000; } break; case 30: AddList("组装Z轴开始回原点…"); AddList("保压Z轴开始回原点…"); GoHome.Instance.AxisHome[0, 3].Result = false; GoHome.Instance.AxisHome[0, 8].Result = false; GoHome.Instance.AxisHome[0, 3].Enable = true; GoHome.Instance.AxisHome[0, 8].Enable = true; GoHome.Instance.AxisHome[0, 3].Step = 10; GoHome.Instance.AxisHome[0, 8].Step = 10; InitTimeOut = API.GetTickCount(); Frm_ProgressBar.SetValueProgressBar(30); StepHome = 40; break; case 40: GotoHome(0, 3, 20, -1000, 10, 1, 10); GotoHome(0, 8, 20, -1000, 10, 1, 10); if (GoHome.Instance.AxisHome[0, 3].Step == 0 && GoHome.Instance.AxisHome[0, 3].Enable) { GoHome.Instance.AxisHome[0, 3].Enable = false; if (GoHome.Instance.AxisHome[0, 3].Result) { AddList("组装Z轴回原点成功!"); } else { AddList("组装Z轴回原点失败!"); ShowList("组装Z轴回原点失败!"); StepHome = 1000; } } if (GoHome.Instance.AxisHome[0, 8].Step == 0 && GoHome.Instance.AxisHome[0, 8].Enable) { GoHome.Instance.AxisHome[0, 8].Enable = false; if (GoHome.Instance.AxisHome[0, 8].Result) { AddList("保压Z轴回原点成功!"); } else { AddList("保压Z轴回原点失败!"); ShowList("保压Z轴回原点失败!"); StepHome = 1000; } } if (GoHome.Instance.AxisHome[0, 3].Result && GoHome.Instance.AxisHome[0, 8].Result) { Frm_ProgressBar.SetValueProgressBar(50); InitTimeOut = API.GetTickCount(); StepHome = 50; } break; case 50: AddList("组装X轴开始回原点…"); AddList("组装Y轴开始回原点…"); AddList("组装R轴开始回原点…"); GoHome.Instance.AxisHome[0, 1].Result = false; GoHome.Instance.AxisHome[0, 2].Result = false; GoHome.Instance.AxisHome[0, 4].Result = false; GoHome.Instance.AxisHome[0, 1].Enable = true; GoHome.Instance.AxisHome[0, 2].Enable = true; GoHome.Instance.AxisHome[0, 4].Enable = true; GoHome.Instance.AxisHome[0, 1].Step = 10; GoHome.Instance.AxisHome[0, 2].Step = 10; GoHome.Instance.AxisHome[0, 4].Step = 10; InitTimeOut = API.GetTickCount(); StepHome = 60; break; case 60: GotoHome(0, 1, 20, -1000, 10, 1, 10); GotoHome(0, 2, 20, -1000, 10, 1, 10); GotoHome(0, 4, 20, -1000, 10, 1, 10); if (GoHome.Instance.AxisHome[0, 1].Step == 0 && GoHome.Instance.AxisHome[0, 1].Enable) { GoHome.Instance.AxisHome[0, 1].Enable = false; if (GoHome.Instance.AxisHome[0, 1].Result) { AddList("组装X轴回原点成功!"); } else { AddList("组装X轴回原点失败!"); ShowList("组装X轴回原点失败!"); StepHome = 1000; } } if (GoHome.Instance.AxisHome[0, 2].Step == 0 && GoHome.Instance.AxisHome[0, 2].Enable) { GoHome.Instance.AxisHome[0, 2].Enable = false; if (GoHome.Instance.AxisHome[0, 2].Result) { AddList("组装Y轴回原点成功!"); } else { AddList("组装Y轴回原点失败!"); ShowList("组装Y轴回原点失败!"); StepHome = 1000; } } if (GoHome.Instance.AxisHome[0, 4].Step == 0 && GoHome.Instance.AxisHome[0, 4].Enable) { GoHome.Instance.AxisHome[0, 4].Enable = false; if (GoHome.Instance.AxisHome[0, 4].Result) { AddList("组装R轴回原点成功!"); } else { AddList("组装R轴回原点失败!"); ShowList("组装R轴回原点失败!"); StepHome = 1000; } } if (GoHome.Instance.AxisHome[0, 1].Result && GoHome.Instance.AxisHome[0, 2].Result && GoHome.Instance.AxisHome[0, 4].Result) { Frm_ProgressBar.SetValueProgressBar(70); InitTimeOut = API.GetTickCount(); StepHome = 70; } break; case 70: AddList("上料Z轴开始回原点…"); AddList("平移Y轴开始回原点…"); AddList("拉料Z轴开始回原点…"); GoHome.Instance.AxisHome[0, 5].Result = false; GoHome.Instance.AxisHome[0, 6].Result = false; GoHome.Instance.AxisHome[0, 7].Result = false; GoHome.Instance.AxisHome[0, 5].Enable = true; GoHome.Instance.AxisHome[0, 6].Enable = true; GoHome.Instance.AxisHome[0, 7].Enable = true; GoHome.Instance.AxisHome[0, 5].Step = 10; GoHome.Instance.AxisHome[0, 6].Step = 10; GoHome.Instance.AxisHome[0, 7].Step = 10; InitTimeOut = API.GetTickCount(); StepHome = 80; break; case 80: GotoHome(0, 5, 20, -1000, 10, 1, 10); GotoHome(0, 6, 20, -1000, 10, 1, 30); GotoHome(0, 7, 20, -1000, 10, 1, 10); if (GoHome.Instance.AxisHome[0, 5].Step == 0 && GoHome.Instance.AxisHome[0, 5].Enable) { GoHome.Instance.AxisHome[0, 5].Enable = false; if (GoHome.Instance.AxisHome[0, 5].Result) { AddList("上料Z轴回原点成功!"); } else { AddList("上料Z轴回原点失败!"); ShowList("上料Z轴回原点失败!"); StepHome = 1000; } } if (GoHome.Instance.AxisHome[0, 6].Step == 0 && GoHome.Instance.AxisHome[0, 6].Enable) { GoHome.Instance.AxisHome[0, 6].Enable = false; if (GoHome.Instance.AxisHome[0, 6].Result) { AddList("平移Y轴回原点成功!"); } else { AddList("平移Y轴回原点失败!"); ShowList("平移Y轴回原点失败!"); StepHome = 1000; } } if (GoHome.Instance.AxisHome[0, 7].Step == 0 && GoHome.Instance.AxisHome[0, 7].Enable) { GoHome.Instance.AxisHome[0, 7].Enable = false; if (GoHome.Instance.AxisHome[0, 7].Result) { AddList("拉料Z轴回原点成功!"); } else { AddList("拉料Z轴回原点失败!"); ShowList("拉料Z轴回原点失败!"); StepHome = 1000; } } if (GoHome.Instance.AxisHome[0, 5].Result && GoHome.Instance.AxisHome[0, 6].Result && GoHome.Instance.AxisHome[0, 7].Result) { Frm_ProgressBar.SetValueProgressBar(80); InitTimeOut = API.GetTickCount(); StepHome = 90; } break; case 90: AddList("转盘R轴开始回原点…"); GoHome.Instance.AxisHome[1, 2].Result = false; GoHome.Instance.AxisHome[1, 1].Enable = true; GoHome.Instance.AxisHome[1, 1].Step = 10; InitTimeOut = API.GetTickCount(); StepHome = 100; break; case 100: GotoHome(1, 1, 30, -360, 5, mFunction.Pos.TeachAxis1[2, 0], 30); if (GoHome.Instance.AxisHome[1, 1].Step == 0 && GoHome.Instance.AxisHome[1, 1].Enable) { GoHome.Instance.AxisHome[1, 1].Enable = false; if (GoHome.Instance.AxisHome[1, 1].Result) { AddList("转盘R轴回原点成功!"); } else { AddList("转盘R轴回原点失败!"); ShowList("转盘R轴回原点失败!"); StepHome = 1000; } } if (GoHome.Instance.AxisHome[1, 1].Result) { Frm_ProgressBar.SetValueProgressBar(90); InitTimeOut = API.GetTickCount(); StepHome = 150; } break; case 150: AddList("各轴开始回待机位置…"); //组装站 Gg.AbsMotion(0, 1, mFunction.Pos.TeachAxis1[0, 0], 20); Gg.AbsMotion(0, 2, mFunction.Pos.TeachAxis2[0, 0], 20); Gg.AbsMotion(0, 3, mFunction.Pos.TeachAxis3[0, 0], 20); Gg.AbsMotion(0, 4, mFunction.Pos.TeachAxis4[0, 0], 20); //保压站 Gg.AbsMotion(0, 8, mFunction.Pos.TeachAxis1[1, 0], 20); //保压初始位置 Tools.AxisTmplPos[1, 1] = 0; //供料 Gg.AbsMotion(0, 5, mFunction.Pos.TeachAxis2[3, 4], 50); //供料起始位置 Gg.AbsMotion(0, 6, mFunction.Pos.TeachAxis1[3, 6], 100); //避让位置 Gg.AbsMotion(0, 7, mFunction.Pos.TeachAxis3[3, 7], 50); //换料位置 InitTimeOut = API.GetTickCount(); StepHome = 160; break; case 160: if (Gg.ZSPD(0, 1) && Gg.ZSPD(0, 2) && Gg.ZSPD(0, 3) && Gg.ZSPD(0, 4) && Gg.ZSPD(0, 5) && Gg.ZSPD(0, 6) && Gg.ZSPD(0, 7) && Gg.ZSPD(0, 8) && Gg.ZSPD(1, 1)) { AddList("各轴回待机位置完成!"); InitTimeOut = API.GetTickCount(); StepHome = 170; } else { if ((API.GetTickCount() - InitTimeOut) > 10000) { if (Gg.ZSPD(0, 1) == false) { AddList("组装X轴回待机位置失败!"); ShowList("组装X轴回待机位置失败!"); } if (Gg.ZSPD(0, 2) == false) { AddList("组装Y轴回待机位置失败!"); ShowList("组装Y轴回待机位置失败!"); } if (Gg.ZSPD(0, 3) == false) { AddList("组装Z轴回待机位置失败!"); ShowList("组装Z轴回待机位置失败!"); } if (Gg.ZSPD(0, 4) == false) { AddList("组装R轴回待机位置失败!"); ShowList("组装R轴回待机位置失败!"); } if (Gg.ZSPD(0, 5) == false) { AddList("上料Z轴回待机位置失败!"); ShowList("上料Z轴回待机位置失败!"); } if (Gg.ZSPD(0, 6) == false) { AddList("平移Y轴回待机位置失败!"); ShowList("平移Y轴回待机位置失败!"); } if (Gg.ZSPD(0, 7) == false) { AddList("拉料Z轴回待机位置失败!"); ShowList("拉料Z轴回待机位置失败!"); } if (Gg.ZSPD(0, 8) == false) { AddList("保压Z轴回待机位置失败!"); ShowList("保压Z轴回待机位置失败!"); } if (Gg.ZSPD(1, 1) == false) { AddList("转盘R轴回待机位置失败!"); ShowList("转盘R轴回待机位置失败!"); } StepHome = 1000; } } break; case 170: if (API.GetTickCount() - InitTimeOut > 500) { //gts.GT_SetPrfPos(1, 1, 0); //规划器置零 //gts.GT_SetEncPos(1, 1, 0); //编码器置零 //gts.GT_SynchAxisPos(1, 1 << 0); //将当前轴进行位置同步 InitTimeOut = API.GetTickCount(); 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_Engineering.fEngineering.Btn_SelectMaterial.Enabled = true; //按钮初始化 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 <= 4; 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.Instance.Reset.State = false; GoHome.Instance.Reset.Result = true; StepHome = 0; break; case 1000: PVar.LampStatus = 10; PVar.MacHold = false; PVar.Stop_Flag = true; Frm_Engineering.fEngineering.Btn_SelectMaterial.Enabled = false; //按钮初始化 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; Frm_Engineering.fEngineering.Home_Timer.Enabled = false; Frm_ProgressBar.IsShowProgresBar(false); //初始化进度条显示 GoHome.Instance.Reset.Result = false; GoHome.Instance.Reset.State = false; StepHome = 0; break; } }
/// <summary> /// 自动运行 /// </summary> private void AutoRun() { #region Switch switch (AutoRunstep) { case 10: SetStep("CLEAR", Mycolor.None); TaskIsWorking = true; EventShowResult(EnumShowResult.Empty); SetStep("测试工站开始...", Mycolor.None); AutoRunstep = 20; break; #region run to test postion case 20: //运动到测试位置 Gg.AbsMotion(0, BVar.MMSY, mFunction.Pos.TeachAxis1[0, 2], PVar.ParAxis.Speed[BVar.MMSY]); TimeOut = API.GetTickCount(); SetStep("测试Y轴运动到测试点开始", Mycolor.None); AutoRunstep = 30; break; case 30: if (Gg.ZSPD(0, BVar.MMSY)) { SetStep("测试Y轴运动到达测试位置", Mycolor.None); TimeOut = API.GetTickCount(); AutoRunstep = (Globals.settingMachineInfo.什么机器 == WhichMachine.IPDM) ? 70 : 40; } break; case 40: Gg.SetDo(0, Gg.OutPutMMS0.产品定位气缸电磁阀, 1); SetStep("定位气缸打开", Mycolor.None); TimeOut = API.GetTickCount(); AutoRunstep = 50; break; case 50: if (Gg.GetDi(0, Gg.InPutMMS0.气缸到位感应器) == 1) { SetStep("定位气缸到定位位置", Mycolor.None); TimeOut = API.GetTickCount(); AutoRunstep = 60; } else if (API.GetTickCount() - TimeOut > 2000) { SetStep("定位气缸缩到定位位置信号异常!", Mycolor.ErrorRed); PostTaskAlarm(XAlarmLevel.STOP, (int)AlarmCode.载具进出气缸伸出信号异常, AlarmCategory.MOTION.ToString(), "载具进出气缸伸出信号异常"); AutoRunstep = 8000; } break; case 60: if (API.GetTickCount() - TimeOut > 300) { SetStep("延时300ms", Mycolor.None); AutoRunstep = 70; } break; #endregion #region start test & collect data case 70: //if (Globals.settingFunc.打开SSH通信 && Globals.SSHconnSt)//SSH打开,且SSH连接成功! { //SSH.Instance.ExecuteCommand("/Users/gdlocal/Desktop/MMS/" + Globals.settingPara.SSH脚本名字);//运行mini脚本 SetStep("Send SSH command-start to move Motor!", Mycolor.None); DAQ.Instance.PCI9222StartCollect(); //开始收集高度数据 SetStep("测试开始,开始收集数据", Mycolor.None); TimeOut = API.GetTickCount(); AutoRunstep = 80; } //else //{ // SetStep("SSH功能没打开,或SSH连接失败!", Mycolor.ErrorRed); // SetStep("请确定SSH,退出测试!", Mycolor.ErrorRed); // TimeOut = API.GetTickCount(); // AutoRunstep = 290; //} break; case 80: //if (API.GetTickCount() - TimeOut > Globals.settingPara.测试超时) if (API.GetTickCount() - TimeOut > 2000) { SetStep("测试超时,退出测试!", Mycolor.ErrorRed); TimeOut = API.GetTickCount(); DAQ.Instance.PCI9222StopCollect(); AutoRunstep = 90; } //if (Globals.SSHstring.Contains("Motor Run Complete"))//SSH feedback string //{ // SetStep("收到SSH的Motor Run Complete,测试结束!", Mycolor.None); // DAQ.Instance.PCI9222Clear();//stop collect the 9222 data // TimeOut = API.GetTickCount(); // AutoRunstep = 90; //} break; case 90: //save the raw data ls.Clear(); string[] stringheader = new string[] { "Time", "laer_p0", "laer_p1", "laer_p2", "laer_p3", "laer_p4" }; ls.Add(stringheader); for (int i = 0; i < DAQ.Instance.listArray[0].Count - 2; i++) //最后两组数据不要 { string[] strarr = new string[6]; strarr[0] = DAQ.Instance.listArray[0][i].X.ToString(); //time strarr[1] = DAQ.Instance.listArray[0][i].Y.ToString(); //laser_p0 strarr[2] = DAQ.Instance.listArray[1][i].Y.ToString(); //laser_p1 strarr[3] = DAQ.Instance.listArray[2][i].Y.ToString(); //laser_p2 strarr[4] = DAQ.Instance.listArray[3][i].Y.ToString(); //laser_p3 strarr[5] = DAQ.Instance.listArray[4][i].Y.ToString(); //laser_p4 ls.Add(strarr); } string path = PVar.BZ_DataPath + "MMS Data-" + Globals.settingMachineInfo.机器编号 + "\\RAW Displacement Data\\" + DateTime.Now.ToString("yyyyMMdd") + "\\"; if (System.IO.Directory.Exists(path) == false) { System.IO.Directory.CreateDirectory(path); } Globals.csv.WriteCSV(path + DataManager.Instance.CurrentCheckData.SN + "_" + DateTime.Now.ToString("HH_mm_ss_fff") + "_raw.csv", ls); ls.Clear(); AutoRunstep = 100; break; case 100: AutoRunstep = 110; break; case 110: AutoRunstep = 120; break; case 120: AutoRunstep = 200; break; case 200: AutoRunstep = 210; break; case 210: SetStep("显示测试数据", Mycolor.None); #region 产生数据 1tray // "装配时间", "产品条码", "Result", "X", "Y", "A", "Dis" DataManager.Instance.CurrentCheckData.StartDate = DateTime.Now.ToString("yyyy-MM-dd"); DataManager.Instance.CurrentCheckData.StartTime = DateTime.Now.ToString("HH:mm:ss"); Random rd = new Random(); double m_A = DataManager.Instance.CurrentCheckData.Mod_Brc_A = rd.Next(-1, 1) / 10.0 + rd.Next(-1, 1) / 100.00; double m_cc = DataManager.Instance.CurrentCheckData.Mod_Brc_CC = 22 + rd.Next(-1, 1) / 100.0 + rd.Next(0, 1) / 1000.00; double m_x = DataManager.Instance.CurrentCheckData.Mod_Brc_X = rd.Next(-1, 1) / 100.0 + rd.Next(-1, 1) / 1000.00; double m_y = DataManager.Instance.CurrentCheckData.Mod_Brc_Y = rd.Next(-1, 1) / 100.0 + rd.Next(-1, 1) / 1000.00; if (tempi % 2 == 1) { DataManager.Instance.CurrentCheckData.PASS = true; DataManager.Instance.CurrentCheckData.PDCAPASS = true; SetStep("the result is Passed", Color.LimeGreen); EventShowResult(EnumShowResult.OK); DataManager.Instance.currentyield.AddOneResult(true); //update the current yield and month yield } else { DataManager.Instance.CurrentCheckData.PASS = false; DataManager.Instance.CurrentCheckData.PDCAPASS = false; SetStep("the result is Failed", Color.Red); EventShowResult(EnumShowResult.NG); DataManager.Instance.currentyield.AddOneResult(false); //update the current yield and month yield } DataManager.Instance.chartData.Adddata(m_A.ToString() + "," + m_x.ToString() + "," + m_y.ToString() + "," + m_cc.ToString()); //AddData为更新生产的CPK数据 AddNewData为UPH数据,包括很多东西 DataManager.Instance.uph.UPHupdate(); //UPH update by hour if (OnCurrentInf != null) { OnCurrentInf(DataManager.Instance.CurrentCheckData); //给工程界面的数据显示 } if (OnFlashDataPage != null) { OnFlashDataPage(); } tempi++; #endregion AutoRunstep = 220; break; case 220: //PDCA DataManager.Instance.CurrentCheckData.Operator_ID = "0"; DataManager.Instance.CurrentCheckData.Mode = "0"; DataManager.Instance.CurrentCheckData.TestSeriesID = "'201805070859"; DataManager.Instance.CurrentCheckData.Prioriyt = "0"; PDCA_data[0] = DataManager.Instance.CurrentCheckData.Mod_Brc_X.ToString(); PDCA_data[1] = DataManager.Instance.CurrentCheckData.Mod_Brc_Y.ToString(); PDCA_data[2] = DataManager.Instance.CurrentCheckData.Mod_Brc_A.ToString(); PDCA_data[3] = DataManager.Instance.CurrentCheckData.Mod_Brc_CC.ToString(); PDCA_data[4] = DataManager.Instance.CurrentCheckData.Operator_ID.ToString(); PDCA_data[5] = DataManager.Instance.CurrentCheckData.Mode.ToString(); PDCA_data[6] = DataManager.Instance.CurrentCheckData.TestSeriesID.ToString(); PDCA_data[7] = DataManager.Instance.CurrentCheckData.Prioriyt.ToString(); PDCA_Step = 10; AutoRunstep = 240; break; case 230: //PDCA if (PDCA_Bali(PDCA_data) == FunctionStatus.Finish) { DataManager.Instance.CurrentCheckData.PDCAPASS = true; AutoRunstep = 240; } else if (PDCA_Bali(PDCA_data) == FunctionStatus.Error) { DataManager.Instance.CurrentCheckData.PDCAPASS = false; AutoRunstep = 240; } break; case 240: #region 从测试数据中取值,保留生产数据 path = PVar.BZ_DataPath + "MMS Data-" + Globals.settingMachineInfo.机器编号 + "\\PDCA Data\\" + DateTime.Now.ToString("yyyyMM") + "\\"; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Clear(); stringBuilder.Append("" + ","); stringBuilder.Append(DataManager.Instance.CurrentCheckData.StartDate + ","); stringBuilder.Append(DataManager.Instance.CurrentCheckData.StartTime + ","); stringBuilder.Append(DataManager.Instance.CurrentCheckData.SN + ","); stringBuilder.Append(DataManager.Instance.CurrentCheckData.PASS + ","); stringBuilder.Append(DataManager.Instance.CurrentCheckData.PDCAPASS + ","); stringBuilder.Append(DataManager.Instance.CurrentCheckData.Mod_Brc_X + ","); stringBuilder.Append(DataManager.Instance.CurrentCheckData.Mod_Brc_Y + ","); stringBuilder.Append(DataManager.Instance.CurrentCheckData.Mod_Brc_A + ","); stringBuilder.Append(DataManager.Instance.CurrentCheckData.Mod_Brc_CC + ","); stringBuilder.Append(DataManager.Instance.CurrentCheckData.Operator_ID + ","); stringBuilder.Append(DataManager.Instance.CurrentCheckData.Mode + ","); stringBuilder.Append(DataManager.Instance.CurrentCheckData.TestSeriesID + ","); stringBuilder.Append(DataManager.Instance.CurrentCheckData.Prioriyt + ","); string pathtemp = path + DateTime.Now.ToString("yyyyMMdd") + "_PDCA_Data.csv"; #region save the csv header if (File.Exists(pathtemp) == false) { StringBuilder stringBuilderHeader = new StringBuilder(); stringBuilderHeader.Clear(); stringBuilderHeader.Append(" ,StartDate,StartTime,SN,Result,PDCA_Result,X,Y,A,CC,Operator_ID,Mode,TestSeriesID,Prioriyt,\t\n"); stringBuilderHeader.Append("Upper Limit,NA,NA,NA,NA,NA,1,2,3,4,\t\n"); stringBuilderHeader.Append("Lower Limit,NA,NA,NA,NA,NA,-1,-2,-3,-4,\t\n"); stringBuilderHeader.Append("Units,NA,NA,NA,NA,NA,mm,mm,mm,mm,"); CsvServer.Instance.WriteLine(pathtemp, stringBuilderHeader.ToString()); stringBuilderHeader.Clear(); } #endregion CsvServer.Instance.WriteLine(pathtemp, stringBuilder.ToString()); stringBuilder.Clear(); #endregion AutoRunstep = 290; break; case 290: DAQ.Instance.PCI9222StopCollect(); AutoRunstep = 300; break; #endregion #region back to wait postion case 300: Gg.SetDo(0, Gg.OutPutMMS0.产品定位气缸电磁阀, 0); SetStep("定位气缸复位......", Mycolor.None); TimeOut = API.GetTickCount(); AutoRunstep = (Globals.settingMachineInfo.什么机器 == WhichMachine.IPDM) ? 320 : 310; break; case 310: if (Gg.GetDi(0, Gg.InPutMMS0.气缸缩回位置感应器) == 1) { SetStep("定位气缸在缩回位置", Mycolor.None); AutoRunstep = 320; } else if (API.GetTickCount() - TimeOut > 2000) { SetStep("定位气缸缩回位置信号异常!", Mycolor.ErrorRed); PostTaskAlarm(XAlarmLevel.STOP, (int)AlarmCode.载具进出气缸缩回信号异常, AlarmCategory.MOTION.ToString(), "载具进出气缸缩回信号异常"); AutoRunstep = 8000; } break; case 320: //等待位置 Gg.AbsMotion(0, BVar.MMSY, mFunction.Pos.TeachAxis1[0, 0], PVar.ParAxis.Speed[BVar.MMSY]); TimeOut = API.GetTickCount(); AutoRunstep = 330; break; case 330: if (Gg.ZSPD(0, BVar.MMSY)) { SetStep("测试y轴运动到初始位置成功…", Mycolor.None); TimeOut = API.GetTickCount(); AutoRunstep = 2000; } break; #endregion case 2000: StaStop = false; StopWatch_Stop(); //stop the CT count AutoRunstep = 0; TaskIsWorking = false; SetStep("SAVE", Mycolor.None); PostTaskAlarm(XAlarmLevel.RST, (int)AlarmCode.位, AlarmCategory.RESET.ToString(), "RST"); //for errorcode break; case 8000: DAQ.Instance.PCI9222Clear(); SetStep("此步为异常,退出循环", Mycolor.None); AutoRunstep = 0; StopWatch_Stop(); //stop the CT count TaskIsWorking = false; SetStep("SAVE", Mycolor.None); return; } SetStepNum(AutoRunstep); Task_StopWatchElapsedMilliseconds();//获取CT #endregion }
/// <summary> /// 空跑 /// </summary> private void DryRun() { #region Switch switch (AutoRunstep) { case 10: SetStep("CLEAR", Mycolor.None); TaskIsWorking = true; EventShowResult(EnumShowResult.Empty); SetStep("AutoRun Setp10", Mycolor.None); AutoRunstep = 20; break; case 20: SetStep("AutoRun Setp20", Mycolor.None); AutoRunstep = 30; break; case 30: Thread.Sleep(1); SetStep("AutoRun Setp30", Mycolor.None); AutoRunstep = 40; break; case 40: Thread.Sleep(10); SetStep("AutoRun Setp40", Mycolor.None); AutoRunstep = 50; break; case 50: //等待位置 Gg.AbsMotion(0, BVar.MMSY, mFunction.Pos.TeachAxis1[0, 0], PVar.ParAxis.Speed[BVar.MMSY]); TimeOut = API.GetTickCount(); AutoRunstep = 60; break; case 60: if (Gg.ZSPD(0, BVar.MMSY)) { SetStep("测试y轴运动到初始位置成功…", Mycolor.None); TimeOut = API.GetTickCount(); AutoRunstep = 70; } break; case 70: if (API.GetTickCount() - TimeOut > 300) { AutoRunstep = 80; } break; case 80: //测试位置 Gg.AbsMotion(0, BVar.MMSY, mFunction.Pos.TeachAxis1[0, 2], PVar.ParAxis.Speed[BVar.MMSY]); TimeOut = API.GetTickCount(); AutoRunstep = 90; break; case 90: if (Gg.ZSPD(0, BVar.MMSY)) { SetStep("测试y轴运动到测试位置成功…", Mycolor.None); TimeOut = API.GetTickCount(); AutoRunstep = 100; } break; case 100: if (API.GetTickCount() - TimeOut > 300) { AutoRunstep = 110; } break; case 110: Gg.SetDo(0, Gg.OutPutMMS0.产品定位气缸电磁阀, 1); SetStep("定位气缸打开......", Mycolor.None); TimeOut = API.GetTickCount(); AutoRunstep = 120; break; case 120: if (Gg.GetDi(0, Gg.InPutMMS0.气缸到位感应器) == 1) { SetStep("定位气缸到定位位置", Mycolor.None); AutoRunstep = 150; } else if (API.GetTickCount() - TimeOut > 2000) { SetStep("定位气缸缩到定位位置信号异常!", Mycolor.ErrorRed); PostTaskAlarm(XAlarmLevel.STOP, (int)AlarmCode.载具进出气缸伸出信号异常, AlarmCategory.MOTION.ToString(), "载具进出气缸伸出信号异常"); AutoRunstep = 8000; } break; case 150: SetStep("测试开始.....", Mycolor.None); Thread.Sleep(2000); AutoRunstep = 180; break; case 180: Gg.SetDo(0, Gg.OutPutMMS0.产品定位气缸电磁阀, 0); SetStep("定位气缸复位......", Mycolor.None); TimeOut = API.GetTickCount(); AutoRunstep = 190; break; case 190: if (Gg.GetDi(0, Gg.InPutMMS0.气缸缩回位置感应器) == 1) { SetStep("定位气缸在缩回位置", Mycolor.None); AutoRunstep = 200; } else if (API.GetTickCount() - TimeOut > 2000) { SetStep("定位气缸缩回位置信号异常!", Mycolor.ErrorRed); PostTaskAlarm(XAlarmLevel.STOP, (int)AlarmCode.载具进出气缸缩回信号异常, AlarmCategory.MOTION.ToString(), "载具进出气缸缩回信号异常"); AutoRunstep = 8000; } break; case 200: uint pck; uint pck2; gts.GT_GetClockHighPrecision(0, out pck); Thread.Sleep(5); gts.GT_GetClockHighPrecision(0, out pck2); uint ctt = pck2 - pck; SetStep("AutoRun Setp60", Mycolor.None); AutoRunstep = 210; break; case 210: Thread.Sleep(1000); SetStep("AutoRun Setp70", Mycolor.None); #region 产生数据 1tray // "装配时间", "产品条码", "Result", "X", "Y", "A", "Dis" DataManager.Instance.CurrentCheckData.SN = "SNXXXXXXX"; DataManager.Instance.CurrentCheckData.StartDate = DateTime.Now.ToString("yyyy-MM-dd"); DataManager.Instance.CurrentCheckData.StartTime = DateTime.Now.ToString("HH:mm:ss"); Random rd = new Random(); if (Globals.settingMachineInfo.什么机器 == WhichMachine.IPDM) { double left1 = DataManager.Instance.CurrentCheckData.IPD_Left1 = rd.Next(-1, 1) / 10.0 + rd.Next(-1, 1) / 100.00; double left2 = DataManager.Instance.CurrentCheckData.IPD_Right1 = 22 + rd.Next(-1, 1) / 100.0 + rd.Next(0, 1) / 1000.00; double Right1 = DataManager.Instance.CurrentCheckData.Mod_Brc_X = rd.Next(-1, 1) / 100.0 + rd.Next(-1, 1) / 1000.00; double Right2 = DataManager.Instance.CurrentCheckData.Mod_Brc_Y = rd.Next(-1, 1) / 100.0 + rd.Next(-1, 1) / 1000.00; DataManager.Instance.chartData.Adddata(left1.ToString() + "," + Right1.ToString() + "," + left2.ToString() + "," + Right2.ToString()); //AddData为更新生产的CPK数据 AddNewData为UPH数据,包括很多东西 } else { double m_A = DataManager.Instance.CurrentCheckData.Mod_Brc_A = rd.Next(-1, 1) / 10.0 + rd.Next(-1, 1) / 100.00; double m_cc = DataManager.Instance.CurrentCheckData.Mod_Brc_CC = 22 + rd.Next(-1, 1) / 100.0 + rd.Next(0, 1) / 1000.00; double m_x = DataManager.Instance.CurrentCheckData.Mod_Brc_X = rd.Next(-1, 1) / 100.0 + rd.Next(-1, 1) / 1000.00; double m_y = DataManager.Instance.CurrentCheckData.Mod_Brc_Y = rd.Next(-1, 1) / 100.0 + rd.Next(-1, 1) / 1000.00; DataManager.Instance.chartData.Adddata(m_A.ToString() + "," + m_x.ToString() + "," + m_y.ToString() + "," + m_cc.ToString()); //AddData为更新生产的CPK数据 AddNewData为UPH数据,包括很多东西 } if (tempi % 2 == 1) { DataManager.Instance.CurrentCheckData.PASS = true; DataManager.Instance.CurrentCheckData.PDCAPASS = true; SetStep("the result is Passed", Color.LimeGreen); EventShowResult(EnumShowResult.OK); DataManager.Instance.currentyield.AddOneResult(true); //update the current yield and month yield } else { DataManager.Instance.CurrentCheckData.PASS = false; DataManager.Instance.CurrentCheckData.PDCAPASS = false; SetStep("the result is Failed", Color.Red); EventShowResult(EnumShowResult.NG); DataManager.Instance.currentyield.AddOneResult(false); //update the current yield and month yield } DataManager.Instance.uph.UPHupdate(); //UPH update by hour if (OnCurrentInf != null) { OnCurrentInf(DataManager.Instance.CurrentCheckData); //给工程界面的数据显示 } if (OnFlashDataPage != null) { OnFlashDataPage(); } tempi++; #endregion AutoRunstep = 220; break; case 220: //等待位置 Gg.AbsMotion(0, BVar.MMSY, mFunction.Pos.TeachAxis1[0, 0], PVar.ParAxis.Speed[BVar.MMSY]); TimeOut = API.GetTickCount(); AutoRunstep = 230; break; case 230: if (Gg.ZSPD(0, BVar.MMSY)) { SetStep("测试y轴运动到初始位置成功…", Mycolor.None); TimeOut = API.GetTickCount(); AutoRunstep = 2000; } break; case 2000: Thread.Sleep(100); SetStep("AutoRun Setp80", Mycolor.None); StaStop = false; StopWatch_Stop(); //stop the CT count AutoRunstep = 0; TaskIsWorking = false; SetStep("SAVE", Mycolor.None); PostTaskAlarm(XAlarmLevel.RST, (int)AlarmCode.位, AlarmCategory.RESET.ToString(), "RST"); //for errorcode break; case 8000: Thread.Sleep(1); SetStep("AutoRun Setp8000", Mycolor.None); AutoRunstep = 0; StopWatch_Stop(); //stop the CT count TaskIsWorking = false; return; } SetStepNum(AutoRunstep); Task_StopWatchElapsedMilliseconds();//获取CT #endregion }
private FunctionStatus InitHoming() { switch (InitHomingStep) { case 10: AutoRunstep = 0; Gg.Set_Servo(0, BVar.MMSY, true); //open servo on Thread.Sleep(200); SetStep("开始回零.......", Mycolor.None); InitHomingStep = 15; break; case 15: Gg.SetDo(0, Gg.OutPutMMS0.产品定位气缸电磁阀, 0); SetStep("定位气缸复位......", Mycolor.None); InitHomingDelay.InitialTime(); InitHomingStep = 20; break; case 20: if (Gg.GetDi(0, Gg.InPutMMS0.气缸缩回位置感应器) == 1) { SetStep("定位气缸在缩回位置", Mycolor.None); InitHomingStep = 30; } else if (InitHomingDelay.TimeIsUp(2000)) { SetStep("定位气缸缩回位置信号异常!", Mycolor.ErrorRed); PostTaskAlarm(XAlarmLevel.STOP, (int)AlarmCode.载具进出气缸缩回信号异常, AlarmCategory.MOTION.ToString(), "载具进出气缸缩回信号异常"); InitHomingStep = 8000; } break; case 30: SetStep("测试y轴开始回原点…", Mycolor.None); GoHome.Instance.AxisHome[0, 1].Result = false; GoHome.Instance.AxisHome[0, 1].Enable = true; GoHome.Instance.AxisHome[0, 1].Step = 10; TimeOut = API.GetTickCount(); InitHomingStep = 40; break; case 40: GoHome.GotoHome(0, 1, 30, -1000, 5, 1, 10); if (GoHome.Instance.AxisHome[0, 1].Step == 0 && GoHome.Instance.AxisHome[0, 1].Enable) { GoHome.Instance.AxisHome[0, 1].Enable = false; if (GoHome.Instance.AxisHome[0, 1].Result) { SetStep("测试y轴回原点成功…", Mycolor.None); InitHomingStep = 50; } else { SetStep("测试y轴回原点失败…", Mycolor.ErrorRed); InitHomingStep = 8000; } } break; case 50: //等待位置 Gg.AbsMotion(0, BVar.MMSY, mFunction.Pos.TeachAxis1[0, 0], PVar.ParAxis.Speed[BVar.MMSY]); TimeOut = API.GetTickCount(); InitHomingStep = 60; break; case 60: if (Gg.ZSPD(0, BVar.MMSY)) { SetStep("测试y轴运动到初始位置成功…", Mycolor.None); InitHomingStep = 2000; } break; case 2000: InitHomingStep = 0; SetStep("MMS测试工站复位OK!", Mycolor.None); SetState(XTaskState.WAITRUN); SetStepNum(InitHomingStep); HomeOK = true; PVar.LampStatus = 20; PostTaskAlarm(XAlarmLevel.RST, (int)AlarmCode.位, AlarmCategory.RESET.ToString(), "RST"); //for errorcode return(FunctionStatus.Finish); case 8000: InitHomingStep = 0; PVar.LampStatus = 10; return(FunctionStatus.Error); } SetStepNum(InitHomingStep); return(FunctionStatus.Working); }
public static void S2_MotionPos1(ref bool Status, int m, int n) { if (n == 1 || (n == 2 && Frm_Engineering.fEngineering.CheckBox_NeedCCD.Checked == false)) { switch (Manual_Step[m, n]) { //Z轴原点位置=>X/Y/R轴初始位置=>Z轴初始位置 case 0: Status = true; Manual_Step[m, n] = Manual_Step[m, n] + 1; break; case 1: Gg.AbsMotion(0, BVar.S2_Z, 0, PVar.ParAxis.Speed[BVar.S2_Z]); Manual_Step[m, n] = Manual_Step[m, n] + 1; break; case 2: if (Gg.ZSPD(0, BVar.S2_Z)) { Manual_Step[m, n] = Manual_Step[m, n] + 1; } break; case 3: disrow = BVar.DisRow * ((PVar.Blogo.MaterialCnt - 1) % 2); //判断所在行 discell = BVar.DisCell * ((PVar.Blogo.MaterialCnt - 1) / 2); //判断所在列 Gg.AbsMotion(0, BVar.S2L_Z, mFunction.Pos.TeachAxis3[3, 3] - discell, PVar.ParAxis.Speed[BVar.S2L_Z]); Gg.AbsMotion(0, BVar.S2_X, mFunction.Pos.TeachAxis1[m, n], PVar.ParAxis.Speed[BVar.S2_X]); Gg.AbsMotion(0, BVar.S2_Y, mFunction.Pos.TeachAxis2[m, n] + disrow, PVar.ParAxis.Speed[BVar.S2_Y]); Gg.AbsMotion(0, BVar.S2_R, mFunction.Pos.TeachAxis4[m, n], PVar.ParAxis.Speed[BVar.S2_R]); Manual_Step[m, n] = Manual_Step[m, n] + 1; break; case 4: if (Gg.ZSPD(0, BVar.S2L_Z) && Gg.ZSPD(0, BVar.S2_X) && Gg.ZSPD(0, BVar.S2_Y) && Gg.ZSPD(0, BVar.S2_Z) && Gg.ZSPD(0, BVar.S2_R)) { Manual_Step[m, n] = Manual_Step[m, n] + 1; } break; case 5: Gg.AbsMotion(0, BVar.S2_Z, mFunction.Pos.TeachAxis3[m, n], PVar.ParAxis.Speed[BVar.S2_Z]); Manual_Step[m, n] = Manual_Step[m, n] + 1; break; case 6: if (Gg.ZSPD(0, BVar.S2_Z)) { Manual_Step[m, n] = Manual_Step[m, n] + 1; } break; case 7: Manual_Step[m, n] = 1000; break; case 1000: Manual_Step[m, n] = 0; Status = false; break; } } else if (n == 2 && Frm_Engineering.fEngineering.CheckBox_NeedCCD.Checked)//取料位置:先CCD拍照后取料 { int sRtn; switch (Manual_Step[m, n]) { //Z轴原点位置=>X/Y/R轴初始位置=>Z轴初始位置 case 0: Status = true; Manual_Step[m, n] = Manual_Step[m, n] + 1; break; case 1: Gg.AbsMotion(0, BVar.S2_Z, 0, PVar.ParAxis.Speed[BVar.S2_Z]); Manual_Step[m, n] = Manual_Step[m, n] + 1; break; case 2: if (Gg.ZSPD(0, BVar.S2_Z)) { Manual_Step[m, n] = Manual_Step[m, n] + 1; } break; case 3: disrow = BVar.DisRow * ((PVar.Blogo.MaterialCnt - 1) % 2); //判断所在行 discell = BVar.DisCell * ((PVar.Blogo.MaterialCnt - 1) / 2); //判断所在列 Gg.AbsMotion(0, BVar.S2L_Z, mFunction.Pos.TeachAxis3[3, 3] - discell, PVar.ParAxis.Speed[BVar.S2L_Z]); //拍照位置 Gg.AbsMotion(0, BVar.S2_X, mFunction.Pos.TeachAxis1[m, n - 1], PVar.ParAxis.Speed[BVar.S2_X]); Gg.AbsMotion(0, BVar.S2_Y, mFunction.Pos.TeachAxis2[m, n - 1] + disrow, PVar.ParAxis.Speed[BVar.S2_Y]); Gg.AbsMotion(0, BVar.S2_R, mFunction.Pos.TeachAxis4[m, n - 1], PVar.ParAxis.Speed[BVar.S2_R]); Manual_Step[m, n] = Manual_Step[m, n] + 1; break; case 4: if (Gg.ZSPD(0, BVar.S2L_Z) && Gg.ZSPD(0, BVar.S2_X) && Gg.ZSPD(0, BVar.S2_Y) && Gg.ZSPD(0, BVar.S2_Z) && Gg.ZSPD(0, BVar.S2_R)) { Manual_Step[m, n] = Manual_Step[m, n] + 1; } break; case 5: Gg.AbsMotion(0, BVar.S2_Z, mFunction.Pos.TeachAxis3[m, n - 1], PVar.ParAxis.Speed[BVar.S2_Z]); Manual_Step[m, n] = Manual_Step[m, n] + 1; break; case 6: if (Gg.ZSPD(0, BVar.S2_Z)) { TimeOut = API.GetTickCount(); Manual_Step[m, n] = Manual_Step[m, n] + 1; } break; case 7: if (API.GetTickCount() - TimeOut > 200) { TimeOut = API.GetTickCount(); Manual_Step[m, n] = Manual_Step[m, n] + 1; } break; case 8: sRtn = Command.TCP_CCD1_Send(Command.取料拍照 + "," + PVar.ParList.Data[7]); if (sRtn == 1) //命令发送成功 { TimeOut = API.GetTickCount(); Manual_Step[m, n] = Manual_Step[m, n] + 1; } else if (sRtn == 2) //网络链接异常 { TimeOut = API.GetTickCount(); Manual_Step[m, n] = 1000; } else { ShowList("取料拍照命令发送失败!"); TimeOut = API.GetTickCount(); Manual_Step[m, n] = 1000; } break; case 9: if (Command.CCD1_Resule && PVar.CCD1_Data[0] == Command.取料拍照) { CCD_Vale.X = Convert.ToDouble(PVar.CCD1_Data[1]); CCD_Vale.Y = Convert.ToDouble(PVar.CCD1_Data[2]); CCD_Vale.T = Convert.ToDouble(PVar.CCD1_Data[3]); CCD_Vale.Judge = Convert.ToDouble(PVar.CCD1_Data[4]); TimeOut = API.GetTickCount(); Manual_Step[m, n] = Manual_Step[m, n] + 1; } else { if (API.GetTickCount() - TimeOut > 2000) { ShowList("等待取料拍照数据超时!"); TimeOut = API.GetTickCount(); Manual_Step[m, n] = 1000; } } Manual_Step[m, n] = 1000; break; case 10: if (CCD_Vale.Judge == 0) { if (CCD_Vale.X > -5 && CCD_Vale.X < 1.5 && Math.Abs(CCD_Vale.Y) < 1.5 && Math.Abs(CCD_Vale.T) < 5) { double tmpX; double tmpY; double mT; double mPI = 3.1415926535897931; double L_Arm = PVar.ParList.Data[9]; Offset.T = CCD_Vale.T + PVar.ParList.Data[7];; mT = Offset.T * mPI / 180; tmpX = -L_Arm * (1 - System.Math.Cos(mT)); tmpY = -L_Arm *System.Math.Sin(mT); Offset.X = CCD_Vale.X + tmpX + PVar.ParList.Data[5]; Offset.Y = CCD_Vale.Y + tmpY + PVar.ParList.Data[6]; TimeOut = API.GetTickCount(); Manual_Step[m, n] = Manual_Step[m, n] + 1; } else { ShowList("物料偏移值过大!"); TimeOut = API.GetTickCount(); Manual_Step[m, n] = 1000; } } else { ShowList("模型搜索错误!"); TimeOut = API.GetTickCount(); Manual_Step[m, n] = 1000; } break; case 11: disrow = BVar.DisRow * ((PVar.Blogo.MaterialCnt - 1) % 2); Gg.AbsMotion(0, BVar.S2_X, mFunction.Pos.TeachAxis1[m, n] + Offset.X, PVar.ParAxis.Speed[BVar.S2_X]); Gg.AbsMotion(0, BVar.S2_Y, mFunction.Pos.TeachAxis2[m, n] + disrow + Offset.Y, PVar.ParAxis.Speed[BVar.S2_Y]); Gg.AbsMotion(0, BVar.S2_R, mFunction.Pos.TeachAxis4[m, n] + Offset.T, PVar.ParAxis.Speed[BVar.S2_R]); TimeOut = API.GetTickCount(); Manual_Step[m, n] = Manual_Step[m, n] + 1; break; case 12: if (Gg.ZSPD(0, BVar.S2_X) && Gg.ZSPD(0, BVar.S2_Y) && Gg.ZSPD(0, BVar.S2_R)) { TimeOut = API.GetTickCount(); Manual_Step[m, n] = Manual_Step[m, n] + 1; } break; case 13: Gg.AbsMotion(0, BVar.S2_Z, mFunction.Pos.TeachAxis3[m, n], PVar.ParAxis.Speed[BVar.S2_Z]); Manual_Step[m, n] = Manual_Step[m, n] + 1; break; case 14: if (Gg.ZSPD(0, BVar.S2_Z)) { Manual_Step[m, n] = Manual_Step[m, n] + 1; } break; case 15: Manual_Step[m, n] = 1000; break; case 1000: Manual_Step[m, n] = 0; Status = false; break; } } }