G-code/ja

From RepRap
Revision as of 11:24, 20 August 2014 by Miketorii (talk | contribs) (G92: Set Position)
Jump to: navigation, search

はじめに

RepRapマシンに送信されるGCodeの例は以下のようである。

 N3 T0*57
 N4 G92 E0*67
 N5 G28*22
 N6 G1 F1500.0*82
 N7 G1 X2.0 Y2.0 F3000.0*85
 N8 G1 X3.0 Y3.0*33

上記のシンボルと数字の意味を以下に説明する。

以下は、任意のファームウェアに実装されているGCodeのサポート状況を識別するための表記である。

Support FiveD Teacup Sprinter Marlin Repetier
yes automatic yes yes experimental
yes
全ての機能をサポートしている
experimental
部分的に機能をサポートしている。
しばしば、デフォルトではなく、ソースコードブランチをチェックする事が要求される、
もしくは、特定の設定スイッチを反転させる事が必要。
automatic
ファームウェアはこの機能を自動的に処理する。つまりコマンドを送信する必要はない。
例えば、Teacupファームウェアの電源のon/off(M80/M81)がこれに相当する。
no
ファームウェアはこの機能をサポートしていない

RepRapの先頭コード

本章では、先頭の文字について説明する。nnnは数字を示す。数字は、その先頭文字の意味に応じて、整数もしくは小数を指定することができる。例えば、X座標は整数(X175)もしくは小数(X17.62)のどちらも指定可能である。一方、エクストルーダーを選択するとき、番号2.76を指定するとおかしい(普通は整数になる)。

先頭の文字 意味
Gnnn GCodeの標準コマンド (例)ある点に動く
Mnnn RepRapが定義したコマンド (例)冷却ファンのスイッチをONにする
Tnnn ツール番号nnnを選択する RepRapにおいて、ツールはエクストルーダー(Extruder)である
Snnn コマンドのパラメータ。(例)モータに送る電圧
Pnnn コマンドのパラメータ。(例)ミリ秒の時間
Xnnn 移動先のX座標
Ynnn 移動先のY座標
Znnn 移動先のZ座標
Innn パラメータ - 現在使用されていない。
Jnnn パラメータ - 現在使用されていない。
Fnnn フィード率(プリンタのヘッドが動くスピード)。1分に何mmフィードするか指定する。
Rnnn パラメータ - 温度のために使用される。
Qnnn パラメータ - 現在使用されていない。
Ennn 押出される長さ(単位mm)。押し出されるフィラメントの長さ。Skeinforge 40もしくは40以上は、押出される長さではなく、消費される入力フィラメントの長さとして、この長さを扱う。
Nnnn ライン番号。エラーが起きたときにRepeat transmission要求するために使われる。
*nnn チェックサム。通信エラーをチェックするために使用される

コメント

G Codeのコメントはセミコロン( ; )で始まる。コメントの終了は行の終わりである。

N3 T0*57 ;This is a comment
N4 G92 E0*67
; So is this
N5 G28*22

コメントはRepRapでは空白の行と解釈され、無視される。しかし、コメント行が送信される前にホストコンピュータで取り除かれる方が望ましい。コメントを取り除くと送信が、その分だけ早くなる。

コマンド

Checking

N and *

Example: N123 [...G Code in here...] *71

These are the line number and the checksum. The RepRap firmware checks the checksum against a locally-computed value and, if they differ, requests a repeat transmission of the line of the given number.

You can leave both of these out - RepRap will still work, but it won't do checking. You have to have both or neither though.

The checksum "cs" for a GCode string "cmd" (including its line number) is computed by exor-ing the bytes in the string up to and not including the * character as follows:

int cs = 0;
for(i = 0; cmd[i] != '*' && cmd[i] != NULL; i++)
   cs = cs ^ cmd[i];
cs &= 0xff;  // Defensive programming...

and the value is appended as a decimal integer to the command after the * character.

The RepRap firmware expects line numbers to increase by 1 each line, and if that doesn't happen it is flagged as an error. But you can reset the count using M110 (see below).

バッファに格納されるGコマンド

RepRapファームウェアは、内部的なリングバッファにコマンドを格納する。

The RepRap firmware stores these commands in a ring buffer internally for execution. This means that there is no (appreciable) delay while a command is acknowledged and the next transmitted. In turn, this means that sequences of line segments can be plotted without a dwell between one and the next. As soon as one of these buffered commands is received it is acknowledged and stored locally. If the local buffer is full, then the acknowledgment is delayed until space for storage in the buffer is available. This is how flow control is achieved.

G0: 即時移動(Rapid move)

Support FiveD Teacup Sprinter Marlin Repetier
 ??? yes yes yes yes

例: G0 X12

上記の例は、X = 12mmへ直ちに移動する。RepRapファームウェアは、G0とG1の区別は行わない。(G1参照) (G0とG1の違いは、軸に対して真直以外にも動作する事が可能な古い機械が、より速く移動するためにある。これらの古い機械にとって、G0は、できるだけ速く目的とする位置へ移動するために、任意の移動を行う事を許可する。)

G1: 制御移動(Controlled move)

Support FiveD Teacup Sprinter Marlin Repetier
yes yes yes yes yes

例: G1 X90.6 Y13.8 E22.4

樹脂を押出す長さを現在の長さから22.4mmに変更し、樹脂を押出しながら、現在の座標(X, Y)から(90.6, 13.8)へ真直ぐに移動する。

RepRapは、以下のようにフィード率を指定する事もできる。

G1 F1500
G1 X90.6 Y13.8 E22.4

上記の例は、フィード率を1500mm/分に指定し、そのフィード率を使用して、(90.6, 13.8)へ移動する。

一方、

G1 F1500
G1 X90.6 Y13.8 E22.4 F3000

上記の例は、一旦、フィード率を1500mm/分に指定し、その後、フィード率3000mm/分に加速しながら、(90.6, 13.8)へ移動する。押出は、X, Y方向に移動しながら加速する。つまり全ては同期する。

RepRapは、線形的に簡単に値を変更するために、フィード率を単純な変数として扱う(X, Y, ZのようにEを扱う)。

This gives complete control over accelerations and decelerations in a way that ensures that everything moves together and the right volume of material is extruded at all points.

Note: 全てのファームウェアが、この機能を実装しているわけではない。例えば、現在の Marlinは、移動の最初から新たに指定されたフィード率を使用して、フィード率の変更は行わない。

前述の最初の例は一定のスピードで移動する方法を示している。2番目の例は、加速する方法、減速する方法を示している。

G1 F1500
G1 X90.6 Y13.8 E22.4 F3000
G1 X80 Y20 E36 F1500

上記の例は、最初の移動は加速し、2番目の移動は3000mm/分から1500mm/分に減速する例である。

To reverse the extruder by a given amount (for example to reduce its internal pressure while it does an in-air movement so that it doesn't dribble) simply use G1 to send an E value that is less than the currently extruded length.

Some implementations and RepRaps allow the sensing of endstops during moves to be switched on and off. Adding an S field allows this: G1 X300 S1 will move X to 300 checking for an endstop hit and stopping if it happens. G1 X300 S0 will do the same move with no checking. The default is no checking.

G2: 時計回りの制御移動(Controlled Move Arc Clockwise)

Support FiveD Teacup Sprinter Marlin Repetier
no no no yes yes

例: G2 X90.6 Y13.8 I5 J10 E22.4

樹脂を押出す長さを現在の長さから22.4mmに変更し、樹脂を押出しながら、かつ、 中心点(5,10)から一定の距離を維持しながら、現在の位置(X, Y)から座標(90.6, 13.8)に時計回りに弧を描いて移動する。

G3: 反時計回りの制御移動(Controlled Move Arc Counter-Clockwise)

Support FiveD Teacup Sprinter Marlin Repetier
no no no yes yes

Example: G3 X90.6 Y13.8 I5 J10 E22.4

樹脂を押出す長さを現在の長さから22.4mmに変更し、樹脂を押出しながら、かつ、 中心点(5,10)から一定の距離を維持しながら、現在の位置(X, Y)から座標(90.6, 13.8)に反時計回りに弧を描いて移動する。

G28: Move to Origin

Support FiveD Teacup Sprinter Marlin Repetier
yes yes yes yes yes

Example: G28

This causes the RepRap machine to move back to its X, Y and Z zero endstops, a process known as "homing". It does so accelerating, so as to get there fast. But when it arrives it backs off by 1 mm in each direction slowly, then moves back slowly to the stop. This ensures more accurate positioning.

If you add coordinates, then just the axes with coordinates specified will be zeroed. Thus

G28 X0 Y72.3

will zero the X and Y axes, but not Z. The actual coordinate values are ignored.

G29-G32: Bed probing

G29 Detailed Z-Probe

probes the bed at 3 points.

G30 Single Z Probe

In its simplest form probes bed at current XY location.

Some implementations allow more general behaviour: if a Pn field is specified the probed X, Y, and Z values are saved as point n on the bed for calculating the offset plane. Generally n is 0, 1, or 2. If X, or Y, or Z values are specified (e.g. G30 P1 X20 Y50 Z0.3) then those values are used instead of the machine's current coordinates. A silly Z value (less than -9999.0) causes the machine to probe at the current point to get Z, rather than using the given value. If an S field is specfied (e.g. G30 P1 Z0.3 S) the bed plane is computed for compensation and stored. The combination of these options allows for the machine to be moved to points using G1 commands, and then probe the bed, or for the user to position the nozzle interactively and use those coordinates. The user can also record those values and place them in a setup GCode file for automatic execution.

G31 Report Current Probe status

When used on its own this reports whether the Z probe is triggered, or gives the Z probe value in some units if the probe generates height values. If combined with a Z and P field (example: G31 P312 Z0.7) this will set the Z height to 0.7mm when the Z-probe value reaches 312 when a G28 Z0 (zero Z axis) command is sent. The machine will then move a further -0.7mm in Z to place itself at Z = 0. This allows non-contact measuring probes to approach but not touch the bed, and for the gap left to be allowed for. If the probe is a touch probe and generates a simple 0/1 off/on signal, then G31 Z0.7 will tell the RepRap machine that it is at a height of 0.7mm when the probe is triggered.

In Duet-dc42 firmware, separate G31 parameters may be defined for probe types 0, 1/2, and 3 (probe types 1 and 2 share the same set of parameters). To specify which probe you are setting parameters for, send a M558 command to select the probe type before the G31 command.

Duet-dc42 firmware supports additional parameters S (bed temperature in degC at which the specified Z parameter is correct, default is current bed temperature), and C (temperature coefficient of Z parameter in mm/degC, default zero). This is useful for ultrasonic and other probes that are affected by temperature.

G32 Probe Z and calculate Z plane

probes the bed at 3 or 4 pre-defined points (see M557) and updates transformation matrix for bed leveling compensation.

バッファに格納されないGコマンド

The following commands are not buffered. When one is received it is stored, but it is not acknowledged to the host until the buffer is exhausted and then the command has been executed. Thus the host will pause at one of these commands until it has been done. Short pauses between these commands and any that might follow them do not affect the performance of the machine.

Teacup Firmware buffers G20, G21, G90 and G91.

G4: 一定時間待つ(Dwell)

例: G4 P200

上記の例の場合、200ミリ秒間、何も行わない。この何もしていない間、機械の状態(例えば、エクストルーダーの温度)は、維持される。

Marlinの場合、Sパラメータは秒、Pパラメータはミリ秒を示す。つまり、G4 S2とG4 P2000は同じである。

G10: Tool Offset

Support RepRapPro Teacup Sprinter Marlin Repetier
yes no no (Retract?)  ???


Example: G10 P3 X17.8 Y-19.3 Z0.0 R140 S205

This sets the offset for tool (or in older implementations extrude head) 3 (from the P3) to the X and Y values specified. You can put a non-zero Z value in as well, but this is usually a bad idea unless the tools are loaded and unloaded by some sort of tool changer. When all the tools are in the machine at once they should all be set to the same Z height.

Remember that any parameter that you don't specify will automatically be set to the last value for that parameter. That usually means that you want explicitly to set Z0.0.

The R value is the standby temperature in oC that will be used for the tool, and the S value is its operating temperature. If you don't want the tool to be at a different temperature when not in use, set both values the same. See the T code (select tool) below. In tools with multiple heaters the temperatures for them all are specified thus: R100.0:90.0:20.0 S185.0:200.0:150.0 .

The NIST G-code standard mentions an additional L parameter, which is ignored.

This command is subject to discussion.

Note that Marlin uses G10/G11 for executing a retraction/unretraction move.

G20: 単位をインチに指定する

例: G20

単位をインチに指定する

G21: 単位をインチに指定する

例: G21

単位をミリメートルに指定する (RepRapのデフォルトはミリメートルである)

G90: 絶対的な位置を設定(Set to Absolute Positioning)

例: G90

全ての座標は、マシンの原点からの絶対的な位置となる。(これはRepRapのデフォルトである)

G91: 相対的な位置を設定する(Set to Relative Positioning)

例: G91

全ての座標は、最後の位置の相対的な位置となる。

G92: Set Position

例: G92 X10 E90


現在の座標を指定した値にリセットする。これは、原点に対して絶対座標を指定するプログラムを可能にする。 上記の例は、マシンのX座標を10、押出座標を90に設定する。物理的な移動は起きない。

座標を指定しないG92は、全ての軸を0にリセットする。

バッファに格納されないM及びTコマンド

M0: Stop

例: M0

RepRap機は、バッファの中のデータを残したまま、移動を終了してシャットダウンする。全てのモーター、ヒーターの電源はOFFとなる。マスターコントローラのリセットボタンを押すことによって、再度、開始される。M1, M112参照。