ABSTRACT: In this paper we consider the problem of realization of linear speed profile of stepper motors in real time. The general case is considered when change of speed in the acceleration and deceleration phases is different. An algorithm of the real time speed control is proposed. Comparing this algorithm with the other ones, it was shown that the algorithm is better than the others with respect to the accuracy of speed, but at the same time it is slower. The practical realization of this algorithm, using Arduino platform, is also given.
KEYWORDS: speed control, control algorithm, stepper motors, Arduino
(ProQuest: ... denotes formulae omitted.)
INTRODUCTION
Stepper motor is an electromechanical device that converts electrical digital pulses into mechanical shaft rotation. Many advantages are achieved using this kinds of motors, as: (i) precise positioning and repeatability of movement, (ii) the motor has full torque at standstill (if the windings are energized), (Hi) very reliable and easy maintenance since there are no contact brushes, and (iv) a wide range of rotational speeds can be realized since the speed is proportional to the frequency of the input pulses. Some disadvantages of these motors are: (i) resonance can occur if not controlled properly, and (ii) not easy to operate at f sM ax extremely high speeds, [1,2].
An important issue about stepper motors is that they are usually used in an open control loop. This means that the motor control system has no feedback information about the position, which eliminates expensive sensing and feedback devices.
Many systems with stepper motors need to control the speed using values of acceleration and deceleration defined in advance. Herein we will analyze the general case, when change of speed in the phase acceleration and deceleration is linear and different (ramp speed profile). In Fig. 1 the relation between acceleration a [rad/sec2 ], deceleration d [rad/sec2 ], speed v[rad/s] and position s [rad] is shown.
Since the stepper motor makes steps in discrete time (after each pulse) and the move of every step is constant, the change of speed is achieved by changing the time interval between successive steps (pulses). It means that the main problem of speed control is to determine instants of the time ti (in [sec]) when pulses (steps) are generated. If speed ν is constant ν = const, (independent of whether it is large or small), it is very easy to determine these instants (equivalently, generate the pulses). In this case the time delays ôl, between two arbitrary successive pulses, are the same and they are given as, ?ι? =aiv = const., where a [rad] is the angle of the rotation motor shaft for every step. But, if the speed is variable, v,. ? const., it is more difficult to determine the instants when we need to generate pulses because the time delay between two successive pulses is changed, ?ι? =a/\r φ const.. In the case when acceleration/deceleration is constant, the speed is changed linearly, but the time interval St, between two adjacent pulses is not linear. So, we need to calculate time St,, which ensures linear change in speed. It is shown for the acceleration phases in Fig. 2.
Depending on the method used to calculate this time, generally, there are two groups of algorithms-two methods, named as: "time per step" and "steps per time", that are described in [3,4,5] and [6,7], respectively. The first group of algorithms is mainly realized by using a microcontroller, while the second group is suitable for realization by using FPGA (field programmable gate array) circuits. Both of the above groups of algorithms generate pulses in real time. However, there are alternate techniques where the pulses are generated based on the previously entered table of data, which include all parameters of motion. Using these techniques we can not calculate the time when pulses are generated in real time, because any change of some parameters of the motion imply a change above table of data. Today, these techniques lose their importance, because by increasing microcontroller's speed it becomes possible to perform all the necessary computation within short time, which is less than St,.
In the sequel of the paper we give a new real time algorithm that belongs to the first group of the above mentioned algorithms. The practical implementation of this algorithm that is based on the Arduino platform of the Atmel microcontroller ATMega 328 is also given.
ALGORITHM
As we emphasized earlier, we observe motion with the ramp speed profile, i.e. a = const., d = const., a,d > 0, and let ? φ d. In this case, in order to determine control algorithm it means to solve two problems: to calculate the instants of time when pulses are generated and calculate the characteristic points of the motion in which the algorithm changes its behavior (trajectory planning), see Fig. 1. We will design a controller that solves both problems.
Calculate time when the pulse is generated
The first pulse (step) controller generates at the start of motion, or at the start of the state of acceleration, at the time t0, see Fig. 3. After the first pulse is generated, the controller needs to calculate time period St0 until the next pulse, wait until this period has elapsed, and then generate the next pulse, at time ι?. This will go on until the desired position is achieved, or in other words, the desired number of pulses has been generated. At the start, the speed is v0, and it retains its value until the moment tl when it becomes yi, at the moment t2 becomes v2, and so on. As after each pulse the motor makes one step for the angle a , then the following is valid
... (1)
where the v, is speed at an arbitrary instant of time t, and ?ι? the time delay between two successive instants of time i, and i,. In the case when the controller is realized by using a microcontroller, the required time delay St, is implemented using counter c, that counts impulses of known frequency f, so St, =c,i f is valid . Now ( 1 ) becomes
... (2)
Based on the above considerations, the speed is changed only at the discrete time t,. But, since inertia always exists, thus we can assume that the speed y, between two arbitrary successive instants of time i, , and t,, i> 1, changes linearly (see dashed light lines in Fig. 3). Thus, the speed v,at the arbitrary instant of time t,, and in the phase of acceleration, becomes
... (3)
Using (2) and (3), the value of the counter c, becomes
... (4)
which, after substituting ..., finally becomes
... (5)
In a similar way, in the phase of deceleration, we obtain
... (6)
From (5) and (6) we calculate the time delay c, (or equivalently?ι? ) based on the previous time delay ci ,, / > 1, which is already known. Further, it implies that it is necessary to determine the initial time delay co.
Calculate the initial time delay
In order to determine the initial time delay co, we observe motion during the first step. The first pulse (that is generated at the time t0 ) initiates the first step for the angle a , where a is given as a = \!2·???62 (because the initial speed vol is zero, vol =0 ). It implies that the speed at the end of the first step is vn =a5t6 = -J2aa . Let speed \>o be the mean value of the initial vol and the final vn speed value in the first step, so the following va = 0.5(vol +vn)= 0.5V2aa is valid. This, together with (4), gives
... (7)
In the case when speed is constant, ν = const., the time delay c, is determined (using (4)), as ci = af/ν,. For the maximum speed ν = vM, the time delay c, = cm is minimum, and it is given as,
... (8)
Simulation and correction of the algorithm
In Fig. 4. and Fig. 5., the results of simulations of the algorithm that is proposed by Eqs. (5), (6), (7) and (8) are given (in Fig. 4 whole profile and in Fig. 5 only a part of the profile in the acceleration phase). These results are given for a stepper motor with 64 steps per round, and with the following parameters of motion: vM = 3 , a = 4 , d = 2 .
We have also compared different types of algorithms, as: this algorithm (speed v- dashed lines) and algorithm that is widely used, and which is proposed in [4] (speed va - light solid line). It is easy to see that they are nearly the same except in the initial steps (one or two steps). In both cases, the step speed is greater than the linear speed (see Fig. 5). In order to decrease the difference from step speed and linear speed, we need to introduce some corrections. If in the acceleration phase, after the time delay c, is calculated by (6), we introduce correction in the form
... (9)
we obtain the new step speed vk - dark solid line in Fig. 5. We can see that the correction step speed vk is much better than the previous uncorrected step speed ν or va (i.e. difference between the step speed vk and the linear speed v, at the time ti is significantly smaller). In the same way, correction in the last five steps of the deceleration phase is done, so that the time delay in the last steps of this phase is given as
... (10)
where the total number of steps during the desired motion is denoted by π, see Fig. 7.
The speed error (it is defined as the difference between analog and step speed) for the cases: this algorithm (uncorrected and corrected) and the algorithm in [4] is shown in Fig.6. (error in the first step is omitted).
TRAJECTORY PLANNING
We need to determine characteristics points of the ramp speed profile where the algorithm changes. Continuous motion and in the case when acceleration and deceleration are the same (for various ways of their change) is described in [8] and [9]. Herein we consider discrete motion for the linear ramp speed profile, see Fig. 7.
For each stepper motor, next parameters must be known: maximum speed, maximum acceleration, maximum start speed and number of steps per round1 (spr). In addition, at the beginning of each motion the following parameters of motion are also known: desired position sMax [rad] or the total number of steps π, desired speed vd , acceleration a and deceleration d . The number of the steps π (see labels in Fig.7.) is calculated as π = sMax/a , where a = 2π/spr [rad] is an angle for one step. In this paper we assume that all phases of motion are finished during η steps exactly. In order to calculate remaining parameters of the speed profile, we use two different approaches which are dependent on the following: (i) desired speed is reached before the start of deceleration (trapezoidal speed profile, Fig. 7, solid line, vd <vr) and (ii) deceleration starts before desired speed has been reached (triangular speed profile, Fig. 7, dashed line, vd >vr). As to which of these speed profiles should be used, it is dependent on values na and nad, where na is the number of steps that are needed to reach desired speed vd during acceleration and nad is the first step when the deceleration phase starts. From the reached speed vr and during next (n-nad) steps, the speed decreases from vr to the zero value. Now, the cases (i) and (ii) expressed with number of the steps na and nad become: ?ad > na and na > nad, respectively. In both cases the speed at the end of acceleration must be the same as the speed at the start of deceleration (due to the continuity of motion), which implies
... (11)
On the other hand, to achieve the desired speed vd = at. ie[0TJ in the acceleration phase, movement sa = naa is given as
... (12)
The number of steps nd when deceleration starts in case (i) is calculated from cma =d{n-nd) which implies nd = n-na-a/d, and in the case (ii) it is the same na, i.e. nd =na =nad(see more details in Arduino program).
IMPLEMENTATION OF THE ALGORITHM
Based on the consideration in the Sections II and III, the proposed algorithm is implemented by using the microcontroller ATMega328.
As the hardware components we use: Arduino UNO unit, 28BYJ-48 stepper motor (power supply 5V-DC, 4096 spr, because the motor has 64 steps and a gear unit with 64:1 ratio, 64*64=4096) and driver based on the ULN 2003 circuit. A program that realized the above algorithm is given in the appendix of the paper and it is adjusted for Arduino platform of the Atmel microcontroller. The desired data such as angle of positioning, speed, acceleration and deceleration are obtained from a program console using serial communication. The equipment and devices for the experiment are shown in Fig. 8.
CONCLUSIONS
According to the results of the experiment and simulation, we can conclude that the algorithm which is proposed by equations (5)-(10) satisfies the expected results completely. The difference between linear speed and step speed, in comparison with the algorithm in [4], is significantly smaller, so from this point of view the proposed algorithm is better, but it is weaker in relation to the time of computing. Generally, we can conclude that the proposed algorithm is better than the one in [4] for lower speed of stepper motors. Also, it is clear that this speed limit depends on the applied hardware and software. In our case, for the Arduino platform and devices that are shown in Fig. 8., this speed limit is close to 5000 steps per second (5kHz).
1 these parameters will be specified by a motor manufacturer
REFERENCES
[1.] Industrial Circuits Application Note. "Stepper Motor Basics", http://wvm.solarbotics.net/ library/pdflib/pdf/motor- bas.pdf
[2.] Reston Condit, Dr. Douglas W. Jones, "Stepping Motors Fundamentals", Microchip AN907, http://homepage.cs.uio- wa.edu/~jones /step/ an907a.pdf
[3.] Atmel Corporation, "AVR446: Linear speed control of stepper motor", Application note, http://fab.cba.mit.edu/classes/ MIT/961.09/prjects!iO!doc8017.pdf
[4.] David Austin, "Generate stepper motor speed profiles in real time", Embedded Systems Programming, January 2005, www.embedded.com/56800129
[5.] Aryeh Eiderman, "Real Time Stepper Motor Linear Ramping Just by Addition and Multipli-cation," http://hwml.com/ LeibRamp.pdf
[6.] Pramod Ranade, "Linear Motor Control Witdout the Math,"SPJ Embedded Technologies, April 2009, https://www.eeti- mes.com/design/other/4026992/
[7.] http://picprog.strongedge.net/step _prof/step-profile.html
[8.] Paul Lambrechts, Matthijs Boerlage, Maarten Steinbuch, "Trajectory planning and feedforward design for electromechanical motion systems," Control Engineering Practice 13 (2005) 145-157, ScienceDirect
[9.] Mihajlo J. Stojcic, "Design electromechanical positioning system with controlled jerk", Heavy Machinery - HM2011, pp. 13-17
1. Mihaylo Y. STOYCHITCH
1. Faculty of Mechanical Engineering, University of Banja Luka, VojvodeStepe71, 78000 Banja Luka, BOSNIA AND HERZEGOVINA WÀ
(ProQuest: Appendix omitted.)
You have requested "on-the-fly" machine translation of selected content from our databases. This functionality is provided solely for your convenience and is in no way intended to replace human translation. Show full disclaimer
Neither ProQuest nor its licensors make any representations or warranties with respect to the translations. The translations are automatically generated "AS IS" and "AS AVAILABLE" and are not retained in our systems. PROQUEST AND ITS LICENSORS SPECIFICALLY DISCLAIM ANY AND ALL EXPRESS OR IMPLIED WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES FOR AVAILABILITY, ACCURACY, TIMELINESS, COMPLETENESS, NON-INFRINGMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Your use of the translations is subject to all use restrictions contained in your Electronic Products License Agreement and by using the translation functionality you agree to forgo any and all claims against ProQuest or its licensors for your use of the translation functionality and any output derived there from. Hide full disclaimer
Copyright Faculty of Engineering Hunedoara 2013
Abstract
In this paper we consider the problem of realization of linear speed profile of stepper motors in real time. The general case is considered when change of speed in the acceleration and deceleration phases is different. An algorithm of the real time speed control is proposed. Comparing this algorithm with the other ones, it was shown that the algorithm is better than the others with respect to the accuracy of speed, but at the same time it is slower. The practical realization of this algorithm, using Arduino platform, is also given. [PUBLICATION ABSTRACT]
You have requested "on-the-fly" machine translation of selected content from our databases. This functionality is provided solely for your convenience and is in no way intended to replace human translation. Show full disclaimer
Neither ProQuest nor its licensors make any representations or warranties with respect to the translations. The translations are automatically generated "AS IS" and "AS AVAILABLE" and are not retained in our systems. PROQUEST AND ITS LICENSORS SPECIFICALLY DISCLAIM ANY AND ALL EXPRESS OR IMPLIED WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES FOR AVAILABILITY, ACCURACY, TIMELINESS, COMPLETENESS, NON-INFRINGMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Your use of the translations is subject to all use restrictions contained in your Electronic Products License Agreement and by using the translation functionality you agree to forgo any and all claims against ProQuest or its licensors for your use of the translation functionality and any output derived there from. Hide full disclaimer