|
*****************************
G code
CNC 的語言
*****************************
在學(xué)習(xí) GRBL 過程中,遇到了很多新知識(shí),CNC 編程對(duì)我來說也是需要補(bǔ)充學(xué)習(xí)的。
首先,坐標(biāo)系統(tǒng),
G90: Set to Absolute Positioning 設(shè)置成絕對(duì)定位
Example: G90
All coordinates from now on are absolute relative to the origin of the machine. (This is the RepRap default.)
所有坐標(biāo)從現(xiàn)在開始變成絕對(duì)坐標(biāo),即與機(jī)器原始位置相對(duì)的..
G91: Set to Relative Positioning 設(shè)置成相對(duì)定位
Example: G91
All coordinates from now on are relative to the last position
所有坐標(biāo)從現(xiàn)在開始變成相對(duì)于當(dāng)前位置的相對(duì)坐標(biāo)
G92: Set Position 設(shè)置位置
Example: G92 X10 E90
可用來設(shè)定絕對(duì)0點(diǎn),或者重置現(xiàn)在的位置到規(guī)定的坐標(biāo)。
沒有指定坐標(biāo)的G92命令會(huì)重置所有軸到0 ‘
*********************************
G00
153144x5e5k6e9m5xe5z5w.jpg (50.02 KB, 下載次數(shù): 169)
下載附件
2016-4-9 23:55 上傳
For rapid linear motion, program G0 X… Y… Z… A… B… C…, where all the axis words are
optional, except that at least one must be used. The G0 is optional if the current motion mode is
G0. This will produce coordinated linear motion to the destination point at the current traverse
rate (or slower if the machine will not go that fast). It is expected that cutting will not take place
when a G0 command is executing.
******************************
G01 可控移動(dòng)
154322flw6rlf3da8drlll.jpg (65.88 KB, 下載次數(shù): 193)
下載附件
2016-4-9 23:55 上傳
160547er9v3y3v96ov3oop.gif (175.35 KB, 下載次數(shù): 190)
下載附件
2016-4-9 23:55 上傳
這個(gè)G01 仿真有點(diǎn)錯(cuò)誤(坐標(biāo)系),不過不影響理解。商用仿真還沒學(xué)會(huì)。
******************************
G0203
162208rccjc4n9p4sjoyc1.jpg (52.42 KB, 下載次數(shù): 177)
下載附件
2016-4-9 23:55 上傳
162209zsrkjksvk6s6yknj.jpg (58.95 KB, 下載次數(shù): 190)
下載附件
2016-4-9 23:55 上傳
162208whmzy6ac9yh0ft9u.jpg (57.92 KB, 下載次數(shù): 198)
下載附件
2016-4-9 23:55 上傳
162230qpr70r9qkomlppt0.gif (121.63 KB, 下載次數(shù): 201)
下載附件
2016-4-9 23:55 上傳
**********************************
內(nèi)容比較多,先開始再說吧。
*****************************
GROUP1 一覽
在 GRBL 中的代碼實(shí)現(xiàn)
*****************************
按照順序,已經(jīng)理解 G00 G01 G02 G03命令后下一個(gè)要理解的命令是 G80,
原因是他們 是同一組的。
group 1= {G0, G1, G2, G3, G38.2, G80, G81, G82, G83, G84, G85, G86, G87, G88, G89} motion
因?yàn)镚RBL 只是實(shí)現(xiàn)了部分命令,
group 1= {G0, G1, G2, G3, G80}
Cancel Modal Motion — G80
Program G80 to ensure no axis motion will occur. It is an error if:
• Axis words are programmed when G80 is active, unless a modal group 0 G code is programmed which uses axis words.
g80是取消固定循環(huán)指令。網(wǎng)上搜了一下 華中數(shù)控,G80不是這個(gè)功能,看來華中數(shù)控并沒有遵循RS274規(guī)范。
*******************************
在GRBL 中(gcode.c)的實(shí)現(xiàn),
switch(letter) {
case 'G':
// Set modal group values
switch(int_value) {
case 0: case 1: case 2: case 3: case 80: group_number = MODAL_GROUP_1; break;
。。。。
遇到 G0, G1, G2, G3, G80 命令時(shí),把 變量 group_number 賦值 MODAL_GROUP_1。
然后,再具體指令,
switch(int_value) {
case 0: gc.motion_mode = MOTION_MODE_SEEK; break;
case 1: gc.motion_mode = MOTION_MODE_LINEAR; break;
case 2: gc.motion_mode = MOTION_MODE_CW_ARC; break;
case 3: gc.motion_mode = MOTION_MODE_CCW_ARC; break;
。。。。
case 80: gc.motion_mode = MOTION_MODE_CANCEL; break;
。。。
設(shè)置 相應(yīng) 的 gc.motion_mode 變量。
剩下是如何具體執(zhí)行的,可能要把 gcode.c 看完才可以理解。
其中,gc 是一個(gè)結(jié)構(gòu)體,
結(jié)構(gòu)
typedef struct {
uint8_t status_code; // Parser status for current block
uint8_t motion_mode; // {G0, G1, G2, G3, G80}
uint8_t inverse_feed_rate_mode; // {G93, G94}
uint8_t inches_mode; // 0 = millimeter mode, 1 = inches mode {G20, G21}
uint8_t absolute_mode; // 0 = relative motion, 1 = absolute motion {G90, G91}
uint8_t program_flow; // {M0, M1, M2, M30}
int8_t spindle_direction; // 1 = CW, -1 = CCW, 0 = Stop {M3, M4, M5}
uint8_t coolant_mode; // 0 = Disable, 1 = Flood Enable {M8, M9}
float feed_rate; // Millimeters/min
// float seek_rate; // Millimeters/min. Will be used in v0.9 when axis independence is installed
float position[3]; // Where the interpreter considers the tool to be at this point in the code
uint8_t tool;
// uint16_t spindle_speed; // RPM/100
uint8_t plane_axis_0,
plane_axis_1,
plane_axis_2; // The axes of the selected plane
uint8_t coord_select; // Active work coordinate system number. Default: 0=G54.
float coord_system[N_AXIS]; // Current work coordinate system (G54+). Stores offset from absolute machine
// position in mm. Loaded from EEPROM when called.
float coord_offset[N_AXIS]; // Retains the G92 coordinate offset (work coordinates) relative to
// machine zero in mm. Non-persistent. Cleared upon reset and boot.
} parser_state_t;
這個(gè)結(jié)構(gòu)體包含的指令 就是要理解的,不包含的則不增加學(xué)習(xí)負(fù)擔(dān)。
*****************************
另外,GRBL 沒有實(shí)現(xiàn) 刀具補(bǔ)償指令,是個(gè)大遺憾。好消息是,學(xué)習(xí)難度小了些。
175516m0t7autypfvn7ug6.jpg (51.56 KB, 下載次數(shù): 179)
下載附件
2016-4-9 23:55 上傳
|
|