New Stepper Motor Library

Thank you, Luni, for the detailed answer :) I already have a phototransistor (PC817-Sharp) to change the "voltage" rise, but additionally, I ordered an inverter (74HC04). Of course, it would be much better to do it in the microcontroller code.

I will check if it works because the DM805 requires a minimum 5μs delay between the pulse and direction signals. However, I think it should not be a problem if the first few steps are lost (I use microsteps, with 3200 pulses per revolution) - but I need to check.
 
Usually you would use a *HCT since the input levels are better suited for a 3.3V controller output. But, the output rating of a HC/HCT chip is a bit borderline. Your driver is specd for typically 10mA (max 16mA) input current (probably a optocoupled input). IIRC the HC/HCT output is speced for 8mA or so. The 74ACT04 I recomended above should be able to deliver some 25mA (https://www.ti.com/lit/pdf/sdyu001)

A 5µs delay after a direction change is already implemented.
 
Last edited:
Hi Luni,

I'm coming back to this project and I'm having issues and I can't figure out why.
I'm using the current library from https://github.com/luni64/TeensyStep4

With this code the motor does not turn as expected. I think higher speeds don't have this problem but I'm working with very low speeds.

Code:
#include "Arduino.h"
#include "teensystep4.h"
using namespace TS4;
Stepper s1(19, 18);
int ms = 20;  //max speed
int a = 40000;   // acc
elapsedMillis stopwatch;
IntervalTimer t1;
void onTimer() {
  Serial.printf("%6d\t%6d\n", s1.getPosition());
}
void setup() {
  Serial.begin(9600);
  TS4::begin();
  while (!Serial)
    ;
  t1.begin(onTimer, 50'000);          // print out motor positions
  stopwatch = 0;
  s1.setMaxSpeed(ms);
  s1.setAcceleration(a);
}
void loop() {
  s1.rotateAsync(20);
  s1.overrideSpeed(50);
  delay(4000);
  s1.overrideSpeed(-1);
  delay(4000);
  s1.overrideSpeed(-10);
  delay(4000);
  s1.overrideSpeed(50);
  delay(1000);
  s1.overrideSpeed(-11);
  delay(4000);
  s1.overrideSpeed(25);
  delay(1000);
  s1.stopAsync();
  delay(4000);
}

Thanks as always!

EDIT: Changed the code to a more appropriate test.
 
Last edited:
Back
Top