Report Finale

Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

Project Report

2 Degree-of-Freedom Robot Arm

Instructor: PhD. Duong Van Lac


Members:
1. Nhan Hồng Thành - 20206107
2. Đào Minh Đức - 20206036
3. Trương Quang Trung - 20206093

Contents
1. Introduction
1.1. Motivation
1.2. Available product
1.3. Overview
2. System Design
2.1. Mechanical Design
2.1.1. 3D Modelling
2.1.2. Material and Manufacturing
2.1.3. Assembly
2.2. Electrical Design
2.2.1. Microcontroller
2.2.2. Actuator
2.2.3. Power
2.3. Control Design
2.3.1. Embedded programming
2.4. User Interface (UI) Design
2.4.1. About Qt5
2.4.2. Implementation
3. Conclusion
3.1. Comment
3.2. Limitation and Development
1. Introduction
1.1 Motivation.
- In today's fast-paced and technologically driven world, the integration of robotics into various industries has
become more prevalent than ever before. Among these remarkable advancements, the robot arm stands tall as
one of the most versatile and transformative inventions of our time. With the ability to replicate human arm
movements and perform a wide range of tasks, robot arms have revolutionized the way we approach
manufacturing, assembly, and automation processes.
- With the development of science and technology, an increasing number of types of robotic arms are being
developed and manufactured to meet the needs of the factories. We can see them in manufacturing facilities.
- Being students on the Mechatronics course, we have seen and approached some kinds of robot arms. And for
this project we will design a small robot arm that has 2 degrees of freedom.

1.2 Available product.


- There are numerous different robotic arm types available on today’s market, each designed with important
core abilities and functions that make various specific types particularly well-suited for roles or industrial
environments. Various robotic arm types include:
 Articulated arm
 Six-axis arm
 Collaborative robot arm
 SCARA arm
 Cartesian arm
 Cylindrical arm
 Spherical/Polar arm
 Parallel/Delta arm
 Etc...
- There are some pictures of the robot arms working in reality as shown below.

Figure 1. Robot Arm in Vin Fast Factory.


Figure 2. Robot SCARA.

1.3 Overview of our project.


We have designed and created a robot arm using an Arduino controller. This robot has 2 degrees of freedom,
and its components have been 3D printed to keep costs low. For controlling the movements of the joints, we
have chosen 2 MG996R servo motors. Additionally, we have developed software to interact with the robot
through the Qt framework. All these aspects will be shown in the following sections.
2. System Design
2.1. Mechanical Design
2.1.1. 3D Modelling
To begin with, we designed the Robot Arm using SolidWorks 3D modeling software. The arm has 2 degrees
of freedom.

Figure 3. Parts in SolidWorks so ware

2.1.2. Material and Manufacturing


All the parts are made from PLA plastic, and we use a 3D printer to manufacture them.
Figure 4. Parts in reality

2.1.3. Assembly
The last job is to assemble all the parts along with servos together to form the whole structure of the robot arm.
Our final prototype is shown below.

Figure 5. Robot Arm a er assembled.


2.2. Electrical Design
2.2.1. Microcontroller
- We will choose the Arduino Uno R3 board for the controller.
- Arduino Uno is a microcontroller board based on the ATmega328P. It has 14 digital input/output pins (of
which 6 can be used as PWM (Pulse Width Modulation) outputs), 6 analog inputs, a 16 MHz quartz
crystal, a USB connection, a power jack, an ICSP header and a reset button. The board is equipped with
the well-known ATmega328P and the AT Mega 16U2 Processor.
- Here are some technical specifications for the Arduino UNO R3:
 Microcontroller: ATmega328P
 USB connector: USB-B
 Pins: Built-in LED (light emitting diodes) Pin 13
 Digital I/O Pins: 14
 Analog input pins: 6
 PWM pins: 6
 Communication: UART Yes, I2C Yes, SPI Yes
 Power I/O Voltage: 5V
 Input voltage (nominal): 7-12V DC (Direct Current)
 Current per I/O Pin: 20 mA
 Power Supply Connector: Barrel Plug
 Clock speed Main Processor: ATmega328P 16 MHz USB-Serial Processor ATmega16U2 16 MHz
Memory ATmega328P 2KB SRAM, 32KB FLASH, 1KB EEPROM

Figure 6. Arduino board


2.2.2. Actuator
- There are lots of servo motors available in the market and each one has its own specialty and
applications. The MG996R is a metal gear servo motor with a maximum stall torque of 11 kg/cm. Like
other RC servos the motor rotates from 0 to 180 degrees based on the duty cycle of the PWM wave
supplied to its signal pin.
- After selecting the right Servo motor for the project, the question is how to use it. As we know there are
three wires coming out of this motor. The description of the same is given on top of this page. To make
this motor rotate, we must power the motor with +5V using the Red and Brown wire and send PWM
signals to the orange color wire. Hence, we need something that could generate PWM signals to make
this motor work, this something could be anything like a 555 Timer or other Microcontroller platforms
like Arduino, PIC, ARM or even a microprocessor like Raspberry Pi. Now, how to control the direction
of the motor? To understand that let us look at the picture given in the datasheet.
-

Figure 7. PWM

- From the picture we can understand that the PWM signal produced should have a frequency of 50 Hz,
that is the PWM period should be 20ms. Out of which the On-Time can vary from 1ms to 2ms. So, when
the on-time is 1ms the motor will be in 0° and when 1.5ms the motor will be 90°, similarly when it is
2ms it will be 180°. So, by varying the on-time from 1ms to 2ms the motor can be controlled from 0° to
180°
- This project's circuit diagram is quite simple. This project's circuit diagram is quite simple. We just need
an Arduino board and 2 MG996R Servo motors and we communicate with the computer through USB
ports. The control pins of the 2 servo motors are connected to 2 digital pins of the Arduino board.
Figure 8. 2 DOF Robot arm circuit

2.2.3. Power
- To power the servos, we need 5V, but this must come from an external power source because the
Arduino is not able to handle the amount of current that all of them can draw.

Figure 9. Lithium Ba ery

2.3 Control design


The algorithm
- We will use a simple algorithm for our project, it is described below.
Figure 10. Algorithm Procedure

- There is also a point-to-point motion function. Where we can save positions to some arrays and push the
Run button to implement those steps.
2.3.1. Embedded programming
- In this project we will use a program to control the robot arm using Arduino Uno R3 board. Below is the
program that we write to control it.

#include <Servo.h>

Servo servo01;
Servo servo02;
Servo servo03;

int servo1Pos, servo2Pos, servo3Pos; // current position


int servo1PPos, servo2PPos, servo3PPos; // previous position
int servo01SP [50], servo02SP [50], servo03SP [50]; // for storing positions/steps
int speedDelay = 20;
int index = 0;
String dataIn = "";
void runservo();

void setup () {
servo01.attach(5);
servo02.attach(6);
servo03.attach(7);
Serial.begin(38400);
Serial.setTimeout(1);
delay (20);
// Robot arm initial position
servo1PPos = 90;
servo01.write(servo1PPos);
servo2PPos = 150;
servo02.write(servo2PPos);
servo3PPos = 35;
servo03.write(servo3PPos);
}
void loop () {
// Check for incoming data
if (Serial.available() > 0) {
//Serial.println("Connected");
dataIn = Serial.readString(); // Read the data as string
Serial.print(dataIn);

// If "Waist" slider has changed value - Move Servo 1 to position


if (dataIn.startsWith("s1")) {
String dataInS = dataIn.substring(2, dataIn.length()); // Extract only the number. E.g., from "s1120" to
"120"
servo1Pos = dataInS.toInt(); // Convert the string into integer
// We use for loops so we can control the speed of the servo
// If previous position is bigger than current position

if (servo1PPos > servo1Pos) {


for (int j = servo1PPos; j >= servo1Pos; j--) {// Run servo down
servo01.write(j);
delay (20); // defines the speed at which the servo rotates
}
}
// If previous position is smaller than current position
if (servo1PPos < servo1Pos) {
for (int j = servo1PPos; j <= servo1Pos; j++) {// Run servo up
servo01.write(j);
delay (20);
}
}
servo1PPos = servo1Pos; // set current position as previous position
}

// Move Servo 2
if (dataIn.startsWith("s2")) {
String dataInS = dataIn.substring(2, dataIn.length());
servo2Pos = dataInS.toInt();
if (servo2PPos > servo2Pos) {
for (int j = servo2PPos; j >= servo2Pos; j--) {
servo02.write(j);
delay (50);
}
}
if (servo2PPos < servo2Pos) {
for (int j = servo2PPos; j <= servo2Pos; j++) {
servo02.write(j);
delay (50);
}
}
servo2PPos = servo2Pos;
}
// Move Servo 3
if (dataIn.startsWith("s3")) {
String dataInS = dataIn.substring(2, dataIn.length());
servo3Pos = dataInS.toInt();
if (servo3PPos > servo3Pos) {
for (int j = servo3PPos; j >= servo3Pos; j--) {
servo03.write(j);
delay (30);
}
}
if (servo3PPos < servo3Pos) {
for (int j = servo3PPos; j <= servo3Pos; j++) {
servo03.write(j);
delay (30);
}
}
servo3PPos = servo3Pos;
}
}
// If button "SAVE" is pressed
if (dataIn.startsWith("SAVE")) {
servo01SP [index] = servo1PPos; // save position into the array
servo02SP [index] = servo2PPos;
servo03SP [index] = servo3PPos;

index++; // Increase the array index


for (int i = 0; i < index; i++) {
Serial.write(servo01SP[i]);
}
}
// If button "RUN" is pressed
if (dataIn.startsWith("RUN")) {
runservo(); // Automatic mode - run the saved steps
}
// If button "RESET" is pressed
if ( dataIn == "RESET") {
memset(servo01SP, 0, sizeof(servo01SP)); // Clear the array data to 0
memset(servo02SP, 0, sizeof(servo02SP));
memset(servo03SP, 0, sizeof(servo03SP));
index = 0; // Index to 0
}
}
// Automatic mode custom function - run the saved steps
void runservo() {
while (dataIn != "RESET") {// Run the steps repeatedly until "RESET" button is pressed
for (int i = 0; i <= index - 2; i++) {// Run through all steps(index)
// Servo 1
if (servo01SP[i] == servo01SP [i + 1]) {
}
if (servo01SP[i] > servo01SP [i + 1]) {
for (int j = servo01SP[i]; j >= servo01SP [i + 1]; j--) {
servo01.write(j);
delay(speedDelay);
}
}
if (servo01SP[i] < servo01SP [i + 1]) {
for (int j = servo01SP[i]; j <= servo01SP [i + 1]; j++) {
servo01.write(j);
delay(speedDelay);
}
}
// Servo 2
if (servo02SP[i] == servo02SP [i + 1]) {
}
if (servo02SP[i] > servo02SP [i + 1]) {
for (int j = servo02SP[i]; j >= servo02SP [i + 1]; j--) {
servo02.write(j);
delay(speedDelay);
}
}
if (servo02SP[i] < servo02SP [i + 1]) {
for (int j = servo02SP[i]; j <= servo02SP [i + 1]; j++) {
servo02.write(j);
delay(speedDelay);
}
}
// Servo 3
if (servo03SP[i] == servo03SP [i + 1]) {
}
if (servo03SP[i] > servo03SP [i + 1]) {
for (int j = servo03SP[i]; j >= servo03SP [i + 1]; j--) {
servo03.write(j);
delay(speedDelay);
}
}
if (servo03SP[i] < servo03SP [i + 1]) {
for (int j = servo03SP[i]; j <= servo03SP [i + 1]; j++) {
servo03.write(j);
delay(speedDelay);
}
}
}
}
- The above program uses the built-in class <Servo.h>, it makes the developing process much easier with
its data and method. We can easily control the servos to move to the desire position if they work properly.

2.4 User Interface Design


2.4.1 About Qt5
- Qt5 is a development framework with tools for creating applications and user interfaces for various
platforms. It uses C++, QML, and JavaScript languages and supports hardware-accelerated graphics. You
can install the Qt Framework and tools by using an online or offline installer, or by building the source
packages yourself. The installers allow you to download and install the following components: Qt libraries,
prebuilt for a particular development platform (operating system and compiler) Qt Creator integrated
development environment (IDE) Reference Documentation and examples Qt in source code form (needed
only if you want to build the framework and tools yourself) Add-On components that are relevant for
different platforms.
2.4.2 Implementation

Figure 11. Qt designer interface


- We used basic components of a UI provided by Qt5 like slider, pushbutton, combo box... to design our
UI.
- After that we hard code the program to implement the UI.
- The idea is to control the robot arm with this UI via serial communications, and the sliders are to control
each link position.
- The project source code is provided with this project report.
- Below is the result of our project.

Figure 12. Interface designed

- At the top portion of UI, it is the connection part, we can choose which port to connect to, which baud
rate to work with along with Connect and Disconnect button to control the connection.
- At the middle portion, there are sliders used to control the position of the arms.
- At the bottom portion, there are three buttons for point-to-point motion.
3. Conclusion
3.1 Comment
- After launching the course work, first, we have learnt to do the teamwork, and how to apply various
mechatronics knowledge we have learnt before to do the project, such as mechanical design, electrical
component selection, along with the knowledge we have just gained from this course like embedded
programming and user interface programming.
- The project was going through a lot of changes during the implementation, we encountered some issues
and had to change the initial design so that we could complete the project.

3.2 Limitation and Development


- We have tried our best to complete the project but there are a lot of inevitable problems. Our infrastructure
was not good enough to assemble the mechanical parts easily, we could not buy authentic electrical
components so that some were not working properly.
- After all, we have gained a lot of experience, and we hope that in the future, we can overcome those
difficulties to do the next project better.

Reference:
1. Howtomechatronics.com
2. Lecture notes from Programming in Mechatronics course
3. Qt.io
4. Wikipedia.com
5. Arduino.cc

You might also like