This question pertains to this video as well as this one by the same person demonstrating his results with a stepper motor (along with a really neat testing method involving a laser spot on a wall a few meters away!).

How did he achieve this kind of high-resolution stepping behavior of < 0.04° steps (with 1-second holding at each step) on a standard, gearless 1.8° stepper motor?

The person claims to use "sine wave patterns" with Arduino's analogWrite function.

I am familiar with microstepping, but:

  • how is this done within an Arduino sketch and without some hardware like DRV8825 or L6470?

  • and how is he able to hold the position so definitely and accurately, something that articles about microstepping usually warn isn't exactly guaranteed?

(Obviously, there is no clear way to measure precision and accuracy here with the videos' limited provided information. However, approximating the wall's flat surface as part of a circle centered on the stepper, we can see that there are very fine steps formed by the laser spot -- as well as a fairly small deviation between expected and observed angle for each step, especially in the 2nd video I linked.)

  • 1
    \$\begingroup\$ It's impossible, it works with mirror and lase pointer, but not with a loaded motor. \$\endgroup\$ Oct 17, 2015 at 17:47
  • \$\begingroup\$ It's just a light passing along the edge of a ruler. How can you say he isn't using the DRV8825 or any other form of tech that might be at hand? \$\endgroup\$
    – Andy aka
    Oct 17, 2015 at 17:48
  • \$\begingroup\$ @Andyaka: Was mostly basing it on the very limited description text below his 1st video; but not fully ruling that out -- I'm still at least interested in learning from my 2nd question above. \$\endgroup\$
    – sasha
    Oct 17, 2015 at 18:07
  • \$\begingroup\$ @MarkoBuršič: But even an unloaded stepper would have its own internal friction, etc., which based on what I read, would prevent this kind of performance -- not saying this demo is magical or anything, but it does appear to conflict what seems to be thrown around regarding microstepping so I'm trying to resolve that. \$\endgroup\$
    – sasha
    Oct 17, 2015 at 18:11
  • 1
    \$\begingroup\$ @sasha It works indeed, no rules are violated, the torque in beteen full steps is reduced down to few percents which is still enough to compensate the friction at almost zero speed, once you load you have a backlash to the nearest full step. \$\endgroup\$ Oct 17, 2015 at 18:41

2 Answers 2


If you look at the notes on the videos, you'll see that he is microstepping. He explicitly states that he is driving the stepper with sine waves. The simplest way to do this is with the PWM outputs feeding the amplitude control of the two stepper drivers.

Begin by noting that 1.8 degrees divided by .04 degrees is ~45, and since a standard stepper quadrature waveform takes 4 steps to complete a cycle, this implies a microstep resolution of 4 x 45, or 180 microsteps per cycle. In fact, it's pretty clear that he is using 64 microsteps nominal.

If n is the step count per excitation revolution (that is, microsteps per every 4 nominal steps) , let n = 0 to 255. For each successive n, find the step angle A = 360/n. Then find $$ X = 127\sin(A) +128$$ and $$ Y = 127\cos(A) +128$$ and use the analogWrite function to produce the PWM versions of these quantities. When applied to the control inputs to standard 1.8 degree steppers, you'll get a nominal step size of $$S = \frac{4\times{1.8}}{256} =.028\text{degrees}$$

Also note that, if you look closely at the videos, the step-to-step distance is not constant, and that is only to be expected.


Since the mirror being used presents a very small mechanical load, microstepping has some measure of positional accuracy. When the motor is loaded that doesn't hold up.

The L6470 has 128th step microstepping, which would be around 1.8/128 = 0.014 deg/step. There are Arduino libraries available for controlling this chip.

Edit: On the analogOut behavior: Microstepping is just approximating a fractional current or voltage by chopping up the incoming signal. He might just be using a couple of DACs and an amplifier in lieu of a microstepping driver. Never done it myself, but don't see any reason why it wouldn't work.


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.