Controlling 3 Stepper Motors with the AccelStepper Library for Arduino

Поділитися
Вставка
  • Опубліковано 29 тра 2024
  • In this video, I demonstrate how to simultaneously control three stepper motors with the Arduino Uno and the Accel Stepper Library with discrete examples.
    Check out this Reference Desk Mat for Arduino:
    amzn.to/3vO6QBl
    Video Timestamps:
    0:00 - Introduction
    0:25 - Installing the library
    0:45 - Parts needed
    1:02 - Wiring the circuit
    1:48 - Moving a single motor to a specific position (blocking)
    4:16 - Sequentially three motors to specific positions (blocking)
    4:57 - Simultaneously moving three motors to specific positions
    7:18 - Simultaneously moving three motors at a constant speed
    8:10 - Simultaneously moving three motors to a position at a constant speed
    9:09 - Using potentiometers to simultaneously control the speed of three motors
    10:20 - Using potentiometers to simultaneously control the position of three motors
    👉Subscribe for more robotics and engineering tips:
    / @theboredrobotllc
    Share this video with a friend:
    • Controlling 3 Stepper ...
    Website:
    www.theboredrobot.com/
    Parts needed for this example:
    Arduino Uno - amzn.to/3pGK6Am
    Stepper Motors - amzn.to/3qtbr9A
    Stepper Motor Drivers - amzn.to/3QpceTP
    Power Supply - amzn.to/3DKs2sF
    Connect:
    Instagram - /theboredrobot
    Twitter - @theboredrobot
    Facebook - / theboredrobot
    Pinterest - /TheBoredRobot
    Disclaimer: This video contains affiliate links, meaning that if you make a purchase from one of the product links, I'll receive a small commission.
  • Наука та технологія

КОМЕНТАРІ • 95

  • @mattinkel7342
    @mattinkel7342 4 місяці тому +11

    That was brilliantly demonstrated and one of the clearest code descriptions I've seen on this subject.

  • @drinski6720
    @drinski6720 6 місяців тому +1

    The best demonstration of Accel Stepper Library. Thank you!

  • @KW-ei3pi
    @KW-ei3pi 9 місяців тому +5

    Very nicely done. Thank you. I'm glad that you noted that the documentation for the Accelstepper library "can be difficult to follow". This is true, even with some experience with Arduino. Another UA-cam creator just say's "Read the documentation" when asked a question. Thanks again. I will look at your other videos.

  • @jessehesch
    @jessehesch Місяць тому

    Yes, very well done. Clear, simple, and thorough. Quite excellent.

  • @skaespearesboys5999
    @skaespearesboys5999 Місяць тому

    This made much more sense of the Accel Stepper Library. Thank you

  • @electronics.unmessed
    @electronics.unmessed 7 місяців тому

    Pretty comprehensive - like it - thanks for sharing!

  • @GlipValor
    @GlipValor 8 місяців тому +6

    Just a comment to promote this content. Clean and detailed

  • @johnnicol5009
    @johnnicol5009 7 місяців тому

    Nice tutorial. Clear and well explained.

  • @bobmain
    @bobmain 2 місяці тому

    Thank you sooo much! I've been confused by the AccelStepper library and this helped me understand it much better. If you're a bonehead like me, **double-check** your Dir and Pul wires. I had them crossed and it was still "kinda" working, but the step counts were off.
    Next for my project will be an attempt to add G-code conversion. Hopefully I can find a Library for that as well. But, if not I think I I'll try write it myself using these commands!
    Thanks again! great work!

  • @alkimadsiz4867
    @alkimadsiz4867 27 днів тому

    Very helpful video thanks

  • @tesg9551
    @tesg9551 2 місяці тому

    Excellent video. Thanks much.

  • @timblewden5399
    @timblewden5399 9 місяців тому +2

    excellent video cheers

  • @chirots
    @chirots 6 місяців тому

    Mainly I use PLC for most projects either big or small, because it is much easier. Often I watch arduino projects and admire people for all programing skills. Personally I hardly use Arduino, because my C language is below average and I prefer using python and micropython for pi and Pico. I can write classes in python, but impossible to do in C.
    You explained really well.

  • @thehypothesisxplorer4449
    @thehypothesisxplorer4449 3 місяці тому

    Hi, thank you for this informative video.
    I would like to know if I have to use a TB6600 driver with a NEMA 17 motor, will the code be the same for constant speed?

    • @TheBoredRobotLLC
      @TheBoredRobotLLC  3 місяці тому

      For the most part, the code should be the same. You'll need to verify your pin assignments.

  • @harishnarrendranr2785
    @harishnarrendranr2785 2 місяці тому

    Clearly explained .👏👏

  • @colormaker5070
    @colormaker5070 8 місяців тому

    Thank you, I am working on a new product with the same setup but using the ESP32.

    • @TheBoredRobotLLC
      @TheBoredRobotLLC  7 місяців тому

      Good luck! I hope this video helps move the project along.

  • @amadeoortiz
    @amadeoortiz 8 місяців тому

    is it possible to move two steppers at the same way as you explained with runToNewPosition, like a program structure?

    • @TheBoredRobotLLC
      @TheBoredRobotLLC  8 місяців тому

      Yes, you can either set up additional variables and objects and run the motors in parallel. Or you can try simply running the motor controller leads to the same pins on the Arduino.

  • @Ockhamcool
    @Ockhamcool Місяць тому

    Thanks for this helpful video. Makes sense, and explained at a good pace. QUESTION: Do you have a video to show simple contact closure switch/motor control integration? (i.e. simple code for stopping and starting individual motors with a simple switch) Thank you!

  • @samuelmarciano9441
    @samuelmarciano9441 Місяць тому

    Hey man! Your explanation was clear and helpfull! I've been trying to use this same library to control 2 Nema 17 motors, on my line follower robot. But when add the code to read some IR sensors, it start's to stop the nema motors. After a quick search for similar problems on the internet, I've found that i can't have functions with that library that take to much time. I'm currently using an Arduino Uno, what if I move to a fast MCU, do you think it can solve this problem? I'm open to other alternatives!

    • @TheBoredRobotLLC
      @TheBoredRobotLLC  Місяць тому

      Using the non-blocking AccelStepper commands help with speed. Perhaps the faster version of the Arduino can help as well.

  • @ahmadqadi2127
    @ahmadqadi2127 6 місяців тому

    Thanks for the video ,,, how do you know the acceleration for stepper ?

    • @TheBoredRobotLLC
      @TheBoredRobotLLC  6 місяців тому +1

      The value you choose for setAcceleration() is in units of steps per second squared.

  • @guillemfuste3839
    @guillemfuste3839 Місяць тому

    Omg that could have been so useful 5 years ago on my highschool project

  • @gregortrierscheid1025
    @gregortrierscheid1025 4 місяці тому

    Excellent!

  • @GPTBot1123
    @GPTBot1123 9 місяців тому +1

    Wow. Actually doing a very similar project right now. Arduino, steppers, plus a little Python just for fun. Using python to pair the Arduino outputs to keyboard/mouse inputs using serial communication.

  • @user-gb5jc9ik1b
    @user-gb5jc9ik1b 7 місяців тому

    if i call set speed to a positive value in one loop and do another loop and set it at a negitive value the rotation moves in the same direction and doesnt change directions like your example. Any ideas on why the direction doesnt change when i change the setSpeed?

    • @TheBoredRobotLLC
      @TheBoredRobotLLC  6 місяців тому

      You don't change direction by changing the value to negative. You need to change direction by flipping the value of the direction pin.

  • @chris-hs
    @chris-hs 6 місяців тому

    Hello! What if I want to move 3 steppers simultaneously, but have other moves it should do after while still having these three simultaneously moving?

    • @TheBoredRobotLLC
      @TheBoredRobotLLC  6 місяців тому

      If I understand the question, you have three motors that will move in exactly the same fashion. Then you'll have additional motors moving in a different way from these three. If this is the case, the first three motors can have the same direction and step pins on the Arduino. Then the other motors can be wired independently.

  • @greenenko
    @greenenko 7 місяців тому

    Hi! What if i have something else besides of stepper.runSpeed in the loop? For example pid control. And it blocks correct steppings, how to deal with it?

    • @TheBoredRobotLLC
      @TheBoredRobotLLC  6 місяців тому

      I would suggest using the non blocking commands in the case where you want to implement feedback control.

  • @nusretalikok823
    @nusretalikok823 3 місяці тому

    Thank you for the video friend, it really helped me out! I seem to be running into a bit of a problem though, the acceleration at the beginning causes low speeds which in return compromises the accuracy of the rotation. I give it the 200 steps 360 degrees command but each time it is off by a few steps. I wanted to use the setSpeed() with the stepper1.runToPosition command but cant get it to work, it just assumes acceleration is equal to 1. Might I ask for assistance ? :)

    • @TheBoredRobotLLC
      @TheBoredRobotLLC  3 місяці тому +1

      You can reach out here if you want to dive deeper into the specifics of your code:
      theboredrobot.com/pages/contact

    • @nusretalikok823
      @nusretalikok823 3 місяці тому

      thanks for the response@@TheBoredRobotLLC

  • @lorenzodalvise9367
    @lorenzodalvise9367 5 місяців тому

    How can I make the stepper motor stop jumping between values when controlled with a potentiometer?

    • @TheBoredRobotLLC
      @TheBoredRobotLLC  5 місяців тому

      You would have to implement a smoothing or filtering function on either the signal being read the for the pot, or the value being sent to the motor driver.

  • @TaitumLaroque
    @TaitumLaroque 8 місяців тому

    any ideas why when i do the first example the stepper is very jittery and vibrates. but when i do other example it moves very smooth and silently. no hardware is changed in between tests.

    • @TheBoredRobotLLC
      @TheBoredRobotLLC  8 місяців тому +1

      It's hard to answer this without more information. If I was running into this issue, I would first play around with speed and acceleration values to see if that changes anything. I've also run into jittery motion when the potentiometer on speed controller was set too low.

    • @TaitumLaroque
      @TaitumLaroque 8 місяців тому

      @@TheBoredRobotLLC it was the speed. when too low it jitters, when higher its smoother. thanks

    • @TheBoredRobotLLC
      @TheBoredRobotLLC  8 місяців тому

      @@TaitumLaroque I'm glad you figured it out.

  • @TheBhaskarsingh
    @TheBhaskarsingh 5 місяців тому

    Which capacitor i shall use and can I use 4 stepper motor

    • @TheBoredRobotLLC
      @TheBoredRobotLLC  5 місяців тому

      That depends on the motors you're using. Here's a good resource that I found that may help with the question:
      resources.pcb.cadence.com/blog/2022-what-size-capacitor-should-i-use

  • @kifahzaidan4505
    @kifahzaidan4505 5 місяців тому

    Hi,
    I really appreciate your efforts and the knowledge you have shared. I am seeking help with developing a code and schematic diagram for a project that involves preset positions using push buttons, an encoder, a linear actuator, and either a DC or stepper motor, to be controlled by an Arduino Mega or UNO. The main goal is to enable the actuator to stop at specific positions selected by the user, which can be easily recalled at any time. I understand that this is quite a complicated task, but any assistance you could provide would be greatly appreciated.
    Regards

    • @TheBoredRobotLLC
      @TheBoredRobotLLC  5 місяців тому

      Sure, I would be happy to help. I do offer consulting/tutoring services. Feel free to contact me here and we can open up that discussion.
      theboredrobot.com/pages/contact

  • @thelegendplz6136
    @thelegendplz6136 5 місяців тому

    What application did you use to create your circuit diagram?

  • @Cfernanv
    @Cfernanv 6 днів тому

    Quiero fabricar un afilador de herramientas, quiero agregarle un eje mas. Tres ejes que se muevan de forma lineal y un eje rotativo. Display para agregar valores en pantalla para el desplazamiento y valores de angulos para que gire la herramienta. Hay formas que me puedas ayudar?

    • @TheBoredRobotLLC
      @TheBoredRobotLLC  4 дні тому

      I had to use google translate on this one. The library works for additional motors. You'll just have to make sure you have enough pins on your Arduino.

  • @alphacreations4558
    @alphacreations4558 8 днів тому

    Is it possible to stop the motor at same time with different position?

    • @TheBoredRobotLLC
      @TheBoredRobotLLC  4 дні тому

      Yes, there are many ways to do that. There are stop commands within the library or send a signal to EN pin on the driver itself at the same time.

  • @AB_Pyrotechnic
    @AB_Pyrotechnic 5 місяців тому

    preface: sorry for being an Arduino noob.
    I am controlling a motor(s) with constant speed. Is it possible to control the acceleration of the motor to its running speed? I cant seem to figure it out and I have been trying for HOURS.

    • @TheBoredRobotLLC
      @TheBoredRobotLLC  5 місяців тому

      Yes you can control the acceleration using the setAcceleration() command. The value of the acceleration goes inside of the parenthesis.

    • @AB_Pyrotechnic
      @AB_Pyrotechnic 5 місяців тому

      @@TheBoredRobotLLC Every time I try that it doesnt do anything. it just goes to its set rpm instantly.

  • @Dracomance
    @Dracomance 17 днів тому

    Hello bro
    I'm doing a project that will use 3 stepper motors
    So far I'm still in my prototype for this project (Of 3 engines I'm only testing 1)
    I was using the L298n driver
    I saw this driver there and found it more interesting
    The A4988
    It requires less wire connected to Arduino,
    enabling a greater number of motors connected at the same time, interesting
    I would like to know if you have seen any difference in practice using these drivers, if, for example, it is more interesting to use an L298N or an A4988 to keep a stepper motor on for longer
    A big hug from Brazil :)

    • @TheBoredRobotLLC
      @TheBoredRobotLLC  12 днів тому

      I really haven't tested both of them extensively. Both have worked for my projects in the past. If one of the options can clean up your wiring, then it would make sense to go with that one.

  • @stevefox3763
    @stevefox3763 2 дні тому

    Please could you release code for this that uses Rc PWM for the control input?
    My personal use requirement is 2 Rc channel input for 2 stepper controls so this would work great for me if I could use Rc input to control it.
    Steve.

  • @DorfyBoi
    @DorfyBoi 2 місяці тому

    After I've grasped all the concepts involved in doing this, how hard would it be to implement stepper motor control over ethernet on a client?

    • @TheBoredRobotLLC
      @TheBoredRobotLLC  2 місяці тому

      To be honest. I've never done anything like that before. It would involve a bit of research on my end.

    • @DorfyBoi
      @DorfyBoi Місяць тому

      @@TheBoredRobotLLC Thanks for the response.
      I've been at it for a few days and have made some progress!
      Here is what I currently have working.
      I have a client PC on the network running a python script with Pygame Library, Requests library, and time.
      I'm able to send button presses from my controller via http to the Arduino which has an ethernet shield, running Ethernet library & accelstepper library.
      I got the motor to respond to button presses. Now I just have to learn how to control it better.
      The end goal is to be able to control a camera slider via http requests and gamepad.

  • @bobmirror7164
    @bobmirror7164 2 місяці тому

    Is there any open source code for Arduino to open and close a house window with a stepper motor actuator 10 or more times in a day; code that one can edited the hours to open and close a house window? Maybe someone made a library to do this. I can not find anything.

    • @TheBoredRobotLLC
      @TheBoredRobotLLC  2 місяці тому

      I'm not aware of any open source code that does specifically this task. Maybe there are projects that do pieces of it.

    • @bobmirror7164
      @bobmirror7164 2 місяці тому

      @@TheBoredRobotLLC Thanks for the reply. I am beginning to think this type of operation is a bit much for the Arduino boards. I just found out telescope trackers do not use Arduino boards.

  • @user-bk3zj2wd4d
    @user-bk3zj2wd4d 26 днів тому

    It would be nice if you could be more specific about the parts you used, such as the potentiometer

    • @TheBoredRobotLLC
      @TheBoredRobotLLC  23 дні тому

      The main parts are in the description. Any hobby level pot will do for this example. In the video, I used the ones from the Arduino starter kit.

  • @ganeshreddy6965
    @ganeshreddy6965 4 місяці тому

    hello Sir i am just beginning my project and i am new with Arduino i have used same code but my driver is TB6600 but it did not work can please help me in coding .

    • @TheBoredRobotLLC
      @TheBoredRobotLLC  4 місяці тому

      That's a pretty broad question. That driver should work pretty much the same. You just need to makes sure you're pin assignments are correct.

  • @queenidog1
    @queenidog1 Місяць тому

    Very good video. Where's the code?

  • @ksssilver
    @ksssilver 4 місяці тому

    wonderfull. thank you very much.