工業製造
産業用モノのインターネット | 工業材料 | 機器のメンテナンスと修理 | 産業プログラミング |
home  MfgRobots >> 工業製造 >  >> Manufacturing Technology >> 製造プロセス

ジャンクDVDドライブで作るミニCNC 2Dプロッター - L293Dシールド使用

必要な部品と材料

使用するソフトウェア

製作手順

1. DVDドライブの分解と軸の取り出し

DVDドライブから可動トレイ (ステッピングモーター付きレール) を2セット取り出し、それぞれX軸・Y軸として使用します。空きケースにネジ止めし、直角に配置。

ジャンクDVDドライブで作るミニCNC 2Dプロッター - L293Dシールド使用

2. ソフトウェア準備

  1. Arduino IDE、Processing IDEをインストール。
  2. Arduinoスケッチ (後述) を書き込み。
  3. Processingスケッチ (後述) を開く。
  4. Inkscape 0.48.5をインストールし、G-code出力アドオンを導入 (インストール手順は同梱README参照)。

3. G-code作成と送信

  1. Inkscapeで図形を描き、拡張機能 → G-code出力で .gcode ファイル生成。
  2. Processingを実行 (再生ボタン)。
  3. キー操作:
    • p: シリアルポート選択
    • 1/2/3: ジョグ速度切替
    • g: G-codeファイル選択
    • Enter: 描画開始

サンプルG-codeファイル

ジャンクDVDドライブで作るミニCNC 2Dプロッター - L293Dシールド使用
ジャンクDVDドライブで作るミニCNC 2Dプロッター - L293Dシールド使用
ジャンクDVDドライブで作るミニCNC 2Dプロッター - L293Dシールド使用
ジャンクDVDドライブで作るミニCNC 2Dプロッター - L293Dシールド使用
ジャンクDVDドライブで作るミニCNC 2Dプロッター - L293Dシールド使用
ジャンクDVDドライブで作るミニCNC 2Dプロッター - L293Dシールド使用
ジャンクDVDドライブで作るミニCNC 2Dプロッター - L293Dシールド使用

Arduinoスケッチ (G-codeインタープリター)

#include <Servo.h>
#include <AFMotor.h>
#define LINE_BUFFER_LENGTH 512
char STEP = MICROSTEP;

const int penZUp = 95, penZDown = 83;
const int penServoPin = 10;
const int stepsPerRevolution = 48;

Servo penServo;
AF_Stepper myStepperY(stepsPerRevolution, 1);
AF_Stepper myStepperX(stepsPerRevolution, 2);

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

float StepInc = 1;
int StepDelay = 0, LineDelay = 0, penDelay = 50;
float StepsPerMillimeterX = 100.0, StepsPerMillimeterY = 100.0;
float Xmin = 0, Xmax = 40, Ymin = 0, Ymax = 40, Zmin = 0, Zmax = 1;
float Xpos = Xmin, Ypos = Ymin, Zpos = Zmax;
boolean verbose = false;

void setup() {
  Serial.begin(9600);
  penServo.attach(penServoPin);
  penServo.write(penZUp); delay(100);
  myStepperX.setSpeed(600); myStepperY.setSpeed(600);
  Serial.println("Mini CNC Plotter alive and kicking!");
  Serial.print("X range: "); Serial.print(Xmin); Serial.print(" to "); Serial.print(Xmax); Serial.println(" mm.");
  Serial.print("Y range: "); Serial.print(Ymin); Serial.print(" to "); Serial.print(Ymax); Serial.println(" mm.");
}

void loop() {
  // シリアルから1行読み取り、processIncomingLine()で解析実行
  // G0/G1: 移動 (Bresenhamアルゴリズム)
  // M300 S30: ペン下ろし, S50: ペン上げ
  // M114: 現在位置報告
  // その他コマンドは無視
}

void drawLine(float x1, float y1) {
  // 範囲クリップ → ステップ変換 → Bresenhamで2軸同時駆動
}

void penUp() { penServo.write(penZUp); delay(penDelay); Zpos=Zmax; }
void penDown() { penServo.write(penZDown); delay(penDelay); Zpos=Zmin; }

Processingスケッチ (G-codeストリーマー)

import processing.serial.*;
Serial port = null;
String portname = null;
boolean streaming = false;
float speed = 0.001;
String[] gcode; int i = 0;

void setup() { size(500,250); openSerialPort(); }
void draw() { /* 操作ヘルプ表示 */ }

void keyPressed() {
  // ジョグ移動 (矢印キー, PgUp/PgDn)
  // h: ホーム, 0: ゼロ点設定, $: 設定表示
  // g: ファイル選択→ストリーミング開始, x: 停止
}

void stream() {
  while (streaming) {
    if (i == gcode.length) { streaming = false; return; }
    if (gcode[i].trim().length() == 0) { i++; continue; }
    println(gcode[i]);
    port.write(gcode[i] + '\n');
    i++;
  }
}

void serialEvent(Serial p) {
  String s = p.readStringUntil('\n');
  println(s.trim());
  if (s.trim().startsWith("ok") || s.trim().startsWith("error")) stream();
}

回路図

ジャンクDVDドライブで作るミニCNC 2Dプロッター - L293Dシールド使用

L293DシールドをArduinoにスタックし、X/YステッパーをM1/M2ポート、サーボをピン10に接続。電源はUSBまたは外部5V。

製造プロセス

  1. 自宅で作るDIY宿題自動筆記マシン:AxiDraw風ペンプロッターの自作ガイド
  2. Arduinoで作るモニター用Ambilightシステム:没入感アップの自作ガイド
  3. Arduino Unoベースの人間検知レスキューロボット:センサー統合ステップバイステップ
  4. Android加速度センサーで操作するラジコン車両:Raspberry Pi・Arduino・モーターシールド連携
  5. Arduinoで作るパンチングキーボードボタン:ストレス解消カスタムキー
  6. Arduinoで地球の質量を測定:ステップバイステップDIYガイド
  7. PHPベースのWebインターフェースでArduino Unoを制御する構築ガイド
  8. Arduinoで楽器演奏:音階生成のステップバイステップガイド
  9. Arduinoと超音波センサーで自動ドアを制御:LCD・ブザー付き完全ガイド
  10. Bluetooth制御Arduinoカー完全自作ガイド – 3Dプリント&Arduino Nanoで作る2輪ロボット
  11. ArduinoとProcessingで作るリアルタイムデジタルコンパス