[go: up one dir, main page]

0% found this document useful (0 votes)
44 views6 pages

Synchronized Control of Four or More Stepper Motors For Computer Numerical Controled Machines and 3D Printers

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 6

Proc.

of the 6th International Conference on Applied Innovations in IT, (ICAIIT), March 2018

Synchronized Control of Four or More Stepper Motors for Computer


Numerical Controled Machines and 3D Printers

Nikola Jovanovski1 and Josif Kjosev2


1,2Institute of Electronics, Faculty of Electrical Engineering and Information Technologies, Ss. Cyril and
MethodiusUniversity, Skopje, Republic of Macedonia
jnikola@feit.ukim.edu.mk, josif@feit.ukim.edu.mk

Keywords: CNC machine, CNC machining, CNC milling machine, 3D printer, 3D printing, Stepper motor control.

Abstract: A simple and effective algorithm for synchronized control of four or more stepper motors for computer
numerical control machines is presented. Advantages and disadvantages of stepper and servo motors for
CNC machines are discussed. Various control topologies for stepper motors are analyzed. Different types of
stepper motor drivers and their characteristics are explained. The main emphasis is on the algorithm for
synchronous control of multiple motors. The mathematical background for moving functions is explained in
context of an overall 3D printing process. A practical implementation of the algorithm is evaluated.
Possible directions for further research in this area are pointed.

1 INTRODUCTION be the most appropriate. The main controller should


be also suitably selected for the dual purpose. These
issues have been discussed in a previous paper [5].
The Computer Numerical Control (CNC) is a
CNC machine motion can be performed with AC
technology that uses microcomputers to generate,
or DC servo motors or stepper motors. Servo motors
parse and execute the sequential control that
require additional positioning sensors and closed
describes the end effector’s behavior. The
loop control systems. Stepper motors are very
application of this technique is often used in turning,
accurate in open loop systems [2][5] and are simple
drilling, milling or extruding machines. Recently its
to control provided that the maximal required torque
application has expanded to other tasks, such as:
at the maximal required speed is available [4][6].
electronic components insertion, tube welding, and
cutting robots [1]. While these technologies are at
the top of the third industrial revolution, today we
are facing the fourth industrial revolution where one
of the main driving forces will be 3D printing [12].
The idea behind this paper is to research the
possibilities for designing an electro-mechanical
system that can be used both as a 3D printer and a
CNC machine. The focus in this paper is placed on
the 3D printer issues, specifically, the synchronized
control of 4 or more stepper motors. These results
can be reused for CNC milling machines with some
additional components [5].
The starting points are: the mechanical
construction, mechanisms for movement and their
integration. A 3D model of the machine is shown in
figure 1. Speed and forces (torques) calculations
define the motors and motor drivers selection. There Figure 1: 3D printer model.
are various types of printer heads but for this dual-
purpose machine a thermal extruder type appears to

45
Proc. of the 6th International Conference on Applied Innovations in IT, (ICAIIT), March 2018

A specific issue regarding motion control is the


multiple axes motion synchronization. This is a very
complex task with servo motors but is also nontrivial
with stepper motors. 3D printer manufacturers have
proprietary control algorithms that are not accessible
for performing experiments. Open source
community projects are available for this purpose
but, again, better performing algorithms are usually Figure 3: Peak winding current decreasing at higher speed,
encapsulated in binary libraries. Some motor and limited by motor inductance [9].
controller manufacturers offer PLC controllers that
provide 2-axes synchronization with speed control
The current is obtained by connecting the coils to
[13] but PLCs are an expensive overkill with the
a voltage source V through appropriate electronic
additional (unnecessary) options they have. They
also do not provide solutions for 3 or more axis switches (a stepper motor driver). One step is a
synchronization. In this paper we present a very sequence of two coils (or four coils) sequentially
efficient algorithm for synchronized stepper motors energized/de-energized (pulsed) and it corresponds
control that uses small number of operations to a rotation by a predefined angle (typically 1.8° for
compared with the algorithm for linear interpolation a 200-step motor).
explained in the literature [3]. The results are based The coils resemble first order circuits with their
on real experiments with a 3D printer designed from inductance L and resistance R. This means the
scratch in our laboratory to experiment with currents through the coils change exponentially:
different types of stepper motors and algorithms.
−t τ
i ( t ) = I ( ∞ ) −  I ( ∞ ) − I ( 0 )  e

where I(0) is the starting current, I(∝)=V/R is the


2 STEPPER MOTOR DRIVE steady state current and τ=L/R is the time-constant
TOPOLOGIES of the circuit. A complete current change takes
approximately 3τ. This limits the maximal
The following is a brief review of the stepper motor applicable step rate i.e. rotational speed of the motor
operation and their drive topologies. Stepper motors at full torque because the torque depends on the coil
usually have permanent magnet rotor and two (or current amplitude – figure 3.
four) groups of windings on the stator as presented The time-constant can be reduced by increasing
in figure 2. The group of windings is presented as R, and correspondingly V, externally by a same
coils at 90 degrees which are called “electrical factor n (typically 4-5) to retain the nominal current.
degrees” while the windings are positioned at certain Unfortunately this increases the power loses nRI2 to
spatial angle such that a 360° electrical angle an unacceptable level. The solution is the Pulse
corresponds to a much smaller spatial angle (eg. Width Modulation (PWM) technique which can
7.2°). provide (on average) the nominal coil current at
The rotor is moved by changing the current much higher voltage with minimum power loses –
through the coils in appropriate sequence such that figures 4 and 5.
magnetic forces attract or repel the rotor to support
the rotation. If the currents through the coils change
direction, the motor is named bipolar. Otherwise it is
unipolar.

Figure 4: Switch mode drive implementation [9].

Figure 2: Stepper motor principle diagram.

46
Proc. of the 6th International Conference on Applied Innovations in IT, (ICAIIT), March 2018

Typical stepper motor driver has three control


inputs:
• ENABLE/DISABLE (“zero” means the
driver is disabled and the motor is turned
off, while “one” puts the motor in the hold
torque state).
• DIRECTION (“zero” drives the motor in
clockwise direction, and “one” drives the
motor in counter-clockwise direction)
• PULSE (each pulse at this input means
rotation of 1 (micro-)step of the motor in
the direction selected by DIRECTION
input)
Figure 5: Current waveforms for L/R, L/nR and Switch
mode drive [9]. These signals are generated by the control unit’s
firmware. Central part of this firmware is the
optimized software algorithm for multiple motor
3 STEPPER MOTOR DRIVERS driving, which is presented in the following sections.

Simplest stepper motor drivers provide full-step and


sometimes half-step driving. For a two-phase motor 4 3D PRINTER PRACTICAL
a full step consists of complete sequential de- IMPLEMENTATION
energizing and energizing of the two coils and
provides rotation of 90° electrical. Half-step is
Besides the previously mentioned electromechanical
achieved by energizing both coils with the same
components, the complete 3D printer includes:
polarity. This positions the rotor at 45° electrical and
-CAD software for designing and rasterizing the
doubles the number of pulses for a revolution but
parts to be printed and generating commands in the
increases the positioning resolution.
standard CNC language named G-code,
The previous idea can be extended further: if the
-control unit (microcontroller),
currents in the energized coils are not equal, the
-methods for transferring the G-code to the
rotor can be positioned at any angle between 0 an
control unit,
90°, depending on the current ratio. This technique
-control unit firmware for coordinates
is called microstepping and provides substantial
calculations and motor driving signals generation,
increase of the positioning resolution. Modern PWM
-user interface.
stepper controllers are ideal for providing the
microstepping control technique. They can typically The implemented CAD software is Pronterface
increase the number of steps up to 16 times (eg. HY- (free open-source software) with it’s rendering
DIV268N) or up to 256 times (eg. DQ860MA). engine Slic3r that slices the part into printable
CNC machines convert the motor rotation into layers. The generated G-code specifies sequence of
linear motion by ball screws. A standard value of coordinates for linear X-Y axes movement and the
5mm displacement is obtained for each motor required speed for each movement including the
revolution. Thus a typical 200-pulse motor provides extruder for material deposition as coordinate E. The
0.025mm linear resolution. This is much above the movement in Z direction is generated only once for
required resolution. If microstepping with 16 each layer to be printed.
microsteps is applied, the resolution becomes 1.56 The control unit is based on STM32F4Discovery
micrometer which is satisfactory [11]. A 256 board with a CortexM4 microcontroller running on
microsteps would provide resolution below 0.1 168MHz.
micrometer that is more than satisfactory [10]. G-commands are transferred through serial
Actually, uncompensated motor errors are much communication at the rate of 115 kbps. New
higher than this resolution [14] when absolute command is transferred after the current is
positioning is needed but position calculations can completed.
also accumulate errors that should be kept below the
CAD resolution (which is typically at 1 micrometer).
Additional benefits of high frequency microstepping
are smooth motion, reduced motor noise, and
reduced possibility for electro-mechanical resonance
and oscillations [14].

47
Proc. of the 6th International Conference on Applied Innovations in IT, (ICAIIT), March 2018

Calculate Timers
Decrement New G period
numofSteps; command

MoveToXcoordinate(X2);
Yes Movement Yes
numofStep command?
s>0?
Calculate number of
steps for(X2-X1) and
No No
direction;
Implement
Stop Timer;
command

MOTOR ISR USART ISR XMove(numSteps,direc


tion);
MoveToXcoordinate(…);

Main Other Set numOfSteps;


While tasks; Set direction;

Turn on timer for


motor X; Figure 7: Movement path between two points without
XMove(…); linear interpolation.
Figure 6: Firmware principle block diagram.
Obviously, the speeds along X and Y axes must
be different to accomplish the required movement
The firmware of the controller consists of many
along the dashed line. The distance and the speed
functions (communication, coordinate interpolation,
components along the X and Y axis are shown in
motor control, extruder heating PID control, sensor
Figure 8.
scan, user interface through a graphical touch-
The problem here is to determine the values of
screen, and some other housekeeping functions).
the X and Y components of the velocity. Since the
Motor control functions are timer interrupt-driven
CAD system actually defines the speed of the
and have the highest priority. Communication is also
material extrusion V (mm/min) it can be applied
interrupt driven at a lower level and incorporates the
only to the direct distance between the points (1) and
linear interpolation calculations. The lowest
(2), Therefore first we needed to calculate the
interrupt driven function is the PID heater control
distance S from the starting point to the destination
(not shown here). All other functions are reaized in
point. We calculate the coordinate changes Δ𝑋𝑋 and
an infinite loop. The principal block-diagram of the
Δ𝑌𝑌 from the following equations:
firmware is presented in figure 6.
The current position is tracked through four ∆X = | X − X |, ∆Y = | Y − Y | .
global variables (X,Y,Z,E) which are updated on 2 1 2 1
each motor step. The target position, sent by the and then the distance :
CAD system, is kept in the variables X2, Y2, E2 and
speed, (As previously mentioned, Z movement is S= ∆X 2 + ∆Y 2
accomplished separately between layers and will not
be discussed here.) Now the travel time is determined from the
The origin (0,0,0,0) is established at power-up of following equation:
the machine. The printer moves into negative S [mm]
t= .
direction until proximity switches are activated to set V [mm / min]
the spatial origin (0,0,0) while the extruder Since the extruder travels the distances Δ𝑋𝑋 and
coordinate at start-up is 0 by definition. Δ𝑌𝑌 during time t, the components of the velocity can
be calculated by the following equations:
∆X [mm] ∆Y [mm]
5 SOFTWARE = VX = , VY .
t[min] t[min]
IMPLEMENTATION OF
LINEAR INTERPOLATION
BETWEEN TWO POINTS
The need for linear interpolation can be depicted in
figure 7. If movement is to be accomplished from
point (X1,Y1) to point (X2,Y2) and the required
numbers of steps for the X and Y axes movements
are generated with the same frequency, a movement
along the dotted line will be performed instead of a Figure 8: Interpolation of distance and velocity between
movement along the dashed line. two points.

48
Proc. of the 6th International Conference on Applied Innovations in IT, (ICAIIT), March 2018

The number of pulses for the required movement After completing the current movement, new
in the 𝑋𝑋 and 𝑌𝑌 directions, Δ𝑋𝑋 and Δ𝑌𝑌, can be point is obtained, calculations are performed and the
calculated from the known koeficient of the spindle, process is repeated until a stop command is received.
5mm/revolution, number of steps per revolution The firmware is heavily interrupt driven and
(200) and number of microsteps per step of the timing calculations have to be performed to check
motor controler. Similar calculation holds for the the processor utilization and confirm that every task
extruder but here the distance is S. can be completed.
The velocity in each direction is determined by The realized prototype has maximum linear
the frequency of steps the motor performs i.e. the speed of 600mm/min, microstepping factor of 128,
frequency of pulses applied to the PULSE imput of 200 steps per motor revolution and 5mm linear
the controller. The easiest way to generate pulses motion per revolution. This gives the lowest
with certain frequency (or period) is to use a interrupt period of Tm=19.5us. The non-optimized
timer/counter in PWM mode and set the period of code produced interrupt routines of maximum
the PWM waveform. The duty cycle is not important Tpm=0.325us.
because the motor controller takes care of the PWM The communication between the controller and
duty cycle applied to the motor. Therefore the pulse Pronterface transfers 34 bytes for each point. Since
duration can be set to the maximum applicable the maximal point distance is 0.1mm the
value. If the current in the coil rampes above the 600mm/min requires 100 transfers per second. The
maximal value, it would be limited by the power four time_and_number_of_pulses calculation
supply current limit. routines take approx. Tpcalc=0.35us each and are
By seting the timer prescalers, depending on the called at period of Tcalc=10000us. Each byte is also
timer frequency and drivers microstepping factors, collected by an interrupt that takes less than
the following calculation can be established: Tpch=0.15us at a period of approx. Tch=100us.
CONSTx CONSTy The total utilization of the processor by the
= TX = [us ], TY [us ]. interrupt routines is:
VX [mm / min] VY [mm / min]
Similar calculation holds for the extruder: T T T 
Utilization= 4  Pch + Pcalc + Pm = 0.073
CONSTe  T T T 
= T ⋅ t[us ]  ch calc m 
E E −E
2 1 This means that the processor has very low
where CONSTe is the appropriate scaling constant. utilization of 7.3% and can easily control much more
These values ( TX , TY , TE ) are directly written than 4 motors. This is accomplished by efficient
into the registers that define the timer periods implementation of the motor control algorithm using
associated with X, Y and E axes which is timer peripherals.
acomplished with the function: This also leaves space for linear velocity increase
up to the maximally obtainable form Pronterface of
void MoveXY(double x2, double y2, 2000mm/min and it would not reduce substantially
double e2, double speed); the number of motors because at higher speeds the
microstepping factor is also reduced.
The same function calculates the number of steps The higher speed may interfere with the current
for each coordinate and activates the appropriate baud rate of 115kbps. At 10 bits per byte
timer. This is presented on the right-hand side of (1start+8data+1stop) 34 bytes take 3.4ms while the
figure 6. maximal point rate of 20000points/min means 3ms
for a point. The remedy would be to increase the
baud rate to the maximum specified by Pronterface
6 SOFTWARE of 250kbps [15].
IMPLEMENTATION TIMING
ANALYSIS
7 CONCLUSIONS
As mentioned before, the current position of the
printer is tracked through four global variables This paper presents an efficient and simple
(X,Y,Z,E). These variables are updated on every algorithm for synchronized control of four or more
motor step i.e. at every timer pulse in an interrupt stepper motors. The algorithm and the 3D printer
routine. (Timers generate interrupts on the falling prototype provide a solid base for further research in
edge of every pulse). The interrupt routine (only for this area.
X-axis) is presented in red colour in Figure 6.

49
Proc. of the 6th International Conference on Applied Innovations in IT, (ICAIIT), March 2018

The prototype achieves high resolution at the [12] Executive Perspectives “Accelerating the Next
expense of slightly reduced printing speed. This is Industrial Revolution”, https://spare-parts-
3d.com/2017/04/18/3d-printing-key-driver-4th-
due to the massive mechanical construction that industrial-revolution-hp-ceo/
provides higher accuracy but also requires higher [13] Eaton Logic Controller Programming Manual,
power drive unit compared to typical commercial http://www.eaton.com/ecm/groups/public/@pub/@el
printers. On the other hand, the massive construction ectrical/documents/content/mn05003003e.pdf
is needed for the alternative CNC subtractive [14] Ericsson, Industrial Circuits Application Note,
processing. Microstepping, http://users.ece.utexas.edu/~valvano/
Other possible direction for experimenting is Datasheets/StepperMicrostep.pdf
variable printing speed. This option is not available [15] Plastic Scribbler, Printing the Future in 3D
(Pronterface tutorial), http://www.plasticscribbler.
in today's commercial 3D printers. Additionally, it com/tutorial/getting-started/item/21-getting-started-
should be emphasized that this kind of stepper motor with-pronterface#.WlGh4oWcEwE
implementation provides a reliable and accurate way
of 3D printing without using a feedback link from
the motors. This topics will be presented in a
following paper.

REFERENCES
[1] Paulo Augusto Sherring da Rocha Junior,Rogerio
Diogne de Silva e Souza, Maria Emilia de Lima
Tostes, “Prototype CNC Machine Design”,
10.1109/INDUSCON.2010.5740068.
[2] J.M. Rosario, L.K. Rincon, D.Kubiak, D. Dumur,
L.F.Melo, “Actuator Selection of CNC Machine Tool
Based in Dynamical Modeling and Control”,
International Symposium on Power Electronics,
Electrical Drives, Automation and Motion, 2014.
[3] Dev P. Desai, Dr. D.M. Patel, “Design of Control
Unit for CNC Machine Tool using Arduino based
Embedded System”, International Conference on
Smart Techologies and Management for Computing,
Communication, Controls, Energy and Materials
(ICSTM), India, 6-8 May 2015, pp. 443-448.
[4] Industrial Circuits Application Note Stepper Motor
Basics, http://www.solarbotics.net/library/pdflib/pdf/
motorbas.pdf.
[5] Nikola Jovanovski, Josif Kjosev, “Hardware and
Software aspects of 3D printers”, International
Conference ETAI, 2016.
[6] Suk-Hwan Suh, Seong-Kyoon Kang, Dae-Hyuk
Chung, Ian Stroud, “Theory and design of CNC
Systems, 2008 Springer-Verlag London Limited.
[7] Jacob Bayless, Mo Chen, Bing Dai, “Wire
Embedding 3D Printer”, Engineering Physics,
University of British Columbia, April 12, 2010.
[8] Jonathan Heathcote, “Improving the Makerbot 3D
Printer”, University of Manchester, School of
Computer Science, Project Report 2012.
[9] Thomas Hopkins, Aplication note, Stepper motor
driving, http://www.st.com/content/ccc/resource/
technical/document/application_note/57/c8/7c/c1/0d/
91/46/89/CD00003774.pdf/files/CD00003774.pdf/jcr
:content/translations/en.CD00003774.pdf.
[10] Wantai Motor, DQ860MA, PWM currrent control,
https://factorydaily.com/fdattachs/fdattachs7/112716
014424312.pdf.
[11] HY-DIV268N-5A two phase hybrid stepper motor
drive manual, http://wiki.kreitek.org/media/
proyectos:cnc:div268n-5a-datasheet.pdf.

50

You might also like