I found your channel today as I am working on a stepper motor project. The video is 3 years old but I see you posted some new one recently and see you have great content. I will be binge watching this weekend. you gave me some insight to the accelstepper lib so thank you.
I am watching your videos, they are excellent, I am learning a lot with you, thank you for your willingness and attention to all of us who participated and enjoyed your videos !!!! I am having difficulties in placing two independent stepper motors, exactly to make these movements, I am also configuring a nextion 7 "screen as a manual and automatic control interface.
Thank you for your kind words! I hope that my videos can help you. I will have many more stepper motor related videos and linear motion related videos. All I need is more free time. :)
Thanks, try to move to a location 1 and save that loc in EERom , then move to next location save the second location. Run from Boot then move to pre-saved locations
Brilliant, just what I needed! I will need to work out with my belt drive gearing how to convert steps to degrees. Would be good of there was a box on screen for this. Even better would be to use a separate 4 x 4 keypad & LCD & memory to become independent of the computer. Thanks again, great tutorial.
Great video tutorial. I to am using Accelstepper for my camera motion control system the only drawback is not being able to control two steppers at the same time with acceleration. I have overcome this on my project by using independent Nano's on each axis not ideal but I know have a modular system where I can control any number off axis wirelessly across the same or different devices.
Thanks! I believe it should work simultaneously with 2 steppers on Nano. Maybe you have a blocking code somewhere or you print on a display....etc. Alternatively, you can try faster, Arduino compatible MCUs such as the STM32F103 blue pill, or the Teensy 4.0. Teensy is super fast.
Are you a professor? you have the best explanation of code and circuitry I have seen. Great instructor. Keep up the good work. I will disable the virus program then download it. Thanks.
Thank you! I studied a lot and taught students in a lab for a year, but I am not a prof. My philosophy of learning is to be able to explain things in details so I am also sure that I understand the topic.
Good explanations all round on all your videos. Just one thing, is the "runallowed = true" needed at all for the Relative & Absolute functions. In the previous library we need it because the RunTheMotor function was triggered by: if (runallowed == true) { stepper.enableOutputs(); stepper.run(); } ............ With this code though it looks like the RunTheMotor operation "stepper.distanceToGo() != 0" doesn't need the boolean statement and only needs the following inputs: stepper.setMaxSpeed(receivedSpeed); stepper.move(receivedSteps); Also is it possible to look at the AccelStepper Library directly, just curious how you got the library to work in the way it does.
Thanks! Check my more recent videos because I actually got rid of this part of the code. Also, you can simply use Google and visit the official website of the Accelstepper library where there's a very nice documentation on each classes and functions.
Thank you for this tutorial and the AccelSteppers software which works very well I can't get the motor to work in the serial monitor with the letters "P" and "R" the ping pong works very well with the letter "K"
Thank you very sharing the sharing the code and control software of your project. It helps me a lot in understanding the accelstepper library. Could you please provide visual studio program in which you created GUI app? I want to modify the GUI according to my requirements. Waiting for your reply. Thanks!
Hi, I have just come across your fantastic channel and now your web site. I have just started building a model railway and one of the things I am researching is an "automated turntable". This enables you turn a locomotive around and to park locomotives in different sheds. I intend to use a Nema 17 to directly spin the turntable and to control the Nema via and Arduino. I will need stop the turntable at precise locations so that the central track lines up perfectly with the track going to the parking bays. So I will look to change the number of steps to predefined positions that match each of the tracks. I was initially thinking of rotary switch to select each parking bay or the home position, but the graphical interface you have would be perfect, with the following addition. It would be nice to replace the numeric display of the current position with a simple graphic of the turntable, moving to the selected position. I hope you can imagine what I am trying to describe. Could you help me with the changes required to the interface? Another approach would be to use a set of leds and buttons on a circular board, with each button set to a specific position. The leds would light up when the turntable is in the requested position. Is it possible to have a number of push buttons with each button representing a specific position? Would it be possible to communicate directly with you some how? Thanks again for your work. The first thing I did after seeing your videos was to Subscribe. Thanks.
Hi! Thanks! For some reason, I cannot see my previous answer. I already made a video with 2 motors. It is not that difficult to figure the things out for 3 motor. This is the video: ruclips.net/video/Xf39xbopAFM/видео.html
Thx for the software and very good video. :-) How about adding 4 push-buttons to the arduino and mapping them up in the software. Exp. Push button one to goto 8000 push button 2 to go -4000 etc. :-) Is that doable?
I would be happy if you could show hot to implement function like setting zero position of the motor without using limit switch, for example manually moving the motor till finding a desired position and setting it as home position so that if we accidentaly press a negative value we dont pass that point
Awesome!! This is great. Thank you so much. I learned alot of things from your video. I am trying to controlling six stepmotor for my robotic arm. Great work.. I wanna to see more and I am watching your other videos.
Once in a blue moon RUclips algorithms provide some great content, and this is such a case! I’m in research mode before building a camera slider and this would be great for that. My goal is to have several keyframes that the slider will move between and it would be great to be able to choose the type of ease in/out. Right now it looks like there is only one value for in and out? Have liked and subscribed 👍🏼
Hi! Thank you very much! If you want to build a camera slider, you might be interested in this video: ruclips.net/video/UojoDm1oZrU/видео.html Especially check the goTo() function and the pingpong() function.
@@CuriousScientist can you provide some further information how you did that ? Your code is awesome and I learned a lot, but I want to modify the code and the GUI to control several Stepper.
It is just a simple GUI where I placed a few controls which send some message to the serial terminal. It is not very complicated, you just need to make sure that the receiver (Arduino) knows how to interpret the commands.
a very good video and well explained This video was cnc /3d printer x y z with accurate positioning ect but could you show an example of a position from an out side program that is all ways up dating where the position should be example DCS (digital combat simulator) a flight sim game, going into a second program Sim Tools which is extracting all the flight telemetry. lets say just the roll of the aircraft . the out-put from sim tools minus 32767 (180 degree bank left) 0 (which is wing level) positive 32767 which is (180 degree bank right) The problem is when you do a complete roll so lets say bank to the right . the counter gets to +32767 (wings level but upside down) then is has to move to minus 32767 and count down until it gets to zero But because the motor can not keep up with the game all the time and a new value comes in be for it has completed its move and makes it stop its full roll and continue with the new input position. This has been my challenge for years, I have a working code but it very lumpy .There seams to be a very big market for arduino code that is easy to understand to make diy stimulators work in my case would i use move (x) or move to (x) or an interrupt or a pingpong sort of thing Just wish i had something between the ears that makes it look as easy as your video to wright code Thank you very much for posting video i now have lots more to think about
Thank you! If the motor cannot keep up with the incoming values, I think it is something wrong with the software. Maybe the processing of the values is not coded efficiently. I hope you find the solution.
Nice project. Are you able to use this in the case of non-blocking and tracking movements? I'm looking to update the position in real-time, and the motor slews to this new position. Sometimes a new fixed position will be ordered (ie move to 255 degrees) or perhaps relative (+15degrees), which will countermand the previous order issued that may not have been completed. Not sure how to implement this without movement that stutters and jolts the motor - which must be avoided. I'm wanting smooth accelerations and decelerations (even in cases of change of direction). My project is to move a homemade observatory dome to orientate the dome window to match the telescope angle of sight. Most of the time movements are slow, but they are always slaved to match the position of the telescope. During some star-seeking movements or perhaps tracking the ISS, the movements require very rapid updates. I currently limit the updates to >ABS(5degrees), too much time is wasted. Using an ESP32 processor with Arduino SDK C++ with the standard AccelStepper library. My current setup works for linear single step instructions, but this is limiting. Any advice or pointers on non-blocking updates would be appreciated. Great videos - keep them coming. regs Rob
Hi Bob, First, I recommend studying the well-written documentation of the AccelStepper library itself. There are multiple functions to run a stepper motor in different ways and some of them are blocking, some of them are not. Actually, these (blocking or non-blocking) are stated in the descriptions of the functions. The simple run() function is for example non-blocking. You give a relative (move()) or absolute (moveTo()) target to the code, and then the run() function does its job in the main loop() of the code. Whenever a step is due according to the set speed and acceleration values, the code will perform a step when the code reaches the run() function. What many people miss is that they can still block this non-blocking function. If you are reading a sensor or doing something else that takes more time than the time between two step pulses, the motor will start stuttering, and it will either skip steps or mess up the speed of the motor and cause jerky motion. So, be careful with "parallel" tasks, they might be "serial". I have a "workaround" for this issue and a video about it on my channel. I use two microcontrollers: one is the master that communicates with a computer, with sensors...etc., and another is the slave that only receives commands from the master and runs the stepper motor. With this arrangement, you won't have speed issues because the slave microcontroller only handles the motor. It is a quick and dirty solution, but when a microcontroller costs 3-5 USD, it is more feasible than spending hours or days on figuring out a better code (think about the time you spend on coding and your hourly wage at a job and compare it with the cheap additional microcontroller). I am sure that a good programmer (which I am not) could figure out a better solution based on a single microcontroller. Link: ruclips.net/video/6zqq79mXjFw/видео.html
Great!!! congratulations!!! do you intend to do with two independent engines? it would be very interesting with controls for rotation, acceleration, steps, and ping pong controlling the time, totally independent.
Thank you! Maybe in the future. First, I want to do the 2-motor setup with a 3-axis joystick, then I can think about the control from a computer. I have all the parts, I am just really short on free time.
First of all I would like to thank you for being an excellent instructor. I am a old man and I learned a lot from you. But here is my problem. I am trying to build an automatic feeder for my birds. So I have 17HS4401 stepper with TB6600 motor drive running with Arduino Uno. The program works great with no load on the stepper. When I attach a a tray to the stepper probably 1 KG equally balanced the stepper goes nuts. It moves very short or very long increments. Do I need a bigger Stepper?. Please help. Andy
Hi! Thank you for the nice words! It is hard to troubleshoot it because I don't see the system. If the stepper goes nuts, try the following: run the motor without any load at the same speed that you would move the tray. When the motor runs, pinch on the shaft and try to stop it. If you can stop the motor, then the torque is low. If you can, try to increase the current (within the motor's specifications) and do the "pinching test" again. If it is still problematic, then maybe you need a larger motor, or you just need to use some gears to reduce the speed and increase the torque. Also check the microstepping. The lower the value, the higher the torque. You should get higher torque at 1/1 microstepping than at 1/16.
Thanks! I think there is a huge potential in this library, so it is worth to buy a few parts and play around with them. I will try to improve my toolbox that I wrote to control the motor from the computer. Hopefully this will also help other people to discover this area.
This bundle software/sketch is really amazing, im trying to make an automated mount for telescopes and this could be a huge help, im not the best at coding but will try to do a deep dive and try to understand/modify for that specific use. Imagine a simple goto mount for telescopes
Thanks, I am glad you like it! Check back soon again because there will be something interesting for you! I made something similar but without involving a computer. The video will be published very soon.
Hello, thanks for all the hard work you put in for these tutorials. Have a question About the a delete post lib, for the acceleration variable, once the desired speed is achieved the acceleration stops but how does the program calculates the deceleration? And is it the same rate as the acceleration ? So, when its x number of steps away from target it determins it needs to go in decel, so the trapedzoid profile is calculated by the run function?
Hi and welcome! Yes, the deceleration is the same as the acceleration, the only difference is the sign. Based on the parameters you determine for the motor, yes, the speed profile will typically have a trapezoidal shape. And yes, the Accelstepper library recalculates the values between every step when you use the run() function. By the way all these are written on the website of the Accelstepper library. Read the documentation.
Thanks for all of content related to stepper motors and TB6600. I'm building my own universal testing machine using twin ballscrews, linear rails, tb6600, and 2x arduinos. I'm a mechanical engineer by trade so the coding aspect is very alien to me but with the help of your videos I reckon I will get there in the end. I would love for you to add the real-time stress/strain graph using data from the load cell and DRO. If not then I will try to do it myself. I notice sometimes in your video you talk about getting metal parts CNC'd.. I do some CNC work myself and have access to a HAAS CNC mill.. as way of thanks for your content I could make some parts for you at cost price if you like?
Hi! Thank you for the kind words! I guess you saw that I have a tensile testing machine as well with most of the parts involved that you mentioned. In this video, I show some data with force and displacement (from the DRO): ruclips.net/video/hH5aBqoqcBE/видео.html . Also, in this video, I show a somewhat real-time data but without any units: ruclips.net/video/PNz2B1gsjtY/видео.html . I calibrated the load cell properly, so we can trust the values of it, but the DRO is still a bit problematic, so I just use it as some kind of feedback. You as a mechanical engineer might know these things better than me, so as you can see it, there are a lot of places where slack, misalignment and similar detrimental things can happen. Reading the strain by the displacement of the crossheads is not the best approach, especially with this "flexible" setup. If you can measure the compliance of the machine, then you can correct your stress and strain values and get really accurate values for them based on the crosshead displacement, but I haven't done that here. The best would be to use an extensometer for strain but the sample is too small (3-5 mm gage length). I already implemented a tiny USB microscope and a video capturing option in my tensile testing software, so I will try to measure the strain with DIC, but I do not have time to implement it. I also have 2 larger twin ball screws sitting in my wardrobe waiting for me for more than 2 years, but I haven't got the time and resources to start building it. I want to build a very tiny machine, and I also want to build a larger, desktop machine which will be more precise and stronger as well. The one that you can find on my channel is sort of a "proof of concept" and it was also a very good learning exercise for me. If you can send me an email through the contact menu on my website, I would be really thankful. I don't have the resources right now to get anything CNC'd, and I also have to draw a few more parts, but it would be nice to have you on my contact list. Also, I might be able to help you with your machine later on.
@@CuriousScientist for the first video above did you plot the graph after the test from the serial data? And for the second video how did you create the real time graph? Was this an extension of the client you created? Yes I agree that the measuring the displacement of the crosshead is not ideal and an extensometer should be used for more accurate readings.. however a DRO measuring crosshead displacement is better than purely measuring the steps taken and converting this to linear displacement I think.. if using an open loop system. Initially in my design I think I will just use the step counter to measure displacement but in future implement a DRO.. or use a hybrid stepper motor with an encoder to count the actual steps.. and maybe in the future after that I will use a servo motor. In my design I am using 6mm laser cut steel as the base plate, crosshead and top plate. I am then welding on 40mm x 20mm steel box section in order to make them stiff. Even with the welded box section I think there will still be some non-negligible deflection but I am not really looking for accuracy greater than 0.1mm or so to be honest. Why did you decide to create your own software and not use something like labview or another program that helps to create custom GUI's?
Hi! Yes, the plots for the first video in my reply were created by capturing the serial data from the Arduino. But I have a custom software for this, so it does the dirty job for me and formats and calculates everything. The real-time data was done by recording the video with a camera and at the same time I was recording the screen of my computer. Then I just synced the 2 videos. The real-time "stress-strain" curve was displayed on my custom software. I show the software in multiple videos. I am working with an open-loop control plus the DRO. It is very easy to step the motor according to the DRO, but as long as my mechanism is not so good, I just run the motor independently from the DRO. I also use 5 mm steel for most of the structural parts. Simple S355 carbon steel. I used a company called Fractory for laser cutting. They have amazing prices, and they are fast and trustworthy. I was using some very bad commercial software during my PhD and I was extremely frustrated about it. I thought I can make a better one. So, I wrote the software (Both Arduino and PC) and I built my own tensile testing machine as well. I already knew some programming and I wanted to develop my skills so I thought this would be a very good exercise. Labview is commercial, so I have to pay for it and I do not really learn what happens behind the buttons and switches. Is I write everything from scratch, I learn all the tiny details, so it is also a lifelong investment in terms of knowledge. Also, I can put in in my CV. There are not too many people around who can tell that they built an entire tensile testing system at home.
Good, you made the acceler client very convenient. I have a question. I checked that the value of the current post (steps) changed. I used the current positioni() function, but steps only expresses the final position value after the motor moves. What method can you use to display the value of change?
Hi! I don't have the code in front of me now, and it has been a while since I wrote the code so I don't remember the details perfectly. I think that the code sends the position only when the movement is finished. The reason is simple, the currentPosition() function, especially combined with a lot of serial communication can cause the motor to stutter. To get a continuous information about the position, you just need to continuously poll the currentPosition() function and send its return value to the serial port. Alternatively, add an encoder to the system.
@@CuriousScientist Is the AccelStepper library, or any library for that matter, viewable or "open source"? Can you view the functions within it? Thanks!
If I understand correctly, you mention that the "run" command results in one step per loop pass. I don't think that is correct. I think it is that as long as the loop is fast enough to provide more "run" commands per step time, the stepper keeps running. Otherwise for very slow step rates if there were one step per loop, the loop time would be extremely long. I find it to be a somewhat unusual approach but I understand why it is structured that way.
The run() function is being polled in every loop() iteration, and if a step is due, the step pin is toggled. At slow step rates, the run function might only toggle the step pin at every 100th iterations.
Ayy man, great content. that client is a legit addition to your code! Much appreciated! I think it would be cool to see Left,Right,Up,Down Arrow keys that control 2 axis/1, button for homing, "Scanning" for the MaxOrMin limits it can travel. Working on a CNC for a project, I have an Arduino controlling the motors very similar to your approach but have a raspberry pi as the main controller that talks with the Ard. How you make a client like that?
@@CuriousScientist Ahh okay, I have never dabbled with C# yet. just C++, C and Arduino's version of C. Learning python right now for raspberry Pi. But yo i'm a fan, learned alot from your videos, your content has been very helpful and informative. I am wiring up & coding the Limit Switches for the 1st time on Saturday, have never messed w/ them before. As I mentioned, I am trying to write code that will allow the motors to "Scan", so it will go from 1 limit to the other and Map the maximum distances it can travel. Do you have any suggestions for this? Like should i use some AttachInterrupts? I'm a bit worried about the Noise that ppl talk about but i got ones that apparently have an onboard RC filter soo maybe that will work combined with some PullUp pins on Arduino Mega.
If you know the syntax of C languages, C# would not be a problem, I think. The travel distance is determined by the length of the free section of the lead screw, belt...etc, so I don't really see why scanning is needed. You can just measure it. But if you want to do it anyway, the code is very simple in my opinion. Go until you hit one limit switch, set the position to zero (or store the current position), then move to the other direction until the other switch is found. Then use the stored position to calculate the travel (in steps) based on the previously stored position, or if you set the position to zero when the first limit switch was hit, then the current distance is the travel distance. Once I receive my new toy, I will upload several videos in this topic with explanations, code...etc.
@@CuriousScientist Hey, thanks for the quick replies! it's for the mechanized movement for a hydroponic vertical farm setup. There are multiple Boards that hold plants or LEDs. So I'm going to integrate an ultrasonic sensor on the X-axis Gantry plate so that when the motors are running the "Scan" function from 1 limit to the other, it will map the Board's position (Once the distance is below a certain number). This will allow me to then just choose like Board 1 on the GUI and the motors will go to it's location, attach and then extend/retract or move right/left. Thank you for the insight, had to devote last weekend to wire management so I am writing up the code as we speak and testing it tonight/tomorrow. Gonna find & watch your video for using attachInterrupt within Accelstepper and try to go that route i think.
Great Job!! When I run the motor at high speed, I have a problem with accuracy. e.g: I ask to perform 5 revolutions, then 5 more and 5 more and so on. The pin does not stop at the same place it started, even using 1/4 steps. Do you have any idea to resolve this? I was thought about every entire movement(e.g: 5 rev, or something else) back to the origin (some place that has a limit switch), so that the loss is minimal and not cumulative. Thank you!
It is maybe skipping steps. So it might be that the power is too low. Try to increase the supply voltage and/or current to see if the issue is resolved. For troubleshooting, try to set a very low stepping speed that you can easily follow and then count the steps done. Try it then with different speeds. I haven't really had precision issues except when I haven't supplied enough power to the stepper motor driver and it skipped steps.
@@CuriousScientist I think there is some problem on the beginning (maybe something related to inertia), because the shaft vibrates and seems to step back a few times haha. It's very strange.
I tried to download the Arduino Client from the link and the antivirus stopped the downloads saying it is a trojan , severe. Any help is appreciated, the client looks very nice.
I wrote the software and I can ensure that it does not contain any harmful code. Since it is a custom exe file, any antivirus (or even Windows) will mark it, as it does not exist in any database. If you don't trust it, upload the exe to any online virus scanners and check it.
Merhaba öncelikle çok iyi bir anlatım ve harika proje için teşekkür ederim, Ben c# ile aktif pozisyonu almakta sorun yaşıyorum ve paylaşılan kodlarda sadece arduino kodları var, rica etsem Windows form kodlarınızda paylaşımısınız?
Thank you for video. I need tun the nema 23 bilolar stepper with TB6600 by arduino. Can you give the code for the beliw sequence? My sequence is puls per rov. 200. I want move the stepper 0 to 54000 steps which is 270 full revolution. And take a time delay, then again return to 0 step. Repeat the cycle with a time delay.
thank you for the video - I absolutely don't understand how the .disableoutput /.enableoutput can work if the enable pin is not defined in the constructor ? or even not wired ? how the library can enable/disable the outputs just by the pulse/dir pins ? as far as my limited understanding goes - the enable/disable functionality of the library works just and only if the constructor is controlling the outputs directly (not 1 = Driver) like 4wire etc. as far as my limited understanding goes when you use a driver (constructor = 1 ) you must wire the enable signal and instead using the library .disableoput / .enableoutput you need to explicitly set the enable signal to HIGH or LOW - please correct me where i'm wrong ....
Hi! You need to add the enable pin yourself to the code. I just added the enable and disable parts to the corresponding places so the viewer can see where it makes sense to potentially use them. As you said, you need to "manually" define a digital pin as an output then use the digitalWrite() function wherever you want to en/disable the motor.
@Curious Scientist thank you for extremely prompt reply ! it could be a nice feature of the library to specify the enable pin in the constructor after the pulse & dir - this way the built in library functions .disableoutputs / .enableoutputs would continue to work even with a driver .
You're welcome! Unfortunately, I don't have any control over the accelstepper library, so I cannot implement this extra functionality. I am just a user who tries to explain his experiences with the library.
Great work, Can you make a video about how you created the client software. Is there any client software that works on Linux, I prefer linux more than windows.
Thanks! I work on Windows, so Linux is not an option for me. The client is unique in every cases, so I can't really think that there are too many of them available. Regarding your question, my answer is sorry but no. I don't make videos on request for free.
@@vineethkumar7803 Thanks! I still have a lot of things to improve. Also, I don't want to put my videos behind a pay-wall. It is free to watch RUclips videos, and if people found my videos useful, there is an option for donation. It is a win-win.
Thanks for your video great work, may i get the source code for the client tool application(Winform) i want to create my own application to work with serial communication same as you or do you have some anywhere that i can learn this thing.
Hi! The source code is not available, sorry. But I am working on a series where I teach how to communicate with a microcontroller via an application on the PC. It just takes tremendous time and effort, so it goes slowly. Please stay tuned.
Hello mate. Your application is very successful. Thank you very much for providing us. I get an error while running the application with windows 10. software error. What operating system are you running? At the same time, I could not solve the problem of motor heating. Nema23 gets very hot when not operating. Probably the code stepper.disableOutputs () is not working. What would be the reason?
Hi! Thank you for the positive words! The software is written on Windows 10 for Windows 10, so it should work. However, Windows might complain that it comes from "untrusted sources". Just click "Run anyway" and it should be fine. Other people also managed to run it, so it works. Heating issue depends on the controller and the applied current. If you run too high current through the motor, it will heat up even without moving.
@@CuriousScientist Although I allow trusted sources, I get the warning "Access to com6 connection is denied". The program freezes after this warning. As you said, it's a security related problem. I feed it on 12V. Despite this, it gets too hot to touch while standing. Thank you for your interest.
@@MrMuratx81 Denied access is usually because you already have a communication open somewhere else. If you have the Arduino IDE open and you are connected to the microcontroller, it will not let you to connect with another software. Close everything, connect the Arduino to USB then connect with my software. It should work. 79 people downloaded the software already, and I haven't received any connectivity issue related messages. The problem is now in my software. 12 V is voltage, not current. You have to check what current is enabled on the controller.
@@CuriousScientist :=) sorry 12 V is not current. 3a my current. serial port is open. I didn't notice. The problem is now fixed. Thank you so much.the program is very good.
I knew that the open connection will be the problem :) I am happy that it works. 3 A can be high and cause warming. Sometimes I also have problems with this, regardless of the controller and code I use. On the controller, set the current as low as possible/feasible. If you do not need too much torque, the current can be relatively low.
Thank you for the awesome video. The Arduino source code was very helpful and I learn a lot. Do you mind sharing the AccelStepperClinet source code? I did subscribe to your channel.
Is there any way to instantiate an AccelStepper instance conditionally? E.g. right now you (and all examples I can find) create the stepper with default or specified pins right at the start. I want to make a stepper available, but only when I receive a command specifying which pins it's on. E.g. I don't know when I start what pins the stepper is on, or if there is one at all. Then later, I get a command saying "I've connected the stepper to pins 3, and 4" and I want to start driving it from those pins at that time.
Probably it is possible, I have never tried it. But this practice might be dangerous because if you just randomly assign pins to the stepper motors, you might end up using important GPIO ports such as i2c, spi...etc pins. I wouldn't use the practice that you described.
@@CuriousScientist I have no idea how you got the idea that the pins would be assigned "randomly". Have you heard of Firmata? It is a program which allows the Arduino (or other device) to be used as an IO device, /without/ re-programming the Arduino. The assignment of pins, etc... is done by the host computer (a RasPi, PC, etc...) by sending commands to the Arduino via Firmata. So the pins are not setup "randomly", they simply aren't set inside the Arduino sketch. The AccelStepper library is not compatible with this system because it simply does not allow one to assign the pins except during the compilation of the program. Sadly, I will have to find a different library.
By random I meant that they are not assigned from the beginning but for example the user says that they want to use pin 10 and 11 for controlling the stepper motor. But this would be "dangerous" because these pins are also used by the SPI protocol. But why can't you assign the pins from the beginning? I always start with the hardware first and then go for the software. So, first check which pins you want to utilize, then write the corresponding code for it.
For anyone who wants to do this, the trick is to use the other syntax for declaring the stepper which takes a pair of functions: e.g. AccelStepper stepper(step_forward, step_back); Then you can define, in the functions, which pins to use, which gives you full control over them. e.g. int dir_pin,step_pin; void step(){ digitalWrite(step_pin, HIGH); // step HIGH delayMicroseconds(DEFAULT_STEP_DELAY_US); // Delay the minimum allowed pulse width digitalWrite(step_pin, LOW); // step LOW } void step_forward() { digitalWrite(dir_pin, HIGH); // Set direction first else get rogue pulses step(); } void step_back() { digitalWrite(dir_pin, LOW); // Set direction first else get rogue pulses step(); }
@@CuriousScientist O that’s not a good news ! Is ok still enjoy watching your videos, hopefully you will make it some other days! Thank you for making videos:)
You just add more steppers to the code and drive them accordingly. You just copy paste the control parts of the code and rename those variables which control the other motors.
@@CuriousScientist i would imagine there are a lot more lcd displays with the hitatchi controller,just seems odd going to all that work not to use possibly the most common lcd in the arduino comunity,what made you decide to use an old nokia lcd?.
The two row LCD can only display characters and the Nokia LCD can display more lines, graphical elements...etc. it is a very good display. I also had it at hand, so why not?!
@@CuriousScientist yeah...sir thank you for your response...then when are you going to release your Accelstepper client software i am eager to download sir ??
@@CuriousScientist Oh...k sir the client software had been released ....hm i didn't notice sir....."its been 2 years" and for this quote ...i just asked to you that its been 2 years ....you didn't given any update about Accl client..sir .Don't mistake me sir for that quote i just asked generally sir....Sorry...
@@CuriousScientist I'm trying to do a similar thing using processing. Can you share any of your source code? Processing works with Java so your code could help
I am sorry but the source code is not publicly available. But it basically just a graphical interface that sends a bunch of characters and numbers to the arduino, which is then processed.
Hi! I tested it right now and it works. The button should bring you to the my files.fm folder and you just have to click that huge red download button.
@@CuriousScientist I'm sorry you feel that way I love what your doing I just wish it where more accessible beyond the hobbyist world of Arduino, it was only a suggestion but my apologies if it came out the wrong way or was like many times online just read the wrong way
I found your channel today as I am working on a stepper motor project. The video is 3 years old but I see you posted some new one recently and see you have great content. I will be binge watching this weekend. you gave me some insight to the accelstepper lib so thank you.
Thanks! I hope you'll find something useful. Don't forget to look at my website, too. It has a lot of additional content.
I am watching your videos, they are excellent, I am learning a lot with you, thank you for your willingness and attention to all of us who participated and enjoyed your videos !!!!
I am having difficulties in placing two independent stepper motors, exactly to make these movements, I am also configuring a nextion 7 "screen as a manual and automatic control interface.
Thank you for your kind words! I hope that my videos can help you. I will have many more stepper motor related videos and linear motion related videos. All I need is more free time. :)
I don know what to say... EXCELENT, BRILLIANT!
Thanks!
Thanks, try to move to a location 1 and save that loc in EERom , then move to next location save the second location. Run from Boot then move to pre-saved locations
Saving the locations to EEPROM and then move there could work. It is a good idea if you stop and start somewhere else than the original home location.
Brilliant, just what I needed! I will need to work out with my belt drive gearing how to convert steps to degrees. Would be good of there was a box on screen for this. Even better would be to use a separate 4 x 4 keypad & LCD & memory to become independent of the computer. Thanks again, great tutorial.
Check my channel, I made a similar control panel that you described. Keypad, lcd, bunch of options...etc.
Excellent presentation. I hope i can use it lateron for my table saw to adjust the guide in real distance, go home, go to position in mm.
Glad it was helpful!
Great video tutorial. I to am using Accelstepper for my camera motion control system the only drawback is not being able to control two steppers at the same time with acceleration. I have overcome this on my project by using independent Nano's on each axis not ideal but I know have a modular system where I can control any number off axis wirelessly across the same or different devices.
Thanks! I believe it should work simultaneously with 2 steppers on Nano. Maybe you have a blocking code somewhere or you print on a display....etc. Alternatively, you can try faster, Arduino compatible MCUs such as the STM32F103 blue pill, or the Teensy 4.0. Teensy is super fast.
Are you a professor? you have the best explanation of code and circuitry I have seen. Great instructor. Keep up the good work. I will disable the virus program then download it. Thanks.
Thank you! I studied a lot and taught students in a lab for a year, but I am not a prof. My philosophy of learning is to be able to explain things in details so I am also sure that I understand the topic.
Great job! Thanks for all explanations and work!
Thank you very much! I am glad that you found it helpful!
Thank you for sharing this fantastic video with us
You are welcome!
Good explanations all round on all your videos. Just one thing, is the "runallowed = true" needed at all for the Relative & Absolute functions. In the previous library we need it because the RunTheMotor function was triggered by:
if (runallowed == true)
{
stepper.enableOutputs();
stepper.run();
} ............
With this code though it looks like the RunTheMotor operation "stepper.distanceToGo() != 0" doesn't need the boolean statement and only needs the following inputs:
stepper.setMaxSpeed(receivedSpeed);
stepper.move(receivedSteps);
Also is it possible to look at the AccelStepper Library directly, just curious how you got the library to work in the way it does.
Thanks! Check my more recent videos because I actually got rid of this part of the code. Also, you can simply use Google and visit the official website of the Accelstepper library where there's a very nice documentation on each classes and functions.
Thank you for this tutorial and the AccelSteppers software which works very well
I can't get the motor to work in the serial monitor with the letters "P" and "R" the ping pong works very well with the letter "K"
You are welcome! Probably you do not send the commands properly. As you can see it in the video, it works for me.
old but gold ! subscribed 🙏 would be epic to see a video using the TMC2209
Thanks! I would love to try those drivers, but they are very expensive.
Thank you very sharing the sharing the code and control software of your project. It helps me a lot in understanding the accelstepper library. Could you please provide visual studio program in which you created GUI app? I want to modify the GUI according to my requirements. Waiting for your reply. Thanks!
Hi! I am glad that the video was useful to you. Sorry, but the source code of my software is not public.
@@CuriousScientist Ok. I understand. Thank you for the reply!
Hi, I have just come across your fantastic channel and now your web site. I have just started building a model railway and one of the things I am researching is an "automated turntable". This enables you turn a locomotive around and to park locomotives in different sheds. I intend to use a Nema 17 to directly spin the turntable and to control the Nema via and Arduino. I will need stop the turntable at precise locations so that the central track lines up perfectly with the track going to the parking bays.
So I will look to change the number of steps to predefined positions that match each of the tracks. I was initially thinking of rotary switch to select each parking bay or the home position, but the graphical interface you have would be perfect, with the following addition. It would be nice to replace the numeric display of the current position with a simple graphic of the turntable, moving to the selected position. I hope you can imagine what I am trying to describe. Could you help me with the changes required to the interface?
Another approach would be to use a set of leds and buttons on a circular board, with each button set to a specific position. The leds would light up when the turntable is in the requested position. Is it possible to have a number of push buttons with each button representing a specific position?
Would it be possible to communicate directly with you some how?
Thanks again for your work. The first thing I did after seeing your videos was to Subscribe. Thanks.
Hi! Thank you! I am glad that you found my channel! I have a contact page on my website, you can find the way to directly reach me.
@@CuriousScientist Great, I have sent an email via the web site.
Thanks, I will read it and reply tonight after I finished at my job.
clear explanation, the app to control is also clear.
Do you have an example of how I can do this control via an HMI?
Thanks! I will implement something similar for a DWIN display. Probably will be published in a few months. Stay tuned! ;)
Great work, thanks!
Could you create video on how to control three stepper motor using this library?
Hi! Thanks!
For some reason, I cannot see my previous answer. I already made a video with 2 motors. It is not that difficult to figure the things out for 3 motor.
This is the video: ruclips.net/video/Xf39xbopAFM/видео.html
Thx for the software and very good video. :-)
How about adding 4 push-buttons to the arduino and mapping them up in the software. Exp. Push button one to goto 8000 push button 2 to go -4000 etc. :-) Is that doable?
Hi, and thank you! Sure, the buttons are easy to implement! I might do some updates to this software in the future and then implement these things.
Great job! Thank you so mutch. Can you provide the code of the Client for Windows? Or the sintax of string that you send over serial?
Hi! Sorry, but the client code is not public. The syntax is in the Arduino code, please read it.
I would be happy if you could show hot to implement function like setting zero position of the motor without using limit switch, for example manually moving the motor till finding a desired position and setting it as home position so that if we accidentaly press a negative value we dont pass that point
I have other videos where I show how this can be done. Check my stepper motor control panel videos.
Very very useful tutorial👍
Thank you very much!
Awesome!! This is great. Thank you so much. I learned alot of things from your video. I am trying to controlling six stepmotor for my robotic arm. Great work.. I wanna to see more and I am watching your other videos.
Thank you! There is, and there will be a lot of stepper motor related videos on my channel!
Good work, explained very well, I liked your software
Thank you!
Once in a blue moon RUclips algorithms provide some great content, and this is such a case! I’m in research mode before building a camera slider and this would be great for that. My goal is to have several keyframes that the slider will move between and it would be great to be able to choose the type of ease in/out. Right now it looks like there is only one value for in and out? Have liked and subscribed 👍🏼
Hi! Thank you very much! If you want to build a camera slider, you might be interested in this video: ruclips.net/video/UojoDm1oZrU/видео.html
Especially check the goTo() function and the pingpong() function.
@@CuriousScientist Thanks. I will take a look 👍🏻
Where did you do your interface to direct your arduino? I think it's C#. Btw your all videos are so amazing. Im so thankful for this.
Thanks! C#, indeed. And I used Microsoft Visual Studio to write the software.
@@CuriousScientist can you provide some further information how you did that ? Your code is awesome and I learned a lot, but I want to modify the code and the GUI to control several Stepper.
It is just a simple GUI where I placed a few controls which send some message to the serial terminal. It is not very complicated, you just need to make sure that the receiver (Arduino) knows how to interpret the commands.
a very good video and well explained
This video was cnc /3d printer x y z with accurate positioning ect but could you show an example of a position from an out side program that is all ways up dating where the position should be
example DCS (digital combat simulator) a flight sim game, going into a second program Sim Tools which is extracting all the flight telemetry. lets say just the roll of the aircraft .
the out-put from sim tools minus 32767 (180 degree bank left) 0 (which is wing level) positive 32767 which is (180 degree bank right)
The problem is when you do a complete roll so lets say bank to the right . the counter gets to +32767 (wings level but upside down) then is has to move to minus 32767 and count down until it gets to zero But because the motor can not keep up with the game all the time and a new value comes in be for it has completed its move and makes it stop its full roll and continue with the new input position.
This has been my challenge for years, I have a working code but it very lumpy .There seams to be a very big market for arduino code that is easy to understand to make diy stimulators work
in my case would i use move (x) or move to (x) or an interrupt or a pingpong sort of thing Just wish i had something between the ears that makes it look as easy as your video to wright code
Thank you very much for posting video i now have lots more to think about
Thank you! If the motor cannot keep up with the incoming values, I think it is something wrong with the software. Maybe the processing of the values is not coded efficiently. I hope you find the solution.
Nice project. Are you able to use this in the case of non-blocking and tracking movements? I'm looking to update the position in real-time, and the motor slews to this new position. Sometimes a new fixed position will be ordered (ie move to 255 degrees) or perhaps relative (+15degrees), which will countermand the previous order issued that may not have been completed. Not sure how to implement this without movement that stutters and jolts the motor - which must be avoided. I'm wanting smooth accelerations and decelerations (even in cases of change of direction). My project is to move a homemade observatory dome to orientate the dome window to match the telescope angle of sight. Most of the time movements are slow, but they are always slaved to match the position of the telescope. During some star-seeking movements or perhaps tracking the ISS, the movements require very rapid updates. I currently limit the updates to >ABS(5degrees), too much time is wasted. Using an ESP32 processor with Arduino SDK C++ with the standard AccelStepper library. My current setup works for linear single step instructions, but this is limiting. Any advice or pointers on non-blocking updates would be appreciated.
Great videos - keep them coming. regs Rob
Hi Bob,
First, I recommend studying the well-written documentation of the AccelStepper library itself. There are multiple functions to run a stepper motor in different ways and some of them are blocking, some of them are not. Actually, these (blocking or non-blocking) are stated in the descriptions of the functions. The simple run() function is for example non-blocking. You give a relative (move()) or absolute (moveTo()) target to the code, and then the run() function does its job in the main loop() of the code. Whenever a step is due according to the set speed and acceleration values, the code will perform a step when the code reaches the run() function.
What many people miss is that they can still block this non-blocking function. If you are reading a sensor or doing something else that takes more time than the time between two step pulses, the motor will start stuttering, and it will either skip steps or mess up the speed of the motor and cause jerky motion. So, be careful with "parallel" tasks, they might be "serial".
I have a "workaround" for this issue and a video about it on my channel. I use two microcontrollers: one is the master that communicates with a computer, with sensors...etc., and another is the slave that only receives commands from the master and runs the stepper motor. With this arrangement, you won't have speed issues because the slave microcontroller only handles the motor. It is a quick and dirty solution, but when a microcontroller costs 3-5 USD, it is more feasible than spending hours or days on figuring out a better code (think about the time you spend on coding and your hourly wage at a job and compare it with the cheap additional microcontroller). I am sure that a good programmer (which I am not) could figure out a better solution based on a single microcontroller. Link: ruclips.net/video/6zqq79mXjFw/видео.html
Hi, isn’t there necessary to connect some resistors in series to the driver’s signal input?
Hi! No, when VCC is 5 V (which is the case in all of my demos). If it is more than that, you'll need current limiting resistors. Source: datasheet.
Great!!! congratulations!!! do you intend to do with two independent engines? it would be very interesting with controls for rotation, acceleration, steps, and ping pong controlling the time, totally independent.
Thank you! Maybe in the future. First, I want to do the 2-motor setup with a 3-axis joystick, then I can think about the control from a computer. I have all the parts, I am just really short on free time.
Very interested in the AcellStepper Client. Where can i get a copy of this.
Thanks! You should watch the video more carefully as well as read the description.
First of all I would like to thank you for being an excellent instructor. I am a old man and I learned a lot from you. But here is my problem. I am trying to build an automatic feeder for my birds. So I have 17HS4401 stepper with TB6600 motor drive running with Arduino Uno. The program works great with no load on the stepper. When I attach a a tray to the stepper probably 1 KG equally balanced the stepper goes nuts. It moves very short or very long increments. Do I need a bigger Stepper?. Please help.
Andy
Hi! Thank you for the nice words! It is hard to troubleshoot it because I don't see the system. If the stepper goes nuts, try the following: run the motor without any load at the same speed that you would move the tray. When the motor runs, pinch on the shaft and try to stop it. If you can stop the motor, then the torque is low. If you can, try to increase the current (within the motor's specifications) and do the "pinching test" again. If it is still problematic, then maybe you need a larger motor, or you just need to use some gears to reduce the speed and increase the torque. Also check the microstepping. The lower the value, the higher the torque. You should get higher torque at 1/1 microstepping than at 1/16.
Great presentation, as always. Now this makes me want to buy the parts to try it myself :)
Thanks! I think there is a huge potential in this library, so it is worth to buy a few parts and play around with them. I will try to improve my toolbox that I wrote to control the motor from the computer. Hopefully this will also help other people to discover this area.
Keep up the good work man... really impressive
Thanks a lot! I will make more videos in this topic, stay tuned!
This bundle software/sketch is really amazing, im trying to make an automated mount for telescopes and this could be a huge help, im not the best at coding but will try to do a deep dive and try to understand/modify for that specific use.
Imagine a simple goto mount for telescopes
Thanks, I am glad you like it! Check back soon again because there will be something interesting for you! I made something similar but without involving a computer. The video will be published very soon.
@@CuriousScientist Thank you very much, sure i will check it i have already subscribed :D
Thanks for the subscription! I hope you will find some useful projects.
Can you please share source code or the toolbox in visual studio. Ur video is very informative for me.
Hi! Sorry, but the source code is not available, but only the compiled software.
@@CuriousScientist ok, thankyou for your replay.
Hello, thanks for all the hard work you put in for these tutorials. Have a question About the a delete post lib, for the acceleration variable, once the desired speed is achieved the acceleration stops but how does the program calculates the deceleration? And is it the same rate as the acceleration ? So, when its x number of steps away from target it determins it needs to go in decel, so the trapedzoid profile is calculated by the run function?
Hi and welcome! Yes, the deceleration is the same as the acceleration, the only difference is the sign. Based on the parameters you determine for the motor, yes, the speed profile will typically have a trapezoidal shape. And yes, the Accelstepper library recalculates the values between every step when you use the run() function. By the way all these are written on the website of the Accelstepper library. Read the documentation.
Thanks for all of content related to stepper motors and TB6600. I'm building my own universal testing machine using twin ballscrews, linear rails, tb6600, and 2x arduinos. I'm a mechanical engineer by trade so the coding aspect is very alien to me but with the help of your videos I reckon I will get there in the end. I would love for you to add the real-time stress/strain graph using data from the load cell and DRO. If not then I will try to do it myself. I notice sometimes in your video you talk about getting metal parts CNC'd.. I do some CNC work myself and have access to a HAAS CNC mill.. as way of thanks for your content I could make some parts for you at cost price if you like?
Hi! Thank you for the kind words! I guess you saw that I have a tensile testing machine as well with most of the parts involved that you mentioned. In this video, I show some data with force and displacement (from the DRO): ruclips.net/video/hH5aBqoqcBE/видео.html . Also, in this video, I show a somewhat real-time data but without any units: ruclips.net/video/PNz2B1gsjtY/видео.html . I calibrated the load cell properly, so we can trust the values of it, but the DRO is still a bit problematic, so I just use it as some kind of feedback. You as a mechanical engineer might know these things better than me, so as you can see it, there are a lot of places where slack, misalignment and similar detrimental things can happen. Reading the strain by the displacement of the crossheads is not the best approach, especially with this "flexible" setup. If you can measure the compliance of the machine, then you can correct your stress and strain values and get really accurate values for them based on the crosshead displacement, but I haven't done that here. The best would be to use an extensometer for strain but the sample is too small (3-5 mm gage length). I already implemented a tiny USB microscope and a video capturing option in my tensile testing software, so I will try to measure the strain with DIC, but I do not have time to implement it. I also have 2 larger twin ball screws sitting in my wardrobe waiting for me for more than 2 years, but I haven't got the time and resources to start building it. I want to build a very tiny machine, and I also want to build a larger, desktop machine which will be more precise and stronger as well. The one that you can find on my channel is sort of a "proof of concept" and it was also a very good learning exercise for me.
If you can send me an email through the contact menu on my website, I would be really thankful. I don't have the resources right now to get anything CNC'd, and I also have to draw a few more parts, but it would be nice to have you on my contact list. Also, I might be able to help you with your machine later on.
@@CuriousScientist for the first video above did you plot the graph after the test from the serial data? And for the second video how did you create the real time graph? Was this an extension of the client you created? Yes I agree that the measuring the displacement of the crosshead is not ideal and an extensometer should be used for more accurate readings.. however a DRO measuring crosshead displacement is better than purely measuring the steps taken and converting this to linear displacement I think.. if using an open loop system. Initially in my design I think I will just use the step counter to measure displacement but in future implement a DRO.. or use a hybrid stepper motor with an encoder to count the actual steps.. and maybe in the future after that I will use a servo motor.
In my design I am using 6mm laser cut steel as the base plate, crosshead and top plate. I am then welding on 40mm x 20mm steel box section in order to make them stiff. Even with the welded box section I think there will still be some non-negligible deflection but I am not really looking for accuracy greater than 0.1mm or so to be honest.
Why did you decide to create your own software and not use something like labview or another program that helps to create custom GUI's?
Hi! Yes, the plots for the first video in my reply were created by capturing the serial data from the Arduino. But I have a custom software for this, so it does the dirty job for me and formats and calculates everything. The real-time data was done by recording the video with a camera and at the same time I was recording the screen of my computer. Then I just synced the 2 videos. The real-time "stress-strain" curve was displayed on my custom software. I show the software in multiple videos. I am working with an open-loop control plus the DRO. It is very easy to step the motor according to the DRO, but as long as my mechanism is not so good, I just run the motor independently from the DRO.
I also use 5 mm steel for most of the structural parts. Simple S355 carbon steel. I used a company called Fractory for laser cutting. They have amazing prices, and they are fast and trustworthy.
I was using some very bad commercial software during my PhD and I was extremely frustrated about it. I thought I can make a better one. So, I wrote the software (Both Arduino and PC) and I built my own tensile testing machine as well. I already knew some programming and I wanted to develop my skills so I thought this would be a very good exercise. Labview is commercial, so I have to pay for it and I do not really learn what happens behind the buttons and switches. Is I write everything from scratch, I learn all the tiny details, so it is also a lifelong investment in terms of knowledge. Also, I can put in in my CV. There are not too many people around who can tell that they built an entire tensile testing system at home.
Keep it up!
Thanks! I will try to do my best.
I Subscribed ;:) thanks for great video i learn a lot
Thank you!
Good, you made the acceler client very convenient.
I have a question.
I checked that the value of the current post (steps) changed.
I used the current positioni() function, but steps only expresses the final position value after the motor moves.
What method can you use to display the value of change?
Hi! I don't have the code in front of me now, and it has been a while since I wrote the code so I don't remember the details perfectly. I think that the code sends the position only when the movement is finished. The reason is simple, the currentPosition() function, especially combined with a lot of serial communication can cause the motor to stutter. To get a continuous information about the position, you just need to continuously poll the currentPosition() function and send its return value to the serial port. Alternatively, add an encoder to the system.
Very nice! Thank you! Are you the author of the AccelStepper library? Thanks
Thanks! No, unfortunately, I am not the author. I just try to make it more popular and accessible by making some fun projects based on it.
@@CuriousScientist Is the AccelStepper library, or any library for that matter, viewable or "open source"? Can you view the functions within it? Thanks!
Sure.
Thanks Mate. Helps alot! Keep it up!
Thank you!
If I understand correctly, you mention that the "run" command results in one step per loop pass. I don't think that is correct. I think it is that as long as the loop is fast enough to provide more "run" commands per step time, the stepper keeps running. Otherwise for very slow step rates if there were one step per loop, the loop time would be extremely long. I find it to be a somewhat unusual approach but I understand why it is structured that way.
The run() function is being polled in every loop() iteration, and if a step is due, the step pin is toggled. At slow step rates, the run function might only toggle the step pin at every 100th iterations.
Ayy man, great content. that client is a legit addition to your code! Much appreciated! I think it would be cool to see Left,Right,Up,Down Arrow keys that control 2 axis/1, button for homing, "Scanning" for the MaxOrMin limits it can travel. Working on a CNC for a project, I have an Arduino controlling the motors very similar to your approach but have a raspberry pi as the main controller that talks with the Ard. How you make a client like that?
Thanks, I will consider these ideas in the next version. The client software is written in C# using MS Visual Studio.
@@CuriousScientist Ahh okay, I have never dabbled with C# yet. just C++, C and Arduino's version of C. Learning python right now for raspberry Pi. But yo i'm a fan, learned alot from your videos, your content has been very helpful and informative. I am wiring up & coding the Limit Switches for the 1st time on Saturday, have never messed w/ them before. As I mentioned, I am trying to write code that will allow the motors to "Scan", so it will go from 1 limit to the other and Map the maximum distances it can travel. Do you have any suggestions for this? Like should i use some AttachInterrupts? I'm a bit worried about the Noise that ppl talk about but i got ones that apparently have an onboard RC filter soo maybe that will work combined with some PullUp pins on Arduino Mega.
If you know the syntax of C languages, C# would not be a problem, I think. The travel distance is determined by the length of the free section of the lead screw, belt...etc, so I don't really see why scanning is needed. You can just measure it. But if you want to do it anyway, the code is very simple in my opinion. Go until you hit one limit switch, set the position to zero (or store the current position), then move to the other direction until the other switch is found. Then use the stored position to calculate the travel (in steps) based on the previously stored position, or if you set the position to zero when the first limit switch was hit, then the current distance is the travel distance. Once I receive my new toy, I will upload several videos in this topic with explanations, code...etc.
@@CuriousScientist Hey, thanks for the quick replies! it's for the mechanized movement for a hydroponic vertical farm setup. There are multiple Boards that hold plants or LEDs. So I'm going to integrate an ultrasonic sensor on the X-axis Gantry plate so that when the motors are running the "Scan" function from 1 limit to the other, it will map the Board's position (Once the distance is below a certain number). This will allow me to then just choose like Board 1 on the GUI and the motors will go to it's location, attach and then extend/retract or move right/left. Thank you for the insight, had to devote last weekend to wire management so I am writing up the code as we speak and testing it tonight/tomorrow. Gonna find & watch your video for using attachInterrupt within Accelstepper and try to go that route i think.
wow, excellent Job!
I was hoping that you'll like it!
Great Job!!
When I run the motor at high speed, I have a problem with accuracy.
e.g: I ask to perform 5 revolutions, then 5 more and 5 more and so on. The pin does not stop at the same place it started, even using 1/4 steps.
Do you have any idea to resolve this? I was thought about every entire movement(e.g: 5 rev, or something else) back to the origin (some place that has a limit switch), so that the loss is minimal and not cumulative.
Thank you!
It is maybe skipping steps. So it might be that the power is too low. Try to increase the supply voltage and/or current to see if the issue is resolved. For troubleshooting, try to set a very low stepping speed that you can easily follow and then count the steps done. Try it then with different speeds. I haven't really had precision issues except when I haven't supplied enough power to the stepper motor driver and it skipped steps.
@@CuriousScientist thank you! I’ll try this.
@@CuriousScientist I think there is some problem on the beginning (maybe something related to inertia), because the shaft vibrates and seems to step back a few times haha. It's very strange.
@@pisobre2 have you tried to play around with the acceleration values as well?
I tried to download the Arduino Client from the link and the antivirus stopped the downloads saying it is a trojan , severe. Any help is appreciated, the client looks very nice.
I wrote the software and I can ensure that it does not contain any harmful code. Since it is a custom exe file, any antivirus (or even Windows) will mark it, as it does not exist in any database. If you don't trust it, upload the exe to any online virus scanners and check it.
Merhaba öncelikle çok iyi bir anlatım ve harika proje için teşekkür ederim, Ben c# ile aktif pozisyonu almakta sorun yaşıyorum ve paylaşılan kodlarda sadece arduino kodları var, rica etsem Windows form kodlarınızda paylaşımısınız?
Hi! Sorry, I don't understand!
@@CuriousScientist C# Code please
The code is not available, only the exe file.
What software name
Can you software for me?
Thanks you very much
Hi! Watch the video and read the description more carefully!
Thank you for video. I need tun the nema 23 bilolar stepper with TB6600 by arduino.
Can you give the code for the beliw sequence?
My sequence is puls per rov. 200.
I want move the stepper 0 to 54000 steps which is 270 full revolution. And take a time delay, then again return to 0 step. Repeat the cycle with a time delay.
Hi! If you want me to write a code for you, you can hire me for work. You find my email on my website.
thank you for the video - I absolutely don't understand how the .disableoutput /.enableoutput can work if the enable pin is not defined in the constructor ? or even not wired ? how the library can enable/disable the outputs just by the pulse/dir pins ? as far as my limited understanding goes - the enable/disable functionality of the library works just and only if the constructor is controlling the outputs directly (not 1 = Driver) like 4wire etc. as far as my limited understanding goes when you use a driver (constructor = 1 ) you must wire the enable signal and instead using the library .disableoput / .enableoutput you need to explicitly set the enable signal to HIGH or LOW - please correct me where i'm wrong ....
Hi! You need to add the enable pin yourself to the code. I just added the enable and disable parts to the corresponding places so the viewer can see where it makes sense to potentially use them. As you said, you need to "manually" define a digital pin as an output then use the digitalWrite() function wherever you want to en/disable the motor.
@Curious Scientist thank you for extremely prompt reply ! it could be a nice feature of the library to specify the enable pin in the constructor after the pulse & dir - this way the built in library functions .disableoutputs / .enableoutputs would continue to work even with a driver .
You're welcome! Unfortunately, I don't have any control over the accelstepper library, so I cannot implement this extra functionality. I am just a user who tries to explain his experiences with the library.
Great work, Can you make a video about how you created the client software. Is there any client software that works on Linux, I prefer linux more than windows.
Thanks! I work on Windows, so Linux is not an option for me. The client is unique in every cases, so I can't really think that there are too many of them available. Regarding your question, my answer is sorry but no. I don't make videos on request for free.
@@CuriousScientist on what platform this client is made
@@vineethkumar7803 MS Visual Studio. Written in C#.
@@CuriousScientist bro your content is great, you should start Udemy course
@@vineethkumar7803 Thanks! I still have a lot of things to improve. Also, I don't want to put my videos behind a pay-wall. It is free to watch RUclips videos, and if people found my videos useful, there is an option for donation. It is a win-win.
Thanks for your video great work, may i get the source code for the client tool application(Winform) i want to create my own application to work with serial communication same as you or do you have some anywhere that i can learn this thing.
Hi!
The source code is not available, sorry. But I am working on a series where I teach how to communicate with a microcontroller via an application on the PC. It just takes tremendous time and effort, so it goes slowly. Please stay tuned.
Hello mate. Your application is very successful. Thank you very much for providing us. I get an error while running the application with windows 10. software error. What operating system are you running? At the same time, I could not solve the problem of motor heating. Nema23 gets very hot when not operating. Probably the code stepper.disableOutputs () is not working. What would be the reason?
Hi! Thank you for the positive words! The software is written on Windows 10 for Windows 10, so it should work. However, Windows might complain that it comes from "untrusted sources". Just click "Run anyway" and it should be fine. Other people also managed to run it, so it works. Heating issue depends on the controller and the applied current. If you run too high current through the motor, it will heat up even without moving.
@@CuriousScientist Although I allow trusted sources, I get the warning "Access to com6 connection is denied". The program freezes after this warning. As you said, it's a security related problem. I feed it on 12V. Despite this, it gets too hot to touch while standing. Thank you for your interest.
@@MrMuratx81 Denied access is usually because you already have a communication open somewhere else. If you have the Arduino IDE open and you are connected to the microcontroller, it will not let you to connect with another software. Close everything, connect the Arduino to USB then connect with my software. It should work. 79 people downloaded the software already, and I haven't received any connectivity issue related messages. The problem is now in my software.
12 V is voltage, not current. You have to check what current is enabled on the controller.
@@CuriousScientist :=) sorry 12 V is not current. 3a my current.
serial port is open. I didn't notice. The problem is now fixed. Thank you so much.the program is very good.
I knew that the open connection will be the problem :) I am happy that it works. 3 A can be high and cause warming. Sometimes I also have problems with this, regardless of the controller and code I use. On the controller, set the current as low as possible/feasible. If you do not need too much torque, the current can be relatively low.
Dear sir
how to download your Accel Stepper client tool box ?
It's on my website.
Thank you for the awesome video. The Arduino source code was very helpful and I learn a lot. Do you mind sharing the AccelStepperClinet source code? I did subscribe to your channel.
Hi and you're welcome. The client's executable file is shared on my website, but the source code is not available for free.
@@CuriousScientist Hi awesome info on your videos, if the source code is not available for free how much would it be to buy a copy from you, Thanks
Is there any way to instantiate an AccelStepper instance conditionally? E.g. right now you (and all examples I can find) create the stepper with default or specified pins right at the start. I want to make a stepper available, but only when I receive a command specifying which pins it's on. E.g. I don't know when I start what pins the stepper is on, or if there is one at all. Then later, I get a command saying "I've connected the stepper to pins 3, and 4" and I want to start driving it from those pins at that time.
Probably it is possible, I have never tried it. But this practice might be dangerous because if you just randomly assign pins to the stepper motors, you might end up using important GPIO ports such as i2c, spi...etc pins. I wouldn't use the practice that you described.
@@CuriousScientist I have no idea how you got the idea that the pins would be assigned "randomly". Have you heard of Firmata? It is a program which allows the Arduino (or other device) to be used as an IO device, /without/ re-programming the Arduino. The assignment of pins, etc... is done by the host computer (a RasPi, PC, etc...) by sending commands to the Arduino via Firmata. So the pins are not setup "randomly", they simply aren't set inside the Arduino sketch. The AccelStepper library is not compatible with this system because it simply does not allow one to assign the pins except during the compilation of the program. Sadly, I will have to find a different library.
By random I meant that they are not assigned from the beginning but for example the user says that they want to use pin 10 and 11 for controlling the stepper motor. But this would be "dangerous" because these pins are also used by the SPI protocol. But why can't you assign the pins from the beginning? I always start with the hardware first and then go for the software. So, first check which pins you want to utilize, then write the corresponding code for it.
For anyone who wants to do this, the trick is to use the other syntax for declaring the stepper which takes a pair of functions: e.g.
AccelStepper stepper(step_forward, step_back);
Then you can define, in the functions, which pins to use, which gives you full control over them. e.g.
int dir_pin,step_pin;
void step(){
digitalWrite(step_pin, HIGH); // step HIGH
delayMicroseconds(DEFAULT_STEP_DELAY_US); // Delay the minimum allowed pulse width
digitalWrite(step_pin, LOW); // step LOW
}
void step_forward() {
digitalWrite(dir_pin, HIGH); // Set direction first else get rogue pulses
step();
}
void step_back() {
digitalWrite(dir_pin, LOW); // Set direction first else get rogue pulses
step();
}
Thank you for sharing this!
Hi very nice! If you can make a 2 motor with teach function and cycle on it?
Hi and thanks! Yes, I can.
@@CuriousScientist really! That will be really great! Can’t wait to watch this video!
I didn't say I will do it. I just answered your question regarding whether I can do it or not. Sorry, but I don't make videos on requests.
@@CuriousScientist O that’s not a good news ! Is ok still enjoy watching your videos, hopefully you will make it some other days! Thank you for making videos:)
are these drivers better than the pololua4988 drivers?.
Definitely! They can drive bigger motors.
I am following your very informative and very descriptive videos. I ask you for the AccelStepper Client software, is it possible ? thanks
Thanks! Check the description!
@@CuriousScientist subscribe to your channel but I can't find it
@@ercyzk There is a *HUGE* button on my website saying AccelStepper Client. It should not be that difficult.
@@CuriousScientist Ok, but Windows 10 does not allow your software to open due of the virus threat! Have u got any ideas?
@@ercyzk just open it. You can neglect the message and open it anyway.
what about multi stepper like 2 or 3 steppers
You just add more steppers to the code and drive them accordingly. You just copy paste the control parts of the code and rename those variables which control the other motors.
Can you share the source code of AccelStepperClient?
Sorry, but only the exe file is available.
have you code to use a normal 2 row lcd display and not the nokia one?.
Hi! No, I don't. It would be a waste of time for me to develop it for several displays.
@@CuriousScientist i would imagine there are a lot more lcd displays with the hitatchi controller,just seems odd going to all that work not to use possibly the most common lcd in the arduino comunity,what made you decide to use an old nokia lcd?.
The two row LCD can only display characters and the Nokia LCD can display more lines, graphical elements...etc. it is a very good display. I also had it at hand, so why not?!
@@CuriousScientist i see your logic there,i would of done the same,i have a nokia display but its connections are way to small for me to solder.
@@CuriousScientist is it a nokia 5110? screen.
I need the code that you have written
Watch the video carefully.
can it connected to plc?
This is a closed system. Computer - Arduino - TB6600. No other units are involved.
sir where i have to download the Accelstepper client ?
Watch the video and read the description carefully!
@@CuriousScientist yeah...sir thank you for your response...then when are you going to release your Accelstepper client software i am eager to download sir ??
@@CuriousScientist its been 2 years sir ...
It has been released together with the video. And what do you mean by "its been 2 years", what is this demanding tone?
@@CuriousScientist Oh...k sir the client software had been released ....hm i didn't notice sir....."its been 2 years" and for this quote ...i just asked to you that its been 2 years ....you didn't given any update about Accl client..sir .Don't mistake me sir for that quote i just asked generally sir....Sorry...
Can you comment on how you wrote your exe?
Hi! I made it in Microsoft Visual Studio using C#.
@@CuriousScientist I'm trying to do a similar thing using processing. Can you share any of your source code? Processing works with Java so your code could help
I am sorry but the source code is not publicly available. But it basically just a graphical interface that sends a bunch of characters and numbers to the arduino, which is then processed.
Sir , i am unable to download the Client...link is broken might be!!!
Hi! I tested it right now and it works. The button should bring you to the my files.fm folder and you just have to click that huge red download button.
Yeahh..I can access this link only with VPN. In my country
why not make this library in pure C and remove the Arduino dependency so it can be used with infinitely more microcontrollers
Maybe because I don't have time for it? :)
Well that's no way to get a supporter
I am not relying on any supporters. If you don't like what I am doing, just find another content creator. Have a nice day!
@@CuriousScientist I'm sorry you feel that way I love what your doing I just wish it where more accessible beyond the hobbyist world of Arduino, it was only a suggestion but my apologies if it came out the wrong way or was like many times online just read the wrong way