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

IJRET 20170604011 - Development of Arduino Code For SCARA Robotic Arm

This paper discusses the development of Arduino code for a SCARA robotic arm, focusing on converting G-Code from Cartesian to polar coordinates to control the arm's movements. It details modifications made to existing CNC firmware to accommodate the new coordinate system and explains the control logic, including angle calculations and stepper motor operations. The findings highlight the SCARA arm's compactness and its applications in automation tasks such as pick-and-place operations and spot welding.

Uploaded by

buditux
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views6 pages

IJRET 20170604011 - Development of Arduino Code For SCARA Robotic Arm

This paper discusses the development of Arduino code for a SCARA robotic arm, focusing on converting G-Code from Cartesian to polar coordinates to control the arm's movements. It details modifications made to existing CNC firmware to accommodate the new coordinate system and explains the control logic, including angle calculations and stepper motor operations. The findings highlight the SCARA arm's compactness and its applications in automation tasks such as pick-and-place operations and spot welding.

Uploaded by

buditux
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

IJRET: International Journal of Research in Engineering and Technology eISSN: 2319-1163 | pISSN: 2321-7308

DEVELOPMENT OF ARDUINO CODE FOR SCARA ROBOTIC ARM

Alekh Kumar Sinha1


1
Tata consultancy Services

Abstract
This paper deals with the development of arduino code for SCARA (Selective compliance assembly robotic arm). It accepts G-
Code and converts Cartesian coordinates to polar coordinates and uses those to move arms to that coordinate. It basically
modifies CNC firmware (working on Cartesian coordinates) available in github to suit for polar coordinates.

---------------------------------------------------------------------***-----------------------------------------------------------------

1. INTRODUCTION
I work in Tata Consultancy Services. There they have
excellent initial learning program (ILP) which they give to
fresher. There they encourage trainee to make innovative
project. My project was development of SCARA arm.

2. CNC FIRMWARE
We downloaded CNC firmware from GITHUB website and
used Arduino to load those codes. Main problem with this Fig 1: Arduino Mega
code was that, it was made to take Cartesian Coordinates as
input, but our requirement was polar coordinates. A separate
function was added to convert Cartesian Coordinates to
polar coordinates and also a new function was added to
calculate steps. It calculated angles that SCARA required to
move for achieving those coordinates, by using inverse
kinematics. Depending on the stepper motor configuration,
those angles were converted to steps, which were given as
input to the stepper motor. Stepper motor has to move by
those steps to achieve those coordinates.

Other changes are in extracting coordinates from G-codes Fig 2: Pololu Ramp 1.4
command. We converted whole command to string, then
used inbuilt functions to extract numbers from those 3.1 Defining Pins and Initialization of Variables
commands. Bresenham's line algorithm was used to move In this block pins are defined. Syntax is #define
two stepper motor together. variable_namepin_number. All the pins are defined here.
Initialization of variable is also done here. Arduino supports
The next task was to take input from the notepad. For that dynamic initialization but global variables definition needs
we used python shell and downloaded MYSERIAL module to be done here only. Syntax for this is
and followed instruction given on data_typevariable_name value.
http://www.meccanismocomplesso.org/en/arduino-tutorial-
serial-data-actuator/

3. ABOUT THE HARDWARE


Arduino was used to integrate logic with the hardware.
Arduino is a micro controller with various output and input
pins. We used POLOLU 1.4 ramps board to move stepper
motor together. Through Arduino interface one can load
logic into the controller and define output pins. Arduino
programming can be basically divided into three blocks.
• Defining of pins and initialization of variable
• Setup block loop block

Fig 3: Variable declaration


_______________________________________________________________________________________
Volume: 06 Issue: 04 | Apr-2017, Available @ http://www.ijret.org 45
IJRET: International Journal of Research in Engineering and Technology eISSN: 2319-1163 | pISSN: 2321-7308

Fig 6: Position function


Fig 4: Defining of pins
4. CONTROL LOGIC
3.2 Setup Block
Control logic can be divided into following steps:-
This block deals with the output and input pin definitions. In
 Extraction of coordinates from the CAD model
this program position() function is called. In position
function initial coordinates of the end collector is taken as  Take G-codes as input
input. This data is used to determine the initial angular  Extract coordinates from the G-Code
position of both the link. The initial angular position of link1  Convert Cartesian coordinates to polar coordinates
and link2 is stored in the array theta1[0] and theta2[0].  Calculation of angles by which links need to rotate
Further angular positions are also stored in this array and the  Convert those angles to steps
value is compared with initial position to calculate the angle  Move stepper motor by those steps
by which link needs to rotate
4.1 Extraction of Coordinates from the G-Code
For extraction of coordinates from G-Code, whole G-Code
command was converted into string and coordinates were
extracted from the command by using library functions.
Number which is preceded with G in the G code determines
the type of command.

Fig 5: Setup function

_______________________________________________________________________________________
Volume: 06 Issue: 04 | Apr-2017, Available @ http://www.ijret.org 46
IJRET: International Journal of Research in Engineering and Technology eISSN: 2319-1163 | pISSN: 2321-7308

4.2 Angle Calculation

Fig 7: Part of code showing extraction of coordinates

As you can see in the figure 6 picture, the first mark


highlights command to convert whole G-Code statements to
string. String.read() function is used for this purpose. This is
a library function which converts everything which is read
as input to string. 'd' is the variable of data type string and it
stores the G-Code command as string.

The second oval mark extracts number, which is after G in


the G-code command. This number is extracted by using Fig 8: Part of Code showing angle calculation
toInt() command. The syntax for this command is
string.toInt(). As number needs to be extracted from the part A user-defined function angle was created which accepts
of the string which is after G, d.substring(i+1) is used along coordinates and calculates angles by which both the link
with toInt() function. (i+1) denotes the subscript of the needs to rotate. This function was called from the loop
character which is after G. block.

Similarly, number after X is extracted from the G codes. If G01 is used with G90 then whatever coordinates extracted
This is marked by the third mark. toFloat() function is used is sent by adding origin which converts those to absolute
for this purpose. Last box denotes extraction of number coordinates, but if G91 is used then absolute coordinates of
which is after letter Y in the G-Code command. Other the previous position needs to be added to the extracted
coordinates such as Z can be extracted with similar logic. coordinates to generate absolute coordinates of the new
These x coordinates and y coordinate are with respect to the position. Here px and py stores absolute coordinate x and y
origin of the work piece but we want all the coordinate with coordinates of the previous position.
respect to point of rotation of the first link so, origin
coordinate with respect to point of rotation of the first link is For angle calculation inverse kinematics is used
asked as input and is added to all the coordinates extracted
from the G-code, which converts all coordinates with 4.2.1 Inverse Kinematics
respect to point of rotation of the first link. Inverse kinematics is used to get polar coordinates from the
Cartesian coordinatesAs you can see in the figure 8 if we
join o with c then it will form a triangle. We know the
length all the sides of the triangle, every angle can be
calculated using Cosine law.

_______________________________________________________________________________________
Volume: 06 Issue: 04 | Apr-2017, Available @ http://www.ijret.org 47
IJRET: International Journal of Research in Engineering and Technology eISSN: 2319-1163 | pISSN: 2321-7308

shown in the above figure, arc tangent is found which gives


the arc angle and that angle is divided into segments to find
intermediate points. The coordinates of intermediate points
is send as input it to the angle function and same as in the
case of line, process is repeated.

4.4 To Move Stepper Motor Together

Fig 9: Inverse Kinematic Calculation

4.3 G02 and G03 Command


G03 and G04 is used for tracing arc. This has five input
preceded by letters G,X,Y,I and Jrespectively. Number after
X and Y are x and y coordinate of the end point of arc and I
and J are vertical and horizontal increment respectively.

Fig 11: Bresenham'salgorithm

In order to move stepper motor, those angles were converted


to steps. We have used NEMA 17 which covers 200steps in
one complete rotation. We have used POLUA RAMPS 1.4
BOARD. It has pins for connecting three motors and can
make them work simultaneously. Jumper along with the
stepper motor driver is used which enables micro- stepping
.This micro stepping divides each step into 32 sub step so, in
360 deg of rotation it has 6400(32*200) micro steps. With
this we can conclude that 1 degree can be covered by
3200/180 sub steps. We have used a belt transmission with
diameter of the pulley in the ratio 1:3. This means that with
3deg of rotation of stepper motor, link will rotate by 1 deg.
This can be further interpreted as for rotating link by one
degree stepper motor needs to move by 9600/180
(3*3200/180) sub steps.

By using the above stated concept steps are calculated from


angles. First few statement of the angle function (as shown
in the figure) illustrate this concept.

The above calculated steps are fed in Bresenham’s algorithm


to move both the stepper motors together. Bresenham's
algorithm ensures that both the motor complete their steps
Fig 10: Part of coding showing interpolation function together. For example if a stepper motor needs to move by
50 steps and other by 100 steps ,their speed will be so
Arc is divided into segments and is approximated to be adjusted that both the motor will complete their steps
formed of small lines. These inputs are used to interpolate together.
arc to find intermediate points and the coordinates of those
points are fed in the previously explained function angle. As
_______________________________________________________________________________________
Volume: 06 Issue: 04 | Apr-2017, Available @ http://www.ijret.org 48
IJRET: International Journal of Research in Engineering and Technology eISSN: 2319-1163 | pISSN: 2321-7308

4.5 Debugging and Validation different points are selected for b. The difference between
those angles will give angle by which links needs to rotate to
achieve those coordinate.

For example at point angle between link 1 and x axis is 141


deg and in point B it changes to 118 deg so link 1 needs to
move by 22 deg for moving end collector from position A to
position B.

This can be used for debugging and also for validation of the
codes. As shown in the figure below ,the value which is sent
to 'tomove' function is printed. This value represents the
angle by which stepper motor will move. A step counter is
also included in step function to calculate how many steps
stepper motor has moved. If these things tally with the
design software generated data then program is correct or
else its require debugging.

Fig 12: Kinematic Representation of SCARA arm

As you can see in the above figure, SCARA model can be


simplified and can be represented by a kinematic line
diagram. This line diagram has one re-volute pair at o and
other at b. The end c represents the position of the end
collector. Now we can draw this line diagram in a designing
software and utilize this concept to find angles by which
links need to rotate.

Fig 14: Angle output to be validated by line diagram

Fig 13: line diagram drawn in designing software to find out


angles that links require to move

We need to decide at what coordinate we want the end


collector to be. With this decision, point b is fixed and now a
line is drawn whose length is equal to the length of link 1
and other whose length is equal to the length of the link 2
(as shown in the figure). With the help of this diagram we
can calculate the angle between link1 and x axis and also
angle between link 2 and link1 This angle will change when
_______________________________________________________________________________________
Volume: 06 Issue: 04 | Apr-2017, Available @ http://www.ijret.org 49
IJRET: International Journal of Research in Engineering and Technology eISSN: 2319-1163 | pISSN: 2321-7308

Table 1: Data extracted from CAD model


Sl Coordinates Absolute Absolute Change in in Change in Direction
no angles moved angles moved angle for link 1 angle for
by link 1 by link 2 link 2
1 (0,335) 141.8864 96.09
2 (115,335) 119.48 90 22.40 6.09 Anticlockwise,clockwise
3 (115,435) 102.76 51.33 16.72 38.67 Anticlockwise,clockwise
4 (0,435) 121.55 59.2 18.79 7.87 Anticlockwise,clockwise

Table 2: Data extracted from software


Sl coordinate Angle required Angle it actually moved
no s to move
1 (0,335)
2 (115,335) 22.40 6.09 22.51 6.33
3 (115,435) 16.72 38.67 18.15 40.89
4 (0,435) 18.79 7.87 19.2 8.175

5. CONCLUSION
Scara is very useful as its very compact. This paper will help
in developing control logic for SCARA model. This model
has varied application in case of pick and place robot, or
automated spot welding etc.

REFERENCES
[1] Codes from GITHUB
[2] https://www.arduino.cc/en/Tutorial/HomePage
[3] https://en.wikipedia.org/wiki/SCARA
[4] https://github.com/grbl/grbl

_______________________________________________________________________________________
Volume: 06 Issue: 04 | Apr-2017, Available @ http://www.ijret.org 50

You might also like