luni64 /TeensyStep

Fast Stepper Motor Library for Teensy boards

★ 299⑂ 62👁 29⑃ 27● 123▤ 7
C++MITCreated 2017-04-19luni64.github.io/TeensyStep/
下载:fix manifestsfix-2.3.4 ↓2.3.42023-04-13
+0
日增长
+0
周增长
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 a

Top issues

Discussions

Latest release

fix manifests v2.3.4 2023-04-13

Snapshot: 2026-11-27T22:26:53Z · Data license Apache-2.0 · JSON