Development of Microprocessor, Time Optimized Stepper Motor Driving Algorithm
Development of Microprocessor, Time Optimized Stepper Motor Driving Algorithm
Development of Microprocessor, Time Optimized Stepper Motor Driving Algorithm
Move
I. I NTRODUCTION smoothness
low low low low high high high high
It is preferable if the MS parameter is a power of 2 in Listing 1 shows how are the thresholds calculated in MAT-
order to make the calculations easier and avoid using LAB code. The variable G N R is obtained from Equation 4 and
fraction numbers in the microcontroller. MMV is obtained from equation 2. A vector of generic speed
values is generated at first (mmvMaxStages). The vector is
• Maximum commutation frequency [Hz] (CM): This flipped in order for higher gears to indicate higher speeds (this
variable is dependent on the application complexity and step is done for the purpose of clarification of the procedure).
motor torque – speed characteristics. It decides on how Then each element is multiplied by a factor bigger than one for
fast the motor windings current can be commutated. the acceleration vector and less than one for deceleration. In
175
2017 22ND INTERNATIONAL CONFERENCE ON METHODS AND MODELS IN AUTOMATION AND ROBOTICS (MMAR) 3
TABLE II
ROUNDED VELOCITY [ RPM ] THRESHOLD VALUES GENERATED FOR
ACCELERATING AND DECELERATING OF THE ROTOR , FOR CM = 5000 HZ
AND MMV = 1500 RPM
Gear 0 1 2 3 4 5 6 7
Microsteps 128 64 32 16 8 4 2 1
Accel [RPM] 13 26 52 103 206 412 825 1650
Decel [RPM] 11 21 42 84 169 338 675 1350
C. Control loop calculations Fig. 2. One of the control systems used for algorithm implementation; A)
32 bit DSP microcontroller based board, B) customized power electronics
After performing all preliminary calculations the motor can daughter board, C) 23D-6309C stepper motor (American Precision), D)
externally coupled SCH24 rotary incremental encoder (Scancon)
be started and the actual commutation (stepping) frequency
can be calculated in the control loop, along with the actual
gear number. D. Experimental hardware setup
The tests performed for the purpose of this paper were
The experimental setup control loop frequency was set to
conducted using a universal motor driving platform. Fig. 2
1000 Hz. New gear is then obtained every 1 ms from Equation
shows the device and the peripherals. This driver is a prototype
5. The result is then rounded down to an integer value.
built upon Launchxl-F28377S Texas Instruments board. The
hardware is capable of driving two motors simultaneously
M MVA/D without any lags, thanks to the procedure presented in the
G = G N R − log2 ( )−1 (5)
CV paper. For the test only one motor was used. The algorithm
software layer itself is hardware independent.
CV variable stands for current rotor velocity [RPM]. It is
obtained by calculating the derivative of the rotor position
(Equation 6), which is indirectly read from the attached E. Experimental results
encoder mounted on the shaft. The data presented in the example diagrams was acquired
from the driver (Fig. 2) in real time using a serial protocol,
∆S while the motor was running. Each sample was taken at 10
CV = (6)
∆t ms rate. The data was then plotted using MATLAB. Fig 3
presents the first test performed at a medium CC of 5000 Hz.
Where:
Vmax and Amax are the maximum velocity and acceleration
◦ ∆S – the distance difference between current position of the trajectory generator, which is feeding the controller
and the position obtained in the last ∆t time quantum., (Fig. 1) with SET POSITION in the control loop. The top
◦ ∆t – time rate at which position measures are taken. plot shows that the real position is acquired very precisely
In this setup it is 1 ms. and smoothly (0.018◦ resolution). The velocity regulator has
little jitter (around 0.4 RPM per second), but mostly overlaps
M MVA/D is the last item of the acceleration or deceleration the set point curve. Two bottom plots show the calculated
gear threshold vector. The chosen vector is based on the gear and commutation frequency variables respectively. For
dynamic parameter of the movement (positive or negative this set of parameters the driver uses the fifth gear at the
velocity error indicates that accordingly in Fig. 1). Using the maximum velocity of 200 RPM, thus it is never leaving
control loop routine, after obtaining the gear number G, the the micro stepping mode. It can be noticed that the gears
commutation frequency can be calculated (Equation 7). are changed fast during the beginning of acceleration and
the end of deceleration phases respectively. Consequently,
MRES CV
60
the stepping frequency changes in the same fashion, never
CC = (7) exceeding the 110 % of MVV (for acceleration phase). The
2G
highest commutation frequency noted in this test was 5492 Hz.
Current commutation frequency CC [Hz] indicates at what
rate new steps (or microsteps, which value depends on the G Fig. 4 shows a similar test where six movement commands
variable) are taken by the motor. are executed as well. This time the maximum commutation
176
4 2017 22ND INTERNATIONAL CONFERENCE ON METHODS AND MODELS IN AUTOMATION AND ROBOTICS (MMAR)
3000 3000
2000 2000
1000 1000
0 0
0 5 10 15 20 25 30 35 40 45 0 10 20 30 40 50 60
Vel set [RPM] Vel set [RPM]
Vel measured [RPM] Vel measured [RPM]
400 400
200 200
0 0
-200 -200
-400 -400
0 5 10 15 20 25 30 35 40 45 0 10 20 30 40 50 60
G G
5 4
4
3
3
2
2
1
1
0 0
0 5 10 15 20 25 30 35 40 45 0 10 20 30 40 50 60
CC CC
6000 10000
8000
4000
6000
4000
2000
2000
0 0
0 5 10 15 20 25 30 35 40 45 0 10 20 30 40 50 60
Time [s] Time [s]
Fig. 3. Example plots for CM = 5000 Hz, Vma x = 200 RPM, A ma x = 100 Fig. 4. Example plots for CM = 8000 Hz, Vma x = 200 RPM, A ma x = 100
RPM2 RPM2
frequency MVV was set to 8000 Hz instead of 5000 Hz. It velocity [6]. In the algorithm, the driver operates in the
can be noticed how the highest reachable gear is lower than micro stepping mode for the most of the gears but last. At
the one from Fig. 3. It means that the motor is driven with the last gear, controller can shift into full step mode, as the
higher micro stepping resolution for longer period of time amount of micro steps is equal to 1. In the full step mode
during the rotation, thus the movement is smoother. This is of the torque is twice as high as in micro stepping mode (Table I).
practical importance as microcontroller resources are heavily
used. A new step is made at 125 µs rate instead of 200 µs, In order to force the algorithm to use the full gear range,
thus, other system procedures are interrupted more often. one has to feed it with low MVV value. Fig. 5 presents
exemplary results for MVV set to 1000 Hz. The maximum
Operating on a low gear has an additional drawback. As possible gear number is acquired near the Vmax as expected.
the stepper motor is a permanent magnet brushless machine, One can notice however that the velocity set curve has a lot
its torque curve decreases along with increasing rotation higher jitter than in the Fig. 3 and Fig. 4. Again, because
177
2017 22ND INTERNATIONAL CONFERENCE ON METHODS AND MODELS IN AUTOMATION AND ROBOTICS (MMAR) 5
TABLE III
A MOUNT OF RESOURCES USED IN AN EXAMPLE PROGRAM FOR CM =
Pos set [Deg] 5000 H Z , Vma x = 200 RPM , A ma x = 100 RPM2 , PC SAMPLES POOL =
Pos measured [Deg] 70100
4000
3000
Function Resources in use No. of PC samples
motSetNextCCR() 26,64 % 18674
2000
taskcontrolLoop() 15,35 % 10760
1000 startSystemTask() 6,17 % 4325
0
0 5 10 15 20 25 30 35 40 45 TABLE IV
Vel set [RPM] A MOUNT OF RESOURCES USED IN AN EXAMPLE PROGRAM FOR CM =
Vel measured [RPM] 1000 H Z , Vma x = 200 RPM , A ma x = 100 RPM2 , PC SAMPLES POOL =
400 79320
200
Function Resources in use No. of PC samples
G
8
Similar results are shown in Table 4 for the program from
6
Fig 5. It can be noticed that the percentage ratio between
the function motSetNextCCR and the other two changed
4 significantly. The former function is executed less often than
when the stepping frequency was set to 5000 Hz, leaving more
2
resources for other system tasks and interrupt routines.
0
0 5 10 15 20 25 30 35 40 45
IV. C ONCLUSIONS
CC
1500 The results show that the microcontroller time optimization
procedure during automatic stepper mode control given in the
1000
paper is operational and gives good results. It is configurable
and should be set adequately to the application. If high
precision and smooth motion is desired, one should set
500
maximum commutation frequency. If high torque or low
resources are important, then low commutation frequency
0
0 5 10 15 20 25 30 35 40 45 should be used.
Time [s]
The algorithm was used in several industrial applications
with success, including applications like 3D printers and Pick
and Place machines.
Fig. 5. Example plots for CM = 1000 Hz, Vma x = 200 RPM, A ma x = 100
RPM2 R EFERENCES
[1] Łukasz Przeniosło, “Universal smart electric motors controller for indus-
try applications,” Westpomeranian University of Technology, 2016.
of their construction stepper motors suffer from high torque [2] M. Bendjedia, Y. Ait-Amirat, B. Walther, and A. Berthon, “Position
ripples at low speeds [7]. control of a sensorless stepper motor,” IEEE Transactions on Power
Electronics, vol. 27, no. 2, pp. 578–587, Feb 2012.
[3] D. R. Gaan, M. Kumar, and C. G. Majumder, “Variable rate based
Table III presents how the resources are used by three microstepping of stepper motor using matlab gui,” in 2017 Indian Control
most resource heavy functions in the program from Fig. Conference (ICC), Jan 2017, pp. 385–390.
[4] M. Bendjedia, Y. Ait-Amirat, B. Walther, and A. Berthon, “Sensorless
3. The measurement was made by checking how often the control of hybrid stepper motor,” in 2007 European Conference on Power
PC (program counter) was located within a certain function Electronics and Applications, Sept 2007, pp. 1–10.
address. For example in Table III, program counter was [5] K. Zawirski, J. Deskur, and T. Kaczmarek, Automatyka nap˛edu elek-
trycznego, 1st ed. Wydawnictwo Politechniki Poznańskiej, Poznań 2012.
monitored 18674 times (on 70100 total samples) within [6] J. Przepiórkowski, Silniki elektryczne w praktyce elektronika, 2nd ed.
function motSetNextCCR, which is used for stepper motor BTC, Warsaw 2012.
commutation. The measurement was taken using True Studio [7] M. Piccoli and M. Yim, “Cogging Torque Ripple Minimization via
software from Atollic (SWV Statistical Profiling tool). Position-Based Characterization,” Robotics: Science and Systems X, 2015.
178
6 2017 22ND INTERNATIONAL CONFERENCE ON METHODS AND MODELS IN AUTOMATION AND ROBOTICS (MMAR)
179