/// <summary> /// Raises an event when the edge finder is being used to report the coordinate where the specified axis touched the finder. /// This event passes the number of inches from the machine origin where the finder was touched. /// </summary> private void RaiseTouchedAtEvent(string responseText) { if (OnEdgeTouched == null) { return; } var coordinate = responseText.Split(':'); if (coordinate.Length < 2) { return; } // Machine stores all coordinates as 8 microsteps per full step regardless of the current resolution double touchedAt = (Convert.ToInt32(coordinate[1]) / 8) / (double)_axisFindingEdgeFor.FullStepsPerInch(); OnEdgeTouched(touchedAt); }
public void FindEdge(string axis) { //NOTE: As we are obviously hard coding the resolution, the speed calculations wouldn't work if we ever changed // resolution or if the speed calculations returned a different resolution. I don't forsee doing this, but just be careful in case. SendStepResolution(FeedRate.StepResolutions.Half); _axisFindingEdgeFor = Settings.GetAxisSettings(axis); FeedRate.StepResolutions resolution; int slowSpeed = Settings.CalculateStepDelayFromFeedRate(20, out resolution); // Back off of the finder by 1/4 inch (maybe this should be a setting too?) int backoffSpeed = Settings.CalculateStepDelayFromFeedRate(30, out resolution); int backoffSteps = _axisFindingEdgeFor.FullStepsPerInch() * (int)_resolution / 4; EnableStepperDrivers(true); SendCommand(string.Format("FINDEDGE:{0},{1},{2},{3}", axis, slowSpeed, backoffSteps, backoffSpeed)); EnableStepperDrivers(false); }