0% found this document useful (0 votes)
140 views

2018 - Using GRBL-Arduino-based Controller To Run A Two-Axis Computerized Numerical Control Machine PDF

Using a GRBL-Arduino controller and Universal GcodeSender software, the authors developed a simple two-axis computer numerical control (CNC) machine. An image file of a hexagon or circle was converted to a CAD drawing file and then to G-code using CAD/CAM software. The G-code was run on the CNC machine using the GRBL-Arduino controller to drive two stepper motors and cut the desired shape. This approach allows customization of proprietary CNC machines by modifying their control codes.

Uploaded by

Sachin Shinde
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
140 views

2018 - Using GRBL-Arduino-based Controller To Run A Two-Axis Computerized Numerical Control Machine PDF

Using a GRBL-Arduino controller and Universal GcodeSender software, the authors developed a simple two-axis computer numerical control (CNC) machine. An image file of a hexagon or circle was converted to a CAD drawing file and then to G-code using CAD/CAM software. The G-code was run on the CNC machine using the GRBL-Arduino controller to drive two stepper motors and cut the desired shape. This approach allows customization of proprietary CNC machines by modifying their control codes.

Uploaded by

Sachin Shinde
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Using GRBL-Arduino-based controller to run a two-

axis computerized numerical control machine

Sakib Shaukat Sarguroh Arun Bhiva Rane


Mechanical dept, A.C.Patil College of Engineering Production dept, Fr. C. Rodrigues College of Engineering
ACPCE, Plot No. 17, Sector -4, Kharghar Fr.CRCE, Father Angels Ashram Road, Bandra West,
Navi Mumbai, India Mumbai, India
[email protected]

Abstract— The proprietary control of CNC machines results specific conditions. The elimination of exclusive control will
in the inability to control and enhance inputs because the enable customization arrangements that grant appropriate
program codes cannot be modified owing to their distribution by control to clients for supporting execution. Continuous
vendors in the compiled form. In this paper, we present a method changes that will significantly increase return on investment
to utilize a GRBL-Arduino based controller to run a simple two- (ROI) can be implemented.
axis computerized numerical control (CNC) machine. We
obtained drawing file by converting a JPG or PNG image of a CNC machines use G- and M-code dialects created by
hexagon or a circle into a drawing file using the software computer-aided manufacturing (CAM) systems that utilize
application Img2CAD. Two-dimensional manufacturing was computer-aided design (CAD) commands. G- and M-code
carried out on the obtained drawing file to generate the G-code dialects are described by numerical codes, such as G, M, F, T,
file by the CAD/CAM software application UG NX. The G-code and S, which represent the operations of a machine. The G-
file generated is given as input to the GRBL-Arduino based and M-codes created by the controllers of different merchants
controller using the Java-based Windows application Universal are not universal.
GcodeSender (UGS). UGS is linked to the Arduino Uno and
GRBL shield V5 hardware via a serial communication port. In this paper, we propose a technique for using a summed-
Before executing the G-code program, the circle or hexagon to be up or widespread controller that will accept G- and M-codes
drawn can be visualized using G-code visualizer option in UGS. created by any CAD/CAM algorithm. The controller will then
G-code program was executed through UGS to run two 2.6 kg- convert these codes into step pulses that will be sent as input
cm stepper motors for motion along x and y-axis direction via to the actuator or stepper motor of a CNC machine.
drivers incorporated on the GRBL-Arduino controller. These
stepper motors were part of a simple two-axis CNC machine
II. BACKGROUND
comprising aluminum angle brackets, chromed chords, linear
motion bearings, a timing belt, and a timing pulley. Stepper Arduino was developed by Banzi et al. [1] at the
motors cause motion of the mentioned mechanical components to Interaction Design Institute in Ivrea, Italy. The Arduino shown
draw desired image of circle or hexagon. This work can be in Fig. 1 is an open-source stage with easy-to-use computer
extended to develop a three-axis CNC machine by utilizing the hardware and software. Arduino boards can read signal
third inbuilt stepper driver of the GRBL shield V5; in this study, sources, such as light detectors, and can generate outputs, such
we used only two of the three inbuilt stepper drivers for the as signals to start a motor or turn on a light-emitting diode
stepper motors. Using the third driver will facilitate the use of a (LED). The Arduino Uno is an open-source outline, and each
third axis so that the machine can function as a milling machine. of its segments is available off the shelf. At the heart of the
Hardware for the third axis must be developed to incorporate a Arduino is the microcontroller chip, which can be modified to
z-axis motor.
perform various operations. In addition, it has a timing crystal,
Keywords—GRBL shield V5; Arduino Uno; Universal power controller, USB interface, and power jack. It has
GcodeSender; UG NX; CAD; CAM fourteen advanced I/O pins, six of which produce a PWM
output. Similarly, the Uno board has six analog input pins
alongside power association pins for 3.3-V and 5-V supplies.
I. INTRODUCTION
Skogsrud [2, 3] contributed to open-source technology by
Computerized numerical control (CNC) machines are an
developing early forms of GRBL in 2009. Since 2011, GRBL
indispensable tool in the manufacturing industry, and they
require coordinated and versatile configurations. CNC has advanced under the leadership of Jeon [2, 3]. The GRBL
machines perform many manufacturing operations, such as shown in Fig. 1 is a superior, minimal-effort, open-source
chip, developed using enhanced C, which is suitable for and
milling, cutting, and boring, without the ability to control and
runs on Arduino Uno. The controller runs on significantly
improve inputs. CNC machines require substantial initial
overhead, and their restrictive control schemes counteract upgraded C, using sharp components of the AVR chips to
achieve exact planning and non-concurrent operation. It can
adjustments to the system codes, which are generally
proprietary to merchants who distribute the product under
maintain up to 30 kHz of stable, unsettling, and influence-free A JPG or PNG image of a hexagon to be converted into a
control pulses. drawing file with a .prt or .dxf extension is provided as the
input to Img2CAD [6], as shown in Fig. 3.

Fig. 1: Arduino Uno and GRBL shield V5 in separate and combined states.

GRBL is used for three-axis machines. It acknowledges


benchmarks consistent with G-code and has been successfully
used in numerous CAM instruments. GRBL deciphers a subset
of the RS274NGC standard G-code. Circular segments, Fig. 3: Hexagonal JPG image and JPG image to CAD drawing converter.
circles, and helical movement are all supported, along with all
distinctive and essential G-code commands. GRBL enables a The drawing file is then imported into the software
faster overhead with look-ahead, which implies that the application UG NX, and the maximum dimensions across the
controller will predetermine eighteen future motions, and will x- and y-axes were found to be 9.5 and 9 mm, respectively. In
set its speed to achieve smooth acceleration and jerk-free addition, by default, the GRBL controller has a microstepping
cornering. GRBL includes a 12-V supply along with three of 8×. Hence, we used a scaling factor of 48.8 as shown in Fig.
drivers for stepper motors. Likewise, each pivot has three 4, and the length across the x- and y-axes of the hexagon was
trimpots to control the measurement of the current flow. increased to 463.6 and 439.2 mm, respectively. An
Microstepping ranging from 1× to 8× can also be achieved approximate drawing using a two-axis machine will have
with GRBL. dimensions of 57.95 mm and 54.9 mm, respectively.
Saunders [4] reported the operation of Nema stepper We performed 2D manufacturing based on the scaled
motors using an Arduino Uno-GRBL shield as the basic drawing as shown in Fig. 4, followed by a post processing
hardware and Universal GcodeSender programming using a operation to generate G- and M-codes of the drawing, which
laptop. were saved with the extension .nc.
Sarguroh et al. [5] utilized a GRBL-Arduino-based
controller with the compatible Windows-based software
application Universal GcodeSender to demonstrate that even
complex figures with irregular profiles, such as a map of
India, can be executed using the same controller.

III. METHODOLOGY

Fig. 4: Drawing file imported into UG NX 5 and 2D manufacturing process.

The G-code file was provided as an input to the Java-based


Windows application Universal GcodeSender, which was
linked to the Arduino Uno and GRBL shield via the USB port.
The output can be seen through a visualizer option before it is
drawn by the machine. The G-code program was executed to
run the stepper motor connected via drivers on the GRBL
shield. These three steps are discussed in detail in the next
section, which focuses on the system design.

IV. SYSTEM DESIGN

A. GRBL shield and Arduino Uno connection with stepper


motor
1) Power connection and power supply requirements: The
GRBL shield uses the Arduino power supply for the digital
logic, and it requires only the power for the motor. The
Fig. 2: Block diagram of research methodology. Arduino can be powered from its DC input connector, but it is
more commonly powered from the USB port of a laptop or 3) Microstepping in GRBL: Four sets of microstepping are
desktop computer as shown in Fig. 5. available in GRBL: 1×, 2×, 4×, and 8× as shown in Fig. 8. By
default, the microstepping setting is 8×; i.e., for the
dimensions used in UG NX 5 to generate the G-code file, the
drawing obtained will be one-eighth of the original
dimensions. To change the microstepping setting to 1×, 2×, or
4×, we add or remove jumpers to the 4-pin male headers as
shown in Fig. 8.

Fig. 5: USB connection of controller with laptop.

The GRBL shield has a 12-V connection to which power is


supplied through a switched-mode power supply (SMPS) as
shown in Fig. 6. In this study, we used two Nema 17 2.6 kg-
cm stepper motors for the x- and y-axes, which require a
current of 1–2 A. The stepper drivers can source up to 2.5 A
(with cooling). The motors do not draw the maximum power
simultaneously, and two-thirds of the total rated current is Fig. 8: Microstepping in GRBL.
adequate. For the two 1.2 A motors used, a minimum current
of 1.6 A is sufficient. A minimum supply of 4.5 A is sufficient B. XLoader software
for almost all Nema 17 stepper motors. The motor voltage can
vary between +12 VDC and +30 VDC. The SMPS used Xloader [7] is a software application used to upload files to
supplied 15 A, 12 VDC to the GRBL to run the motors, which an Arduino board using the boot loader. Fig. 9 shows a
is sufficient according to the requirement discussed above. screenshot of the XLoader application.
The motor current for each axis can be adjusted using the 5-
mm trimpot adjacent to the axis by rotating it clockwise to
increase or counterclockwise to decrease the current.

Fig. 9: XLoader application.

The desired hex [8] file to be uploaded to the Arduino Uno


Fig. 6: SMPS and its connection to the GRBL shield. can be browsed, and an appropriate Arduino must be selected
under device options; in this study, we used Uno (ATmega).
2) Stepper motor connection to GRBL shield: We used the
The baud rate indicates the number of pulses transmitted per
12-V power supply to run stepper motors via inbuilt stepper unit time; the value is 9600 s−1 in this study. After clicking on
drivers on the GRBL shield. The motors used were bipolar the Upload button, the hex file was successfully uploaded to
with 4 wires—i.e., two pairs. Each pair of wires can be the Arduino Uno.
identified by testing the resistance using an ohmmeter. Most
NEMA 17 motors have pair resistances in the range of 2–20
Ω. Once the pairs were identified, they were connected to the C. Universal GcodeSender
drivers on the GRBL shield as shown in Fig. 7. Universal GcodeSender (UGS) [9] is a Java-based GRBL-
compatible cross platform for interfacing with advanced CNC
controllers, such as GRBL. It is a self-contained Java
application that includes all external dependencies for all
supported operating systems; therefore, UGS is easily
supported in the Java Runtime Environment.
The G-code file generated after the CAM operation is
provided as the input to UGS, which is linked to the Arduino
Uno and GRBL shield V5 hardware via a serial
communication port—i.e., the USB port of a laptop. In this
section, we will provide some insight into various
Fig. 7: Stepper motor connection to drivers on GRBL shield. functionalities available with UGS.
1) Commands: After clicking on the UGS application, the 200 steps x
sub options under the command functionality are displayed as
x = 0.8 mm
shown in Fig. 10. The appropriate port to which the GRBL
hardware is connected via the laptop port should be selected. Actual distance travelled in 1 revolution
We selected a baud rate of 9600 bit/s and GRBL as the
firmware. After clicking on the Open button, UGS is Timing pulley outer diameter = 9.56 mm
connected to the GRBL shield shown in the white console Number of revolutions = 1
box. Typing any G-code, such as G01 X200, in the text box
under the Command option will cause the x-axis motor to Pi = 3.1416
move by 200 mm, as with any CNC machine. Distance = Pi × D × Revolution
= 3.1416 × 9.56 × 1
= 30.033696 mm
Stepper steps per 1 mm
200 steps 30.033696 mm
y steps 1 mm
y = 6.659 steps/mm
The values must be updated in the GRBL settings for both
the x- and y-axes. The values are updated by typing $0=6.659
and $1=6.659 sequentially in the text box below the Command
Fig. 10: Command functionality. option and then pressing the enter key. The above changes can
be verified by typing $$ in the same text box and pressing
Once a connection is made, a GRBL prompt appears as enter. The values are then updated. Apart from the two values
GRBL 0.9i ['$' for help]. There are various settings available mentioned above, the default feed, default seek, and
in GRBL, which can be viewed and modified through the acceleration values were also updated using a similar approach
command functionality. The $ symbol can be typed, and after as indicated in Table 1. These values were obtained by
pressing the enter key, GRBL prints a help message showing carrying out trials on the machine.
other settings that can be used.
TABLE I.COMPARISON OF DEFAULT AND CHANGED SETTINGS.
The $-commands are GRBL system commands used to
Setting done
tweak the settings, view or change GRBL states and running Symbol Terminology Unit
Default
to match
modes, and start a homing cycle. The non-$ commands are setting
hardware
real-time control commands that can be sent at any time, Travel across x-
notwithstanding the current state of GRBL. These either $0 axis step/mm 250 6.659
immediately change its runtime behavior or immediately print Travel across y-
a report of important real-time data, such as the current $1 axis step/mm 250 6.659
position. Of the commands available, we used only $4 Default feed mm/min 250 6000
“$x=value” in this study because most of the remaining $5 Default seek mm/min 500 6000
commands require the use of limit switches, which are not $8 Acceleration mm/sec2 10 500
included in this study.
Steps/mm calculations: 2) File mode: Under the command functionality, we have
seen that we can input one line of G-code at a time. However,
Because the motors are not connected directly to the lead
what we want is to execute a group of commands, one
screw for the transmission of motion, the default values of $0
complete operation, or a group of operations simultaneously.
and $1 must be changed based on the calculations below.
This can be achieved by browsing the G-code file generated in
Stepper steps/revolution (for stepper motor) = 200 UG NX 5 as shown in Fig. 11.
Degree/step = 1.80
Total steps/revolution = 200
Current travel setting (GRBL)
Steps = 250
Millimeters of travel = 1
Millimeters of travel required for stepper to make one
revolution
250 steps 1 mm Fig. 11: Browsing G-code file.
After browsing the file, the image of the drawing can be parts. Fig. 14 shows hexagon and a circle being drawn using
visualized by clicking on the Visualize button next to the the setup.
Browse button. Upon executing the G-code file by clicking the
Send button, the motors are actuated, resulting in motion of
the mechanical components across the x- and y-axes to draw
the desired image. The animated motion of the components
can be observed simultaneously in the G-code visualizer
window. As the program is executed, the status of the tool
path can be seen under the Machine Status option. When the
drawing operation is completed, a popup window will appear
to indicate job completion.

D. Experimental setup Fig. 14: Drawing hexagon and a circle using the setup.
The mechanical system in this project comprises four
aluminum angle brackets (two for each axis) and four chromed V. RESULTS AND DISCUSSION
rods fitted on brackets along which linear ball bearings slide.
These linear ball bearings move across the x- and y-axes by After converting the image file into a drawing file, we
the stepper motor via a timing belt and pulley to draw the observed a variation of 4.1% on the sides of the hexagon and
desired image. 5.3% on the diameter of the circle, which affected the overall
accuracy by the same margin. Small arcs were formed at the
Apart from the mechanical components, the electrical, corners of the hexagon sides, resulting in speed reduction
electronic, and software aspects discussed in earlier sections when the machine changed direction. Table 2 compares
also form part of the assembly as shown in Fig. 12. various parameters of the hexagon and circle drawn using UG
NX 5 and those drawn by the two-axis CNC machine.
TABLE II.COMPARISON OF HEXAGON AND CIRCLE DIMENSIONS
DRAWN USING NX AND CNC MACHINE.

Hexagon Circle
Parameters
Parameters (in mm)
(in mm)
Maximum Maximum
length length Length
Diameter
across x- across y- of side
axis axis
Fig. 12: Experimental setup.
Dimension in
1) Executing the G-code program and running the setup: UG NX 5
57.95 54.9 29.3 60.1
The G-code file of the hexagon was provided as input to UGS.
The hexagon to be drawn along with the tool path can be seen Dimension
obtained on 56.1 52.7 30 61
after clicking the Visualize button as shown in Fig. 13. A machine
similar visualization can be seen before executing the G-code
program for a circle as shown in Fig. 13.
VI. CONCLUSION AND FUTURE SCOPE
In this study, we presented a method to eliminate
proprietary control by utilizing a universal GRBL-Arduino-
based controller that accepts G-code input generated by any
CAD/CAM software tool. The G-code program was executed
using the Windows-based UGS application, which actuates the
stepper motors of a simple two-axis hardware setup to draw
the desired image.
A JPEG or PNG image of a circle or hexagon was
successfully converted into a drawing file (.prt or .dxf), and
the corresponding G-code file was generated by carrying out
Fig. 13: G-code visualizer depicting tool path for hexagon and circle.
2D manufacturing in UG NX 5.0. A universal controller was
successfully utilized that accepts G- and M-codes generated
After executing the G-code program by clicking the Send by UG NX 5.0 CAD/CAM software. A simple two-axis CNC
button, the stepper motors were actuated, resulting in the machine was developed to draw a circle and hexagon after it
motion of the block-holding sketch pen across the x- and y- received the necessary G-code input via UGS. The accuracy of
axes via a timing pulley, timing belt, and other mechanical the circle and hexagon drawn was measured and slight
variations within the range of 2–5% were found.
This work can be extended to develop a three-axis CNC [3] S.S. Skogsrud, and S.K. Jeon, “Using grblShield.” [Online]. Available:
machine by utilizing the third inbuilt stepper driver of the https://github.com/synthetos/grblShield/wiki/Using-grblShield.
[Accessed: 04- September- 2015].
GRBL shield V5; in this study, we used only two of the three
[4] J. Saunders, “DIY Arduino CNC machine with GRBL Shield.” [Online].
inbuilt stepper drivers for the stepper motors. Using the third Available: https://www.youtube.com/watch?v=1ioctbN9JV8. [Accessed:
driver will facilitate the use of a third axis so that the machine 10- July- 2015].
can function as a milling machine. Hardware for the third axis [5] S.S. Sarguroh, A.B. Rane, S.A. Korgaonkar, and D.S.S. Sudhakar,
must be developed to incorporate a z-axis motor. “Elimination of Proprietary Control for Computerized Numerical
Control (CNC) Machine,” Journal of Basic and Applied Research
International, vol. 17, issue 3, pp. 211-217, April 2016.
[6] Img2CAD.com, “Img2CAD Software.” [Online]. Available:
REFERENCES http://www.img2cad.com/. [Accessed: 12- December- 2015].
[7] D. Read, “Xloader Arduino hex uploader.” [Online]. Available:
[1] M. Banzi, D. Cuartielles, D. Mellis, T. Igoe, and G. Martino, “Arduino http://russemotto.com/xloader/. [Accessed: 22- September- 2015].
Uno Hardware.” [Online]. Available: [8] S.S. Skogsrud, and S.K. Jeon, “Grbl Hex file.” [Online]. Available:
https://www.arduino.cc/en/Main/ArduinoBoardUno. [Accessed: 04- https://github.com/grbl/grbl/downloads. [Accessed: 02- September-
June- 2015]. 2015].
[2] S.S. Skogsrud, and S.K. Jeon, “Grbl.” [Online]. Available: [9] S.S. Skogsrud, and S.K. Jeon, “Universal-G-Code-Sender.” [Online].
https://github.com/grbl/grbl/wiki. [Accessed: 16- August- 2015]. Available: https://github.com/winder/Universal-G-Code-Sender.
[Accessed: 26- September- 2015].

You might also like