示例#1
0
 public void moveStepperToTop()
 {
     try
     {
         double currentMicrosecondWait = 630;
         double currentWait            = 0;
         while (printer.LimitSwitchPressed() == false)
         {
             bool printerStepped = printer.StepStepper(PrinterControl.StepperDir.STEP_UP);
             if (!printerStepped && !printer.LimitSwitchPressed())
             {
                 throw new Exception("printer step failed, speed is wrong?");
             }
             printer.WaitMicroseconds((long)currentMicrosecondWait);
             currentWait += currentMicrosecondWait;
             if (currentWait > 1000 && currentMicrosecondWait > 69)
             {
                 currentMicrosecondWait -= .06;
                 currentWait             = 0;
             }
         }
         Console.WriteLine("Limit switch pressed?");
     }
     catch (Exception e)
     {
         System.Console.WriteLine(e.StackTrace);
     }
 }
        void RetractPlate()
        {
            ResetAccelStepper();


            while (!printer.LimitSwitchPressed())
            {
                if (!printer.StepStepper(PrinterControl.StepperDir.STEP_UP))
                {
                    break;
                }

                WaitForNextStep();
            }

            plateZ = printer.GetPrinterHeight();
        }
示例#3
0
 public void ResetZRail()
 {
     while (!printer.LimitSwitchPressed())
     {
         printer.StepStepper(PrinterControl.StepperDir.STEP_UP);
     }
     for (int i = 0; i < 39800; i++)
     {
         printer.StepStepper(PrinterControl.StepperDir.STEP_DOWN);
     }
 }
示例#4
0
        public void ToLimit()
        {
            var switch_pressed = printer.LimitSwitchPressed();
            var delay          = 0;
            var stepperSpeed   = 1;
            var totalDelay     = 0; //Too keep track of the number of uS before increasing speed.

            while (switch_pressed != true)
            {
                totalDelay += delay;
                if (totalDelay >= 1010000)
                {
                    stepperSpeed = IncreaseStepperSpeed(stepperSpeed);
                    totalDelay   = 0;
                }
                delay = CalculateStepperDelay(stepperSpeed);
                printer.WaitMicroseconds(delay);
                printer.StepStepper(PrinterControl.StepperDir.STEP_UP);
                switch_pressed = printer.LimitSwitchPressed();
            }
        }
示例#5
0
        //Since the build plate starts at a random point every time, this function moves it all the way up until
        //the limit switch is pressed. It then steps down 40000 (calculated from datasheet) which will put it at the home position.
        public void SetBuildPlateHome()
        {
            while (printer.LimitSwitchPressed() != true)
            {
                zRailController.StepOnce(PrinterControl.StepperDir.STEP_UP);
            }

            zRailController.ResetSteps();

            Console.WriteLine("Build plate is at top and will now move to bottom");

            zRailController.MoveZRail(PrinterControl.StepperDir.STEP_DOWN, 40000);
            return;
        }
示例#6
0
        public void GoToLimitSwitch()
        {
            double currentDelay       = 625;
            double microsecondsPassed = 0;

            while (printer.LimitSwitchPressed() == false)
            {
                printer.StepStepper(PrinterControl.StepperDir.STEP_UP);

                printer.WaitMicroseconds((long)currentDelay);
                microsecondsPassed = microsecondsPassed + currentDelay;

                if (microsecondsPassed > 1000000L)
                {
                    currentDelay = currentDelay - 60;
                    if (currentDelay < 70)
                    {
                        currentDelay = 70;
                    }
                    microsecondsPassed = 0;
                }
            }
        }
示例#7
0
        public void movementWithSpeed(PrinterControl printer, PrinterControl.StepperDir dir, float distance)
        {
            float velocity         = 0;
            float distanceTraveled = 0;

            while (currentLocation == -1 && !(printer.LimitSwitchPressed()))
            {
                velocity += Acceleration;
                //Thread.Sleep(1000);
                for (var i = 0; i < velocity; i++)
                {
                    for (var j = 0; j < 400; j++)
                    {
                        if (printer.LimitSwitchPressed())
                        {
                            break;
                        }
                        printer.StepStepper(dir);
                        distanceTraveled += (float)(1.0 / 400);
                    }
                    if (printer.LimitSwitchPressed())
                    {
                        break;
                    }
                }

                //printer.StepStepper(dir);
            }
            if (((dir == PrinterControl.StepperDir.STEP_DOWN) && (currentLocation - distance > 0) && (!printer.LimitSwitchPressed() || (currentLocation != -1))))
            {
                while (distanceTraveled < distance)
                {
                    if (velocity < maxVelocity && (velocity + Acceleration < maxVelocity))
                    {
                        velocity += Acceleration;
                    }
                    else if (velocity < maxVelocity && (maxVelocity - velocity < Acceleration)) //allows us to reach max velocity without overshooting
                    {
                        velocity = maxVelocity;
                    }
                    //Thread.Sleep(1000);
                    for (var i = 0; i < velocity; i++)
                    {
                        for (var j = 0; j < 400; j++)
                        {
                            if (distanceTraveled >= distance || (printer.LimitSwitchPressed() && (currentLocation == -1)))
                            {
                                break;
                            }
                            printer.StepStepper(dir);
                            distanceTraveled += (float)(1.0 / 400);
                        }
                        if (distanceTraveled >= distance || printer.LimitSwitchPressed())
                        {
                            break;
                        }
                    }/*
                      * if (distanceTraveled + velocity < distance) //if we wont over shoot
                      * {
                      * distanceTraveled += velocity;
                      * }
                      * else //this happens if we're close but the velocity will over shoot it should move the rest of the way without overshooting
                      * {
                      * //distanceTraveled += (velocity - distance);
                      * velocity = 0;
                      * }
                      */
                }
                currentLocation -= distanceTraveled;
            }
            if ((dir == PrinterControl.StepperDir.STEP_UP) && currentLocation + distance < 100 && !printer.LimitSwitchPressed())
            {
                while (distanceTraveled < distance)
                {
                    if (velocity < maxVelocity && (velocity + Acceleration < maxVelocity))
                    {
                        velocity += Acceleration;
                    }
                    else if (velocity < maxVelocity && (maxVelocity - velocity < Acceleration))
                    {
                        velocity = maxVelocity;
                    }
                    // Thread.Sleep(1000);
                    for (var i = 0; i < velocity; i++)
                    {
                        for (var j = 0; j < 400; j++)
                        {
                            if (distanceTraveled >= distance || printer.LimitSwitchPressed())
                            {
                                break;
                            }
                            printer.StepStepper(dir);
                            distanceTraveled += (float)(1.0 / 400);
                        }
                        if (distanceTraveled >= distance || printer.LimitSwitchPressed())
                        {
                            break;
                        }
                    }
                }
                currentLocation += distanceTraveled;
            }
        }