-1
\$\begingroup\$

I'm gonna use stepper motor for the first time in our project and it's need speed and precision both to rotate a particular angle. So I'm thinking of changing micro steps continuously like initially at full steps, then half steps , then 1/4 th steps. portion of the code would be like this:

   while(i<40){
  delay(1);
  digitalWrite(Step_Pin, HIGH);
  delay(1);
   digitalWrite(Step_Pin, LOW);
  i++;
  }
digitalWrite(MS1,HIGH);
while(i<40){
  delay(1);
  digitalWrite(Step_Pin, HIGH);
  delay(1);
   digitalWrite(Step_Pin, LOW);
  i++;
  }
digitalWrite(MS2,HIGH);
digitalWrite(MS1,LOW);
......
.....

I'm gonna use EasyDriver stepper motor driver IC. My question is as I wanna continuously change the micro steps setup without motor being stopped or any other precautionary code like things , is it gonna harm my motor or my driver ?

Can it cause heat up problem ?

Is there any other way to do this thing safely and increase stepper motor's precision and speed simultaneously ? thx in advance .

FYI : I don't know this post fulfil the criteria to be posted in this forum as It may turned out to be a discussion generating question rather then for precise question & answer .

\$\endgroup\$
8
  • \$\begingroup\$ You should just use the stepper before you try fancy hacks to get around problems you don't know exist yet. \$\endgroup\$
    – Daniel
    May 8, 2016 at 20:36
  • 2
    \$\begingroup\$ The only reason full steps would be faster is if your drive logic can't keep up. Normally it is inductance which limits torque at speed and thus speed, unless you hit a resonance problem first. \$\endgroup\$ May 8, 2016 at 20:36
  • \$\begingroup\$ @Damoel , I can use stepper. I'm just precocious before doing this kind of thing ,wanna find out is it safe for the driver. \$\endgroup\$
    – Anklon
    May 8, 2016 at 20:44
  • 2
    \$\begingroup\$ No, the same distance can be covered per unit time, you just need to have shorter waits between your finer increments. The ideal drive is sinusoids with infinitely fine steps. \$\endgroup\$ May 8, 2016 at 20:55
  • 2
    \$\begingroup\$ You are ignoring how I said you would have to decrease the wait time between finer steps. \$\endgroup\$ May 8, 2016 at 21:05

2 Answers 2

6
\$\begingroup\$

That code looks like Arduino 'language', yes?

I guess from your comment "I'm not sure how to decrease the wait time less then 1 millisecond" you are new to it.
delayMicroseconds(500); is 1/2 a millisecond.
So there is plenty of resolution to use.

History, experience, and hard evidence show that people are very poor at identifying the areas of a project that will cause problems. So I recommend you make everything as simple, easy and quick as practical to implement. Get something realistic working early, and use that to discover and understand the actual, interesting, and useful problems to solve.

I recommend you do NOT vary the step resolution dynamically.

So, though it is very unlikely to harm the motor or driver, dynamically changing stepper resolution will introduce extra complexity. In software we talk about 'premature optimisation'. The extra complexity of early optimisation (especially before the problem is properly understood) hampers efforts to get a system working, or improve it. In this project complexity may get in the way of achieving the motors best performance. Worse, the complexity may allow the system to be inconsistent, then making positive changes becomes horribly hard.

Use microstepping from the start, to discover the limits of your hardware and software. It'll be easier to reduce microstepping resolution if you hit problems, than increase it if everything is working at worse resolution.

Microstepping produces smoother motion than simpler step sequences, and reduces resonance. So you might get better performance from it anyway.

I recommend you do NOT use software to drive the Easy Driver pulses. The millis() timer, I/O (e.g. Serial.print) and other parts of the system will introduce 'jitter', which is undesirable, and may confound some attempts to improve the motors performance.

Learn to use the ATmega's timers. They can be used to continuously generate rock-steady pulses without relying on software. IIRC, the Easy Driver can microstep the stepper motor at a constant speed forever without any software involvement. That gives you a stable platform to improve, with lots of flexibility on how you use software and CPU cycles to make the system work better.

Timer/Counter1 is particularly handy. All three timer/counters allow the fundamental counting frequency to be controlled via a clock divider (pre-scaler). This is a not very flexible as the pre-scaler can only divide the main clock by a few fixed values, 8, 64, 256 or 1024. This gets into the right ball-park, but is too crude to adjust the stepper pulse rate, and hence the motor speed.

However, the 16bit timer/counter can also have its frequency controlled precisely by loading a 16bit value which defines the counters frequency (the mode is called "Clear Timer on Compare Match (CTC) Mode")

So this can be used to exactly control the duration of each pulse to your stepper controller. So software could ramp the motor speed up and down in increments of a 1/2 microsecond, if needed.

Then you'll have the task of characterising the motor so that you can accelerate and decelerate it smoothly, and hence change position rapidly and reproducibly. This can take time, and is one of the reasons for trying to get a stable motor drive working early in a project.

You will very likely need to do experiments and measurements on the motor to figure out how fast it can be accelerated, decelerated and driven.

EasyDriver, like the vast majority of stepper controls, drives steppers 'open-loop', without feedback. Overdriving the stepper isn't detected, but will reduce speed and position accuracy. An overdriven stepper will fail to move as many steps as the software thinks it has gone.

A stepper's speed must be ramped up and down quite carefully for best performance. Most steppers will struggle to accelerate instantly even to quite modest speeds, and will lose synchronisation (destroying any ability to reach a specific position) if accelerated too quickly, or driven too fast.

Edit:
I noticed Sparkfun's EasyDriver page links to this article about driving a stepper motor using the EasyDriver. The article is helpful. It shows how to wire things up and quickly get started driving a stepper using the EasyDriver.

However, it may be misleading. It shows a software-only technique, using the millisecond-resolution delay() function to generate the pulses for the EasydDriver. It does not even mention using hardware to generate the pulse-train. The article was written about 5 years ago, so it's a bit late to ask them to fix it.

Summary:

  • Drive the stepper using timer-derived signals so that everything is stable and reproducible.
  • Use microstepping from the start, as that will give the smoothest motion.
  • Ditch the idea of using different stepping resolutions until you have a problem it can help solve.
  • Keep the system simple and consistent/uniform so that it is easier to measure system behaviour or tune the system for good performance.
  • Allow lots of time to test and measure the system if you want to approach the steppers best performance.
\$\endgroup\$
2
  • \$\begingroup\$ Thank you for your elaborated answer. It helps me to have a clear idea about stepper motor's motion . :D \$\endgroup\$
    – Anklon
    May 9, 2016 at 16:08
  • \$\begingroup\$ @Anklon - You're welcome. Best of luck with the project. \$\endgroup\$
    – gbulmer
    May 10, 2016 at 17:11
2
\$\begingroup\$

I doubt it'd cause any issues, full stepping is just on/off (PWM if you've got current control), microstepping is just flipping between different PWM duty cycles, so I see no immediatly obvious reason why you can't switch between the two. Having said that, microstepping itself won't limit the maximum speed provided your controller can send 'step' commands fast enough. E.g. a motor with 100 steps/rev needs 100 steps/sec to spin at 60rpm, while a 100step/rev mptor with 16x microstepping needs 1600steps/sec to spin at 60rpm. Microstepping doesn't limit speed, in fact it can sometimes 8ncrease speed as the motor runs smoother with less juddering. The only limitation is whether your micro can keep up.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.