PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Overshoot.pde 751B

3 yıl önce
12345678910111213141516171819202122232425262728
  1. // Overshoot.pde
  2. // -*- mode: C++ -*-
  3. //
  4. // Check overshoot handling
  5. // which sets a new target position and then waits until the stepper has
  6. // achieved it. This is used for testing the handling of overshoots
  7. //
  8. // Copyright (C) 2009 Mike McCauley
  9. // $Id: Overshoot.pde,v 1.1 2011/01/05 01:51:01 mikem Exp mikem $
  10. #include <AccelStepper.h>
  11. // Define a stepper and the pins it will use
  12. AccelStepper stepper; // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5
  13. void setup()
  14. {
  15. stepper.setMaxSpeed(150);
  16. stepper.setAcceleration(100);
  17. }
  18. void loop()
  19. {
  20. stepper.moveTo(500);
  21. while (stepper.currentPosition() != 300) // Full speed up to 300
  22. stepper.run();
  23. stepper.runToNewPosition(0); // Cause an overshoot then back to 0
  24. }