Great video as always. It's possible to use a cheap hall effect sensor and a small neodymium magnet as a limit switch to avoid any mechanical failure.
@CuriousScientist3 жыл бұрын
Thank you! Yes, a Hall sensor would provide a contactless switching possibilities!
@tedwakefield10854 жыл бұрын
This code works with my a4988 driver and belt driven gantry (with tweaks for steps/mm) and thank you. I was pulling my hair out looking for exactly this functionality. I deleted the malarkey regarding LEDs. Anyone looking to control a linear actuator can take this code and run with it even if they're an arduino noob like me.
@CuriousScientist4 жыл бұрын
Thank you very much for your positive feedback! My intention with the whole channel is exactly this! I want to provide knowledge in a form that is easy to understand and easy to work with. I am very happy that the code worked for you and you could use it for your own project. Don't forget to subscribe, if you haven't done it already. More stepper motor related videos are on their way, I am just waiting for some parts.
@dsbupadrasta23852 жыл бұрын
Kudos to you. Really informative.
@CuriousScientist2 жыл бұрын
Thank you!
@kavorka88553 жыл бұрын
The wobbling, which is a huge issue, is actually because of the quality of the Chinese parts. I too have similar issue. I am not saying parts make in China are all the same, but these are the affordable ones from Amazon or Aliexpress.
@CuriousScientist3 жыл бұрын
Yeah, but I also barely put any effort into properly assembling a nice carriage. I did not have too many parts for the demo, so I had to use what I had.
@petergrant4302 жыл бұрын
Great video. I would like to count the revolutions. I'm building a winder and have to have for instance 150 windings on my probe, it varies from probe to probe. I am beginner with Arduino. don't know how to do it. Like your videos very much. Thank you, learn a lot.
@CuriousScientist2 жыл бұрын
Hi and thanks. I built a coil winder and published everything, check my channel and website for the resources.
@zachshellouff72053 жыл бұрын
you are correct, delay() does not work in an ISR function. I believe you can use delayMillis() or whatever function is closest to that spelling
@CuriousScientist3 жыл бұрын
No, you should not use any delays, at all.
@rjayabharath5 ай бұрын
HI, Just a question, is it possible to use the acceleration and deceleration in example. seems the setspeed() is not using it.
@CuriousScientist5 ай бұрын
Hi! Sure it is possible.
@jasenolan7357 Жыл бұрын
Thanks for sharing the video and your code. Would you be able to make a suggestion on how to adjust the code so that it works from buttons instead of the serial monitor? I just want to truncate it to a momentary button for homing, and one each for fast positive/negative movement and slow positive/negative movement while button pressed.
@CuriousScientist Жыл бұрын
I made a control panel for stepper motors based on buttons and other controllers. Search for it on my channel and website.
@kamleshpanchal86612 жыл бұрын
Give me help , my question is that ln holding ( means stop ) condition stepper motor draw current which is not good for my product , my product has holding time 1 hrs and running time 3 second . So how to solve my problem please reply me
@CuriousScientist2 жыл бұрын
I already replied in another comment.
@freytube111 ай бұрын
good video. i have been using your code thanks.. have not gotten over the limit switch bouncing issue yet. can you share where you bought the microswitch with its board? thanks
@CuriousScientist11 ай бұрын
Hi! It is on my website under the parts & tools page. Check it!
@freytube111 ай бұрын
great thank you @@CuriousScientist
@CuriousScientist11 ай бұрын
It is my pleasure!
@rawcow24964 жыл бұрын
Hi, Thank you for your 2 videos on this setup, it's pretty much what I have for my project. My question is how are the limit switch wired (can't make out from the vid), I have the same limit switches but can't make them work. I assume you are using just the green and red wires. Also, I want to use an external timer to start and stop the motor, opposed to using keyboard commands, to reverse the direction twice a day to open and close a small hatch (door), any suggestions?
@CuriousScientist4 жыл бұрын
Hi! I am glad that it helped you! In this video, I just wired the black (GND) and green (signal, D2) pins and that's all. It is not the best practice, but it worked. I have a more recent video, where I show a sort of a ping pong game with 2 limit switches, you might want to check that out for some extra knowledge. There, I wired all 3 wires (red: 5 V, black: GND, green: signal) For the timer-related question, check my video where I built a real-time clock based plant watering circuit. If you combine that with the stepper motor controller, you get what you want. But to make it more simple, you don't need an external timer. Twice a day, that can be fitted in the millis() function very easily. Start two timers when you start the arduino. You need two if() statements which are checking the time. Something like this: if(time1 > 80000) { runmotor(); restartTime1(); } if(time2 > 80000) { runmotor (); restartTime2(); } This is a very simple algorithm and it does not need any external units.
@thomashawk578824 күн бұрын
without tension, do you know if the middle part can move freely ?
@CuriousScientist24 күн бұрын
What do you mean by "middle part"?
@thomashawk578824 күн бұрын
@CuriousScientist i mean the part moins on the axis thanks to the motor
@CuriousScientist24 күн бұрын
Ah, you mean the leadscrew nut. You need to spin the leadscrew to make the nut move. It is self-locking to some extent due to the friction of the threads.
@Psihopatim4 жыл бұрын
Hello. Thank you very much for the tutorials!!! I learned a lot from your videos and sketches you make! I have a question. How can I make my bipolar stepper motor constantly looping back and forth with the AccelStepper library with the NON-blocking function? Thank you!
@CuriousScientist4 жыл бұрын
Hi! Thank you, I am happy that I could help. Just write a loop where you move to a certain number of steps, then with an if() statement, check if you have reached the end of the movement in one direction. After that, step back the same amount (flip the sign) and check the steps again with an if(). You can check the accelstepper library's info page where they say which functions are non-blocking. Use those. Remember, if you want to do something between 2 steps, the time required for the task should be quicker than the delay between the two steps. Otherwise, the motor will be lagging.
@Psihopatim4 жыл бұрын
@@CuriousScientist Thank you very much, I will try that!!
@JohnDoe-sz5jh2 жыл бұрын
Do you have wiring diagram that you have already shared or can you. Please sir.
@CuriousScientist2 жыл бұрын
Hi! Every pin connection is in the source code.
@oded61884 жыл бұрын
1) You should NEVER use delay inside ISR. 2) Serial print inside ISR is not recommended too
@CuriousScientist4 жыл бұрын
Yes, you are right. I wanted to visualize that something actually happens when the ISR is triggered. Therefore, I had to send some messages to the computer, and I wanted to light up some LEDs. As the ISR was related to something which stops the motor, I think it is "okay" to use it as it is not taking away the resources from some important task.
@ahm73734 жыл бұрын
Thanks so much for great work Where I could find the connection diagram
@CuriousScientist4 жыл бұрын
Hi! I am glad to help. For example, you can read the source code that I made available, and you can see what are the assigned pins for the different connections. Or, you can check the video, that I dedicated to this specific question: kzbin.info/www/bejne/aX29kKlpf9GXrdE
@SrkLarblack3 жыл бұрын
love your videos, I've learned a lot with em 🙌
@CuriousScientist3 жыл бұрын
Thank you! I am glad that you could learn something from my videos!
@fooballers7883 Жыл бұрын
Thank you...much appreciated.
@CuriousScientist Жыл бұрын
It is my pleasure!
@leefish19814 ай бұрын
I have a problem where if the button is released slowly it counts as another button press which stops the movement. so it stops fine. the limit switch is held down. then you move away from the switch, it releases and stops again.
@CuriousScientist4 ай бұрын
The button you use is probably bouncing a lot. You need to debounce it. Either with software or hardware.
@Thomas-ij7ki4 жыл бұрын
It would help to show the schematics. It is is hard to see how you wired all up.
@CuriousScientist4 жыл бұрын
Hi, You are right, but the wiring is so simple, it does not worth the effort to draw it. Also, pretty much everything is explained in the video, you just have to watch it carefully. DIR (-) goes to 9, PUL (-) goes to 8. DIR(+), PUL(+) ENA(+) goes to +5 V, and ENA(-) is not connected. The 4 wires for the stepper always depends on the motor. The limit switch uses one of the interrupt pins, in this case pin 2. The LED is connected to the pin 4 using a limiting resistor. Also, there is another video mentioned in the description where I tell where did I connect the pins. Check that video from 17:15-19:00. You're welcome!
@apdevoocomany11794 жыл бұрын
Hi I have tried your examples they are very good . But your last two examples where you have Changed to P, N etc i get a message on the monitor but the motor does not move . Have you made some other changes which effect the Accel Libaray ? Can you please help many thanks
@CuriousScientist4 жыл бұрын
Hi! It is a bit difficult to guess your issue. Do you use the code from PasteBin? Do you have the exact same wiring...etc? What did you exactly try?
@maryannemacalinao83764 жыл бұрын
Hi may I ask if making a 'homing' needs microswitch always? Can I make homing by just putting codes? I'm using nema23 and same driver module as yours
@CuriousScientist4 жыл бұрын
Hi! Homing can also be done by keeping track of the number of steps done. In fact the AccelStepper library keeps track of the steps and you can always use that to perform the homing. For example you move the motor clockwise 2000 steps, then move counterclockwise 500, then 700 clockwise and then give the homing command, the library will know that the overall steps from zero in cw direction was 2200, therefore it has to make 2200 steps in ccw direction to get back to zero. You just have to make sure that the system is 100% doing the exact amount of steps you give as a command. I can make a video on homing without switches using the AccelStepper library in the near future.
@maryannemacalinao83764 жыл бұрын
@@CuriousScientist Thank you so much! So all I need is the AccelStepper library and not any extra module for that control then?
@CuriousScientist4 жыл бұрын
@@maryannemacalinao8376 Yes, you are right! I will upload a video of it during this week where I explain everything.
@maryannemacalinao83764 жыл бұрын
@@CuriousScientist looking forward for it sir! Thanks again!
@CuriousScientist4 жыл бұрын
Hi! I uploaded the promised video. Please check it out if you have time. :)
@patis.IA-AI5 жыл бұрын
Thanks a lot... I have other questions but I dont want to abuse ;)
@CuriousScientist5 жыл бұрын
You are welcome! Just go on, ask it! We are here to help each other. And maybe if I can answer your question, it will help others too.
@patis.IA-AI5 жыл бұрын
Hello Is it possible to make a cercle with accelstepper library without Gcode ?
@CuriousScientist5 жыл бұрын
@@patis.IA-AI I think it is possible. If you have a x and y table or you can move your pen or anything that you use for drawing in terms of x and y, then you can do it. The equation of a circle with its center in the origin is x^2 + y^2 = r^2. So, you have to define the radius, then you can basically manually calculate x and y. You can run x as the integer in the for loop and calculate the y values at each step. Then you move your x-y stage/table/head...etc, according to the coordinates. It is pretty straightforward, you just have to move the x and y stepper motors based on the coordinates calculated from the equation of the circle. You can refine the step of x, then the circle will be smoother as well. If you want to place the circle at a certain place, you have to use the whole equation: r^2 = (x-a)^2 + (y-b)^2. Variables 'a' and 'b' will determine the center of the circle in the coordinate system.
@unknownblueblue4 жыл бұрын
@@CuriousScientist works with drv drivers?
@CuriousScientist4 жыл бұрын
@@unknownblueblue Hello! Yes, it will work with the DRV8825, the A4988 as well as with the Easydriver circuits. Why? All these circuits basically have the same two inputs: Step (or pulse) and direction. You just have to make sure that when you do the setup/initilaization, you define the proper pins for the step and the direction.
@zachshellouff72053 жыл бұрын
i'm having issues in my code tho. I have a 2-axis system, 2 motors on y-axis and 1 motor on X-axis. I have 6 total limit switches attached for each end. I want my program to do the following: when the motors hit the limit switches, i want them to stop and then move in opposite direction a small amount to "De-press" the switch and then set that to my 0 position or Maxtravel Position. Any suggestions?
@zachshellouff72053 жыл бұрын
Could i possibly do something like this?: in setup() { attachInterrupt(digitalPinToInterrupt(limitSwitch3), revXMotor, FALLING); } void revXMotor() { //Stops motor then moves reverses direction and moves it 1-inch back. stepper3.stop(); stepper3.moveTo(abs(stepper3.currentPosition()- 254)); }
@CuriousScientist3 жыл бұрын
Looks ok, but why would you do that "complicated" stuff with the abs and moveTo... etc if you can directly move the motor in relative terms using the move() function?!
@thewthatsuracharoenkan54404 жыл бұрын
Thanks . How to setting origin position ?
@CuriousScientist4 жыл бұрын
Hi! You define it manually when you assemble your system, then you just use the accelstepper library and program it. The library knows where the stepper motor is located at.
@thewthatsuracharoenkan54404 жыл бұрын
@@CuriousScientist if i need to control 3 stepper mycode is AccelStepper stepperX(1, 8, 9); AccelStepper stepperY(1, 10, 11); AccelStepper stepperZ(1, 12, 13); right ? sir
@thewthatsuracharoenkan54404 жыл бұрын
@@CuriousScientist 0 position alway reset when power off arduino ?
@CuriousScientist4 жыл бұрын
Yes, if you remove the power, the physical position of the stepper becomes the zero if you don't have homing. That's why you have homing. You have to code a home direction (let's say, all your 3 motors move in the same direction within their coordinate system), then when you restart the Arduino, you can initiate a homing procedure which brings the 3 axes (1 by 1, that is the safest), to their own home position. The part of the code looks OK, however, I would avoid pin 10-13. They are valuable SPI pins. :)
@thewthatsuracharoenkan54404 жыл бұрын
@@CuriousScientist thank
@danilobelen15864 жыл бұрын
Curious scientist, Great work! I am very new with Arduino, I have used AccelStepper bounce example but I don't know to make the motor always start in one set place(Home or Cero if you will, at the very beginning) then go from point A to point B and vice versa until it is shot down. Please Help. can you give me some codes.
@CuriousScientist4 жыл бұрын
Hi and thank you! I suggest you to look around in my stepper motor related playlist. There are many videos and each video has its own code. I also have a website where you can find the playlist and the codes too.
@musaaftabi62693 жыл бұрын
hello. I made a project with arduino and RF433 module and I hooked up a stepper motor to it and it works fine. but i need some help with the sketch. how can i define 1 button of remote control to turn the motor shaft CW and CCW ? i mean when i pressed the button the motor turned 45 degree CW and when hit the button again its turn in upposit direction. is that possible to answer me
@CuriousScientist3 жыл бұрын
Hi! It is very difficult to answer this without seeing the system and the code. Sorry!
@musaaftabi62693 жыл бұрын
@@CuriousScientist This is the video link for my setup : kzbin.info/www/bejne/eJO1g3WeiaeemKs and this is the link for sketch : drive.google.com/file/d/1zXLyvI9J7zIwIZOa5bKqR1TsO38wGnfV/view?usp=sharing
@CuriousScientist3 жыл бұрын
Hi! Could you please upload the code to PasteBin? Or it would be easier if you could email it to me. You can find my email address on my website: curiousscientist.tech . I think it should be easy to solve your issue.
@musaaftabi62693 жыл бұрын
@@CuriousScientist I really thank you for reply and i need to tell you I found the solution.one of my friends helped me with code.
@CuriousScientist3 жыл бұрын
I am glad that you and your friend could find a solution! Have a great day!
@adriaja55614 жыл бұрын
terimakasih banyak atas tutorialnya
@CuriousScientist4 жыл бұрын
Sorry, I just understand the first word, but you are welcome. :)
@hemanthkota81593 жыл бұрын
Hello, thanks for creating videos like this but i was bit confused with circuit. And there was no circuit diagram in your source code if update it it would be very helpful to our project Thankyou
@CuriousScientist3 жыл бұрын
Hi! All the pins are described in the source code.
@mariosnikolaidis18492 жыл бұрын
@@CuriousScientist a clear circuit diagram is always needed. But thanks for the info you've been a massive help
@CuriousScientist2 жыл бұрын
Just watch the video carefully and read the source code I made available. It is a very simple circuit.
@mohamedadam30852 жыл бұрын
This guy spent %80 of the video time taling about the very simple things but when he goes in the important stuff which why we are all here in the first place, he went flying
@CuriousScientist2 жыл бұрын
What do you mean?
@yaditya39104 жыл бұрын
I want wiring connection diagram
@CuriousScientist4 жыл бұрын
I want many things too. Maybe you should actually watch the video. The wiring is in the source code.
@ПавлоЛях-ъ2ю4 жыл бұрын
Cool! How do I add buttons to control movement?
@CuriousScientist4 жыл бұрын
Hi! Assign a digital pin as an input, then connect a button to it using either an external debounce wiring or the internal pullup resistor. Then you just have to check the status by the button. You can do this by reading the pin's status withing the main loop() or by connecting the button to an attachInterrupt()-capable pin. I can make a video about this in the near future (in 1-2 weeks).
@ПавлоЛях-ъ2ю4 жыл бұрын
@@CuriousScientist thanks! wait for the video, I'm new to this)
@CuriousScientist4 жыл бұрын
@Павел Лях Please check my new video where I show the button-controlled stepper motor.
@CheekyLeoGames3 жыл бұрын
Hey everyone, I used the template provided and tried to adapt the code for my used case, but I encountered some issues and though someone will stumble over this and will be able to help. I do not really understand the AccelStepper step counting feature. Could someone please help? I want to enter a char into the serial monitor, say "t" and make the stepper move to a fixed position, where I know the number of steps from the zero position (which is indicated by the limit switch). But I want to be able to move to this position freely. However, I encounter two main problems: I don't really understand how the step counter in AccelStepper works. My try was: long sputter_pos = 1000; if (receivedCommand == 's') { //Sputter - Sends the motor to the predefined sputter position runallowed = true; //Allow running Serial.println("Going to sputter position."); current_pos = stepper.currentPosition(); howfar=abs(sputter_pos-current_pos); //Set distance if(current_pos > sputter_pos){ stepper.move(howfar); //Move distance } else{ stepper.move(-1 * howfar); //Set distance - negative value flips the direction } However the output simply is: 09:27:43.432 -> Going to sputter position. 09:27:43.480 -> POS: 0 09:27:43.480 -> POS: 0 and the motor does not move. Another problem I have is that I would like the acceleration curve to be as specified but to have no deceleration curve, is that possible? I also need a way of counting steps, so I would then send the stepper from the zero (limit switch) position and until I stop him manually with "n" for example and output the number of steps it went. Here the problem with the deceleration comes into play, as the stepper moves different amounts for different accelerations and if I stop him without decelerating th distance is slightly skewed. Would someone reading this happen to know a thing or two, please let me know. I will update this if I find the solution to my problems.
@CuriousScientist3 жыл бұрын
Check my most recent videos in the stepper motor related playlist and you will find information for your questions. Your task is easy to do and I showed a lot of similar stuff in my most recent video related to stepper motors. As far as I know, you cannot accelerate but not decelerate. Then, just use the functions which do not use acceleration. But keep in mind that you won't reach high speeds.
@CheekyLeoGames3 жыл бұрын
@@CuriousScientist Thanks a lot for your quick reply! I will check it out and also figured that it can't be that difficult. Also thanks for the info in the deceleration. Maybe I will have to measure the position from full speed to stop when decelerating and just add this amount of steps as an offset for the distance to travel.
@CuriousScientist3 жыл бұрын
As long as your stepper motor is not hindered by something, it will do the exact amount of steps that you instructed. The deceleration does not influence the amount of steps and the precision if everything is set up properly. For example let's say you want to move 4000 steps and you have acceleration/deceleration implemented. Then the motor for example will step 800 steps with acceleration, then it does 2400 steps with constant speed and finally it decelerates to zero in the final 800 steps. So, even with deceleration, it will stop at the desired 4000 step position.
@CheekyLeoGames3 жыл бұрын
@@CuriousScientist Oh okay, then I will have to check it again but that was a thing that I didn't understand before.
@tulsicontrolsystem8624 Жыл бұрын
Your linear screw is not pendiculer of the motor😂
@CuriousScientist Жыл бұрын
The linear screw is what?
@F111BMATHIS Жыл бұрын
I "Liked" the video, I did that cause the code is available, but the wiring ... This code uses AccelStepper, and all my previous projects use Stepper, so stepper wiring is different, and so far I've not figured it out. Your code uses only 3 wires for the stepper control, (1, 8, 9); whereas usually I needed to wire all 4, usually (8,9,10,11); So I'm confused, but I've got time!
@CuriousScientist Жыл бұрын
Don't confuse the accelstepper library with other stepper motor libraries. This is a different system, it is not the video's fault. :)
@F111BMATHIS Жыл бұрын
@@CuriousScientist I get that, I changed the code, added #define motorPin1 8, and such and added AccelStepper stepper(8, 9, 10, 11); and it moves, but VERY slowly and always in the same direction! I don't know any other method of using a 4 wire motor on a 3 wire program.
@F111BMATHIS Жыл бұрын
@@CuriousScientist I'm using a DM542T driver
@CuriousScientist Жыл бұрын
You are using it totally wrong.
@F111BMATHIS Жыл бұрын
@@CuriousScientist I am, obviously, it's not working, but I don't know what to do. And it looked so promising!
@warden99945 ай бұрын
balkanc 100%
@CuriousScientist5 ай бұрын
What do you mean?
@discolapy4 жыл бұрын
Thanks for the video! It was useful for me in order to construct my "Bimbo V.1" device: kzbin.info/www/bejne/rJjJdIypnr90oac By the way, what do you think it is actually good for?
@CuriousScientist4 жыл бұрын
Do you want to open and close something with it?
@discolapy4 жыл бұрын
@@CuriousScientist Well, I would like to periodically close and open something...until its failure : ) and plan B is to do something like this: kzbin.info/www/bejne/l6KkhqCdepiKr68
@CuriousScientist4 жыл бұрын
Nice! So, you will build a fatigue testing machine! :D
@gelatinskeleton87452 жыл бұрын
I need the switch to send the motor back home.
@CuriousScientist2 жыл бұрын
Should I send it to you by post or what?
@gelatinskeleton87452 жыл бұрын
@@CuriousScientist HAHAHAHAHAHA! Touché.
@CuriousScientist2 жыл бұрын
But jokes aside, could you elaborate on the question a bit more? Maybe I can help. 😄
@gelatinskeleton87452 жыл бұрын
@@CuriousScientist I need to send an object about 6 feet, via a motor. But, I need the object to come back once it hits the limit switch. I’m currently using a stepper for the “motor” part of my build, but I’m running into issues regarding missing steps. My end point continues to slowly move further away. This is really due to a combination of things. Stepper working with a diy belt system.
@CuriousScientist2 жыл бұрын
Yeah, it can be due to many reasons. Check the tension of the belt, it can cause missed steps. Also, if you overload the motor or provide insufficient current to it, it can skip steps. Maybe it would be easier to put an encoder in the system and rely on that to navigate between different points.