Development of Microcontroler
Development of Microcontroler
Development of Microcontroler
DEVELOPMENT OF MICROCONTROLLER
CONTROLLED COMPUTER NUMERICAL CONTROL
(CNC) ROUTER MACHINE WITH
GRAPHICAL USER INTERFACE (GUI)
By
March 2016
ACKNOWLEDGEMENTS
First and foremost, I would like to thank God, the merciful and the compassionate, for
having made everything possible from start to finish in my journey for knowledge.
It is a pleasure to offer my regards and thanks to those who made this thesis possible
and those who helped me during the research. This dissertation could not have been
written without their help and support. Firstly, I am sincerely thankful to all my
family, particularly to my dearest loving mother. Thank you for everything that you
have done for me; and this thesis is for you. I would like to express my greatest
appreciation to Dr. Syed Sahal Nazli Alhady bin Syed Hassan, as my supervisor for
I would like to thank the Dean and staff of the School of EE, USM especially Pn
Jamaliah who has helped me during my candidature period in USM and technicians
from Micro P. laboratory for their help providing space and equipments needed in this
II
TABLE OF CONTENTS
ACKNOWLEDGEMENTS………………………………………………………...…II
TABLE OF CONTENTS………………………………………………………….....III
LIST OF TABLES…………………………………………………………………....V
LIST OF FIGURES…………………………………………………………………..VI
LIST OF ABBREVIATIONS………………………………………………………..IX
ABSTRAK…..………………………………………………………………………..X
ABSTRACT………………………………………………………………...…….….XI
CHAPTER 1 : INTRODUCTION…………………………………………………….1
1.1 Overview………………………………………………………………….1
2.4 Summary………………………………..……………………………….16
CHAPTER 3 : METHODOLOGY…………………………………………………...17
3.1 Overview……..………………………………………………………….17
III
3.2.3 EasyDriver v4.4 stepping motor driver…………………...............…24
4.1 Overview……..………………………………………………………….44
CHAPTER 5 : CONCLUSIONS………….……………………..…………………...59
5.1 Conclusions……..……………………………………………..………...59
REFERENCES………………..………….……………………..………….………...61
APPENDICES……….………..………….……………………..………….………...64
APPENDIX A………………………………………………………………..64
APPENDIX B………………………………………………………………..66
APPENDIX C………………………………………………………………..76
APPENDIX D………………………………………………………………..86
IV
LIST OF TABLES
Table 2.1 : Examples of G-code and M-code ( Desai & Patel, 2015 ) .………......…16
Table 3.1 : Specifications of RS 440-442 Hybrid and Vexta PH 268-21 stepper motors
………………………………………………………………………………………..22
Table 3.2 : Step for energize and de-energized port A, B, A', and B' for clockwise
direction……………………..........................................................……………......…23
Table 3.3 : Step for energize and de-energized port A, B, A', and B' for counter
clockwise direction………………………….................................……………......…23
Table A.1 : Current level sequences and current polarities for step modes…...……..64
V
LIST OF FIGURES
Figure 3.1 : Flow chart of the process flow of developing the AVR controlled CNC
Figure 3.2 : Block diagram for CNC router machine on one axis configuration……20
Figure 3.5 : 8 wires stepper motor configuration with transistors and microcontroller
……………….……………………………………………………………………….22
Figure 3.6 : 6 wires stepper motor configuration with transistors and microcontroller
…………………………………………………………………………………..……23
Figure 3.7 : Block diagram of the EasyDriver v4.4 stepping motor driver….…...…..24
Figure 3.9 : Initial state of AVR G-code Sender after the connection is establish .…27
VI
Figure 3.21 : G-code panel……………………………………………………......….37
Figure 3.23 : Flow chart of SEND button function in File Mode panel………...……38
Figure 3.24 : Flow chart of SEND button function in Command Mode panel…..…..38
Figure 4.1 : Wiring diagram of the CNC embedded system before improvement
implementation………………………………………………………………….……46
Figure 4.2 : Wiring diagram of the CNC embedded system after improvement
implementation………………………………………………………………….……47
Figure 4.6 : Fin type shape copper heat sink setting on EasyDriver…………………49
Figure 4.7 : An ERROR message appear upon clicking the OPEN button if serial port
VII
Figure 4.14 : 40 mm square drawn by CNC………………………………………….58
VIII
LIST OF ABBREVIATIONS
NC Numerical Control
3-D Three-Dimentional
DC Direct Current
AC Alternating Current
I/O Input/Output
IX
PEMBANGUNAN MESIN PEMOTONG KOMPUTER KAWALAN
BERANGKA (CNC) KAWALAN PENGAWAL MIKRO BESERTA
ANTARAMUKA PENGGUNA GRAFIK (GUI)
ABSTRAK
pemantauan operasi mesin dengan melalui proses ‘flashing’ Grbl – sebuah pengawal
CNC dan pengurai G-code berprestasi tinggi serta terbuka ke pengawal mikro. GUI
dimana ianya adalah piawaian industri untuk kod pemesinan. Alat peranti lain seperti
suis pembatas disepadukan bersama pengawal micro AVR untuk penentuan titik
rujukan sifar mesin dan juga untuk melaksanakan fungsi had batasan. Cabaran
pertama adalah membina GUI yang berfungsi untuk antara muka mesin menggunakan
bahasa pengaturcaraan Microsoft Visual Basic 2010 Express dan yang keduanya
adalah untuk menggabungkan semua komponen ini bersama dengan pengawal mikro
mengurangkan kejadian ralat kesalahan dari 60% ke 5%, GUI yang dibina berupaya
berfungsi 100% seperti yang diingini, dan ketepatan mesin CNC dengan ralat kurang
dari 1%, objektif kajian ini tercapai. Penambahbaikan yang dapat dilakukan adalah
X
DEVELOPMENT OF MICROCONTROLLER CONTROLLED
COMPUTER NUMERICAL CONTROL (CNC) ROUTER MACHINE
WITH GRAPHICAL USER INTERFACE (GUI)
ABSTRACT
Control (CNC) router machine with Graphical User Interface (GUI). The
by flashing Grbl - an open source, high performance G-code-parser and CNC milling
between computer and the microcontroller. The CNC router machine able to perform
3-D coordination using its three axes. For positioning and axes motion control,
stepper motors are incorporated with stepping motor drivers and AVR
standard industry machining code. Other peripheral devices such as limit switches are
integrated with AVR microcontroller for machine's zero reference point calibration as
well to perform hard limit function. The first challenge is to build a working GUI for
machine interface using Microsoft Visual Basic 2010 Express programming language
and secondly is to interface all these components together with the AVR
able to reduce fault error occurrence from 60% to 5%, the built GUI able to function
100% as intended to, and the accuracy of the CNC router machine with less than 1%
error, the objective of this research is achieved. Improvements that can be done on the
system are to further developing the Grbl system, the GUI and the hardware system to
XI
CHAPTER 1
INTRODUCTION
1.1 Overview
precise, reliable and able to speed up the manufacturing process without sacrificing
the product's quality. CNC used coded instructions which are then sent to controller,
guiding the machine movement or action as per instruction, thus allowing the
fabrication of precise part. One of the type of coded instructions used is G-code which
focus on machine's positioning. Other example of coded instructions are F-code that
controls the feed of the tool and S-code addresses the feed of the tools. All three of the
coded instructions are part of Numerical Control (NC) programming language. There
are many variants of CNC machines. CNC router machine is one of the examples.
CNC router are mostly used in carpentry works such as creating pattern or cut-outs
out of wood. The CNC router able to do 3-D coordination motion control using
Cartesian coordination system on three axes (x, y and z axes). Nowadays, with the
(CAM) software, user are able to generates the NC programming without the need to
object with vectors. Usually CAD is use in tandem to CAM software. This is because
CAM is able to accept vector-based graphical input file created by CAD. The user
then gives the needed information to allow CAM to create an output file in G-code
format with all the cutting tool paths, feed rates necessary instruction in it (Overby,
2011). Mach3 and EMC (Enhance Machine Controller) are the most powerful and
1
popular controllers available in the market. However due to its pricey price tag, a
cheap alternative is needed for this project. AVR microcontroller is used because it is
not only cheap, the microcontroller is also supported by Grbl. Grbl is an open source,
controlling hardware, in this case the CNC router. For interfacing between computer
and CNC router, serial communication method is used which can be establish by the
use of Graphical User Interface (GUI) on the computer. In this project, a new GUI is
built. GUI is use to feed G-code to microcontroller line-by-line via USB cable and
then the G-code parser produces set of pulses to the driver to drive up stepper motors.
Calculated positioning status info and other feedback data then being send from Grbl
Aside from reliable and precise nature of CNC machines, the ability to do
repetitive movement or task without losing its accuracy is why CNC machines
reduce cost of the product by speeding up production lines, reduce the manpower, and
ease the job in fabricating complex products. Since the AVR microcontroller is not
compatible with the industry standard G-code, Grbl which is a G-code interpreter and
parser are used to interpret and process the G-code. A GUI is needed as mean for
computer to interface with Grbl system in the microcontroller. A good GUI will
increase productivity and lowering the learning curve needed to control the CNC.
2
1.3 Objective of Research
The main objective in this research is to develop AVR controlled CNC router
There are two minor objectives to support main objective during the
controlled CNC router machine for ensuring system stability during experiments.
Stability of the system is determine by the number of successful CNC run without the
together with computer, stepping motor drivers and other peripheral devices for
In this research, the CNC router machine allowable operating area is limited within
40cm x 30cm. The positioning of router and table are limited by limit switches that
are placed at the both end of the x, y and z axes. Work piece size, weight and
thickness allowable on the gantry or working area are restricted to a certain amount.
no router is installed on the hardware system as all available router at hand weight
over than 500g. Before suitable router is purchased, as replacement a pen is use to
3
illustrate the router point. In other word, the pen is used to verify axes coordination by
drawing object or product's cutting path. The objective is still achievable with this
replacement.
Not all NC codes are supported by the Grbl system. These codes are seldom
used in general cutting process thus their functions are not included in the system.
However mostly basic functions for router machine are supported by the Grbl system.
In this research, the existing Grbl system capable to fulfill objective requirements.
For building a new graphical user interface (GUI) as mean for sending the G-
facilities to computer programmers for software development. This IDE is chosen for
its low learning curve and user friendly interface, as well as it is freely available from
the internet. GUI need to at least fulfill few requirements such as able to establish
connection with AVR microcontroller, able to send codes and instructions (i.e. G-
code), able to receive feedback data from AVR microcontroller, and able to display
high level software such as CAD/CAM, the designer need to manually write in the G-
code. In order to work with CNC router, the designer need to have certain
4
1.5 Outline of Thesis
In overall, this thesis comprises of five chapters. First chapter starts with an
embedded system, and GUI is presented. This chapter also discuss the basic
description of software and hardware parts of CNC machine, together with simple
Chapter 3 will focusing on the approaches of developing the GUI and the
devices are done in this chapter. The newly built GUI overall functions as per source
code is describes with the use of flow charts. Furthermore, experiments to check CNC
the results. Some of the CNC products are presented at the end of the chapter.
Chapter 5 as the last chapter will conclude research and future development
5
CHAPTER 2
BACKGROUND STUDIES
controlled by digital quantity in form of coded instructions (Li & Zhang, 2014). The
coded instruction comprise of letters of symbols, numbers and alphabets can be read
by the machine control unit (MCU). These letters referred to specific motions,
positions, distances, or functions of the machine tools which are converted into
electrical pulses of current (Krar, Gill & Smid, 2001). The birth of NC technology is
Parsons Corp.
develop the Numerical control (NC) between end of 1940s and early 1950s. Parsons
was involved in the manufacture of helicopter propellers that required the perfect
blend of complex shapes leading to discoveries that by using an IBM computer, more
accurate contour profiles can be obtained using calculations and models (Albert,
2011). The program of the NC machines at that time was stored in tape and was
edited and programmed by using only basic computers. For controller to read the
6
program, a tape reader was required to read the program, and then store the program
in the controller's memory (The CNC controller History past to Present, 2011). By
the early 1960s, the price and complexity of automated device tools had reduced to
the point where they were introduced in other industries (Iliescu, Deaconu, Fartinescu,
Deaconu, & Chirila, 2015). The invention of more modern computers on early 70's
Material for CNC, 2007). By using microcontrollers and computer systems, the NC
controller can communicated directly to a computer (The CNC controller History past
to Present, 2011).
subdivided into two main groups. The first group contains standalone controllers
programmable gate arrays (FPGAs), and others. The other groups utilize general-
purpose PCs. The CNC controllers implemented on the PC usually utilize some form
Karwowski, & Wawrzak, 2013). CNC machines are usually used in carpentry or
machinery with materials such as metal and wood. The machining mostly involves
drilling, milling, cutting and contouring which are done with servo mechanism
controlled by computer and specific tools. The servo mechanism can be separated into
two fashion, an open-loop or close-loop fashion. Stepper motor is an open close servo
control mechanism which is suitable for small loads while close-loop fashion is using
servo control driving AC/DC motor or linear motor. As close-loop fashion, linear
servo systems have the advantages of high velocity, precise, and excellent stability
which can be used as high-performance system for CNC machine tools (Xu, Li, Lin,
7
& He, 2011). But such setting requires multiple sensors thus total cost are high. By
using Kalman Filter to estimate the angular speed by measuring noisy current of DC
motor, Khalid and Nawaz was able to create sensor less CNC machine (Khalid, &
Nawaz, 2014). Motion controller is the core part of a CNC system, thus the
the open CNC system (Yuan, Yong-zhang, & Hong-ya, 2008). Since the
becomes more flexible to integrate, modify, and expand systematic functions in order
various hard materials, such as wood, composites, aluminium, steel, plastics, and
foams. Depending on machining tools, software controller and machine design and
hardware, CNC routers can perform the tasks of many carpentry shop machines such
as the panel saw and spindle moulder. With CNC router, instead of routing by hand,
the machine takes control of the tool paths. A CNC router can produces high-quality
work and consistent products as well improves factory productivity. Unlike a jig
router, due to the accuracy and precision of the CNC router, it can produce a one-off
as effectively as repeated identical production. The main benefit of CNC router are
automation and precision. Generally CNC routers are available in 3-axis. Higher
axis machines, multi-axis machines perform more efficient and accurate machining. It
is believed that multi-axis CNC machine is the best tools in sculptured surfaces
machining (Yang, Shengmin, & Ping, 2011). With rapid technologies development,
8
even wireless control CNC machine is possible. Rong, Kerong, and Zhisen was
successful in developing CNC system that able to be use with wireless Bluetooth
technologies where part of the original CNC system functions is transferred to PDA
mechanical parts or any other physical device. The software is the programs or GUI
that are designed for particular functions. The heart of embedded system is the
available nowadays are examples of embedded system such as cellular phones and
cameras. Even automobiles are packed with embedded system to the point checking
faulty in cars can be done just by connecting to main car board system.
Software
For CNC router, the software mainly must be develop to be able to send
commands, able to display positioning of the axes, and user friendly. Interface is very
controllers, and displaying the system operating data and results (Lu, Jia & Wang,
Zhanbiao, 2010). However, in this research Visual Basic 2010 Express had been used
due to its easy learning curve and freely available to create the CNC machine's GUI,
9
AVR G-code Sender. Aside from GUI, CNC control software also needed to build a
Some CNC control software are design to works specifically with certain
hardware while some other are standalone software that support a wide range of
hardware. The two most popular software available nowadays are Mach3 and EMC
which use industry standard such as G-codes. The Mach3 software can operates up to
6 axes simultaneously while EMC operates up to 9 axes. The Mach3 software runs in
Microsoft Windows while EMC only support Linux operating system. EMC is an
open source and free controller which supports PLC programming with ladder
diagrams. PLC programming is widely used in the industry. Despite being widely use
and highly accurate, these systems are designed for nonprofessional use. Industry uses
machines and industrial PCs (Mejdr, & Beran, 2015). Apart from these control
software to work, instruction code is needed. Instruction code for complex design can
computer software that used for design and manufacture products by generating
coordinates or paths for tool processing. Combination use of both software are widely
uses in CNC scenes commercially as these software able support complex tool paths
(Wang, Qi, Cai, Zeng, & Wang, 2011). For NC programming, the technologies used
is still mainly based on M-codes and G-codes. CAD is mainly use to designs parts
10
(i.e. shape) and CAM use the design to create paths or coordinates in codes instruction
for CNC machine. CAD stores graphics data in DWG and DXF format. DWG is
binary format file, which mainly consists of five parts: head, entity part, table part,
block entity part and emergency entity head. The entity part keeps all graphic entities,
including point, line, arc, circle, size, and others (He, Wu, Dai, Chen L., & Chen C.,
2011). DXF contains graphic information such as line types, base surface height,
thickness, and other relevant geometric data (Laijie, Qiangbo, Lijuan, Ruiwen, &
Jing, 2011). In current market, CAD software such as ORCAD or PowerPCB has
been widely used in designing printed circuit boards (Haiming, Yueming, Peng, &
Jiaxiang, 2013).
There are 4 stages in process flow of CNC router software parts. There are
design, convert, interpret and interface. In design stage, parts to be machine is design
by using CAD software, producing CAD drawings. In the next stage, the CAD
drawings then are convert to G-codes via CAM software. These G-codes then being
interpret by CNC control software for controlling the motor on each axis, producing
motion or path for tools create the design part. The last stage is where GUI is use to
send and receive data from CNC control software to check position and machine
Hardware
Basic hardware component of CNC routers are a controller, servo motors, servo
drivers, power supplies, workspaces table, and depending on setting, lead screw rod-
nut or belt-gear combination parts. In this research, the developed CNC router
11
power supplies, lead screw rods and nuts for each axis, frame to hold all the parts and
workspace to accommodate the CNC router machines. The dedicated controller is the
devices through offering a variety of digital and analog inputs, SPI, serial interface,
digital and PWM outputs. Arduino also easy to use and can connects to computer via
USB, communicates using standard serial protocol, and widely supported in various
OS such as Window or Linux whereby EMC only can run on Linux (Overby, 2011).
Arduino also is cheap compare to other controller. Since Arduino also back up by
online community where a lot of open source libraries are available for references in
design using G-code. However, users can not program microcontroller directly by
& Sziebig, 2013). Arduino, together with computer and motor driver, control the
stepper motor.
In CNC setup, stepper motor provide the motion necessary in the machining
process by turning the electrical pulses into mechanical forms. When electrical pulses
are applied in proper sequence, the stepper motor rotates its shaft in clockwise or
counterclockwise direction. If the motor shaft connected to the lead screw rods, this in
turn rotates the lead screw rods thus controlling motion on the axis. The motor shaft
pulse frequency contribute to higher shaft rotation speed. Since stepper motor is an
open loop operation, no sensor is required as there is no feedback system. This can
12
cause incorrect display of positioning data if stepper motor are to miss its step. In this
research, the CNC router machine use two stepper motor model. The RS 440-442
In order for stepper motor to work, stepper motor driver is needed to supply
the input pulse. In this research, EasyDriver v4.4 is use as the stepper motor driver.
EasyDriver v4.4 designed with two input lines: step and direction, and capable to
drive bi-polar stepper motors. EasyDriver v4.4 support up to 30V output voltage and
±750mA range of output current per coil. Resolution of the driver can be set by
manipulating MS1 and MS2 value. In the developed CNC, EasyDriver is set to
fullstep (2 phase). The main component of EasyDriver v4.4 is the A3967 IC. A3967
circuitry, and DACs. PWM mainly controls the current supplied to stepper motor
depending on stepper motor phases. DAC or Digital Analog Converter convert the
step command on STEP pin to current level sequence and current polarity. Current
level sequences and current polarities for step modes is tabulated in Table A.1 in
Appendix A.
devices using a combination of technologies and devices for the tasks of gathering
and producing information. Nowadays, GUI are in a wide range used in programs and
they are considered as the main media between the user and the computer. GUI is the
front-end of a software where the user interacts with the software (Ahmed, 2014).
13
GUI can be develop using programming language or integrated development
environment (IDE) such as Visual Basic, LabView, and MatLab. In developing GUI,
there are key areas need to be focus on in ensuring a good GUI building. Those are
the functions detail, defining the user interface (UI) element such as input and output
type, and placement rules that controls the UI (Khaddam, Mezhoudi, &
Vanderdonckt, 2015). Detailed functions explain how a task is carried such as system
functions (carried out by the system), input functions (require input from the end
user), and output functions such as display information on the screen. The UI of input
and output type can be either visible such as button, label, text box or non-visible such
as mouse click. The placement rules here refer to placement of such button or label on
the GUI.
In this research, the built GUI must act as a platform for AVR microcontroller
interfaces with the computer. GUI send data such as G-code and Grbl commands to
microcontroller line-by-line from the computer. Other GUI functions are to connect
computer to microcontroller via serial communication upon setting up the serial port
and baud rate, and to report the status of the Grbl system and axes positioning.
Grbl system
Grbl is an open source, free high performance CNC router controller. Grbl need
to be flash to Arduino board for it to run. It accepts standard G-code and support most
of the basic motions like linear and circle. However Grbl only support 3 axes with no
rotation axes. When a G-code text file is stream to microcontroller via GUI that act as
G-code sender, Grbl interprets the G-code command before converting them into
pulse signal which is sent to stepper drivers thus producing motion on stepper motor.
14
Grbl mainly consist of two parts, the interpreter and interpolator. For the interpreter
part to work, these four components are needed. There are the parser, the executor, the
path generator and the error handler. Parser main function is to interpret the input
code line by line while the executor executes the function as per interpreted code from
parser. The function of path generator is to generate position data based on input code.
If there is an error in part of the program, the error handler generates warning
movement data as per data generated by the interpreter (Voon, 2013). For building
the GUI, the basic understanding of Grbl’s program flow is needed. By analyzing
Grbl program flows, the GUI requirement for controlling the CNC can be establish.
G-code
does not have decisions, variables or loops (Aciu, & Ciocarlie, 2014). G-code
comprise of two part, an address and a set of two digit number. An address is to
differentiate between what kind of code is being use especially between G-code and
M-code. The set of two digit number is to identify particular program to run in CNC.
For CNC to run, at least a word complete with address and two digit number is
needed. These variables of G-code command can be combine together in text file
creating a set of instruction or program that can be send to CNC to perform certain
tasks. For Grbl system, G-code and M-code are supported. G-code mostly use for tool
movement while the M-code is for controlling the on/off functions in machine tools
(Suh, Kang, Chung, & Stroud, 2008). Some of the examples of G-code and M-code is
15
Table 2.1: Examples of G-code and M-code (Desai & Patel, 2015)
2.4 Summary
wireless CNC and sensor less close loop CNC system is the proof of that. More CNC
system are becoming accessible to common user due to software and hardware for
CNC costing lesser and lesser. Arduino AVR microcontroller as software controller
cost significantly lower than Mach3 or EMC with wider support since can run on both
Windows and Linux. As a free high performance CNC router machine controller,
Grbl is preferable as it’s also support Arduino. However Grbl only able to support up
to only 3 axes compare to much more costly Mach3 or EMC. The programming
language chosen for developing GUI is Visual Basic Express 2010 as it’s easy to
16
CHAPTER 3
METHODOLOGY
3.1 Overview
In this chapter, the methodology of developing Grbl flashed AVR controlled CNC
router machine with its own Graphical User Interface (GUI) is discussed.
Methodology process flow is shown in Figure 3.1. The developed CNC router
machine rig setting is reviewed. Further improvements are implemented on the CNC
router machine hardware. The Grbl program is written in C language and being
compiled by AVR Studio 4 to the AVR microcontroller (Voon, 2013). The GUI is
built using Microsoft Visual Basic 2010 Express. Functional tests are conducted to
confirm GUI usability. Further tests are done to confirm microcontroller interfacing
with other peripheral devices, specifically motor drivers and stepper motors.
The block diagram for CNC router machine for one axis configuration is shown
in Figure 3.2. The actual setting of the CNC rig is shown in Figure A.1 in Appendix
A. This CNC machine setting originally developed by Voon (2013). This CNC
machine setting is chosen due to low cost, easily obtainable hardware and support
factors. Since the main program on the microcontroller is the widely used Grbl
program, commonly in private setting, the use for GUI is needed. The CNC router
machine able to perform 3-D coordination using its three axes. For positioning and
17
axes motion control, stepper motors are incorporated with stepping motor drivers and
standard industry machining code. Other peripheral devices such as limit switches are
integrated with AVR microcontroller for machine's zero reference point calibration as
The x, y, and z axes motions are controlled by three stepping motors via turning
the screw rods. The RS 440-442 stepping motors with the lower torque is use for y
and z axes motion. The higher torque Vexta PH 268-21 stepper motor is needed to
control x axis, the longest axis where the table work for carrying work piece is set. A
certain parameter need to be define for Grbl system to work correctly. For this CNC
machine, the setting parameter is shown in Figure 3.3. By using the selected setting
parameter of steps/mm, Grbl system can generate necessary step pulses to stepper
motor which then rotates the screw rods, moving in 1 mm distance .There are 6 limit
switches installed on the CNC machine. 2 limit switches on each axis. Limit switches
are needed in homing cycle to locate zero reference positioning. Once homing cycle
started, stepper motors will rotates each axis until limit switches is triggered. Hard
18
3.2.1 Input/Output (I/O) of AVR microcontroller
reduce noise some resistor were added between input pins and VCC. Since only one
LIMIT input pin available for each axis, two limit switches are wired in parallel to
LIMIT pin to allow hard limit function to perform on both ends on the axis.
START
No
Success?
Yes
Test run on CNC machine
No
Success? Improvement
or new
Yes
methods to
Yes compensate
Any error occurs?
errors
No
Write thesis
End
Figure 3.1 : Flow chart of the process flow of developing the AVR controlled CNC
router machine complete with Graphical User Interface (GUI)
19
Figure 3.2 : Block diagram for CNC router machine on one axis configuration
20
Figure 3.4 : Block diagram of Arduino UNO ATmega 328p microcontroller
In the developed CNC router machine, three stepper motors are being
implemented. Two of the stepper motors are RS 440-442 hybrid stepping motors
while the other one is Vexta PH 268-21 stepping motor. Each stepper motor model
specifications are listed in Table 3.1. The rated current is the maximum amount of
currents can be allowed to flows through the coil without damaging the motor.
Both model have stepping angle of 1.8 degree but RS 440-442 have 8 wires
while Vexta PH 268-21 only have 6 wires. The setting configuration of both model to
a controller and power supply is shown in Figure 3.5 and Figure 3.6. To obtain full
step drive mode, both motors are configured as 2-phases motors by wiring only four
wires of the motors. For RS 440-442, the remaining 4 wires are connect in short
circuit but for Vexta PH 268-21, the remaining 2 wires are leave unconnected. Table
21
3.2 and Table 3.3 shows that the sequence of energize and de-energize of coil A and B
Table 3.1 : Specifications of RS 440-442 Hybrid and Vexta PH 268-21 stepper motors
Figure 3.5 : 8 wires stepper motor configuration with transistors and microcontroller
22
Figure 3.6 : 6 wires stepper motor configuration with transistors and microcontroller
Table 3.2 : Step for energize and de-energized port A, B, A', and B'
for clockwise direction.
Table 3.3 : Step for energize and de-energized port A, B, A', and B'
for counter clockwise direction.
23
3.2.3 EasyDriver v4.4 stepping motor driver
750mA output current for each phase of stepping motor below than rated current of
both stepper motor and compatible with 4,6 and 8 wires stepper motor configuration
of any voltages, is used in the CNC router machine . Since the driver can easily get
heated up upon running, heat sinks is added onto the top of the driver's IC chip to
counter this disadvantage as well to protect the IC chip. If the maximum thermal
tabulated in Table 3.4. The driver pin out is shown in Figure 3.7.
Figure 3.7 : Block diagram of the EasyDriver v4.4 stepping motor driver
24