Synchronized Control of Four or More Stepper Motors For Computer Numerical Controled Machines and 3D Printers
Synchronized Control of Four or More Stepper Motors For Computer Numerical Controled Machines and 3D Printers
Synchronized Control of Four or More Stepper Motors For Computer Numerical Controled Machines and 3D Printers
of the 6th International Conference on Applied Innovations in IT, (ICAIIT), March 2018
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.
45
Proc. of the 6th International Conference on Applied Innovations in IT, (ICAIIT), March 2018
46
Proc. of the 6th International Conference on Applied Innovations in IT, (ICAIIT), March 2018
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
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