• Tidak ada hasil yang ditemukan

BAB V KESIMPULAN DAN SARAN

5.2 Saran

Berdasarkan hasil implementasi yang diperoleh, untuk pengembangan penelitian lebih lanjut ada beberapa saran agar alat ini dapat bekerja lebih baik, yaitu :

1. Perancangan ulang pada mekanik sistem lengan robot pantograf dengan berdasarkan area kerja harus lebih tepat atau presisi sesuai dengan fungsi dan kegunaan.

2. Penentuan titik nol yang tepat dan tidak berubah-ubah agar dalam pengambilan data tidak mengalami salah kepresisian.

3. Pemilihan software dalam menggerakkan suatu robot akan mempengaruhi proses penggerakkan lengan robot.

47

DAFTAR PUSTAKA

[1] Dina. Caysar, "PENGATURAN PERGERAKAN ROBOT LENGAN SMART ARM ROBOTIC AX-12A MELALUI PENDEKATAN GEOMETRY BASED

KINEMATIC MENGGUNAKAN ARDUINO," 2014.

[2] Hans. G. Frommer, practical CNC-Training for Planning and Shop (part2 : Example and exercise), Germany: Hanser , 1985.

[3] RobotShop, "Arduino Mega 2560 Datasheet," [Online]. Available:

https://www.robotshop.com/media/files/PDF/ArduinoMega2560Datasheet.pdf. [Accessed 5 februari 2019].

[4] Budi. Wiro, "Desain Manufaktur Kode dan Format Program CNC," 29 September 2015. [Online]. Available:

http://desainmanufaktur.bayuwiro.net/index.php/2015/09/29/kode-format-program-cnc/. [Accessed 25 Oktober 2018].

[5] Leonardus. Dwi. Niandityo, "PENGUBAH GAMBAR VEKTOR MENJADI PERINTAH GERAKAN ROBOT DALAM G-CODE," Skripsi, pp. 5-6, 2017. [6] "INKSCAPE," [Online]. Available:

https://inkscape.org/doc/basic/tutorial-basic.id.html. [Accessed 09 November 2018].

[7] CAMotics. [Online]. Available: https://camotics.org/.html. [Accessed 10 September 2019].

[8] Syahrul. "BIDANG REKAYASA," Motor STEPPER: TEKNOLOGI, METODA DAN

RANGKAIAN KONTROL, vol. 6, p. 187.

[9] Agustinus. Welly. Adi. Nugroho, "LENGAN ROBOT PENGGAMBAR BIDANG DUA DIMENSI BERBASIS MIKROKONTROLER DENGAN PC," Skripsi, pp. 21-22, 2015.

[10] processing. "processing," [Online]. Available: https://processing.org/reference/. [Accessed 4 oktober 2019].

[11] "Universitas Narotama sistem komputer," Mikrokontroler, Februari 2013. [Online]. Available: http://sistemkomputer.narotama.ac.id/2013/02/konsep-mikrokontroler/. [Accessed 25 Oktober 2018].

48

49

Hasil Pengujian Gambar Kotak, Segitiga, Lingkaran 10x gambar dengan

5x skala 100% dan 50%

L4. Motor Servo Tower pro MG90S

Specifications : 1. Weigh : 13.4 g 2. Dimension : 22.5 x 12 x 35.5 mm 3. Stall torque : 1.8 kg/cm (4.8V) 4. Operating speed: 0.1s/60° (4.8V) 5. Operating Voltage: 4.8V to 6V 6. Max Stall Torque: 2.2 kg/cm (6V) 7. Gear Type: Metal

8. Rotation : 0°-180°

L7. Power Supply 12V 30 A

SPESIFIKASI * Model : 12V-30A * Input : 220 volt AC * Output : 12 volt DC * Kapasitas : 30 ampere * Ukuran : 215mmx115mmx50mm * Berat bersih : 750g Cara Pemakaiannya :

- kabel listrik di hubungkan ke lambang L & N - lambang COM di hubungkan 12 V - ( min ) - lambang +V dihubungkan 12 V + ( plus )

L9. Perintah G-Code Pada Pengujian Gambar Kotak

%

(Header)

(Generated by gcodetools from Inkscape.)

(Using default header. To add your own header create file "header" in the output dir.) M3

(Header end.)

G21 (All units in mm)

(Start cutting path id: path16879) (Change tool to Default tool) G00 Z5.000000 G00 X34.201464 Y39.688380 G01 Z-0.125000 F100.0(Penetrate) G01 X34.201464 Y62.701760 Z-0.125000 F400.000000 G01 X57.705574 Y62.701760 Z-0.125000 G01 X81.209702 Y62.701760 Z-0.125000 G01 X81.209702 Y39.688380 Z-0.125000 G01 X81.209702 Y16.674960 Z-0.125000 G01 X57.705574 Y16.674960 Z-0.125000 G01 X34.201464 Y16.674960 Z-0.125000 G01 X34.201464 Y39.688380 Z-0.125000 G00 Z5.000000

(End cutting path id: path16879) (Start cutting path id: path16879) (Change tool to Default tool) G00 Z5.000000

(End cutting path id: path16879) (Footer)

M5

G00 X0.0000 Y0.0000 M2

(Using default footer. To add your own footer create file "footer" in the output dir.) (end)%

L10. Perintah G-Code Pada Pengujian Gambar segitiga

%

(Header)

(Generated by gcodetools from Inkscape.)

(Using default header. To add your own header create file "header" in the output dir.) M3

(Header end.)

G21 (All units in mm)

(Start cutting path id: path6489) (Change tool to Default tool) G00 Z5.000000 G00 X51.199114 Y59.622900 G01 Z-0.125000 F100.0(Penetrate) G02 X51.158608 Y59.280813 Z-0.125000 I-0.345390 J-0.132544 F400.000000 G02 X38.576875 Y41.117899 Z-0.125000 I-2474.754731 J1700.861787 G02 X25.861959 Y23.048195 Z-0.125000 I-2462.522396 J1719.268641 G02 X25.551654 Y22.887840 Z-0.125000 I-0.310305 J0.220060 G02 X25.239434 Y23.049991 Z-0.125000 I0.000000 J0.381663 G02 X12.640020 Y41.113519 Z-0.125000 I2413.460056 J1696.828090 G02 X0.175762 Y59.270660 Z-0.125000 I2425.907148 J1678.659160 G02 X0.135381 Y59.618070 Z-0.125000 I0.311733 J0.212286 G02 X0.472195 Y59.851918 Z-0.125000 I0.340229 J-0.130553 G02 X25.667251 Y59.971180 Z-0.125000 I25.456662 J-2716.540072 G02 X50.862398 Y59.856771 Z-0.125000 I0.261608 J-2716.686517 G02 X51.199114 Y59.623070 Z-0.125000 I-0.003343 J-0.364237 G01 X51.199114 Y59.622900 Z-0.125000 G00 Z5.000000

(End cutting path id: path6489) (Start cutting path id: path6489) (Change tool to Default tool) G00 Z5.000000

G00 X1.749841 Y58.753860 G00 Z5.000000

(End cutting path id: path6489) (Footer)

M5

G00 X0.0000 Y0.0000 M2

(Using default footer. To add your own footer create file "footer" in the output dir.) (end)

L11. Perintah G-Code Pada Pengujian Gambar lingakaran

%

(Header)

(Generated by gcodetools from Inkscape.)

(Using default header. To add your own header create file "header" in the output dir.) M3

(Header end.)

G21 (All units in mm)

(Start cutting path id: path21986) (Change tool to Default tool) G00 Z5.000000 G00 X52.115384 Y16.227550 G01 Z-0.125000 F100.0(Penetrate) G02 X49.378585 Y16.974042 Z-0.125000 I4.470887 J21.781334 F400.000000 G02 X45.930405 Y18.346840 Z-0.125000 I12.338735 J36.009244 G02 X42.725454 Y20.172052 Z-0.125000 I8.506959 J18.664105 G02 X39.135549 Y23.072860 Z-0.125000 I18.339984 J26.368460 G02 X34.775994 Y28.283062 Z-0.125000 I18.976061 J20.306918 G02 X31.901200 Y34.255290 Z-0.125000 I22.213159 J14.370554 G02 X30.725536 Y41.702047 Z-0.125000 I21.575368 J7.222416 G02 X32.048621 Y49.205430 Z-0.125000 I23.237315 J-0.229136 G02 X34.944609 Y55.010635 Z-0.125000 I24.827997 J-8.760758 G02 X39.307233 Y60.134710 Z-0.125000 I23.599822 J-15.673628 G02 X53.426550 Y66.919530 Z-0.125000 I18.085464 J-19.552465 G02 X69.473245 Y64.677430 Z-0.125000 I4.243090 J-28.176331 G02 X76.345911 Y60.168593 Z-0.125000 I-11.134724 J-24.464584 G02 X81.119575 Y54.168130 Z-0.125000 I-15.669596 J-17.365009 G02 X83.602822 Y47.984519 Z-0.125000 I-23.264635 J-12.933156 G02 X84.436919 Y41.513250 Z-0.125000 I-24.686327 J-6.471269 G02 X83.609122 Y35.067626 Z-0.125000 I-25.508255 J-0.000000 G02 X81.131923 Y28.858350 Z-0.125000 I-26.118180 J6.821104 G02 X76.621104 Y23.019750 Z-0.125000 I-21.055544 J11.605416 G02 X70.470830 Y18.746870 Z-0.125000 I-17.045161 J17.971653

G02 X61.220460 Y15.926711 Z-0.125000 I-13.389659 J27.338168 G02 X52.115384 Y16.227550 Z-0.125000 I-3.673244 J26.762782 G01 X52.115384 Y16.227550 Z-0.125000

G00 Z5.000000

(End cutting path id: path21986) (Start cutting path id: path21986) (Change tool to Default tool) G00 Z5.000000

(End cutting path id: path21986) (Footer)

M5

G00 X0.0000 Y0.0000 M2

(Using default footer. To add your own footer create file "footer" in the output dir.) (end)

%

L12. Listing Program Arduino Mega2560

#include <Arduino.h>

#include "BasicStepperDriver.h" #include "MultiDriver.h"

#include "SyncDriver.h"

//---motor---

// Motor steps per revolution. Most steppers are 200 steps or 1.8 degrees/step

#define MOTOR_STEPS 800 //200*4 (360* = 200 step. diguakan reduksi 1:4 15t:60t jadi satu putaran = 200X4=800pulsa per putaran<360*>)

#define MICROSTEPS 32

#define STEPS_PER_DEG MOTOR_STEPS*MICROSTEPS // Target RPM for X axis motor

#define MOTOR_X_RPM 0.5 // mengatur kecepatan x // Target RPM for Y axis motor

#define MOTOR_Y_RPM 0.5 // mengatur kecepatan y // X motor pin #define DIR_X 28 #define STEP_X 26 // Y motor pin #define DIR_Y 34 #define STEP_Y 36

BasicStepperDriver stepperX(MOTOR_STEPS, DIR_X, STEP_X); BasicStepperDriver stepperY(MOTOR_STEPS, DIR_Y, STEP_Y);

SyncDriver controller(stepperX, stepperY);

//#define CW 1 //motor directions //#define CCW -1 //--- //---//servo//--- #include <Servo.h> Servo myservo; int pos = 0; //--- // --- constants--- #define PI 3.1415926535897932384626433832795 #define HALF_PI 1.5707963267948966192313216916398 #define TWO_PI 6.283185307179586476925286766559 #define DEG_TO_RAD 0.017453292519943295769236907684886 #define RAD_TO_DEG 57.295779513082320876798154814105 //--- long

PULSE_WIDTH = 5, //easydriver step pulse-width (uS)

DELAY_MIN = 20000, //minimum inter-step delay (uS) between motor steps (controls speed)

DELAY1=0, //inter-step delay for motor1 (uS) DELAY2=0, //inter-step delay for motor2 (uS)

STEPS1 = 0, //motor1 steps from 12 o'clock to reach an XY co-ordinate STEPS2 = 0; //motor2 steps from 12 o'clock to reach an XY co-ordinate double

angleX, angleY;

// --- plotter definitions #define BAUD 9600

#define XOFF 0x13 //pause transmission (19 decimal) #define XON 0x11 //resume transmission (17 decimal) #define PEN 4

float

OFFSET1 = 155, //motor1 offset along x_axis OFFSET2 = 255, //motor2 offset along x_axis YAXIS = 570, //motor heights above (0,0) LENGTH = 320, //length of each arm-segment SCALE_FACTOR = 1, //drawing scale (1 = 100%)

ARC_MAX = 2; //maximum arc-length (controls smoothness) int

/*

XY plotters only deal in integer steps. */

THIS_X = 0, //this X co-ordinate (rounded) THIS_Y = 0, //this Y co-ordinate (rounded) LAST_X = 0, //last X co-ordinate (rounded) LAST_Y = 0; //last Y co-ordinate (rounded) // --- gcode definitions

#define STRING_SIZE 256 //string size char

BUFFER[STRING_SIZE + 1], INPUT_CHAR;

INPUT_STRING, SUB_STRING; int

INDEX = 0, //buffer index

START, //used for sub_string extraction FINISH;

//deltaX=0; //deltaY=0; float

X, //gcode float values held here Y,

I, J;

void setup() {

// put your setup code here, to run once: // stepper.enable(); stepperX.begin(MOTOR_X_RPM, MICROSTEPS); stepperY.begin(MOTOR_Y_RPM, MICROSTEPS); pinMode(30, OUTPUT); pinMode(24, OUTPUT);

digitalWrite(30, LOW); // pin enable motor x digitalWrite(24, LOW); // pin enable motor y

// --- initialise STEPS1, STEPS2 for co-ordinate (0,0) calculate_steps(0, 0);

myservo.attach(PEN); // --- plotter setup

memset(BUFFER, '\0', sizeof(BUFFER)); //fill with string terminators INPUT_STRING.reserve(STRING_SIZE);

INPUT_STRING = ""; // --- establish serial link Serial.begin(BAUD);

// --- flush the buffers

Serial.flush(); //clear TX buffer

while (Serial.available()) Serial.read(); //clear RX buffer

// --- display commands menu(); } //--- // MAIN LOOP //--- void loop() {

// put your main code here, to run repeatedly:

// --- // get the next instruction // --- while (Serial.available()) {

INPUT_CHAR = (char)Serial.read(); //read character

Serial.write(INPUT_CHAR); //echo character to the screen BUFFER[INDEX++] = INPUT_CHAR; //add char to buffer if (INPUT_CHAR == '\n') { //check for line feed Serial.flush(); //clear TX buffer Serial.write(XOFF); //pause transmission INPUT_STRING = BUFFER; //convert to string

process(); //interpret string and perform task memset(BUFFER, '\0', sizeof(BUFFER)); //fill buffer with string terminators INDEX = 0; //point to buffer start

INPUT_STRING = ""; //empty string Serial.flush(); //clear TX buffer

Serial.write(XON); //resume transmission } } } void menu() { Serial.println(F("")); Serial.println(F(" ---")); Serial.println(F(" MENU")); Serial.println(F(" ---")); Serial.println(F(" MENU ... menu"));

Serial.println(F(" G00 X## Y## ... goto XY (pen-up)")); Serial.println(F(" G01 X## Y## ... goto XY (pen-down)")); Serial.println(F(" T1 ... move pen to 0,0"));

Serial.println(F(" T2 S##.## ... set drawing Scale (1=100%)")); Serial.println(F(" ---")); }

void process() {

// --- convert string to upper case INPUT_STRING.toUpperCase(); // --- // G00 linear move with pen_up // --- if (INPUT_STRING.startsWith("G00")) { // --- extract X START = INPUT_STRING.indexOf('X'); if (!(START < 0)) { FINISH = START + 8;

SUB_STRING = INPUT_STRING.substring(START + 1, FINISH + 1); X = SUB_STRING.toFloat();

}

START = INPUT_STRING.indexOf('Y'); if (!(START < 0)) {

FINISH = START + 8;

SUB_STRING = INPUT_STRING.substring(START + 1, FINISH + 1); Y = SUB_STRING.toFloat(); } Serial.println(F("")); Serial.print(X); Serial.print("<-X Y->"); Serial.println(Y); pen_up(); move_to(X, Y); } // --- // G01 linear move with pen_down // --- if (INPUT_STRING.startsWith("G01")) { // --- extract X START = INPUT_STRING.indexOf('X'); if (!(START < 0)) { FINISH = START + 8;

SUB_STRING = INPUT_STRING.substring(START + 1, FINISH + 1); X = SUB_STRING.toFloat(); } // --- extract Y START = INPUT_STRING.indexOf('Y'); if (!(START < 0)) { FINISH = START + 8;

SUB_STRING = INPUT_STRING.substring(START + 1, FINISH + 1); Y = SUB_STRING.toFloat();

} Serial.println(F("")); Serial.print(X); Serial.print("<-X Y->"); Serial.println(Y); pen_down(); move_to(X, Y); } // ---

// G02 clockwise arc with pen_down // ---

if (INPUT_STRING.startsWith("G02")) {

// --- extract X

START = INPUT_STRING.indexOf('X'); if (!(START < 0)) {

FINISH = INPUT_STRING.indexOf('.', INPUT_STRING.indexOf('X')); SUB_STRING = INPUT_STRING.substring(START + 1, FINISH + 7); X = SUB_STRING.toFloat();

}

// --- extract Y

START = INPUT_STRING.indexOf('Y'); if (!(START < 0)) {

FINISH = INPUT_STRING.indexOf('.', INPUT_STRING.indexOf('Y')); SUB_STRING = INPUT_STRING.substring(START + 1, FINISH + 7); Y = SUB_STRING.toFloat();

}

// --- extract I

START = INPUT_STRING.indexOf('I'); if (!(START < 0)) {

FINISH = INPUT_STRING.indexOf('.', INPUT_STRING.indexOf('I')); SUB_STRING = INPUT_STRING.substring(START + 1, FINISH + 7); I = SUB_STRING.toFloat();

}

// --- extract J

START = INPUT_STRING.indexOf('J'); if (!(START < 0)) {

FINISH = INPUT_STRING.indexOf('.', INPUT_STRING.indexOf('J')); SUB_STRING = INPUT_STRING.substring(START + 1, FINISH + 7); J = SUB_STRING.toFloat(); } Serial.println(F("")); Serial.print(X); Serial.print("<-X Y->"); Serial.println(Y); pen_down(); draw_arc_cw(X, Y, I, J); } // ---

// G03 counter-clockwise arc with pen_down // ---

if (INPUT_STRING.startsWith("G03")) {

// --- extract X

START = INPUT_STRING.indexOf('X'); if (!(START < 0)) {

FINISH = INPUT_STRING.indexOf('.', INPUT_STRING.indexOf('X')); SUB_STRING = INPUT_STRING.substring(START + 1, FINISH + 7); X = SUB_STRING.toFloat();

// --- extract Y

START = INPUT_STRING.indexOf('Y'); if (!(START < 0)) {

FINISH = INPUT_STRING.indexOf('.', INPUT_STRING.indexOf('Y')); SUB_STRING = INPUT_STRING.substring(START + 1, FINISH + 7); Y = SUB_STRING.toFloat();

}

// --- extract I

START = INPUT_STRING.indexOf('I'); if (!(START < 0)) {

FINISH = INPUT_STRING.indexOf('.', INPUT_STRING.indexOf('I')); SUB_STRING = INPUT_STRING.substring(START + 1, FINISH + 7); I = SUB_STRING.toFloat();

}

// --- extract J

START = INPUT_STRING.indexOf('J'); if (!(START < 0)) {

FINISH = INPUT_STRING.indexOf('.', INPUT_STRING.indexOf('J')); SUB_STRING = INPUT_STRING.substring(START + 1, FINISH + 7); J = SUB_STRING.toFloat(); } Serial.println(F("")); Serial.print(X); Serial.print("<-X Y->"); Serial.println(Y); pen_down(); draw_arc_ccw(X, Y, I, J); } // --- // MENU // ---

if (INPUT_STRING.startsWith("MENU")) { menu();

}

// --- // T1 position the pen over 0,0 // ---

if (INPUT_STRING.startsWith("T1")) {

// --- variables

int step; //loop counter

int steps = MOTOR_STEPS; //steps motor is to rotate

// --- instructions Serial.println(F(""));

Serial.println(F(" ---")); Serial.println(F(" Position the pen over the 0,0 co-ordinate:")); Serial.println(F(" ---")); Serial.println(F(" X-axis: Y-axis:"));

Serial.println(F(" 'A' 'S' 'K' 'L'")); Serial.println(F(" <- -> <- ->")); Serial.println(F(" Exit = 'E'"));

// --- flush the buffer

while (Serial.available() > 0) Serial.read();

// --- control motors with 'A', 'S', 'K', and 'L' keys

char keystroke = ' ';

while (keystroke != 'E') { //press 'E' key to exit

// --- check for keypress if (Serial.available() > 0) {

keystroke = (char) Serial.read(); } // --- select task switch (keystroke) { case 'a': case 'A': { // --- rotate motor1 CW Serial.println(F(" "));

Serial.println(F(" --- rotate motor1 CW ")); // for (step = 0; step < steps; step++) { // step1_cw();

// }

for (step = 0; step < 2; step++) { step1_cw();

}

keystroke = ' '; //otherwise motor will continue to rotate break; } case 's': case 'S': { // --- rotate motor1 CCW Serial.println(F(" "));

Serial.println(F(" --- rotate motor1 CCW ")); // for (step = 0; step < steps; step++) {

// step1_ccw(); // }

for (step = 0; step < 2; step++) { step1_ccw();

}

keystroke = ' '; break;

case 'k': case 'K': {

// --- rotate motor2 CW Serial.println(F(" "));

Serial.println(F(" --- rotate motor2 CW ")); // for (step = 0; step < steps; step++) {

// step2_cw(); // }

for (step = 0; step < 2; step++) { step2_cw(); } keystroke = ' '; break; } case 'l': case 'L': { // --- rotate motor2 CCW Serial.println(F(" "));

Serial.println(F(" --- rotate motor2 CCW ")); // for (step = 0; step < steps; step++) {

// step2_ccw(); // }

for (step = 0; step < 2; step++) { step2_ccw(); } keystroke = ' '; break; } case 'e': case 'E': { // --- exit Serial.println(F(" "));

keystroke = 'E'; break;

}

// --- default for keystroke default: {

break; } } }

// --- initialise counters for co-ordinate (0,0)

calculate_steps(0, 0); //initialise STEPS1, STEPS2 THIS_X = 0; //current X co-ordinate

THIS_Y = 0; //current Y co-ordinate LAST_X = 0; //previous X co-ordinate LAST_Y = 0; //previous Y-co-ordinate }

// --- // T2 set scale factor

// --- if (INPUT_STRING.startsWith("T2")) { Serial.println("T2"); START = INPUT_STRING.indexOf('S'); if (!(START < 0)) { FINISH = START + 6;

SUB_STRING = INPUT_STRING.substring(START + 1, FINISH); SCALE_FACTOR = SUB_STRING.toFloat();

Serial.print(F("Drawing now ")); Serial.print(SCALE_FACTOR * 100); Serial.println(F("%"));

} else {

Serial.println(F("Invalid scale factor ... try again. (1 = 100%)")); }

}

void calculate_steps(float x, float y) {

// --- locals float

distance1, //pen distance to motor1 distance2, //pen distance to motor2 angle1, //motor1 angle

angle2; //motor2 angle

// --- calculate distances

distance1 = sqrt((OFFSET1 - x) * (OFFSET1 - x) + (YAXIS - y) * (YAXIS - y)); distance2 = sqrt((OFFSET2 - x) * (OFFSET2 - x) + (YAXIS - y) * (YAXIS - y));

// --- calculate motor1 angle when pen at (x,y) if (x > OFFSET1) {

angle1 = PI + acos(distance1 / (2 * LENGTH)) - atan((x - OFFSET1) / (YAXIS - y)); //radians

} else {

angle1 = PI + acos(distance1 / (2 * LENGTH)) + atan((OFFSET1 - x) / (YAXIS - y)); //radians

}

// --- calculate motor2 angle when pen at start position (0,0) if (x > OFFSET2) {

angle2 = PI - acos(distance2 / (2 * LENGTH)) - atan((x - OFFSET2) / (YAXIS - y)); //radians

angle2 = PI - acos(distance2 / (2 * LENGTH)) + atan((OFFSET2 - x) / (YAXIS - y)); //radians } angleX = (angle1*RAD_TO_DEG); angleY = (angle2*RAD_TO_DEG); }

Dokumen terkait