元高専生のロボット作り

元高専生のロボット作り

主にプログラミング, 電子系について書きます。たまに機械系もやります。メモ代わりの記事ばっか書きます

3DプリンタのGコード編集

私はAnycubic Kosselという3Dプリンタを使用しています。

この3Dプリンタのために、制御ソフトのうちPronterfaceというソフトを使用しています。

PronterfaceはGコードを読み込んで制御します。

また、Gコード作成のためにCuraというソフトを使用しています。

で、今回は3Dプリンタで印刷中にちょっとモデルの形状を変えたいなというときの小技です。

Gコードの編集

まず、CuraでGコードを作成すると以下のような感じの.gcodeファイルが出力されます。

M190 S70.000000
M109 S185.000000
;Sliced at: Sat 01-06-2019 14:18:39
;Basic settings: Layer height: 0.2 Walls: 1 Fill: 5
;Print time: 2 hours 55 minutes
;Filament used: 15.35m 45.0g
;Filament cost: None
;M190 S70 ;Uncomment to add your own bed temperature line
;M109 S185 ;Uncomment to add your own temperature line
G21        ;metric values
G90        ;absolute positioning
M82        ;set extruder to absolute mode
M107       ;start with the fan off
G28 X0 Y0  ;move X/Y to min endstops
G28 Z0     ;move Z to min endstops
G1 Z15.0 F7800 ;move the platform down 15mm
G92 E0                  ;zero the extruded length
G1 F200 E3              ;extrude 3mm of feed stock
G92 E0                  ;zero the extruded length again
G1 F7800
;Put printing message on LCD screen
M117 Printing...

;Layer count: 250
;LAYER:0
M107
G0 F7800 X58.250 Y58.250 Z0.300
;TYPE:SKIRT
G1 F1200 X-58.250 Y58.250 E7.26526
G1 X-58.250 Y-58.250 E14.53052
G1 X58.250 Y-58.250 E21.79578
G1 X58.250 Y58.250 E29.06104
G1 F3000 E24.06104
G0 F7800 X54.250 Y54.250
;TYPE:WALL-INNER
G1 F3000 E29.06104
G1 F1200 X-54.250 Y54.250 E35.82740
G1 X-54.250 Y-54.250 E42.59376
・
・
・
;LAYER:1
M106 S255
G0 F7800 X-54.250 Y54.250 Z0.500
;TYPE:WALL-INNER
G1 F1620 X-54.250 Y-54.250 E1533.79380
G1 X54.250 Y-54.250 E1538.30471
・
・
・

・
・
・
G0 F7800 X52.306 Y-54.074
G1 F3000 X51.924 Y-53.692 E3933.01334
M107
G1 F3000 E3928.01334
G0 F7800 X51.924 Y-53.692 Z55.000
;End GCode
M104 S0                     ;extruder heater off
M140 S0                     ;heated bed heater off (if you have it)
G91                                    ;relative positioning
G1 E-1 F300                            ;retract the filament a bit before lifting the nozzle, to release some of the pressure
G1 Z+0.5 E-5 X-20 Y-20 F7800 ;move Z up a bit and retract filament even more
G28 X0 Y0                              ;move X/Y to min endstops, so the head is out of the way
M84                         ;steppers off
G90                         ;absolute positioning


Z座標が変わるごとに;LAYER:1とかコメントが挟んであるのでわかりやすいです。

モデルのある高さから上を作り変えたい場合は、対応したZ座標を探して、そこから上のコードをすべて削除してください。

Gコードの編集はこれだけです。

Pronterfaceでの操作

Pronterfaceでは、3Dプリンタが上記で設定した高さまで到達したらPauseボタンを押して待機させてください。

そしたら、すぐにLoad Fileボタンから編集したGコードを読み込ましてください。

これで、Printボタンを押せば、編集したGコードの高さから印刷を開始してくれます。

Pauseボタンで待機しているだけなので、ヒーターの設定とかは必要ないです。