国产精品乱码一区-性开放网站-少妇又紧又爽视频-西西大胆午夜人体视频-国产极品一区-欧美成人tv-四虎av在线-国产无遮挡无码视频免费软件-中文字幕亚洲乱码熟女一区二区-日产精品一区二区三区在线观看-亚洲国产亚综合在线区-五月婷婷综合色-亚洲日本视频在线观看-97精品人人妻人人-久久久久久一区二区三区四区别墅-www.免费av-波多野结衣绝顶大高潮-日本在线a一区视频高清视频-强美女免费网站在线视频-亚洲永久免费

 找回密碼
 注冊會員

QQ登錄

只需一步,快速開始

搜索
查看: 19295|回復: 15

單片機MCP制作數控雕刻機3D打印機

[復制鏈接]
1#
發表于 2016-8-20 23:56:23 | 只看該作者 |倒序瀏覽 |閱讀模式
本帖最后由 1五湖四海1 于 2016-8-21 00:09 編輯 ) P4 }& C! S5 S4 d2 p! q# X
+ P; N5 J( p7 z, z7 m& A
    以前制作過CNC雕刻機,是用MACH3作為上位機控制,硬件是采用PC接并口輸出脈沖和方向使能信號經過隔離驅動步進電機驅動器,步進電機驅動是采用TB6560芯片控制。最后就接到步進電機。機械是用鋁合金制作,主要部件有三個1605的滾珠絲杠,多個運動滑塊等制作。用這臺DIY CNC雕刻機可以雕刻木頭塑料等東西。當時沒有一直玩下去,現在發現網上有用單片機制作的雕刻機挺精巧的現在分享給大家。7 R6 y+ u- k7 ?
   GRBL CNC 3D打印機,這就是我說的可以用單片機來控制的3D打印機,我先照著百度科普下grbl,Grbl是性能高,成本低,基于并口運動控制,用于CNC雕刻。它可以運行在Vanilla Arduino (Duemillanove/Uno) 只要它配備了Atmega 328型芯片。 控制器由C編寫并優化,利用了AVR 芯片的每一個靈巧特性來實現精確時序和異步控制。它可以保持超過30kHz的穩定、無偏差的控制脈沖 它接受標準的G代碼而且通過了數個CAM工具的輸出測試。弧形、圓形和螺旋的運動都可以像其他一些基本G代碼命令一樣完美支持。函數和變量目前并不支持,但是會作為預處理器包含在將來發布的版本之中。 Grbl 包含完整的前瞻性加速度控制。它意味著控制器將提前16到20個運動來規劃運行速度,以實現平穩的加速和無沖擊的轉彎。Grbl是性能高,成本低,基于并口運動控制,用于CNC雕刻。它可以運行在Vanilla Arduino (Duemillanove/Uno) 只要它配備了Atmega 328型芯片。 控制器由C編寫并優化,利用了AVR 芯片的每一個靈巧特性來實現精確時序和異步控制。它可以保持超過30kHz的穩定、無偏差的控制脈沖 它接受標準的G代碼而且通過了數個CAM工具的輸出測試。弧形、圓形和螺旋的運動都可以像其他一些基本G代碼命令一樣完美支持。函數和變量目前并不支持,但是會作為預處理器包含在將來發布的版本之中。 Grbl 包含完整的前瞻性加速度控制。它意味著控制器將提前16到20個運動來規劃運行速度,以實現平穩的加速和無沖擊的轉彎。很棒吧!開始玩起。6 b8 N& C7 l* P2 q7 a
    還沒有雕刻機的機械部分可以用廢舊光驅制作個微型雕刻機運動平臺。雕刻機最重要的是主控程序這次用 Arduino/AVR328單片機,價格在15元左右,主控程序是上面提到的目前很火的開源
的GRBL,還有一種基于STM32平臺的開源主控程序Dlion也不錯可以替代grbl。如果從性能比較這兩個方案,顯然是stm32平臺運行速度更快畢竟他是32單片機呀!
7 n9 T% h, d6 o3 _: H2 F$ W$ m& c0 F1 c
7 l' Y* B3 _7 e" \1 D0 C5 u" L0 O
    下面介紹小這個些主控程序主要干的事,通過串口PC和主控板通訊,PC命令給控制板,控制板接收命令做不同的響應,PC可以發G代碼給主控板,接收完成后可以自動開始雕刻任務。2 M' \# }' n$ i* Q, R
          在介紹下G代碼因為G代碼是雕刻機的核心部分
2 z! n1 \# S! }$ H1 O/ P: ?G代碼是數控程序中的指令。一般都稱為G指令。* a& D9 V) e! _$ z( q% b, |
G00------快速定位
' K; z/ d# h/ I$ [/ l0 MG01------直線插補" E7 j8 v+ I8 k: C9 \6 Y
G02------順時針方向圓弧插補
  a% q+ o6 U6 c! M8 fG03------逆時針方向圓弧插補* M6 ~; q3 }+ Q( }2 g( @
G04------定時暫停! e: L6 X0 H  X% |4 u1 T7 j  j8 A
G05------通過中間點圓弧插補
6 M" i3 Y% D" ?) K' _) X$ cG06------拋物線插補( O4 e- V9 Q+ r& k( q3 ?
G07------Z 樣條曲線插補( @( e( e! x$ K/ z6 Z+ S& ?
G08------進給加速, N6 Z4 g+ \" b5 b7 h% \
G09------進給減速: e3 k; i0 t4 W5 v5 P0 n2 ]6 ^
G10------數據設置" V' q3 P5 I& m  U) N
G16------極坐標編程
" o( V8 ]8 Y& O: i% `/ OG17------加工XY平面! ~4 N3 W4 n& ?3 |& M
G18------加工XZ平面
: T7 E3 z9 F& v' X! c4 R, h, Y  xG19------加工YZ平面
9 k2 H% c- }( k
核心就是解析G代碼,完成步進電機驅動,和控制主軸開啟關閉,還有插補算法,直線插補,圓弧插補,還有一些步進電機的加減速算法。; F5 P0 g" ]$ m% K+ N
下面對grbl主結構做介紹
! l4 w2 z3 [6 Y) l8 x' |  Lmain()主函數首先執行下面初始化函數  i9 F9 E+ l1 t- E4 ~
        serial_init();                           // 設置串口波特率和中斷
+ K5 y9 z4 P  e' ?        settings_init();                         // 從ROM加載grbl設置- @4 r5 D4 z4 l1 B" G& |% q
        stepper_init();                          // 配置步進方向和中斷定時器
" V# J6 i9 H! B8 l        system_init();                           // 配置引腳分配別針和pin-change中斷8 Y* L+ C* M$ d+ r# \8 X* \: s: F
        memset(&sys, 0, sizeof(system_t));          // 清除所有系統變量5 H3 R/ v3 S1 R* @- J+ q8 h7 I
        sys.abort = true;                           // 中止標識位置位& p$ r" o3 k# ^
        sei();                                         // 使能中斷
! U; B2 Q3 ^) F  z: N  #ifdef HOMING_INIT_LOCK                        // 宏運算(settings.flags & (1 << 4)) != 0結果flags等于執行sys.state = STATE_ALARM
5 {5 b* t0 l, f$ V" P. P" g' i                                                // 系統狀態賦值為報警狀態1 a- M6 u  S! M( j4 n% a  r3 [
            if (bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE)) { sys.state = STATE_ALARM; }+ y4 G# [0 X$ ^
  #endif; P8 S/ @$ k1 }4 ?
_____________________________________________________________________________________________________________________________________
$ ?  v; q; h* m" z/ `  h2 D8 F接下來是一些主要部分初始化
' G6 C1 m/ n7 i0 A/ Z7 G: ^( S8 B7 J) Pfor(;;) {
* f8 @# t0 l. S% d        serial_reset_read_buffer();         //清除串口讀緩沖區
) P* M! i5 H9 F% a5 A5 U        gc_init();                         //初始化G代碼功能函數
# X/ {  r3 r+ a# M        spindle_init();                        //主軸初始化
, S7 b& x  b& n& n        coolant_init();                        //冷卻液初始化6 o' U, [" [* S
        limits_init();                         //極限開關初始化
% d6 G: L/ p, S* @/ B- p        probe_init();                        //探測部件初始化
, J1 e# E! ]( O  |        plan_reset();                         //清除塊緩沖區和規劃師變量
+ D( w4 E4 R% Y$ U- k& C1 W        st_reset();                         //清除步進系統變量。
& Q- O  u) y& ^' u% v/ T
; v! k% I/ A$ Q5 W3 [1 p3 i$ d8 d0 F! h' P# c! @
        //下面兩行清除同步gcode和策劃師職位當前系統位置。
' |9 ^' B3 |1 v( M9 M0 Q
        plan_sync_position();
9 _6 D( j" z7 o& T0 d        gc_sync_position();2 p" g0 {% c5 Y

2 u/ T# R$ _5 y. @& b# W
$ t3 x  g$ @7 J5 D3 Q        //復位系統變量
( Q. O$ I7 @3 O1 T; E7 u4 n4 n        sys.abort = false;                //系統中止標志- b& g7 A2 \4 {+ b3 y
        sys_rt_exec_state = 0;                //系統標志位變量狀態管理。看到EXEC位掩碼。
( y1 D1 u4 D3 S3 ]1 g; Q) A        sys_rt_exec_alarm = 0;                //系統標志位變量設置不同的警報。- X. X; G2 P! T5 M" u* d+ L5 Y
        sys.suspend = false;                //系統暫停標志位變量管理,取消,和安全保護。+ g, o* O5 W6 M
        sys.soft_limit = false;                //限位開關限制狀態機錯誤。(布爾)
( a7 _& V- P5 F' V" F1 a
" |) H3 x! g# j$ G6 r4 Q: ]7 S! K' ]: v5 N, Z2 W/ f
        protocol_main_loop();                //主協議循環+ {4 p2 K0 E) S5 d9 ^
}        //7 H  V) n+ Q, Q1 t
_____________________________________________________________________________________________________________________________& L" A5 F7 r- y: ?# P2 \  C' x: j
進入void protocol_main_loop()函數
; K6 @4 I5 U2 N{6 N5 z% E" I% a* x- q% S% u
        report_init_message();                // 打印歡迎信息 ) e9 ~; B# A( g
        //重啟后檢驗和報告報警狀態如果錯誤重啟初始化。
3 @  P0 L% }$ f! s& m) _
        if (sys.state == STATE_ALARM) {
8 X# [. Q$ G* V# z9 o4 q" W            report_feedback_message(MESSAGE_ALARM_LOCK); //打印信息! e! d+ p" G+ X  B9 K2 p; c
          } else {
: g1 A  k; {& [. }  \) T+ m% Y            // 如果沒有報警說明一切正常!但還是要檢查安全門. + n# C5 ~/ J+ y; N# K" T- `
            if (system_check_safety_door_ajar()) {
/ r5 O* ^8 b5 g5 n! J( y; e# A) M                     bit_true(sys_rt_exec_state, EXEC_SAFETY_DOOR);
0 w7 |4 v7 `9 z                     protocol_execute_realtime(); // 進入安全模式。應該返回空閑狀態。+ K% \/ Q% V  ?$ G. R# t
            }         else {
5 h5 c0 i6 ^* T% h1 H              sys.state = STATE_IDLE; // .設置系統做好準備。清除所有國家國旗。
) P) p0 ~: C, d, `. O$ z" G2 d            }
* L: H7 [- ?5 u7 G            system_execute_startup(line);    //開始執行系統腳本
. Y. X0 F, R; v  U) o$ m1 z% Y$ K" }  } : o) b. j" r" z
& V4 E# z7 j& z# u/ V3 w* f0 u( W

; t* N# i9 N$ y. B  // 這是主循環!在系統中止時這是出口回到主函數來重置系統。, b5 m5 Z% S7 e& T; r3 a9 m
  // ---------------------------------------------------------------------------------  - s+ K; L4 q  v+ o8 ]  w# B
  + u* C) w9 f) e! g
        uint8_t comment = COMMENT_NONE;
. {; h# ~. n+ Z' i$ ~. z        uint8_t char_counter = 0;
- E# j6 A. o  `" t- r! k4 P        uint8_t c;+ R4 V% k4 \) A" K  Y
_______________________________________________________________________________________________________________________________
0 S+ o( x% r+ c/ i# ^接下來進入for(;;)循環                //下面代碼是G代碼解析核心部分,程序中comment(注釋)變量會被賦不同值,代表發符號有‘(’‘)’‘;’
+ H! ]( D# G/ I( C; O{* W5 B( d( D9 d0 D( k8 l
//串行數據輸入一行的的過程,作為數據。執行一個% b! Y; x; E& w2 ^  Z; D
//所有數據初始過濾去除空格和注釋。 . U% x# d+ W/ r
//注意:注釋,空格和程序段刪除(如果支持的話)處理技術$ ?/ h# z* n2 c2 {. \
//在G代碼解析器,它有助于壓縮到Grbl傳入的數據
9 I$ H9 F0 v" M9 L" u2 d' _3 ]//線緩沖區,這是有限的。刀位點標準實際上州一行不行, O' u- b1 i  G* `2 G' L0 Q
//不能超過256個字符,Arduino Uno沒有更多內存空間。. W3 E* J1 C" `4 a% `
//有更好的處理器,它會很容易把這個初步解析的
% r! u! l; \" g1 p7 Z' G: ~: K- v//分離任務共享的刀位點解析器和Grbl系統命令。                                                               
3 B# G2 v4 L/ I) r+ d( |2 L  a    while((c = serial_read()) != SERIAL_NO_DATA) {                             //讀取串口數據,有數據執行下面代碼
& I. ?7 _5 }" W" A! k      if ((c == '\n') || (c == '\r')) { // End of line reached                //如果數據是/r,/n代表一行結束
# u9 p) _9 r  A) T        line[char_counter] = 0; // Set string termination character.        //設置結束標志
- {$ `# I8 X  {/ v3 C0 _* c        protocol_execute_line(line); // Line is complete. Execute it!        //一行完成執行此函數1 N" ?, C" j& W. n
        comment = COMMENT_NONE;                                                //注釋清零
0 P7 q" j7 n* W% v- ?  a        char_counter = 0;                                                    //字符計數清零( H8 y$ _$ N% _$ ]+ j7 t
  
1 P/ t' T; g- F1 k/ f        else {- S7 U, w1 ?3 f" w1 @
        if (comment != COMMENT_NONE) {
; y: X6 c; e7 J: o; q' u1 N; c- e                                                     //扔掉所有注釋字符
! N7 T9 d3 J9 C* O: W0 l          if (c == ')') {# R6 H+ a$ J! j
            //最后注釋。重新開始。但是如果有分號類型的注釋。
$ e/ j  ~0 D/ D: w; N6 J  n            if (comment == COMMENT_TYPE_PARENTHESES) { comment = COMMENT_NONE; }0 M- L* D* g2 m" o
          }4 }1 n0 e; h: G
      } else {. K5 i7 x8 [" O: Q& R* S5 ~
          if (c <= ' ') { 5 }' _! S2 b# J$ l
            //扔掉whitepace和控制字符
/ `4 c5 X/ _6 _: t          } else if (c == '/') {
5 @$ |( t/ L. c' w5 j: y# f            //塊刪除不支持將忽略字符。$ X$ [' R2 K8 P- G2 s- g# |- }
            //注意:如果支持,只需要檢查系統是否啟用了塊刪除。
/ J" n7 X- {+ q' e% R* `( p          } else if (c == '(') {3 T% ~* S& e7 ]! U: F
            // Enable comments flag and ignore all characters until ')' or EOL.6 ^* Z9 Z& ~, ?# G/ u! U0 Y$ C
            // NOTE: This doesn't follow the NIST definition exactly, but is good enough for now.
9 i! D/ t; ~5 F3 h8 p  L6 u4 e! `            // In the future, we could simply remove the items within the comments, but retain the. U, b9 ]: B* V
            // comment control characters, so that the g-code parser can error-check it.
2 l2 M7 ]0 j& e$ N* A" J; Z# B            comment = COMMENT_TYPE_PARENTHESES;& o9 o8 C  O4 c( u7 Z4 |
          } else if (c == ';') {' n9 I' ^: Y" u6 O7 C5 ~3 {
            //注意:','注釋EOL LinuxCNC定義。沒有國家標準。
9 p/ N, ?! t  |5 D9 L6 a            comment = COMMENT_TYPE_SEMICOLON;# f5 E8 y# ~1 _1 U- |2 I( O
; x) X( n- `; |

* q$ N8 Q# d! _) D7 U+ P% |  Z_____________________________________________________________________________________________________________________________________- U" {, o' D4 ?$ l9 a+ n
          } else if (char_counter >= (LINE_BUFFER_SIZE-1)) {                        //串口接收數據大于80字符時  ^. l2 @$ n2 }% d* Z  P; Z
            // Detect line buffer overflow. Report error and reset line buffer.        檢測緩沖區溢出。報告錯誤和復位線緩沖區。
! [7 D$ ?$ x: R: e6 O/ W            report_status_message(STATUS_OVERFLOW);                                //打印溢出信息  u- [( S7 u# ?! B( n! y7 H
            comment = COMMENT_NONE;7 c- [( b# s+ J- C) T
            char_counter = 0;; r- z6 ?' o0 S6 W2 u: a
          } else if (c >= 'a' && c <= 'z') { // Upcase lowercase                        //小寫改大寫% S# ~3 x5 e3 R6 _$ I, e( _6 q* o
            line[char_counter++] = c-'a'+'A';
+ _9 S( a, p& z  x( l: G          } else {; _" l+ B1 W5 C" q- x
            line[char_counter++] = c;% ~0 F5 G1 n! m: G4 U
          }
/ f9 ]5 L  `1 M  ?3 y) U        }) u, E3 L$ T* a6 q
      }, D/ O8 w4 t& a8 ?* l" n
    }) L6 m0 s. S. {) i4 v' t/ T% \
____________________________________________________________________________________________________________________________________
8 i" A9 L3 D6 d6 G5 X/ ]' h+ l        //如果沒有其他字符在串行處理讀取緩沖區和執行,這表明以完成,自動啟動,如果啟用,任何隊列動作。/ Y0 y5 H+ O' k1 |3 I6 s$ e
        protocol_auto_cycle_start();                //自動開始協議循環
& H3 F1 H' E0 ~* c9 d        
/ H* d' [+ @5 L- Q            protocol_execute_realtime();                  //運行實時命令。
) \: }6 }7 O% N            if (sys.abort) { return; }                 //中止標識置位程序循環重置系統。            + K0 w) O3 l3 k, G( _
  } . r! {3 z6 {6 O: Q6 c9 G  _9 ]6 E
  return;                         //一般程序不會執行到這里
, J/ y6 _8 t9 S" t2 x4 X}, o2 {1 f/ M, m" u+ k/ O+ p
____________________________________________________________________________________________________________________________________, R( s4 h0 t3 x' O4 v9 }
正常情況下,讀取完G代碼程序會進入protocol_auto_cycle_start();//自動開始協議循環 函數下面介紹此函數
: H# W2 X' |" t+ f/ B5 _8 T// Auto-cycle start has two purposes: 1. Resumes a plan_synchronize() call from a function that
* m1 o3 n! E, i( p6 ^// requires the planner buffer to empty (spindle enable, dwell, etc.) 2. As a user setting that & D2 X$ b. d! U' z
// automatically begins the cycle when a user enters a valid motion command manually. This is
& e: }( D9 P1 _7 ^// intended as a beginners feature to help new users to understand g-code. It can be disabled
1 e1 b1 }) o* f# T// as a beginner tool, but (1.) still operates. If disabled, the operation of cycle start is
. V* W" {$ E# P// manually issuing a cycle start command whenever the user is ready and there is a valid motion * F1 q8 C1 ]- r! A. H
// command in the planner queue.
% e1 l2 H& y, Y! R( a// NOTE: This function is called from the main loop, buffer sync, and mc_line() only and executes 5 {3 ~. R! D9 Z% \! t$ ]
// when one of these conditions exist respectively: There are no more blocks sent (i.e. streaming
+ E& `7 ~$ l( B! |7 ?% o// is finished, single commands), a command that needs to wait for the motions in the buffer to * A- N0 J6 P% [6 A+ o  f
// execute calls a buffer sync, or the planner buffer is full and ready to go., M0 v5 t# h2 C; a7 T- C: @
//自動開始有兩個目的:1。回復一個plan_synchronize()調用的函數; C) T9 ~+ N/ H+ O" ]. i
//需要規劃師緩沖區空(主軸啟用、住等)2。作為一個用戶設置
4 h0 V( \8 E. ]2 }$ J//自動循環開始當一個用戶輸入一個有效的運動命令手動。這是3 J! a* f6 ?% J. m
//作為一個初學者的特性來幫助新用戶了解刀位點。它可以被禁用2 J. @( O. M0 U) L% f
//作為一個初學者工具,但(1)仍然運作。如果禁用,運行周期開始
  l% t3 w, x5 N% Z5 C( ~: n//手動發出一個周期開始命令每當用戶準備好,有一個有效的運動
6 f/ I  n& o; N# `2 C2 @9 D5 ?//命令的規劃師隊列。
) [' n; `$ G9 U/ [//注意:這個函數被稱為從主循環緩沖區同步,mc_line只()并執行9 w% a, D* O2 Z- ]0 J6 C5 K3 {
//當其中一個條件分別存在:沒有更多的塊(即流發送
( U1 `7 t2 }" Y2 _" r1 P//完成后,單一的命令),一個命令,需要等待緩沖的動作7 {, P- q1 N  A) S
//執行調用一個緩沖區同步,或規劃師緩沖區滿了,準備好了。6 |8 E8 e0 `* J# Y: A9 \
void protocol_auto_cycle_start() { bit_true_atomic(sys_rt_exec_state, EXEC_CYCLE_START); }
, L7 p2 U1 V% C; c& ^9 e_______________________________________________________________________________________________
9 a$ S5 e+ Y9 R$ P接下來程序運行protocol_execute_realtime(); /運行實時命令。
' \5 V6 C+ L: l  }5 `9 x// Executes run-time commands, when required. This is called from various check points in the main
' g! t! Y% \& s, A0 ?// program, primarily where there may be a while loop waiting for a buffer to clear space or any
0 ?3 Y$ j! \, d3 B) C" q8 J// point where the execution time from the last check point may be more than a fraction of a second.5 V6 v5 Z6 T* A! m3 \2 A5 E
// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code
/ E# }. f5 M( }5 Y6 p! j5 E// parsing and planning functions. This function also serves as an interface for the interrupts to
' k  e2 V) p6 Q// set the system realtime flags, where only the main program handles them, removing the need to, c& N  K# M7 H
// define more computationally-expensive volatile variables. This also provides a controlled way to
! U2 `6 [2 F/ T" {7 M// execute certain tasks without having two or more instances of the same task, such as the planner
! B0 {$ U% J3 z3 J2 r4 u8 S* P% a4 N" f// recalculating the buffer upon a feedhold or override.# o9 k( C4 E* Z3 o
// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,
# D' n# N; p# m- ]% q1 ~% S// limit switches, or the main program.$ p, s5 [9 O8 O; |" a
void protocol_execute_realtime()
4 I( G9 ^( S5 _9 n2 ?/ X8 ~ uint8_t rt_exec; // Temp variable to avoid calling volatile multiple times.臨時變量來避免多次調用不穩定。: t8 v- D( {7 _( t* O
就先分享到這吧!* ]2 K0 W9 T' F! l
; y8 |" ~4 a& x, C  E8 a
& W" p4 d4 {9 p+ o1 M

# Y/ A2 X( C: F  d/ J- c4 D0 f" L& D1 `. d$ x/ ]& Q
9 |7 K( w% ~* M( I3 e, y
, }1 M. ?* X( N# [8 b, {1 w$ g

/ P" m( K/ R& _1 N& J
  V$ z9 d& k( w- m% v: W
. n/ J8 {. j4 z" o8 R, z6 y# l* S# k+ u! E/ f7 B

4 P: P# W# V/ C
. q6 _- q0 K) V! N( s$ {5 P  F

4 u) ^8 o  A3 Y$ w- U# a" O
9 S0 D8 }0 Q. ?8 \5 j
3 P$ M$ E: M  j$ ^! q/ X( b
* Y0 o8 m9 |, S7 ~! n
& i3 j& V; d/ X' O( Q8 J- G7 ]- L# _
5 ?3 y5 @! w; h8 i& r
4 r/ ~# z8 X6 z! r; R% r& C
: Y# C5 B( D9 k7 ?) s/ g- v8 P

& V$ O0 X" e0 f* Z$ j補充內容 (2016-8-25 22:40):
- n5 `4 R& P" F配置說明
& ?: E) X+ |# L5 y//這個文件包含編譯時配置Grbl的內部系統。在大多數情況下,
- m  R* G4 ^5 i- H% }: u  _# q( d//用戶不需要直接修改這些,但是他們在這里為特定的需求,即。* l9 y$ ]' H; Y0 q" q+ q3 G. a
//性能調優或適應非典型的機器。
* Y/ }: X- P6 G2 Z8 f主要配置項:
- @% h( w% E% \) v1.#define DEFAULTS_GENERIC        //在重置eepm時使用。在defaults.h改變想要的名字
5 C0 D9 Q! t  \; I/ A, ]2.#define BAUD_RATE 115200        //配置串口波特率115200
+ S6 b; p" S9 F3.#define CPU_MAP_ATMEGA328P         // Arduino Uno CPU
7 y" A9 k+ H0 f; _+ ^6 ~( o! Y4.#define CMD_STATUS_REPORT '?'        //定義實時命令特殊字符
4 h8 L# j# q% z! O7 ~5.#define HOMING_INIT_LOCK         //回原點保護鎖
+ K5 i0 v% n; Q' ~& D- ?. `6.#define HOMING_CYCLE_0 (1<<Z_AXIS)              // 第一步Z清除工作區。+ T# I8 o, u+ Z# M# k6 H) Y
  #define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // 然后X,Y在同一時間。, H. H$ U; N1 f; Z0 c6 D2 y4 k
7.#define N_HOMING_LOCATE_CYCLE 1 //回原點循環次數+ R( S. C2 R6 v, Q
8.#define HOMING_FORCE_SET_ORIGIN //取消這定義迫使Grbl總是在這時候位置設置機器原點盡管開關方向。
0 ?  c  n: y9 \* b& K+ Y/ `9.#define N_STARTUP_LINE 2 //塊Grbl啟動時執行的數量。# l+ Q3 g: L& W
10.#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 協調或位置價值英寸* k- C0 r" c8 d. t
   #define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 協調在毫米或位置價值
- ]' t' q6 e9 d- e1 l4 r   #define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分鐘的速度值* X1 C! p) a) M; y; G8 x( B
   #define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分鐘* a$ ^) D( _. u/ \
   #define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 對浮點小數設置值' d" T5 P: k2 K7 M8 t5 U; E6 y' X) u
11.#define LIMITS_TWO_SWITCHES_ON_AXES //如果你的機器有兩個極限開關連接在平行于一個軸,您需要啟用這個特性7 K5 l) D. v6 b( k
12.#define USE_LINE_NUMBERS         //允許GRBL跟蹤和報告gcode行號
% Z" h' _4 v- X5 ?5 V# Q3 n1 d13.#define REPORT_REALTIME_RATE //允許GRBL報告實時進給速率
, F7 ]1 f% `8 m6 w# r2 S14.#define MESSAGE_PROBE_COORDINATES  //坐標通過Grbl $ #的打印參數?
; l" q) u$ z7 \& R; T15.#define SAFETY_DOOR_SPINDLE_DELAY 4000 //安全門主軸延時
  A* Z& A# g0 h  z16.#define SAFETY_DOOR_COOLANT_DELAY 1000 //安全門冷卻液延時
, S- l' F- h/ J4 k' h17.#define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS) //啟用CoreXY運動學。
( Q8 s% t/ Z3 j. U2 f! v18.#define COREXY // Default disabled. Uncomment to enable.改變X和Y軸的運動原理0 J. @& s  c& N0 X
19.#define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.反轉針銷邏輯的控制命令5 c0 p% a( D, S, t/ F& U# B! j+ p1 H
20.#define INVERT_SPINDLE_ENABLE_PIN // 反轉主軸使銷從low-disabled
6 O0 G: l8 e" t6 L3 j1 {21.#define REPORT_CONTROL_PIN_STATE //啟用控制銷狀態反饋狀態報告。
, k9 h+ y% S; {7 Z) @22.#define FORCE_INITIALIZATION_ALARM //啟用和用戶安裝限位開關,Grbl將啟動報警狀態指示
7 Z# m3 a0 h3 w23.#define REPORT_GUI_MODE // gui允許最小的報告反饋模式
, j9 j' E# X0 V; \24.#define ACCELERATION_TICKS_PER_SECOND 100 //加速度的時間分辨率管理子系統。- G5 N0 S2 L! {7 K. B, e. w; O
25.#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING //自適應多軸步平滑(積累)是一種先進的功能
: ~( r% L9 B$ m5 b# d* P7 J0 S  L26.#define MAX_STEP_RATE_HZ 30000 //設置最大一步速率可以寫成Grbl設置
3 a3 y* U% ~+ G$ O# G) N' t27.#define DISABLE_LIMIT_PIN_PULL_UP //以下選項禁用內部上拉電阻
0 v; O5 `+ W/ r, J0 c+ X' S28.#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS //設置哪個軸長度補償應用的工具。假設軸總是與選擇軸工具面向負方向4 k. f3 R' y8 o: C0 P! M6 T
29.#define VARIABLE_SPINDLE //允許變量軸輸出電壓不同的轉速值。
. x1 R) J8 |  M+ c30.#define SPINDLE_MAX_RPM 1000.0  // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.* p0 w1 e; v: H" F( c6 D9 @
   #define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.
3 v4 t/ f& V, b31.#define MINIMUM_SPINDLE_PWM 5 //使用的變量軸輸出。這迫使PWM輸出最小占空比時啟用。2 s: J) _! n- N6 V
32.#define USE_SPINDLE_DIR_AS_ENABLE_PIN //主軸方向使能M4被刪除
9 K* R2 E, F/ k; T' k  B33.#define REPORT_ECHO_LINE_RECEIVED //應該對所有正常線路送到Grbl# g$ W4 b0 M2 M1 z& b
34.#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min) //最小規劃師結速度。設置默認最小連接速度規劃計劃8 `2 }. N% t! S
35.#define MINIMUM_FEED_RATE 1.0 // (mm/min)//設置計劃將允許的最小進給速率$ {( G% }6 J+ u; m  m& K* \. y
36.#define N_ARC_CORRECTION 12 //弧生成迭代次數之前小角度近似精確的弧線軌跡
7 V5 y6 L4 ~. @37.#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)//定義值設置機器ε截止來確定電弧是一個原點了?' m7 k4 V4 e. h( C% a
38.#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds) //延時增加表現在住。默認值設置為50毫秒
+ C7 S) T: v, T+ k% g39.#define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.! {9 T/ b/ n4 S8 h, |
40.#define BLOCK_BUFFER_SIZE 18  //線性運動規劃師緩沖區的數量在任何給出時間計劃
: r+ x; j3 J9 U2 t& E0 K+ o41.#define SEGMENT_BUFFER_SIZE 6 //控制之間的中間段緩沖大小的步驟執行算法
! y& o  y7 Q3 J# J1 A8 i42.#define LINE_BUFFER_SIZE 80 //行執行串行輸入流的緩沖區大小。
' P8 u# d# o# y+ ^. O3 x43.define RX_BUFFER_SIZE 128 //串行發送和接收緩沖區大小- s0 Z- T0 g! U3 W# z1 H
44.#define TX_BUFFER_SIZE 64
3 O) g* H4 \& ~+ f, P) z8 F8 R8 D: m) Y45.#define ENABLE_XONXOFF        ////切換為串行通信發送流軟件流控制。1 q. M' T% R9 r7 i
46.#define ENABLE_SOFTWARE_DEBOUNCE //一個簡單的軟件消除抖動特性硬限位開關。
4 J8 Y# s' |5 G4 e2 n6 ?( o47.#define HARD_LIMIT_FORCE_STATE_CHECK        //Grbl檢查硬限位開關的狀態
' s( E6 y2 M4 u- N; a48.// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:編譯時錯誤檢查的定義值:, w& p9 D8 R. p8 }; E  p

- N+ ^' l: P8 q4 h8 t2 ^___________________________________________________________________________________________________5 ?# N0 q+ ]/ V' q8 m2 ]
/*  ?/ K% F+ I2 v8 Z2 o, k
  config.h - compile time configuration
$ [& H2 i) b: q  Part of Grbl+ C, M% |$ @& i7 a& ]+ Q8 ?* h' Q

1 Y3 M0 M# B% V; ?+ s; E$ h  {  Copyright (c) 2012-2015 Sungeun K. Jeon5 @9 i% `% F; q3 |6 [- d
  Copyright (c) 2009-2011 Simen Svale Skogsrud
! p4 U* q7 @( P% [, |
1 ^6 C9 Z4 a3 y; Q0 j: c1 N  Grbl is free software: you can redistribute it and/or modify1 [8 u5 I. L* q
  it under the terms of the GNU General Public License as published by
5 J  j& M8 M# r) W1 s5 l  the Free Software Foundation, either version 3 of the License, or" J. e; J$ X# Y$ c
  (at your option) any later version.
- D% M9 H8 H# n1 |7 J% ~' h6 F+ [; Y) |/ s- G3 R$ Z
  Grbl is distributed in the hope that it will be useful,
+ G) q# F, ~0 k  but WITHOUT ANY WARRANTY; without even the implied warranty of
6 k5 M) G9 n; G6 y/ [  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the1 F- u, Z; c; u4 R
  GNU General Public License for more details.7 T$ m: G9 N; u) A4 w; U

3 c! K7 f' h4 H1 y  You should have received a copy of the GNU General Public License/ i; N4 P. d. d( |) [
  along with Grbl.  If not, see <http://www.gnu.org/licenses/>.
4 e9 n1 l- q$ i# l$ `config.h  -編譯時配置,Grbl的一部分
% l* g' r9 q- r' w$ v5 ~( t4 }3 t
# A# i& @& z& E4 l* T4 H- r& g+ O版權(c)2012 - 2015 Sungeun K. Jeon0 t0 ^0 K( v0 w0 _9 m
版權(c)2009 - 2011 Simen Svale Skogsrud
/ R' M0 K3 @9 q4 q
! l+ D( q9 {, y3 n' T- v  CGrbl是免費軟件:可以重新分配和/或修改! U) }1 F1 r9 J
GNU通用公共許可證的條款下發布的自由軟件基金會,版本3的許可,或(任您選)其后的版本。
/ X2 h" e3 `5 ^  h! X
9 F- u1 v3 V! @  \1 t% c+ eGrbl分布,希望這將是有用的,但是沒有任何保證;沒有即使的默示保證適銷性或健身為特定目的。看到. q! h# O2 ]/ `* z% k, E" K+ u* q9 `
GNU通用公共許可證的更多細節。
" G: Z+ k) J9 k
' ?2 ~+ @# h6 t你應該收到了GNU通用公共許可證的副本
$ H1 _+ r1 F" M$ ^2 W連同Grbl。如果沒有,看< http://www.gnu.org/licenses/ >。# ]3 q9 X! p3 F6 |( ~
! g0 a* R# S5 a  l; k; V4 A/ O8 K
*/
6 M! a; T' a# v" ]# G+ }  
; z# P2 Z6 b, l8 N& \* A) R// This file contains compile-time configurations for Grbl's internal system. For the most part,
+ F$ W( p2 w: w* r0 t// users will not need to directly modify these, but they are here for specific needs, i.e.
1 i- D* J/ h) b# D+ m6 ?, j// performance tuning or adjusting to non-typical machines.! a* F* A4 A; T# l
//這個文件包含編譯時配置Grbl的內部系統。在大多數情況下,
" W5 r7 r: v. }9 M2 d, K) W//用戶不需要直接修改這些,但是他們在這里為特定的需求,即。
0 D) ^$ p1 O" y: ?. T. U//性能調優或適應非典型的機器。
+ W& |7 D9 \% n; w4 I: @0 K) n3 g3 ~7 E* n: L
// IMPORTANT: Any changes here requires a full re-compiling of the source code to propagate them.
1 E* Q! q3 a8 C8 c; P0 M//重要:任何變化需要一個完整的基于源代碼的傳播。
9 u  v2 Z8 H7 l( x& e8 [' t' Z2 C5 a7 K8 Z1 [6 C/ a) t3 D% G9 F/ x
#ifndef config_h) O9 u' i. q( k
#define config_h
. Q; k) W$ d: E2 R% t" D#include "grbl.h" // For Arduino IDE compatibility.8 \+ r# l* o, G
' }4 P; R9 o1 E- w- L/ B5 K6 |# f
// Default settings. Used when resetting EEPROM. Change to desired name in defaults.h
% G: T3 T2 W: N% ~// 默認設置。在重置eepm時使用。在defaults.h改變想要的名字8 N; x9 a1 i  r0 C4 e! y+ Q- s3 `
$ b, X! g) G& X0 {6 J
#define DEFAULTS_GENERIC
8 I+ {5 c6 E, g6 y& X3 D
) s( a( `& [, l8 q+ @$ }0 C/ X// Serial baud rate
2 z* \0 a2 s- d#define BAUD_RATE 115200                //配置串口波特率115200) v0 m2 O, {: r+ B" T- Y6 x. \. j' T

5 x: f6 ], m* D! `// Default cpu mappings. Grbl officially supports the Arduino Uno only. Other processor types; X0 t  b& y( G  H8 T9 c
// may exist from user-supplied templates or directly user-defined in cpu_map.h
7 C/ n$ R5 U  ^, n//默認cpu映射。Grbl正式支持Arduino Uno。其他類型的處理器可能存在cpu_map.h直接從用戶提供的模板或用戶定義的" g' q2 Q& t. [, G

# q0 W( b4 w- K/ Y8 ^6 A3 z7 B#define CPU_MAP_ATMEGA328P // Arduino Uno CPU
( Q! l7 i3 P2 q4 a7 \( M: b  E! O; x4 {( T* ~+ ]7 f  Z* H  R
// Define realtime command special characters. These characters are 'picked-off' directly from the7 N$ M" |* `+ J& w) F
// serial read data stream and are not passed to the grbl line execution parser. Select characters
% x0 s$ L; Z4 n. N// that do not and must not exist in the streamed g-code program. ASCII control characters may be ) \1 A' T$ J, ]5 H# _
// used, if they are available per user setup. Also, extended ASCII codes (>127), which are never in
: i/ l: @* a) E; `// g-code programs, maybe selected for interface programs." m6 {- {- m# g. C; t) B' I* C
// NOTE: If changed, manually update help message in report.c.1 O6 {4 V: }2 g: h' t) u/ ]! o' V

# h- L6 i6 @. `0 a( o/ Y//定義實時命令特殊字符。這些字符是直接從“各個擊破”串口讀取數據流并沒有傳遞到grbl行執行解析器。選擇角色
4 |9 \7 A/ R1 x5 r, L: z4 a- s2 j//不,不能存在于程序流刀位點。ASCII控制字符9 \2 d/ \* F" @
//使用,如果他們是可用的每個用戶設置。同時,擴展的ASCII碼(> 127),從來沒有
$ d; X2 |& i) B+ X//刀位點的程序,也許選擇界面程序。
! U( K* f8 ^; r//注意:如果改變,手動更新report.c幫助信息。+ \" Q: _0 Z% V4 ^5 i" z1 E2 K
$ v9 t/ t& |9 T1 h) _, q
#define CMD_STATUS_REPORT '?'
# a8 M4 [7 u0 B8 }#define CMD_FEED_HOLD '!'
) W6 g4 L1 t% P% @) C#define CMD_CYCLE_START '~'
- t% h# E1 ?$ b- U2 V3 A* u#define CMD_RESET 0x18 // ctrl-x.
8 }$ V! T" q$ K! ?#define CMD_SAFETY_DOOR '@'8 B, `  S8 w8 m9 w4 ~" W
# @  a1 |3 n" F, y
// If homing is enabled, homing init lock sets Grbl into an alarm state upon power up. This forces' M1 |8 N. }: a8 x2 V
// the user to perform the homing cycle (or override the locks) before doing anything else. This is% u. I- ^# k6 e1 W- P& I7 a
// mainly a safety feature to remind the user to home, since position is unknown to Grbl.
) c; O1 V$ w( z  Q' O& s1 H. w5 z$ k6 H, I3 i/ g" T1 d
//如果啟用了回原點,導航初始化鎖集Grbl進入警報狀態啟動。這就迫使9 Y8 |! D: Q! \. j8 G/ y
//用戶執行歸航周期(或覆蓋鎖)在做任何其他事情之前。這是! ]! @8 s+ @4 J+ w- U
//主要安全功能,提醒用戶家里,因為Grbl位置是未知的。
/ a) ^+ c# S% r, g( N! E4 k
9 _  _  q" J6 p8 E) ~- H#define HOMING_INIT_LOCK // Comment to disable
! \  k; _" Y+ V# L4 o) E, T! h7 L8 k! G* X/ }) h- P
// Define the homing cycle patterns with bitmasks. The homing cycle first performs a search mode7 F* Q- c9 P2 ?- A
// to quickly engage the limit switches, followed by a slower locate mode, and finished by a short- G# A; B) D8 E  v/ ~, U- f
// pull-off motion to disengage the limit switches. The following HOMING_CYCLE_x defines are executed - V$ k$ X: i. c4 m& f
// in order starting with suffix 0 and completes the homing routine for the specified-axes only. If
9 N' o1 A3 }2 O4 G* ?' R5 g% D// an axis is omitted from the defines, it will not home, nor will the system update its position.
) G% \' d7 Q5 ^2 O6 P. f1 r  T" e2 [8 ~// Meaning that this allows for users with non-standard cartesian machines, such as a lathe (x then z,
& a' m  V1 ^! K, L1 \& X3 U+ o6 [// with no y), to configure the homing cycle behavior to their needs.
  a4 N: b  F! f; }$ l0 N! l# r! t/ F4 ~3 @// NOTE: The homing cycle is designed to allow sharing of limit pins, if the axes are not in the same2 R, x9 }, z  H# T: @8 d* G6 t
// cycle, but this requires some pin settings changes in cpu_map.h file. For example, the default homing
% F# L" w8 d/ I; ^2 Y// cycle can share the Z limit pin with either X or Y limit pins, since they are on different cycles.
! _( P* C3 a! |. m// By sharing a pin, this frees up a precious IO pin for other purposes. In theory, all axes limit pins
& |7 J2 |  @. u1 I) \; \, J// may be reduced to one pin, if all axes are homed with seperate cycles, or vice versa, all three axes" K* }9 Q8 G0 o- E' ]$ Q& I
// on separate pin, but homed in one cycle. Also, it should be noted that the function of hard limits
/ m) l9 a2 j% o: o3 i, @: n// will not be affected by pin sharing.3 ]: Y' s; ^' @8 _, ~
//定義導航循環模式的位掩碼。歸航周期首先執行一個搜索模式
. O& t* i# E( a; @/ D4 B. Y7 c//快速進行限位開關,其次是較慢的定位模式,完成了由一個短
/ R0 i* D4 e  P" m//拖出運動脫離限位開關。以下HOMING_CYCLE_x定義執行
/ j9 |3 K4 `; s//為了與后綴0開始并完成specified-axes只尋的例程。如果3 h9 u) D  n& I) b$ \4 O
//定義省略一個軸,它會不在家,也不會系統更新它的位置。- H" l9 z* h+ @$ ^" c  R. j* t
//意義,這允許用戶與非標準笛卡爾的機器,比如車床(x,z,) Z- G- w' G/ ~8 \( R
//沒有y),配置導航循環行為對他們的需求。
3 O" }5 r% |6 X7 v6 l6 A0 e//注意:歸航周期允許共享限制針,如果軸不相同
" J/ x, n& R/ S( A+ K+ B//循環,但這需要一些銷設置cpu_map的變化。h文件。例如,默認的導航! @; O6 z, ?4 m, p, k
//循環可以分享Z限位銷X或Y限制針,因為它們是在不同的周期。
6 u& ^% |0 o- b- L, y- j3 y//通過共享一個銷,這騰出寶貴的IO銷用于其他目的。從理論上講,所有軸限制別針
" f9 M+ r7 {; t  N2 U//可能會減少到一個銷,如果所有軸與分離周期居住的地方,反之亦然,所有三個軸0 ?- T' C* W4 i2 ]% T
//在不同銷,但這時候一個周期。同時,應該注意的是,硬限制的功能- K1 ~" j9 J1 y6 l% [) E4 m
//將不會影響銷共享。+ E9 K/ E/ K+ v* z' l/ u9 w
//注意:默認設置為一個傳統的硬件數控機器。z軸首次明確,其次是X和Y。
4 x$ O/ x6 L/ R4 l! q7 w" M: t8 K/ l5 o4 U+ I
// NOTE: Defaults are set for a traditional 3-axis CNC machine. Z-axis first to clear, followed by X & Y., L! T% @* e2 J8 A2 J1 O. Z6 [4 A
#define HOMING_CYCLE_0 (1<<Z_AXIS)                // REQUIRED: First move Z to clear workspace. 第一步Z清除工作區。, R/ K7 _9 |# T6 Y) C! u
#define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // OPTIONAL: Then move X,Y at the same time.然后X,Y在同一時間。
, ]7 c/ g1 s$ d' E) @" X// #define HOMING_CYCLE_2                         // OPTIONAL: Uncomment and add axes mask to enable$ K. P* e; g0 w- k: h2 v: l
, l7 W# X+ T2 l$ C; E
// Number of homing cycles performed after when the machine initially jogs to limit switches.
* p7 N' E  N  V$ E4 b8 M. Z// This help in preventing overshoot and should improve repeatability. This value should be one or
! v4 Q. p4 P* @) H- t// greater.4 |2 r3 l% X' B( N* A: ]
//執行回原點循環次數后,當機器最初慢跑限位開關。這個幫助防止過度,應該提高重復性。這個值應該是一個或大。
8 A5 ^& W& X5 ]# ^( t; e" {- u; [# w* Q2 d5 A; M4 u
#define N_HOMING_LOCATE_CYCLE 1 // Integer (1-128)
0 l* _; N- V3 f& b5 w/ N' i' x& [3 J( U/ k. |2 q  D
// After homing, Grbl will set by default the entire machine space into negative space, as is typical
2 |' f. n. |  I4 d+ p% p// for professional CNC machines, regardless of where the limit switches are located. Uncomment this
4 m; T9 G0 {! q& z// define to force Grbl to always set the machine origin at the homed location despite switch orientation.
+ A" M& A2 Y  C& O' u/ `& w% n9 q0 G6 [
//導航后,默認Grbl將整個機器空間留白,是典型的專業數控機器,不管限位開關所在的地方。
" y3 v8 l: i& x! y" _. M3 }//取消這定義迫使Grbl總是在這時候位置設置機器原點盡管開關方向。
& I( c# B$ N% V7 C' X3 A, I' g& T
' A- m& z. x! ]// #define HOMING_FORCE_SET_ORIGIN // Uncomment to enable.2 Q' r( y$ _; f# B- C) z
( V* \) g; K. Q7 P8 A- ?
6 ~6 c7 W& ]* L' @3 J8 [
// Number of blocks Grbl executes upon startup. These blocks are stored in EEPROM, where the size1 j' F7 c5 a. R& L9 }! Y
// and addresses are defined in settings.h. With the current settings, up to 2 startup blocks may$ H1 P3 f( t. f# B9 j
// be stored and executed in order. These startup blocks would typically be used to set the g-code
1 U% c8 a% L. g. ^& E: z// parser state depending on user preferences.5 P1 M+ S7 P( L' h8 z) w
% ]5 e. y) z9 ^2 o1 t, r
//塊Grbl啟動時執行的數量。這些塊存儲在eepm,大小( g2 a2 F+ L5 F
//和地址在settings.h中定義。與當前設置,可能2啟動塊, U1 H; f0 \6 v7 ?4 z
//存儲和執行。這些啟動塊通常被用來設置刀位點# W; o0 B6 {1 S- W" s
//解析器的狀態取決于用戶首選項。
- v5 T! w( }7 G  R6 \
* W( v0 _) ?" u% g& }#define N_STARTUP_LINE 2 // Integer (1-2)6 I: v4 K6 {3 }
1 Y4 e: @7 x( ~2 @% A. y* h
// Number of floating decimal points printed by Grbl for certain value types. These settings are / |. I  \' n4 O% y& I/ M
// determined by realistic and commonly observed values in CNC machines. For example, position. e: g1 @/ X7 B; d7 D5 q
// values cannot be less than 0.001mm or 0.0001in, because machines can not be physically more
3 v3 W0 N; _$ f" Z// precise this. So, there is likely no need to change these, but you can if you need to here.
' L$ W: k+ U+ v. j- E5 n// NOTE: Must be an integer value from 0 to ~4. More than 4 may exhibit round-off errors.
% W' T  z& Q; N# F" x
& W; u! t4 |4 J  r2 R8 [// Grbl浮動小數點的數字印刷的特定的值類型。這些設置是; _, j8 m' ?. S+ X
//一般由現實和觀測值在數控機器。例如,位置
3 G/ ?# p: e& v$ Y; _0 R+ d  ?//值不能小于0.001毫米或0.0001,因為機器不能身體更多
2 A2 t% b: ~% z) d# H0 I& x& V//精確。因此,有可能不需要改變這些,但你可以在這里如果你需要。7 M0 c+ l. d: R# @+ L* {% n
//注意:必須是一個整數值從0 ~ 4。超過4可能出現舍入錯誤。
  R# E6 A$ ]# ?# n
0 [5 h4 g! i$ G* P, j: u  M#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 協調或位置價值英寸& A1 W; y$ G7 V3 ?& G
#define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 協調在毫米或位置價值3 M/ Q4 }, J) h7 m* o7 }; o
#define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分鐘的速度值
* h5 ~3 I1 F/ Y7 i& K6 g: B#define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分鐘; Z+ }" K. t/ G+ E$ J
#define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 對浮點小數設置值2 i) h5 [) k: w! z' t3 w  F$ q

0 M: V4 L$ r: E' M7 ~- p. j) I) E// If your machine has two limits switches wired in parallel to one axis, you will need to enable
) J% _1 y$ n0 t// this feature. Since the two switches are sharing a single pin, there is no way for Grbl to tell" r7 B* J& Q. a; ?: H- b3 r( }
// which one is enabled. This option only effects homing, where if a limit is engaged, Grbl will
& Z2 k1 s/ g2 H% i// alarm out and force the user to manually disengage the limit switch. Otherwise, if you have one
% \( Q3 C# I: U; b1 V& c- a) X// limit switch for each axis, don't enable this option. By keeping it disabled, you can perform a0 n; V% ~" \8 @- D7 c# K
// homing cycle while on the limit switch and not have to move the machine off of it.
7 j8 J* t: q9 i$ e  u" f
- Z0 W( m7 P+ S9 V//如果你的機器有兩個極限開關連接在平行于一個軸,您需要啟用
9 K8 h1 X2 J5 q4 Y' E2 B//這個特性。自從兩個交換機共享一個銷,沒有辦法Grbl告訴
# G; ~/ e3 c) I# ~" w+ R//啟用哪一個。此選項僅影響歸航,如果限制,Grbl意志
! N8 J# @" S8 @. q//報警,迫使用戶手動松開限位開關。否則,如果你有一個4 @1 S+ b0 l* d4 c. y
//為每個軸限位開關,不啟用該選項。通過保持禁用,您可以執行2 K: h0 \" E; H5 ]
//導航循環在限位開關并沒有將這臺機器。
6 n2 O" \3 B! `- ]
2 ~; n: y- w9 i" V$ v( `// #define LIMITS_TWO_SWITCHES_ON_AXES
0 B% j; o$ q5 j! B$ U3 P  }0 A+ f) ?) }9 Y; u
// Allows GRBL to track and report gcode line numbers.  Enabling this means that the planning buffer& q" n" x: x/ ^6 }4 [
// goes from 18 or 16 to make room for the additional line number data in the plan_block_t struct
( ~0 y( j) ]+ v' p/ t
8 Z5 o7 E. F7 r: S//允許GRBL跟蹤和報告gcode行號。使這意味著計劃緩沖從18歲或16歲,為額外的行號plan_block_t結構中的數據1 D& ?* \5 ]# O; {
/ u  y! ~& w' [+ a0 H6 P
// #define USE_LINE_NUMBERS // Disabled by default. Uncomment to enable.# n9 ?8 x& Z) |) o( ~  p

$ M2 f0 R  y2 ]- Z4 u! q// Allows GRBL to report the real-time feed rate.  Enabling this means that GRBL will be reporting more + K- X3 |6 x# K7 o7 u, [
// data with each status update.  S+ L( x/ j0 r: _
// NOTE: This is experimental and doesn't quite work 100%. Maybe fixed or refactored later.
, N/ a: C0 j1 q- p" H//允許GRBL報告實時進給速率。使這意味著GRBL將報告數據和狀態更新。
, }' x# L( c1 O4 p/ ?//注意:這是實驗和100%沒有工作。也許以后固定或重構。
$ k# f. r3 |/ d$ a& ?
0 Z3 W7 K. e* Y/ i. F' [) K6 I// #define REPORT_REALTIME_RATE // Disabled by default. Uncomment to enable." g& W* U1 q( B0 e4 N
  q! C: }; v! m. s
// Upon a successful probe cycle, this option provides immediately feedback of the probe coordinates# {% F; q( @; L0 J
// through an automatically generated message. If disabled, users can still access the last probe9 u) e& p# n& Z: e$ S- }4 C' @1 A
// coordinates through Grbl '$#' print parameters.( m$ h- j% r5 `! n
//在一個成功的調查周期,這個選項提供立即反饋的探測器坐標5 @2 i& c( W/ V; e3 M
//通過一個自動生成的消息。如果禁用,用戶仍然能夠訪問調查6 a$ }  D/ `2 z' R5 Z
//坐標通過Grbl $ #的打印參數。
3 Q( U  k; n. V
9 U# i( p# l/ C% W$ d$ ^, y% v#define MESSAGE_PROBE_COORDINATES // Enabled by default. Comment to disable.
  [7 ~5 w" N/ p- y
1 \& _  l6 p4 @2 L// Enables a second coolant control pin via the mist coolant g-code command M7 on the Arduino Uno
; i0 V# E* d; O- p5 C: j// analog pin 5. Only use this option if you require a second coolant control pin.
: b- H* _5 n5 z) a' I4 G// NOTE: The M8 flood coolant control pin on analog pin 4 will still be functional regardless.! ]( a+ ~- u5 P) z! }, _+ s
// #define ENABLE_M7 // Disabled by default. Uncomment to enable.2 A& p0 c: j8 L/ s
) K: @" L' X, l6 _  v+ h
// This option causes the feed hold input to act as a safety door switch. A safety door, when triggered,
: M% x: E* u: Y* ^5 J2 |: O// immediately forces a feed hold and then safely de-energizes the machine. Resuming is blocked until2 u. r7 m1 P& I
// the safety door is re-engaged. When it is, Grbl will re-energize the machine and then resume on the! D% r# j/ [6 E% U" X& O; k6 {
// previous tool path, as if nothing happened.
+ V# }% w+ P+ V) T% V/ V! ~// #define ENABLE_SAFETY_DOOR_INPUT_PIN // Default disabled. Uncomment to enable.6 L6 A  K# P7 {/ U9 U) r- c5 {

; u7 Y; K$ ]7 P# d" _( Z// After the safety door switch has been toggled and restored, this setting sets the power-up delay' I# t: C' U0 [7 `8 t1 p' ~
// between restoring the spindle and coolant and resuming the cycle.9 [4 Z3 ?2 A7 S3 k* s1 ?" e
// NOTE: Delay value is defined in milliseconds from zero to 65,535.
  h; R. ~' x! @8 \% c  }! B$ w7 w- R- |
//定義導航循環模式的位掩碼。歸航周期首先執行一個搜索模式  c! X- p. y* a5 O  c- P, y
//快速進行限位開關,其次是較慢的定位模式,完成了由一個短
8 B5 l" {7 e% c7 v) |7 i//拖出運動脫離限位開關。以下HOMING_CYCLE_x定義執行
6 [, s0 e& ?9 y$ I* Q) S2 @8 N" x//為了與后綴0開始并完成specified-axes只尋的例程。如果- H# x- k3 o5 v& S( p4 [# U( i) T5 N
//定義省略一個軸,它會不在家,也不會系統更新它的位置。5 b) p" R9 Y. P0 a6 p6 r
//意義,這允許用戶與非標準笛卡爾的機器,比如車床(x,z,
+ G% r; J  q! x) W2 X2 D2 D//沒有y),配置導航循環行為對他們的需求。
4 C& X: n3 ?) w- n8 `% P: p$ L4 [//注意:歸航周期允許共享限制針,如果軸不相同
  I! n3 p& R2 w, M' d! V- @//循環,但這需要一些銷設置cpu_map的變化。h文件。例如,默認的導航8 X, m$ A+ w! e) j& T' O" D
//循環可以分享Z限位銷X或Y限制針,因為它們是在不同的周期。* X, j% F8 _8 w4 c2 K
//通過共享一個銷,這騰出寶貴的IO銷用于其他目的。從理論上講,所有軸限制別針% D! v: h3 g8 x7 j# H( c! T/ D
//可能會減少到一個銷,如果所有軸與分離周期居住的地方,反之亦然,所有三個軸0 a* G- y. k  ^+ X
//在不同銷,但這時候一個周期。同時,應該注意的是,硬限制的功能- F5 q* K8 h7 d4 V. [
//將不會影響銷共享。& m$ r3 }7 N& H! B, A% [( D
//注意:默認設置為一個傳統的硬件數控機器。z軸首次明確,其次是X和Y。2 W+ e) ]  U4 P7 N1 z
2 \' X5 Z  ~+ J8 K/ y

1 x* m) ~, `) Z! F5 A  p#define SAFETY_DOOR_SPINDLE_DELAY 4000
9 h! d3 _. q3 g5 n# Z# m! ~#define SAFETY_DOOR_COOLANT_DELAY 1000
' t' y- g6 ~. ^( T8 ]5 z" ~* W; h. b/ p  d8 b) d
// Enable CoreXY kinematics. Use ONLY with CoreXY machines.
- E5 Z+ V+ [7 T" r: M8 X* M! e! \// IMPORTANT: If homing is enabled, you must reconfigure the homing cycle #defines above to : I* a& [! H+ ~, a7 O/ E
//啟用CoreXY運動學。只使用與CoreXY機器。" o* ?3 v, {* Q3 v
//重要:如果啟用了自動尋的,你必須重新配置導航循環#定義上面
9 l* N" Q- l7 t% x+ j# g; l2 }0 h, x9 d2 }7 ^
// #define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS): P/ P( ~+ D4 `: N8 e# \6 l

+ C4 F1 c5 V" e4 O+ O5 W/ p% ?+ x// NOTE: This configuration option alters the motion of the X and Y axes to principle of operation) X, R1 |$ D8 L1 g7 R3 ?
// defined at (http://corexy.com/theory.html). Motors are assumed to positioned and wired exactly as
' |/ Z' u5 H* C/ h$ ~+ y8 ]// described, if not, motions may move in strange directions. Grbl assumes the CoreXY A and B motors
5 I6 c3 r( r; Q/ {/ ~' c9 A! Y// have the same steps per mm internally.8 \6 @7 A2 {# p5 l
//注意:這種配置選項改變X和Y軸的運動原理,操作' w0 k4 G) r% I4 z; y9 S
//定義(http://corexy.com/theory.html)。汽車被認為定位和連接一樣
4 H5 d' O: L5 q/ G) H1 i//描述,如果沒有,運動可能會奇怪的方向移動。A和B Grbl假設CoreXY馬達4 Q# c& e: f+ e( r+ I+ z) P9 T2 z
//每毫米內部有相同的步驟。) f; B3 z8 V# q' [$ N3 A
1 v0 a, G' S" R7 l
// #define COREXY // Default disabled. Uncomment to enable.
; k1 F- ]+ H; P5 H5 J
$ T! Y: K- e% q// Inverts pin logic of the control command pins. This essentially means when this option is enabled
6 D' B' Q! h) x, B  B// you can use normally-closed switches, rather than the default normally-open switches.
, f# t; `) {& X9 Y& T! v// NOTE: Will eventually be added to Grbl settings in v1.0.. n) S& i0 U3 T! v9 n$ L* f
//反轉針銷邏輯的控制命令。這實質上意味著當啟用這個選項
7 j! e+ k- t/ h3 J& P//可以使用閉合開關,而不是默認的常開開關。( L2 t+ h2 i/ h+ Z! P
//注意:最終將被添加到在v1.0 Grbl設置。$ m" A$ m, X$ g' |

' `+ Y; G) o1 t. h) n# [: J// #define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.
; r! p+ @7 J+ y* L/ W! @* N" s& q
( F& Y1 l" \. s1 p// Inverts the spindle enable pin from low-disabled/high-enabled to low-enabled/high-disabled. Useful
. }! s; N* e' _7 j* D// for some pre-built electronic boards.
4 g. ^$ l/ j. y( T// NOTE: If VARIABLE_SPINDLE is enabled(default), this option has no effect as the PWM output and 2 u9 R  t7 w% U
// spindle enable are combined to one pin. If you need both this option and spindle speed PWM, & a* ]. T7 D  f; z2 I) V8 a7 O
// uncomment the config option USE_SPINDLE_DIR_AS_ENABLE_PIN below.
4 T. n  X5 E0 p+ p+ z  Q. ]: u//反轉主軸使銷從low-disabled / high-enabled low-enabled / high-disabled。有用的( G0 D7 x, i& B9 }) S
//預構建的電子板。
- Z0 r- E' d' h: n" |' P//注意:如果啟用了VARIABLE_SPINDLE(默認),這個選項作為PWM輸出并沒有影響* t; w- W5 m, P, a9 e
//銷軸使結合。如果你需要這個選項和主軸轉速PWM,3 ^" F: O7 W2 o! |7 m' L+ Z7 J
//取消注釋以下配置選項USE_SPINDLE_DIR_AS_ENABLE_PIN+ ?7 o5 p" M9 D8 W1 D

+ s* z5 O+ b. Q8 ^// #define INVERT_SPINDLE_ENABLE_PIN // Default disabled. Uncomment to enable.2 y3 B- O, z: @5 x- y: h  Q
; H/ E# u- g4 {1 R0 `' c
// Enable control pin states feedback in status reports. The data is presented as simple binary of5 a( b# l) c; y  Z
// the control pin port (0 (low) or 1(high)), masked to show only the input pins. Non-control pins on the
9 a$ v2 U2 c( I; E- `& B7 R// port will always show a 0 value. See cpu_map.h for the pin bitmap. As with the limit pin reporting,
: N  _, ~1 a4 X7 H4 Q// we do not recommend keeping this option enabled. Try to only use this for setting up a new CNC.
$ ?. ]7 M* f3 Y, o9 d( W# f0 F, i! W//啟用控制銷狀態反饋狀態報告。作為簡單的二進制數據
; S7 U* y/ A" W% I3 d1 H//控制針端口(0(低)或1(高)),蒙面,只顯示輸入插腳。非控制性針上
- L+ \" d( D) s9 u" n2 ]8 E//端口總是顯示0值。看到cpu_map。針位圖h。與限制銷報告,: `' ^; L+ t6 Q& b% Z
//我們不推薦保持啟用這個選項。盡量只使用這個設置一個新的數控。
4 x. x& V: A7 U9 r2 A7 T$ R# J; o6 p  {, X
// #define REPORT_CONTROL_PIN_STATE // Default disabled. Uncomment to enable.
4 ]) w& h' e) H3 h% ^( N8 [. M6 \  R" ?
// When Grbl powers-cycles or is hard reset with the Arduino reset button, Grbl boots up with no ALARM
2 ~4 x! R# M2 q5 Y) i- e// by default. This is to make it as simple as possible for new users to start using Grbl. When homing' Q* u! L6 t; |: L4 x
// is enabled and a user has installed limit switches, Grbl will boot up in an ALARM state to indicate
& }- Q# p+ G; U// Grbl doesn't know its position and to force the user to home before proceeding. This option forces9 d/ T2 f- Q: a: _( \4 o
// Grbl to always initialize into an ALARM state regardless of homing or not. This option is more for$ A! w1 K0 ^3 ?! q( J( B+ P3 O
// OEMs and LinuxCNC users that would like this power-cycle behavior.) @% U* [5 n) X' `) ^5 w
//當Grbl powers-cycles還是硬重置Arduino復位按鈕,Grbl啟動沒有報警4 h* n. }  L  o  L. Z0 Y
//默認情況下。這是為了讓新用戶盡可能簡單使用Grbl開始。當歸航0 s, ^5 Y" x* K% M& k7 W) b
//啟用和用戶安裝限位開關,Grbl將啟動報警狀態指示" k: u4 Z0 b/ B4 |2 j
// Grbl不知道它的位置,迫使用戶在繼續之前回家。這個選項部隊2 d* o' n9 ?) V# p7 a. x
// Grbl總是初始化進入警報狀態不管歸航。這個選項是更多
3 g# v- O: \: V2 G//原始設備制造商和LinuxCNC用戶這樣的控制行為。: n  _1 S# J; W6 z" V; E# G- ~

4 r5 O: k& F" n& h/ @- ^$ B  ?, Y// #define FORCE_INITIALIZATION_ALARM // Default disabled. Uncomment to enable.
! C1 o' k2 T6 f' t; g
% ^( i( A- j3 p: Z/ b// ---------------------------------------------------------------------------------------" q" r6 u1 M, n$ `
// ADVANCED CONFIGURATION OPTIONS://高級配置選項:
9 m& o% J& a5 b1 h4 L% S
+ ?$ z  B5 _: Q& Z) I" s' w// Enables minimal reporting feedback mode for GUIs, where human-readable strings are not as important.
7 x  e: f1 ~/ V" M! Y: s/ z// This saves nearly 2KB of flash space and may allow enough space to install other/future features.* `- g4 g2 A" i' y; c
// GUIs will need to install a look-up table for the error-codes that Grbl sends back in their place.4 O0 H. X( Z" V: p* [# u1 M: D
// NOTE: This feature is new and experimental. Make sure the GUI you are using supports this mode.
, n- b0 u; U/ N# U" Z
. P, w! g6 x: }! }// gui允許最小的報告反饋模式,人類可讀的字符串在哪里不重要。, R# L) U0 y! l. m1 ?# `5 I
//這個節省近2 kb的閃存空間,允許足夠的空間來安裝其他/未來的功能。
) i. [, d, \+ k4 y" A  y! ^// gui需要安裝一個查找表的錯誤代碼Grbl發回。) `% H8 R2 T8 a% [4 H
//注意:此功能是新的和實驗。確保您使用的GUI支持這種模式。
% n9 ~% N, a$ i; `5 e; f9 l" d3 [6 K+ y- r
// #define REPORT_GUI_MODE // Default disabled. Uncomment to enable.
4 z6 y- K4 [9 S! \' ^+ ^9 y8 f* }) R+ a/ ~1 q3 e
// The temporal resolution of the acceleration management subsystem. A higher number gives smoother! Q1 g4 p0 K$ C* I/ G1 \; e5 T
// acceleration, particularly noticeable on machines that run at very high feedrates, but may negatively
% Z: G$ n4 C+ W1 m& g// impact performance. The correct value for this parameter is machine dependent, so it's advised to$ N; U' f4 N5 G; B5 n
// set this only as high as needed. Approximate successful values can widely range from 50 to 200 or more.  c; k. ~* M2 e4 T6 }* k
// NOTE: Changing this value also changes the execution time of a segment in the step segment buffer.
( f7 O- E$ Y* ^* R7 ~/ h1 {// When increasing this value, this stores less overall time in the segment buffer and vice versa. Make
/ a/ t: \+ x6 v9 X// certain the step segment buffer is increased/decreased to account for these changes.2 [! z1 Y/ f+ p8 J$ _
//加速度的時間分辨率管理子系統。更多更平穩
3 E6 B8 O: f- H; J2 n* g- l; g//加速度,特別明顯的機器上,運行在非常高的進料速度,但可能負面  o! q- l) {( ~/ o2 ?5 S
//影響性能。正確的值為這個參數是依賴于機器的,所以建議( h9 V. C1 O6 H& B: k+ Z. Z+ j
//這只設置為高。近似成功的價值觀可以廣泛的范圍從50到200或者更多。
4 U) q' g1 m/ p$ @5 l# Y2 w1 N//注意:改變這個值也變化的部分步驟的執行時間緩沖。; I1 Z) b- U9 u% d
//增加這個值時,這個商店部分緩沖區的總時間減少,反之亦然。使* r4 _  s) `3 r$ W, }0 i  r! q
//特定步驟段緩沖是考慮這些變化增加/減少。
& w; r3 H) p9 l6 S7 i1 y
* V" T! ~% Q/ `#define ACCELERATION_TICKS_PER_SECOND 100  //加速度的時間分辨率管理子系統。更多更平穩2 a, o" V7 w* L! M' W
; Q- U& \  N( I( @
// Adaptive Multi-Axis Step Smoothing (AMASS) is an advanced feature that does what its name implies,
- U0 x% b! \! B) f6 U& O# y// smoothing the stepping of multi-axis motions. This feature smooths motion particularly at low step! {" q! R) e* I
// frequencies below 10kHz, where the aliasing between axes of multi-axis motions can cause audible 1 y+ U! u% r$ c, U. Z9 N% S- D* i& X
// noise and shake your machine. At even lower step frequencies, AMASS adapts and provides even better
8 [- _5 j2 E: `! ~. ~// step smoothing. See stepper.c for more details on the AMASS system works.* {" c* b5 M2 |! r6 e1 e
//自適應多軸步平滑(積累)是一種先進的功能,它的名字所暗示的那樣,% P" g9 @$ t& h
//平滑的多軸步進運動。這個特性平滑運動尤其是在低一步! Q0 A) k1 i  h4 _! B) ?" T
//頻率低于10 khz,軸之間的混疊的多軸運動可能導致音響% }3 [# f" L1 B3 U: J! L8 A! o2 C
//噪音和震動你的機器。在更低的頻率步,積累適應并提供更好- D' s/ }4 S3 Q! c- v& h+ }: X
//步驟平滑。看到步進。c更多細節的積累系統的工作原理。5 ~1 J5 J0 ?5 Q0 f

0 L! E" X' }& X: f" @2 v#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING  // Default enabled. Comment to disable.//自適應多軸步平滑
$ b9 L$ r4 Q$ n! I: a) R% m7 s0 Y2 [0 `/ d0 E
// Sets the maximum step rate allowed to be written as a Grbl setting. This option enables an error . A, t) o9 Q' |: b2 _, }, y* W
// check in the settings module to prevent settings values that will exceed this limitation. The maximum* J, S; B3 _4 ?* e! A7 Z
// step rate is strictly limited by the CPU speed and will change if something other than an AVR running
5 a2 s9 e- P- c! W/ Q& Q// at 16MHz is used.
% V; g8 P1 ]- @: F5 J9 \  J( e// NOTE: For now disabled, will enable if flash space permits.* q8 P( b; h! Y' k( C! B# I& m
//設置最大一步速率可以寫成Grbl設置。這個選項可以使一個錯誤' m6 R0 Z. X' q7 P) L* J* T$ D9 ~
//設置模塊中檢查,防止設置值將超過這個限制。的最大
3 ~* J# Y( L5 j0 G4 W//步驟嚴格限制的CPU速度也會改變如果是其他AVR運行2 s8 _! y6 m; q5 R; L: S
//使用16兆赫。
3 M0 o$ t3 E, y//注意:現在殘疾,將使如果flash空間許可。
5 G6 j6 j- s! \; U; Q% c& p  q
6 a0 d0 V/ @2 r$ [* |// #define MAX_STEP_RATE_HZ 30000 // Hz 設置最大一步速率
# O/ o% R# d+ f& n# Q$ T, T, H1 Y( B  K( I' ?' [8 O0 s. ]
// By default, Grbl sets all input pins to normal-high operation with their internal pull-up resistors7 y% D& I8 ~/ k; ~* U( }
// enabled. This simplifies the wiring for users by requiring only a switch connected to ground, 1 K# \0 B# y0 }: N  K( F
// although its recommended that users take the extra step of wiring in low-pass filter to reduce5 s$ y! j/ ?; h+ h3 n
// electrical noise detected by the pin. If the user inverts the pin in Grbl settings, this just flips
. |4 F( Z) I  }# f) C// which high or low reading indicates an active signal. In normal operation, this means the user
5 X- G0 _4 _9 b// needs to connect a normal-open switch, but if inverted, this means the user should connect a
! j2 U" y/ J  I6 o& w// normal-closed switch.
1 n7 U  d+ I; G  m7 W; b// The following options disable the internal pull-up resistors, sets the pins to a normal-low 5 ]5 O* X! q5 `- e
// operation, and switches must be now connect to Vcc instead of ground. This also flips the meaning ! A7 ~) D( n! _; g- X# \9 b0 g! z/ L
// of the invert pin Grbl setting, where an inverted setting now means the user should connect a * I% m7 c" e( h5 Q5 [8 }/ }+ ~2 D) c
// normal-open switch and vice versa.' X2 M" K3 g. ^
// NOTE: All pins associated with the feature are disabled, i.e. XYZ limit pins, not individual axes.+ M% s$ A$ K8 u$ z# F, K
// WARNING: When the pull-ups are disabled, this requires additional wiring with pull-down resistors!' N5 f, A7 s* I+ [6 s0 ~: C
//默認情況下,Grbl所有輸入引腳設置為正常高操作的內部上拉電阻: O# P3 v: A: g, I1 Z+ n
//啟用。這簡化了布線為用戶只需要一個開關連接到地面,
& R2 ~" m# C7 [6 U6 t//雖然其建議用戶采取額外的步驟,在低通濾波器來減少布線6 M7 F) P+ _. {3 B' t+ B1 r
//電噪音檢測銷。如果用戶反轉的銷Grbl設置,這只是翻轉! P5 ?& t8 v6 C; T/ |, h) x. O
//讀高或低表明一個積極的信號。在正常操作中,這意味著用戶: W8 d4 R( [' M( _! _( q
//需要連接一個常開開關,但如果倒,這意味著用戶應該連接
5 }, Y( Q8 r4 v( i( P// normal-closed開關。
, P" X0 |3 {5 {6 w' t% e0 e//以下選項禁用內部上拉電阻,一般低設置別針
" D! A2 d( c- k! h0 K. X/ p' g//操作,現在開關必須連接到Vcc代替地面。這也掀的意思
  a# l$ \3 B3 G9 ?- K4 @( J//反銷Grbl設置,一個倒置的設置現在意味著用戶應該連接
& `/ v2 p1 e' t2 {//常開開關,反之亦然。
  r! x! M$ k6 ]. z+ ^/ N3 O//注意:所有針與功能被禁用,例如XYZ限制針,而不是單獨的軸。
0 S2 }. F4 Q- W, Z$ ~- Z/ C//警告:引體向上被禁用時,這需要額外的布線與下拉電阻!6 ]0 |. a( G5 [, ^
. `/ t: e8 B& f6 O0 z
//#define DISABLE_LIMIT_PIN_PULL_UP //以下選項禁用內部上拉電阻5 E. {$ U; w1 f
//#define DISABLE_PROBE_PIN_PULL_UP
  n* ]# l' @6 ]  U$ F4 z//#define DISABLE_CONTROL_PIN_PULL_UP1 L+ t8 {1 F2 v4 o3 X  H
4 D. }$ s2 D6 R
// Sets which axis the tool length offset is applied. Assumes the spindle is always parallel with * V; J+ ~( Y! W' f0 f
// the selected axis with the tool oriented toward the negative direction. In other words, a positive
% Y! T9 w! Z. o0 M// tool length offset value is subtracted from the current location.9 _4 _- L) O5 ]& [, F  F
//設置哪個軸長度補償應用的工具。假設軸總是與
2 S" r% u4 n. W//選擇軸工具面向負方向。換句話說,一個積極的. i& T( v$ b1 W' ]
//工具長度偏移值減去從當前位置。: {6 U* a% O0 X' o7 `7 z. j

  C7 @  |1 Q7 {' Q& [" [1 T. D#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS // Default z-axis. Valid values are X_AXIS, Y_AXIS, or Z_AXIS.設置哪個軸長度補償應用的工具
* i2 ^( W  {  q9 B, Y7 a- v
- ^. K5 n; T7 l3 R8 N0 z// Enables variable spindle output voltage for different RPM values. On the Arduino Uno, the spindle
* Y$ w6 l* N( r( |// enable pin will output 5V for maximum RPM with 256 intermediate levels and 0V when disabled.
. J: ~. P& g. N) ]4 ]- X; x// NOTE: IMPORTANT for Arduino Unos! When enabled, the Z-limit pin D11 and spindle enable pin D12 switch!
' x1 ^1 I7 [; O// The hardware PWM output on pin D11 is required for variable spindle output voltages.1 J: R6 C- b. G0 x- j
//允許變量軸輸出電壓不同的轉速值。Arduino Uno,主軸
: v( \! @4 |( {5 R5 f//啟用銷將輸出5 v的最高轉速256中級水平和0 v時禁用。% P- O" @6 J8 z9 E2 S3 ~7 w1 l
//注意:重要Arduino凱澤本人!當啟用時,Z-limit銷這里和軸銷D12開關!
2 q( L8 C2 E) r1 {& h( R//硬件PWM輸出銷這里需要變量軸輸出電壓。! E: h, Y1 x; _/ \
" y1 w6 Z" A8 F' f1 R
#define VARIABLE_SPINDLE // Default enabled. Comment to disable.//允許主軸輸出電壓不同的轉速值, T# G' f3 I; \7 z" c3 k6 _
  k, ~, [+ i6 z6 ~: h$ \! M
// Used by the variable spindle output only. These parameters set the maximum and minimum spindle speed+ O3 q$ g- |/ M  j
// "S" g-code values to correspond to the maximum and minimum pin voltages. There are 256 discrete and
/ N: N) _% E% O0 e4 i/ V// equally divided voltage bins between the maximum and minimum spindle speeds. So for a 5V pin, 10005 C# e+ U# `* B( _- Z9 s; W
// max rpm, and 250 min rpm, the spindle output voltage would be set for the following "S" commands: 7 h& Q$ \6 b# G. A
// "S1000" @ 5V, "S250" @ 0.02V, and "S625" @ 2.5V (mid-range). The pin outputs 0V when disabled.
. n/ o$ ~5 [( c4 t- p# P0 t% Z//使用的變量軸輸出。這些參數設置最大和最小軸轉速0 ~( q+ R& i/ w; g8 I# }* j
//“S”刀位點值對應于銷電壓的最大值和最小值。有256個離散和& J8 O7 M2 x. X, O
//電壓平均分配箱主軸速度的最大值和最小值之間。所以對于一個5 v銷,1000" {5 a# Z2 S4 ~! H3 ~. R5 G
// max rpm,250分鐘rpm,主軸輸出電壓將為以下“S”命令:
0 E# i# G8 t* ?# c3 m7 S. Y// @“S1000 5 v,“S250”@ 0.02 v,“S625”@ 2.5 v(中檔)。銷輸出0 v時禁用。
+ Q8 z+ O+ j$ j0 P) \& f9 P; K& u: S$ |" M) M
#define SPINDLE_MAX_RPM 1000.0 // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.
( x7 z/ S9 N! I#define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.1 k% @/ E; \  Y( i6 l" L
  }0 }* i2 u% s3 ~8 S
// Used by variable spindle output only. This forces the PWM output to a minimum duty cycle when enabled., A" C0 U7 D2 f8 f
// When disabled, the PWM pin will still read 0V. Most users will not need this option, but it may be
5 E/ C9 E$ Z. d5 I* `: G0 H// useful in certain scenarios. This setting does not update the minimum spindle RPM calculations. Any% H5 J4 w1 r, Y. o
// spindle RPM output lower than this value will be set to this value.
, N$ Z! J6 Y4 w1 j7 e//使用的變量軸輸出。這迫使PWM輸出最小占空比時啟用。
, p( D& l6 R% N//當禁用,PWM銷仍讀0 v。大多數用戶不需要這個選項,但是它可能是5 Z1 e/ {2 l; X, K  v! v
//在某些情況下很有用。這個設置不會更新最小主軸轉速計算。任何5 N/ |* Z2 v4 X+ Y1 D1 p7 L
//輸出軸轉速低于這個值將被設置為這個值。; a  s7 l+ S9 }3 _3 F/ \" u

; t. m/ b5 A; u  n. w% }  u// #define MINIMUM_SPINDLE_PWM 5 // Default disabled. Uncomment to enable. Integer (0-255)
& g' {6 N7 _/ f
% {3 Z1 k7 Z& m) |; z( s// By default on a 328p(Uno), Grbl combines the variable spindle PWM and the enable into one pin to help
  ?6 A1 I. r5 _) \, D5 g// preserve I/O pins. For certain setups, these may need to be separate pins. This configure option uses
* @& p: A% T" A( b5 e+ r// the spindle direction pin(D13) as a separate spindle enable pin along with spindle speed PWM on pin D11.
5 i4 R  ?3 p8 p! Y" c2 K// NOTE: This configure option only works with VARIABLE_SPINDLE enabled and a 328p processor (Uno).
; [2 R# g3 D) Q// NOTE: With no direction pin, the spindle clockwise M4 g-code command will be removed. M3 and M5 still work.% S8 A; ^) \, R/ n. \2 ]
// NOTE: BEWARE! The Arduino bootloader toggles the D13 pin when it powers up. If you flash Grbl with; ?8 ^: R- T3 p( r/ ~
// a programmer (you can use a spare Arduino as "Arduino as ISP". Search the web on how to wire this.), 1 E; F0 r& {( `( q( P* r% p* t' m
// this D13 LED toggling should go away. We haven't tested this though. Please report how it goes!! X4 H+ L4 u9 C
//默認ATmega328 p(Uno),Grbl結合變量軸PWM和使到一個銷的幫助
9 q0 L4 K5 W8 p# o//保存I / O管腳。對于某些設置,這些可能需要單獨的別針。這個配置選項使用
5 P: ~3 a4 ?! l: e4 f2 I, c//方向軸銷(D13)作為一個單獨的軸銷上啟用銷以及主軸轉速PWM這里。
0 x, x# C1 C' x# N//注意:該配置選項僅適用于VARIABLE_SPINDLE啟用和328 p處理器(Uno)。0 E) }$ q( i4 s
//注意:沒有方向銷,主軸順時針M4刀位點命令將被刪除。M3和M5仍然工作。2 E( O! Q; Q4 ^
//注意:小心!Arduino引導裝載程序切換D13銷的權力。如果flash Grbl
0 Q; q9 d) a/ Y4 k) `/ ]//程序員(您可以使用一個備用Arduino“Arduino ISP”。搜索網絡如何線),( v$ v9 K. A" w  J& B" m
//這D13導致切換應該消失。我們還沒有測試這個。請報告將會怎樣!& M+ J2 j6 d" H2 P: d

5 M, ~/ N" m+ W4 [: |7 e// #define USE_SPINDLE_DIR_AS_ENABLE_PIN // Default disabled. Uncomment to enable.
, ^7 F& b; n5 {# |! c5 r+ J: N: H3 X1 q6 @6 S8 r
// With this enabled, Grbl sends back an echo of the line it has received, which has been pre-parsed (spaces, Q8 n+ F; u1 c* N& l
// removed, capitalized letters, no comments) and is to be immediately executed by Grbl. Echoes will not be * a( S, b/ A) U3 `$ N4 p) O
// sent upon a line buffer overflow, but should for all normal lines sent to Grbl. For example, if a user ) q4 f2 z- h1 r# I0 f
// sendss the line 'g1 x1.032 y2.45 (test comment)', Grbl will echo back in the form '[echo: G1X1.032Y2.45]'.( f" _7 k& x8 f
// NOTE: Only use this for debugging purposes!! When echoing, this takes up valuable resources and can effect0 r  z2 i& Y9 S  v0 Q' P
// performance. If absolutely needed for normal operation, the serial write buffer should be greatly increased
  j) z. @" ]2 S4 S7 e// to help minimize transmission waiting within the serial write protocol.* V* i# z. J" g1 s' k# B) _7 h

9 @. j7 [# v- Y, C  U//啟用,Grbl發回的回聲線已收到,已預編譯(空間
4 p7 [2 v& S) a% q7 V//移除,大寫字母,沒有評論),由Grbl立即執行。回聲將不會
/ Y2 f& k' z9 F. D//發送一個線緩沖區溢位,但應該對所有正常線路送到Grbl。例如,如果一個用戶
+ ^" v, j& Y  _3 j0 Y' u//發送線的g1 x1.032 y2.45(測試評論)形式”,Grbl將回聲”(回聲:G1X1.032Y2.45]”。
, i6 ~9 J2 L( J1 ]: L//注意:只使用這個調試! !當呼應,這占用了寶貴的資源,可以影響* Y) L/ N: E1 N2 o5 \% s" y
//性能。如果正常運行所需的絕對,串行寫入緩沖器應該大大增加
0 [7 [8 y. V, B3 S7 J8 W9 o- i//幫助最小化傳輸等系列內寫協議。
$ D9 n& j* V( {! s% o/ _2 O' g
2 Q# D  R7 V) V// #define REPORT_ECHO_LINE_RECEIVED // Default disabled. Uncomment to enable.
1 v# c3 t' s( l, }9 z' I0 h) ~  {+ O9 P6 _
2 G9 s0 m) X: W+ W// Minimum planner junction speed. Sets the default minimum junction speed the planner plans to at
' O1 V4 [2 P: i5 T5 K// every buffer block junction, except for starting from rest and end of the buffer, which are always
  P' R8 u5 H; S( l// zero. This value controls how fast the machine moves through junctions with no regard for acceleration; i7 \& D, G# {, r& O8 g/ f$ v
// limits or angle between neighboring block line move directions. This is useful for machines that can't
. I& k2 o8 Z3 `& L6 n% C// tolerate the tool dwelling for a split second, i.e. 3d printers or laser cutters. If used, this value7 b/ P% m$ I( x; B4 ]
// should not be much greater than zero or to the minimum value necessary for the machine to work.5 q0 ~6 w5 e% P! a* J9 m+ z
5 D( X5 z$ a& P* l
//最小規劃師結速度。設置默認最小連接速度規劃計劃3 O$ n0 l# H3 o0 s# ~. c
//每一個緩沖塊接頭,除了從結束休息和緩沖區,它總是
  J7 W" R2 b6 i// 0。這個值控制機器的速度穿過路口,沒有考慮加速度0 k2 G- f0 [6 b' N3 u# U
//限制或相鄰塊之間的角線方向移動。這是有用的機器,不能
# X" H& W% d$ G3 r1 D9 t! C( c" x  N//容忍工具居住某一剎那,即3 d打印機或激光切割機。如果使用這個值
9 u( i9 s. y  u- T8 H; Y//不應大于零或機器工作所需的最小值。
& l$ O/ z* P% Q$ P* G( V2 H5 X' ?0 p# f; `
#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min)- y# k9 H1 u( i2 b

* U7 H( G' \) T0 t+ f// Sets the minimum feed rate the planner will allow. Any value below it will be set to this minimum, G2 e+ K$ M& k8 |/ r* o- a
// value. This also ensures that a planned motion always completes and accounts for any floating-point4 u: k4 S# F" d# P. B# I1 i
// round-off errors. Although not recommended, a lower value than 1.0 mm/min will likely work in smaller
8 L! i! I0 G- P6 M5 R1 Z// machines, perhaps to 0.1mm/min, but your success may vary based on multiple factors.
3 O; m; z- u9 q- n//設置計劃將允許的最小進給速率。任何價值低于它將被設置為最低值。這也保證了運動計劃總是完成,占任何浮點
$ K# C3 _$ l9 A* h  G//舍入錯誤。雖然不推薦,價值低于1.0毫米/分鐘可能會在較小的工作- T  F" ^7 i5 l
//機器,也許到0.1毫米/分鐘,但你的成功基于多種因素可能會有所不同。& f% a/ T! r' e3 u' l2 e+ h
: s. T1 ^- v# u# w
#define MINIMUM_FEED_RATE 1.0 // (mm/min)//設置計劃將允許的最小進給速率
6 i1 M& D3 e0 I1 A* u: z+ p( k: q
6 j. t, E# b/ K/ j+ M& a// Number of arc generation iterations by small angle approximation before exact arc trajectory
2 C3 E+ \: D, J. k( j  t9 ?4 s  t* N// correction with expensive sin() and cos() calcualtions. This parameter maybe decreased if there ( {& t5 U; l& X& y& d  z
// are issues with the accuracy of the arc generations, or increased if arc execution is getting
" u- j& A9 \' j// bogged down by too many trig calculations. 9 b) O6 d' d% c/ u
//弧生成迭代次數之前小角度近似精確的弧線軌跡
9 I: G7 R) F, U6 s+ ^- }, k//修正與昂貴的sin()和cos()calcualtions。如果有這個參數可能減少0 b* d2 Z- ?* P0 m  @9 B
//與弧一代又一代的準確性問題,或如果電弧執行得到增加
1 L1 W# D9 h, T0 n4 k//太多的三角計算的泥潭。
5 ?1 n+ N0 C0 k- H9 r
6 m+ J. x9 }/ x5 Q#define N_ARC_CORRECTION 12 // Integer (1-255)
7 H- V3 ]& ~" A1 c/ ~/ X( T
0 a0 S; p2 V( G! s1 A/ j// The arc G2/3 g-code standard is problematic by definition. Radius-based arcs have horrible numerical
+ k! C, h" G- p0 Y: c1 O// errors when arc at semi-circles(pi) or full-circles(2*pi). Offset-based arcs are much more accurate
/ ?) B# |. z, o8 L$ {4 j4 p+ o// but still have a problem when arcs are full-circles (2*pi). This define accounts for the floating : q8 @' P! P% H  V5 j+ \
// point issues when offset-based arcs are commanded as full circles, but get interpreted as extremely- t* ]$ A9 T' W3 Y5 @. y
// small arcs with around machine epsilon (1.2e-7rad) due to numerical round-off and precision issues./ G" c5 {  ]! r  V- [
// This define value sets the machine epsilon cutoff to determine if the arc is a full-circle or not." `) U/ z/ m1 x$ P+ O9 s; ^
// NOTE: Be very careful when adjusting this value. It should always be greater than 1.2e-7 but not too
$ ?4 G$ B- m: y- o+ I// much greater than this. The default setting should capture most, if not all, full arc error situations.
2 s# S! @1 ]: i) j$ s8 k1 t//弧G2/3刀位點的標準定義是有問題的。Radius-based弧有可怕的數值# c0 L& R3 [' M% s
//錯誤當電弧在半圓(π)或原點(2 *π)。Offset-based弧更準確
: j1 q/ `; [( ^" q8 f//但仍有一個問題當弧原點(2 *π)。這個定義占浮動9 D" B* C7 C1 v# F6 K
//當offset-based弧吩咐點問題完整的圓,但解釋為極8 ^2 i& N* y1 z
//小弧機周圍ε(1.2 e-7rad)由于數字舍入和精度問題。# _& t4 x" s' r& @' n( z" r
//定義值設置機器ε截止來確定電弧是一個原點了。! P  P. |8 a! Q# k
//注意:調整這個值時非常小心。它應該總是大于1.2 e -但不要太
0 }4 U; _! q6 W0 a+ b//比這大得多。默認設置應該捕獲大部分,如果不是全部,全部錯誤的情況。/ O% l3 R, Y7 W4 y
, H* k0 g" w' G* R' u! `! E9 t( I5 w
#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)
: e4 g$ `, i% w& d/ N9 K$ n5 J& O9 Z, U( W
// Time delay increments performed during a dwell. The default value is set at 50ms, which provides3 q. h# \% a# |
// a maximum time delay of roughly 55 minutes, more than enough for most any application. Increasing
: K2 ~9 l' d$ W// this delay will increase the maximum dwell time linearly, but also reduces the responsiveness of
2 ^/ ?. k1 L( ~+ Z// run-time command executions, like status reports, since these are performed between each dwell 3 ~& F& a+ ^4 H. h
// time step. Also, keep in mind that the Arduino delay timer is not very accurate for long delays.8 d1 T( R: |! m: d: G- ^& B
//延時增加表現在住。默認值設置為50毫秒,它提供了
0 d1 o5 y. P7 K/ x4 e$ T0 R  Y//最大延時約55分鐘,足夠對大多數任何應用程序。增加
  j# L5 ?6 h) _- R" q//這種延遲將增加線性最大停留時間,也減少了響應能力
, e% `$ g4 B1 R9 t1 _//運行命令執行狀態報告一樣,因為這些每個住之間執行
6 y' F$ y# ]* ~( R) k7 B//時間步。還有,記住,Arduino延遲計時器不是很準確的長時間延誤。
5 M" o# R& h% ~8 ^* D% g
6 Q6 x5 `: y' l. Z  @6 M9 {$ e, J; t#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds)
. K" I+ H, u1 _6 p! R) _  `
4 N1 C4 ], F" v: E, T/ H// Creates a delay between the direction pin setting and corresponding step pulse by creating
8 @/ J7 \; K* e, i- A0 V// another interrupt (Timer2 compare) to manage it. The main Grbl interrupt (Timer1 compare) 7 {, }7 Y/ m2 e! f
// sets the direction pins, and does not immediately set the stepper pins, as it would in 0 E! C0 R: b: [, n# e) \5 e
// normal operation. The Timer2 compare fires next to set the stepper pins after the step
7 K6 R2 w# v- l// pulse delay time, and Timer2 overflow will complete the step pulse, except now delayed
) Q& S% X3 V+ A  {9 G% J; y% q" n$ t9 q// by the step pulse time plus the step pulse delay. (Thanks langwadt for the idea!)2 ]8 X+ g3 \4 q3 l( [
// NOTE: Uncomment to enable. The recommended delay must be > 3us, and, when added with the
6 B8 S# a/ Z  l2 C// user-supplied step pulse time, the total time must not exceed 127us. Reported successful+ e5 _% E4 z6 f$ m
// values for certain setups have ranged from 5 to 20us.
/ k6 F5 u5 B6 w5 [//創建一個方向銷之間的延遲脈沖通過創建設置和相應的步驟! A' H% Z. ^* Z: L8 C: G
//另一個中斷(Timer2比較)來管理它。主要Grbl中斷(Timer1比較)
* u& w+ y5 N/ a8 ?4 N//設置方向針,不立即設置步進針,因為它會在0 o( E1 E2 \+ H$ u0 Q/ @
//正常操作。Timer2比較火旁邊設置步進針后一步
' r$ t( n8 g" I. ?//脈沖延遲時間,Timer2溢出脈沖將完成的步驟,現在延遲除外" \! T- }0 u$ k% s4 _; H/ I
//脈沖時間加上的一步一步脈沖延遲。(感謝langwadt主意!)9 A" z0 s) f" u, I
//注意:取消啟用。必須> 3,建議延遲,當添加的
" X5 @4 \! h0 j( k3 q//用戶提供的步驟脈沖時間,總時間不得超過127美元。成功的報道: ~5 w! M5 ?. [' H  o
//值對某些設置范圍從5到20。
$ [4 @* A5 n+ i& g8 `3 ]" D8 e
9 @, h4 I. q! I3 t" d) T// #define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.
+ G6 L* {9 y- D( L: [: K9 z  g  t! d8 r4 `$ O
// The number of linear motions in the planner buffer to be planned at any give time. The vast
' R" A' S! f8 o/ V! O1 i// majority of RAM that Grbl uses is based on this buffer size. Only increase if there is extra 1 o' b" o# b7 I2 Z: A' s! y2 y
// available RAM, like when re-compiling for a Mega or Sanguino. Or decrease if the Arduino
3 F. [5 A- e- D$ {; A// begins to crash due to the lack of available RAM or if the CPU is having trouble keeping: `+ c0 u8 b# W3 p
// up with planning new incoming motions as they are executed.   G% D( U* ?1 K. N! J' V/ G$ p7 @4 U
//線性運動規劃師緩沖區的數量在任何給出時間計劃。絕大& i" _2 B1 z3 I! `2 v# L
//多數RAM Grbl使用基于這個緩沖區的大小。如果有額外的只會增加* c  x/ K* N- r
//可用內存,比如當基于大型或Sanguino。如果Arduino或減少: i; v! x* {! C# F  Q7 x
//開始崩潰由于缺乏可用的RAM或者CPU是難以保持
7 Q5 x; V) V( h! J# G$ q9 j$ }//與規劃新傳入的動作執行。* L6 c% a8 p7 q
/ n$ M. j. T' E$ g
// #define BLOCK_BUFFER_SIZE 18  // Uncomment to override default in planner.h.
, h" i+ \* u$ S: {5 m" ^& ]6 ]- j3 B" Y
// Governs the size of the intermediary step segment buffer between the step execution algorithm# F. P4 U* p0 P9 S- f# u% a8 k
// and the planner blocks. Each segment is set of steps executed at a constant velocity over a+ w4 {. {+ ~  j
// fixed time defined by ACCELERATION_TICKS_PER_SECOND. They are computed such that the planner
4 _5 e& F# ?& u8 ^& W( s1 S// block velocity profile is traced exactly. The size of this buffer governs how much step 6 u2 p" H4 S3 r2 ^+ B2 o
// execution lead time there is for other Grbl processes have to compute and do their thing 1 I2 b# B) }/ ^) O/ u8 S' q% b
// before having to come back and refill this buffer, currently at ~50msec of step moves., \/ Z) @" M& [2 I- t
//控制之間的中間段緩沖大小的步驟執行算法
$ S; w+ u" I2 ~: }$ E//和規劃師塊。每一部分的步驟執行在一個恒定的速度4 i5 i5 x7 C) L- [) k+ c
//固定的時間由ACCELERATION_TICKS_PER_SECOND定義的。他們計算的計劃
) Z; f5 F3 r: [: D4 Q//塊速度剖面追蹤到底。這個緩沖區的大小控制多少步驟$ {5 n, X6 G8 g* f1 T2 `/ r' T
//執行時間有其他Grbl過程需要計算和做他們的事情8 a, b% I0 i# w: ]2 ]
//之前必須回來重新填充這個緩沖區,目前移動~ 50毫秒的一步。
1 |  O# D( J+ K; S6 q0 \
1 V; T' ~0 E# H+ m// #define SEGMENT_BUFFER_SIZE 6 // Uncomment to override default in stepper.h.! a% @9 n& Z6 d+ Z! x
$ W' q7 w; o/ X- f! N
// Line buffer size from the serial input stream to be executed. Also, governs the size of
0 ~6 p9 B, ]# S. I5 Y. t  q// each of the startup blocks, as they are each stored as a string of this size. Make sure
. ~- v  i5 D( n$ E// to account for the available EEPROM at the defined memory address in settings.h and for- p$ E, _: K1 s
// the number of desired startup blocks.% r0 n; {( g6 v2 i/ W) b
// NOTE: 80 characters is not a problem except for extreme cases, but the line buffer size
9 a2 G0 F, v" ]% L: l// can be too small and g-code blocks can get truncated. Officially, the g-code standards
8 B  v" @. M3 `4 [// support up to 256 characters. In future versions, this default will be increased, when : G- I, I2 x' ^& Z- E
// we know how much extra memory space we can re-invest into this.+ `* U. P& a* f# A/ m
//行執行串行輸入流的緩沖區大小。同時,大小的控制: `0 I8 b# G; H5 g  D
//每個啟動模塊,它們分別存儲為字符串的大小。確保
- d$ A  r/ T2 m4 v0 L//占可用eepm定義內存地址的設置。h和' O' G7 ?4 B3 f
//需要啟動塊的數量。
, g5 U. @; l9 ^9 J. l' f: D2 t//注意:80個字符不是一個問題,除了極端的情況下,但線緩沖區大小
3 ^- u& C9 Y" I+ C: V2 |, G//可以太小和刀位點塊可以截斷。正式,刀位點標準
' E. D5 Y4 Q6 e$ T/ e) d+ c//支持多達256個字符。在未來的版本中,這個違約將會增加,當4 s4 x$ E# P$ L3 a
//我們知道多少額外內存空間的時候我們可以再投資。& Z- j* F5 x, H3 ~8 g

  Z" k) r- n# G% U5 [6 S// #define LINE_BUFFER_SIZE 80  // Uncomment to override default in protocol.h# r6 R# p* O7 _6 u: M
  + h) r7 B2 t, G1 r1 v1 O
// Serial send and receive buffer size. The receive buffer is often used as another streaming& w6 V8 W" L' L/ `* Y* P
// buffer to store incoming blocks to be processed by Grbl when its ready. Most streaming+ z7 s8 x% v0 [" V, i$ D5 ?
// interfaces will character count and track each block send to each block response. So,   S( c' V- D; ^6 l/ ~4 Q
// increase the receive buffer if a deeper receive buffer is needed for streaming and avaiable
0 a  t, t3 J, b! O3 N! U// memory allows. The send buffer primarily handles messages in Grbl. Only increase if large
% Y- ^5 N3 W0 A4 A3 z// messages are sent and Grbl begins to stall, waiting to send the rest of the message.
/ F$ f3 r3 e* ~, K; _: L; E- a// NOTE: Buffer size values must be greater than zero and less than 256.4 g5 ?. o/ E/ M0 m  c
// #define RX_BUFFER_SIZE 128 // Uncomment to override defaults in serial.h, ?) b% d( X( h) U
//串行發送和接收緩沖區大小。接收緩沖區通常用作另一個流
$ [% ~9 C- I/ [; P7 }2 H//緩沖存儲傳入的塊來處理Grbl當它準備好了。最流
% |) o1 W( p& {& U//接口將字符計數和跟蹤每一塊發送給每個塊的回應。所以,$ b1 _5 Z4 i; F! G1 e
//增加接收緩沖區如果需要更深層次的接收緩沖區為流,、' [* h+ E) ]0 Q$ [$ R0 y
//內存允許。Grbl發送緩沖主要處理消息。只會增加如果大
  e2 _' H9 k8 ^6 c6 j# w/ F  z+ u//消息發送和Grbl開始停滯,等待發送其余的消息。
& B/ @1 F7 n4 \//注意:緩沖區大小值必須大于零,小于256。
" d+ i2 Q# n* j9 h// # define RX_BUFFER_SIZE 128 / /取消serial.h覆蓋默認值
8 g1 u5 N; @6 P, R: [
$ V5 @! o4 O6 K8 O
2 o1 A+ j( H; F; [. c5 G+ ?// #define TX_BUFFER_SIZE 64- H# b% E0 w% }! o1 H( {
  
* `7 y+ n9 o: R% ^// Toggles XON/XOFF software flow control for serial communications. Not officially supported7 T. d  {4 ^8 k7 g6 l7 z
// due to problems involving the Atmega8U2 USB-to-serial chips on current Arduinos. The firmware; W1 G7 \7 x) ]4 `* K5 W+ j6 q, U
// on these chips do not support XON/XOFF flow control characters and the intermediate buffer
9 y+ x  y& R  d5 A// in the chips cause latency and overflow problems with standard terminal programs. However, ) D" H+ T. ~9 a7 @
// using specifically-programmed UI's to manage this latency problem has been confirmed to work.
' k# p1 F/ N" A// As well as, older FTDI FT232RL-based Arduinos(Duemilanove) are known to work with standard
8 k) b- s% H' C& Z! p- j5 M// terminal programs since their firmware correctly manage these XON/XOFF characters. In any
. I" t" w2 B# f. C% a7 u// case, please report any successes to grbl administrators!
3 o7 ?" p4 o6 M( X//切換為串行通信發送樸通/發送葡開軟件流控制。不是官方支持, K& N; a0 I  t  V+ d- @
//由于問題涉及Atmega8U2 USB-to-serial當前arduino芯片。固件
" j+ {( J- @' F  i% n' U//在這些芯片不支持發送樸通/發送葡開流控制字符和中間緩沖區4 r) z9 G; r( f+ X& X
//芯片導致延遲和溢出問題的標準終端程序。然而,) h% F% ~1 \4 ~! f7 q
//使用specifically-programmed UI的管理這個延遲問題已經確認工作。7 |3 r& o5 R8 |' z
//以及老FTDI FT232RL-based arduino(Duemilanove)是已知的標準
* q; x' |( C9 [$ O% K" Y' g4 v; j//終端程序因為他們正確的固件管理這些發送樸通/發送葡開的角色。在任何
5 h) H  }( l. U//情況,請報告任何成功grbl管理員!8 Z+ r. b0 e3 w3 T/ u% R% U; `

4 n+ j: H8 U* g/ d0 l# f$ b// #define ENABLE_XONXOFF // Default disabled. Uncomment to enable.
7 v: {1 R+ v6 R5 \/ c% S! ]; W, I- W7 A) M7 A
// A simple software debouncing feature for hard limit switches. When enabled, the interrupt / {& f. T3 `; |% W; [- B$ [
// monitoring the hard limit switch pins will enable the Arduino's watchdog timer to re-check
! Y8 \" C7 c8 s/ a. {// the limit pin state after a delay of about 32msec. This can help with CNC machines with
* O, [4 R( G' }, F& `# t// problematic false triggering of their hard limit switches, but it WILL NOT fix issues with 5 B2 U0 x( B' Y
// electrical interference on the signal cables from external sources. It's recommended to first
6 Q: G4 `3 @( e( A8 B// use shielded signal cables with their shielding connected to ground (old USB/computer cables " N% ^7 u& q: L* g1 @8 \
// work well and are cheap to find) and wire in a low-pass circuit into each limit pin.6 z2 j+ }8 o5 g. V" |# Z3 E
//一個簡單的軟件消除抖動特性硬限位開關。當啟用時,中斷- |8 n3 c- }. P0 G# ?; h2 d
//監控硬限位開關針將使Arduino的看門狗定時器重新審視4 N( V: L! G& ]0 _
//銷的極限狀態后約32毫秒的延遲。這可以幫助與數控機器& L" F$ {/ H7 W3 r  Q" K
//問題錯誤引發的硬限位開關,但是它不會解決問題
, {6 D" p1 ^1 l6 n3 @  {! v//電干擾信號電纜從外部來源。首先它的建議
0 Q% w) v4 u1 k; x* |3 F# P//使用屏蔽信號電纜的屏蔽連接到地面(老USB /計算機電纜/ w# H& n+ Q$ R' y2 q
//工作得很好,很便宜)和線低通電路到每個限位銷。3 ]% ]& e, N: F
9 t/ F- L0 A. _% x& b- d
// #define ENABLE_SOFTWARE_DEBOUNCE // Default disabled. Uncomment to enable.4 Q( @  [; j8 m

* {* W8 o3 [" @: v' J// Force Grbl to check the state of the hard limit switches when the processor detects a pin% k6 ~+ V7 ]% B9 v* g
// change inside the hard limit ISR routine. By default, Grbl will trigger the hard limits1 Q4 ?4 w/ c  `4 y5 w* e; {9 N
// alarm upon any pin change, since bouncing switches can cause a state check like this to
  B6 U% H, M. K4 u// misread the pin. When hard limits are triggered, they should be 100% reliable, which is the6 X2 A, O- ]4 U, m
// reason that this option is disabled by default. Only if your system/electronics can guarantee$ F+ F% |8 S2 `8 U
// that the switches don't bounce, we recommend enabling this option. This will help prevent6 K# o* M7 m1 r2 H+ p3 m  j& k9 X
// triggering a hard limit when the machine disengages from the switch.1 b# k' A; ?5 x1 r6 Z3 ^
// NOTE: This option has no effect if SOFTWARE_DEBOUNCE is enabled.
/ \# p1 z: c! N2 B//力Grbl檢查硬限位開關的狀態,當處理器檢測到一個銷
4 L2 `# k" R0 K+ |- m4 p7 J1 S1 G//改變內部硬限制ISR例行公事。默認情況下,Grbl將觸發硬限制0 G+ V/ n! E$ y2 O3 y# j
//報警在任何銷更改,因為跳開關可以導致這樣的狀態檢查
$ K3 Y* ~& g3 o9 K//誤讀了銷。硬限制觸發時,他們應該100%可靠,這是
/ q$ ]) h" B9 K2 w! b/ U//原因,這個選項默認是禁用的。只有在你的系統/電子產品可以保證" ]5 y5 I0 g& _! p! M! Q
//開關不反彈,我們建議啟用這個選項。這將有助于防止2 B) \, k" U0 X# e; o6 n
//觸發機退出時硬限制開關。
3 v) Q2 @5 P% ?; S* l//注意:這個選項如果啟用了SOFTWARE_DEBOUNCE沒有影響。3 I( G% @0 {; @4 p4 G7 H7 _. S

' D! H( J7 A: b) _' k// #define HARD_LIMIT_FORCE_STATE_CHECK // Default disabled. Uncomment to enable.7 h$ r# v9 X8 m

. v/ H3 W0 N% p& H  L* `) Q
" \( R! f5 r# H4 v// ---------------------------------------------------------------------------------------
. r% O, {! Y2 U: j// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:編譯時錯誤檢查的定義值:* r" }& ^/ d+ E! x! {

* B  o3 l7 c7 I2 d/ w#ifndef HOMING_CYCLE_0
" }, @, h) g9 U) ~! z  #error "Required HOMING_CYCLE_0 not defined."
8 r: Q6 y' y0 W  a$ T1 E& _8 a8 t0 z#endif! ?- d) g/ E9 f- W6 ]1 E7 M
3 f6 O) ~; |3 y& J- E
#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(VARIABLE_SPINDLE)
# M% v0 }- ^- r" {5 @  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with VARIABLE_SPINDLE enabled"# R: S: ~( x8 c1 f, V4 v
#endif
; |& o4 A; x( k1 q- H* d
# [: P5 Y/ ]; o8 [9 H( Y, [( }0 e#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(CPU_MAP_ATMEGA328P)& A8 W+ s' G( r/ F& E
  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with a 328p processor"! y' b. C. u7 i. b) r4 n  S
#endif
$ H; A" k4 q3 m! B, h5 t0 H$ u: ~$ K
5 d4 i/ G& `+ }% z& ], ?8 V// ---------------------------------------------------------------------------------------
) J# R$ ?9 E$ U
% f- p4 G5 }% O/ b$ S
8 n8 ?1 C+ S2 O2 V( `#endif: h; e/ z' k4 o' X3 K/ t

8 M6 z% |" L7 u' _! U  F4 n( m, c- D9 u
1 \: v, |5 ^7 B+ H+ K" ]2 N

7 n; j6 s# d" Q) D3 B2 H) }9 }8 k; }. o& P& N% L1 Q4 d

3 C2 p+ i+ f$ K  o: w& C9 L  z
3 W1 [5 }" T. Q/ s9 ]& V! g0 S4 h
6 `, e- `* ]; K# V+ |1 t
. b% _* G- @! C2 a, ]" c5 B, }1 u, v8 ]5 u

1 X; g1 q* K; I" \0 w7 M9 Y0 n: R: Q

) ]; ?' |& I- k
8 {  G# y  e; e
# e- L( E1 T2 n& f0 A# J7 C& \# h: C$ I+ W' h" [

本帖子中包含更多資源

您需要 登錄 才可以下載或查看,沒有賬號?注冊會員

×

評分

參與人數 2威望 +201 收起 理由
mrplplplpl + 1 思想深刻,見多識廣!
管理團隊 + 200

查看全部評分

回復

使用道具 舉報

2#
 樓主| 發表于 2016-8-21 00:11:42 | 只看該作者
那些沒有用的照片不知道怎么就上去了好討厭。
3#
 樓主| 發表于 2016-8-21 00:14:16 | 只看該作者

. q+ v6 b/ X9 F  \% B
4#
發表于 2016-8-21 05:50:22 | 只看該作者
      樓主厲害!
5#
發表于 2016-8-21 08:22:05 | 只看該作者
謝謝樓主,先收藏一下,慢慢學習
6#
發表于 2016-8-23 15:11:25 | 只看該作者
這是什么寶貝?
7#
發表于 2016-8-23 15:11:47 | 只看該作者
換了個瀏覽器Chrome,試試能否發言了。
8#
發表于 2016-8-23 20:12:33 | 只看該作者
樓主厲害
回復

使用道具 舉報

9#
 樓主| 發表于 2016-8-23 23:03:17 | 只看該作者
補充( o( F7 B4 C/ W( f8 h6 R2 S" l
程序運行protocol_execute_realtime(); /運行實時命令。
/ W$ `0 p0 d' x4 [+ ?) X, d// Executes run-time commands, when required. This is called from various check points in the main
6 _7 Y' Z! p5 O) K- w1 I$ y// program, primarily where there may be a while loop waiting for a buffer to clear space or any
8 l1 o% `- h. ?3 R4 [// point where the execution time from the last check point may be more than a fraction of a second.
3 M* N1 H! B1 s8 ^) _; c2 d// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code
% O0 e# o, K) r$ T5 U  l0 V5 K. K// parsing and planning functions. This function also serves as an interface for the interrupts to 3 {) Z" p' Y1 [- w
// set the system realtime flags, where only the main program handles them, removing the need to
# j* [( G0 t( n. P// define more computationally-expensive volatile variables. This also provides a controlled way to
: t* C8 I) [% u1 z* j4 r// execute certain tasks without having two or more instances of the same task, such as the planner
$ c0 a8 o" |+ _$ d// recalculating the buffer upon a feedhold or override./ t, C, c4 P5 [6 z
// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,) j3 D- I' f' p  r' X- B
// limit switches, or the main program.. X9 Q( q0 c6 Y* T
" f/ m/ B3 H; j- k; ^$ x" Z( m- f
//執行運行時間命令,在需要時。這就是所謂的從各種主程序要檢查站
# A  |, w! f* p//,主要是那里可能是一個while循環等待緩沖區空間或任何3 V2 L: C& K7 \$ H- }% i
//執行時間從過去的止點可以超過幾分之一秒。5 I& H! H8 U* ^9 T! b
//這是一種異步執行實時命令(又名多任務)grbl的刀位點
/ b$ G/ T, K7 J2 |" I8 \) ^" j9 J//解析和規劃功能。這個函數也可以作為一個接口,用于中斷4 H* |; l  c  M  }. |
//設置系統實時的旗幟,只有主程序處理,消除的需要
" A& {  u& i' B+ ^//定義更多的計算昂貴volatile變量。這也提供了一種控制方法
2 G7 T* S1 C7 ]6 o8 i* d//執行某些任務不相同的兩個或多個實例的任務,比如計劃, ?; e  a5 ^% O# G
//重新計算緩沖feedhold或覆蓋。
7 P* i9 G7 C8 u2 k$ G( l2 P; W//注意:sys_rt_exec_state變量標志設置任何過程,步驟或串行中斷,插腳引線,
2 h3 h' P* C6 D2 E7 b0 u' W//限位開關或主程序。
) Q3 Q) y6 s/ L2 B- D2 Pvoid protocol_execute_realtime()
% Z7 v1 w/ v, I6 {. j5 ?{: O; X6 C+ O, h& A: ]
        // Temp variable to avoid calling volatile multiple times.0 U, `8 A9 n! x5 Z+ A# }0 ]7 W: @7 V
        // 臨時變量來避免多次調用不穩定。
% @2 m) j- V8 ]9 `, F        uint8_t rt_exec; ) S1 G# F* L4 {# c! k5 B" V. s
        do{
$ J* T/ d* J& a7 J9 n7 a          if (rt_exec) {                 // 有標志位置位進入' l" V+ n1 K. B$ y
        7 c7 X, x& T1 o. I" x
            sys.state = STATE_ALARM; // 設置系統為報警狀態+ }2 I) G- y: P9 o( n2 N/ W% T6 a
      report_alarm_message(ALARM_HARD_LIMIT_ERROR);        //報告報警信息為接近極限值
) I, M" d% y# O/ H, L6 m6 E8 ~' \    } else if (rt_exec & EXEC_ALARM_SOFT_LIMIT) {                        //報告執行軟件限位報警$ q2 z% c% ?' C( v
      report_alarm_message(ALARM_SOFT_LIMIT_ERROR);        //報告出現軟件限位報警
+ c$ R( S, ~* D# G& C0 I$ \4 a( h    } else if (rt_exec & EXEC_ALARM_ABORT_CYCLE) {                //執行停止循環報警      $ D5 I: \  m& \
      report_alarm_message(ALARM_ABORT_CYCLE);                //出現終止循環報警% p, c8 ?7 v0 x0 h
    } else if (rt_exec & EXEC_ALARM_PROBE_FAIL) {                        //執行探查失敗報警2 H, n4 K* V4 [) ^$ G# w8 l, `! F
      report_alarm_message(ALARM_PROBE_FAIL);                        //出現探查失敗報警
1 Z" k& {  U2 Y    } else if (rt_exec & EXEC_ALARM_HOMING_FAIL) {                //執行返回原點失敗報警
( [& q6 f; o( @* R+ X' I2 \* g      report_alarm_message(ALARM_HOMING_FAIL);                //出現返回原點失敗報警$ Z- k4 @- t* s  x) W: I
    }
/ a' T8 h) I, U0 {* v) O1 Y& n2 Q: q1 `7 _, Q% I' `+ D! a
    // Halt everything upon a critical event flag. Currently hard and soft limits flag this.
% A8 E4 H+ |9 t5 Q    // 停止一切在一個關鍵事件標志。目前硬和軟限制標志7 @5 Q3 g# C, m2 T7 H
           if (rt_exec & EXEC_CRITICAL_EVENT) {                //如果系統是循環事件進入+ U! w  l) S- W1 L6 v
             report_feedback_message(MESSAGE_CRITICAL_EVENT);        //報告反饋信息) r( ?& G! r- E2 [: m! W  O- p- v
              bit_false_atomic(sys_rt_exec_state,EXEC_RESET);                         //清除目前的復位狀態+ R! |3 Z: R; S/ E' s
) t6 x) m2 n2 M% F8 w6 C
        bit_false_atomic(sys_rt_exec_alarm,0xFF);                                 // 清除所有報警標志# X5 N) F+ J. E& W" C9 V- d; r
        }        8 z( r% Q$ s% K) t1 s/ ^

# Y1 `' z5 V) [; F+ n) R上面代碼將rt_exec = sys_rt_exec_alarm ,如果rt_exec為真,打印不同報警信息# w7 ]( s" K8 |0 R/ s
和限位保護信息,然后清除報警狀態# R5 @- s) Z5 Z. n2 e$ R
___________________________________________________________________________
7 H/ a6 k3 Y( U# L& d- u) @1 D沒有報警進行執行下面代碼,執行了終止命令,串口打印命令% Z, G& J7 r- \) Z
        // Check amd execute realtime commands        校驗和執行實時命令
2 }, |" U  X# @          rt_exec = sys_rt_exec_state; // Copy volatile sys_rt_exec_state. h3 H9 e& c# \) b4 f0 Y) R0 `5 `

- D6 |+ e# _+ [& Z0 Z! d  \8 z! l" b8 ?        if (rt_exec) { // 輸入標志是正確的執行
% u* @  E4 |: W- z) g! O8 O& _1 T# {9 Y! p3 {
            // Execute system abort. 執行系統終止命令, N: H7 H6 w* U& b  R9 Q( O+ q
            if (rt_exec & EXEC_RESET) {7 P5 L) C( q, O. B7 f' {5 j/ m
              sys.abort = true;  // Only place this is set true.1 P4 O) ?' w( h
              return; // Nothing else to do but exit.% d% e2 J' ]5 e' @& e
        }$ ]3 U3 z2 \8 a# \4 w7 m) A6 L

( z& ^" ^* \3 y" @: x4 u- {            // Execute and serial print status 執行和串口打印狀態
: Q# U# H3 j. L) n  S+ k            if (rt_exec & EXEC_STATUS_REPORT) { ' {* v$ z9 p* U' `! M# |0 C- q
              report_realtime_status();        //報告實時狀態- H2 s- a+ J+ h0 S" e
              bit_false_atomic(sys_rt_exec_state,EXEC_STATUS_REPORT);        //清除報告狀態清零
" ]& f; X* I4 f! \            }( \7 |, J+ m( ?$ z3 U3 Q5 e7 z
_____________________________________________________________________________
" v. y: ]- r' j9 m& R0 D下面代碼
1 @0 Y$ _% R3 O  ~1 R//執行狀態。
2 u; J- {, ~% H3 o& k//注意:所涉及的數學計算持有應該足夠低對大多數人來說,即使不是全部,
5 w' B6 w9 J8 ^0 f% W//操作場景。一旦啟動,系統進入暫停狀態
$ O: c: @* L: U! h) E//主程序流程,直到重置或恢復。/ G' d+ b( ~  V' ^8 G
待辦事項:檢查模式?如何處理呢?可能沒有,因為它只會在空閑,然后重置Grbl。4 ^5 ^+ O- |1 N
狀態檢查容許狀態的方法。
# A2 v$ s+ `! T7 u4 [& ^8 h
1 F7 W$ g$ ]6 S        //如果全局各自報警標志位其中(執行取消動作) | (執行進給保持) | (執行安全門)任意一位為真進入
, y& i  F3 X( h7 s! E: w) g7 S            if (rt_exec & (EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR)) {        5 z, f# C9 V8 d3 {! H" t6 E  a# ^
/ x$ A0 W- @1 |! h2 F! \" P
        //如果是循環狀態執行暫停狀態
2 v& _: j+ c4 d7 {+ |# o  e' Q; C        if (sys.state == STATE_CYCLE) {7 v) ~: T3 u! L; M% S8 k
        st_update_plan_block_parameters(); //通知stepper module驗算減速。/ ~& t* `7 ~  T% _/ ~
        sys.suspend = SUSPEND_ENABLE_HOLD; // 開始暫停標志
* T" T: V$ V# [        }9 ]9 F' _0 a0 t1 |/ U% [0 b
) {- F" m$ g* `
        // 如果,Grbl空閑不在運動。簡單的指示暫停就緒狀態。
2 u' I" W6 `* ~! D  w0 c2 D, s6 z, N        if (sys.state == STATE_IDLE) { sys.suspend = SUSPEND_ENABLE_READY; }
' e& w  ]; X7 b: l* \/ S; i& A
- q6 z) V4 `5 ], U
7 L6 G1 d% T: Q  g5 _8 ^( \7 K" Q        //執行和標志和減速運動取消并返回空閑。主要由探測使用周期5 A/ v% |4 M, o9 {& F' N6 @8 {
        //停止和取消剩余的運動。      
' m/ b4 c! S. A- b        if (rt_exec & EXEC_MOTION_CANCEL) {
3 z1 c& R; X, K$ k          if (sys.state == STATE_CYCLE) { sys.state = STATE_MOTION_CANCEL; }. J" g( ]) d* n& [8 r
          sys.suspend |= SUSPEND_MOTION_CANCEL; ) v' T! D4 Z+ E8 X
        }; b) d; d/ z, H+ B* s

# y8 V& S+ }+ |+ C, c        // 只在循環時執行進給保持減速
3 A% U' ]/ O( U) B7 l         if (rt_exec & EXEC_FEED_HOLD) {
8 @" L% w" d7 G3 o5 p' {- R) Y& p        //只有安全門為1才執行保持進給狀態賦值
6 x$ I7 Z' Z. ~& ~6 k% u          if (bit_isfalse(sys.state,STATE_SAFETY_DOOR)) { sys.state = STATE_HOLD; }
" u) d$ U* t( i1 k' a# H! J        }: ]6 C; e0 v. p2 J* t

9 ?5 L0 Z; {1 T) p4 o        if (rt_exec & EXEC_SAFETY_DOOR) {
0 Q. {3 M0 F4 ^# L* ^5 Y          report_feedback_message(MESSAGE_SAFETY_DOOR_AJAR);
0 T% ]5 P2 D7 U7 a, Q/ /如果已經活躍,準備好重新開始,CYCLE_STOP標志設置為強制斷開。
- _/ E+ u) \6 D; @/ /注意:只是暫時設置“rt_exec”變量,不是動蕩的“rt_exec_state”變量。7 d* u9 x9 r5 S9 g; X2 N8 c
          if (sys.suspend & SUSPEND_ENABLE_READY) { bit_true(rt_exec,EXEC_CYCLE_STOP); }
% H0 Q. }; A7 H& ~, \          sys.suspend |= SUSPEND_ENERGIZE;5 k* F/ N8 z8 O) Y$ P
          sys.state = STATE_SAFETY_DOOR;/ w! W: [& u8 x" ^0 S" ]
        }* Y4 X- t0 v3 i+ V0 {) u
+ _; A; |6 A  F1 O# h
bit_false_atomic(sys_rt_exec_state,(EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR));   
9 j- q& X8 ~7 Z2 a5 A' M
% b) ]$ q$ D+ N1 I0 a* R}2 J6 W! @8 o( s  ^3 x
以上代碼執行了+ R( O0 y' E) V, W
1.如果全局各自報警標志位其中(執行取消動作) | (執行進給保持) | (執行安全門)任意一位為真進入
) A/ \1 w- m1 Q; N" n/ j2 K  Z2.系統為閑著狀態, 開始循環狀態, 回原點狀態, 控制取消狀態, 開始保持狀態, 開始安全門狀態時進入
% l' v: I1 j" y9 [3.如果是循環狀態執行暫停狀態
. y/ X+ o( Q5 y/ I/ {- l4.如果系統閑置狀態執行暫停就緒狀態- `7 Y% [  I- L
5.執行動作取消
9 J# T' Q4 Q% `7 d( ]+ j3 i6.如果是保持進給狀態,執行保持進給狀態
7 i) C6 C! s  }4 P( T7.執行安全門狀態% d1 u) |1 E( R: _5 R: l! c" Q* W3 W
最后執行bit_false_atomic清標志清除(執行取消動作)(執行進給保持)(執行安全門)標志位                  3 z9 @) S& \% ]+ f9 T, W" U. I
_____________________________________________________________________________3 f; C. j0 e# P
* F4 t. B$ I9 \
    // Execute a cycle start by starting the stepper interrupt to begin executing the blocks in queue.
0 B. y: ^- s* t6 W! Q* c; x) C& k    // 執行一個循環開始啟動步進開始執行中斷隊列的街區
* ~( q+ d& v4 |& B9 c* r, _    if (rt_exec & EXEC_CYCLE_START) {        //循環開始狀態進入. R( ]4 c) V) E" C  A
      // Block if called at same time as the hold commands: feed hold, motion cancel, and safety door.
2 i! G, N+ ~3 {; _( v: S      // Ensures auto-cycle-start doesn't resume a hold without an explicit user-input.# f; J% X7 o# T. B( Q: N1 }3 d
          //塊如果在同時舉行的命令:保持進給,運動取消,和安全的門。 //確保auto-cycle-start沒有簡歷沒有顯式的用戶輸入。
8 O7 S7 Z! J& ]8 k! e          
8 @0 w* k9 W+ h6 [3 ?- R      if (!(rt_exec & (EXEC_FEED_HOLD | EXEC_MOTION_CANCEL | EXEC_SAFETY_DOOR))) {   //狀態機如果不是保持進給,運動取消,和安全的門。
. w5 `$ X- L( @. @) W        // Cycle start only when IDLE or when a hold is complete and ready to resume.
4 A- \; `% L& s: K        // NOTE: SAFETY_DOOR is implicitly blocked. It reverts to HOLD when the door is closed.
' o: [3 ?6 L7 e                //循環開始時只有當閑置或持有完成并準備簡歷。- q- p% h2 E4 X% E% l- A+ a
                //注意:SAFETY_DOOR是隱式地屏蔽。它返回的時候門是關閉的。   
- J  A4 T$ B1 ]* D' z
7 l4 H9 U7 z, Z/ H$ c5 o  c                // 如果系統狀態為閑著狀態,系統狀態為開始進給或運動取消,暫停標志為位重新開始
0 c5 g% s* ?" b        if ((sys.state == STATE_IDLE) || ((sys.state & (STATE_HOLD | STATE_MOTION_CANCEL)) && (sys.suspend & SUSPEND_ENABLE_READY))) {
) {/ O0 l7 j. V- G! ?          // Re-energize powered components, if disabled by SAFETY_DOOR.- [1 e# `, M) q2 p' J" Q8 a0 \& r
          //        由SAFETY_DOOR重振組件供電,如果禁用。9 V- q2 G, u9 w' |1 r- W* u/ A
          if (sys.suspend & SUSPEND_ENERGIZE) {
& `- {8 ^4 M; n$ P; v/ l. }2 V& a            // Delayed Tasks: Restart spindle and coolant, delay to power-up, then resume cycle.3 J4 u4 q0 i# \1 z, J
            //延遲任務:重新啟動主軸和冷卻劑,延遲升高,然后恢復周期。7 N: `7 }0 k$ I& R: x* I# q
            if (gc_state.modal.spindle != SPINDLE_DISABLE) {   //主軸模式不是失能進入
$ L9 Z3 M6 B8 B8 F; e              spindle_set_state(gc_state.modal.spindle, gc_state.spindle_speed); //設置狀態和速度* G- p- j! Q8 J1 _7 c3 p0 X
              //待辦事項:阻塞函數調用。最終需要一個非阻塞。9 _7 \3 K, Z8 o( A: X
                delay_ms(SAFETY_DOOR_SPINDLE_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.( r6 P( W* A, |, g4 m6 H% r
            }
' U: W/ X1 |; k0 f# p0 ]3 k1 X            if (gc_state.modal.coolant != COOLANT_DISABLE) { 8 W- |% c' ]) R4 K; X6 x
              coolant_set_state(gc_state.modal.coolant);
8 D- ^$ P* g. e/ @/ q              delay_ms(SAFETY_DOOR_COOLANT_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually." |0 h3 J$ \) ], V4 D1 _# z* G
            }
+ z0 c3 |2 o" \/ D$ D0 J3 ~            // TODO: Install return to pre-park position.
+ A1 Q- G. B( I7 Y! a2 T3 r          }  B. F, ^1 Z( e( t
______________________________________________________________________________________________________________
% j! o- B* T# D. D2 U          // Start cycle only if queued motions exist in planner buffer and the motion is not canceled.
! q3 i) K) E' d' r                  
$ u$ Q* k" _, f% m/ X                  //只有在隊列馬達存在規定的緩沖,并且動機沒有讓取消,才會循環
. B! \3 g+ i' P; }6 X  e( v) ?( D                  
& z( K8 j' y- p. D2 M) p- y: ]          if (plan_get_current_block() && bit_isfalse(sys.suspend,SUSPEND_MOTION_CANCEL)) {' T4 x- p& j# ]
            sys.state = STATE_CYCLE;
9 E* k* E+ x) |+ g0 e            st_prep_buffer(); // Initialize step segment buffer before beginning cycle.初始化步開始循環之前
7 Z0 B3 }6 L5 I& x4 G9 I            st_wake_up();& r2 c* n& t5 k
          } else { // Otherwise, do nothing. Set and resume IDLE state.否則,什么也不做,設置和復位空閑模式! t; ?0 R* `6 K
            sys.state = STATE_IDLE;. Q1 R6 {/ {+ E
          }1 Q8 C. w: U* g! L# q
          sys.suspend = SUSPEND_DISABLE; // Break suspend state.
) K4 {: Q8 i5 l        }
0 C! ~3 S2 H8 w0 a2 i2 o2 s9 H. H      }    $ G" o) [7 u# t2 E, j  E
      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_START);        * O; P8 O) B6 e
    }
/ P+ }$ |! E% @: o$ m2 A
" l8 X7 s7 X! k+ A/ J_______________________________________________________________________________________________________( Z9 C5 {5 Z9 V2 ]
    // Reinitializes the cycle plan and stepper system after a feed hold for a resume. Called by 0 O$ i: t6 l' g: n! m' G
    // realtime command execution in the main program, ensuring that the planner re-plans safely., _9 n+ \! q4 U# {# f0 {! R
    // NOTE: Bresenham algorithm variables are still maintained through both the planner and stepper# J9 O2 [# o/ I6 H7 S3 e# h/ i/ d, y
    // cycle reinitializations. The stepper path should continue exactly as if nothing has happened.   $ j/ H7 `2 Y, y. h. M1 p% H
    // NOTE: EXEC_CYCLE_STOP is set by the stepper subsystem when a cycle or feed hold completes.- W2 m9 K! r- @3 x

; B& N4 z: M+ u& p        //重新啟動后循環計劃和步進系統的進給保持簡歷。通過實時命令執行主程序,確保安全計劃重新計劃。
' g; ^) v3 v! o        //注意:畫線算法變量仍保持通過規劃師和步進( V1 o( c& t) h
        //循環僅。步進路徑應該繼續,好像什么都沒發生一樣。        2 [# v3 x/ l6 N1 ], A) a
        //注意:EXEC_CYCLE_STOP由步進子系統周期或進給保持時完成。
+ y, V8 M% x$ i, }( x1 ?7 N# E0 I1 h/ f* F/ G
    if (rt_exec & EXEC_CYCLE_STOP) {                         //如果是循環停止狀態進入
/ m& g, `+ h: d5 y      if (sys.state & (STATE_HOLD | STATE_SAFETY_DOOR)) {8 I! }5 k5 j! E. ~% y- w+ i- N
        // Hold complete. Set to indicate ready to resume.  Remain in HOLD or DOOR states until user, `7 d& m% j0 e2 A2 W
        // has issued a resume command or reset.
& a# i3 D+ x; U3 a: A, t
+ Q! }1 }7 O2 S4 j& X) Z                //保存完整。設置為指示準備簡歷。繼續持有或門狀態,直到用戶
, q+ |+ r. P( K9 i' n                //已發布了一份簡歷命令或重置。
3 h- m, h8 H! A9 W4 p, {; p# ^               
0 p! G4 u- }3 K% V* N( U6 r& _; o$ d! E        if (sys.suspend & SUSPEND_ENERGIZE) { // De-energize system if safety door has been opened. 如果安全的門已被打開。斷開系統
# X  J: R; p/ k9 h3 f. I          spindle_stop();, t) d( m! u0 K3 |4 p4 r
          coolant_stop();  O! Q+ q* d+ @/ T; B
          // TODO: Install parking motion here. 安裝停車動作。6 q' Q% l3 p& b2 h8 ]7 W
        }
; _, D: d: o) w' Z: S' O" y5 I( ?7 {        bit_true(sys.suspend,SUSPEND_ENABLE_READY);- M3 h4 s. p/ _( J
      } else { // Motion is complete. Includes CYCLE, HOMING, and MOTION_CANCEL states. 電機完成,循環,回原點,,MOTION_CANCEL
! f7 [6 W0 z! X) o7 U1 v        sys.suspend = SUSPEND_DISABLE;
$ p1 B2 p6 a9 P7 c: R( A$ M        sys.state = STATE_IDLE;/ i; P: [( h- p, i( l6 `2 r
      }
. S9 K' o. W% w* d8 d      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_STOP);
: z: n/ |0 J# c8 T3 P" F    }1 B0 ^" F5 j. J2 y
    # [1 ~! U  f5 \$ L9 ~! {6 _
  }
# a& ?- \7 f' ^/ B: L# ?___________________________________________________________________________________________________* L& Q* ?; d+ _% F! V
6 F4 q* n% H  {* k. s3 u7 B% J
  // Overrides flag byte (sys.override) and execution should be installed here, since they 3 w7 {5 G/ H8 V* A3 S% B
  // are realtime and require a direct and controlled interface to the main stepper program." a9 n) w3 b" y

& {& l5 j! D0 T" Q, n. e8 |0 r  //重寫標志字節(sys.override)和執行應該安裝在這里,因為他們
$ `. i8 x2 D3 K6 j5 J" Y; z! ^  //實時和需要直接和控制接口的主要步進程序。
' I; o+ |9 f9 ~) v. ^- e, K3 B/ d/ l* x+ I( }
; P' o# p: y% k' \7 J$ n* `
  // Reload step segment buffer 重新加載步段緩沖
! R# j& ^1 B# G; j  if (sys.state & (STATE_CYCLE | STATE_HOLD | STATE_MOTION_CANCEL | STATE_SAFETY_DOOR | STATE_HOMING)) { st_prep_buffer(); }   |! B8 s1 z  |, c0 i

# s! Q/ b  |; c; z" e4 X2 W# c' H  // If safety door was opened, actively check when safety door is closed and ready to resume.# [& t  n) V: ~+ o& O! Z
  // NOTE: This unlocks the SAFETY_DOOR state to a HOLD state, such that CYCLE_START can activate a resume.        . r, L0 T$ {) S# w7 P" C8 |6 j. f& w
6 y2 V: E2 g% z6 T9 X! d1 ?
//如果安全的門被打開,積極檢查當安全門關閉,準備簡歷。
7 R, p+ @: U& X: F' _( C( e; p( i  //注意:這解鎖SAFETY_DOOR狀態保持狀態,這樣CYCLE_START可以激活一個簡歷。0 O7 V7 R' ~% @+ L; A

' Y2 ^; O- x  U+ O. S  if (sys.state == STATE_SAFETY_DOOR) {                 //安全門狀態進入
+ F, x5 A/ \" E    if (bit_istrue(sys.suspend,SUSPEND_ENABLE_READY)) { , p: T/ B# _2 b5 I& b
      if (!(system_check_safety_door_ajar())) {
' X  \/ n9 l$ `& `9 f        sys.state = STATE_HOLD; // Update to HOLD state to indicate door is closed and ready to resume. 更新保存狀態指示門關閉,準備簡歷。) s. f) k8 c, d- ]! Z; R
      }! ]3 l: K2 Z' W, W5 y* S; l
    }: ~6 Y3 Z9 h2 {4 j; z: \
  }6 _  y# L/ x8 y5 R  k
/ |" b" ^* q) q* k
  } while(sys.suspend); // Check for system suspend state before exiting.0 o( \2 h; p" R7 {4 g
  / L1 y8 V+ B5 [) v+ W- E/ S$ Q
}  
10#
發表于 2016-8-25 09:31:12 | 只看該作者
樓主這些代碼。是網上搜來,然后自己組合的嗎?全是自己想的,那是牛逼了

點評

外國的開源軟件grbl,在研究它,將打注釋了下而已,研究透徹了好移植的其他平臺應用,學習階段。 https://github.com/grbl/grbl  詳情 回復 發表于 2016-8-25 22:19
您需要登錄后才可以回帖 登錄 | 注冊會員

本版積分規則

Archiver|手機版|小黑屋|機械社區 ( 京ICP備10217105號-1,京ICP證050210號,浙公網安備33038202004372號 )

GMT+8, 2025-9-2 22:24 , Processed in 0.102139 second(s), 19 queries , Gzip On.

Powered by Discuz! X3.5 Licensed

© 2001-2025 Discuz! Team.

快速回復 返回頂部 返回列表