Controlling 3 Stepper Motors with the AccelStepper Library for Arduino
ฝัง
- เผยแพร่เมื่อ 10 พ.ค. 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. - วิทยาศาสตร์และเทคโนโลยี
That was brilliantly demonstrated and one of the clearest code descriptions I've seen on this subject.
Thanks! I'm glad you liked it.
Lcd
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 TH-cam creator just say's "Read the documentation" when asked a question. Thanks again. I will look at your other videos.
Thank you!
The best demonstration of Accel Stepper Library. Thank you!
Glad it was helpful!
Just a comment to promote this content. Clean and detailed
Thank you! Much appreciated.
Pretty comprehensive - like it - thanks for sharing!
Glad you liked it!
excellent video cheers
Glad you enjoyed it
This made much more sense of the Accel Stepper Library. Thank you
Glad it was helpful!
Yes, very well done. Clear, simple, and thorough. Quite excellent.
Glad you liked it
Nice tutorial. Clear and well explained.
Glad it was helpful!
Thank you, I am working on a new product with the same setup but using the ESP32.
Good luck! I hope this video helps move the project along.
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!
Thanks! Good luck on your next project.
Clearly explained .👏👏
Thank you!
Excellent video. Thanks much.
Glad you enjoyed it!
Very helpful video thanks
Glad it was helpful!
Excellent!
Glad you liked it!
Omg that could have been so useful 5 years ago on my highschool project
I'm glad you liked the video!
is it possible to move two steppers at the same way as you explained with runToNewPosition, like a program structure?
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.
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!
Sorry, I haven't created a video like this.
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.
Thanks for the feedback!
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.
Nice! That sounds like a fun project.
I’m doing that but for homework ;-;
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?
For the most part, the code should be the same. You'll need to verify your pin assignments.
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!
Using the non-blocking AccelStepper commands help with speed. Perhaps the faster version of the Arduino can help as well.
Thanks for the video ,,, how do you know the acceleration for stepper ?
The value you choose for setAcceleration() is in units of steps per second squared.
It would be nice if you could be more specific about the parts you used, such as the potentiometer
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.
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?
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.
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.
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.
@@TheBoredRobotLLC it was the speed. when too low it jitters, when higher its smoother. thanks
@@TaitumLaroque I'm glad you figured it out.
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?
You don't change direction by changing the value to negative. You need to change direction by flipping the value of the direction pin.
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 ? :)
You can reach out here if you want to dive deeper into the specifics of your code:
theboredrobot.com/pages/contact
thanks for the response@@TheBoredRobotLLC
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?
I would suggest using the non blocking commands in the case where you want to implement feedback control.
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
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
Which capacitor i shall use and can I use 4 stepper motor
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
How can I make the stepper motor stop jumping between values when controlled with a potentiometer?
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.
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.
Yes you can control the acceleration using the setAcceleration() command. The value of the acceleration goes inside of the parenthesis.
@@TheBoredRobotLLC Every time I try that it doesnt do anything. it just goes to its set rpm instantly.
What application did you use to create your circuit diagram?
I used Fritzing.
@@TheBoredRobotLLC Thank you!
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?
To be honest. I've never done anything like that before. It would involve a bit of research on my end.
@@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.
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.
I'm not aware of any open source code that does specifically this task. Maybe there are projects that do pieces of it.
@@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.
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 .
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.
Very good video. Where's the code?
github.com/TheBoredRobot/TH-cam-Code
wonderfull. thank you very much.
Thank you. I hope it helped!