# Microstepping not constant on the simulink simulation ee_stepper_motor

5 views (last 30 days)
Martin Gille on 18 Jan 2022
Answered: Abhimenyu on 11 Feb 2024
Hello dear Matlabian,
I have a question regarding the simulink simulation of a stepper motor (ee_stepper_motor):
With its specs (that I choosed):
I want to simulate the operation of a stepper motor. For full and half stepping everything is fine but when I switch to micro stepping there is a difference between the theoretical step and the output shaft angle (I was careful to set the inertia to the minimum: 10^-7). I use a full step size of 1.8 deg and for full stepping I get steps of 1.8 deg and 0.9 deg for half stepping. But for micro stepping the shaft angle step is not constant anymore but I always get the right values for full and half stepping. As you can see on the following figure of the shaft angle (for 1/8 micro stepping):
I would like to know if this is due to the specificities of my stepper motor or the functioning of Matlab (or stepper motors in general)?
Is there a solution to get the right and constant step?
And another question, why, in half and full stepping, the first step goes down instead of up (such as the image below)?
Have a good day,
Martin Gille.

Abhimenyu on 11 Feb 2024
Hello Martin,
I understand that you are trying to simulate a stepper motor in Simulink using the `ee_stepper_motor` block. There are many physical and simulation aspects that can affect the accuracy and behavior of the motor, especially in "microstepping" mode.
When you switch to "microstepping", the shaft angle step becomes non-constant. This behavior is inherent to microstepping and is not specific to the stepper motor or Simulink. "Microstepping" allows for smoother motion by dividing each full step into smaller increments. Instead of abruptly transitioning from one full step to the next, "microstepping" introduces intermediate positions. The "microstepping" process relies on varying the current in the motor windings to achieve these intermediate positions. However, due to the sinusoidal nature of the back electromotive forces (emfs) induced in the windings, the resulting shaft angle steps are not uniform.
While "microstepping" inherently introduces non-constant steps, the variation can be minimized by increasing the "microstepping resolution" (i.e., using more microsteps per full step). Consider using higher "microstepping ratios" (e.g., 1/16, 1/32, or even 1/256) to reduce the angular deviation between consecutive microsteps. Additionally, ensure that your motor driver and controller are capable of handling the desired microstepping resolution. The simulation time step can also impact the accuracy of the simulation. If the time step is too large, it might not capture the nuances of the "microstepping" algorithm. Decrease the simulation time step to capture more detail of the motor's behavior during "microstepping".
The direction of the first step (whether it goes up or down) depends on the initial rotor position relative to the phase winding of pulse A. If the initial rotor position aligns with the phase winding of pulse A (positive current flowing from A+ to A-), the first step will be in the same direction as pulse A. However, if the initial rotor position is different, the first step may go in the opposite direction. This behavior is a consequence of the motor’s winding configuration and the specific phase relationship between pulses A and B. Mechanical "backlash" in the system could also cause the first movement to be in the opposite direction as the motor takes up the slack.
For a better understanding on "microstepping", follow the example as given by this MATLAB R2023b documentation link: https://www.mathworks.com/help/sps/ug/stepper-motor-averaged-mode.html
I hope this helps!
Thanks,
Abhimenyu

### Categories

Find more on Electromechanical in Help Center and File Exchange

R2021b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!