Arduino Mini CNC: 8 étapes (avec photos)

Arduino Mini CNC: 8 étapes (avec photos)

Table des matières:

Anonim

Bonjour, Dans ce projet, nous allons parler de la possibilité de recycler les lecteurs de DVD et de cd-rom corrompus et de produire du cnc à faible coût. Commençons à construire le projet mini cnc qui dessine

Provisions:

Étape 1: matériaux

  1. Arduino (peut être nano, uno ou méga)
  2. DVD ou CD-ROM endommagé (le moteur pas à pas fonctionnera à l'intérieur)
  3. 2 morceaux de DVD ou de CD-ROM endommagés (le moteur pas à pas à l'intérieur fonctionnera)
  4. Servo moteur (Mg90 suffit)
  5. 5v 2 amp batterie ou adaptateur
  6. Plaque Plexi de 20 x 16 cm et 5 mm d'épaisseur pour maintenir l'axe X.
  7. Plaque Plexi 15 x 16 cm et épaisseur 5 mm pour fixer l'axe Y
  8. Vous pouvez utiliser une plaque de plexiglas de 75 × 75 mm et une épaisseur de 5 mm pour la surface de dessin.
  9. 1 pièce écrou M5 (pour fixer la plaque)
  10. 14 pièces écrou M4

Étape 2: Aperçu avant et arrière du mini-cnc et explications de ses composants

  1. Plaque Plexi Plan X (200x150x3 mm)
  2. Plaque Plexi en Y (200x150x3 mm)
  3. Mécanisme de déplacement sur l'axe X (mécanisme de lecteur de DVD)
  4. Mécanisme de mouvement d'axe Y (mécanisme de lecteur DVD)
  5. Section du plan Z
  6. Servomoteur
  7. Porte-stylo
  8. Écrou de fixation du stylet - disposition des vis (1 pièce écrou M5)
  9. Stylo
  10. Table à dessin (plateau en plexi de 75x75x5 mm)
  11. Supports d'axe et écrous à vis
  12. Moteur pas à pas pour le mouvement de l'axe X
  13. Moteur pas à pas pour le mouvement de l'axe Y
  14. Trombones pour sécuriser le papier
  15. 14 pièces écrou M4
  16. Support de stylo
  17. Axe z
  18. Câbles
  19. 4 angles
  20. L'unité de contrôle (Arduino uno, 2 l239d, pertinaks, prise d'entrée d'énergie)
  21. Câble USB pour la connexion à l'ordinateur

Étape 3: partie mécanique

Nous utiliserons la pièce avec la pièce mécanique DVD ou le système de rails à l’intérieur du lecteur Cd-R0m.Dans cette section, le moteur pas à pas est connecté à l’arbre de la vis sans fin et déplace la partie du lecteur laser qui est connectée à l’arbre en tournant le manche. Nous supprimons cette partie sans dommage. De la même manière, l'autre pilote est également démonté et deux systèmes de moteur pas à pas sont installés. Si vous utilisez un DVD-Rom, vous pouvez également réaliser un découpeur laser avec ses diodes laser. Ce sont les pièces mécaniques qui déplacent les axes. Nous allons extraire d'autres pièces mécaniques de l'imprimante 3D.

Vous pouvez télécharger les fichiers stl de pièces ici >>

Étape 4: Section électronique

Dans notre système électronique, nous connecterons les deux moteurs pas à pas qui déplaceront les axes x et y et un servomoteur qui lèvera et baissera la matrice.

Étape 5: Partie de code Arduino

#comprendre

#comprendre

#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;

float y_adim_mm = 6.0;

struct point {float x; float y; float z; };

struct point actuatorPos;

float StepInc = 1;

int StepDelay = 0;

int LineDelay = 50;

int penDelay = 50;

float Xmin = 0;

float Xmax = 40;

float Ymin = 0;

float Ymax = 40;

float Zmin = 0;

float Zmax = 1;

float Xpos = Xmin;

float Ypos = Ymin;

float Zpos = Zmax;

booléen verbose = false;

void setup () {// Configuration

Serial.begin (9600);

kalem_servo.attach (kalem_servo_pin);

kalem_servo.write (kalem_kaldir);

délai (200);

x_ekseni.setSpeed ​​(hareket_hizi);

y_ekseni.setSpeed ​​(hareket_hizi);

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

Serial.print ("X min");

Serial.print (Xmin);

Serial.print ("den");

Serial.print (Xmax);

Serial.println ("mm.");

Serial.print ("Y min");

Serial.print (Ymin);

Serial.print ("den");

Serial.print (Ymax);

Serial.println ("mm.");

}

boucle vide () {

délai (200);

ligne de caractères LINE_BUFFER_LENGTH;

char c; int lineIndex;

bool lineIsComment, lineSemiColon;

lineIndex = 0;

lineSemiColon = false;

lineIsComment = false;

tandis que (1) {

while (Serial.available ()> 0) {

c = Serial.read ();

if ((c == ' n') || (c == ' r')) {

if (lineIndex> 0) {

line lineIndex = ' 0';

si (verbeux) {

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

Serial.println (ligne);

}

processIncomingLine (line, lineIndex);

lineIndex = 0; }

autre {

// Ligne vide ou commentaire. Passer le bloc.

}

lineIsComment = false;

lineSemiColon = false;

Serial.println ("ok");

}

autre {

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

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

} autre {

si (c <= '') {

}

sinon si (c == '/') {

}

sinon si (c == '(') {

lineIsComment = true;

}

sinon si (c == ';') {

lineSemiColon = true;

}

else if (lineIndex> = LINE_BUFFER_LENGTH-1) {

Serial.println ("Yazma Hatası");

lineIsComment = false;

lineSemiColon = false;

} sinon si (c> = 'a' && c <= 'z') {

line lineIndex ++ = c-'a '+' A ';

} autre {

line lineIndex ++ = c; }}}}}}

void processIncomingLine (char * line, int charNB) {

int currentIndex = 0; tampon de chars 64;

struct point newPos;

newPos.x = 0.0;

newPos.y = 0.0;

while (currentIndex <charNB) {

commutateur (ligne currentIndex ++) {

cas 'U':

penUp ();

Pause;

cas 'D':

penDown ();

Pause;

cas 'G':

tampon 0 = ligne currentIndex ++;

tampon 1 = ' 0';

commutateur (atoi (tampon)) {

cas 0:

cas 1:

char * indexX = strchr (line + currentIndex, 'X');

char * indexY = strchr (line + currentIndex, 'Y');

si (indexY <= 0) {

newPos.x = atof (indexX + 1);

newPos.y = actuatorPos.y;

} sinon si (indexX <= 0) {

newPos.y = atof (indexY + 1);

newPos.x = actuatorPos.x; }

else {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;

Pause; }

Pause; cas 'M':

tampon 0 = ligne currentIndex ++;

tampon 1 = ligne currentIndex ++;

tampon 2 = ligne currentIndex ++;

tampon 3 = ' 0'; commutateur (atoi (tampon)) {

cas 300: {char * indexS = strchr (line + currentIndex, 'S');

float Spos = atof (indexS + 1);

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

} if (Spos == 50) {

penUp (); } Pause;

} cas 114:

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

Serial.print (actuatorPos.x);

Serial.print ("- Y =");

Serial.println (actuatorPos.y);

Pause; défaut:

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

Serial.println (tampon); }}}

}

void drawLine (float x1, float y1) {

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

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

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

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

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

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

si (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; float y0 = Ypos; long dx = abs (x1-x0); long dy = abs (y1-y0); int sx = x0

long i; long over = 0;

si (dx> dy) {pour (i = 0; i = dx) {plus = = dx; y_ekseni.step (sy); }

délai (StepDelay); }} else {for (i = 0; i = dy) {over = = dy; x_ekseni.step (sx); } delay (StepDelay); }}

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

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

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

délai (LineDelay);

Xpos = x1; Ypos = y1; }

void penUp () {kalem_servo.write (kalem_kaldir); délai (LineDelay);

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

void penDown () {kalem_servo.write (kalem_indir);

délai (LineDelay); Zpos = Zmin; si (verbeux) {

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

Étape 6: Code de traitement

importer java.awt.event.KeyEvent;

import javax.swing.JOptionPane;

import processing.serial. *;

Port série = null;

String portname = null;

diffusion booléenne = false;

vitesse de flottement = 0,001;

String gcode; int i = 0;

void openSerialPort () {

if (nom du port == null) return;

if (port! = null) port.stop (); port = new Serial (this, nom du port, 9600); port.bufferUntil (' n'); }

void selectSerialPort () {

String result = (String) JOptionPane.showInputDialog (cadre, "Sélectionnez le port série correspondant à votre carte Arduino.", "Serial port seç", JOptionPane.QUESTION_MESSAGE, null, Serial.list (), 0);

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

void setup () {taille (500, 250); openSerialPort (); }

void draw () {background (0);

remplir (255); int y = 24, dy = 12; text ("Menuler", 12, y);

y + = dy; text ("p: serial port seç", 12, y); y + = dy;

text ("1: hız 0,001 inch", 12, y); y + = dy; text ("2: hız 0,010 inch", 12, y); y + = dy;

texte ("3: hız 0,100 pouce", 12, y); y + = dy; texte ("Yön Tuşları: x-y Düzlemi", 12, y);

y + = dy; texte ("Sayfa aşağı-yukarı: z eksen", 12, y); y + = dy;

text ("$: grbl ayarlar", 12, y); y + = dy; text ("h: Başlangıç ​​Konumu", 12, y); y + = dy;

texte ("0: Güncel Konum", 12, y); y + = dy; text ("g: code g dosya seç", 12, y);

y + = dy; text ("x: Çizimi Durdur", 12, y); y + = dy; y = hauteur - dy;

text ("güncel hız:" + speed + "adım", 12, y); y - = dy;

text ("port série güncel:" + nom du port, 12, y); y - = dy; }

void keyPressed () {if (key == '1') speed = 0.001; si (clé == '2') vitesse = 0,01;

si (clé == '3') vitesse = 0,1; si (! streaming) {

if (code clé == GAUCHE) port.write ("G91 nG20 nG00 X-" + vitesse + "Y0.000 Z0.000 n");

if (code de clé == DROITE) port.write ("G91 nG20 nG00 X" + vitesse + "Y0.000 Z0.000 n");

if (code de clé == UP) port.write ("G91 nG20 nG00 X0.000 Y" + vitesse + "Z0.000 n");

if (code de clé == BAS) port.écrire ("G91 nG20 nG00 X0.000 Y-" + vitesse + "Z0.000 n");

if (keyCode == KeyEvent.VK_PAGE_UP) port.write ("G91 nG20 nG00 X0.000 Y0.000 Z" + vitesse + " n");

if (keyCode == KeyEvent.VK_PAGE_DOWN) port.write ("G91 nG20 nG00 X0.000 Y0.000 Z-" + vitesse + " n");

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

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

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

if (! streaming && key == 'g') {gcode = null; i = 0; Fichier fichier = null; println ("Chargement du fichier …"); selectInput ("Sélectionnez un fichier à traiter:", "fichier_sélectionné", fichier); } if (clé == 'x') streaming = false; }

void fileSelected (sélection de fichier) {if (selection == null) {println ("La fenêtre a été fermée ou l'utilisateur a appuyé sur annuler."); }

else {println ("Utilisateur sélectionné" + selection.getAbsolutePath ());

gcode = loadStrings (selection.getAbsolutePath ()); if (gcode == null) return;

streaming = true; courant(); }}

void stream () {if (! streaming) return; while (true) {if (i == gcode.length) {

streaming = false; revenir; } if (gcode i.trim (). length () == 0) i ++; sinon pause }

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

void serialEvent (série p) {chaîne s = p.readStringUntil (' n'); println (s.trim ());

if (s.trim (). startsWith ("ok")) stream ();

if (s.trim (). startsWith ("erreur")) stream (); // XXX: vraiment? }

Étape 7: Paramètres d'encrage

Pour obtenir la sortie gccode avec INKSCAPE, commencez par télécharger le plug-in G-code de makerbot unicorn ici >> Inkcape plug-in gcode

Configuration complète et détails du projet >> Projet Arduino cnc

Étape 8: Merci de voter sur le projet:)

J'ai participé au concours du concours de conception CNC et 3D 2016. J'attends votre vote. Vous pouvez voter en cliquant sur le bouton "vote" en haut à droite. Merci d'avance:)