Giter Club home page Giter Club logo

accelstepper's People

Contributors

waspinator avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

accelstepper's Issues

No headers ?

I get an error with the latest version of the lib and notice the examples are still in "PDE" format not "INO"
Thought there was a version 1.64 ?

Arduino: 1.8.19 (Windows 10), Board: "Arduino Uno"
Invalid library found in C:\Program Files (x86)\Arduino\libraries\AccelStepper-1.59: no headers files (.h) found in C:\Program Files (x86)\Arduino\libraries\AccelStepper-1.59

Is there a bug in AccelStepper::step4?

Hi,

as far as I know is in a 4 phase full step mode, the value for the sequence zero 0b1010 and for sequence two 0b0101. You can find this sequences in lots of stepper theroy books too.

In AccelStepper.cpp I found the values in the comments but the coding differs.

void AccelStepper::step4(long step)
{
...
case 0: // 1010
setOutputPins(0b0101); <--- 0b1010
break;
...
case 2: //0101
setOutputPins(0b1010); <--- 0b0101
break;
...

Regards,
Ray

Run bug!

While I set Xaxis.move,Yaxis.move both negtive, both of two motor not run.

I am using ESP32 with arduino & TMC2209 driver.

I have tested that 3 type work and only 1 type not work.

Code:

#include <Arduino.h>

#include <AccelStepper.h>
AccelStepper Xaxis(1, 16, 17); // step, direction
AccelStepper Yaxis(1, 25, 26); // step, direction
void setup() {
    int x_circle = 3200;
    int y_circle = 3200;

    Xaxis.setMaxSpeed(x_circle*8);
    Yaxis.setMaxSpeed(y_circle*8);
    Xaxis.setAcceleration(1*x_circle);
    Yaxis.setAcceleration(1*y_circle);

    // work!
//    Xaxis.move(1*x_circle);
//    Yaxis.move(1*y_circle);

    // work!
//    Xaxis.move(1*x_circle);
//    Yaxis.move(-1*y_circle);

    // work!
//    Xaxis.move(-1*x_circle);
//    Yaxis.move(1*y_circle);

    // NOT WORK!
    Xaxis.move(-1*x_circle);
    Yaxis.move(-1*y_circle);
}
void loop() {
    Xaxis.run();
    Yaxis.run();

}

Interruping blocking-mode functions (e.g., limit switch)

Hello,

In my application I'd like to incorporate limit switches that would stop the motor immediately when engaged (e.g., when reaching a hardstop).
For non-blocking mode functions (i.e., constantly calling run() or runSpeed() inside a loop) it is pretty straight-forward by either interrupts or polling. No problem there.

I wonder if there is a way to do the same for blocking functions, such as runToPosition(). Even if I interrupt to set a flag or whatever, as soon as the ISR function returns (which will be very shortly, if it's just setting a flag) the motor will continue the movement (and if a hard stop was reached it will just slip and won't move).
So basically what I am looking for is a way to use interrupts to conditionally break out runToPosition.

I would say this is a pretty basic feature that many other might need.

Thanks!

How to configure endpoints

Hello. I am working on custom camera slider, but I dont know how I can set endpoints and e.g. calculate where middle is.
Is it possible send me simple code of this?

Thanks.

Stop the stepper motor immediately

Hello everyone. I would like to stop the stepper motor immediately after the limit switch has been triggered. If I call the stop() function, the stepper motor starts to decrease its speed depending on the given acceleration.
I need to stop the stepper motor now, so I use the code:
if (stepper.isRunning()) { stepper.moveTo(stepper.currentPosition()); }
It works. But there is a problem. After I set another position to move again, the stepper motor starts moving at maximum speed without using acceleration. This may cause the stepper motor in my device to jam. Are there any other solutions to this problem?
To set the movement speed, I use the setMaxSpeed() functions, and for the stepper motor movement: run().

Change target position while moving and min speed.

Hi!

Thanks for this great lib, I like it verry much!
I will use it for gauges of my flight sim.
I could not find out, if it is already possible to change the target position while the stepper is moving without interupting the travel.
The non blocking way is needed. I tried moveTo() but it stops the stepper and start a new movement . It would be nice, if it is possible to simply update the target position.

The second question: every travel begin with the speed of 0. It would be nice, if the travel can begin with minSpeed for faster arrival at the target position.

Is this possible?
Burkhard Venus

Is this still actively maintained?

Latest release to the library manager is v1.61 from 2020-06-30.

Latest AccelStepper version is v1.63 from 2022-06-30.

It would be nice to be able to install it from the library manager.

Thanks for your effort
Jan

Entering deep sleep on an esp32 re-enables outputs

I have a project running on an esp32 where I only need to move a motor every few minutes, and I'm using deep sleep to reduce the power consumption. However, the motor is still powered (which probably uses more power than the esp32 itself), so I tried to call stepper.disableOutputs(), but it turns out that somehow the output pins are re-enabled when the esp32 enters deep sleep.

Here is some code to reproduce the problem:

#include <AccelStepper.h>
#define IN1 5
#define IN2 18
#define IN3 19
#define IN4 21

// Create an instance of AccelStepper
AccelStepper stepper(AccelStepper::HALF4WIRE, IN1, IN3, IN2, IN4);

void setup() {

  // Initialize the serial port
  Serial.begin(115200);

  stepper.moveTo(123);
  stepper.runToPosition();

  stepper.disableOutputs();

  sleep(3); // Wait for three seconds to have time to observe the outputs.

  // Outputs are now all low

  Serial.println("Entering deep sleep");
  esp_deep_sleep(10000000);

  // Some outputs are enabled again, reflecting the last motor position before disabling outputs.
}

I'm not sure this is relevant, but this project is using a unipolar 28BYJ-48 stepper motor.

Any idea what could be causing this issue, and how it could be possible to disable outputs while the esp is in deep sleep?

is there a possability to use AccelStepper in a non-blocking way "in the backround"

Hello Everybody,

as far as I have used AccelStepper there are two main ways to use it

  1. in a blocking way which means no other code can be executed until the stepper-move has finished
  2. in a non-blocking way which requires to call function run() at a high frequency to ensure that all step-pulses are created just in time?

Is there any way to run accelstepper to create stepper-pulses and in parallel to use the serial interface or to read in onewire.sensors (which is "blocking for 870 milliseconds)

Does anybody know of a another stepper-motor-library that is able to do this?

best regards Stefan

Speed is wrong - there is error accumulation in every runSpeed call

Lets assume I am calling runSpeed in my loop which runs once every 1000 microsecond.
Lets assume I have set speed to 183.75 which means _stepInterval equals to 5442 microseconds so I should have step in loops number:
6 - because 5442us * 1 = 5442us,
11 - because 5442us * 2 = 10.884,
17 - because 5442us * 3 = 16.326,
22 - because 5442us * 4 = 21.768,
28 - because 5442us * 5 = 27.210,
33 - because 5442us * 6 = 32.652,
...

But what happens is this:
After 1st loop (at 1000us), 2nd loop (at 2000us), ... 5th loop (at 5000us) nothing happens.
But at the 6th loop (at 6000us) the condition (from runSpeed function) is true:
if (time - _lastStepTime >= _stepInterval)
which is correct.

The problem is that inside the if body there is a line:
_lastStepTime = time; // Caution: does not account for costs in step()

which is wrong because steps will occure in loops number:
6 - because 6000us - _lastStepTime >= 5442us
12 - because 12000us - 6000us >= 5442us
18 - because 18000us - 12000us >= 5442us
22 - because 22000us - 18000us >= 5442us
28 - because 28000us - 22000us >= 5442us
34 - because 34000us - 28000us >= 5442us
...

and the error accumulates over time. So in any case when _stepInterval is not the same as interval between calling runStep then there is the error and difference in speed is quite dramatic.

At speed of 183.75 steps per second and going from position = 0 to position = 147 I expect it to happen in 800ms but it happens in 877ms which is huge error.

What I did to fix it locally was changing the line:
_lastStepTime = time; // Caution: does not account for costs in step()
to following line
_lastStepTime += _stepInterval; // Caution: does not account for costs in step()
which I believe is correct but becuase _lastStepTime is 0 at the beginning I had to make ugly trick and I locally initialized it inside setSpeed just because I am starting to loop just after calling setSpeed so in my case it worked.

After those fixes the result is as expected - all takes expected 800ms.

RP2040 Support

Does this library support the RP2040? I could not find anything in the code that suggests it doesn't, but would prefer to have a solid answer.

Thanks

compatibility with arduino grbl shield

I saw in another issue that AccelStepper was compatible with A4988 drivers. The Grbl shield uses these drivers, so I would like to know if I can use this library (and, in general, any library that supports A4988) to control stepper motors that work with a Grbl shield using A4988 drivers. sorry for my bad English and thank you for your attention.

High Speeds with setSpeed()

Hi!
I am working on a project which requires stepper motors to be driven at high speeds like 5000 steps/sec and Class documentation discourages use of setSpeed() function for speeds more than 1000 steps/sec setSpeed() Documentation

Does anyone have some suggestion on how I can still use AccelStepper and Arduino for this purpose or should I move to Raspberry Pi/some industrial stepper controller?

Unable to install AccelStepper library on Ubuntu 18.04.4 LTS

When PlatformIO tries to install AccellStepper v1.61 (platformio run command), I'm getting the following error:

xeon132:/opt/robotic-control-panel# platformio run --verbose
Processing esp32doit-devkit-v1 (platform: espressif32; board: esp32doit-devkit-v1; framework: arduino; build_flags: -DCORE_DEBUG_LEVEL=3; monitor_speed: 115200; board_build.partitions: custompart.csv; lib_deps: Adafruit Unified [email protected], [email protected], DHT sensor [email protected], ESP32 BLE [email protected], [email protected], [email protected], [email protected], waspinator/[email protected]; lib_extra_dirs: src/libraries/frameworks, src/libraries/https)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32doit-devkit-v1.html
PLATFORM: Espressif 32 1.12.4 > DOIT ESP32 DEVKIT V1
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 3.10004.200129 (1.0.4)
 - tool-esptoolpy 1.20600.0 (2.6.0)
 - toolchain-xtensa32 2.50200.80 (5.2.0)
xtensa-esp32-elf-g++ -o "/opt/robotic-control-panel/src/esp32RobotController.ino.cpp" -x c++ -fpreprocessed -dD -E "/tmp/tmpkyzummoq"
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
LibraryManager: Installing AccelStepper @ 1.61
git version 2.27.0
Cloning into '/opt/robotic-control-panel/.pio/libdeps/esp32doit-devkit-v1/_tmp_installing-zryrj0zh-package'...
AssertionError: Package version a9bf2f9 doesn't satisfy requirements 1.61:
  File "/usr/local/lib/python3.6/dist-packages/platformio/builder/main.py", line 168:
    env.SConscript("$BUILD_SCRIPT")
  File "/root/.platformio/packages/tool-scons/script/../engine/SCons/Script/SConscript.py", line 597:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/root/.platformio/packages/tool-scons/script/../engine/SCons/Script/SConscript.py", line 286:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/root/.platformio/platforms/espressif32/builder/main.py", line 223:
    target_elf = env.BuildProgram()
  File "/root/.platformio/packages/tool-scons/script/../engine/SCons/Environment.py", line 219:
    return self.method(*nargs, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/platformio/builder/tools/platformio.py", line 62:
    env.ProcessProjectDeps()
  File "/root/.platformio/packages/tool-scons/script/../engine/SCons/Environment.py", line 219:
    return self.method(*nargs, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/platformio/builder/tools/platformio.py", line 131:
    project_lib_builder = env.ConfigureProjectLibBuilder()
  File "/root/.platformio/packages/tool-scons/script/../engine/SCons/Environment.py", line 219:
    return self.method(*nargs, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/platformio/builder/tools/piolib.py", line 1036:
    project.install_dependencies()
  File "/usr/local/lib/python3.6/dist-packages/platformio/builder/tools/piolib.py", line 868:
    lm.install(uri)
  File "/usr/local/lib/python3.6/dist-packages/platformio/managers/lib.py", line 281:
    force=force,
  File "/usr/local/lib/python3.6/dist-packages/platformio/managers/package.py", line 702:
    pkg_dir = self._install_from_url(name, url, requirements, track=True)
  File "/usr/local/lib/python3.6/dist-packages/platformio/managers/package.py", line 499:
    return self._install_from_tmp_dir(_tmp_dir, requirements)
  File "/usr/local/lib/python3.6/dist-packages/platformio/managers/package.py", line 542:
    assert tmp_manifest["version"] == requirements, mismatch_error
================================================================================ [FAILED] Took 2.80 seconds ================================================================================

On Windows PC with the same versions of platformIO, platform and library everything works.

Here is the platformio.ini file which I'm using:

[env:esp32doit-devkit-v1]
platform = espressif32
board = esp32doit-devkit-v1
framework = arduino
build_flags = -DCORE_DEBUG_LEVEL=3 ;debugging level
monitor_speed = 115200
board_build.partitions = custompart.csv

lib_deps =
     # Depend on specific version
     Adafruit Unified [email protected]
     [email protected]
     DHT sensor [email protected]
     ESP32 BLE [email protected]
     [email protected]
     [email protected]
     [email protected]
     waspinator/[email protected]

lib_extra_dirs =
# library path
     src/libraries/frameworks
     src/libraries/https

Simple example

Hi guys.
This should move the stepper 100000 steps forward, in non-blocking mode, at speed 50, right ?
Becaue it does nothing, only electrical noise from the stepper motor

    AccelStepper TestStepper(AccelStepper::DRIVER, STEP_PIN, DIR_PIN);

    TestStepper.setEnablePin(EN_PIN);
    TestStepper.enableOutputs();
    TestStepper.move(100000);
    TestStepper.setMaxSpeed(50*2);
    TestStepper.setSpeed(50);

    while ( TestStepper.runSpeedToPosition() ) {
      // .............
   }

MotorInterfaceType using easydriver and 4 wire stepper using expeceted enumerator does not work as expected.

I'm using a 4 wire bipolar stepper with easy driver using step/dir/MS1/MS2 as pins 2,3,4,5 respectively.
Using the easy driver code I can successfully perform half step rotations.

When using the AccelStepper library and code that causes the motor to go in forward and then in reverse for a few seconds using FULL4WIRE and HALF4WIRE causes the motor to not reverse when expected and continues to spin in one direction
AccelStepper stepper(AccelStepper::FULL4WIRE, 2, 3,4,5)
AccelStepper stepper(AccelStepper::HALF4WIRE, 2, 3,4,5)

Using DRIVER or FULL2WIRE works as expected in terms of forward/reverse of the stepper although FULL2WIRE behaves like a half-step.
AccelStepper stepper(AccelStepper::DRIVER, 2, 3)
AccelStepper stepper(AccelStepper::FULL2WIRE, 2, 3)

stepper: https://www.sparkfun.com/datasheets/Robotics/SM-42BYG011-25.pdf
driver: https://learn.sparkfun.com/tutorials/easy-driver-hook-up-guide/all

The current documentation is unclear.
Does using DRIVER/FULL2DRIVER mean we can only using step/dir pins and not MS1/MS2 for half steps? is this a limitation of using the easydriver with AccelStepper library?
What is the difference between DRIVER and FULL2DRIVER?
If I want to use the MS1/MS2 for half steps how I can I use that using AccelStepper library if 4 wire stepper does not work with the FULL4/HALF4?
Does the Caution for blocking delay apply to all enumerators types or just DRIVER?

Number of pins to interface to. Integer values are supported, but it is preferred to use the MotorInterfaceType symbolic names. AccelStepper::DRIVER (1) means a stepper driver (with Step and Direction pins). If an enable line is also needed, call setEnablePin() after construction. You may also invert the pins using setPinsInverted(). Caution: DRIVER implements a blocking delay of minPulseWidth microseconds (default 1us) for each step. You can change this with setMinPulseWidth(). AccelStepper::FULL2WIRE (2) means a 2 wire stepper (2 pins required). AccelStepper::FULL3WIRE (3) means a 3 wire stepper, such as HDD spindle (3 pins required). AccelStepper::FULL4WIRE (4) means a 4 wire stepper (4 pins required). AccelStepper::HALF3WIRE (6) means a 3 wire half stepper, such as HDD spindle (3 pins required) AccelStepper::HALF4WIRE (8) means a 4 wire half stepper (4 pins required) Defaults to AccelStepper::FULL4WIRE (4) pins.

stm32fxxx support

Hello,

I am attempting to use the AccelStepper library on a NUCLEO-F767ZI board with stm32duino, but it seems that none of the pins are toggled at all (did not measure any signal). What steps should I undertake to get it to work? Maybe the pin defines are lost in translation.

I tried to draw inspiration from a different project, but its unmaintained:
https://github.com/JonathanGoldnauVogt/STM32_Stepper_Driver/tree/master

I tried to run the ConstantSpeed example with a iHSS42-24-07 integrated closed-loop stepper.

Missing step when direction change

It is because during a change of direction, the signal on the DIR pin changes too quickly compared to the signal on the STEP pin. The driver does not yet take into account the change of direction and the first pulse is incorrect.
To fix the problem, you need to add a delay between the state change of the DIR pin and the pulse on the STEP pin.

Motion in Opposite Direction During Acceleration and Deceleration

I am using a NEMA 17, bi-polar stepper motor with a DRV8825 stepper driver. When I attempt to use any acceleration and deceleration on the motor at all, the motor will momentarily "stutter" and travel in the opposite direction briefly while the motor is speeding up or slowing down. It is not a very large amount of travel but it is significant enough to cause the motor to be out of position after a couple of moves of the motor, since it happens during both the acceleration and deceleration parts of the movement. Since steppers get the most torque when they are moving slowly, I was hoping to be able to use this library to also get the most speed out of the motors as possible. I have checked the direction pin and that is not changing at all. I have to think it's something with the timing of the steps that are being sent to the controller. Any idea what might be causing this?

max speed with tcm 16 microsteps

Hi all
i've read that the max speed for this library is 4000steps/s to have a reliable movement.

But is this including the 16 microsteps for TMC2209 (or others) or just the full step? Because i'm currently using 9600 steps/mm (200 * 3 * 16microsteps) without any visible issue on a ESP32 but i need a little bit more speed, like 12800 (200416 steps/s)

What do you think ?

Incompatible with Uno R4 Minima and WIFI

I tested the following sketch using a TB6600 on the Arduino UNO R3, R4 Minima, and R4 WIFI. The R3 works perfectly, but the R4 boards do not. The motor attempts to turn but simply stutters. If I instantiate a WiFiServer in the sketch for the R4 WIFI, the motor still stutters, but it does so at a much slower rate than when the WiFIServer is not instantiated.

// Bounce.pde
// -*- mode: C++ -*-
//
// Make a single stepper bounce from one limit to another
//
// Copyright (C) 2012 Mike McCauley
// $Id: Random.pde,v 1.1 2011/01/05 01:51:01 mikem Exp mikem $

#include <AccelStepper.h>
#define dirPin 9
#define stepPin 8
#define motorInterfaceType 1

// Create a new instance of the AccelStepper class:
AccelStepper stepper = AccelStepper(motorInterfaceType, stepPin, dirPin);

void setup()
{  
  // Change these to suit your stepper if you want
  stepper.setMaxSpeed(900);
  stepper.setAcceleration(500);
  stepper.moveTo(1500);
}

void loop()
{
    // If at the end of travel go to the other end
    if (stepper.distanceToGo() == 0)
      stepper.moveTo(-stepper.currentPosition());

    stepper.run();
}

Losing steps

test Stepper.txt

Hi, I'm using the library with a Stepper driver (only use Pulse pin and Dir pin).
I'm running an example (one revolution forward, one revolution reverse).
I notice that it's losing about 1 degree each iteration. If I let it run for a while the zero moves a lot.
I try it with different accelerations, low speeds, medium speeds.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.