示例#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);
     }
 }
示例#2
0
        public void MoveZRail(PrinterControl.StepperDir dir, int steps)
        {
            double secondsElapsed = 1;
            double waitCounter    = 0;
            double waitTime;

            for (int i = 0; i < steps; i++)
            {
                waitTime = (1 / (secondsElapsed * 4 * 400)) * 1000000;

                if (waitTime < 70)
                {
                    waitTime = 70;
                }

                printer.StepStepper(dir);

                printer.WaitMicroseconds((long)waitTime);

                waitCounter += (int)waitTime;

                if (waitCounter >= 1000000)
                {
                    secondsElapsed += 1;
                    waitCounter     = 0;
                }
            }
        }
示例#3
0
        public void GoToBuildSurface()
        {
            double currentDelay       = 625;
            double microsecondsPassed = 0;

            for (int i = 0; i < 40000; i++)
            {
                printer.StepStepper(PrinterControl.StepperDir.STEP_DOWN);
                printer.WaitMicroseconds((long)currentDelay);
                microsecondsPassed = microsecondsPassed + currentDelay;
                if (microsecondsPassed > 1000000L)
                {
                    currentDelay = currentDelay - 100;
                    if (currentDelay < 150)
                    {
                        currentDelay = 150;
                    }
                    microsecondsPassed = 0;
                }
            }
        }
        void WaitForNextStep()
        {
            long microWait;

            microWait = (long)(1000000L / (accelCurVelocity * PrinterControl.STEPS_PER_MM));

            printer.WaitMicroseconds(microWait);

            accelCounter += microWait;

            if (accelCounter > 1000000L)  // Increase velocity every second
            {
                accelCurVelocity += MAX_STEPPER_ACCEL;
                if (accelCurVelocity > MAX_STEPPER_VELOCITY)
                {
                    accelCurVelocity = MAX_STEPPER_VELOCITY;
                }

                accelCounter = 0;
            }
        }
示例#5
0
        static int maxStepperSpeed  = 100;                  //Because the max amount of times the stepper can accelerate is 10 times

        public void z_rail_init(/*PrinterControl printer*/) //Moves Galvos to the top
        {
            printer.WaitMicroseconds(1000000);
            ToLimit();
            MoveZrail(printer.GetPrinterHeight(), PrinterControl.StepperDir.STEP_DOWN);
        }