G-code/ja
Contents
はじめに
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).
4.2 Buffered G Commands
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.
4.2.1 G0: 即時移動
Support | FiveD | Teacup | Sprinter | Marlin | Repetier |
---|---|---|---|---|---|
??? | yes | yes | yes | yes |
例: G0 X12
上記の例は、X = 12mmへ直ちに移動する。
In this case move rapidly to X = 12 mm. In fact, the RepRap firmware uses exactly the same code for rapid as it uses for controlled moves (see G1 below), as - for the RepRap machine - this is just as efficient as not doing so. (The distinction comes from some old machine tools that used to move faster if the axes were not driven in a straight line. For them G0 allowed any movement in space to get to the destination as fast as possible.)