Arduino Mini CNC: 8 ขั้นตอน (พร้อมรูปภาพ)

Arduino Mini CNC: 8 ขั้นตอน (พร้อมรูปภาพ)

สารบัญ:

Anonim

สวัสดีเพื่อน ๆ ในโครงการนี้เราจะพูดถึงการทำไดรฟ์ DVD และ cd-rom ที่เสียหายแล้วนำกลับมาใช้ใหม่และผลิต cnc ในราคาที่ต่ำ เรามาเริ่มสร้างโปรเจ็กต์ขนาดเล็กที่ดึงดูด

วัสดุ:

ขั้นตอนที่ 1: วัสดุ

  1. Arduino (สามารถเป็นนาโน uno หรือ mega)
  2. ดีวีดีหรือซีดีรอมที่เสียหาย (ตัวสเต็ปเปอร์มอเตอร์จะทำงาน)
  3. dvd หรือ cd-rom ที่เสียหาย 2 ชิ้น (สเต็ปเปอร์มอเตอร์ภายในทำงาน)
  4. เซอร์โวมอเตอร์ (Mg90 ก็เพียงพอแล้ว)
  5. แบตเตอรี่หรืออะแดปเตอร์ 5v 2 แอมป์
  6. แผ่น Plexi ที่มีความหนา 20 x 16 ซม. และ 5 มม. เพื่อยึดแกน X
  7. แผ่น Plexi ขนาด 15 x 16 ซม. และความหนา 5 มม. เพื่อยึดแกน Y
  8. คุณสามารถใช้แผ่น plexi ขนาด 75 × 75 มม. และความหนา 5 มม. สำหรับพื้นผิวการวาด
  9. น็อตน๊อต M5 1 ชิ้น (เพื่อซ่อมแผ่น)
  10. น็อตน๊อต M4 14 ชิ้น

ขั้นตอนที่ 2: ภาพรวมด้านหน้าและด้านหลังของ Mini Cnc และคำอธิบายของชิ้นส่วน

  1. เพลท X plane Plexi (200x150x3 มม.)
  2. เพลเพลล็กต์ Y สำหรับเครื่องบิน (200x150x3 มม.)
  3. กลไกการเคลื่อนที่ในแนวแกน X (กลไกการเคลื่อนที่ของไดรฟ์ดีวีดี)
  4. กลไกการเคลื่อนที่แกน Y (กลไกการเคลื่อนที่ของไดรฟ์ดีวีดี)
  5. ส่วนเครื่องบิน Z
  6. เซอร์โวมอเตอร์
  7. ที่ใส่ปากกา
  8. น็อตยึดปากกา - การจัดสกรู (น็อตน็อต M5 หนึ่งชิ้น)
  9. ปากกา
  10. โต๊ะเขียนแบบ (จานขนาดเล็ก 75x75x5 มม.)
  11. แกนรองรับและสกรูน็อต
  12. สเต็ปปิ้งมอเตอร์สำหรับการเคลื่อนที่ในแนวแกน X
  13. สเต็ปปิ้งมอเตอร์สำหรับการเคลื่อนที่แกน Y
  14. คลิปหนีบกระดาษเพื่อยึดกระดาษ
  15. น็อตน๊อต M4 14 ชิ้น
  16. รองรับที่ใส่ปากกา
  17. แกน Z
  18. สายเคเบิ้ล
  19. 4 มุม
  20. ชุดควบคุม (Arduino uno, 2 l239d, pertinaks, แจ็คอินพุตพลังงาน)
  21. สาย USB สำหรับเชื่อมต่อคอมพิวเตอร์

ขั้นตอนที่ 3: ส่วนเครื่องกล

เราจะใช้ชิ้นส่วนกับ DVD ชิ้นส่วนเชิงกลหรือระบบรางภายในไดรฟ์ Cd-R0m ในส่วนนี้จะมีการเชื่อมต่อกับสเต็ปเปอร์มอเตอร์กับเพลาสกรูหนอนและย้ายส่วนของเครื่องอ่านเลเซอร์ที่เชื่อมต่อกับเพลาด้วยการหมุน เพลา เรากำลังลบส่วนนี้โดยไม่มีอันตราย ในทำนองเดียวกันไดรเวอร์อื่น ๆ ก็ถูกถอดแยกชิ้นส่วนและติดตั้งระบบสเต็ปเปอร์มอเตอร์ทั้งหมดสองตัว หากคุณใช้ DVD-Rom คุณสามารถสร้างเครื่องตัดเลเซอร์ด้วยเลเซอร์ไดโอด เหล่านี้เป็นชิ้นส่วนเครื่องจักรกลที่เคลื่อนย้ายแกน เราจะแยกส่วนเครื่องจักรกลอื่น ๆ จากเครื่องพิมพ์ 3d

คุณสามารถดาวน์โหลดไฟล์ stl ได้ที่นี่ >>

ขั้นตอนที่ 4: ส่วนอิเล็กทรอนิกส์

ในระบบอิเล็กทรอนิกส์ของเราเราจะเชื่อมต่อสเต็ปเปอร์มอเตอร์สองตัวซึ่งจะย้ายแกน x และ y และเซอร์โวมอเตอร์หนึ่งตัวที่จะยกและลดดาย

ขั้นตอนที่ 5: ส่วนรหัส Arduino

#include

#include

#define LINE_BUFFER_LENGTH 512

const int kalem_kaldir = 130;

const int kalem_indir = 40;

const int kalem_servo_pin = 12;

const int adim_sayisi = 20;

const int hareket_hizi = 250;

Servo kalem_servo;

Stepper y_ekseni (adim_sayisi, 3,4,5,6);

Stepper x_ekseni (adim_sayisi, 9,10,11,12);

float x_adim_mm = 6.0;

ลอย y_adim_mm = 6.0;

จุด struct {ลอย x; ลอย y; ลอย z; };

struct point actuatorPos;

ลอย StepInc = 1;

int StepDelay = 0;

int LineDelay = 50;

int penDelay = 50;

float Xmin = 0;

Xmax ลอย = 40;

ลอย Ymin = 0;

ลอย Ymax = 40;

float Zmin = 0;

Zmax ลอย = 1;

Xpos ลอย = Xmin;

Ypos ลอย = Ymin;

Zpos ลอย = Zmax;

บูลีน verbose = false;

การตั้งค่าเป็นโมฆะ () {// การตั้งค่า

Serial.begin (9600);

kalem_servo.attach (kalem_servo_pin);

kalem_servo.write (kalem_kaldir);

ล่าช้า (200);

x_ekseni.setSpeed ​​(hareket_hizi);

y_ekseni.setSpeed ​​(hareket_hizi);

Serial.println ("Çizim Yapan Mini CNC!");

Serial.print ("X นาที");

Serial.print (Xmin);

Serial.print ("den");

Serial.print (xmax);

Serial.println ("mm.");

Serial.print ("Y นาที");

Serial.print (ymin);

Serial.print ("den");

Serial.print (ymax);

Serial.println ("mm.");

}

void loop () {

ล่าช้า (200);

char line LINE_BUFFER_LENGTH;

ถ่านค; int lineIndex;

บูล lineIsComment, lineSemiColon;

lineIndex = 0;

lineSemiColon = false;

lineIsComment = false;

ในขณะที่ (1) {

ในขณะที่ (Serial.available ()> 0) {

c = Serial.read ();

ถ้า ((c == ' n') || (c == ' r')) {

if (lineIndex> 0) {

line lineIndex = ' 0';

ถ้า (verbose) {

Serial.print ("Alıcı:");

Serial.println (บรรทัด);

}

processIncomingLine (บรรทัด lineIndex);

lineIndex = 0; }

อื่น {

// ว่างหรือบรรทัดความคิดเห็น ข้ามบล็อก

}

lineIsComment = false;

lineSemiColon = false;

Serial.println ("ok");

}

อื่น {

if ((lineIsComment) || (lineSemiColon)) {

if (c == ')') lineIsComment = false;

} อื่น {

ถ้า (c <= '') {

}

อื่นถ้า (c == '/') {

}

อื่นถ้า (c == '(') {

lineIsComment = true;

}

อื่นถ้า (c == ';') {

lineSemiColon = จริง

}

อื่นถ้า (lineIndex> = LINE_BUFFER_LENGTH-1) {

Serial.println ("Yazma Hatası");

lineIsComment = false;

lineSemiColon = false;

} อื่นถ้า (c> = 'a' && c <= 'z') {

บรรทัด lineIndex ++ = c-'a '+' A ';

} อื่น {

สาย lineIndex ++ = c; }}}}}}

ถือเป็นโมฆะ processIncomingLine (บรรทัด char *, int charNB) {

int currentIndex = 0; ถ่านบัฟเฟอร์ 64;

struct point newPos;

newPos.x = 0.0;

newPos.y = 0.0;

ในขณะที่ (currentIndex <charNB) {

สวิตช์ (บรรทัด currentIndex ++) {

กรณี 'U':

penUp ();

ทำลาย;

กรณี 'D':

penDown ();

ทำลาย;

กรณี 'G':

buffer 0 = บรรทัด currentIndex ++;

buffer 1 = ' 0';

สวิทช์ (atoi (บัฟเฟอร์)) {

กรณีที่ 0:

กรณีที่ 1:

ถ่าน * indexX = strchr (บรรทัด + currentIndex, 'X');

ถ่าน * indexY = strchr (บรรทัด + currentIndex, 'Y');

if (indexY <= 0) {

newPos.x = atof (indexX + 1);

newPos.y = actuatorPos.y;

} อื่น ๆ ถ้า (indexX <= 0) {

newPos.y = atof (indexY + 1);

newPos.x = actuatorPos.x; }

อื่น {newPos.y = atof (indexY + 1);

indexY = ' 0'; newPos.x = atof (indexX + 1); }

drawLine (newPos.x, newPos.y);

// Serial.println ("ok");

actuatorPos.x = newPos.x;

actuatorPos.y = newPos.y;

ทำลาย; }

ทำลาย; กรณี 'M':

buffer 0 = บรรทัด currentIndex ++;

buffer 1 = บรรทัด currentIndex ++;

buffer 2 = บรรทัด currentIndex ++;

buffer 3 = ' 0'; สวิทช์ (atoi (บัฟเฟอร์)) {

กรณี 300: {char * indexS = strchr (บรรทัด + currentIndex, 'S');

float Spos = atof (indexS + 1);

if (Spos == 30) {penDown ();

} if (Spos == 50) {

penUp (); } พัก;

} กรณี 114:

Serial.print ("Tam Pozisyon: X =");

Serial.print (actuatorPos.x);

Serial.print ("- Y =");

Serial.println (actuatorPos.y);

ทำลาย; ค่าเริ่มต้น:

Serial.print ("Komut Tanınmadı: M");

Serial.println (บัฟเฟอร์); }}}

}

โมฆะ drawLine (ลอย x1, ลอย y1) {

if (verbose) {Serial.print ("fx1, fy1:");

Serial.print (x1); Serial.print ("");

Serial.print (y1); Serial.println (""); }

if (x1> = Xmax) {x1 = Xmax; }

if (x1 <= Xmin) {x1 = Xmin; }

if (y1> = Ymax) {y1 = Ymax; }

ถ้า (y1 <= Ymin) {y1 = Ymin; }

if (verbose) {Serial.print ("Xpos, Ypos:");

Serial.print (Xpos); Serial.print ("");

Serial.print (ypos); Serial.println (""); }

if (verbose) {Serial.print ("x1, y1:");

Serial.print (x1); Serial.print ("");

Serial.print (y1); Serial.println (""); }

x1 = (int) (x1 * x_adim_mm); y1 = (int) (y1 * y_adim_mm);

float x0 = Xpos; ลอย y0 = Ypos; ยาว dx = abs (x1-x0); ยาว dy = abs (y1-y0); int sx = x0

ยาวฉัน; นานกว่า = 0;

ถ้า (dx> dy) {สำหรับ (i = 0; i = dx) {over- = dx; y_ekseni.step (ซี่); }

ล่าช้า (StepDelay); }} else {สำหรับ (i = 0; i = dy) {over- = dy; x_ekseni.step (SX); } ล่าช้า (StepDelay); }}

if (verbose) {Serial.print ("dx, dy:"); Serial.print (DX); Serial.print ("");

Serial.print (DY); Serial.println (""); }

if (verbose) {Serial.print ("Going ("); Serial.print (x0); Serial.print (","); Serial.print (y0); Serial.println (")"); }

ล่าช้า (LineDelay);

Xpos = x1; Ypos = y1; }

ถือเป็นโมฆะ penUp () {kalem_servo.write (kalem_kaldir); ล่าช้า (LineDelay);

Zpos = Zmax; if (verbose) {Serial.println ("Pen up!"); }}

ถือเป็นโมฆะ penDown () {kalem_servo.write (kalem_indir);

ล่าช้า (LineDelay); Zpos = Zmin; ถ้า (verbose) {

Serial.println ("Pen down."); }}

ขั้นตอนที่ 6: ประมวลผลรหัส

นำเข้า java.awt.event.KeyEvent;

นำเข้า javax.swing.JOptionPane;

นำเข้าการประมวลผล.serial. *;

พอร์ตอนุกรม = null;

String portname = null;

บูลีนสตรีมมิ่ง = false;

ความเร็วลอย = 0.001;

String gcode; int i = 0;

เป็นโมฆะ openSerialPort () {

if (portname == null) ส่งคืน;

if (port! = null) port.stop (); พอร์ต = อนุกรมใหม่ (สิ่งนี้ชื่อพอร์ต, 9600); port.bufferUntil (' n'); }

ถือเป็นโมฆะ selectSerialPort () {

String result = (String) JOptionPane.showInputDialog (frame "เลือกพอร์ตอนุกรมที่สอดคล้องกับบอร์ด Arduino ของคุณ", "serial port seç", JOptionPane.QUESTION_MESSAGE, null, Serial.list (), 0);

if (result! = null) {portname = result; openSerialPort (); }}

การตั้งค่าเป็นโมฆะ () {ขนาด (500, 250); openSerialPort (); }

ถือเป็นโมฆะวาด () {background (0);

เติมเต็ม (255); int y = 24, dy = 12; ข้อความ ("Menuler", 12, y);

y + = dy; ข้อความ ("p: พอร์ตอนุกรมseç", 12, y); y + = dy;

ข้อความ ("1: hız 0.001 นิ้ว", 12, y); y + = dy; ข้อความ ("2: hız 0.010 นิ้ว", 12, y); y + = dy;

ข้อความ ("3: hız 0.100 นิ้ว", 12, y); y + = dy; ข้อความ ("YönTuşları: x-y Düzlemi", 12, y);

y + = dy; ข้อความ ("Sayfa aşağı-yukarı: z eksen", 12, y); y + = dy;

ข้อความ ("$: grbl ayarlar", 12, y); y + = dy; ข้อความ ("h: Başlangıç ​​Konumu", 12, y); y + = dy;

ข้อความ ("0: Güncel Konum", 12, y); y + = dy; ข้อความ ("g: g- รหัส dosya seç", 12, y);

y + = dy; ข้อความ ("x: Çizimi Durdur", 12, y); y + = dy; y = ความสูง - dy;

ข้อความ ("güncelhız:" + speed + "adım", 12, y); y - = dy;

ข้อความ ("พอร์ตอนุกรมgüncel:" + ชื่อพอร์ต, 12, y); y - = dy; }

ถือเป็นโมฆะ keyPressed () {ถ้า (key == '1') speed = 0.001; ถ้า (key == '2') speed = 0.01;

ถ้า (key == '3') speed = 0.1; if (! streaming) {

ถ้า (keyCode == ซ้าย) port.write ("G91 nG20 nG00 X-" + ความเร็ว + "Y0.000 Z0.000 n");

ถ้า (keyCode == RIGHT) port.write ("G91 nG20 nG00 X" + ความเร็ว + "Y0.000 Z0.000 n");

if (keyCode == UP) port.write ("G91 nG20 nG00 X0.000 Y" + ความเร็ว + "Z0.000 n");

ถ้า (keyCode == DOWN) port.write ("G91 nG20 nG00 X0.000 Y-" + ความเร็ว + "Z0.000 n");

ถ้า (keyCode == KeyEvent.VK_PAGE_UP) port.write ("G91 nG20 nG00 X0.000 Y0.000 Z" + ความเร็ว + " n");

ถ้า (keyCode == KeyEvent.VK_PAGE_DOWN) port.write ("G91 nG20 nG00 X0.000 Y0.000 Z-" + ความเร็ว + " n");

if (key == 'h') port.write ("G90 nG20 nG00 X0.000 Y0.000 Z0.000 n"); if (key == 'v') port.write ("$ 0 = 75 n $ 1 = 74 n $ 2 = 75 n"); // ถ้า (key == 'v') port.write ("$ 0 = 100 n $ 1 = 74 n $ 2 = 75 n");

if (key == 's') port.write ("$ 3 = 10 n"); if (key == 'e') port.write ("$ 16 = 1 n"); if (key == 'd') port.write ("$ 16 = 0 n");

if (key == '0') openSerialPort (); if (key == 'p') selectSerialPort (); if (key == '$') port.write ("$$ n"); }

if (! streaming && key == 'g') {gcode = null; i = 0; ไฟล์ file = null; println ("กำลังโหลดไฟล์ … "); selectInput ("เลือกไฟล์ที่จะดำเนินการ:", "fileSelected", ไฟล์); } if (key == 'x') streaming = false; }

เป็นโมฆะ fileSelected (การเลือกไฟล์) {ถ้า (selection == null) {println ("หน้าต่างถูกปิดหรือผู้ใช้กดยกเลิก"); }

อื่น {println ("ผู้ใช้ที่เลือก" + selection.getAbsolutePath ());

gcode = loadStrings (selection.getAbsolutePath ()); if (gcode == null) ส่งคืน;

สตรีมมิ่ง = จริง; กระแส(); }}

กระแสโมฆะ () {ถ้า (! สตรีม) กลับมา; ในขณะที่ (จริง) {ถ้า (i == gcode.length) {

สตรีมมิ่ง = false; กลับ; } if (gcode i.trim (). length () == 0) i ++; อื่นทำลาย }

println (GCode ผม); port.write (gcode i + ' n'); i ++; }

ถือเป็นโมฆะ serialEvent (อนุกรม p) {String s = p.readStringUntil (' n'); println (s.trim ());

ถ้า (s.trim (). startsWith ("ok")) สตรีม ();

if (s.trim ().st สตรีม ("ข้อผิดพลาด")) สตรีม (); // XXX: จริงเหรอ? }

ขั้นตอนที่ 7: การตั้งค่า INKSCAPE

ในการรับเอาต์พุต gccode ด้วย INKSCAPE ขั้นแรกให้ดาวน์โหลดปลั๊กอิน makerbot ยูนิคอร์น G-code ที่นี่ >> ปลั๊กอิน gks Inkscape

ksnkscape การตั้งค่าเต็มรูปแบบและรายละเอียดของโครงการ >> โครงการ cnc Arduino

ขั้นตอนที่ 8: ได้โปรดโหวตโครงการ:)

ฉันเข้าร่วมการแข่งขันใน CNC และ 3D Design CONTEST 2016 ฉันรอการโหวตของคุณ คุณสามารถลงคะแนนได้โดยคลิกที่ปุ่ม "โหวต" ที่ด้านบนขวาขอขอบคุณล่วงหน้า:)