Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do steppers work (some rarely described facts) #83

Closed
AnHardt opened this issue Sep 5, 2018 · 0 comments
Closed

How do steppers work (some rarely described facts) #83

AnHardt opened this issue Sep 5, 2018 · 0 comments

Comments

@AnHardt
Copy link
Owner

AnHardt commented Sep 5, 2018

The key here is the different definition of jerk in Marlin and the rest of the world.
Physicists talk about jerk as the change of acceleration (m/s²) over time - having the unit m/s³.
Marlins jerk-speed is in m/s - the fastest speed we can begin a move with when starting from 0m/s. A difference in speed.
I hear you thinking - that's impossible. You can't have a jump in speed - that needs because of F=m*a an infinite force. It's the other way around. We don't move a mass. We do change the direction of a field. It's about like loading a spring. And the mass of the rotor is forced and accelerated by the spring to rotate.

Imagine a powered stepper motor with only 4 full steps per rotation. Now we mount a lever pointing to 12 o'clock. Now we take a finger and try to displace the lever up to 3 o'clock. We experience a increasing force/moment against our finger, reaching it's maximum at 3. Going further to 6 the moment decreases down to zero. Reaching 6 the lever is pulled away from the finger and increasingly accelerated to 9, then decreasingly accelerated to 12, where it reaches its maximum speed. Then because of the momentum of the mass it continues its move, now decelerated by the field until (on a low friction system) our finger is hit near 6 from the other side. We'll see some oscillations around 12 with decreasing amplitude. In summ we skipped 4 steps.

moment from dispacement full steps
No displacement between field and rotor - No moment!

Now the other way around. Put away your finger. We apply a step. Logically this is an immediate proces. We tell the stepper driver to take a step. That's a nearly infinite fast thing, we just switch a pin to high. Locking at the field it takes somewhat longer to decrease the current in the one coil and rise it in the other. But compared to the now slowly starting to move rotor, changing the field is a fast process. The rotor follows the, now pointing to 3 o'clock, field and is accelerated up to there. If no further step follows in time the rotor is now decelerated, returns at a bit before 6, and oscillates around 3 for a while until all energy is converted to heat by the friction. Now we could repeat our first experiment - displacing the lever with the finger. Will get the same result turned 90°. We also will lose 4 full steps again.
Now let's see what happens when we don't take full steps, but microsteps. Let's assume 3 microsteps per full step, to stay with the picture of a clock. We readjusted the lever to 12 o'clock. Right, we applied a full step backwards. Pushing the lever to there will not work. Now we can apply the microstep. The field now points to 1 o'clock. The rotor, coming from 12 follows accelerating the field to 1, has its maximum speed there, swings over up to nealy 2, oscillates around 1 and finally points steadily to 1. All in all this microstep was much less violent than the full step. Overswing, speeds and duration of the oscillation have been much lower. The microstep was smoother than the full step. Repeating the experiment with manually displacing the lever shows increasing force up to 4, zero at 7, a return to 1. The needed forces and achieved speeds have been about the same as with full steps (depending on the exact currents the stepper-driver applied). We learn, even here the amount of lost full steps, when displacing manually was 4, or in microsteps 4*3= 12. We also can learn, we have to apply 3 microsteps, with unmoved rotor, until the moment can reach its maximum. Further follows, if we have a system with N microsteps per full step, we can apply 2*N-1 (in our 3 microstep system for example from 12 to 5) microsteps at once while holding the lever, and the lever will still go to the right place and in the right direction when released.

moment from dispacement 3 microsteps

That has consequences for 'double-' and 'quad-stepping' at systems with full- or half-stepping when starting from zero speed. In 'double stepping we apply two steps as fast as we can. That means, on a full-step system, we get zero moment and the direction of the move, when it comes, is undefined (Butterfly effect). Applying a quad step makes the rotor think - nothing to do because field did not change. On a half step system we have the same situation with a quad-step - direction of rotation is undetermined. Nevertheless double- quad-stepping does work. We don't hold the the rotor, can't apply steps infinite fast and, provided jerk-speed or 'junction deviation' is set low enough, start with a speed below it takes double-stepps. When we reach the speed we begin with the double-steps the rotor does not stand still - its direction is determined.

Double- (quad-)stepping is about as switching the micro-stepping one (two) levels down. For example from 16 to 8 (16 to 4).

Now let's add a very special (unreal) stick only break to the 3 microsystem system. We adjust the break to the point where, when the field points to 12, we can position the lever to every place between 11 and 1 (that also means between 5 and 7). Let's point with the field to 12 and also the lever. Now we apply a microstep, the field is pointing to 1 but we don't see any change. The moment applied to the rotor by turning the field by 1 hour is just not big enough to exceed the stick-force. When we apply a second micro-step, the field points to 2, the rotor brakes loose, accelerates up to 2, swings over to about 4, oscillates a bit around 2 until the amplitude is below 1h difference and finally stands still somewhere between 1 and 3, where 1 and 3 are the most likely places (because oscillations have zero speed at the point they change direction and stick forces can grab). What we will see when we apply the next micro-step, pointing the field to 3, depends on the position of the lever when we apply it. At 1 it will end at a place between 2 and 4. At 2 and 3 it will not move, because the stick-forces are not exceeded. However, the lever will always end at the place where the field points to, +- one hour. If we change to more microsteps this will stay the same - but an hour will be an other amount of microsteps.
If we take a look at the lever we can't say anymore where the field is pointing to. It's somewhere +-1 hoer before or after the lever. Think about what happens when we increase the stick forces. Right - the margin will grow - but how far can we increase? Right - Until the margin is one full step. Then we don't get any movement because the stick-force is greater than the moment the motor can develop.
When we (again) hold the lever and apply a bunch of steps we now have to calculate the max with 2*N-1-(stick-force in micro-steps), to get always a movement into the right direction.

Why can't we step infinitely fast? Because it takes some time to readjust the currents in the coils. If we switch off the current in the coil before it reached its maximum, maximum moment is not reached. Because the moment goes to zero when the time for a step goes to zero, somewhere we get to the point where the moment is not large enough to overcome and resistance. The angle between rotor and field increases and finally, when the distance is one full stepp, the motor will skip (at least 4 full steps).

Why can't we accelerate infinitely fast? The now the not that surprising answer is - We can! But before you want to give the Nobel-award to me I have to restrict/relativate this. We can, at the step level for a very little amount of microsteps. We can, safely jump 1 full step if field and rotor was pointing into the same direction, to get the full moment instantly. Thereafter F=m*a rules! We have to accelerate slow enough to never exceed the motors max moment at that speed.

Why do we want S-shape-acceleration? The upper part of the S is about the lower available moment at high speeds. You remember - when we do step slow the coils get the full current where we have the highest moment. When stepping fast we don't have that high currents - not that high moments. So when stepping slow we have a lot of moment available to realise high accelerations, but when stepping fast a lot less.
The lower part of the S is about smoothness of the move. When we apply high moments, we get high displacements between field and rotor. Do you remember the oscillations when we applied full steps?

Because of that (and some more elasticities in the system) we can apply Marlins jerk-speed. It describes the length of the break in between of the first two step pulses. How much the break shrinks is described by acceleration. The number of steps in time is speed, the sum of steps - way. Jerk (in the conventional sense) is variation in acceleration.

EDIT: Still not satisfied with the S-shape chapter.
EDIT: Still no chapter explaining the dynamic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant