public void Pick(RackGripper gripper = RackGripper.None, bool okToReloadConveyor = true) { OnInfoOccured(20016, "Find gripper for pick."); if (gripper == RackGripper.None) { gripper = GetAvailableGripper(); } OnInfoOccured(20016, "About to pick phone on conveyor with gripper" + gripper + "."); if (LatestPhone != null) { if (LatestPhone.OnGripper != RackGripper.None) { OnInfoOccured(20016, "Already got a phone in " + gripper + "."); //Robot not release control on conveyor in this case. OkToReloadOnConveyor(); return; } } else { throw new Exception("Phone is not ready."); } if (EcatIo.GetInput(Input.PickHasPhone) == false) { throw new Exception("No phone in pick position. Quit picking."); } RobotTakeControlOnConveyor(); CheckGripperAvailable(gripper); Conveyor.ReadyForPicking(); TargetPosition target = Motion.PickPosition; if (gripper == RackGripper.Two) { target.XPos = target.XPos + Motion.PickOffset.XPos; } MoveToTargetPosition(gripper, target, false, false); CloseGripper(gripper); MoveToPointTillEnd(Motion.MotorZ, Motion.PickPosition.ApproachHeight); CheckPhoneLost(gripper); MoveToPointTillEnd(Motion.MotorY, Motion.HomePosition.YPos); LatestPhone.OnGripper = gripper; if (okToReloadConveyor) { OkToReloadOnConveyor(); RobotReleaseControlOnConveyor(); } OnInfoOccured(20017, "Pick phone succeed."); }
public void Reset() { Motion.SetSpeed(DefaultRobotSpeed); //SystemFault = false; RobotReleaseControlOnConveyor(); ResetConveyor(); Conveyor.HasBinAPhone = false; Conveyor.StopBeltBin(); Conveyor.HasPlaceAPhone = false; }
/// <summary> /// /// </summary> /// <see cref="Conveyor.Monitor"/> private void ConveyorManager() { while (true) { _conveyorWorkingManualResetEvent.WaitOne(); try { ConveyorIsBusy = true; if (LatestPhone == null && Conveyor.PickBufferHasPhone) { if (OkToLetInNewPhone()) { //if (ScannerOnline) //{ // if (Scanner.ScanSuccessful == false) // { // throw new Exception("Scan fail, please remove phone manually."); // } //} Conveyor.InposForPicking(); //Conveyor is still stop, so no new SN would enter, wrong SN would not happen. AddNewPhone(); } } if (LatestPhone == null || Conveyor.PickBufferHasPhone == false || Conveyor.HasPlaceAPhone) { Conveyor.RunBeltPick(); } if (LatestPhone != null && Conveyor.PickBufferHasPhone && Conveyor.HasPlaceAPhone == false) { Conveyor.StopBeltPick(); Delay(100); Conveyor.ReadyForPicking(); _conveyorPickReadyManualResetEvent.Set(); _conveyorPickReadyManualResetEvent.WaitOne(); } } catch (Exception e) { OnErrorOccured(40007, "Conveyor error:" + e.Message); _conveyorWorkingManualResetEvent.Reset(); } finally { ConveyorIsBusy = false; } Delay(100); } }
public void ReadyThePhone(int timeout = 3000) { //RobotTakeControlOnConveyor(); Conveyor.Clamp(false); Conveyor.UpBlockSeparate(false); Conveyor.UpBlockPick(false); Conveyor.SideBlockSeparate(false); Conveyor.ConveyorMovingForward = !Conveyor.ConveyorMovingForward; Conveyor.UpBlockSeparate(false); Conveyor.UpBlockPick(false); Conveyor.SideBlockSeparate(false); Conveyor.ConveyorMovingForward = !Conveyor.ConveyorMovingForward; EcatIo.SetOutput(Output.ClampPick, true); Stopwatch sw = new Stopwatch(); sw.Start(); while (!EcatIo.GetInput(Input.ClampTightPick)) { if (sw.ElapsedMilliseconds > timeout) { throw new Exception("ReadyThePhone timeout"); } Thread.Sleep(10); } EcatIo.SetOutput(Output.SideBlockPick, true); sw.Restart(); while (EcatIo.GetInput(Input.SideBlockPick)) { if (sw.ElapsedMilliseconds > timeout) { throw new Exception("ReadyThePhone timeout"); } Thread.Sleep(10); } Thread.Sleep(500); EcatIo.SetOutput(Output.SideBlockPick, false); sw.Restart(); while (!EcatIo.GetInput(Input.SideBlockPick)) { if (sw.ElapsedMilliseconds > timeout) { throw new Exception("ReadyThePhone timeout"); } Thread.Sleep(10); } EcatIo.SetOutput(Output.ClampPick, false); sw = new Stopwatch(); sw.Restart(); while (!EcatIo.GetInput(Input.ClampLoosePick)) { if (sw.ElapsedMilliseconds > timeout) { throw new Exception("ReadyThePhone timeout"); } Thread.Sleep(10); } }
public void Bin(RackGripper gripper, Phone phone = null) { OnInfoOccured(20019, "Try binning phone with " + gripper + "."); if (phone != null) { string footprint = string.Empty; foreach (var foot in phone.TargetPositionFootprint) { footprint += (int)foot.TeachPos + ","; } OnProductionComplete(false, phone.SerialNumber, footprint, phone.FailDetail); } Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); while (Conveyor.NgFullWarning) { if (stopwatch.ElapsedMilliseconds > 2 * 60 * 60 * 1000) // 2 hour waiting. { throw new Exception("Can't bin because ng conveyor is full."); } Delay(1000); } if (Conveyor.HasBinAPhone == true || EcatIo.GetInput(Input.ConveyorBinIn) == true || EcatIo.GetInput(Input.ConveyorBinInTwo) == true) { throw new Exception("Last bin movement has't finished."); } Conveyor.RobotBinning = true; ShieldBox3.RobotBining = true; bool needReopen = false; if (gripper == RackGripper.One) { if (ShieldBox3.WasEnabled) { if (ShieldBox3.IsClosed() == false) { ShieldBox3.CloseBox(5000, false); needReopen = true; } } } Conveyor.StopBeltBin(); MoveToTargetPosition(gripper, Motion.BinPosition, true); OpenGripper(gripper); Conveyor.HasBinAPhone = true; MoveToPointTillEnd(Motion.MotorZ, Motion.BinPosition.ApproachHeight); YRetractFromBox(); Conveyor.RunBeltBin(); if (needReopen && ShieldBox3.Enabled) { ShieldBox3.OpenBox(5000, true, true); } ShieldBox3.RobotBining = false; Conveyor.RobotBinning = false; OnInfoOccured(20019, "Finish binning phone with " + gripper + "."); }
/// <summary> /// /// </summary> /// If a new phone went into pick position, it has to be picked before /// place a pass phone, in <see cref="ArrangePhones"/> , it serve new /// phone before wifi phone(second priority), and new phone will only come in /// when there is empty enough Rf box. /// <param name="gripper"></param> public void Place(RackGripper gripper, Phone phone = null) { OnInfoOccured(20026, "Try placing with " + gripper + "."); if (Conveyor.HasPlaceAPhone == true) { throw new Exception("Last place movement has't finished."); } if (phone != null) { string footprint = string.Empty; foreach (var foot in phone.TargetPositionFootprint) { footprint += (int)foot.TeachPos + ","; } OnProductionComplete(true, phone.SerialNumber, footprint, ""); } RobotTakeControlOnConveyor(); Conveyor.StopBeltPick(); RackGripper theOtherGripper = RackGripper.None; if (Conveyor.PickPhoneSensor()) { if (LatestPhone != null) { theOtherGripper = gripper == RackGripper.One ? RackGripper.Two : RackGripper.One; Pick(theOtherGripper, false); } else { throw new Exception("When place, has an unknown phone."); } } if (Conveyor.PickPhoneSensor()) { throw new Exception("When place, has an unknown phone in pick position."); } if (EcatIo.GetInput(Input.UpBlockPickForward) || EcatIo.GetInput(Input.UpBlockPickBackward) || EcatIo.GetInput(Input.ClampTightPick)) { throw new Exception("When place, cylinder on conveyor is up."); } CheckPhoneLost(gripper); TargetPosition placePosition = Motion.PickPosition; if (gripper == RackGripper.Two) { placePosition.XPos = placePosition.XPos + 1 + Motion.PickOffset.XPos; } else { placePosition.XPos = placePosition.XPos + 1; } placePosition.ZPos = placePosition.ZPos + 4; if (theOtherGripper != RackGripper.None) { Motion.ToPointX(placePosition.XPos); ToPointR(placePosition, gripper); //ToPointGripper(placePosition, gripper); ToPointGripperOnConveyorTillEnd(placePosition, gripper); //WaitTillEndGripper(placePosition, gripper); Motion.WaitTillEndX(); Motion.WaitTillEnd(Motion.MotorR); MotorYOutThenBreakMotorZDown(placePosition, gripper, false); } else { MoveToTargetPosition(gripper, placePosition, true, false); } OpenGripper(gripper); if (theOtherGripper != RackGripper.None) { Steppers.ToPoint(theOtherGripper, Motion.PickPosition.APos); } MoveToPointTillEnd(Motion.MotorZ, Motion.PickPosition.ApproachHeight); MoveToPointTillEnd(Motion.MotorY, Motion.HomePosition.YPos); Conveyor.HasPlaceAPhone = true; if (theOtherGripper != RackGripper.None) { //Steppers.ToPoint(theOtherGripper, Motion.PickPosition.APos); Steppers.WaitTillEnd(theOtherGripper, Motion.PickPosition.APos); } RobotReleaseControlOnConveyor(); OnInfoOccured(20026, "Finish placing with " + gripper + "."); }
public void Start() { SetupComplete = false; if (EthercatOnline) { if (_ch.IsConnected == false) { EnableEvent(); _ch.OpenCommEthernet(_ip, 701); } if (EcatIo == null) { EcatIo = new EthercatIo(_ch, 72, 7, 4); } EcatIo.Setup(); } if (MotorsOnline) { if (Motion == null) { Motion = new EthercatMotion(_ch, 5); } if (Motion.MotorSetupComplete == false) { Motion.Setup(); } Motion.LoadPositions(); SetMotorSpeed(DefaultRobotSpeed); if (EthercatOnline) { EcatIo.MapEtherCAT(); } } if (StepperOnline) { if (Steppers == null) { Steppers = new Stepper("COM2"); } Steppers.Setup(); SetStepperSpeed(DefaultRobotSpeed); } if (ConveyorOnline) { if (Conveyor == null) { Conveyor = new Conveyor(EcatIo); } Conveyor.Start(); Conveyor.ErrorOccured -= Conveyor_ErrorOccured; Conveyor.ErrorOccured += Conveyor_ErrorOccured; StartConveyorManager(); } if (ShieldBoxOnline) { ShieldBoxSetup(); if (TesterOnline) { TesterSetup(); } } if (ScannerOnline) { if (Scanner == null) { Scanner = new Scanner("COM44"); Scanner.InfoOccured -= Scanner_InfoOccured; Scanner.InfoOccured += Scanner_InfoOccured; Scanner.ErrorOccured -= Scanner_ErrorOccured; Scanner.ErrorOccured += Scanner_ErrorOccured; } Scanner.Start(); } GoldPhoneSetup(); SelfChecking(); SetupComplete = true; }