Stepper Motor MicroStepping? Things to keep in mind when doing it…

  Рет қаралды 57,777

Brainy-Bits

Brainy-Bits

Күн бұрын

Micro Stepping might seems like something you’d want to do all the time, but there might be some compromises. Let’s talk about it!

Пікірлер: 63
@evgenypavlovskiy3945
@evgenypavlovskiy3945 3 жыл бұрын
Nice video, thank you. I noticed that your code uses runSpeedToPosition(), so it seems that you're not using AccelStepper's acceleration/deceleration capabilities, basically the main selling point of this library. For using them, one should use either run(), runToPosition() or runToNewPosition(). With runSpeedToPosition(), one should be able to run quite a bit faster than 4000 PPS (although above certain speeds, the stepper should be accelerated gradually, rather than trying to go "from zero to hero" abruptly). The delay-based stepping has a drawback that it blocks the loop for the minimum pulse duration time (16-48 clock cycles), during that time your program can't do anything useful. As the pulse rate is increased, the amount of time spent sleeping inside the delays grows larger and larger, leaving less and less time to run any other code you have. I want to clarify that Arduino Uno runs at 16 MHz, and is capable of generating much more than 4000 pulses per second. The mentioned 4000 PPS limitation comes from the AccelStepper library. The library's basic operation is based on setting the output pulse pin high, delay for minimum pulse duration microseconds (1-3 depending on the driver), then setting the pin low again. Stepping like that via this library's runSpeed() or runSpeedToPosition(), or manually, you could easily output quite a few pulses per second. However, if one uses AccelStepper's acceleration/deceleration features, for each single step it does quite a bit of calculations to compute the new speed, including floating-point multiplications and divisions - very slow operations on an Arduino. This reduces the max possible pulse rate probably by a couple of orders of magnitude. The AccelStepper library is based on equations from an article "Generate stepper-motor speed profiles in real time" by David Austin - I couldn't find the source code, but the article says it uses 24.8 fixed-point math (and an 8-bit PIC microcontroller), unlike the AccelStepper. For a much more optimized code, see AN_8017 from Atmel/Microchip - www.microchip.com/wwwAppNotes/AppNotes.aspx?appnote=en591185 It uses only integer math (including a neat integer sqrt implementation), and a timer interrupt (using the 16-bit Timer1) to manage the stepper's movement - leaving you free to do whatever you want in the main loop (no need to call run()). According to the application note, "the timer interrupt performs calculations during acceleration and deceleration and approximately 200us are used in one timer interrupt. When running at constant speed less time is need and approximately 35us is sufficient. The maximum output speed is then limited by acceleration/deceleration calculations. For a stepper motor with 400 steps per round maximum output speed is: 78,5 rad/sec (750 rpm)". The demo code is for an ATmega48 running on 3,68MHz - an Uno is 4.3 time faster, so you could use 1/8 microstep (1600 steps per revolution) and still run a (single) stepper up to 750 rpm. Having said that, AccelStepper provides a simple and easy-to use API, and is good for beginners. It is slow, but if it's good enough for a particular application, why not? The reason I posted all this is that I don't like it when people make general statements like "This 8-bit microcontroller is too underpowered to do task X at speed Y". A typical Arduino project (and many of the libraries) don't care much about doing things in a performant way, instead priority is given to other considerations, such as simple-looking code that is easy to write and read, being beginner-friendly, etc. This is great for learning to program and to tinker with electronics! But when one starts to push the boundaries of what an 8-bit 16MHz Arduino can do with these libraries and programming attitude, there are two choices - get a bigger and faster MCU (e.g. STM32, ESP32) or go deeper and learn to program your Arduino in a more direct, low-level way, learn to optimize your code. It's likely you will be able to do the same things as you were doing before, but 10, 100 or even 1000 times faster.
@taufikmahmud1566
@taufikmahmud1566 3 жыл бұрын
yes I agree with you
@h7opolo
@h7opolo 10 ай бұрын
the fact the video uploader hasn't responded to you shows how complacent and incompetent he is.
@enaudeni
@enaudeni 4 жыл бұрын
Many thanks for the tutorials, they are always interesting and helpful. You are far better than many other of the KZbinrs around Arduino etc... Keep it up, it is most appreciated! Thanks!
@BrainybitsCanada
@BrainybitsCanada 4 жыл бұрын
Like I said in the video, comments like yours really keeps me going. Thanks you so much and wishing a safe and great holidays to you and your family.
@SkottTomas
@SkottTomas 4 жыл бұрын
Great video once again. I find your tutorials very informative and easy to follow - Grat job and happy Holidays!
@BrainybitsCanada
@BrainybitsCanada 4 жыл бұрын
Thanks for watching. Happy holidays!
@radifuddinahmed6650
@radifuddinahmed6650 2 жыл бұрын
In depth and accurate presentation. Please keep up the good work
@ed-jf3xh
@ed-jf3xh 4 жыл бұрын
Torque is also affected during micro stepping. Smaller steps, less torque.
@wadib3eed7
@wadib3eed7 3 жыл бұрын
Why torque goes less as small steps ? it that because of less current goes to the windings ?
@ed-jf3xh
@ed-jf3xh 3 жыл бұрын
@@wadib3eed7 You have a fixed number of magnets. Full step, greatest torque, is stepping from magnet to magnet. When you start making the steps smaller it's because you are magnetizing off center windings. This probably explains it better; www.linearmotiontips.com/microstepping-basics/
@adrianharrison5208
@adrianharrison5208 4 жыл бұрын
thanks for the video it has helped with my understanding with my cnc
@lenin972
@lenin972 3 жыл бұрын
Very informative and well made. Thank you! You got me rethinking the code for my telescope controller. I'm using a Teensy 4.0, which is a tiny bit faster the the UNO. Right now it is set up to give me a motion resolution which is twice that of the optics, but maybe more will be better. I'll need to experiment a little and compare the results.
@wallybe2946
@wallybe2946 4 жыл бұрын
Thank-you for your time and effort, awesome tutorial Merry Christmas/Happy New Year
@BrainybitsCanada
@BrainybitsCanada 4 жыл бұрын
Same to you and your family, be safe and have fun! Thanks for watching and see you next year!
@coloradoken3926
@coloradoken3926 3 жыл бұрын
May I suggest using tone() command for generating a pulse step? I have been using it for several years in the Arduiono environment and have had good luck. I drive small pumps and run them from 1-500 RPM using 16 microsteps = 53Hz to 26.5kHz. Of course, this does limit further use of the timer associated with the tone() command. Not a problem for me because I am only interested in stop/start, direction and speed when running the pump.
@jackevans2386
@jackevans2386 Жыл бұрын
07:14 The big tradeoff is NOT the microcontroller. The tradeoff is your Arduino software. If you were to write your code in Microchip's Studio 7 in either ASM or even C, you could have as many steps per second as the stepper motor could handle.
@mehmetaligorur4183
@mehmetaligorur4183 Жыл бұрын
Where are you mate? I hope that everything is perfectly fine and you are away just because you wanted to. Missed the way you thought things. Hope we gonna see you around again. Cheers!
@Ayush-tl8se
@Ayush-tl8se 4 жыл бұрын
Awesome video and very clear information.
@BrainybitsCanada
@BrainybitsCanada 4 жыл бұрын
Thanks for watching and Happy Holidays, see you in the next year!
@doubleHLabs
@doubleHLabs 4 жыл бұрын
nice, needed a quick refresh on microstepping
@Don_Meggi
@Don_Meggi 4 жыл бұрын
Nice video - Merry Christmas and a Happy New Year
@BrainybitsCanada
@BrainybitsCanada 4 жыл бұрын
Same to you and your family Don. All the best and see you in the next year!
@justinssleeyt
@justinssleeyt 2 жыл бұрын
Great video, thanks!
@danielesilvaggi
@danielesilvaggi 4 жыл бұрын
Just getting into the arduino and I want to learn all about it but I was supposed to retire this year but the company I work for decide not to give buyouts till contract time so my time is tight. I love the videos on the stepper motors as I want to build a camera slider. Thank you
@BrainybitsCanada
@BrainybitsCanada 4 жыл бұрын
Thanks for taking the time to leave a comment, check out my channel, I've built a camera slider no long ago and I have quite a few more on controlling stepper motors. Good luck with your future projects and thanks for watching!
@sameerk12982
@sameerk12982 4 жыл бұрын
Hello from India...thank you for the great video...appreciated....looking forward for more.
@classicrc3575
@classicrc3575 3 жыл бұрын
Great video. Is there a wiring schematic for this setup?
@joramkalfa9521
@joramkalfa9521 3 жыл бұрын
Thanks for the video. Very informative. I wondering how slow can a stepper motor turn without being "jerky". I'm in the middle of building a barber pole and I'm having trouble getting the pole to turn slowly without being "jerky". Is this a lost cause? Thanks again!
@the4hunters
@the4hunters 4 жыл бұрын
Brilliant! Subbed
@kraken3d718
@kraken3d718 4 жыл бұрын
Merry Christmas - and thanks for all the great content in your videos. I always have issues with the easy driver and them getting really hot almost instantly. I have tried to use them several times just messing around with them. Maybe my steppers are to much of a load with a standard Nema 17. However they still get to hot with some of the Nema 14 / Nema 15 size motors. That why I just moved to the TMC drivers and using that with the Nano. Have to make my own make shift PCB but they seem to work well in my application. Guess I will have to try one last time with the easy drivers :(
@BrainybitsCanada
@BrainybitsCanada 4 жыл бұрын
I hear you, the EasyDriver can get pretty hot but it is made to run hot. Adding a small heatsink will help. I've been using the EasyDriver for a while, at the time it was a good option, but there's better option out there now. In the next year I'll start using those to see how they compare. Thanks for watching and Happy Holidays!
@chaithanyaprasadch3474
@chaithanyaprasadch3474 4 жыл бұрын
Thanks for the tutorial, can u help me with controlling stepper motor with bi dectional switch
@chanchalsakarde2768
@chanchalsakarde2768 4 ай бұрын
lets say in your circle u have 400 locations as 400 teeths on it, each location identified as numeric location id, so how can we move to pointer to series of location given... for example starts from 0 to 10 then move to 34 -> 200 -> 90 -> 275 -> 345 and so on .. how to do these series moves one after other
@altamiradorable
@altamiradorable 4 жыл бұрын
Merci Yvan ! ;)
@saeedehsani1732
@saeedehsani1732 2 жыл бұрын
I really enjoyed watching and learning here. and as is obviously you have so many projects done and gathered experiences from them. so please help me if you have time for this: I have three stepper motors which are 3 phase - 3 wired - 4 a . I know some drivers like leadshine HY-DIV268N-5A but they all are more than my budget ! once Itried that with a driver and when I addjusted the sw setting to micro step mode 2A or 2B it worked very nice , smooth and with high torque but the direction was random!! some correct and some not! do you know how could I drive these nice steppers?!
@Bianchi77
@Bianchi77 Жыл бұрын
Nice video, thanks :)
@JM_Tushe
@JM_Tushe 2 жыл бұрын
What about torque? How is it affected? And do they need more current when using micro stepping?
@webslinger2011
@webslinger2011 4 жыл бұрын
Merry Christmas!
@BrainybitsCanada
@BrainybitsCanada 4 жыл бұрын
Same to you and your family, thanks for watching and see you next year!
@TheHectorOg
@TheHectorOg 4 жыл бұрын
Nice content.
@Thermo88
@Thermo88 3 жыл бұрын
how can i control the direction of stepper using external signals such that when the first signal is high and the second is low turn in clockwise , when change states turn in the anticlockwise and when the two are low stop the motor please would you help me with the code to do so?
@wadib3eed7
@wadib3eed7 3 жыл бұрын
which better case for using some steps ? 1/2 or 1/8 or 1/32 .... ?
@thanasisathanasi4965
@thanasisathanasi4965 4 жыл бұрын
What about torque! Also can you move by a single microstep? Nobody tells us !!!
@alvarobyrne
@alvarobyrne 4 жыл бұрын
Nice! TY YT! Wouldn't you want to include thisone in your stepper motors tutorials playlist?
@BrainybitsCanada
@BrainybitsCanada 4 жыл бұрын
I'm always forgetting to add new videos to playlists. Thank you for reminding me and for watching!
@vzr314
@vzr314 3 жыл бұрын
The thing that limits your speed is not microcontroller but your code. You shuld use stepper motor based on interrupts and avoid delay() in main loop. Instead, you said that Arduino Uno is bottleneck...
@electro7939
@electro7939 Жыл бұрын
Amazing
@whitefields5595
@whitefields5595 4 жыл бұрын
Ivan, thanks for this. How is the torque affected when microstepping. I presume as the signal is ‘shared’ across coils the torque is reduced?
@BrainybitsCanada
@BrainybitsCanada 4 жыл бұрын
This is a tricky one, depending on a lot of variables, voltage, stepper motor, etc.. but in most cases you can expect around less than 10% loss in torque when micro stepping, but again this is not consistent. I will try to make a test bench of this to see what I come up with in the next year :) Thanks for watching and happy holidays!
@an_R_key
@an_R_key 4 жыл бұрын
@@BrainybitsCanada +1 for this test. Also, thanks for uploads. Very interesting stuff. Learning a lot.
@barenekid9695
@barenekid9695 4 жыл бұрын
Torque losses are proportional to the number of micro steps attempted + the speed of rotation used.. at 256 steps there ain't much left. Also the precision falls off just as proportionally, as Interpolation can only go so far in dividing up the magnetic poles ..cleanly . (as if :-) Short answer: Micro stepping our Cheap Ass Chinoiserie steppers is often Pointless even counterproductive. There are Far better ways to genuine precision with Torque ..such as Gasp! reduction gearing
@fatihmeral9863
@fatihmeral9863 9 ай бұрын
what happens to torkue when microstepping
@vzr314
@vzr314 3 жыл бұрын
Not a single word about vref and max current settings in microsteping mode :(
@ortizgab
@ortizgab 3 жыл бұрын
Hi there! I followed your project to automate an old slider and "almost" works perfectly ... The electronics work very well but the video picks up a shake when I use high focal lengths. I'm using vibration dampeners. Any suggestion?
@ortizgab
@ortizgab 3 жыл бұрын
*UPDATE* I just found the TMC2208 to be much quieter. Could you help me make the connection by replacing the EASY DRIVER for this?
@paulocella9745
@paulocella9745 3 жыл бұрын
Gooooood!!
@Emptiness-
@Emptiness- 4 жыл бұрын
Did you need an external power source for the motor?
@Emptiness-
@Emptiness- 4 жыл бұрын
I made myself useful and read on your website that you used a 24V 5A source. I am currently power my stepper motor with the 5V usb cable to the pc so I could not get higher speeds than 70 rpm. At higher speeds the motor would just skip.
@qozia1370
@qozia1370 9 ай бұрын
lol 16 mhz! go with an esp32
@ibrahimabdeen105
@ibrahimabdeen105 3 жыл бұрын
Please I need code of arduino which used for drawing full wave rectifier diode
@h7opolo
@h7opolo 10 ай бұрын
3:25 wow, mispronunciation of the word "variables." well, this video would be unfit for youtube if it were perfect, eh. 4:16 mispronunciation of the word "orientation." please tell me English is not your native language.
A4988 Micro-Stepping Driver with Arduino Uno
17:56
Gadget Reboot
Рет қаралды 32 М.
THE POLICE TAKES ME! feat @PANDAGIRLOFFICIAL #shorts
00:31
PANDA BOI
Рет қаралды 25 МЛН
Smart Sigma Kid #funny #sigma #comedy
00:25
CRAZY GREAPA
Рет қаралды 25 МЛН
Nutella bro sis family Challenge 😋
00:31
Mr. Clabik
Рет қаралды 13 МЛН
50 YouTubers Fight For $1,000,000
41:27
MrBeast
Рет қаралды 121 МЛН
Magnetic rotary encoder vs stepper motor accuracy
5:41
Matthias random stuff
Рет қаралды 141 М.
How Stepper Motors Work - Electric motor
14:01
The Engineering Mindset
Рет қаралды 1 МЛН
Closed loop stepper motors -- very impressive
10:46
Matthias random stuff
Рет қаралды 120 М.
Arduino Motorized Camera Slider - Let's Finish This!
10:11
Brainy-Bits
Рет қаралды 7 М.
Stepper Motor Torque For Your Applications..
15:04
Corvetteguy50
Рет қаралды 138 М.
Controlling 3 Stepper Motors with the AccelStepper Library for Arduino
11:49
What Makes TMC2208 Stepper Motor Drivers Silent?
9:07
Michael Klements
Рет қаралды 295 М.
DIY Stepper Motor Driver From Scratch
9:56
Sine Lab
Рет қаралды 18 М.
Clicks чехол-клавиатура для iPhone ⌨️
0:59
PART 52 || DIY Wireless Switch forElectronic Lights - Easy Guide!
1:01
HUBAB__OFFICIAL
Рет қаралды 48 МЛН
Мой инст: denkiselef. Как забрать телефон через экран.
0:54
تجربة أغرب توصيلة شحن ضد القطع تماما
0:56
صدام العزي
Рет қаралды 52 МЛН
Как правильно выключать звук на телефоне?
0:17
Люди.Идеи, общественная организация
Рет қаралды 1,2 МЛН