void Home_alone(ushort Cardno, ushort Axis, ushort home_mode, double Low_Vel, double High_Vel) { // LTDMC.nmc_set_axis_enable(0, 0); //使能 ///Thread.Sleep(1000); PublicClass.AxisHome(Cardno, Axis, home_mode, Low_Vel, High_Vel); ushort homerres = 99; while ((LTDMC.dmc_check_done(Cardno, Axis) == 0) || (homerres != 1)) //判断是否回零完 { LTDMC.dmc_get_home_result(Cardno, Axis, ref homerres); Application.DoEvents(); if (VarClass.ReadIN[4]) //jiting { return; } Thread.Sleep(10); } }
public void HomeMove() { HomeStep = 1; while (HomeStep != 0) { switch (HomeStep) { case 1: { myFrMain.Invoke((MethodInvoker) delegate { myFrMain.addLog("3个Z轴归零中", Color.Black); }); Home1: PublicClass.AxisHome(0, 0, 7, VarClass.Low_Wel[0], VarClass.High_Wel[0]); //大Z轴归零 PublicClass.AxisHome(0, 1, 7, VarClass.Low_Wel[1], VarClass.High_Wel[1]); //小Z轴归零 PublicClass.AxisHome(0, 2, 7, VarClass.Low_Wel[2], VarClass.High_Wel[2]); //扫码轴归零 ushort BigZstate = 99; ushort SmallZstate = 99; ushort ScanZstate = 99; Thread.Sleep(500); while ((LTDMC.dmc_check_done(0, 0) == 0) || (BigZstate != 1) || (LTDMC.dmc_check_done(0, 1) == 0) || (SmallZstate != 1) || (LTDMC.dmc_check_done(0, 2) == 0) || (ScanZstate != 1)) //判断是否回零完 { LTDMC.dmc_get_home_result(0, 0, ref BigZstate); LTDMC.dmc_get_home_result(0, 1, ref SmallZstate); LTDMC.dmc_get_home_result(0, 2, ref ScanZstate); while (VarClass.Pause_Flag) { PublicClass.AxisStop(0, 0, 0); //大Z轴停止 PublicClass.AxisStop(0, 1, 0); //小Z轴停止 PublicClass.AxisStop(0, 2, 0); //大Z轴停止 Thread.Sleep(5); if (!VarClass.Pause_Flag) { goto Home1; } } } myFrMain.Invoke((MethodInvoker) delegate { myFrMain.addLog("3个Z轴归零完成,下一步小Z轴归零", Color.Black); }); HomeStep = 3; break; } case 3: { Home3: PublicClass.AxisMove(1, VarClass.AutoSpeed[1], VarClass.SmallZ_Location[1]); //小Z轴跑低位 while ((LTDMC.dmc_check_done(0, 1) == 0) || (VarClass.SmallZ_Location[1] != VarClass.Pulse_Current[1])) { Thread.Sleep(5); while (VarClass.Pause_Flag) { PublicClass.AxisStop(0, 1, 0); //小Z轴停止 Thread.Sleep(5); if (!VarClass.Pause_Flag) { goto Home3; } } } myFrMain.Invoke((MethodInvoker) delegate { myFrMain.addLog("小Z轴到达低位,下一步左右气缸出", Color.Black); }); //PublicClass.WriteOUT(0, 12, 0);//左气缸出 //PublicClass.WriteOUT(0, 13, 1); PublicClass.WriteOUT(0, 6, 0); //左右气缸出 PublicClass.WriteOUT(0, 7, 1); while (!VarClass.ReadIN[13] || !VarClass.ReadIN[16]) //左,右气缸出限 { Thread.Sleep(5); while (VarClass.Pause_Flag) { Thread.Sleep(5); } } myFrMain.Invoke((MethodInvoker) delegate { myFrMain.addLog("左右气缸出完,下一步小Z轴跑位,扫码Z轴去扫码位", Color.Black); }); HomeStep = 4; break; } case 4: { Home4: Thread.Sleep(500); PublicClass.AxisMove(1, VarClass.AutoSpeed[1], VarClass.SmallZ_Location[0]); //小 Z轴跑高位 // PublicClass.AxisMove(2, VarClass.AutoSpeed[2], VarClass.ScanZ_Location[1]); //扫码Z轴到扫描位 while ((LTDMC.dmc_check_done(0, 1) == 0) || (VarClass.SmallZ_Location[0] != VarClass.Pulse_Current[1])) { Thread.Sleep(5); while (VarClass.Pause_Flag) { PublicClass.AxisStop(0, 1, 0); //小Z轴停止 Thread.Sleep(5); if (!VarClass.Pause_Flag) { goto Home4; } } } myFrMain.Invoke((MethodInvoker) delegate { myFrMain.addLog("小Z轴到达高位;XY轴归零", Color.Black); }); HomeStep = 5; break; } case 5: { Home5: Thread.Sleep(500); PublicClass.AxisHome(0, 3, 13, VarClass.Low_Wel[3], VarClass.High_Wel[3]); //X轴归零 PublicClass.AxisHome(0, 4, 13, VarClass.Low_Wel[4], VarClass.High_Wel[4]); //Y轴归零 ushort XAixsState = 99; ushort YAixsState = 99; Thread.Sleep(500); while ((LTDMC.dmc_check_done(0, 3) == 0) || (XAixsState != 1) || (LTDMC.dmc_check_done(0, 4) == 0) || (YAixsState != 1)) //判断是否回零完 { LTDMC.dmc_get_home_result(0, 3, ref XAixsState); LTDMC.dmc_get_home_result(0, 4, ref YAixsState); Thread.Sleep(10); while (VarClass.Pause_Flag) { PublicClass.AxisStop(0, 3, 0); //X轴停止 PublicClass.AxisStop(0, 4, 0); //Y轴停止 Thread.Sleep(5); if (!VarClass.Pause_Flag) { goto Home5; } } } myFrMain.Invoke((MethodInvoker) delegate { myFrMain.addLog("归零完成", Color.Black); }); VarClass.Homeing = false; //归零标志 VarClass.HomeFinish = true; HomeStep = 0; break; } } } }