public static void Main() { //FanTacho.Intialize(Cpu.Pin.GPIO_Pin13);//not working dont use X = new Axis("X", Pins.GPIO_PIN_D11, Pins.GPIO_PIN_D4, Pins.GPIO_PIN_D3); Y = new Axis("Y", Pins.GPIO_PIN_D9, Pins.GPIO_PIN_D8, Pins.GPIO_PIN_A1); Z = new Axis("Z", Pins.GPIO_PIN_D7, Pins.GPIO_PIN_D6, Pins.GPIO_PIN_A2); ExternalDevices = new Devices(Pins.GPIO_PIN_A4, Pins.GPIO_PIN_A3, Pins.GPIO_NONE); X.OnAxisLimitReached += OnAxisLimitReached; Y.OnAxisLimitReached += OnAxisLimitReached; Z.OnAxisLimitReached += OnAxisLimitReached; EStopButton.OnInterrupt += EStopButton_OnPress; EnableSteppers(false); // don't drive the stepper coils while idle SetStepResolution("2"); // half stepping by default ServoZTemp.Angle = 10; // raise the sharpie on reboot Controller = new MotionController(X, Y, Z, ExternalDevices); var socketServer = new SocketServer(); socketServer.OnRequest += SocketServer_OnRequest; BlinkLED(3, false); // Visual "Ready" Cue // Boot up in E-Stop mode to require an initializing communication from the controller UI SetEStop(); socketServer.ListenForRequest(); }
public string FindEdge(int delaySlow, int backoffCount, int backoffDelay, Axis axisToFindEdgeFor) { // X and Y move towards home to find their edges, Z moves away from home (towards bed) axisToFindEdgeFor.StepDirection = axisToFindEdgeFor.ID == "Z" ? true : false; while (true) { if (Program.EStopCondition) return ""; // Use Z Limit pin regardless of axis we're finding the edge for if (AxisZ.IsAtLimit()) break; axisToFindEdgeFor.Step(); DelayBy(delaySlow); } int edgeFoundAt = axisToFindEdgeFor.Location; axisToFindEdgeFor.StepDirection = !axisToFindEdgeFor.StepDirection; for (int i = 0; i < backoffCount; i++) { axisToFindEdgeFor.Step(); DelayBy(backoffDelay); } AxisZ.ResetLimitReached(); return "Edge touched at: " + edgeFoundAt.ToString(); }
public MotionController(Axis axisX, Axis axisY, Axis axisZ, Devices externalDevices) { //TODO: Eliminate all references to Program.x - make sure all dependancies are injected AxisX = axisX; AxisY = axisY; AxisZ = axisZ; ExternalDevices = externalDevices; }
private static void OnAxisLimitReached(Axis sender) { if (!IsHoming) SetEStop(true); }