機(jī)械社區(qū)

 找回密碼
 注冊(cè)會(huì)員

QQ登錄

只需一步,快速開(kāi)始

搜索
查看: 17826|回復(fù): 15
打印 上一主題 下一主題

單片機(jī)MCP制作數(shù)控雕刻機(jī)3D打印機(jī)

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
1#
發(fā)表于 2016-8-20 23:56:23 | 只看該作者 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
本帖最后由 1五湖四海1 于 2016-8-21 00:09 編輯 % O4 t+ i  S4 ~. X5 `
7 s: ^" ^" J7 v2 b
    以前制作過(guò)CNC雕刻機(jī),是用MACH3作為上位機(jī)控制,硬件是采用PC接并口輸出脈沖和方向使能信號(hào)經(jīng)過(guò)隔離驅(qū)動(dòng)步進(jìn)電機(jī)驅(qū)動(dòng)器,步進(jìn)電機(jī)驅(qū)動(dòng)是采用TB6560芯片控制。最后就接到步進(jìn)電機(jī)。機(jī)械是用鋁合金制作,主要部件有三個(gè)1605的滾珠絲杠,多個(gè)運(yùn)動(dòng)滑塊等制作。用這臺(tái)DIY CNC雕刻機(jī)可以雕刻木頭塑料等東西。當(dāng)時(shí)沒(méi)有一直玩下去,現(xiàn)在發(fā)現(xiàn)網(wǎng)上有用單片機(jī)制作的雕刻機(jī)挺精巧的現(xiàn)在分享給大家。
+ V2 e4 o% a& x, x* @% [5 l* Q  J   GRBL CNC 3D打印機(jī),這就是我說(shuō)的可以用單片機(jī)來(lái)控制的3D打印機(jī),我先照著百度科普下grbl,Grbl是性能高,成本低,基于并口運(yùn)動(dòng)控制,用于CNC雕刻。它可以運(yùn)行在Vanilla Arduino (Duemillanove/Uno) 只要它配備了Atmega 328型芯片。 控制器由C編寫(xiě)并優(yōu)化,利用了AVR 芯片的每一個(gè)靈巧特性來(lái)實(shí)現(xiàn)精確時(shí)序和異步控制。它可以保持超過(guò)30kHz的穩(wěn)定、無(wú)偏差的控制脈沖 它接受標(biāo)準(zhǔn)的G代碼而且通過(guò)了數(shù)個(gè)CAM工具的輸出測(cè)試;⌒、圓形和螺旋的運(yùn)動(dòng)都可以像其他一些基本G代碼命令一樣完美支持。函數(shù)和變量目前并不支持,但是會(huì)作為預(yù)處理器包含在將來(lái)發(fā)布的版本之中。 Grbl 包含完整的前瞻性加速度控制。它意味著控制器將提前16到20個(gè)運(yùn)動(dòng)來(lái)規(guī)劃運(yùn)行速度,以實(shí)現(xiàn)平穩(wěn)的加速和無(wú)沖擊的轉(zhuǎn)彎。Grbl是性能高,成本低,基于并口運(yùn)動(dòng)控制,用于CNC雕刻。它可以運(yùn)行在Vanilla Arduino (Duemillanove/Uno) 只要它配備了Atmega 328型芯片。 控制器由C編寫(xiě)并優(yōu)化,利用了AVR 芯片的每一個(gè)靈巧特性來(lái)實(shí)現(xiàn)精確時(shí)序和異步控制。它可以保持超過(guò)30kHz的穩(wěn)定、無(wú)偏差的控制脈沖 它接受標(biāo)準(zhǔn)的G代碼而且通過(guò)了數(shù)個(gè)CAM工具的輸出測(cè)試;⌒、圓形和螺旋的運(yùn)動(dòng)都可以像其他一些基本G代碼命令一樣完美支持。函數(shù)和變量目前并不支持,但是會(huì)作為預(yù)處理器包含在將來(lái)發(fā)布的版本之中。 Grbl 包含完整的前瞻性加速度控制。它意味著控制器將提前16到20個(gè)運(yùn)動(dòng)來(lái)規(guī)劃運(yùn)行速度,以實(shí)現(xiàn)平穩(wěn)的加速和無(wú)沖擊的轉(zhuǎn)彎。很棒吧!開(kāi)始玩起。
! k5 U. l1 `1 V0 R5 u    還沒(méi)有雕刻機(jī)的機(jī)械部分可以用廢舊光驅(qū)制作個(gè)微型雕刻機(jī)運(yùn)動(dòng)平臺(tái)。雕刻機(jī)最重要的是主控程序這次用 Arduino/AVR328單片機(jī),價(jià)格在15元左右,主控程序是上面提到的目前很火的開(kāi)源
的GRBL,還有一種基于STM32平臺(tái)的開(kāi)源主控程序Dlion也不錯(cuò)可以替代grbl。如果從性能比較這兩個(gè)方案,顯然是stm32平臺(tái)運(yùn)行速度更快畢竟他是32單片機(jī)呀!
: ]5 x; E+ G- ~3 [: W
% O2 O$ O) q4 h( Z0 o& ^% G
( D: K! J# q* w( w3 y, d
    下面介紹小這個(gè)些主控程序主要干的事,通過(guò)串口PC和主控板通訊,PC命令給控制板,控制板接收命令做不同的響應(yīng),PC可以發(fā)G代碼給主控板,接收完成后可以自動(dòng)開(kāi)始雕刻任務(wù)。+ j- r2 J+ G* j0 _; D! l9 x
          在介紹下G代碼因?yàn)镚代碼是雕刻機(jī)的核心部分/ R: b) c4 D- h( P" @( v; r
G代碼是數(shù)控程序中的指令。一般都稱(chēng)為G指令。1 a6 |: a# e" `" A! I% Y
G00------快速定位, f; h. l+ M4 t0 @5 _
G01------直線插補(bǔ)
( l" h% D9 H6 F/ a: ]1 ZG02------順時(shí)針?lè)较驁A弧插補(bǔ)
# V: G1 {( Z( q$ E! k. EG03------逆時(shí)針?lè)较驁A弧插補(bǔ)
" D+ E8 }  M5 v$ }9 }4 XG04------定時(shí)暫停
7 g7 Q! `+ j1 r+ q: C% h( wG05------通過(guò)中間點(diǎn)圓弧插補(bǔ). U' r1 N2 n+ _' ]+ e4 `
G06------拋物線插補(bǔ)
6 q6 _; v* G+ Z/ ?6 oG07------Z 樣條曲線插補(bǔ)
  h1 e. J  V: q( NG08------進(jìn)給加速! ~! O( {. K# b0 E9 O/ Q
G09------進(jìn)給減速% m4 h) y9 ^' a9 g8 x- J
G10------數(shù)據(jù)設(shè)置
, X! m$ t" }3 k; v- U( k# rG16------極坐標(biāo)編程& q4 k3 D6 Y1 V1 _' G) ^# T
G17------加工XY平面* _; X# t* ^2 o' [2 b& Z5 a
G18------加工XZ平面* j' c8 g7 s% K8 J7 b9 j
G19------加工YZ平面
: Z6 C% m- z* J; X, B
核心就是解析G代碼,完成步進(jìn)電機(jī)驅(qū)動(dòng),和控制主軸開(kāi)啟關(guān)閉,還有插補(bǔ)算法,直線插補(bǔ),圓弧插補(bǔ),還有一些步進(jìn)電機(jī)的加減速算法。
/ D% P4 i5 _  g. L+ I3 q; U下面對(duì)grbl主結(jié)構(gòu)做介紹" D& y7 H+ z8 U/ q2 ?' {2 n+ D
main()主函數(shù)首先執(zhí)行下面初始化函數(shù)5 d+ e. a! k5 i* q# M6 d+ p
        serial_init();                           // 設(shè)置串口波特率和中斷
, A2 T  E1 q' ?6 K! \        settings_init();                         // 從ROM加載grbl設(shè)置3 Q2 p: F3 }$ D$ A" t2 h
        stepper_init();                          // 配置步進(jìn)方向和中斷定時(shí)器( o4 J# L7 W# P; F
        system_init();                           // 配置引腳分配別針和pin-change中斷
. ~. }% d0 Q" [4 x( y) X9 d        memset(&sys, 0, sizeof(system_t));          // 清除所有系統(tǒng)變量7 [" D: s: u2 t: X9 ^
        sys.abort = true;                           // 中止標(biāo)識(shí)位置位; z/ N8 [' U$ z$ R7 @! ]0 O" k7 d
        sei();                                         // 使能中斷& h( D+ ~5 _% C; V/ {0 G) v
  #ifdef HOMING_INIT_LOCK                        // 宏運(yùn)算(settings.flags & (1 << 4)) != 0結(jié)果flags等于執(zhí)行sys.state = STATE_ALARM2 W, L. p2 W. l5 @
                                                // 系統(tǒng)狀態(tài)賦值為報(bào)警狀態(tài)
( `( ^6 K. J1 @& ]) R5 g# |" m5 s! u6 o            if (bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE)) { sys.state = STATE_ALARM; }( q. h* ]4 s5 C' F
  #endif9 C/ h9 H5 [% \
_____________________________________________________________________________________________________________________________________. F' N: D; E  @& }2 ]2 K: v
接下來(lái)是一些主要部分初始化/ L: g9 k. u0 \, I" C3 y
for(;;) {$ l) ]  `6 e* H7 r2 F! @
        serial_reset_read_buffer();         //清除串口讀緩沖區(qū)
& T  Q) j. C! v, C        gc_init();                         //初始化G代碼功能函數(shù)
' G; a  X9 \; v8 D6 ]        spindle_init();                        //主軸初始化
: }- O! R0 c* L0 j  ]$ C% x        coolant_init();                        //冷卻液初始化
+ _- G8 M2 C, N" H% ^8 B        limits_init();                         //極限開(kāi)關(guān)初始化. L' I/ `% m- H& N+ }/ U+ A
        probe_init();                        //探測(cè)部件初始化
+ B1 K  i; G8 B5 `* S        plan_reset();                         //清除塊緩沖區(qū)和規(guī)劃師變量6 P6 h: ?& Y. V( k
        st_reset();                         //清除步進(jìn)系統(tǒng)變量。
3 c& d3 M3 D' p3 E4 J
8 U' \  X2 t7 _7 }; g9 ?, d4 t( S: Y" ?: v1 z# l/ v8 j3 W9 s
        //下面兩行清除同步gcode和策劃師職位當(dāng)前系統(tǒng)位置。8 c0 z6 P  z4 v* ^
        plan_sync_position();
# a( @* s4 z1 L0 T, g7 T        gc_sync_position();
# G0 ^9 d1 z( t6 W' C3 u4 O" n# q$ O% [$ _" a: H/ M
5 E# b% L# n/ j
        //復(fù)位系統(tǒng)變量
: W4 n8 p$ S" R- F' ]        sys.abort = false;                //系統(tǒng)中止標(biāo)志# [9 d! [" p- z: E" v
        sys_rt_exec_state = 0;                //系統(tǒng)標(biāo)志位變量狀態(tài)管理?吹紼XEC位掩碼。8 s2 ^& I9 Q7 f  b" A) g, e: B
        sys_rt_exec_alarm = 0;                //系統(tǒng)標(biāo)志位變量設(shè)置不同的警報(bào)。. X: H6 l9 B7 B! [/ e
        sys.suspend = false;                //系統(tǒng)暫停標(biāo)志位變量管理,取消,和安全保護(hù)。
' c% v& o1 G2 O7 K3 }  I        sys.soft_limit = false;                //限位開(kāi)關(guān)限制狀態(tài)機(jī)錯(cuò)誤。(布爾)" D2 J) L9 G) [

. u3 O9 U* |3 X7 e+ ~, a' ~1 h1 P; [" R  |
        protocol_main_loop();                //主協(xié)議循環(huán)  `2 x5 T% X# ?2 K
}        //
  q0 I% X. E6 H& `6 P! `_____________________________________________________________________________________________________________________________
% d1 C: _, c! ~/ \, S進(jìn)入void protocol_main_loop()函數(shù)
8 [1 V: N+ M+ B2 E2 ^{, l1 ]( T* y5 \, V
        report_init_message();                // 打印歡迎信息
8 g" S. }) J4 I- @3 Y7 e2 [7 q        //重啟后檢驗(yàn)和報(bào)告報(bào)警狀態(tài)如果錯(cuò)誤重啟初始化。
2 }( F& a2 }( q3 P
        if (sys.state == STATE_ALARM) {
8 v4 K6 w) _/ j- x            report_feedback_message(MESSAGE_ALARM_LOCK); //打印信息0 c: i" [% z6 }
          } else {
* K$ t8 @& m' Z6 O3 A  R* a            // 如果沒(méi)有報(bào)警說(shuō)明一切正常!但還是要檢查安全門(mén). 6 A! H6 u8 A8 `) G5 o  z" Y3 _3 T
            if (system_check_safety_door_ajar()) {
: t8 l' P# Y9 q' v! R7 r% T                     bit_true(sys_rt_exec_state, EXEC_SAFETY_DOOR);' f1 i* z# Z& \* V/ I; R
                     protocol_execute_realtime(); // 進(jìn)入安全模式。應(yīng)該返回空閑狀態(tài)。
2 A6 R9 f( A2 D) W            }         else {
9 |' f, t  `/ q! N              sys.state = STATE_IDLE; // .設(shè)置系統(tǒng)做好準(zhǔn)備。清除所有國(guó)家國(guó)旗。) ~" {( O9 G  m% t2 `5 p9 A
            }
- j* i% a: n7 O3 l+ r! C            system_execute_startup(line);    //開(kāi)始執(zhí)行系統(tǒng)腳本
! \$ j8 p" f8 a* F  } 0 n0 @% A& u! u* i7 N( y. t
6 J0 a! c& {: T8 ~5 n, o
1 W; h- o; z  h. U; d! w: q. d
  // 這是主循環(huán)!在系統(tǒng)中止時(shí)這是出口回到主函數(shù)來(lái)重置系統(tǒng)。0 @& q0 ^6 n1 ^/ H8 N
  // ---------------------------------------------------------------------------------  3 u7 y( i( E! O2 K0 C2 c
  
' D( S( g* {% m: Z3 V" \        uint8_t comment = COMMENT_NONE;
0 K0 q% _+ f2 @( A        uint8_t char_counter = 0;7 B+ \  B# s0 u
        uint8_t c;
( `- Q6 S0 M% E( g5 k6 k" v_______________________________________________________________________________________________________________________________/ F2 F/ }( J8 B* z0 `
接下來(lái)進(jìn)入for(;;)循環(huán)                //下面代碼是G代碼解析核心部分,程序中comment(注釋?zhuān)┳兞繒?huì)被賦不同值,代表發(fā)符號(hào)有‘(’‘)’‘;’: E( z3 i( P# ?0 v8 T
{
& Y$ w- u+ T7 U4 \+ E//串行數(shù)據(jù)輸入一行的的過(guò)程,作為數(shù)據(jù)。執(zhí)行一個(gè), H7 Y4 V! O& y" M8 n
//所有數(shù)據(jù)初始過(guò)濾去除空格和注釋。 " a$ a  `: \% F; H) m
//注意:注釋,空格和程序段刪除(如果支持的話)處理技術(shù)/ [0 f1 w! J) V0 c7 f" a  D5 o3 ]: c
//在G代碼解析器,它有助于壓縮到Grbl傳入的數(shù)據(jù)- a7 I8 I/ D0 T4 [! ?0 N
//線緩沖區(qū),這是有限的。刀位點(diǎn)標(biāo)準(zhǔn)實(shí)際上州一行不行& G. L: l, z( f: k. r
//不能超過(guò)256個(gè)字符,Arduino Uno沒(méi)有更多內(nèi)存空間。
. V/ I) ?9 B  Y4 g3 ~; G//有更好的處理器,它會(huì)很容易把這個(gè)初步解析的
* e) [: O  n. G" s//分離任務(wù)共享的刀位點(diǎn)解析器和Grbl系統(tǒng)命令。                                                                ! ]7 Y$ z+ f  W8 i4 s
    while((c = serial_read()) != SERIAL_NO_DATA) {                             //讀取串口數(shù)據(jù),有數(shù)據(jù)執(zhí)行下面代碼$ Z6 }7 P, G8 X: T. }' a
      if ((c == '\n') || (c == '\r')) { // End of line reached                //如果數(shù)據(jù)是/r,/n代表一行結(jié)束* _1 O2 `6 l: Y1 I, g
        line[char_counter] = 0; // Set string termination character.        //設(shè)置結(jié)束標(biāo)志
) _0 H! a# y* |7 G3 w        protocol_execute_line(line); // Line is complete. Execute it!        //一行完成執(zhí)行此函數(shù)8 O( |2 D% E0 I, `; `6 t
        comment = COMMENT_NONE;                                                //注釋清零
  c( O4 j1 f$ Y& K& ^1 [1 J7 D        char_counter = 0;                                                    //字符計(jì)數(shù)清零
8 D$ y, ~1 S) V  
, C% o, p; k+ I2 j& Y) I( d        else {3 z, |- S! }3 `$ d, E8 `% e' Q
        if (comment != COMMENT_NONE) {
5 T( S' `0 P$ ~- _: h                                                     //扔掉所有注釋字符
% D# n6 i8 m( a& [          if (c == ')') {8 _7 t( P. D0 h* k5 b/ D
            //最后注釋。重新開(kāi)始。但是如果有分號(hào)類(lèi)型的注釋。0 U1 t- ]- U! C8 G" r! K7 S
            if (comment == COMMENT_TYPE_PARENTHESES) { comment = COMMENT_NONE; }
" s1 w0 Q3 A% @7 T          }
5 S  }  o) J# h. J% a9 L      } else {7 c7 y% n" |  X3 ]
          if (c <= ' ') { & w9 g; u; t4 E' S
            //扔掉whitepace和控制字符, d5 ?( d- }$ f
          } else if (c == '/') { 0 p- @, |2 _7 f+ X" v
            //塊刪除不支持將忽略字符。
$ T$ k+ o# Y9 f7 ~, ]; |            //注意:如果支持,只需要檢查系統(tǒng)是否啟用了塊刪除。
* c, O; u2 X- y# I          } else if (c == '(') {
8 V( g2 K- o3 m5 O, |/ A; H            // Enable comments flag and ignore all characters until ')' or EOL.. n; w! O9 C# _$ W0 \
            // NOTE: This doesn't follow the NIST definition exactly, but is good enough for now.' ]" z( v: M9 J; E
            // In the future, we could simply remove the items within the comments, but retain the7 @: u, U6 C* R% ]
            // comment control characters, so that the g-code parser can error-check it.
2 H1 M3 c: |& G2 B            comment = COMMENT_TYPE_PARENTHESES;0 F. s7 s0 D! r- O; D( o
          } else if (c == ';') {
+ x( P3 @. L" C( H  Q2 O            //注意:','注釋EOL LinuxCNC定義。沒(méi)有國(guó)家標(biāo)準(zhǔn)。
: p: `$ e) j% S            comment = COMMENT_TYPE_SEMICOLON;: ^9 @; F' ~* n: R$ A. {6 v$ j. V
  A7 X% L/ D! W! I7 ]3 p4 D  Z
$ q' k& ]; h( G" q, a( u
_____________________________________________________________________________________________________________________________________, e4 r7 \) n! Y0 N& G* n3 ?
          } else if (char_counter >= (LINE_BUFFER_SIZE-1)) {                        //串口接收數(shù)據(jù)大于80字符時(shí); q  b) x  x  s* T
            // Detect line buffer overflow. Report error and reset line buffer.        檢測(cè)緩沖區(qū)溢出。報(bào)告錯(cuò)誤和復(fù)位線緩沖區(qū)。, O/ [# W- g8 O- u7 v& M
            report_status_message(STATUS_OVERFLOW);                                //打印溢出信息
/ L4 R3 m/ E. E# b7 H+ C            comment = COMMENT_NONE;
1 j/ Z+ t" v! C- P: G7 V, `            char_counter = 0;. r, [# e: t  Y+ E0 q: P( d. R
          } else if (c >= 'a' && c <= 'z') { // Upcase lowercase                        //小寫(xiě)改大寫(xiě)
, t9 C" W2 F$ S; j            line[char_counter++] = c-'a'+'A';
' s: w2 t3 U( I          } else {
, \$ G0 Z4 T5 v/ _8 m+ a2 V            line[char_counter++] = c;8 Z" w+ i& ]( Z( Q, j  Y
          }
$ n, q0 R/ D. \& j        }3 S) J- l) p  W2 ~8 q/ _3 v
      }) q+ d+ ?) T* l4 H2 y$ x& }8 |
    }
% R* B. c- b& g7 S1 q____________________________________________________________________________________________________________________________________
  @! x1 q( Y3 V4 a        //如果沒(méi)有其他字符在串行處理讀取緩沖區(qū)和執(zhí)行,這表明以完成,自動(dòng)啟動(dòng),如果啟用,任何隊(duì)列動(dòng)作。
# h2 l1 d1 G  ]        protocol_auto_cycle_start();                //自動(dòng)開(kāi)始協(xié)議循環(huán), W; B" f5 C/ }8 m( p4 E: I
        : K3 {1 t6 i' T4 a7 f
            protocol_execute_realtime();                  //運(yùn)行實(shí)時(shí)命令。: i0 q3 A' F* ~2 L1 {1 C
            if (sys.abort) { return; }                 //中止標(biāo)識(shí)置位程序循環(huán)重置系統(tǒng)。            4 J9 \" c; l% X  \
  } 4 ^' A0 j8 C9 E9 g
  return;                         //一般程序不會(huì)執(zhí)行到這里' X  l' n0 X7 l
}
7 z$ h; S: ^- `2 R: c2 T____________________________________________________________________________________________________________________________________4 V% h* }" z+ M2 Z$ d) O( l9 z& t
正常情況下,讀取完G代碼程序會(huì)進(jìn)入protocol_auto_cycle_start();//自動(dòng)開(kāi)始協(xié)議循環(huán) 函數(shù)下面介紹此函數(shù); u9 ^. x0 M- @, c1 x" w
// Auto-cycle start has two purposes: 1. Resumes a plan_synchronize() call from a function that
, G8 v* D% F% O# P3 {0 ?// requires the planner buffer to empty (spindle enable, dwell, etc.) 2. As a user setting that
& \8 J5 k& n6 N# y4 M: q0 B// automatically begins the cycle when a user enters a valid motion command manually. This is ; T' \+ v% E" }; s: j4 P
// intended as a beginners feature to help new users to understand g-code. It can be disabled4 S6 h8 o+ O+ h/ ^0 n6 e5 |8 |: o
// as a beginner tool, but (1.) still operates. If disabled, the operation of cycle start is
2 \" I; v, q8 R9 |// manually issuing a cycle start command whenever the user is ready and there is a valid motion
' f0 _4 X- |, _// command in the planner queue.6 d: W: E5 S8 Q+ ^, D! a% ^
// NOTE: This function is called from the main loop, buffer sync, and mc_line() only and executes / y% ~: q0 q, l3 g8 n4 ?1 s
// when one of these conditions exist respectively: There are no more blocks sent (i.e. streaming
5 g+ ?6 m( A5 U# g// is finished, single commands), a command that needs to wait for the motions in the buffer to
# M" p* y6 [6 S8 q& Q( c// execute calls a buffer sync, or the planner buffer is full and ready to go.4 ?1 U0 S/ e, u0 ^/ Y
//自動(dòng)開(kāi)始有兩個(gè)目的:1。回復(fù)一個(gè)plan_synchronize()調(diào)用的函數(shù)
! R5 a/ W& o, z7 p3 R//需要規(guī)劃師緩沖區(qū)空(主軸啟用、住等)2。作為一個(gè)用戶(hù)設(shè)置( i( X6 S. ^& l2 O& M) m
//自動(dòng)循環(huán)開(kāi)始當(dāng)一個(gè)用戶(hù)輸入一個(gè)有效的運(yùn)動(dòng)命令手動(dòng)。這是
3 H2 H0 i8 l& K; ?1 ]2 M: X8 z: v4 {//作為一個(gè)初學(xué)者的特性來(lái)幫助新用戶(hù)了解刀位點(diǎn)。它可以被禁用
  V0 H& N, r2 [) B% M/ r) o: n//作為一個(gè)初學(xué)者工具,但(1)仍然運(yùn)作。如果禁用,運(yùn)行周期開(kāi)始2 E$ @' S3 u2 m/ ~
//手動(dòng)發(fā)出一個(gè)周期開(kāi)始命令每當(dāng)用戶(hù)準(zhǔn)備好,有一個(gè)有效的運(yùn)動(dòng)
+ c2 A' F7 u3 E7 i//命令的規(guī)劃師隊(duì)列。
& [/ i8 R' o6 }" J. v' w+ P# f. O//注意:這個(gè)函數(shù)被稱(chēng)為從主循環(huán)緩沖區(qū)同步,mc_line只()并執(zhí)行0 Y( @# T7 x3 R8 ~: s: h. e5 ~) S
//當(dāng)其中一個(gè)條件分別存在:沒(méi)有更多的塊(即流發(fā)送
, I# F' z9 Z: v. y! @/ P//完成后,單一的命令),一個(gè)命令,需要等待緩沖的動(dòng)作
  g; z6 H: \% m; U. d* W//執(zhí)行調(diào)用一個(gè)緩沖區(qū)同步,或規(guī)劃師緩沖區(qū)滿了,準(zhǔn)備好了。
: I0 A+ f8 `. hvoid protocol_auto_cycle_start() { bit_true_atomic(sys_rt_exec_state, EXEC_CYCLE_START); } $ q( N( s( k; m: O& ?8 _: o
_______________________________________________________________________________________________
: A6 W/ |/ P* r接下來(lái)程序運(yùn)行protocol_execute_realtime(); /運(yùn)行實(shí)時(shí)命令。7 Z) |* e+ G; ^
// Executes run-time commands, when required. This is called from various check points in the main) x: S0 o' e- R# W( f: ?2 C" ]
// program, primarily where there may be a while loop waiting for a buffer to clear space or any2 r( l7 \8 r8 x3 B
// point where the execution time from the last check point may be more than a fraction of a second.
" a0 j, i2 i/ B, ?4 l// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code
( g, I" W! V( s$ R! d7 s2 S// parsing and planning functions. This function also serves as an interface for the interrupts to 4 s6 z9 H$ N6 w+ V  c# L) b2 j4 w
// set the system realtime flags, where only the main program handles them, removing the need to
# C3 m+ Q2 c. F// define more computationally-expensive volatile variables. This also provides a controlled way to
* R- V0 H7 Q9 g  [$ _- L) f( V// execute certain tasks without having two or more instances of the same task, such as the planner
* n. w- W- L! m& l! @// recalculating the buffer upon a feedhold or override.
( n8 b, Z6 n5 h: j8 T// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,. y! X0 O+ x6 [* y! ]
// limit switches, or the main program.
- L7 ~; W1 w. z8 bvoid protocol_execute_realtime()
" l7 G( {# |  ]( S5 i. U8 ^ uint8_t rt_exec; // Temp variable to avoid calling volatile multiple times.臨時(shí)變量來(lái)避免多次調(diào)用不穩(wěn)定。
# R9 b$ @2 b- `3 i" s就先分享到這吧!7 k( b* H( l+ M7 w6 v5 ]) w% }

, l# ~. e  n' W+ g; I& w8 N' ^. N, G& ]. B5 Y5 j
1 J0 q) g% R' T# s* d. V6 [9 h

. L# t1 o6 \. J) U5 w8 }, ]1 K% A2 r- O

6 P6 U  @. f7 b/ G, I! a- a! G& ?  g: P! L6 \7 K( j2 h) N8 B; {
" j) y$ f# T' _" H

5 [; w+ \1 J0 }. C
. K$ o. `" S4 }6 ^" a& W/ L0 v' q/ a' q1 o6 h3 k

) E$ j  I. S, K3 ^0 X% C" Y- y( x$ T) ?# E, G
8 f: I) H# s2 b/ i' c' A

1 }/ M% @* j$ b& c) A
' v* j  f: ?; g7 o: W# Q
% \2 v+ p8 e) c; H9 w$ J( W; k8 F& m* m

8 L; v/ k* V  z4 R7 Q7 q
( Y3 [0 u- o- @
. ?6 d, }9 u7 _! B, V
' ~8 b4 l$ g" I/ q

  q9 g. z2 ?; r" T6 K補(bǔ)充內(nèi)容 (2016-8-25 22:40):  H9 n+ D, r; {. p! Q$ f( c
配置說(shuō)明
# A1 c% R8 t+ P//這個(gè)文件包含編譯時(shí)配置Grbl的內(nèi)部系統(tǒng)。在大多數(shù)情況下,1 y$ E/ E+ ?% H% N! a5 t
//用戶(hù)不需要直接修改這些,但是他們?cè)谶@里為特定的需求,即。: k! j% x/ Z  Y# v; Y# w5 r
//性能調(diào)優(yōu)或適應(yīng)非典型的機(jī)器。
! C$ z0 f4 p0 h! T4 x+ B& u# v主要配置項(xiàng):
7 G/ ?; ], P0 h  [2 M1.#define DEFAULTS_GENERIC        //在重置eepm時(shí)使用。在defaults.h改變想要的名字$ F4 @4 h; @8 Q+ m! |8 }
2.#define BAUD_RATE 115200        //配置串口波特率115200
: o0 l* c( D5 D) O6 k& V3.#define CPU_MAP_ATMEGA328P         // Arduino Uno CPU$ {5 N2 o4 _! F! M$ x  u& Y+ ^+ h
4.#define CMD_STATUS_REPORT '?'        //定義實(shí)時(shí)命令特殊字符
  m! t" O* K" I7 r8 i9 y5.#define HOMING_INIT_LOCK         //回原點(diǎn)保護(hù)鎖
: H4 o& u, \8 S0 s5 N( s% c5 o6.#define HOMING_CYCLE_0 (1<<Z_AXIS)              // 第一步Z清除工作區(qū)。
0 f7 o8 v) D' L  B* ~1 `. M% C( |" W3 L  #define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // 然后X,Y在同一時(shí)間。* o) L+ Y* {& ^5 |9 C* V$ j7 g
7.#define N_HOMING_LOCATE_CYCLE 1 //回原點(diǎn)循環(huán)次數(shù)
! `" \' S/ g+ L5 _! E  z8.#define HOMING_FORCE_SET_ORIGIN //取消這定義迫使Grbl總是在這時(shí)候位置設(shè)置機(jī)器原點(diǎn)盡管開(kāi)關(guān)方向。! J8 ~. ~: |* P% \+ }( e
9.#define N_STARTUP_LINE 2 //塊Grbl啟動(dòng)時(shí)執(zhí)行的數(shù)量。
7 \) n( e! y0 E# G" Y  Z+ d10.#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 協(xié)調(diào)或位置價(jià)值英寸
4 S% Q9 ?- M- n) w( l. |  N   #define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 協(xié)調(diào)在毫米或位置價(jià)值9 U6 c0 @/ S# ?4 Z2 e: n
   #define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分鐘的速度值
) K, f; q1 b1 m2 t   #define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分鐘
6 \% p2 b" E1 m: z   #define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 對(duì)浮點(diǎn)小數(shù)設(shè)置值
. H' p6 H/ G0 y11.#define LIMITS_TWO_SWITCHES_ON_AXES //如果你的機(jī)器有兩個(gè)極限開(kāi)關(guān)連接在平行于一個(gè)軸,您需要啟用這個(gè)特性! y$ B- `. E5 I5 j% p
12.#define USE_LINE_NUMBERS         //允許GRBL跟蹤和報(bào)告gcode行號(hào)+ ]; T; [  y2 e0 j
13.#define REPORT_REALTIME_RATE //允許GRBL報(bào)告實(shí)時(shí)進(jìn)給速率
: k& U/ z. Y1 ~& a& |& g14.#define MESSAGE_PROBE_COORDINATES  //坐標(biāo)通過(guò)Grbl $ #的打印參數(shù)?8 y: J* O2 z- A. a' A; H
15.#define SAFETY_DOOR_SPINDLE_DELAY 4000 //安全門(mén)主軸延時(shí)
2 I) O. c6 Q& f4 l  f16.#define SAFETY_DOOR_COOLANT_DELAY 1000 //安全門(mén)冷卻液延時(shí)
$ P" V7 q9 q$ u- {* Q( w17.#define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS) //啟用CoreXY運(yùn)動(dòng)學(xué)。
* I# \( K2 _' Y) v18.#define COREXY // Default disabled. Uncomment to enable.改變X和Y軸的運(yùn)動(dòng)原理
& \1 R, \6 {+ v3 V" S19.#define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.反轉(zhuǎn)針?shù)N邏輯的控制命令% H2 s* u5 u' W9 c- T8 I
20.#define INVERT_SPINDLE_ENABLE_PIN // 反轉(zhuǎn)主軸使銷(xiāo)從low-disabled# `* Y8 w: C+ e; M2 n; S
21.#define REPORT_CONTROL_PIN_STATE //啟用控制銷(xiāo)狀態(tài)反饋狀態(tài)報(bào)告。4 ?& e; b1 b8 y* A5 D
22.#define FORCE_INITIALIZATION_ALARM //啟用和用戶(hù)安裝限位開(kāi)關(guān),Grbl將啟動(dòng)報(bào)警狀態(tài)指示
4 F8 K9 ~/ |9 h' d- Q" d23.#define REPORT_GUI_MODE // gui允許最小的報(bào)告反饋模式
+ m2 l, O; S5 M1 s24.#define ACCELERATION_TICKS_PER_SECOND 100 //加速度的時(shí)間分辨率管理子系統(tǒng)。
; c4 R4 d0 a/ C7 @3 {! t25.#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING //自適應(yīng)多軸步平滑(積累)是一種先進(jìn)的功能 * g/ c: l# b+ v. b/ ?
26.#define MAX_STEP_RATE_HZ 30000 //設(shè)置最大一步速率可以寫(xiě)成Grbl設(shè)置7 F# c/ z) L+ o4 w7 e
27.#define DISABLE_LIMIT_PIN_PULL_UP //以下選項(xiàng)禁用內(nèi)部上拉電阻% }, d8 h# ?% ~& b: Q& E6 s6 ~1 a( y
28.#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS //設(shè)置哪個(gè)軸長(zhǎng)度補(bǔ)償應(yīng)用的工具。假設(shè)軸總是與選擇軸工具面向負(fù)方向
& Q& y/ d4 i0 w. t4 d29.#define VARIABLE_SPINDLE //允許變量軸輸出電壓不同的轉(zhuǎn)速值。
8 @( c" `+ l& l: |30.#define SPINDLE_MAX_RPM 1000.0  // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.2 ?1 D5 f8 Y- @, v
   #define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.& \/ C! m( {2 ^- r8 e
31.#define MINIMUM_SPINDLE_PWM 5 //使用的變量軸輸出。這迫使PWM輸出最小占空比時(shí)啟用。
. e+ O& [4 n, L+ G. j# O32.#define USE_SPINDLE_DIR_AS_ENABLE_PIN //主軸方向使能M4被刪除
8 j) H3 D4 k& E( Y33.#define REPORT_ECHO_LINE_RECEIVED //應(yīng)該對(duì)所有正常線路送到Grbl
! r+ u' Z/ ~5 v* C34.#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min) //最小規(guī)劃師結(jié)速度。設(shè)置默認(rèn)最小連接速度規(guī)劃計(jì)劃
- ?0 Y7 t4 u# h35.#define MINIMUM_FEED_RATE 1.0 // (mm/min)//設(shè)置計(jì)劃將允許的最小進(jìn)給速率
8 T4 T* F7 P0 B+ W6 X36.#define N_ARC_CORRECTION 12 //弧生成迭代次數(shù)之前小角度近似精確的弧線軌跡0 q+ `; b9 N. m9 Q6 K* L6 i# a
37.#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)//定義值設(shè)置機(jī)器ε截止來(lái)確定電弧是一個(gè)原點(diǎn)了?) U, x1 ~; Z9 u7 C
38.#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds) //延時(shí)增加表現(xiàn)在住。默認(rèn)值設(shè)置為50毫秒0 O8 M7 ^8 t) J7 W7 m- F
39.#define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.
8 L4 }* ~$ m! m2 z, W/ G40.#define BLOCK_BUFFER_SIZE 18  //線性運(yùn)動(dòng)規(guī)劃師緩沖區(qū)的數(shù)量在任何給出時(shí)間計(jì)劃
0 p2 F$ `: H; H% T* f  H$ Y6 l41.#define SEGMENT_BUFFER_SIZE 6 //控制之間的中間段緩沖大小的步驟執(zhí)行算法
, z/ p& L- u0 l  ?7 Y42.#define LINE_BUFFER_SIZE 80 //行執(zhí)行串行輸入流的緩沖區(qū)大小。4 K) E7 y8 e/ w/ a" J) b
43.define RX_BUFFER_SIZE 128 //串行發(fā)送和接收緩沖區(qū)大小
9 M0 H& h, l1 A  J44.#define TX_BUFFER_SIZE 64
2 q7 S; j+ Q6 t45.#define ENABLE_XONXOFF        ////切換為串行通信發(fā)送流軟件流控制。
! M+ I; I9 ~* D% u# L, }5 T46.#define ENABLE_SOFTWARE_DEBOUNCE //一個(gè)簡(jiǎn)單的軟件消除抖動(dòng)特性硬限位開(kāi)關(guān)。- `* q$ w3 f3 \. t
47.#define HARD_LIMIT_FORCE_STATE_CHECK        //Grbl檢查硬限位開(kāi)關(guān)的狀態(tài)
& K" Y5 \- B2 L2 K. c+ g48.// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:編譯時(shí)錯(cuò)誤檢查的定義值:; G9 {: L2 _. J/ }1 ~1 o8 _

- q) l0 U( A& R) W9 G2 m8 a* G. S* C___________________________________________________________________________________________________/ A2 s" [9 H. a, N  j6 }: y7 K1 y) X
/*
% L& O' Q, t2 i* z. l) |' s  config.h - compile time configuration0 }3 b( K' L2 C' H
  Part of Grbl" c* j2 Q: M7 F4 z' f# O. Z

5 Z+ v7 k4 {+ }  Copyright (c) 2012-2015 Sungeun K. Jeon
5 T! a6 K8 l& p* L8 s1 n  Copyright (c) 2009-2011 Simen Svale Skogsrud: N! ?% Z, M8 K. C
0 x4 S  d+ K5 h, o  W* {
  Grbl is free software: you can redistribute it and/or modify4 K# A/ W* q" V1 J3 M0 P0 O4 ?
  it under the terms of the GNU General Public License as published by" H) s# r9 D' {9 L
  the Free Software Foundation, either version 3 of the License, or: z8 _3 \0 M5 x
  (at your option) any later version.( F& X, \, m/ \/ {, L. t- W

' S7 ?, R/ {( G  Grbl is distributed in the hope that it will be useful,
0 H0 H4 q  o3 t+ D: x# Z& Q  but WITHOUT ANY WARRANTY; without even the implied warranty of4 y+ @7 H% w6 H% K" L) V
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the- \0 e+ ~8 u, J6 W
  GNU General Public License for more details.8 w' _$ P+ \) \

' b% d( q; Z6 H! Q: S  You should have received a copy of the GNU General Public License* Z* P7 ]. s: C( L, B
  along with Grbl.  If not, see <http://www.gnu.org/licenses/>.7 f6 ]* `9 @, w& ^* v( I* J# {! t
config.h  -編譯時(shí)配置,Grbl的一部分
: ^6 u" n/ j8 N. B' F, f; G- m3 g1 W1 d$ J! F2 F% O
版權(quán)(c)2012 - 2015 Sungeun K. Jeon' ?5 c7 V$ F& w! L
版權(quán)(c)2009 - 2011 Simen Svale Skogsrud
" D9 {) ?& R1 O- s8 s5 o' W: }" v) H) J
Grbl是免費(fèi)軟件:可以重新分配和/或修改/ f( Y  s( P$ I: s8 l
GNU通用公共許可證的條款下發(fā)布的自由軟件基金會(huì),版本3的許可,或(任您選)其后的版本。
& A% t! z+ i& Q1 _& ~7 F- o9 i
1 \" g: \: `4 b' Z9 J# \$ xGrbl分布,希望這將是有用的,但是沒(méi)有任何保證;沒(méi)有即使的默示保證適銷(xiāo)性或健身為特定目的?吹0 k; P# V" \) O
GNU通用公共許可證的更多細(xì)節(jié)。; ^3 v, ~  P; V; L! O
& s( O! d4 I. b/ B9 Z
你應(yīng)該收到了GNU通用公共許可證的副本
, T' \- P- r( ]/ L+ [( ~+ r7 }連同Grbl。如果沒(méi)有,看< http://www.gnu.org/licenses/ >。
. e: r$ S3 `( C% }- M1 S2 p / |0 u5 E- l, x+ P- p9 T
*/4 S3 U" B# p/ B% X8 N% ^
  9 b& D# ^6 O8 J! f3 q" O; s
// This file contains compile-time configurations for Grbl's internal system. For the most part,
3 c- n3 w8 a# T7 Q// users will not need to directly modify these, but they are here for specific needs, i.e.$ _3 O$ D9 j( k) ~9 J
// performance tuning or adjusting to non-typical machines.! o8 x7 N9 h0 r% x! B0 Z: ~+ \) Q
//這個(gè)文件包含編譯時(shí)配置Grbl的內(nèi)部系統(tǒng)。在大多數(shù)情況下,
% Y! P( L5 R- ], v5 W5 v//用戶(hù)不需要直接修改這些,但是他們?cè)谶@里為特定的需求,即。
* p7 j% S; O6 b! j! g//性能調(diào)優(yōu)或適應(yīng)非典型的機(jī)器。- |% X- w7 E+ ^  t' b. m# q/ [5 C

+ U: K0 Q  O4 Q, p9 t: R5 ]( Q// IMPORTANT: Any changes here requires a full re-compiling of the source code to propagate them.
7 U7 M% z% q4 k: g- i: L2 k. j//重要:任何變化需要一個(gè)完整的基于源代碼的傳播。
& u2 d# O. l: w* {, p
$ k/ d, }! @5 d8 z" d#ifndef config_h- E/ s9 {& d% i$ i8 ~
#define config_h0 w7 U& n+ f: c5 o  C
#include "grbl.h" // For Arduino IDE compatibility.) O" ^: }6 G3 k( n6 O9 R* j
1 i: h( U- \- S: g% f; e4 Q
// Default settings. Used when resetting EEPROM. Change to desired name in defaults.h+ h7 I* O% m- U/ A
// 默認(rèn)設(shè)置。在重置eepm時(shí)使用。在defaults.h改變想要的名字
& f0 @; [! b- s8 w6 R8 s& N' P; a& k2 s3 \- R% T% A( d: k) q
#define DEFAULTS_GENERIC
2 @! m1 o; B$ n( l* g2 q% v
$ S) l) U. f6 [- X9 E0 ]// Serial baud rate1 v; y& s) o6 @. E# L" c9 l
#define BAUD_RATE 115200                //配置串口波特率115200
  ?+ e% o: `1 s$ j# y+ ]' L/ A( s
, s1 P9 f# K! H9 F( A' G* V' b) c( c// Default cpu mappings. Grbl officially supports the Arduino Uno only. Other processor types6 i6 V* H% ^1 h# S
// may exist from user-supplied templates or directly user-defined in cpu_map.h( F# S1 W6 u; o' D6 }6 X, f
//默認(rèn)cpu映射。Grbl正式支持Arduino Uno。其他類(lèi)型的處理器可能存在cpu_map.h直接從用戶(hù)提供的模板或用戶(hù)定義的
7 h9 p: y, ]* M) x2 o5 o- g( g( n! z) c3 o: _9 S# B8 g8 x
#define CPU_MAP_ATMEGA328P // Arduino Uno CPU+ j1 K3 w$ O( B! \

3 q$ ~, a: x# Y4 t6 ?( D// Define realtime command special characters. These characters are 'picked-off' directly from the
% g7 ?$ B% O3 r- v9 \9 z2 D7 P// serial read data stream and are not passed to the grbl line execution parser. Select characters
  \! c2 e4 Q# g5 k* Q8 c// that do not and must not exist in the streamed g-code program. ASCII control characters may be
! r0 l- e8 f) s. l2 E: o// used, if they are available per user setup. Also, extended ASCII codes (>127), which are never in & j/ m8 l. _4 a6 N3 }2 }
// g-code programs, maybe selected for interface programs.
# A6 M: e4 z$ a2 }// NOTE: If changed, manually update help message in report.c.2 y" r8 r- b( h3 |4 m+ |7 e
7 g" ^2 h( ]- c1 ?' Q
//定義實(shí)時(shí)命令特殊字符。這些字符是直接從“各個(gè)擊破”串口讀取數(shù)據(jù)流并沒(méi)有傳遞到grbl行執(zhí)行解析器。選擇角色
7 |6 K* C- F+ ~9 W5 `: g; X//不,不能存在于程序流刀位點(diǎn)。ASCII控制字符& k9 b0 O" z" R
//使用,如果他們是可用的每個(gè)用戶(hù)設(shè)置。同時(shí),擴(kuò)展的ASCII碼(> 127),從來(lái)沒(méi)有
# {( t* Q5 a  j' j! ~" h/ F//刀位點(diǎn)的程序,也許選擇界面程序。" q/ ~9 ]5 b  z) ~
//注意:如果改變,手動(dòng)更新report.c幫助信息。
! \! z. s( V3 s" y  L$ Z" @! ]; Y: o* Q: ]9 j. ]0 x0 a! u; W2 t) a
#define CMD_STATUS_REPORT '?'
3 c8 {1 g7 T3 h#define CMD_FEED_HOLD '!'9 Z, v) [7 l) M
#define CMD_CYCLE_START '~'
) R( u7 f5 u. `7 N9 V#define CMD_RESET 0x18 // ctrl-x.  B; v5 ]1 A0 b6 r
#define CMD_SAFETY_DOOR '@'
. q) f3 P6 x. l6 t; y# V
; E0 g; k* I9 _  I$ }// If homing is enabled, homing init lock sets Grbl into an alarm state upon power up. This forces
; W' I2 J! c1 O+ U$ x5 ]9 I2 r- n// the user to perform the homing cycle (or override the locks) before doing anything else. This is
: C' M+ `; z% q: o! S) `. i5 B// mainly a safety feature to remind the user to home, since position is unknown to Grbl.
$ M0 X+ M# O- B4 U5 j( u& F: K( d/ e- g" n; `7 j) c# F3 q
//如果啟用了回原點(diǎn),導(dǎo)航初始化鎖集Grbl進(jìn)入警報(bào)狀態(tài)啟動(dòng)。這就迫使
) P% G) l  I! }. u$ r5 E7 N//用戶(hù)執(zhí)行歸航周期(或覆蓋鎖)在做任何其他事情之前。這是
* O. E- \; p; l1 `* t//主要安全功能,提醒用戶(hù)家里,因?yàn)镚rbl位置是未知的。3 O+ b: f. g% n: ~

' v2 o& A: Q- B+ ?! H# p#define HOMING_INIT_LOCK // Comment to disable
: z% H/ s. E+ E+ @0 P: R* E1 h( v5 Y$ R" ]
// Define the homing cycle patterns with bitmasks. The homing cycle first performs a search mode
4 P6 x! ?! f% Z  U3 S// to quickly engage the limit switches, followed by a slower locate mode, and finished by a short/ n3 ^6 \1 X! r6 J# l
// pull-off motion to disengage the limit switches. The following HOMING_CYCLE_x defines are executed ) |. b% v$ ^5 G5 U+ c# Y6 v4 m
// in order starting with suffix 0 and completes the homing routine for the specified-axes only. If
$ j" E* `$ Z* Y% z// an axis is omitted from the defines, it will not home, nor will the system update its position.
/ w. T4 g2 P0 N// Meaning that this allows for users with non-standard cartesian machines, such as a lathe (x then z,
& [) a6 P7 V5 n& N0 k" q// with no y), to configure the homing cycle behavior to their needs. : ?4 O' y- v. x9 M( k
// NOTE: The homing cycle is designed to allow sharing of limit pins, if the axes are not in the same
# h) F* H: [' v8 @( r8 f// cycle, but this requires some pin settings changes in cpu_map.h file. For example, the default homing7 s+ e# g: z0 E" i. b! |) G( @
// cycle can share the Z limit pin with either X or Y limit pins, since they are on different cycles.
4 T6 ]  s3 P, p$ t1 _* }2 ^( P3 N) M// By sharing a pin, this frees up a precious IO pin for other purposes. In theory, all axes limit pins
. o' j: j8 t: o: s7 [// may be reduced to one pin, if all axes are homed with seperate cycles, or vice versa, all three axes
: y9 K/ j9 |9 v% s7 E// on separate pin, but homed in one cycle. Also, it should be noted that the function of hard limits
0 O, \5 U+ r( j% ~: l// will not be affected by pin sharing.; A3 _' t( K8 d* y6 N
//定義導(dǎo)航循環(huán)模式的位掩碼。歸航周期首先執(zhí)行一個(gè)搜索模式% R# ?& V1 M2 S* e. A
//快速進(jìn)行限位開(kāi)關(guān),其次是較慢的定位模式,完成了由一個(gè)短
& u( F7 k  q. g0 ~//拖出運(yùn)動(dòng)脫離限位開(kāi)關(guān)。以下HOMING_CYCLE_x定義執(zhí)行8 I$ s& ~/ l' D+ X
//為了與后綴0開(kāi)始并完成specified-axes只尋的例程。如果% ~& I$ j! |1 z  u6 O( l
//定義省略一個(gè)軸,它會(huì)不在家,也不會(huì)系統(tǒng)更新它的位置。
( g# ~% Q2 E& D: z5 ~  V//意義,這允許用戶(hù)與非標(biāo)準(zhǔn)笛卡爾的機(jī)器,比如車(chē)床(x,z,2 n" o( J) X% b- g. E  x6 u, P. k) R
//沒(méi)有y),配置導(dǎo)航循環(huán)行為對(duì)他們的需求。
& U  m, O1 _3 _& N4 W//注意:歸航周期允許共享限制針,如果軸不相同2 Y6 ?- e6 A6 j) U; M/ x
//循環(huán),但這需要一些銷(xiāo)設(shè)置cpu_map的變化。h文件。例如,默認(rèn)的導(dǎo)航  n6 L( i+ U! c1 T1 M) I7 k! K
//循環(huán)可以分享Z限位銷(xiāo)X或Y限制針,因?yàn)樗鼈兪窃诓煌闹芷凇?br /> ! ]& {! k% R0 H9 N' b' Y0 q//通過(guò)共享一個(gè)銷(xiāo),這騰出寶貴的IO銷(xiāo)用于其他目的。從理論上講,所有軸限制別針$ t& b+ L% x/ F. O# m% n
//可能會(huì)減少到一個(gè)銷(xiāo),如果所有軸與分離周期居住的地方,反之亦然,所有三個(gè)軸
* F- J+ w" {) H7 y! U- \- \//在不同銷(xiāo),但這時(shí)候一個(gè)周期。同時(shí),應(yīng)該注意的是,硬限制的功能0 z2 A" o8 B) j( a7 M% J
//將不會(huì)影響銷(xiāo)共享。- H8 k8 W4 P# P" Z0 P& N2 t
//注意:默認(rèn)設(shè)置為一個(gè)傳統(tǒng)的硬件數(shù)控機(jī)器。z軸首次明確,其次是X和Y。' L, X' r& k+ {; {- h  ]
  F( F. W; u) v( G0 M- [) R+ ^
// NOTE: Defaults are set for a traditional 3-axis CNC machine. Z-axis first to clear, followed by X & Y.
: d7 ]4 F7 X9 D9 l+ b( n' O#define HOMING_CYCLE_0 (1<<Z_AXIS)                // REQUIRED: First move Z to clear workspace. 第一步Z清除工作區(qū)。8 I. w6 T) w7 \6 b
#define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // OPTIONAL: Then move X,Y at the same time.然后X,Y在同一時(shí)間。; r6 C6 B: a' N0 R# o  d; m
// #define HOMING_CYCLE_2                         // OPTIONAL: Uncomment and add axes mask to enable
5 v$ K2 W( ^/ u& X1 D" X
: D2 {) c0 Y  o  @// Number of homing cycles performed after when the machine initially jogs to limit switches., }8 Q6 I9 i! r  R' p2 G+ {
// This help in preventing overshoot and should improve repeatability. This value should be one or % c; v, m4 o% b  i! |# {/ _( k( w
// greater.
4 M" c' M# r# ~. E$ X9 Z3 ^//執(zhí)行回原點(diǎn)循環(huán)次數(shù)后,當(dāng)機(jī)器最初慢跑限位開(kāi)關(guān)。這個(gè)幫助防止過(guò)度,應(yīng)該提高重復(fù)性。這個(gè)值應(yīng)該是一個(gè)或大。
8 _7 p; u5 k* n& C, ~- x2 N5 a& U: K8 }6 f# ^! c8 T: N, i
#define N_HOMING_LOCATE_CYCLE 1 // Integer (1-128)
) ~. {& ]5 ]: Y0 u
, `- t# F9 w) \* j# U// After homing, Grbl will set by default the entire machine space into negative space, as is typical
7 S4 @4 b3 m  H6 t, M// for professional CNC machines, regardless of where the limit switches are located. Uncomment this
5 Z; g( B8 l/ n// define to force Grbl to always set the machine origin at the homed location despite switch orientation.7 d  T. S, j0 H2 \
. e! {; H6 F" @: U  t, O8 F
//導(dǎo)航后,默認(rèn)Grbl將整個(gè)機(jī)器空間留白,是典型的專(zhuān)業(yè)數(shù)控機(jī)器,不管限位開(kāi)關(guān)所在的地方。
/ y& `; c& H7 x  I" K//取消這定義迫使Grbl總是在這時(shí)候位置設(shè)置機(jī)器原點(diǎn)盡管開(kāi)關(guān)方向。
& u0 l! g7 D+ a' F0 s0 o
7 K4 g6 `2 |8 Z% w% O// #define HOMING_FORCE_SET_ORIGIN // Uncomment to enable.
) M' a4 Z  e5 i! t* `
! E' T3 s& ^. K
; `5 n- p' u5 i1 d; M// Number of blocks Grbl executes upon startup. These blocks are stored in EEPROM, where the size
+ `/ u3 p- D+ o2 Z- T. z( G// and addresses are defined in settings.h. With the current settings, up to 2 startup blocks may
. W: T5 q9 x; S4 j7 a: b// be stored and executed in order. These startup blocks would typically be used to set the g-code2 m& t9 f7 t, Y' g
// parser state depending on user preferences.
' y5 ?- @) v  @3 a" i/ U. k7 N0 n3 _, P
//塊Grbl啟動(dòng)時(shí)執(zhí)行的數(shù)量。這些塊存儲(chǔ)在eepm,大小
: `8 h4 v; p+ T# G9 f2 k, q) z/ X: S1 v//和地址在settings.h中定義。與當(dāng)前設(shè)置,可能2啟動(dòng)塊
7 l. ?# ]5 E( ~//存儲(chǔ)和執(zhí)行。這些啟動(dòng)塊通常被用來(lái)設(shè)置刀位點(diǎn)0 }$ ]  y( ?+ W+ e
//解析器的狀態(tài)取決于用戶(hù)首選項(xiàng)。
- C4 d7 v# x6 f; V! e# A& Z7 a
- _" B" b6 _- S. `#define N_STARTUP_LINE 2 // Integer (1-2)
% c* ?# e: l- Z% R9 d# q# B
7 r2 Z$ O9 F, e// Number of floating decimal points printed by Grbl for certain value types. These settings are ! o+ J+ u0 u; G2 @5 j- E
// determined by realistic and commonly observed values in CNC machines. For example, position9 q% v2 ~/ p! Q: l& Y8 ?
// values cannot be less than 0.001mm or 0.0001in, because machines can not be physically more; J) _4 Y1 p7 K1 w/ D! d: ~
// precise this. So, there is likely no need to change these, but you can if you need to here.  W: L  ], a4 I" e( I: U
// NOTE: Must be an integer value from 0 to ~4. More than 4 may exhibit round-off errors.  S+ Y* Z7 o- {8 w9 |4 n
" `+ T1 p7 u' _+ T# u, a0 M
// Grbl浮動(dòng)小數(shù)點(diǎn)的數(shù)字印刷的特定的值類(lèi)型。這些設(shè)置是
" v/ C! [% k/ q6 R//一般由現(xiàn)實(shí)和觀測(cè)值在數(shù)控機(jī)器。例如,位置
0 O8 o6 P$ ^5 p" z//值不能小于0.001毫米或0.0001,因?yàn)闄C(jī)器不能身體更多" R( p* ?% t) j( p4 f7 P+ [
//精確。因此,有可能不需要改變這些,但你可以在這里如果你需要。% Q, `+ Q  ]* s& D
//注意:必須是一個(gè)整數(shù)值從0 ~ 4。超過(guò)4可能出現(xiàn)舍入錯(cuò)誤。
, |( c" ~. @  d2 D2 s
. F& ?3 [& @' X) H#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 協(xié)調(diào)或位置價(jià)值英寸. T; S/ m: Q! W! F* E- r' D7 R
#define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 協(xié)調(diào)在毫米或位置價(jià)值
% W7 L5 x3 B# F, J#define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分鐘的速度值
7 p) A& {4 l, v3 V+ y  K#define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分鐘
9 k; M# D- Z" t! B8 v; t#define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 對(duì)浮點(diǎn)小數(shù)設(shè)置值8 m( q$ w* g) o1 M6 E& D- Z0 _
2 ]5 B. l0 x6 m/ f
// If your machine has two limits switches wired in parallel to one axis, you will need to enable
9 a# z* ^" N! N6 o& J+ ^' [// this feature. Since the two switches are sharing a single pin, there is no way for Grbl to tell6 S6 h9 m/ d# t% C0 O" H8 \( w
// which one is enabled. This option only effects homing, where if a limit is engaged, Grbl will
+ ~7 z$ @' i0 Q( T// alarm out and force the user to manually disengage the limit switch. Otherwise, if you have one
+ l2 x3 ~9 U3 [3 E- r2 s// limit switch for each axis, don't enable this option. By keeping it disabled, you can perform a
' \6 n( A  ^4 e+ `// homing cycle while on the limit switch and not have to move the machine off of it.  e% u; d9 }  j6 m
7 g7 `3 l+ B2 E. j
//如果你的機(jī)器有兩個(gè)極限開(kāi)關(guān)連接在平行于一個(gè)軸,您需要啟用) r+ K. e7 V1 x
//這個(gè)特性。自從兩個(gè)交換機(jī)共享一個(gè)銷(xiāo),沒(méi)有辦法Grbl告訴
0 r3 G! E- E7 r8 Y* q( q3 T//啟用哪一個(gè)。此選項(xiàng)僅影響歸航,如果限制,Grbl意志) K2 G6 K7 u: b$ M3 C* C
//報(bào)警,迫使用戶(hù)手動(dòng)松開(kāi)限位開(kāi)關(guān)。否則,如果你有一個(gè)
" V5 Y! \* V# {//為每個(gè)軸限位開(kāi)關(guān),不啟用該選項(xiàng)。通過(guò)保持禁用,您可以執(zhí)行
( n, c3 j$ z1 \//導(dǎo)航循環(huán)在限位開(kāi)關(guān)并沒(méi)有將這臺(tái)機(jī)器。' |8 {5 n, `$ E) B' J& Z

; H4 x! R+ n! ?' K. b// #define LIMITS_TWO_SWITCHES_ON_AXES# r8 A3 u) h  F  c; q( b
1 J3 d! }( V  p! r1 ]
// Allows GRBL to track and report gcode line numbers.  Enabling this means that the planning buffer* [6 I8 o: f/ O9 A2 L2 A
// goes from 18 or 16 to make room for the additional line number data in the plan_block_t struct# c. T2 ^9 M+ n6 C

8 u' e. c1 q3 h8 g5 f2 O6 i' b; H+ Q//允許GRBL跟蹤和報(bào)告gcode行號(hào)。使這意味著計(jì)劃緩沖從18歲或16歲,為額外的行號(hào)plan_block_t結(jié)構(gòu)中的數(shù)據(jù): C& |9 A; P6 E, U; T# G

: u" k% d8 u3 c// #define USE_LINE_NUMBERS // Disabled by default. Uncomment to enable.! e" P! k" j6 d; Q- r7 ~
& v3 P# n. S* ~+ p( `3 z4 c/ a
// Allows GRBL to report the real-time feed rate.  Enabling this means that GRBL will be reporting more
# p$ T8 S- d0 k8 P1 d/ \// data with each status update.
! ?, {/ q$ R/ Z/ F1 i1 |+ S// NOTE: This is experimental and doesn't quite work 100%. Maybe fixed or refactored later.  e: v3 ?) r& X! Z6 \
//允許GRBL報(bào)告實(shí)時(shí)進(jìn)給速率。使這意味著GRBL將報(bào)告數(shù)據(jù)和狀態(tài)更新。
, G0 B& A0 @7 T/ [' B1 L3 N" I//注意:這是實(shí)驗(yàn)和100%沒(méi)有工作。也許以后固定或重構(gòu)。9 |" x4 e& x! L% N

# K: D  C9 y8 i: `: D' t7 l// #define REPORT_REALTIME_RATE // Disabled by default. Uncomment to enable.
; c; {- r+ L+ ^% U/ O% h4 B7 H
+ f( x; f$ v# `8 I! J9 l// Upon a successful probe cycle, this option provides immediately feedback of the probe coordinates' A5 R  A+ v2 W# [, S. m$ @4 U4 L
// through an automatically generated message. If disabled, users can still access the last probe
1 L$ N* N. W8 Q" s' v// coordinates through Grbl '$#' print parameters.& O1 b( z6 @( m* i5 \3 b
//在一個(gè)成功的調(diào)查周期,這個(gè)選項(xiàng)提供立即反饋的探測(cè)器坐標(biāo)
, {! y* j+ q6 _, `; y6 {! _//通過(guò)一個(gè)自動(dòng)生成的消息。如果禁用,用戶(hù)仍然能夠訪問(wèn)調(diào)查
: i$ e7 A& J. W) k//坐標(biāo)通過(guò)Grbl $ #的打印參數(shù)。, Y. t2 }3 a7 {% f
$ i7 O- S7 V% B+ h  V1 X
#define MESSAGE_PROBE_COORDINATES // Enabled by default. Comment to disable.* b7 [6 \6 l: o+ f

% F) q) D2 A5 b  L4 Z5 R7 x// Enables a second coolant control pin via the mist coolant g-code command M7 on the Arduino Uno
; v$ ]7 Y  p, i. Z9 U% t' N* t" n// analog pin 5. Only use this option if you require a second coolant control pin., n4 l* J1 A6 {. w
// NOTE: The M8 flood coolant control pin on analog pin 4 will still be functional regardless.
1 L8 D8 ~* y8 G6 _' O( V+ `// #define ENABLE_M7 // Disabled by default. Uncomment to enable." Q5 c) Q7 B6 d  I/ |  I. a" e! U1 d2 W
) s* @, U/ _; }7 ^6 s
// This option causes the feed hold input to act as a safety door switch. A safety door, when triggered,6 C( }! E6 [3 c/ V9 n7 }
// immediately forces a feed hold and then safely de-energizes the machine. Resuming is blocked until
( g7 s  L' {% \/ k// the safety door is re-engaged. When it is, Grbl will re-energize the machine and then resume on the. X; ~8 G1 o" I: F9 @7 |) ]
// previous tool path, as if nothing happened.5 B$ a- v2 A% g- G  J) D
// #define ENABLE_SAFETY_DOOR_INPUT_PIN // Default disabled. Uncomment to enable.
7 p" d6 S& N. y8 Q% o6 t( u4 _; A8 b5 ^. e4 }
// After the safety door switch has been toggled and restored, this setting sets the power-up delay
- |# |( a; G7 @; \// between restoring the spindle and coolant and resuming the cycle.  W9 ?4 Y) O/ [+ E! M+ Y: ^
// NOTE: Delay value is defined in milliseconds from zero to 65,535.
8 b5 ^" U4 m1 l. ^
6 t. ~- d- L; S8 J. h//定義導(dǎo)航循環(huán)模式的位掩碼。歸航周期首先執(zhí)行一個(gè)搜索模式
' L# Q3 Q$ b5 ?* Q7 H: j/ B//快速進(jìn)行限位開(kāi)關(guān),其次是較慢的定位模式,完成了由一個(gè)短# P# m+ X8 `( P3 K( z8 |
//拖出運(yùn)動(dòng)脫離限位開(kāi)關(guān)。以下HOMING_CYCLE_x定義執(zhí)行2 T1 j% U( _) |/ b4 J3 R
//為了與后綴0開(kāi)始并完成specified-axes只尋的例程。如果: i  U) |# h- F8 }0 `
//定義省略一個(gè)軸,它會(huì)不在家,也不會(huì)系統(tǒng)更新它的位置。
1 u; q- ?9 z0 T3 C//意義,這允許用戶(hù)與非標(biāo)準(zhǔn)笛卡爾的機(jī)器,比如車(chē)床(x,z,* |7 s8 v& i* \, k0 H+ @
//沒(méi)有y),配置導(dǎo)航循環(huán)行為對(duì)他們的需求。
: r, {/ V3 O; _8 i9 W6 N5 S//注意:歸航周期允許共享限制針,如果軸不相同$ ]1 @) Y% M) e# M& d
//循環(huán),但這需要一些銷(xiāo)設(shè)置cpu_map的變化。h文件。例如,默認(rèn)的導(dǎo)航
0 \% R3 Y* D- a: i% K' I$ a//循環(huán)可以分享Z限位銷(xiāo)X或Y限制針,因?yàn)樗鼈兪窃诓煌闹芷凇?font class="jammer">. N' D* L$ I$ [/ q8 m& i% h" ?( K
//通過(guò)共享一個(gè)銷(xiāo),這騰出寶貴的IO銷(xiāo)用于其他目的。從理論上講,所有軸限制別針
# ~+ Q9 Q  [- \//可能會(huì)減少到一個(gè)銷(xiāo),如果所有軸與分離周期居住的地方,反之亦然,所有三個(gè)軸
6 a' S" Y+ \( a5 n) s& R//在不同銷(xiāo),但這時(shí)候一個(gè)周期。同時(shí),應(yīng)該注意的是,硬限制的功能
2 m# \- S3 R. W+ G6 }; m//將不會(huì)影響銷(xiāo)共享。, K! X0 K- x# W9 X* l9 k* _
//注意:默認(rèn)設(shè)置為一個(gè)傳統(tǒng)的硬件數(shù)控機(jī)器。z軸首次明確,其次是X和Y。4 |: l# w. }9 ]6 z: [

; @9 H& x6 t) b
# u5 `! t  A: _2 n#define SAFETY_DOOR_SPINDLE_DELAY 4000# S9 H& _" M% s' E) N; C) r
#define SAFETY_DOOR_COOLANT_DELAY 1000: f  t" P4 W, J+ z" a

7 P9 I  r+ T! ]- Z' R9 @// Enable CoreXY kinematics. Use ONLY with CoreXY machines.
) F0 a& t, I* Y6 H5 l) J// IMPORTANT: If homing is enabled, you must reconfigure the homing cycle #defines above to   F- b$ d- v/ c# ]" f
//啟用CoreXY運(yùn)動(dòng)學(xué)。只使用與CoreXY機(jī)器。6 Q, U# ]1 k  h. n  F9 F
//重要:如果啟用了自動(dòng)尋的,你必須重新配置導(dǎo)航循環(huán)#定義上面/ I  n2 Y8 K7 [5 M& K2 W

! v& K! u. N1 D5 Q* t// #define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS)1 _. |  B6 H; ]2 f, Y

5 P9 W8 j  U* }/ [  p; Z7 M& L! m// NOTE: This configuration option alters the motion of the X and Y axes to principle of operation; D* U7 M( E: C6 P3 s" M
// defined at (http://corexy.com/theory.html). Motors are assumed to positioned and wired exactly as2 u% x6 c+ N1 H: T9 T) K1 D& L) c* t
// described, if not, motions may move in strange directions. Grbl assumes the CoreXY A and B motors
  x% G- Y+ y8 b) Z// have the same steps per mm internally.
5 \1 \( \6 Y. ^4 `; I. l, s4 \//注意:這種配置選項(xiàng)改變X和Y軸的運(yùn)動(dòng)原理,操作
: O( U/ n8 C" `3 U//定義(http://corexy.com/theory.html)。汽車(chē)被認(rèn)為定位和連接一樣
6 e' |" \+ U! N1 a//描述,如果沒(méi)有,運(yùn)動(dòng)可能會(huì)奇怪的方向移動(dòng)。A和B Grbl假設(shè)CoreXY馬達(dá)
3 L& U  N- f3 v8 V6 {. V//每毫米內(nèi)部有相同的步驟。
/ `. K6 V- g. S3 L3 Q
; Q3 L0 g' m: {* f- i; r# b) t  I/ l// #define COREXY // Default disabled. Uncomment to enable.
1 K9 {7 }! a/ ~- b4 g4 o" E0 ^) y& p$ e5 I. W; a
// Inverts pin logic of the control command pins. This essentially means when this option is enabled! f+ p: j" ?: p% A
// you can use normally-closed switches, rather than the default normally-open switches.4 y) [/ f6 H/ `4 T4 p3 B& x1 i
// NOTE: Will eventually be added to Grbl settings in v1.0.# Z6 x5 u( @- [5 _
//反轉(zhuǎn)針?shù)N邏輯的控制命令。這實(shí)質(zhì)上意味著當(dāng)啟用這個(gè)選項(xiàng)
% n2 S' a1 d! y0 F7 h6 R//可以使用閉合開(kāi)關(guān),而不是默認(rèn)的常開(kāi)開(kāi)關(guān)。- @1 E4 Y- Z! [3 h; d3 k" h1 F
//注意:最終將被添加到在v1.0 Grbl設(shè)置。
; z' Q9 c# M4 O4 h) m5 r5 Z$ m
% A2 X$ B, m5 ^  ?, D* h4 Y// #define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.
: \3 E( v! ^* g+ G4 E# [7 }% L1 e0 C* }! H3 }2 X7 i7 f
// Inverts the spindle enable pin from low-disabled/high-enabled to low-enabled/high-disabled. Useful
0 P5 r' g9 J8 H# @1 k7 F// for some pre-built electronic boards.9 d6 e0 |) D  b1 a% {
// NOTE: If VARIABLE_SPINDLE is enabled(default), this option has no effect as the PWM output and
9 F4 X* p4 g9 ~5 S. @9 e1 y4 S3 K& r// spindle enable are combined to one pin. If you need both this option and spindle speed PWM, 4 j% ?" r: t5 m2 X3 w
// uncomment the config option USE_SPINDLE_DIR_AS_ENABLE_PIN below.
' H' e7 {9 e6 q6 e: y0 g//反轉(zhuǎn)主軸使銷(xiāo)從low-disabled / high-enabled low-enabled / high-disabled。有用的
3 V- Q) Q: [. Q//預(yù)構(gòu)建的電子板。
7 k7 p% S) N4 n//注意:如果啟用了VARIABLE_SPINDLE(默認(rèn)),這個(gè)選項(xiàng)作為PWM輸出并沒(méi)有影響
) M6 Y7 B9 B) [' e//銷(xiāo)軸使結(jié)合。如果你需要這個(gè)選項(xiàng)和主軸轉(zhuǎn)速PWM,
* j* \6 _+ R' j5 O0 j7 Y//取消注釋以下配置選項(xiàng)USE_SPINDLE_DIR_AS_ENABLE_PIN
) F3 B; ~" s# M7 T, g4 ]/ k2 i) U5 E) |1 H% t
// #define INVERT_SPINDLE_ENABLE_PIN // Default disabled. Uncomment to enable.  |* E; _" [% z7 z7 J$ ~

5 [, [3 w5 y: E9 O4 U4 F, }- @2 x// Enable control pin states feedback in status reports. The data is presented as simple binary of8 ], g- ]# l2 {: t
// the control pin port (0 (low) or 1(high)), masked to show only the input pins. Non-control pins on the 4 h) u- x$ M* s0 q
// port will always show a 0 value. See cpu_map.h for the pin bitmap. As with the limit pin reporting,7 y! o! W" ]- `, z7 I( A
// we do not recommend keeping this option enabled. Try to only use this for setting up a new CNC.& [9 p% H4 [% o1 e2 _0 ~$ k! J: Z
//啟用控制銷(xiāo)狀態(tài)反饋狀態(tài)報(bào)告。作為簡(jiǎn)單的二進(jìn)制數(shù)據(jù)- U2 y" I1 Y, [9 |6 Y
//控制針端口(0(低)或1(高)),蒙面,只顯示輸入插腳。非控制性針上
1 x2 f* b8 L" T* ]" v- [+ G//端口總是顯示0值。看到cpu_map。針位圖h。與限制銷(xiāo)報(bào)告,' o9 }  {+ m8 Q, \! K- s
//我們不推薦保持啟用這個(gè)選項(xiàng)。盡量只使用這個(gè)設(shè)置一個(gè)新的數(shù)控。+ s* Y9 p% \  D7 S, x2 ~

, R0 A) d0 l4 p// #define REPORT_CONTROL_PIN_STATE // Default disabled. Uncomment to enable.2 _+ R1 ~5 V7 F7 B! M% c/ C# r" C% V

  T% ~& }; c- Y// When Grbl powers-cycles or is hard reset with the Arduino reset button, Grbl boots up with no ALARM
/ ?6 N" E9 C: ^8 v+ v5 K3 C; V; s, X% t// by default. This is to make it as simple as possible for new users to start using Grbl. When homing
9 G/ R, C: A: K- C9 M// is enabled and a user has installed limit switches, Grbl will boot up in an ALARM state to indicate
  Z4 X# [) ]% ~# N0 O1 w& t% j// Grbl doesn't know its position and to force the user to home before proceeding. This option forces5 V* S9 `" o. o! G1 L- _
// Grbl to always initialize into an ALARM state regardless of homing or not. This option is more for
+ j' b# ^8 w, I( `4 F4 \// OEMs and LinuxCNC users that would like this power-cycle behavior.
& [$ k# ^+ d; Z1 m0 e//當(dāng)Grbl powers-cycles還是硬重置Arduino復(fù)位按鈕,Grbl啟動(dòng)沒(méi)有報(bào)警
9 k6 j) c5 B! Q3 \% E. U//默認(rèn)情況下。這是為了讓新用戶(hù)盡可能簡(jiǎn)單使用Grbl開(kāi)始。當(dāng)歸航" u# C8 X# Y6 l; z* C
//啟用和用戶(hù)安裝限位開(kāi)關(guān),Grbl將啟動(dòng)報(bào)警狀態(tài)指示8 y# h2 Z1 u2 }
// Grbl不知道它的位置,迫使用戶(hù)在繼續(xù)之前回家。這個(gè)選項(xiàng)部隊(duì)
; ]; R0 Z* _/ X+ c; u0 L  p// Grbl總是初始化進(jìn)入警報(bào)狀態(tài)不管歸航。這個(gè)選項(xiàng)是更多
8 }0 z% G7 Y/ D" _* O! K//原始設(shè)備制造商和LinuxCNC用戶(hù)這樣的控制行為。6 |: \3 Y0 p" o  b: Q1 }

+ m7 u1 q" G$ {7 N( |+ G// #define FORCE_INITIALIZATION_ALARM // Default disabled. Uncomment to enable.
( B/ R- X  s- ^- O9 F. w6 {  ?: U+ a: e* G  [
// ---------------------------------------------------------------------------------------0 Y+ k$ K( @) H5 ?/ w* [! g
// ADVANCED CONFIGURATION OPTIONS://高級(jí)配置選項(xiàng):. g% f2 M6 R# ^% J( ]! O$ a
. N6 k; E5 S7 k- n% ]
// Enables minimal reporting feedback mode for GUIs, where human-readable strings are not as important.  t( n& g) B( O: Y$ Z: {4 p
// This saves nearly 2KB of flash space and may allow enough space to install other/future features.# v' f4 S$ c8 @3 U/ n- [
// GUIs will need to install a look-up table for the error-codes that Grbl sends back in their place.
7 L' {) g+ o- J7 d% C// NOTE: This feature is new and experimental. Make sure the GUI you are using supports this mode.$ w" ?# X* N6 h& l! ~) _; p

% l  K  M% l; U5 r( p// gui允許最小的報(bào)告反饋模式,人類(lèi)可讀的字符串在哪里不重要。4 Z' R6 T' s$ E4 O4 u
//這個(gè)節(jié)省近2 kb的閃存空間,允許足夠的空間來(lái)安裝其他/未來(lái)的功能。
5 [+ f2 h" @" X' p" j2 `+ @* Z// gui需要安裝一個(gè)查找表的錯(cuò)誤代碼Grbl發(fā)回。) C) m- N3 S3 E6 t* H+ w9 s/ h
//注意:此功能是新的和實(shí)驗(yàn)。確保您使用的GUI支持這種模式。; h! k% F; \( U9 I/ D" [$ P+ O
! j. ]( T* J0 E  ?# k0 O4 v
// #define REPORT_GUI_MODE // Default disabled. Uncomment to enable.5 |" ^0 M' t; v/ @4 {1 h( D7 I
1 x( Z3 |5 z& {- b3 M. \
// The temporal resolution of the acceleration management subsystem. A higher number gives smoother
8 u# A$ `! L- @+ `( n5 z0 g// acceleration, particularly noticeable on machines that run at very high feedrates, but may negatively0 H  ~* Z& q& N% X& j1 f/ u3 T
// impact performance. The correct value for this parameter is machine dependent, so it's advised to& V! O( H* d4 w9 c- X1 [
// set this only as high as needed. Approximate successful values can widely range from 50 to 200 or more.7 Y: n2 L' @7 q: b+ x
// NOTE: Changing this value also changes the execution time of a segment in the step segment buffer. 4 t" b7 j' U( T) ~. \% C6 T" v
// When increasing this value, this stores less overall time in the segment buffer and vice versa. Make
5 u# h9 m  O0 H, c// certain the step segment buffer is increased/decreased to account for these changes.# d3 [# f. Z1 j( o5 U
//加速度的時(shí)間分辨率管理子系統(tǒng)。更多更平穩(wěn); l; z8 f/ a+ U: G/ e: Q
//加速度,特別明顯的機(jī)器上,運(yùn)行在非常高的進(jìn)料速度,但可能負(fù)面( A  A4 @" Q% M7 v5 N8 Z4 v# e
//影響性能。正確的值為這個(gè)參數(shù)是依賴(lài)于機(jī)器的,所以建議' \3 G& \. q0 _) `* N# I
//這只設(shè)置為高。近似成功的價(jià)值觀可以廣泛的范圍從50到200或者更多。
1 H# G4 Q# k' U( r//注意:改變這個(gè)值也變化的部分步驟的執(zhí)行時(shí)間緩沖。+ e2 {! V* I& m) J
//增加這個(gè)值時(shí),這個(gè)商店部分緩沖區(qū)的總時(shí)間減少,反之亦然。使
2 N, B. K% v) B9 Z$ D//特定步驟段緩沖是考慮這些變化增加/減少。' k' i3 i$ t+ M2 p

0 d) e. R$ @$ Q8 `. A0 @#define ACCELERATION_TICKS_PER_SECOND 100  //加速度的時(shí)間分辨率管理子系統(tǒng)。更多更平穩(wěn)7 n' k% a5 A* l7 S
; a5 q" l! {; J* [! v2 ?
// Adaptive Multi-Axis Step Smoothing (AMASS) is an advanced feature that does what its name implies,
8 `. X2 O% C' m- f3 A" `# Q) o// smoothing the stepping of multi-axis motions. This feature smooths motion particularly at low step8 z1 w: A8 z! c+ n
// frequencies below 10kHz, where the aliasing between axes of multi-axis motions can cause audible * G' [  R/ @, M. _, @: Y1 y
// noise and shake your machine. At even lower step frequencies, AMASS adapts and provides even better* _# y$ [4 }8 g4 t
// step smoothing. See stepper.c for more details on the AMASS system works.
3 q% i( J  A  C9 `//自適應(yīng)多軸步平滑(積累)是一種先進(jìn)的功能,它的名字所暗示的那樣,; T" x& S( \  z  Y# h; o
//平滑的多軸步進(jìn)運(yùn)動(dòng)。這個(gè)特性平滑運(yùn)動(dòng)尤其是在低一步/ |) H  E+ G$ u) \
//頻率低于10 khz,軸之間的混疊的多軸運(yùn)動(dòng)可能導(dǎo)致音響' g" j# V  d% K* k
//噪音和震動(dòng)你的機(jī)器。在更低的頻率步,積累適應(yīng)并提供更好
: R! B2 s" V8 t' M  d6 n! r6 ^//步驟平滑。看到步進(jìn)。c更多細(xì)節(jié)的積累系統(tǒng)的工作原理。7 O  O/ S# G  V5 i' j
/ A% r0 G' S) k, Z2 Q
#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING  // Default enabled. Comment to disable.//自適應(yīng)多軸步平滑& z9 O0 ]# v7 c' h

/ l$ q; ]9 O* n3 o/ P$ W// Sets the maximum step rate allowed to be written as a Grbl setting. This option enables an error / A) Q4 Z* I* c- {, i! F7 ]: a
// check in the settings module to prevent settings values that will exceed this limitation. The maximum2 A' s  a* H# g! B
// step rate is strictly limited by the CPU speed and will change if something other than an AVR running. j& s5 S. _! R( b  W
// at 16MHz is used.
& {1 W, E  \/ m. _// NOTE: For now disabled, will enable if flash space permits.
' [& c" h8 M5 V/ D$ s' p7 r7 m8 U//設(shè)置最大一步速率可以寫(xiě)成Grbl設(shè)置。這個(gè)選項(xiàng)可以使一個(gè)錯(cuò)誤
6 k+ O5 t( Z7 {& l//設(shè)置模塊中檢查,防止設(shè)置值將超過(guò)這個(gè)限制。的最大
$ Z# v7 U% B2 v" Y3 A//步驟嚴(yán)格限制的CPU速度也會(huì)改變?nèi)绻瞧渌鸄VR運(yùn)行
6 C0 q1 z/ P# b  Z5 a) e; F//使用16兆赫。
' ]1 k. C% s9 T# r- a0 O//注意:現(xiàn)在殘疾,將使如果flash空間許可。
2 G' Y  _2 U& a) Q
6 w3 ]% e; C2 Q// #define MAX_STEP_RATE_HZ 30000 // Hz 設(shè)置最大一步速率
4 N4 ~) T- k9 a2 d' r1 ]# h4 U1 X, E  T7 E
// By default, Grbl sets all input pins to normal-high operation with their internal pull-up resistors2 {; g% {6 V: a! s6 F/ Y
// enabled. This simplifies the wiring for users by requiring only a switch connected to ground, ( c: ?) @! Q$ `/ U7 C4 F7 |' ]
// although its recommended that users take the extra step of wiring in low-pass filter to reduce
+ m/ p- F  S- L8 P. g- q// electrical noise detected by the pin. If the user inverts the pin in Grbl settings, this just flips' i2 h7 u( w/ ~0 ^0 |% i: A5 ?
// which high or low reading indicates an active signal. In normal operation, this means the user * E) @/ K0 i, Z- L% g# [# _9 i
// needs to connect a normal-open switch, but if inverted, this means the user should connect a 9 P3 P& k; I' I- A
// normal-closed switch.
5 z, t% u/ h  \( i' o// The following options disable the internal pull-up resistors, sets the pins to a normal-low
9 p2 n1 i  K& w" q: ^6 u" P% n* k// operation, and switches must be now connect to Vcc instead of ground. This also flips the meaning 7 ?6 h2 S  N& \) G# n) R; i) N
// of the invert pin Grbl setting, where an inverted setting now means the user should connect a
; I* {% x4 L( O% X# Z// normal-open switch and vice versa.
3 h! g5 q# N4 P0 p+ }5 y+ }0 Z) x// NOTE: All pins associated with the feature are disabled, i.e. XYZ limit pins, not individual axes.
( e* p" H- B5 o* c# a// WARNING: When the pull-ups are disabled, this requires additional wiring with pull-down resistors!. p, N3 p: Z+ U% [6 I! p1 C
//默認(rèn)情況下,Grbl所有輸入引腳設(shè)置為正常高操作的內(nèi)部上拉電阻# g7 P3 o) n+ [3 q! t
//啟用。這簡(jiǎn)化了布線為用戶(hù)只需要一個(gè)開(kāi)關(guān)連接到地面,
5 b3 q7 s1 I+ Q5 }//雖然其建議用戶(hù)采取額外的步驟,在低通濾波器來(lái)減少布線' I) o8 P# C# q! Q) `
//電噪音檢測(cè)銷(xiāo)。如果用戶(hù)反轉(zhuǎn)的銷(xiāo)Grbl設(shè)置,這只是翻轉(zhuǎn)  ?( H5 V) H" @3 Y2 N' w& ?
//讀高或低表明一個(gè)積極的信號(hào)。在正常操作中,這意味著用戶(hù)1 B' ~. ^2 ?$ J1 n: {* j
//需要連接一個(gè)常開(kāi)開(kāi)關(guān),但如果倒,這意味著用戶(hù)應(yīng)該連接1 i; j- X4 ~3 v- q- P: _
// normal-closed開(kāi)關(guān)。  \+ ~' p% n2 ^2 ^; F/ ]
//以下選項(xiàng)禁用內(nèi)部上拉電阻,一般低設(shè)置別針4 E) t& K2 d7 P3 m
//操作,現(xiàn)在開(kāi)關(guān)必須連接到Vcc代替地面。這也掀的意思3 `; U$ t; |1 J  E; x7 r- ]
//反銷(xiāo)Grbl設(shè)置,一個(gè)倒置的設(shè)置現(xiàn)在意味著用戶(hù)應(yīng)該連接( F6 Y, [2 f" j/ a& q7 |0 C
//常開(kāi)開(kāi)關(guān),反之亦然。
, x9 }. r% I4 C( W# Y//注意:所有針與功能被禁用,例如XYZ限制針,而不是單獨(dú)的軸。
/ r' f7 M( ~( g3 X* v( m//警告:引體向上被禁用時(shí),這需要額外的布線與下拉電阻!
4 q! H3 s6 |% \- C& Q$ A/ P. L; i: \: f# b& ]7 q4 n
//#define DISABLE_LIMIT_PIN_PULL_UP //以下選項(xiàng)禁用內(nèi)部上拉電阻" ]7 p" W" F1 K; o( n1 g/ `
//#define DISABLE_PROBE_PIN_PULL_UP+ D  T- i2 d1 u" {0 d' y
//#define DISABLE_CONTROL_PIN_PULL_UP# D8 g" j2 V* {: b8 @+ z

! j& Q. H9 S' L; N0 o5 q% t// Sets which axis the tool length offset is applied. Assumes the spindle is always parallel with 9 x  F! `: q6 C" |* N
// the selected axis with the tool oriented toward the negative direction. In other words, a positive$ N: r7 i4 [7 u/ d
// tool length offset value is subtracted from the current location.
4 C' b1 i+ j) K8 j3 O//設(shè)置哪個(gè)軸長(zhǎng)度補(bǔ)償應(yīng)用的工具。假設(shè)軸總是與! q; f0 _; w+ u, G2 ?
//選擇軸工具面向負(fù)方向。換句話說(shuō),一個(gè)積極的
( u+ k' b0 a% S9 U  ^4 k. ]//工具長(zhǎng)度偏移值減去從當(dāng)前位置。
$ `1 q& D7 u( a) L4 b8 h
; l8 W' [1 s% d# a, ]; o3 l#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS // Default z-axis. Valid values are X_AXIS, Y_AXIS, or Z_AXIS.設(shè)置哪個(gè)軸長(zhǎng)度補(bǔ)償應(yīng)用的工具+ u# A' ^! f! W$ o* ~+ \0 l. O
. a3 q& U- Q( G  h- I
// Enables variable spindle output voltage for different RPM values. On the Arduino Uno, the spindle
: F( w: J: l& K// enable pin will output 5V for maximum RPM with 256 intermediate levels and 0V when disabled.
( X2 s: X7 k2 N; M* U. }7 }. W2 u// NOTE: IMPORTANT for Arduino Unos! When enabled, the Z-limit pin D11 and spindle enable pin D12 switch!
$ z1 w  A. g7 e3 `4 `// The hardware PWM output on pin D11 is required for variable spindle output voltages.
) E& P* K8 {5 ^  A//允許變量軸輸出電壓不同的轉(zhuǎn)速值。Arduino Uno,主軸
# @  Y! A) O+ e, g* Y//啟用銷(xiāo)將輸出5 v的最高轉(zhuǎn)速256中級(jí)水平和0 v時(shí)禁用。
# \% {3 c- E- X//注意:重要Arduino凱澤本人!當(dāng)啟用時(shí),Z-limit銷(xiāo)這里和軸銷(xiāo)D12開(kāi)關(guān)!1 g8 D* K3 B# {& \" T& ]
//硬件PWM輸出銷(xiāo)這里需要變量軸輸出電壓。
- x4 \. R( d2 W8 B* E/ F  w& r" c9 {
#define VARIABLE_SPINDLE // Default enabled. Comment to disable.//允許主軸輸出電壓不同的轉(zhuǎn)速值
7 L0 Q, ^# s6 k3 f9 q1 a( N9 }- ]' [4 j" L7 L7 ?
// Used by the variable spindle output only. These parameters set the maximum and minimum spindle speed0 d& B4 n  T3 a- p, Z" W
// "S" g-code values to correspond to the maximum and minimum pin voltages. There are 256 discrete and 0 g2 l- A0 H* P' i% l% R. H5 J
// equally divided voltage bins between the maximum and minimum spindle speeds. So for a 5V pin, 10009 O% R) V3 u: w$ E$ }
// max rpm, and 250 min rpm, the spindle output voltage would be set for the following "S" commands: 6 E- s, q& Y3 C2 m4 b
// "S1000" @ 5V, "S250" @ 0.02V, and "S625" @ 2.5V (mid-range). The pin outputs 0V when disabled.& K7 W- {/ L$ r
//使用的變量軸輸出。這些參數(shù)設(shè)置最大和最小軸轉(zhuǎn)速
2 |0 ^: {# ?' g  [, b9 s2 c' [//“S”刀位點(diǎn)值對(duì)應(yīng)于銷(xiāo)電壓的最大值和最小值。有256個(gè)離散和
$ I* k; p. R) T7 g3 X//電壓平均分配箱主軸速度的最大值和最小值之間。所以對(duì)于一個(gè)5 v銷(xiāo),10004 X' N' d4 Y1 a. i/ `: Q
// max rpm,250分鐘rpm,主軸輸出電壓將為以下“S”命令:
- Z( u% f( q) N% c// @“S1000 5 v,“S250”@ 0.02 v,“S625”@ 2.5 v(中檔)。銷(xiāo)輸出0 v時(shí)禁用。, }! R% \! c' r+ B/ v$ o" J

) g3 j2 T/ d* u# u#define SPINDLE_MAX_RPM 1000.0 // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.6 _7 j0 K, @( ]! J
#define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM., ]2 O( E2 W! u+ g

) \  E, B$ ?! L" X1 L! U// Used by variable spindle output only. This forces the PWM output to a minimum duty cycle when enabled.* F- s1 K6 w5 u. Z5 p6 B
// When disabled, the PWM pin will still read 0V. Most users will not need this option, but it may be 5 v, [1 B- |; ^' g( N
// useful in certain scenarios. This setting does not update the minimum spindle RPM calculations. Any
. n; L% H2 G# [// spindle RPM output lower than this value will be set to this value.4 \' y# ?, d, \1 R+ z
//使用的變量軸輸出。這迫使PWM輸出最小占空比時(shí)啟用。- n% X2 D! v& H+ ^
//當(dāng)禁用,PWM銷(xiāo)仍讀0 v。大多數(shù)用戶(hù)不需要這個(gè)選項(xiàng),但是它可能是) C" [+ [) z6 z- h& w
//在某些情況下很有用。這個(gè)設(shè)置不會(huì)更新最小主軸轉(zhuǎn)速計(jì)算。任何
2 O  Y8 T9 l. i! A1 \; J% D" F//輸出軸轉(zhuǎn)速低于這個(gè)值將被設(shè)置為這個(gè)值。
0 I: H3 J/ H% J& c" s8 X8 Y7 E, H
, G( B" j9 Q. Z/ ^( s// #define MINIMUM_SPINDLE_PWM 5 // Default disabled. Uncomment to enable. Integer (0-255)
! U2 r/ B2 I( {& \, I4 U, B4 j7 j* [: A+ J8 n5 R9 Q0 |
// By default on a 328p(Uno), Grbl combines the variable spindle PWM and the enable into one pin to help
# B: I/ `7 z' b+ g# j4 Z// preserve I/O pins. For certain setups, these may need to be separate pins. This configure option uses8 i' s  r9 }  A# N- r
// the spindle direction pin(D13) as a separate spindle enable pin along with spindle speed PWM on pin D11.
! p2 f- G" B; ~: k0 W; v// NOTE: This configure option only works with VARIABLE_SPINDLE enabled and a 328p processor (Uno). ! E! Z* I3 s* v. Z
// NOTE: With no direction pin, the spindle clockwise M4 g-code command will be removed. M3 and M5 still work.
+ x" y$ D" x% x+ a% ]// NOTE: BEWARE! The Arduino bootloader toggles the D13 pin when it powers up. If you flash Grbl with
5 |1 g; W$ c& w6 M) o5 z! Z5 A// a programmer (you can use a spare Arduino as "Arduino as ISP". Search the web on how to wire this.),
/ s* U, F, ^  i& L$ o// this D13 LED toggling should go away. We haven't tested this though. Please report how it goes!
" y7 }" w  C& ^, s. @//默認(rèn)ATmega328 p(Uno),Grbl結(jié)合變量軸PWM和使到一個(gè)銷(xiāo)的幫助
6 v: y# H% X/ j  U* Q: t//保存I / O管腳。對(duì)于某些設(shè)置,這些可能需要單獨(dú)的別針。這個(gè)配置選項(xiàng)使用7 h4 i6 t" c( f% q" g1 v
//方向軸銷(xiāo)(D13)作為一個(gè)單獨(dú)的軸銷(xiāo)上啟用銷(xiāo)以及主軸轉(zhuǎn)速PWM這里。/ Q" @0 [, Z' B0 I, }7 _* l; s
//注意:該配置選項(xiàng)僅適用于VARIABLE_SPINDLE啟用和328 p處理器(Uno)。6 z* a1 W7 S$ S, t9 b7 x
//注意:沒(méi)有方向銷(xiāo),主軸順時(shí)針M4刀位點(diǎn)命令將被刪除。M3和M5仍然工作。5 m# O4 W4 t$ L- q) x6 z, Q5 I
//注意:小心!Arduino引導(dǎo)裝載程序切換D13銷(xiāo)的權(quán)力。如果flash Grbl7 \8 b8 D# f3 [; g+ L( W* K
//程序員(您可以使用一個(gè)備用Arduino“Arduino ISP”。搜索網(wǎng)絡(luò)如何線),' J. ^) T9 @; v% X9 w
//這D13導(dǎo)致切換應(yīng)該消失。我們還沒(méi)有測(cè)試這個(gè)。請(qǐng)報(bào)告將會(huì)怎樣!% q" f) @; o2 _! x
' y3 n4 L  U' L% w4 f- r
// #define USE_SPINDLE_DIR_AS_ENABLE_PIN // Default disabled. Uncomment to enable.
: g0 f3 s6 U& t# }7 y' t% \; [( t) @& j- D$ B9 E  R* a9 Y
// With this enabled, Grbl sends back an echo of the line it has received, which has been pre-parsed (spaces6 u# H# B# O8 _: i5 d
// removed, capitalized letters, no comments) and is to be immediately executed by Grbl. Echoes will not be 0 z3 K& ], {1 B$ L  V
// sent upon a line buffer overflow, but should for all normal lines sent to Grbl. For example, if a user - m( ?; f$ Y7 z. J3 O+ d0 Z
// sendss the line 'g1 x1.032 y2.45 (test comment)', Grbl will echo back in the form '[echo: G1X1.032Y2.45]'./ H+ o7 ~& @# F; v1 _, h5 D6 f& y. I# w
// NOTE: Only use this for debugging purposes!! When echoing, this takes up valuable resources and can effect
; v  ~* d' X, I// performance. If absolutely needed for normal operation, the serial write buffer should be greatly increased
9 s* v- K$ Q; v8 e0 Q" s# s// to help minimize transmission waiting within the serial write protocol.- j8 q: t0 D1 N

( s* B( V/ q- g- g$ m//啟用,Grbl發(fā)回的回聲線已收到,已預(yù)編譯(空間7 W* Y6 W+ p5 X: \& T* ]
//移除,大寫(xiě)字母,沒(méi)有評(píng)論),由Grbl立即執(zhí)行;芈晫⒉粫(huì)
7 T. {6 ~  @9 B+ k+ P" y' i) l//發(fā)送一個(gè)線緩沖區(qū)溢位,但應(yīng)該對(duì)所有正常線路送到Grbl。例如,如果一個(gè)用戶(hù)$ U- [( N# M7 d" B& I$ ~, b9 E
//發(fā)送線的g1 x1.032 y2.45(測(cè)試評(píng)論)形式”,Grbl將回聲”(回聲:G1X1.032Y2.45]”。
% D8 ^6 m1 H% g; W5 b+ w  w//注意:只使用這個(gè)調(diào)試! !當(dāng)呼應(yīng),這占用了寶貴的資源,可以影響
" v+ |& d) Y& X- y6 s) Y$ S+ y& K//性能。如果正常運(yùn)行所需的絕對(duì),串行寫(xiě)入緩沖器應(yīng)該大大增加& G5 Q3 i2 p2 Z/ |) w& k
//幫助最小化傳輸?shù)认盗袃?nèi)寫(xiě)協(xié)議。0 B% j& Q) H/ t% T  V/ h- y1 Y
# g- S$ z+ b% y
// #define REPORT_ECHO_LINE_RECEIVED // Default disabled. Uncomment to enable.
) I* o. A6 n4 @  v0 J  ]) H/ q8 \- O2 d
// Minimum planner junction speed. Sets the default minimum junction speed the planner plans to at
4 L! g3 ~* W- q! F9 D8 m// every buffer block junction, except for starting from rest and end of the buffer, which are always- o# S+ @: _3 v* c- A+ Y8 {
// zero. This value controls how fast the machine moves through junctions with no regard for acceleration0 n8 ^1 `+ {& a0 J( }
// limits or angle between neighboring block line move directions. This is useful for machines that can't
; k1 ~1 H# x4 P$ l. ?/ G// tolerate the tool dwelling for a split second, i.e. 3d printers or laser cutters. If used, this value
& r# g' r5 l2 w6 p! K3 c2 ?  H// should not be much greater than zero or to the minimum value necessary for the machine to work.4 }9 |3 X. G0 |- s! Z7 y
3 ?( o! O/ I) R
//最小規(guī)劃師結(jié)速度。設(shè)置默認(rèn)最小連接速度規(guī)劃計(jì)劃  k& r( Z! e9 C/ k: S; O
//每一個(gè)緩沖塊接頭,除了從結(jié)束休息和緩沖區(qū),它總是
' _( b0 H% a, f  \* z$ d7 [// 0。這個(gè)值控制機(jī)器的速度穿過(guò)路口,沒(méi)有考慮加速度5 z; d# H, d" b0 b0 \
//限制或相鄰塊之間的角線方向移動(dòng)。這是有用的機(jī)器,不能% d4 u5 ~2 [& Z1 C3 ~- `& @3 l' O
//容忍工具居住某一剎那,即3 d打印機(jī)或激光切割機(jī)。如果使用這個(gè)值/ o3 K- ~& A' l- e
//不應(yīng)大于零或機(jī)器工作所需的最小值。
9 S. j8 u- R- S/ h! \4 P  Y; u9 O% e- J( z
#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min)
1 }3 i4 j; }, H/ A+ ?0 {! h7 z5 h# t9 ]8 f: I& t* a
// Sets the minimum feed rate the planner will allow. Any value below it will be set to this minimum( h- z* p; {2 i: v! X  F
// value. This also ensures that a planned motion always completes and accounts for any floating-point; _- F3 t) Q8 E2 k
// round-off errors. Although not recommended, a lower value than 1.0 mm/min will likely work in smaller% L; S* P- |2 N) P4 g
// machines, perhaps to 0.1mm/min, but your success may vary based on multiple factors.4 D/ H3 H/ z, g+ b' ^9 P/ t! Z+ k
//設(shè)置計(jì)劃將允許的最小進(jìn)給速率。任何價(jià)值低于它將被設(shè)置為最低值。這也保證了運(yùn)動(dòng)計(jì)劃總是完成,占任何浮點(diǎn)
7 L0 h0 v+ O8 _% k/ ]//舍入錯(cuò)誤。雖然不推薦,價(jià)值低于1.0毫米/分鐘可能會(huì)在較小的工作% u' m" P3 M" c7 j7 K
//機(jī)器,也許到0.1毫米/分鐘,但你的成功基于多種因素可能會(huì)有所不同。  x# H% K; @# a

$ k' Y& Y9 r2 Z* g$ C/ Y9 J#define MINIMUM_FEED_RATE 1.0 // (mm/min)//設(shè)置計(jì)劃將允許的最小進(jìn)給速率+ X: ~8 R4 C- C# g
5 W9 e4 H) \9 k: m; D1 t
// Number of arc generation iterations by small angle approximation before exact arc trajectory
0 T3 h+ y; H, \" _// correction with expensive sin() and cos() calcualtions. This parameter maybe decreased if there ; a) a' o8 N  S8 L5 h* [$ j
// are issues with the accuracy of the arc generations, or increased if arc execution is getting
2 G% r3 q! T" U// bogged down by too many trig calculations.
) |; _! z0 Z+ ]1 C1 a9 t//弧生成迭代次數(shù)之前小角度近似精確的弧線軌跡1 g, X$ K# ^& N+ H% ?( r
//修正與昂貴的sin()和cos()calcualtions。如果有這個(gè)參數(shù)可能減少
# F2 U% S) [. j//與弧一代又一代的準(zhǔn)確性問(wèn)題,或如果電弧執(zhí)行得到增加
- {' d1 d" `2 O//太多的三角計(jì)算的泥潭。
# r1 m+ r7 A& K0 m6 f7 ]1 D: L7 j3 W. _5 I% I) s/ R
#define N_ARC_CORRECTION 12 // Integer (1-255)) }1 T5 z/ S8 S  ^$ s) t  Z

& S3 t" m9 T. |; s# c// The arc G2/3 g-code standard is problematic by definition. Radius-based arcs have horrible numerical 6 O: C% m5 D& t1 C# q- _) H
// errors when arc at semi-circles(pi) or full-circles(2*pi). Offset-based arcs are much more accurate ) I7 v0 y3 S& r. B0 X
// but still have a problem when arcs are full-circles (2*pi). This define accounts for the floating
4 j; R1 V% X$ ~: Z, n* b// point issues when offset-based arcs are commanded as full circles, but get interpreted as extremely
- }1 p0 N  ^$ R& b/ j// small arcs with around machine epsilon (1.2e-7rad) due to numerical round-off and precision issues.4 _* ~% F% G1 [) p) n, o
// This define value sets the machine epsilon cutoff to determine if the arc is a full-circle or not.
6 `9 R5 Y- s) I2 o// NOTE: Be very careful when adjusting this value. It should always be greater than 1.2e-7 but not too
6 c+ I2 j5 L( E& [" I7 v% J// much greater than this. The default setting should capture most, if not all, full arc error situations.+ f7 J2 q9 I6 V) h1 B! a) _- F
//弧G2/3刀位點(diǎn)的標(biāo)準(zhǔn)定義是有問(wèn)題的。Radius-based弧有可怕的數(shù)值* U7 M  @- H/ W  N  L3 o
//錯(cuò)誤當(dāng)電弧在半圓(π)或原點(diǎn)(2 *π)。Offset-based弧更準(zhǔn)確9 T  @' m0 s' @- a
//但仍有一個(gè)問(wèn)題當(dāng)弧原點(diǎn)(2 *π)。這個(gè)定義占浮動(dòng)
# o& ]$ w6 X* }//當(dāng)offset-based弧吩咐點(diǎn)問(wèn)題完整的圓,但解釋為極
' z' n# `( G" `( R  F//小弧機(jī)周?chē)?1.2 e-7rad)由于數(shù)字舍入和精度問(wèn)題。
6 x3 d/ B4 b; }8 o) b: q% f. p8 ]//定義值設(shè)置機(jī)器ε截止來(lái)確定電弧是一個(gè)原點(diǎn)了。
/ I+ `2 m7 h8 G5 K) l//注意:調(diào)整這個(gè)值時(shí)非常小心。它應(yīng)該總是大于1.2 e -但不要太& R( H! ~0 d8 l; J" v7 a3 W
//比這大得多。默認(rèn)設(shè)置應(yīng)該捕獲大部分,如果不是全部,全部錯(cuò)誤的情況。/ y' E. D& \2 P

/ F5 u  m, Z% [; ~0 H+ V. D/ n#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)4 C4 D! S6 Y  z# L
9 C4 X" D$ n+ @3 E# V. e6 E0 |
// Time delay increments performed during a dwell. The default value is set at 50ms, which provides& {5 Q& A: l( L: R) A' D
// a maximum time delay of roughly 55 minutes, more than enough for most any application. Increasing
% z1 D5 ^7 n9 Y9 T+ e// this delay will increase the maximum dwell time linearly, but also reduces the responsiveness of ; k# X$ W9 }+ f6 a( }$ U: z) D1 r6 S
// run-time command executions, like status reports, since these are performed between each dwell , H* N9 E* Z* a
// time step. Also, keep in mind that the Arduino delay timer is not very accurate for long delays.
5 s5 N9 U5 J" _8 ?) J# L//延時(shí)增加表現(xiàn)在住。默認(rèn)值設(shè)置為50毫秒,它提供了7 r- u8 M, F/ Z1 i9 `8 s
//最大延時(shí)約55分鐘,足夠?qū)Υ蠖鄶?shù)任何應(yīng)用程序。增加1 s# a, R5 `: }  @* E- r7 X; Z
//這種延遲將增加線性最大停留時(shí)間,也減少了響應(yīng)能力3 i0 ^0 k& g* t; }; v, ~
//運(yùn)行命令執(zhí)行狀態(tài)報(bào)告一樣,因?yàn)檫@些每個(gè)住之間執(zhí)行
7 i- m, l5 J% Z# u//時(shí)間步。還有,記住,Arduino延遲計(jì)時(shí)器不是很準(zhǔn)確的長(zhǎng)時(shí)間延誤。
; m& a& U5 t+ l- V' _, F+ Y+ a" A
#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds)
8 d+ T) U+ n* W* Q* u$ p9 y7 C
# H" R7 W2 }' R/ I5 Y( @+ r// Creates a delay between the direction pin setting and corresponding step pulse by creating
# d6 ?7 l4 K( O* T$ l1 K// another interrupt (Timer2 compare) to manage it. The main Grbl interrupt (Timer1 compare) ; e$ x+ |! \2 ?+ A3 k9 |( l
// sets the direction pins, and does not immediately set the stepper pins, as it would in : ?4 [% k( t0 D) Z
// normal operation. The Timer2 compare fires next to set the stepper pins after the step
" ]* w# ^7 D, o. Q% W// pulse delay time, and Timer2 overflow will complete the step pulse, except now delayed 7 E+ n% f/ {; n" e% e  q# i3 |
// by the step pulse time plus the step pulse delay. (Thanks langwadt for the idea!)
4 }$ V( @2 `3 _// NOTE: Uncomment to enable. The recommended delay must be > 3us, and, when added with the
. {/ A6 Y; X2 e" \; O. T% ]// user-supplied step pulse time, the total time must not exceed 127us. Reported successful
2 W; x" e" o: ]4 G% g; ~! _# n0 f# Z// values for certain setups have ranged from 5 to 20us.
1 j: e+ E& ?9 b/ h5 L1 l! d//創(chuàng)建一個(gè)方向銷(xiāo)之間的延遲脈沖通過(guò)創(chuàng)建設(shè)置和相應(yīng)的步驟
/ ]; [1 ^5 \; D" U//另一個(gè)中斷(Timer2比較)來(lái)管理它。主要Grbl中斷(Timer1比較)
2 ~& Q8 x5 E8 R//設(shè)置方向針,不立即設(shè)置步進(jìn)針,因?yàn)樗鼤?huì)在
6 G  r" _8 j' Z/ j9 S7 y  N//正常操作。Timer2比較火旁邊設(shè)置步進(jìn)針后一步
2 p7 c+ @. J) {! @0 U3 s( |- C//脈沖延遲時(shí)間,Timer2溢出脈沖將完成的步驟,現(xiàn)在延遲除外# C5 W9 s4 W. w9 x" N
//脈沖時(shí)間加上的一步一步脈沖延遲。(感謝langwadt主意!)
0 X* V1 m& ?: U# r//注意:取消啟用。必須> 3,建議延遲,當(dāng)添加的
: V! j7 {. A3 C" M. ?/ H//用戶(hù)提供的步驟脈沖時(shí)間,總時(shí)間不得超過(guò)127美元。成功的報(bào)道
" g; G- H5 ^8 K9 N0 j//值對(duì)某些設(shè)置范圍從5到20。
7 r" d. @+ t% v1 B% M5 r" T5 O. D: g! n$ W
// #define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled." S) o$ R% `* N0 h  k% S0 P3 a* J( r

0 X* L/ l, E# J* T: y// The number of linear motions in the planner buffer to be planned at any give time. The vast
+ X0 G+ z6 C& I4 g. E! x5 m// majority of RAM that Grbl uses is based on this buffer size. Only increase if there is extra
' @& z" `4 z. }" d% B) G// available RAM, like when re-compiling for a Mega or Sanguino. Or decrease if the Arduino5 u) H2 C# H7 p& W# I: B
// begins to crash due to the lack of available RAM or if the CPU is having trouble keeping8 y7 H& W; K- K; `
// up with planning new incoming motions as they are executed.   r! e& P4 i! t4 D( g& a5 }. e+ n
//線性運(yùn)動(dòng)規(guī)劃師緩沖區(qū)的數(shù)量在任何給出時(shí)間計(jì)劃。絕大# q8 v* z8 _; c- Z8 C/ O, p" Q
//多數(shù)RAM Grbl使用基于這個(gè)緩沖區(qū)的大小。如果有額外的只會(huì)增加
6 V$ s2 `8 T$ i' Q5 ]9 F6 h! M* p* [//可用內(nèi)存,比如當(dāng)基于大型或Sanguino。如果Arduino或減少* t* g  b9 z2 p9 y3 J
//開(kāi)始崩潰由于缺乏可用的RAM或者CPU是難以保持7 [$ s/ X- T) X+ E" @% ^: l1 [
//與規(guī)劃新傳入的動(dòng)作執(zhí)行。
; W2 R8 I9 s& K. G9 u( @+ v* M5 n! y7 `+ z+ _/ d( g7 T  U
// #define BLOCK_BUFFER_SIZE 18  // Uncomment to override default in planner.h.
" u$ B( O- h8 m1 F5 s( w1 s1 P7 i
* R, E; h+ ]9 X/ `1 }3 \. j// Governs the size of the intermediary step segment buffer between the step execution algorithm8 ?! Q1 ?7 l' r) C
// and the planner blocks. Each segment is set of steps executed at a constant velocity over a
+ R1 B9 S: z& G! f& u4 a3 v// fixed time defined by ACCELERATION_TICKS_PER_SECOND. They are computed such that the planner
8 q9 p: l% l7 g, N// block velocity profile is traced exactly. The size of this buffer governs how much step ' d; j" G2 r  f& s- Y) c
// execution lead time there is for other Grbl processes have to compute and do their thing
- d% q, `% u6 F6 N0 I- |6 ]// before having to come back and refill this buffer, currently at ~50msec of step moves.
* B# G+ E( _" c  s( E& `9 y# r//控制之間的中間段緩沖大小的步驟執(zhí)行算法/ K7 z! E' Q2 t4 T8 G( t
//和規(guī)劃師塊。每一部分的步驟執(zhí)行在一個(gè)恒定的速度+ `, ]& H# E. a4 x0 w; |/ \
//固定的時(shí)間由ACCELERATION_TICKS_PER_SECOND定義的。他們計(jì)算的計(jì)劃; F4 Z7 Q" O6 Q- E
//塊速度剖面追蹤到底。這個(gè)緩沖區(qū)的大小控制多少步驟
* W' v3 Z, X" E; @% U; V6 q//執(zhí)行時(shí)間有其他Grbl過(guò)程需要計(jì)算和做他們的事情0 v# Z8 T7 k- ^( D1 F6 P9 {
//之前必須回來(lái)重新填充這個(gè)緩沖區(qū),目前移動(dòng)~ 50毫秒的一步。3 H; \4 T$ u6 Q$ O

+ e7 K! v' G2 }9 ^// #define SEGMENT_BUFFER_SIZE 6 // Uncomment to override default in stepper.h.3 u4 a6 j/ J- X
1 b! r; p2 K: N, t8 P- z
// Line buffer size from the serial input stream to be executed. Also, governs the size of " Z) D( {7 ^  z7 k2 _& K
// each of the startup blocks, as they are each stored as a string of this size. Make sure2 h: ~: X$ V/ t9 v% r
// to account for the available EEPROM at the defined memory address in settings.h and for# {& E/ z) J) I6 b* `. Q. {
// the number of desired startup blocks.6 A3 |0 A8 I# l1 g
// NOTE: 80 characters is not a problem except for extreme cases, but the line buffer size
+ s: i0 U# |- L1 {+ r// can be too small and g-code blocks can get truncated. Officially, the g-code standards
! S3 _, ?/ w2 Z2 r5 Q( ~// support up to 256 characters. In future versions, this default will be increased, when $ z: L2 N3 ?: M7 c
// we know how much extra memory space we can re-invest into this.4 A1 l1 s% P) f% H3 R
//行執(zhí)行串行輸入流的緩沖區(qū)大小。同時(shí),大小的控制* `% H1 D  C4 k
//每個(gè)啟動(dòng)模塊,它們分別存儲(chǔ)為字符串的大小。確保
, @+ E6 W  v1 J  d1 b//占可用eepm定義內(nèi)存地址的設(shè)置。h和
( P6 W1 q1 D. V//需要啟動(dòng)塊的數(shù)量。
  f0 W" x' N6 k6 ^* @8 j' y//注意:80個(gè)字符不是一個(gè)問(wèn)題,除了極端的情況下,但線緩沖區(qū)大小
& K( h2 S5 u- A; |//可以太小和刀位點(diǎn)塊可以截?cái)唷U?刀位點(diǎn)標(biāo)準(zhǔn)" t% ?7 _8 v6 Q. N
//支持多達(dá)256個(gè)字符。在未來(lái)的版本中,這個(gè)違約將會(huì)增加,當(dāng)
/ D9 j& U* e0 G0 o/ X//我們知道多少額外內(nèi)存空間的時(shí)候我們可以再投資。+ y, ^6 V% C% m; _4 k2 `

3 l9 Z: i) G+ y5 ^0 \+ U1 s' Y// #define LINE_BUFFER_SIZE 80  // Uncomment to override default in protocol.h7 p5 x& Q: }2 l3 `
  
8 j) d8 R5 ?# p4 I( |// Serial send and receive buffer size. The receive buffer is often used as another streaming
! ^* X& o8 L: B- k0 K0 u// buffer to store incoming blocks to be processed by Grbl when its ready. Most streaming
$ l$ k! W$ {* U4 i& S// interfaces will character count and track each block send to each block response. So,
1 `2 l+ H" ?6 Q0 I5 o, ^( m  ], S6 @// increase the receive buffer if a deeper receive buffer is needed for streaming and avaiable
4 e% p2 d, o) P8 M8 e// memory allows. The send buffer primarily handles messages in Grbl. Only increase if large
5 k- K1 c; i  |// messages are sent and Grbl begins to stall, waiting to send the rest of the message.
7 L, ~+ i+ z$ |2 L8 [- n// NOTE: Buffer size values must be greater than zero and less than 256.
6 s  L5 \% J6 h. S$ P! F$ z// #define RX_BUFFER_SIZE 128 // Uncomment to override defaults in serial.h+ e( x# X4 l0 A) F
//串行發(fā)送和接收緩沖區(qū)大小。接收緩沖區(qū)通常用作另一個(gè)流
8 E0 b3 [" G# ^1 F//緩沖存儲(chǔ)傳入的塊來(lái)處理Grbl當(dāng)它準(zhǔn)備好了。最流
8 n; V+ {! m. K' W//接口將字符計(jì)數(shù)和跟蹤每一塊發(fā)送給每個(gè)塊的回應(yīng)。所以,, w" W. @9 E& R0 i9 [7 g! j
//增加接收緩沖區(qū)如果需要更深層次的接收緩沖區(qū)為流,、) s* _' M) K! `9 j5 ?( z
//內(nèi)存允許。Grbl發(fā)送緩沖主要處理消息。只會(huì)增加如果大
* _, J1 q) q' T0 A3 L& |! S//消息發(fā)送和Grbl開(kāi)始停滯,等待發(fā)送其余的消息。' |9 i4 q/ S/ }5 H2 \% [8 R
//注意:緩沖區(qū)大小值必須大于零,小于256。
0 N; u% J: v) ^8 i7 \0 G6 A// # define RX_BUFFER_SIZE 128 / /取消serial.h覆蓋默認(rèn)值" M: m) ~* P7 m2 r& W, K

3 b0 j( P6 }  S" Y' a' V/ N6 e. u0 t$ N  S  t- X
// #define TX_BUFFER_SIZE 64# K8 i, O; k% S3 q5 Q+ E
  
, g- |' I$ p( N( B# H// Toggles XON/XOFF software flow control for serial communications. Not officially supported" x$ A: ^0 r8 N; r3 J9 ^8 q
// due to problems involving the Atmega8U2 USB-to-serial chips on current Arduinos. The firmware5 {! F6 m0 G/ E9 v
// on these chips do not support XON/XOFF flow control characters and the intermediate buffer
' ~7 s& q2 i4 y// in the chips cause latency and overflow problems with standard terminal programs. However, # n  G4 E+ }: @
// using specifically-programmed UI's to manage this latency problem has been confirmed to work.5 U" X$ v+ Q# v9 n
// As well as, older FTDI FT232RL-based Arduinos(Duemilanove) are known to work with standard
: B, h, Y/ q0 ^! f3 a) r// terminal programs since their firmware correctly manage these XON/XOFF characters. In any
! ]( m- a: z, n6 i// case, please report any successes to grbl administrators!
: i6 j1 j6 _* y4 R% j! U//切換為串行通信發(fā)送樸通/發(fā)送葡開(kāi)軟件流控制。不是官方支持; D. y0 l0 u2 f
//由于問(wèn)題涉及Atmega8U2 USB-to-serial當(dāng)前arduino芯片。固件
" C3 P4 U5 v$ i, x  C//在這些芯片不支持發(fā)送樸通/發(fā)送葡開(kāi)流控制字符和中間緩沖區(qū): ], b0 T  _9 E
//芯片導(dǎo)致延遲和溢出問(wèn)題的標(biāo)準(zhǔn)終端程序。然而,# o4 g, a9 r0 t) b0 v& ?; h
//使用specifically-programmed UI的管理這個(gè)延遲問(wèn)題已經(jīng)確認(rèn)工作。' E$ ^/ U* p  L5 q$ E8 Q: \
//以及老FTDI FT232RL-based arduino(Duemilanove)是已知的標(biāo)準(zhǔn)
  y/ W* s- `8 w  v6 t# {  t5 }. A//終端程序因?yàn)樗麄冋_的固件管理這些發(fā)送樸通/發(fā)送葡開(kāi)的角色。在任何0 I7 S% J: e' b4 N6 `. U
//情況,請(qǐng)報(bào)告任何成功grbl管理員!: W8 i" @. `- X! \3 W8 w

& ^4 w, Q( p. D  z6 A5 x0 ?7 V// #define ENABLE_XONXOFF // Default disabled. Uncomment to enable.% h" r& d) ^: \  d; x

) I7 ~1 M9 v! b2 I. Z2 @// A simple software debouncing feature for hard limit switches. When enabled, the interrupt
# B  ~! A; U4 t+ O$ [3 h8 `// monitoring the hard limit switch pins will enable the Arduino's watchdog timer to re-check
* J* ]( ?; M: ^  d4 u& G% i// the limit pin state after a delay of about 32msec. This can help with CNC machines with # C3 S* G0 h: G; x
// problematic false triggering of their hard limit switches, but it WILL NOT fix issues with ; H) h" V0 i7 z! `" p( T) w
// electrical interference on the signal cables from external sources. It's recommended to first7 P2 g: N8 d/ d4 q
// use shielded signal cables with their shielding connected to ground (old USB/computer cables , W3 x) [) M: L+ O5 D7 l
// work well and are cheap to find) and wire in a low-pass circuit into each limit pin.9 ^" w5 O/ d3 J6 ?+ p. E8 b
//一個(gè)簡(jiǎn)單的軟件消除抖動(dòng)特性硬限位開(kāi)關(guān)。當(dāng)啟用時(shí),中斷* ?" x$ J4 v1 O8 j5 ]9 x
//監(jiān)控硬限位開(kāi)關(guān)針將使Arduino的看門(mén)狗定時(shí)器重新審視
% K: p( C- D" {5 o/ q' w% _% c//銷(xiāo)的極限狀態(tài)后約32毫秒的延遲。這可以幫助與數(shù)控機(jī)器1 f# J5 X( ~' f0 K8 X
//問(wèn)題錯(cuò)誤引發(fā)的硬限位開(kāi)關(guān),但是它不會(huì)解決問(wèn)題
9 o, T/ p$ H) B6 l//電干擾信號(hào)電纜從外部來(lái)源。首先它的建議$ @, B" r/ v! ?# O
//使用屏蔽信號(hào)電纜的屏蔽連接到地面(老USB /計(jì)算機(jī)電纜: w3 {! ?% H, x/ m
//工作得很好,很便宜)和線低通電路到每個(gè)限位銷(xiāo)。9 W: A3 x: k/ n/ N3 c6 S- g
: F) E: ~/ [, m# @( _& B7 x
// #define ENABLE_SOFTWARE_DEBOUNCE // Default disabled. Uncomment to enable.
  f8 N& m5 S5 K4 t* }$ p
: D9 d, [9 b" \9 b6 h  W$ Z// Force Grbl to check the state of the hard limit switches when the processor detects a pin- b, h5 ~2 A! q/ \9 H* u
// change inside the hard limit ISR routine. By default, Grbl will trigger the hard limits. z1 w4 s9 _: e
// alarm upon any pin change, since bouncing switches can cause a state check like this to & v# B" E- ]% Q* `4 H  N4 m
// misread the pin. When hard limits are triggered, they should be 100% reliable, which is the
; Z$ v" W4 I( a1 B+ |1 w// reason that this option is disabled by default. Only if your system/electronics can guarantee. H/ _/ z6 a, r5 L" s  N
// that the switches don't bounce, we recommend enabling this option. This will help prevent7 M9 N) k4 j5 O: r' S; o
// triggering a hard limit when the machine disengages from the switch.' ?% `4 D) }( R2 t1 K5 p* V
// NOTE: This option has no effect if SOFTWARE_DEBOUNCE is enabled.
3 X. d" ~* ]+ J7 C//力Grbl檢查硬限位開(kāi)關(guān)的狀態(tài),當(dāng)處理器檢測(cè)到一個(gè)銷(xiāo)& R! l; [! K9 W2 h: W
//改變內(nèi)部硬限制ISR例行公事。默認(rèn)情況下,Grbl將觸發(fā)硬限制
: E. x3 B" F" q" a5 l4 c//報(bào)警在任何銷(xiāo)更改,因?yàn)樘_(kāi)關(guān)可以導(dǎo)致這樣的狀態(tài)檢查
5 }$ ?. Y: h2 Q8 w! s6 {' K. k//誤讀了銷(xiāo)。硬限制觸發(fā)時(shí),他們應(yīng)該100%可靠,這是4 g3 a- d3 T$ ~, W# [  F
//原因,這個(gè)選項(xiàng)默認(rèn)是禁用的。只有在你的系統(tǒng)/電子產(chǎn)品可以保證5 b; j" |; I, E* ?: x7 V) A$ e
//開(kāi)關(guān)不反彈,我們建議啟用這個(gè)選項(xiàng)。這將有助于防止7 v6 \* {4 m# p* q
//觸發(fā)機(jī)退出時(shí)硬限制開(kāi)關(guān)。
$ P. T( A8 J  }. Q  G//注意:這個(gè)選項(xiàng)如果啟用了SOFTWARE_DEBOUNCE沒(méi)有影響。* R# n" O9 e7 W) \6 Z* c
( D7 {: m  t% k  ]* u
// #define HARD_LIMIT_FORCE_STATE_CHECK // Default disabled. Uncomment to enable.+ Q; U8 y) v: C$ P. V

; ^$ W' [/ q& P# M! V2 y% S
. P2 w$ Z) g4 h. L6 d+ s* o// ---------------------------------------------------------------------------------------
  G) c5 u+ i  y' H/ Q// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:編譯時(shí)錯(cuò)誤檢查的定義值:( C$ |% F& A9 o- M; \: [- F9 F

( b8 r9 P0 x; a6 _9 Y. R#ifndef HOMING_CYCLE_0
" K7 V0 B3 t! R' A& x/ }  #error "Required HOMING_CYCLE_0 not defined.", g3 R" @! D: q: o4 m
#endif
- J" e2 c: {9 o& ~5 L& G. E6 U; R% i3 [/ ^/ L5 e- u3 E# P
#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(VARIABLE_SPINDLE)
+ O: P3 D+ d! \2 t  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with VARIABLE_SPINDLE enabled"% u/ n& l# N2 X7 b& p4 a9 W, @
#endif
0 i' \% l9 f" U! h' e( H/ k; b8 A% U- P# W. ~) ^: X
#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(CPU_MAP_ATMEGA328P)' O$ M* B5 K1 g1 @/ ]
  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with a 328p processor": b* k4 b7 y2 N% X/ N
#endif/ x8 U" ~5 X3 v; g; W

6 a' _$ H# C$ h9 o) W" J// ---------------------------------------------------------------------------------------
5 v4 J6 B8 T' i* G. b
7 F- `, r, }$ P( k9 i7 j
9 b( L8 L/ ]: L6 f1 j#endif
6 S8 g2 {  G" d3 ~9 L' o- T, e; X6 ~( E" Z8 }, Z2 v( Q
+ b) M- S$ Y* W4 q" @4 K

- C; X: k; d! E6 H: S2 a
, d! [) u- a8 W& I8 J. `
; W& A, V" U, L  t" N2 F; I. E$ I# C  y9 J0 N

8 Z2 i+ K: Y; o" i& ~2 b/ \9 @1 v2 w. Y: }$ e& l
$ k. U, X" p' p& m! w
. i6 A; D3 {5 R; d
$ s5 \& A) y  |+ w" o: z! L# S
" M6 s( u* _9 l8 g9 I+ Y

6 y" q1 A" G* g0 v$ ~8 d' {. ~" A- R+ l7 D& V
% ]  J- v: m- t- Z

* C! H+ x3 L' J7 c

本帖子中包含更多資源

您需要 登錄 才可以下載或查看,沒(méi)有帳號(hào)?注冊(cè)會(huì)員

x

評(píng)分

參與人數(shù) 2威望 +201 收起 理由
mrplplplpl + 1 思想深刻,見(jiàn)多識(shí)廣!
管理團(tuán)隊(duì) + 200

查看全部評(píng)分

回復(fù)

使用道具 舉報(bào)

2#
 樓主| 發(fā)表于 2016-8-21 00:11:42 | 只看該作者
那些沒(méi)有用的照片不知道怎么就上去了好討厭。
3#
 樓主| 發(fā)表于 2016-8-21 00:14:16 | 只看該作者
" H  E& P$ w8 y8 w
4#
發(fā)表于 2016-8-21 05:50:22 | 只看該作者
      樓主厲害!
5#
發(fā)表于 2016-8-21 08:22:05 | 只看該作者
謝謝樓主,先收藏一下,慢慢學(xué)習(xí)
6#
發(fā)表于 2016-8-23 15:11:25 | 只看該作者
這是什么寶貝?
7#
發(fā)表于 2016-8-23 15:11:47 | 只看該作者
換了個(gè)瀏覽器Chrome,試試能否發(fā)言了。
8#
發(fā)表于 2016-8-23 20:12:33 | 只看該作者
樓主厲害
回復(fù)

使用道具 舉報(bào)

9#
 樓主| 發(fā)表于 2016-8-23 23:03:17 | 只看該作者
補(bǔ)充% _% S5 m% U1 P2 T7 X3 K* h3 G8 O
程序運(yùn)行protocol_execute_realtime(); /運(yùn)行實(shí)時(shí)命令。
& ~' w8 r, y9 L2 S// Executes run-time commands, when required. This is called from various check points in the main7 Q4 S. l2 i2 `  q
// program, primarily where there may be a while loop waiting for a buffer to clear space or any" a3 C2 Y7 i: f& |7 O/ ?4 g9 `* Q
// point where the execution time from the last check point may be more than a fraction of a second.
! P4 j7 w0 B( v# K" _1 X( l// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code
3 Z; [4 f/ @0 H/ `0 t3 d// parsing and planning functions. This function also serves as an interface for the interrupts to
2 A" f' m. ^) x// set the system realtime flags, where only the main program handles them, removing the need to
: [3 ~) D6 y; G9 H// define more computationally-expensive volatile variables. This also provides a controlled way to
+ C- I7 C6 }6 y// execute certain tasks without having two or more instances of the same task, such as the planner
6 _' z; l! b/ p) c2 V& \// recalculating the buffer upon a feedhold or override.
  @/ r% y5 V, ~+ f// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,
, X, k5 O$ j8 @1 t. p: x// limit switches, or the main program.
. W# f; p3 u! K: _' b, ]0 g( X$ q7 I) v. I6 w5 H  ^; P5 o
//執(zhí)行運(yùn)行時(shí)間命令,在需要時(shí)。這就是所謂的從各種主程序要檢查站6 w- o- x" ], D! G3 S8 o3 O% S
//,主要是那里可能是一個(gè)while循環(huán)等待緩沖區(qū)空間或任何
% A1 t6 a, h* q//執(zhí)行時(shí)間從過(guò)去的止點(diǎn)可以超過(guò)幾分之一秒。
; W* I4 t- f# |: }; l, N& q9 L//這是一種異步執(zhí)行實(shí)時(shí)命令(又名多任務(wù))grbl的刀位點(diǎn): K# p" c3 l. d, K# a  J3 W" c2 r
//解析和規(guī)劃功能。這個(gè)函數(shù)也可以作為一個(gè)接口,用于中斷
* z3 ~. s( N  L* N+ b//設(shè)置系統(tǒng)實(shí)時(shí)的旗幟,只有主程序處理,消除的需要2 @4 i! r' G- q# m# j
//定義更多的計(jì)算昂貴volatile變量。這也提供了一種控制方法* Z+ C. Q/ T( Y9 E
//執(zhí)行某些任務(wù)不相同的兩個(gè)或多個(gè)實(shí)例的任務(wù),比如計(jì)劃& v9 r! f! D3 w$ l+ d$ b3 o& I" q/ o
//重新計(jì)算緩沖feedhold或覆蓋。! ?- U! T9 {" Q) O/ }
//注意:sys_rt_exec_state變量標(biāo)志設(shè)置任何過(guò)程,步驟或串行中斷,插腳引線,7 p+ E4 i2 D, p% i1 W
//限位開(kāi)關(guān)或主程序。
* V" f2 ]0 x# {void protocol_execute_realtime(); j* y' r1 A0 f" c- ]1 j
{
3 ]) [5 u4 R4 e1 C3 \8 G        // Temp variable to avoid calling volatile multiple times.
5 U0 s1 T, s0 S( G) A6 g9 B        // 臨時(shí)變量來(lái)避免多次調(diào)用不穩(wěn)定。
3 l& Z; s  ^2 W5 q; ^% ^; J* ^- c        uint8_t rt_exec;
) L" ^$ Z( N7 r0 \7 I) X( v        do{
0 M* ~& L, w* Q! L. C          if (rt_exec) {                 // 有標(biāo)志位置位進(jìn)入
+ I4 R3 H" L! l9 [! S9 S% d       
9 Q7 i# }4 t( M5 {+ |. J: P            sys.state = STATE_ALARM; // 設(shè)置系統(tǒng)為報(bào)警狀態(tài)3 R' J, r. M5 W' x: u0 o# A) i( j
      report_alarm_message(ALARM_HARD_LIMIT_ERROR);        //報(bào)告報(bào)警信息為接近極限值
* ~. y) e1 }" ^) a- Y    } else if (rt_exec & EXEC_ALARM_SOFT_LIMIT) {                        //報(bào)告執(zhí)行軟件限位報(bào)警$ {6 o8 {; m, U0 E3 S% I* J
      report_alarm_message(ALARM_SOFT_LIMIT_ERROR);        //報(bào)告出現(xiàn)軟件限位報(bào)警
8 d1 W: b# U! c- T, M* J8 Y    } else if (rt_exec & EXEC_ALARM_ABORT_CYCLE) {                //執(zhí)行停止循環(huán)報(bào)警      2 L, Q/ f5 ]5 T7 S5 c: O8 J5 E) O
      report_alarm_message(ALARM_ABORT_CYCLE);                //出現(xiàn)終止循環(huán)報(bào)警
) |5 I9 O4 m* @- v, c    } else if (rt_exec & EXEC_ALARM_PROBE_FAIL) {                        //執(zhí)行探查失敗報(bào)警5 d- U4 m7 L% c
      report_alarm_message(ALARM_PROBE_FAIL);                        //出現(xiàn)探查失敗報(bào)警
% c( J8 M, d" z& e    } else if (rt_exec & EXEC_ALARM_HOMING_FAIL) {                //執(zhí)行返回原點(diǎn)失敗報(bào)警
1 \. c. K1 ^- q/ B1 B      report_alarm_message(ALARM_HOMING_FAIL);                //出現(xiàn)返回原點(diǎn)失敗報(bào)警
% G& T3 P. H! w    }5 m" O8 E/ M3 i' g1 T4 F9 c: K$ y

8 l0 s- v( o% m8 `) I    // Halt everything upon a critical event flag. Currently hard and soft limits flag this.7 B+ X7 c( f0 \' g; ?
    // 停止一切在一個(gè)關(guān)鍵事件標(biāo)志。目前硬和軟限制標(biāo)志
; T- I' b. \& {8 E: l6 _           if (rt_exec & EXEC_CRITICAL_EVENT) {                //如果系統(tǒng)是循環(huán)事件進(jìn)入
- W9 @' m2 J' ]" G- K  }, o- \             report_feedback_message(MESSAGE_CRITICAL_EVENT);        //報(bào)告反饋信息. j8 W/ _+ \& Z0 f6 s( ~
              bit_false_atomic(sys_rt_exec_state,EXEC_RESET);                         //清除目前的復(fù)位狀態(tài)
0 p$ U- h- H& k. z
3 i3 `% }- P6 T4 w# r0 X        bit_false_atomic(sys_rt_exec_alarm,0xFF);                                 // 清除所有報(bào)警標(biāo)志
' W, B7 h! Q: r, P; A6 f        }        7 S5 b# P# K* g& z# F

, T2 i3 q3 s" v$ I; b0 c上面代碼將rt_exec = sys_rt_exec_alarm ,如果rt_exec為真,打印不同報(bào)警信息; g3 j# X5 k5 n
和限位保護(hù)信息,然后清除報(bào)警狀態(tài)5 F4 S. Q/ I' f" ?, d4 \+ s! Y) k) Z; k
___________________________________________________________________________
$ Y. ^4 `' J$ E0 Z1 M沒(méi)有報(bào)警進(jìn)行執(zhí)行下面代碼,執(zhí)行了終止命令,串口打印命令& s9 U% J9 b! e  o/ \
        // Check amd execute realtime commands        校驗(yàn)和執(zhí)行實(shí)時(shí)命令% ]4 z& H' o; P- X
          rt_exec = sys_rt_exec_state; // Copy volatile sys_rt_exec_state& I/ s6 L9 {5 T" V5 s; u
8 q& [" @6 l2 b, X: w
        if (rt_exec) { // 輸入標(biāo)志是正確的執(zhí)行  H0 ^) S7 r4 }

- i, }. t6 z" c4 @            // Execute system abort. 執(zhí)行系統(tǒng)終止命令
: s/ P8 I+ n% ~$ A            if (rt_exec & EXEC_RESET) {
3 M0 ~! H: X# M- E              sys.abort = true;  // Only place this is set true.
! e+ O- F, `; ?6 }              return; // Nothing else to do but exit.) D! Y: [) B- |0 I
        }" Z$ C2 X5 c+ r9 h1 _

' b4 x, L" l2 n0 S8 ~            // Execute and serial print status 執(zhí)行和串口打印狀態(tài)! e+ A8 Z4 i- Q3 I, X
            if (rt_exec & EXEC_STATUS_REPORT) { * X# ]. j- w; q/ q: w, |
              report_realtime_status();        //報(bào)告實(shí)時(shí)狀態(tài)9 w6 w& \! d6 x$ b0 m) Y
              bit_false_atomic(sys_rt_exec_state,EXEC_STATUS_REPORT);        //清除報(bào)告狀態(tài)清零* I6 p4 x' `! }$ G% h5 Z
            }% v6 x, t7 h- U
_____________________________________________________________________________
$ N3 D- E4 Y$ F  l下面代碼7 s, g" {$ @- u+ V
//執(zhí)行狀態(tài)。! T  q6 y) B. |
//注意:所涉及的數(shù)學(xué)計(jì)算持有應(yīng)該足夠低對(duì)大多數(shù)人來(lái)說(shuō),即使不是全部,  H; D+ u( ?% Z3 M' O5 |
//操作場(chǎng)景。一旦啟動(dòng),系統(tǒng)進(jìn)入暫停狀態(tài)
9 j1 g( t4 ^: K# C- x//主程序流程,直到重置或恢復(fù)。
$ i7 X! Q! @' ]% l$ a& e待辦事項(xiàng):檢查模式?如何處理呢?可能沒(méi)有,因?yàn)樗粫?huì)在空閑,然后重置Grbl。9 G. m3 _0 V1 C) a% x8 G
狀態(tài)檢查容許狀態(tài)的方法。# @! K4 O* |! C- D4 Z8 }9 B
% i/ b8 F  i2 |: S
        //如果全局各自報(bào)警標(biāo)志位其中(執(zhí)行取消動(dòng)作) | (執(zhí)行進(jìn)給保持) | (執(zhí)行安全門(mén))任意一位為真進(jìn)入
5 D: E! ~; U+ m9 i% t% B            if (rt_exec & (EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR)) {          m1 K- \, H3 [! C# Q9 v4 h" o# T

' ]* R$ Z3 ?: D. }/ C& x        //如果是循環(huán)狀態(tài)執(zhí)行暫停狀態(tài)
4 m2 p& C4 v& j% r! v; }; |( O        if (sys.state == STATE_CYCLE) {
. @+ s' P& a4 v, X4 k# L  h        st_update_plan_block_parameters(); //通知stepper module驗(yàn)算減速。
  [, h/ n, `; ]. `* i        sys.suspend = SUSPEND_ENABLE_HOLD; // 開(kāi)始暫停標(biāo)志. l% |& a- [3 N: ^
        }" T3 y- L2 y3 |7 [" Z
1 Y# C# T; K8 y% N
        // 如果,Grbl空閑不在運(yùn)動(dòng)。簡(jiǎn)單的指示暫停就緒狀態(tài)。
. o  e( M0 r9 I  ]        if (sys.state == STATE_IDLE) { sys.suspend = SUSPEND_ENABLE_READY; }0 e) n( w# x7 h5 @2 }

2 P3 E% s$ r6 h9 v  T; Z7 ?6 e3 k2 J; u# ~. W: z) u& D/ F3 v4 d) Z
        //執(zhí)行和標(biāo)志和減速運(yùn)動(dòng)取消并返回空閑。主要由探測(cè)使用周期* A% J  t' x. @# Y
        //停止和取消剩余的運(yùn)動(dòng)。      
/ ~1 R* Y+ [! j: W3 R        if (rt_exec & EXEC_MOTION_CANCEL) {) Q4 B% K3 T0 b
          if (sys.state == STATE_CYCLE) { sys.state = STATE_MOTION_CANCEL; }0 l! `2 i% H* q0 h+ d0 L2 R$ b, {+ y. o
          sys.suspend |= SUSPEND_MOTION_CANCEL; 8 l1 q- D( |  \/ R
        }7 d* O8 t" o: o5 M2 m: q

: L- \6 ]4 v$ J  P+ _        // 只在循環(huán)時(shí)執(zhí)行進(jìn)給保持減速' D: w5 ]* u2 \7 S7 O5 N
         if (rt_exec & EXEC_FEED_HOLD) {' D, N0 u3 S/ T8 T6 A& D  L
        //只有安全門(mén)為1才執(zhí)行保持進(jìn)給狀態(tài)賦值% E4 g0 F# M& Q3 }; \- d6 r0 {9 o1 ~" E
          if (bit_isfalse(sys.state,STATE_SAFETY_DOOR)) { sys.state = STATE_HOLD; }, D4 B" r* Y6 W8 D
        }9 G+ K1 q2 i, E
( M  G  Y1 E; W& ?/ b
        if (rt_exec & EXEC_SAFETY_DOOR) {# v/ |6 ^, W" B6 _
          report_feedback_message(MESSAGE_SAFETY_DOOR_AJAR);
9 h- N5 ]  D/ ]8 }  J8 Z+ H+ N/ /如果已經(jīng)活躍,準(zhǔn)備好重新開(kāi)始,CYCLE_STOP標(biāo)志設(shè)置為強(qiáng)制斷開(kāi)。; _3 N4 G1 x' m# Y  R
/ /注意:只是暫時(shí)設(shè)置“rt_exec”變量,不是動(dòng)蕩的“rt_exec_state”變量。% I8 S3 T% L0 ?2 n
          if (sys.suspend & SUSPEND_ENABLE_READY) { bit_true(rt_exec,EXEC_CYCLE_STOP); }
& n8 S( u1 F) n! g! z% l" {. Z          sys.suspend |= SUSPEND_ENERGIZE;5 X: |/ m& E" h' H
          sys.state = STATE_SAFETY_DOOR;9 _3 A+ Q  [% u; a# {
        }
- J/ p3 c: |" E! G, _- H, b+ F) e* J: {# I( T& A8 P7 L6 k! p
bit_false_atomic(sys_rt_exec_state,(EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR));    4 z- ]: t+ ?* P( ]; n5 p
5 `- F2 X4 i1 O9 D! N. c
}2 W9 S3 q! T8 n% d$ p
以上代碼執(zhí)行了& @; i6 d; R5 ^1 M/ f# ^/ p2 n: r
1.如果全局各自報(bào)警標(biāo)志位其中(執(zhí)行取消動(dòng)作) | (執(zhí)行進(jìn)給保持) | (執(zhí)行安全門(mén))任意一位為真進(jìn)入9 W1 D3 t1 S* l; c: w) M2 j& V
2.系統(tǒng)為閑著狀態(tài), 開(kāi)始循環(huán)狀態(tài), 回原點(diǎn)狀態(tài), 控制取消狀態(tài), 開(kāi)始保持狀態(tài), 開(kāi)始安全門(mén)狀態(tài)時(shí)進(jìn)入
. A+ ?6 L! E4 ]: R0 u3.如果是循環(huán)狀態(tài)執(zhí)行暫停狀態(tài)
0 _  ]: k; ^% Y# i/ n4.如果系統(tǒng)閑置狀態(tài)執(zhí)行暫停就緒狀態(tài)+ X3 Q& w; C5 \
5.執(zhí)行動(dòng)作取消
& J6 V4 J' [. y% R- Y6.如果是保持進(jìn)給狀態(tài),執(zhí)行保持進(jìn)給狀態(tài)
+ ?$ L. Z# Q0 d7.執(zhí)行安全門(mén)狀態(tài)
, c; M4 P8 J; D4 {) t' k最后執(zhí)行bit_false_atomic清標(biāo)志清除(執(zhí)行取消動(dòng)作)(執(zhí)行進(jìn)給保持)(執(zhí)行安全門(mén))標(biāo)志位                 
9 v! |7 M+ w2 e# y_____________________________________________________________________________
4 Y, L' g6 q1 g* V9 D+ c, f3 f' E+ r: J$ K& [% b+ T" G7 ~
    // Execute a cycle start by starting the stepper interrupt to begin executing the blocks in queue.
! @1 k5 Z8 G( F: h    // 執(zhí)行一個(gè)循環(huán)開(kāi)始啟動(dòng)步進(jìn)開(kāi)始執(zhí)行中斷隊(duì)列的街區(qū)8 M/ t' |; M+ A4 `8 U1 e
    if (rt_exec & EXEC_CYCLE_START) {        //循環(huán)開(kāi)始狀態(tài)進(jìn)入
. y6 Q6 E: Y( n, p) n      // Block if called at same time as the hold commands: feed hold, motion cancel, and safety door.
+ r% ^' D2 u8 I+ m      // Ensures auto-cycle-start doesn't resume a hold without an explicit user-input.
# d; _+ b4 O  B( l          //塊如果在同時(shí)舉行的命令:保持進(jìn)給,運(yùn)動(dòng)取消,和安全的門(mén)。 //確保auto-cycle-start沒(méi)有簡(jiǎn)歷沒(méi)有顯式的用戶(hù)輸入。
& b4 B; l' j. A" a" X& P% I          
$ a  j5 p$ \$ {3 _' n# O! Y      if (!(rt_exec & (EXEC_FEED_HOLD | EXEC_MOTION_CANCEL | EXEC_SAFETY_DOOR))) {   //狀態(tài)機(jī)如果不是保持進(jìn)給,運(yùn)動(dòng)取消,和安全的門(mén)。
9 X# X7 o! h% G; [( y; I        // Cycle start only when IDLE or when a hold is complete and ready to resume.# E0 A' I. R2 A' [$ a, J
        // NOTE: SAFETY_DOOR is implicitly blocked. It reverts to HOLD when the door is closed.3 f, w' M; c( D+ j
                //循環(huán)開(kāi)始時(shí)只有當(dāng)閑置或持有完成并準(zhǔn)備簡(jiǎn)歷。
* U. F9 l( D5 w                //注意:SAFETY_DOOR是隱式地屏蔽。它返回的時(shí)候門(mén)是關(guān)閉的。    : X% m: G$ y9 U" i. x
9 T" E8 Y: C: |9 p$ `# W1 |3 ^& t
                // 如果系統(tǒng)狀態(tài)為閑著狀態(tài),系統(tǒng)狀態(tài)為開(kāi)始進(jìn)給或運(yùn)動(dòng)取消,暫停標(biāo)志為位重新開(kāi)始+ v0 A/ a4 D5 z7 y, \" J% [/ v
        if ((sys.state == STATE_IDLE) || ((sys.state & (STATE_HOLD | STATE_MOTION_CANCEL)) && (sys.suspend & SUSPEND_ENABLE_READY))) {
- l, f. i5 K7 H- M# q. F4 Q7 n          // Re-energize powered components, if disabled by SAFETY_DOOR.2 \8 t; U8 D! v& E
          //        由SAFETY_DOOR重振組件供電,如果禁用。8 d1 c3 ]0 c  X# J+ q
          if (sys.suspend & SUSPEND_ENERGIZE) { : G5 X5 V* {, s  k
            // Delayed Tasks: Restart spindle and coolant, delay to power-up, then resume cycle.
  C  i& v/ ]4 ]' \! q' z            //延遲任務(wù):重新啟動(dòng)主軸和冷卻劑,延遲升高,然后恢復(fù)周期。" x% Q' J. f' \' B) T
            if (gc_state.modal.spindle != SPINDLE_DISABLE) {   //主軸模式不是失能進(jìn)入7 `0 t! F3 H/ ^
              spindle_set_state(gc_state.modal.spindle, gc_state.spindle_speed); //設(shè)置狀態(tài)和速度
) c1 i0 ~- r  l7 p/ O              //待辦事項(xiàng):阻塞函數(shù)調(diào)用。最終需要一個(gè)非阻塞。' e# c2 |/ m& h) `: J! f
                delay_ms(SAFETY_DOOR_SPINDLE_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.
! k6 g7 t4 l! h# ^6 U. B            }
- Q! s$ P* t7 N& o            if (gc_state.modal.coolant != COOLANT_DISABLE) {
5 U+ M' p* f8 M' C              coolant_set_state(gc_state.modal.coolant);
5 |" n) ?/ K( |& t% n( c8 r+ R, Z              delay_ms(SAFETY_DOOR_COOLANT_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.) O* V- O4 ?: T* ^: U5 t
            }% w+ l7 [! {; d" _" U% ~/ f
            // TODO: Install return to pre-park position.
  Z0 y0 F' y( o1 Y9 S          }" R% t3 k! ]8 _" ]  z6 i9 i
______________________________________________________________________________________________________________- u& D! G9 w6 [
          // Start cycle only if queued motions exist in planner buffer and the motion is not canceled., g& M% S7 m# m0 j/ Q
                  
+ a9 T1 T: B7 [" D                  //只有在隊(duì)列馬達(dá)存在規(guī)定的緩沖,并且動(dòng)機(jī)沒(méi)有讓取消,才會(huì)循環(huán)4 F. G! F, y) C8 Q+ E
                  ) J5 N7 j0 O! G4 a
          if (plan_get_current_block() && bit_isfalse(sys.suspend,SUSPEND_MOTION_CANCEL)) {& E. B. j$ I6 ]% Z; y# K  M
            sys.state = STATE_CYCLE;
) ?2 E( J5 ?) e/ v' Y* ?3 {% T2 R9 B            st_prep_buffer(); // Initialize step segment buffer before beginning cycle.初始化步開(kāi)始循環(huán)之前% B* h' S! }) G; {4 Z5 G7 Q# c5 G
            st_wake_up();! n. W" S9 ?2 t8 k  U: ^. p
          } else { // Otherwise, do nothing. Set and resume IDLE state.否則,什么也不做,設(shè)置和復(fù)位空閑模式8 ?2 ?& v7 I- r  ?
            sys.state = STATE_IDLE;( q+ l3 @9 y& x- r
          }) f. t: J' y. j( Q* Z# X$ W
          sys.suspend = SUSPEND_DISABLE; // Break suspend state.3 q7 B. ?4 P5 D) l
        }# t" [$ ]/ @1 c: _- t; f
      }    0 I6 K, o4 d/ y, X
      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_START);       
: @( \- g  ?) C) n, r2 D) P    }7 F6 }( i# w5 a; w9 A7 D, B2 |

! h* g- _# |* f_______________________________________________________________________________________________________, m) T: ~& K2 L1 O
    // Reinitializes the cycle plan and stepper system after a feed hold for a resume. Called by
" m' o$ q$ a7 E8 V, d    // realtime command execution in the main program, ensuring that the planner re-plans safely.2 E1 }$ k  z( L" x
    // NOTE: Bresenham algorithm variables are still maintained through both the planner and stepper
+ q1 O, C$ W8 N' K  z7 f! K7 `    // cycle reinitializations. The stepper path should continue exactly as if nothing has happened.   
! S7 I  Z4 ^! i' l+ j0 v! y& P$ i    // NOTE: EXEC_CYCLE_STOP is set by the stepper subsystem when a cycle or feed hold completes.3 {$ a3 U) z, x
5 j6 n8 p. i* q- p
        //重新啟動(dòng)后循環(huán)計(jì)劃和步進(jìn)系統(tǒng)的進(jìn)給保持簡(jiǎn)歷。通過(guò)實(shí)時(shí)命令執(zhí)行主程序,確保安全計(jì)劃重新計(jì)劃。
9 r( |" ~- G) Q        //注意:畫(huà)線算法變量仍保持通過(guò)規(guī)劃師和步進(jìn)( _9 H8 R+ r- Z$ [6 n& M7 u
        //循環(huán)僅。步進(jìn)路徑應(yīng)該繼續(xù),好像什么都沒(méi)發(fā)生一樣。       
6 K1 D1 M4 ?$ F        //注意:EXEC_CYCLE_STOP由步進(jìn)子系統(tǒng)周期或進(jìn)給保持時(shí)完成。
8 U! h' ~  g. |$ X/ k+ \4 {# l! t& U. T* }
    if (rt_exec & EXEC_CYCLE_STOP) {                         //如果是循環(huán)停止?fàn)顟B(tài)進(jìn)入) M- ?" x, i4 z+ H6 t
      if (sys.state & (STATE_HOLD | STATE_SAFETY_DOOR)) {: R# ?8 o# q4 D4 X) q! `
        // Hold complete. Set to indicate ready to resume.  Remain in HOLD or DOOR states until user& J# U9 g! ?8 `; Q* n
        // has issued a resume command or reset.
1 f& p, A; G- Q9 p% `) @1 }0 r& Q; o- T2 D& R
                //保存完整。設(shè)置為指示準(zhǔn)備簡(jiǎn)歷。繼續(xù)持有或門(mén)狀態(tài),直到用戶(hù)" B4 q' ?. e3 V9 h# M) Z
                //已發(fā)布了一份簡(jiǎn)歷命令或重置。
( Y5 }# s5 G, U* W3 {/ t7 I9 R1 g                7 O: M. z. t) t  `; w  N8 p
        if (sys.suspend & SUSPEND_ENERGIZE) { // De-energize system if safety door has been opened. 如果安全的門(mén)已被打開(kāi)。斷開(kāi)系統(tǒng)
+ W0 ~2 |9 k! I% [2 L          spindle_stop();
7 _& T8 Z; M0 J8 i* z          coolant_stop();# m6 v6 D, p, C
          // TODO: Install parking motion here. 安裝停車(chē)動(dòng)作。
! z3 o% e! K, X        }
, ^6 _  Z$ x' `; h3 M, \: i        bit_true(sys.suspend,SUSPEND_ENABLE_READY);9 \1 I, [7 F7 d. L# E( s
      } else { // Motion is complete. Includes CYCLE, HOMING, and MOTION_CANCEL states. 電機(jī)完成,循環(huán),回原點(diǎn),,MOTION_CANCEL( C/ E4 ~; Z& w
        sys.suspend = SUSPEND_DISABLE;
5 w/ V1 Z- m3 O" K$ ]( V( u        sys.state = STATE_IDLE;% D; N' a& V; f) y, W
      }3 R  \) z2 S  ~5 v+ e
      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_STOP);7 w' C6 r; c  y& s/ e' @1 R1 W! A
    }3 w  \0 Z( C- n3 I3 u
    + t# D4 V, {+ A' h7 h5 p; j
  }
* ~8 _$ k- n! E3 X; r2 V___________________________________________________________________________________________________7 A2 O( i, a' Y" x
: g+ V. p8 ^+ Q: O
  // Overrides flag byte (sys.override) and execution should be installed here, since they
1 C( e/ p. ]: z( r+ ^  // are realtime and require a direct and controlled interface to the main stepper program.
3 m" a9 O+ H! u8 Y" N6 Q6 ~  R% I9 W9 ^1 O
  //重寫(xiě)標(biāo)志字節(jié)(sys.override)和執(zhí)行應(yīng)該安裝在這里,因?yàn)樗麄?font class="jammer">5 S5 [  J/ Q5 h. \( i4 y
  //實(shí)時(shí)和需要直接和控制接口的主要步進(jìn)程序。
4 T) J! `( @" K5 l* N, x4 v* l
( f0 T0 n. Z1 ?8 S& r9 S3 I2 x' \  @) q4 i, O& o, z5 }2 [; [7 ?8 A) N
  // Reload step segment buffer 重新加載步段緩沖1 z  I1 [9 u2 Z% t5 \* e; q' v
  if (sys.state & (STATE_CYCLE | STATE_HOLD | STATE_MOTION_CANCEL | STATE_SAFETY_DOOR | STATE_HOMING)) { st_prep_buffer(); }   i' y! `0 X) X& D8 A
& B7 u( a9 m% W! H4 f) r) I
  // If safety door was opened, actively check when safety door is closed and ready to resume.
3 q* k% T, L: T5 M0 S  // NOTE: This unlocks the SAFETY_DOOR state to a HOLD state, such that CYCLE_START can activate a resume.        7 X0 V& [0 Z/ P
& L  @- u! }3 [- B  N
//如果安全的門(mén)被打開(kāi),積極檢查當(dāng)安全門(mén)關(guān)閉,準(zhǔn)備簡(jiǎn)歷。/ t) q% R& b' c0 x
  //注意:這解鎖SAFETY_DOOR狀態(tài)保持狀態(tài),這樣CYCLE_START可以激活一個(gè)簡(jiǎn)歷。
( F8 R' V1 W; N3 C
0 D" N: Q: G9 V9 R1 Y8 G  if (sys.state == STATE_SAFETY_DOOR) {                 //安全門(mén)狀態(tài)進(jìn)入
% ?+ T# V* t$ {! G4 f2 h9 P8 N; Z. s" q    if (bit_istrue(sys.suspend,SUSPEND_ENABLE_READY)) {
/ U, [, q" t! V2 p: L      if (!(system_check_safety_door_ajar())) {% [) w' Q3 `$ {- n& C
        sys.state = STATE_HOLD; // Update to HOLD state to indicate door is closed and ready to resume. 更新保存狀態(tài)指示門(mén)關(guān)閉,準(zhǔn)備簡(jiǎn)歷。
  a" ~7 K8 @( \6 y. c3 v      }
$ c# h1 ]4 ~5 A) Q! y% d    }- o. t( m& G3 \1 P0 P2 T
  }4 T1 M3 U+ a$ b
$ N9 R2 Z8 |' |, u% o9 L! \4 t8 v
  } while(sys.suspend); // Check for system suspend state before exiting.2 x& o. Z: c7 [
  
# h6 `1 v# _: k# x8 x}  
10#
發(fā)表于 2016-8-25 09:31:12 | 只看該作者
樓主這些代碼。是網(wǎng)上搜來(lái),然后自己組合的嗎?全是自己想的,那是牛逼了

點(diǎn)評(píng)

外國(guó)的開(kāi)源軟件grbl,在研究它,將打注釋了下而已,研究透徹了好移植的其他平臺(tái)應(yīng)用,學(xué)習(xí)階段。 https://github.com/grbl/grbl  詳情 回復(fù) 發(fā)表于 2016-8-25 22:19

本版積分規(guī)則

小黑屋|手機(jī)版|Archiver|機(jī)械社區(qū) ( 京ICP備10217105號(hào)-1,京ICP證050210號(hào),浙公網(wǎng)安備33038202004372號(hào) )

GMT+8, 2024-9-23 13:30 , Processed in 0.078891 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回復(fù) 返回頂部 返回列表