+0
Daily
+0
Weekly
299
stars
62
forks
29
watchers
27
prs
123
issues
7
releases
README
TeensyStep
Stepper motor library for PJRC Teensy boards, for drivers with STEP and DIR inputs.
Version 3 is a beta (3.0.0-beta.1): the interface can still change in details until version 3.0.0. It
is a rewrite and runs on Teensy 4.0, 4.1 and MicroMod and on Teensy 3.5 and 3.6. Its manual is at
luni64.github.io/TeensyStep. The last release of version 2 is 2.3.4
on the branch master; the sources of its web site are
in the branch gh-pages.
A first sketch
cpp
include "TeensyStep.h"
using namespace TeensyStep;
Stepper motor(2, 3); // STEP pin 2, DIR pin 3
void setup()
{
motor.setMaxSpeed(20000); // steps/s
motor.setAcceleration(50000); // steps/s^2
}
void loop()
{
motor.moveRel(1000); // returns when the motor stands still
delay(500);
motor.moveRel(-1000);
delay(500);
}
The commands are member functions of the motor. There are no controller objects, and the library takes and
releases the hardware timers itself. The sketches in examples/ show the rest, from the
smallest sketch to complete applications; examples/README.md lists them.
What the new version does
- Commands on the motor: moveAbs, moveRel, rotateAsync, stop, emergencyStop. Every move command
exists in a blocking form (moveAbs) and a non-blocking form (moveAbsAsync).
- Changes during a move: a new target, a new maximum speed or a new acceleration can be given at any
time. The ramp is calculated from the current state of the motor, not planned once at the start.
- Target with a speed: motor.moveAbs(position, speed) reaches the position exactly at that speed and
runs on. A function of the sketch can be called on arrival and can give the next command, which follows
without a stop.
- Groups: StepperGroup moves motors synchronized. The motors stay within half a step of the straight
line between start and target, also while accelerating, decelerating and when the group is stopped early.
A group can have a speed and an acceleration of its own, and it can rotate with a fixed speed ratio.
- For motion planners: TeensyStepAdvanced.h adds moves of a group that follow each other without a
stop (advanced::GroupPath). It is kept apart from the standard interface, which stays small.
- Units: speeds in steps/s, accelerations in steps/s². Speeds below 1 step/s are possible.
- Motor settings: pull-in speed, separate deceleration, pulse width, step polarity, inverse rotation,
DIR setup time, enable pin with on and off delays.
- Errors: every command returns an errorCode. attachErrFunc() registers a function for warnings and
errors; ErrorHandler(Serial) prints them.
- Sketches for version 2 compile unchanged: StepControl and RotateControl are kept as deprecated
wrappers (see examples/version2/ and examples/10_LegacyV2).
Boards
| Board | State |
|---|---|
| Teensy 4.0, 4.1, MicroMod | Works. Up to 16 motors or groups move independently at the same time, each on one channel of the QuadTimers (TMR1 to TMR4). A timer that makes PWM or that aTop issues
#139MultipleSteppers without Acceleration 37 comments · 2022-07-21#131TeensyStep HelloStepper with Teensy 4.1 will not compile 8 comments · 2022-03-13#150RotateController with attached Stepper can cause stepper position freeze (in TeensyStep > 2.0.0)4 comments · 2023-03-17#128TeensyStep stops working if you use it somewhere TIM13 or use TIM2, TIM5 as stepTimer4 comments · 2022-02-02#114V2.3 Error compiling4 comments · 2021-09-28#155The analog Joystick code doesn't work on the STM32F43 comments · 2023-05-06#133Multiple Stepper Synchronization with new position control at specified speed3 comments · 2022-05-28#164getMaxSpeed(); and getAcceleration(); request.2 comments · 2025-08-15
Discussions
#162How to dynamically update the absolute target during a moveAsync?1 comments · 2024-11-20#160TeensyStep 4 for Motion Control Camera System?0 comments · 2024-09-06#159TeensyStep <algorithm> lib issue1 comments · 2024-06-17#156engage / disengage motor1 comments · 2023-06-26#153STM32F3DISCOVERY board and PlatformIO0 comments · 2023-04-25#147Teensy 4.0 compatibility? (no Teensy 3.2 availability)1 comments · 2022-11-21#141TeensyStep library assistance requested2 comments · 2022-08-23#135More groups for STM321 comments · 2022-06-10