public override void Start() { base.Start(); ADCSamplingPointMissException pointsMissedEx = null; double deltaPos = double.MaxValue; Log.Clear(); //while(true) //{ double distMovedLinear = 0, distMovedRotating = 0; double halfRangeLinear = Args.LinearRange / 2; // get the unit of axes var unitLinearAxis = Args.AxisLinear.PhysicalAxisInst.UnitHelper; var unitRotatingAxis = Args.AxisRotating.PhysicalAxisInst.UnitHelper; AddLog($"Start to align ..."); #region Linear Alignment // clear the previous scan curve Args.ClearScanCurve(); // clear the variables to restart now process of linear align distMovedLinear = 0; /// <summary> /// move to alignment start position. /// the move methods of the physical axis MUST BE called because the move methods of logical /// axis will trigger the changing of system status in SystemService. /// <see cref="SystemService.MoveLogicalAxis(LogicalAxis, MoveByDistanceArgs)"/> /// </summary> if (Args.AxisLinear.PhysicalAxisInst.Move(MoveMode.REL, Args.MoveSpeed, -halfRangeLinear) == false) { throw new InvalidOperationException($"unable to move the linear axis, {Args.AxisLinear.PhysicalAxisInst.LastError}"); } var axis = Args.AxisLinear.PhysicalAxisInst as IrixiM12Axis; var m12 = axis.Parent as IrixiM12; var range = Args.LinearRange; var interval = Args.LinearInterval; List <Point2D> points = null; List <Point2D> points2 = null; try { m12.StartFast1D(axis, range, interval, Args.MoveSpeed, ADCChannels.CH3, out points, ADCChannels.CH4, out points2); } catch (ADCSamplingPointMissException ex) { pointsMissedEx = ex; } // convert position from step to distance. for (int i = 0; i < points.Count; i++) { points[i].X = axis.UnitHelper.ConvertStepsToDistance((int)points[i].X); points2[i].X = axis.UnitHelper.ConvertStepsToDistance((int)points2[i].X); } Args.ScanCurve.AddRange(points); Args.ScanCurve2.AddRange(points2); // find the position of max power and draw the constant lines /// <seealso cref="ScanCurve.MaxPowerConstantLine"/> var maxPos = Args.ScanCurve.FindPositionWithMaxIntensity(); var maxPos2 = Args.ScanCurve2.FindPositionWithMaxIntensity(); // calculate the position differential deltaPos = maxPos.X - maxPos2.X; // move to the middle position of the max power var returnToPos = maxPos.X - deltaPos / 2; // output messages AddLog($"Position with Max Intensity: ({maxPos.X.ToString("F2")}{unitLinearAxis}, {maxPos.Y.ToString("F3")}), ({maxPos2.X.ToString("F2")}{unitLinearAxis}, {maxPos2.Y.ToString("F3")}"); AddLog($"ΔPosition: {deltaPos.ToString("F2")}{unitLinearAxis}"); AddLog($"Middle of ΔPosition: {returnToPos.ToString("F2")}{unitLinearAxis}"); // move to the middle position if (Args.AxisLinear.PhysicalAxisInst.Move(MoveMode.REL, Args.MoveSpeed, -(distMovedLinear - returnToPos)) == false) { throw new InvalidOperationException(Args.AxisLinear.PhysicalAxisInst.LastError); } #endregion // if the first cycle, rotate to the position calculate according to the delta position and the length of the two DUTs double angle = -1 * Math.Asin(deltaPos / Args.Pitch) * (180 / Math.PI); AddLog($"The predicted rolling angle is: {angle.ToString("F2")}{unitRotatingAxis}"); // record the angle rotated distMovedRotating += angle; if (Args.AxisRotating.PhysicalAxisInst.Move(MoveMode.REL, Args.MoveSpeed, angle) == false) { throw new InvalidOperationException(Args.AxisRotating.PhysicalAxisInst.LastError); } AddLog($"{this} has done!"); }
public override void Start() { base.Start(); int state = 0; ADCSamplingPointMissException pointsMissedEx = null; LogicalAxis activeAxis = Args.Axis; var range = Args.HorizonalRange; var interval = Args.HorizonalInterval; double moved = 0; AddLog($"Start to align ..."); _align: // reset arguments Args.ScanCurveGroup.ClearCurvesContent(); moved = 0; // move to the start point if (activeAxis.PhysicalAxisInst.Move(MoveMode.REL, Args.MoveSpeed, -(range / 2)) == false) { throw new InvalidOperationException(activeAxis.PhysicalAxisInst.LastError); } var axis = activeAxis.PhysicalAxisInst as IrixiM12Axis; var m12 = axis.Parent as IrixiM12; List <Point2D> points = null; List <Point2D> points2 = null; try { m12.StartFast1D(axis, range, interval, Args.MoveSpeed, ADCChannels.CH3, out points, ADCChannels.CH4, out points2); } catch (ADCSamplingPointMissException ex) { pointsMissedEx = ex; } // convert position from step to distance. for (int i = 0; i < points.Count; i++) { points[i].X = axis.UnitHelper.ConvertStepsToDistance((int)points[i].X); points2[i].X = axis.UnitHelper.ConvertStepsToDistance((int)points2[i].X); } Args.ScanCurve.AddRange(points); Args.ScanCurve2.AddRange(points2); var maxPos = Args.ScanCurve.FindPositionWithMaxIntensity(); var maxPos2 = Args.ScanCurve2.FindPositionWithMaxIntensity(); var diffPos = maxPos.X - maxPos2.X; // return to the position with maximum indensity var returnToPos = maxPos.X - diffPos / 2; // output messages var unitHelper = activeAxis.PhysicalAxisInst.UnitHelper; AddLog($"Max Intensity Position: ({maxPos.X.ToString("F1")}{unitHelper}, {maxPos.Y.ToString("F3")}), ({maxPos2.X.ToString("F1")}{unitHelper}, {maxPos2.Y.ToString("F3")})"); AddLog($"ΔPosition: {diffPos.ToString("F1")}{activeAxis}"); AddLog($"Middle of ΔPosition: {returnToPos.ToString("F1")}{unitHelper}"); if (activeAxis.PhysicalAxisInst.Move(MoveMode.REL, Args.MoveSpeed, -(moved - returnToPos)) == false) { throw new InvalidOperationException(activeAxis.PhysicalAxisInst.LastError); } // switch to the next axis to scan if (state < 1) { state++; activeAxis = Args.Axis2; range = Args.VerticalRange; Task.Delay(500); goto _align; } AddLog($"Done! {(DateTime.Now - alignStarts).TotalSeconds.ToString("F1")}s costs."); }
public override void Start() { base.Start(); ADCSamplingPointMissException pointMissEx = null; double maxIndensity = 0; //int moved_points = 0; //var curr_pos = new Point(0, 0); //var curr_point3d = new Point3D(); AddLog("Start to align ..."); Args.ClearScanCurve(); var haxis = Args.Axis.PhysicalAxisInst as IrixiM12Axis; var vaxis = Args.Axis2.PhysicalAxisInst as IrixiM12Axis; var m12 = haxis.Parent as IrixiM12; List <Point3D> points = null; try { m12.StartBlindSearch(haxis, vaxis, Args.Range, Args.Interval, Args.Interval, Args.MoveSpeed, M12.Definitions.ADCChannels.CH3, out points); } catch (ADCSamplingPointMissException ex) { // ran too fast, some ADC sampling points missed. pointMissEx = ex; AddLog("Some of the sampling points are lost, reduce the speed and try again."); AddLog($"{ex.Desired} points desired but only {ex.Reality} points got."); } // convert position from step to distance. for (int i = 0; i < points.Count; i++) { points[i].X = haxis.UnitHelper.ConvertStepsToDistance((int)points[i].X); points[i].Y = vaxis.UnitHelper.ConvertStepsToDistance((int)points[i].Y); } // draw curve. Args.ScanCurve.AddRange(points); // move the position with maximum intensity. var maxPoint = Args.ScanCurve.FindMaximalPosition3D(); var lastPoint = Args.ScanCurve.Last(); var last_x = lastPoint.X; var last_y = lastPoint.Y; var max_x = maxPoint.X; var max_y = maxPoint.Y; maxIndensity = maxPoint.Z; // Axis0 acts logical X Args.Axis.PhysicalAxisInst.Move(MoveMode.REL, Args.MoveSpeed, -(last_x - max_x)); // Axis1 acts logical Y Args.Axis2.PhysicalAxisInst.Move(MoveMode.REL, Args.MoveSpeed, -(last_y - max_y)); AddLog($"Done! {(DateTime.Now - alignStarts).TotalSeconds.ToString("F1")}s costs."); if (pointMissEx != null) { throw pointMissEx; } }
public override void Start() { int cycles = 0; double max_measval = 0; ADCSamplingPointMissException pointsMissedEx = null; base.Start(); Args.ClearScanCurve(); // select enabled axes var arg_enabled = Args.AxisParamCollection.Where(a => a.IsEnabled == true); // sort by AlignOrder var args = arg_enabled.OrderBy(a => a.Order); // align by each axis. foreach (var arg in args) { AddLog($"Start to align {arg.Axis} ..."); //double dist_moved = 0; double halfrange = arg.Range / 2; /// <summary> /// move to alignment start position. /// the move methods of the physical axis MUST BE called because the move methods of logical /// axis will trigger the changing of system status in SystemService. /// <see cref="SystemService.MoveLogicalAxis(MotionControllers.Base.LogicalAxis, MoveByDistanceArgs)"/> /// </summary> if (arg.Axis.PhysicalAxisInst.Move(MoveMode.REL, arg.MoveSpeed, -halfrange) == false) { throw new InvalidOperationException(arg.Axis.PhysicalAxisInst.LastError); } var axis = arg.Axis.PhysicalAxisInst as IrixiM12Axis; var m12 = axis.Parent as IrixiM12; List <Point2D> points = null; try { m12.StartFast1D(axis, arg.Range, arg.Interval, arg.MoveSpeed, M12.Definitions.ADCChannels.CH3, out points); } catch (ADCSamplingPointMissException ex) { pointsMissedEx = ex; AddLog("Some of the sampling points are lost, reduce the speed and try again."); AddLog($"{ex.Desired} points desired but only {ex.Reality} points got."); } // convert position from step to distance. for (int i = 0; i < points.Count; i++) { points[i].X = axis.UnitHelper.ConvertStepsToDistance((int)points[i].X); } arg.ScanCurve.AddRange(points); // cancel the alignment process if (cts_token.IsCancellationRequested) { break; } // return to the position with the maximnm measurement data var max_pos = arg.ScanCurve.FindPositionWithMaxIntensity(); max_measval = max_pos.Y; // move to the position of max power // Note: The distance to move is minus if (arg.Axis.PhysicalAxisInst.Move(MoveMode.REL, arg.Axis.MoveArgs.Speed, -(arg.Range - max_pos.X)) == false) { throw new InvalidOperationException(arg.Axis.PhysicalAxisInst.LastError); } AddLog($"Done! {(DateTime.Now - alignStarts).TotalSeconds.ToString("F1")}s costs."); } }