Jump to content

SkySurveyBanner.jpg.21855908fce40597655603b6c9af720d.jpg

Stepper motor microstepping noob question


Jim09

Recommended Posts

Sorry if this sounds like a really silly question but I can't seem to find any information online

Can you switch from different stepping modes from the arduino code? full, 1/2,1/4 etc

or does that need to be set physically from the driver module?

My plan is to switch between stepping modes to achieve necessary speeds during slewing and tracking, so I need to be able to switch from the code in order to achieve that.

 

Sorry I never had a chance to work with stepper motors before so this might 

 

Edited by Jim09
Link to comment
Share on other sites

You set the microstep stepping mode by setting the relevant pins on the driver module high or low. For the commonly used DRV8825 stepper driver module there are three mode pins M0, M1 and M2 which set the microstep mode according to the table.

DRV8825-pinout.jpg.550331a547c662e40a06fe6d2bc7942d.jpgdrv8825.jpg.182145b7b208678313413980b698ce14.jpg

Just connect the mode pins you want to use to a corresponding digital pin on the arduino and set those pins to be outputs. Writing high or low to those arduino digital pins will then change the stepping mode of the motor. If you don't want to have all 8 microstep modes you can just connect the unused pins to 5V or Gnd as necessary. For example if you only want Full, half, quarter and eighth, connect M0 and M1 to two arduino digital pins and connect M2 to Gnd.

Each pulse to the step pin will then move the motor 1 microstep as set by the mode pins.

If you are microstepping you normally need to have the stepper motor powered all the time (Enable pin kept low) so it will get warm. If you're using full steps you can often just power the motor (using the Enable pin) only when you want to step it, as the motor naturally wants to stay in a full step position (its detent torque) when un-powered. If this torque isn't enough to hold the mount still, you need to keep the stepper motors powered so they generate holding torque which is higher. When microstepping the motor needs to be held between full step positions, so power must be applied all the time to keep it in that position. If power is removed when microstepping the motor will jump to the nearest full step position.

Different driver modules may only have 2 pins to set the stepping mode as they may have only 4 stepping modes and not 8 like the one above. 

Alan

Edited by symmetal
Link to comment
Share on other sites

As Alan has said, you use the mode pins, but I would not recommend using the DRV8825 modules as they have a design flaw on their internal current drivers, requiring additional diodes to be fitted to their outputs.

Instead go for the A4988 or TMC2130 series, but the control of these is a little more complicated.

Link to comment
Share on other sites

You can also do "speed" setting without changing the Step size to some extent by using a decent Arduino Stepper Library such as Accelstepper which enables different non blocking movements/speeds/acceleration. The only problem is that it does depend on the processor cycle time. It also supports most drivers out there.

https://www.airspayce.com/mikem/arduino/AccelStepper/

Link to comment
Share on other sites

6 hours ago, symmetal said:

You set the microstep stepping mode by setting the relevant pins on the driver module high or low. For the commonly used DRV8825 stepper driver module there are three mode pins M0, M1 and M2 which set the microstep mode according to the table.

DRV8825-pinout.jpg.550331a547c662e40a06fe6d2bc7942d.jpgdrv8825.jpg.182145b7b208678313413980b698ce14.jpg

Just connect the mode pins you want to use to a corresponding digital pin on the arduino and set those pins to be outputs. Writing high or low to those arduino digital pins will then change the stepping mode of the motor. If you don't want to have all 8 microstep modes you can just connect the unused pins to 5V or Gnd as necessary. For example if you only want Full, half, quarter and eighth, connect M0 and M1 to two arduino digital pins and connect M2 to Gnd.

Each pulse to the step pin will then move the motor 1 microstep as set by the mode pins.

If you are microstepping you normally need to have the stepper motor powered all the time (Enable pin kept low) so it will get warm. If you're using full steps you can often just power the motor (using the Enable pin) only when you want to step it, as the motor naturally wants to stay in a full step position (its detent torque) when un-powered. If this torque isn't enough to hold the mount still, you need to keep the stepper motors powered so they generate holding torque which is higher. When microstepping the motor needs to be held between full step positions, so power must be applied all the time to keep it in that position. If power is removed when microstepping the motor will jump to the nearest full step position.

Different driver modules may only have 2 pins to set the stepping mode as they may have only 4 stepping modes and not 8 like the one above. 

Alan

Thanks very much Alan, that was very informative and cleared the doubt I had.

Link to comment
Share on other sites

4 hours ago, Dr_Ju_ju said:

As Alan has said, you use the mode pins, but I would not recommend using the DRV8825 modules as they have a design flaw on their internal current drivers, requiring additional diodes to be fitted to their outputs.

Instead go for the A4988 or TMC2130 series, but the control of these is a little more complicated.

Thanks very much Julian, I went ahead and ordered couple of A4988 and a sensor shield for arduino uno which makes things easier.

Link to comment
Share on other sites

3 minutes ago, stash_old said:

You can also do "speed" setting without changing the Step size to some extent by using a decent Arduino Stepper Library such as Accelstepper which enables different non blocking movements/speeds/acceleration. The only problem is that it does depend on the processor cycle time. It also supports most drivers out there.

https://www.airspayce.com/mikem/arduino/AccelStepper/

Thank you 

I will have a look and play around a with it when my gear gets delivered.

What exactly do you mean by processor cycle time? speed of the chip or something else?

Link to comment
Share on other sites

8 hours ago, Dr_Ju_ju said:

As Alan has said, you use the mode pins, but I would not recommend using the DRV8825 modules as they have a design flaw on their internal current drivers, requiring additional diodes to be fitted to their outputs.

Instead go for the A4988 or TMC2130 series, but the control of these is a little more complicated.

Thanks Julian. I wasn't aware of that problem as I've only used them in full step mode on my focusers. Here's a useful article describing the problem when microstepping and using the diodes to 'cure' it. I only used the DRV8825 as they were described as an 'upgrade' to the A4988. :smile:

Alan

Link to comment
Share on other sites

4 hours ago, Jim09 said:

Thank you 

I will have a look and play around a with it when my gear gets delivered.

What exactly do you mean by processor cycle time? speed of the chip or something else?

Exactly  CPU Cycle time -  bearing in mind this library is non blocking for max efficiency and that's how it is able to do speed control - quote from Accellibrary The fastest motor speed that can be reliably supported is about 4000 steps per second at a clock frequency of 16 MHz on Arduino such as Uno etc. Faster processors can support faster stepping speeds.   . 

Accelstepper can run in blocking mode - i.e. where you code waits until the operation is finished.

Its a pretty flexible library and can control more than one stepper at a time if required.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. By using this site, you agree to our Terms of Use.