PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

Quickstop.pde 1.0KB

hace 3 años
12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Quickstop.pde
  2. // -*- mode: C++ -*-
  3. //
  4. // Check stop handling.
  5. // Calls stop() while the stepper is travelling at full speed, causing
  6. // the stepper to stop as quickly as possible, within the constraints of the
  7. // current acceleration.
  8. //
  9. // Copyright (C) 2012 Mike McCauley
  10. // $Id: $
  11. #include <AccelStepper.h>
  12. // Define a stepper and the pins it will use
  13. AccelStepper stepper; // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5
  14. void setup()
  15. {
  16. stepper.setMaxSpeed(150);
  17. stepper.setAcceleration(100);
  18. }
  19. void loop()
  20. {
  21. stepper.moveTo(500);
  22. while (stepper.currentPosition() != 300) // Full speed up to 300
  23. stepper.run();
  24. stepper.stop(); // Stop as fast as possible: sets new target
  25. stepper.runToPosition();
  26. // Now stopped after quickstop
  27. // Now go backwards
  28. stepper.moveTo(-500);
  29. while (stepper.currentPosition() != 0) // Full speed basck to 0
  30. stepper.run();
  31. stepper.stop(); // Stop as fast as possible: sets new target
  32. stepper.runToPosition();
  33. // Now stopped after quickstop
  34. }