久久久国产一区二区_国产精品av电影_日韩精品中文字幕一区二区三区_精品一区二区三区免费毛片爱

 找回密碼
 注冊會員

QQ登錄

只需一步,快速開始

搜索
查看: 19083|回復: 15

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

[復制鏈接]
1#
發表于 2016-8-20 23:56:23 | 只看該作者 |倒序瀏覽 |閱讀模式
本帖最后由 1五湖四海1 于 2016-8-21 00:09 編輯 2 |+ S7 Y$ j; k

% @3 B; r0 A: a) M    以前制作過CNC雕刻機,是用MACH3作為上位機控制,硬件是采用PC接并口輸出脈沖和方向使能信號經過隔離驅動步進電機驅動器,步進電機驅動是采用TB6560芯片控制。最后就接到步進電機。機械是用鋁合金制作,主要部件有三個1605的滾珠絲杠,多個運動滑塊等制作。用這臺DIY CNC雕刻機可以雕刻木頭塑料等東西。當時沒有一直玩下去,現在發現網上有用單片機制作的雕刻機挺精巧的現在分享給大家。9 j/ v' G0 A1 w3 a# M# ]9 l
   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個運動來規劃運行速度,以實現平穩的加速和無沖擊的轉彎。很棒吧!開始玩起。
0 d) i" _, y% F* R9 b/ M    還沒有雕刻機的機械部分可以用廢舊光驅制作個微型雕刻機運動平臺。雕刻機最重要的是主控程序這次用 Arduino/AVR328單片機,價格在15元左右,主控程序是上面提到的目前很火的開源
的GRBL,還有一種基于STM32平臺的開源主控程序Dlion也不錯可以替代grbl。如果從性能比較這兩個方案,顯然是stm32平臺運行速度更快畢竟他是32單片機呀!+ ]) f# k8 h1 I6 n% \
: n5 |  A/ e( ]5 p& p+ u
$ I  B0 l; ~; i7 ?6 k; H
    下面介紹小這個些主控程序主要干的事,通過串口PC和主控板通訊,PC命令給控制板,控制板接收命令做不同的響應,PC可以發G代碼給主控板,接收完成后可以自動開始雕刻任務。
1 R$ r) j  f$ b: G# Y. ?2 J/ K          在介紹下G代碼因為G代碼是雕刻機的核心部分
+ F: c' I4 O5 j: UG代碼是數控程序中的指令。一般都稱為G指令。
( E- h4 A1 R$ U7 jG00------快速定位
) W. t# H/ r5 ]- rG01------直線插補
, u! w+ P* f* k) IG02------順時針方向圓弧插補
  L2 C8 @! Q" y2 A; P: rG03------逆時針方向圓弧插補
4 g' C* z1 J! t! @; e) o: |2 AG04------定時暫停/ }+ w: e1 }# U, A
G05------通過中間點圓弧插補- W2 O2 @1 b# X& A% y( f9 i
G06------拋物線插補8 k1 m) g6 Z) }8 {
G07------Z 樣條曲線插補( @: i6 t: `5 M. M) z* H: c
G08------進給加速
) Q" n  s& @4 O( @/ h3 xG09------進給減速
0 ]) _9 J. @+ I" X6 FG10------數據設置% t  z2 |7 `  Z3 ]  R2 o
G16------極坐標編程: o6 `: @0 i; Z, ^
G17------加工XY平面
1 A; B1 m0 W& G* |$ b+ ]. JG18------加工XZ平面
) s( |# y5 G" P9 @: @, EG19------加工YZ平面
" p' U) X3 l5 h5 N" U
核心就是解析G代碼,完成步進電機驅動,和控制主軸開啟關閉,還有插補算法,直線插補,圓弧插補,還有一些步進電機的加減速算法。9 Z! P* `( r! i7 ^
下面對grbl主結構做介紹7 ?6 a" \; N5 H+ R- |$ n" I( M6 z1 }
main()主函數首先執行下面初始化函數
3 A+ c1 |3 E" g3 L; |        serial_init();                           // 設置串口波特率和中斷
; R3 A: O, B' e9 W# w/ g& q        settings_init();                         // 從ROM加載grbl設置' H- f7 }, z: |; O, E+ @* k
        stepper_init();                          // 配置步進方向和中斷定時器
2 G6 C) V- M7 m1 k, T' R        system_init();                           // 配置引腳分配別針和pin-change中斷+ V! Z1 }( N; s
        memset(&sys, 0, sizeof(system_t));          // 清除所有系統變量0 c3 H' @# P0 x/ X/ D( ~, E( i# j
        sys.abort = true;                           // 中止標識位置位' s  ~2 ^: N; c/ C* x- i, u7 l
        sei();                                         // 使能中斷
5 b& I( `6 W7 H& U  #ifdef HOMING_INIT_LOCK                        // 宏運算(settings.flags & (1 << 4)) != 0結果flags等于執行sys.state = STATE_ALARM
6 m9 m: v+ j3 g( h4 R/ [  R, ^  P) W                                                // 系統狀態賦值為報警狀態5 `* x+ w: m6 }
            if (bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE)) { sys.state = STATE_ALARM; }- C4 d! o6 n2 v- a! f
  #endif
* ~$ j% {$ M4 {% r) A$ ______________________________________________________________________________________________________________________________________" O+ p; M/ n2 i- K$ q
接下來是一些主要部分初始化
( ^# ]; Z$ ^+ H( t2 V" l9 A4 `for(;;) {
" }4 l6 ~9 F6 C- b: ~        serial_reset_read_buffer();         //清除串口讀緩沖區3 t) n# ~" N) _+ ^3 c
        gc_init();                         //初始化G代碼功能函數  z! E" o' E$ ~. K" B/ i0 }
        spindle_init();                        //主軸初始化2 E& Y& b- d( X  E6 D
        coolant_init();                        //冷卻液初始化
/ F. s) R( N% X- f/ \        limits_init();                         //極限開關初始化
, V; r3 r( R% j3 s        probe_init();                        //探測部件初始化! j$ a& o* W; @; `+ k1 }2 m8 N
        plan_reset();                         //清除塊緩沖區和規劃師變量
* k9 X$ `! G+ d4 w5 j        st_reset();                         //清除步進系統變量。
* Y9 h! v+ q- C) A1 A# Z' f0 K! y/ ]# z% }/ N2 t
6 F* p. c3 n; a6 D
        //下面兩行清除同步gcode和策劃師職位當前系統位置。
* h4 ~9 N  C4 |7 ^
        plan_sync_position();
  \; u' q( v2 z- N8 M1 D        gc_sync_position();
8 H+ w7 x5 {! q2 T5 _: B$ k# M% _. ^/ Y

3 d5 k6 h3 I: c        //復位系統變量: q$ Z2 j) A7 l  w- W; ]3 e9 N
        sys.abort = false;                //系統中止標志6 ^6 d7 d9 y  |7 ?# i
        sys_rt_exec_state = 0;                //系統標志位變量狀態管理。看到EXEC位掩碼。
$ C4 v( p$ d$ F* ?        sys_rt_exec_alarm = 0;                //系統標志位變量設置不同的警報。9 @  I( m. l, ^# S
        sys.suspend = false;                //系統暫停標志位變量管理,取消,和安全保護。
5 |6 l8 L% W: Y, o; V* f        sys.soft_limit = false;                //限位開關限制狀態機錯誤。(布爾)
! T% D' \3 t! _: u
3 q  A, g) `8 c: m. j2 r( ?; s* K  ]5 a) O# d* z) ?! \
        protocol_main_loop();                //主協議循環
: P$ p& v3 K5 d$ ?* G# w% g; N}        //4 e9 P& h3 n8 ~) C9 y9 w# b- Z8 X
_____________________________________________________________________________________________________________________________
& X; h' V4 y! J) f進入void protocol_main_loop()函數
+ a! G$ j! v+ j2 X  O0 E{5 c- W/ z! |( J5 x- N
        report_init_message();                // 打印歡迎信息 9 \+ D6 T- [' m2 J
        //重啟后檢驗和報告報警狀態如果錯誤重啟初始化。' y  o0 J8 t3 z; S
        if (sys.state == STATE_ALARM) {0 z" y( `! Z% M; e2 m
            report_feedback_message(MESSAGE_ALARM_LOCK); //打印信息5 d0 W) F" t1 _& ~
          } else {& a2 ?' A7 @! C! m7 x
            // 如果沒有報警說明一切正常!但還是要檢查安全門. 2 K' A" C+ f6 i4 r
            if (system_check_safety_door_ajar()) {
/ C+ F  m' W  M. W$ h( W                     bit_true(sys_rt_exec_state, EXEC_SAFETY_DOOR);+ }! P5 H6 O; N2 P4 W" \, A
                     protocol_execute_realtime(); // 進入安全模式。應該返回空閑狀態。' H% K$ |# x% b; z# }) c
            }         else {2 y  e8 o% O7 G# j
              sys.state = STATE_IDLE; // .設置系統做好準備。清除所有國家國旗。
# p' y( w0 `/ l! u            } " ]  M- ^/ z( n
            system_execute_startup(line);    //開始執行系統腳本
# e0 Q5 N! a' K, t, U  H! r6 I' N  } % u/ M( k) J8 {; x8 L. t9 v
- p# m; ?5 a- i) |8 A

4 v  ~1 H1 d0 h" `$ L( O. o  v  // 這是主循環!在系統中止時這是出口回到主函數來重置系統。
1 t' A0 L/ H& g# D. C- d  // ---------------------------------------------------------------------------------  & e7 O. ^; w8 k0 ]7 l; z
  5 V$ _4 f. I8 X; J- f8 v
        uint8_t comment = COMMENT_NONE;3 r( O6 [1 K" p
        uint8_t char_counter = 0;
. \6 A) o& z! W9 a' A; k. n( ]+ K        uint8_t c;! B2 H: Q* D% Z* M: y; `/ ]
_______________________________________________________________________________________________________________________________, k0 L/ J. \! b% x- N
接下來進入for(;;)循環                //下面代碼是G代碼解析核心部分,程序中comment(注釋)變量會被賦不同值,代表發符號有‘(’‘)’‘;’
$ M+ U. B5 @5 G% O6 M{' N$ o" c: l9 C) C: q% p3 |8 ?$ A
//串行數據輸入一行的的過程,作為數據。執行一個
9 F% l1 g4 F, K//所有數據初始過濾去除空格和注釋。
- j5 M/ q$ X, E4 R//注意:注釋,空格和程序段刪除(如果支持的話)處理技術
  q& Y1 }8 i5 T, t//在G代碼解析器,它有助于壓縮到Grbl傳入的數據% W- |8 D  ]5 g' r
//線緩沖區,這是有限的。刀位點標準實際上州一行不行
" d/ b* U9 |% S9 G3 v# h3 q//不能超過256個字符,Arduino Uno沒有更多內存空間。/ f- s; U7 D: H4 v
//有更好的處理器,它會很容易把這個初步解析的
+ j$ [0 [( S; `//分離任務共享的刀位點解析器和Grbl系統命令。                                                                $ x1 b( x8 q! Z* ]+ h
    while((c = serial_read()) != SERIAL_NO_DATA) {                             //讀取串口數據,有數據執行下面代碼! N  c5 D+ q: O5 H3 R& [2 i+ g$ N
      if ((c == '\n') || (c == '\r')) { // End of line reached                //如果數據是/r,/n代表一行結束1 i3 I7 y5 S; c, {# _+ c
        line[char_counter] = 0; // Set string termination character.        //設置結束標志% `+ @; D/ @# L7 h- a& B" ~
        protocol_execute_line(line); // Line is complete. Execute it!        //一行完成執行此函數5 g! P5 i3 Q0 _  f
        comment = COMMENT_NONE;                                                //注釋清零
  C& T2 g( s/ h- J; L8 H6 ]: f5 v2 }" W        char_counter = 0;                                                    //字符計數清零
8 m# Y4 q3 a6 B& ~  8 W+ L( `2 n5 W9 l, N" W
        else {
5 S; R( q% X/ b% H+ ?/ ^        if (comment != COMMENT_NONE) {3 ~' H! J9 @. R$ z2 M
                                                     //扔掉所有注釋字符  t& E4 I, c* c8 v/ [' K& j1 e
          if (c == ')') {( b4 ^- ]( E+ y; }
            //最后注釋。重新開始。但是如果有分號類型的注釋。  C) ~- o$ U2 A$ u$ |8 s9 C5 o& }
            if (comment == COMMENT_TYPE_PARENTHESES) { comment = COMMENT_NONE; }
( b  y" o8 h6 A          }% u1 h# ]' ?8 d' K* q! E2 B$ }
      } else {4 C) y1 X! f+ T% F8 L7 N1 `
          if (c <= ' ') {
, J8 Q2 [% C, [; M            //扔掉whitepace和控制字符
  L% x1 L& U2 t          } else if (c == '/') {
$ \: Q& i9 `4 `" ~            //塊刪除不支持將忽略字符。
( X- x8 n, X) d3 b( r/ E: b            //注意:如果支持,只需要檢查系統是否啟用了塊刪除。: i* x8 c9 K( I8 R' v# u* B
          } else if (c == '(') {* t( ], ]. d; f+ S5 ?1 V
            // Enable comments flag and ignore all characters until ')' or EOL.
9 q$ d9 M  z+ _+ }! G            // NOTE: This doesn't follow the NIST definition exactly, but is good enough for now.( N: h4 o) U- o, B" s9 T  A3 e, q
            // In the future, we could simply remove the items within the comments, but retain the* U* I) U1 [+ L$ Y& A8 e' E
            // comment control characters, so that the g-code parser can error-check it.
3 O- j3 a; N) \7 L; L            comment = COMMENT_TYPE_PARENTHESES;: r( m( r( J. |0 `# k8 L
          } else if (c == ';') {
; ^" e8 r* B6 }& G6 w9 i3 k( ]            //注意:','注釋EOL LinuxCNC定義。沒有國家標準。0 ?1 {7 T- |) y8 i7 o5 a
            comment = COMMENT_TYPE_SEMICOLON;: g- N- S, d& B) @* H& x3 H

* m8 N4 U. v+ w8 ^6 f! \6 V" b) A8 u5 d  Y+ `4 i! D
_____________________________________________________________________________________________________________________________________
& A0 P( @& r' o, h          } else if (char_counter >= (LINE_BUFFER_SIZE-1)) {                        //串口接收數據大于80字符時
# Z2 _9 l7 d. D! n. f            // Detect line buffer overflow. Report error and reset line buffer.        檢測緩沖區溢出。報告錯誤和復位線緩沖區。4 q( z1 _6 @. Y
            report_status_message(STATUS_OVERFLOW);                                //打印溢出信息1 M5 z  O, Q: F( h0 G4 g
            comment = COMMENT_NONE;
1 e. |$ u2 I  u* c' N4 J            char_counter = 0;
# N; h  c* f0 H          } else if (c >= 'a' && c <= 'z') { // Upcase lowercase                        //小寫改大寫
% B% {+ p; {# L% k3 k+ p            line[char_counter++] = c-'a'+'A';
; J  N9 I- [- X          } else {! q# P2 X' y* z, Z
            line[char_counter++] = c;  y  t+ q  X9 t, M3 b# v& w
          }- j0 c8 q  H$ i0 j+ O; w
        }) L  u* Y% q' i! z6 V* X
      }
* O0 k4 @" ]: z+ d5 y2 X5 j6 `. M    }
& }, v4 y6 D& @/ h' D____________________________________________________________________________________________________________________________________" i; L4 d3 a; Z% q0 a. G
        //如果沒有其他字符在串行處理讀取緩沖區和執行,這表明以完成,自動啟動,如果啟用,任何隊列動作。- ~$ B' p# H* E& t. T
        protocol_auto_cycle_start();                //自動開始協議循環
8 {% }/ u9 @( a% j- G4 M) T6 H" {        0 O# R* x3 p* E3 [/ u
            protocol_execute_realtime();                  //運行實時命令。" u, N( r" J0 U  G
            if (sys.abort) { return; }                 //中止標識置位程序循環重置系統。            - G- {5 ~5 U! n+ u* S; s+ ~! q5 [0 E
  }
6 N- F4 x5 g1 m+ e% [1 h) F4 h  return;                         //一般程序不會執行到這里
4 v: v- N4 o" v. D' L& _}" g. L' W9 s8 e' {. n8 c% ?2 v/ y# O; _. N
____________________________________________________________________________________________________________________________________! D) X8 e( ~9 R- E
正常情況下,讀取完G代碼程序會進入protocol_auto_cycle_start();//自動開始協議循環 函數下面介紹此函數8 ^. f' t' n  s* z
// Auto-cycle start has two purposes: 1. Resumes a plan_synchronize() call from a function that, x4 ]+ M' }- s. j  w
// requires the planner buffer to empty (spindle enable, dwell, etc.) 2. As a user setting that
- O$ k6 y% Z4 y3 n// automatically begins the cycle when a user enters a valid motion command manually. This is
5 b% R( S- d8 s9 @8 o// intended as a beginners feature to help new users to understand g-code. It can be disabled
& i: C! S' y. n" n. j// as a beginner tool, but (1.) still operates. If disabled, the operation of cycle start is
- }2 x* L6 o% X, w4 q) Q) u% ]! i// manually issuing a cycle start command whenever the user is ready and there is a valid motion
" W* r. I- D9 p/ L6 V// command in the planner queue.
: c- O  A! B/ x) g// NOTE: This function is called from the main loop, buffer sync, and mc_line() only and executes ) E5 S  W# U" j
// when one of these conditions exist respectively: There are no more blocks sent (i.e. streaming ) c  m' u  q7 `' Y1 v
// is finished, single commands), a command that needs to wait for the motions in the buffer to 0 p6 c8 h" f$ I% Z6 c
// execute calls a buffer sync, or the planner buffer is full and ready to go.
* g6 U) p0 R; T" o$ L) W//自動開始有兩個目的:1。回復一個plan_synchronize()調用的函數; `7 _+ P+ j( P8 u
//需要規劃師緩沖區空(主軸啟用、住等)2。作為一個用戶設置
, x7 A+ u+ T& o7 _0 c  }% d' h  d% j) Y' [//自動循環開始當一個用戶輸入一個有效的運動命令手動。這是
6 [( c! G7 c( k//作為一個初學者的特性來幫助新用戶了解刀位點。它可以被禁用
) D* f) K9 B& K//作為一個初學者工具,但(1)仍然運作。如果禁用,運行周期開始; a5 M* R& c/ L  D2 b
//手動發出一個周期開始命令每當用戶準備好,有一個有效的運動
0 g0 [+ B( E# K( t" h$ W//命令的規劃師隊列。+ D& J: b+ K6 r! G
//注意:這個函數被稱為從主循環緩沖區同步,mc_line只()并執行
( T& k1 I9 {' ]+ n4 J9 j9 v0 U//當其中一個條件分別存在:沒有更多的塊(即流發送- X9 S7 k' g4 E- o  S/ f9 B/ g# o
//完成后,單一的命令),一個命令,需要等待緩沖的動作
0 f; s/ Q( X4 |//執行調用一個緩沖區同步,或規劃師緩沖區滿了,準備好了。  i- i0 r! z7 E3 w! k2 y" P
void protocol_auto_cycle_start() { bit_true_atomic(sys_rt_exec_state, EXEC_CYCLE_START); } $ K5 c9 X; W( M2 l
_______________________________________________________________________________________________
, N& q7 G+ R) _, _: z1 y5 }8 \接下來程序運行protocol_execute_realtime(); /運行實時命令。" r5 `+ E) ^( o7 w2 k
// Executes run-time commands, when required. This is called from various check points in the main
! t0 N8 S$ J5 o- U* Z// program, primarily where there may be a while loop waiting for a buffer to clear space or any
* Z# M0 `' \7 S3 l# O// point where the execution time from the last check point may be more than a fraction of a second.
& N8 Z( u5 S% \; `// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code! q, b- S( j  m2 p
// parsing and planning functions. This function also serves as an interface for the interrupts to ; t0 A4 e$ J6 V( o# `
// set the system realtime flags, where only the main program handles them, removing the need to
5 p+ T+ e6 ?( Z9 N5 g) A// define more computationally-expensive volatile variables. This also provides a controlled way to
2 B- k. _9 }' B// execute certain tasks without having two or more instances of the same task, such as the planner( g% ^5 ]0 J. A0 }
// recalculating the buffer upon a feedhold or override.
' B( S5 C( B) r! Y6 u' G// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,
5 c0 o7 o/ E/ t+ a2 D// limit switches, or the main program.: I9 U/ t& D7 ~7 I9 b4 V- i
void protocol_execute_realtime()- N8 y* C: [9 _
uint8_t rt_exec; // Temp variable to avoid calling volatile multiple times.臨時變量來避免多次調用不穩定。# n7 a; m% `5 v
就先分享到這吧!
+ P8 H$ G1 b. M2 s% k( u3 z' Z$ s) J) Y- a2 ]  b( v/ G  `
& E$ `* a$ b0 y3 u

7 W% n* g8 D( S( }9 S+ N* `
, B! C& X6 R4 B/ ~# F* N5 _: Y$ f# w0 q9 S

0 `. T& T7 K, H% u* {: z+ q/ ], p9 e2 p' \3 w! z) {
! w* U. I  C- ~; m6 o# u7 a! o1 l* q
# U) u% K- V! t5 W5 U4 b

: R  X; `9 I3 j5 E, e+ Q: \( w; @0 Y! y: D9 _5 g

. L; x; z8 _1 K+ g( ?( p: ?! T2 m
/ J" Y( w  n4 p5 S$ x* b- V8 v/ C  |: B  N( L- v- C, M

+ d- @8 f" I& H0 I: }* d
% v4 z7 b; d  v% K+ |
5 N1 j& j" z+ i6 o
9 H# l* y" o2 o3 V; b( e2 N; ^7 l& C: _- v" v
# _; n: X. ^9 S  ^
: O" i! o0 G, X4 O1 q

  u# I5 a7 B: X3 i: q4 G) Y6 ?9 ~
# F( \/ l+ e5 o; j補充內容 (2016-8-25 22:40):% O& t. o9 H4 u% H8 [
配置說明
* j& c' B8 }6 x' f/ p5 z- n6 H//這個文件包含編譯時配置Grbl的內部系統。在大多數情況下,
- B3 |( }! I) q! k//用戶不需要直接修改這些,但是他們在這里為特定的需求,即。1 L- o2 j* ?$ _/ V/ x
//性能調優或適應非典型的機器。
5 g" t5 @& n7 C9 q6 J3 s主要配置項:3 I: u/ S3 e5 _4 D6 _* H+ E  k
1.#define DEFAULTS_GENERIC        //在重置eepm時使用。在defaults.h改變想要的名字* O/ B6 b9 {3 L2 c- A% c4 ^
2.#define BAUD_RATE 115200        //配置串口波特率115200$ e0 t9 [5 {; |
3.#define CPU_MAP_ATMEGA328P         // Arduino Uno CPU
3 _, v" k: [  p% v' r9 B$ s5 \/ U; v4.#define CMD_STATUS_REPORT '?'        //定義實時命令特殊字符, c, P" V" `* M. q4 Q
5.#define HOMING_INIT_LOCK         //回原點保護鎖
" P( x! M) p: {& r6.#define HOMING_CYCLE_0 (1<<Z_AXIS)              // 第一步Z清除工作區。
! M+ n/ x3 h* D8 Z  #define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // 然后X,Y在同一時間。
' q  f( {7 g9 ~, W: ^* Y5 L5 x7.#define N_HOMING_LOCATE_CYCLE 1 //回原點循環次數2 y, b6 ?4 I6 R' s
8.#define HOMING_FORCE_SET_ORIGIN //取消這定義迫使Grbl總是在這時候位置設置機器原點盡管開關方向。$ `1 }$ _8 y" [# K  C
9.#define N_STARTUP_LINE 2 //塊Grbl啟動時執行的數量。' D! f4 S% I1 a& Q8 s8 ^8 ~
10.#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 協調或位置價值英寸
; P- ]+ f. k! {  g# `   #define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 協調在毫米或位置價值& ]/ m8 q" ~' ~; I
   #define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分鐘的速度值* K! l% V, j: ]
   #define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分鐘
, O! S3 Z+ g' T- R   #define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 對浮點小數設置值
- q8 m, q, x1 V0 J' n. h7 ~11.#define LIMITS_TWO_SWITCHES_ON_AXES //如果你的機器有兩個極限開關連接在平行于一個軸,您需要啟用這個特性
' g2 }5 c- n  }8 x$ [+ q  U12.#define USE_LINE_NUMBERS         //允許GRBL跟蹤和報告gcode行號
8 u. _. p' r! m5 T7 h5 x13.#define REPORT_REALTIME_RATE //允許GRBL報告實時進給速率
/ n; y$ Q6 j1 ~14.#define MESSAGE_PROBE_COORDINATES  //坐標通過Grbl $ #的打印參數?  j# q4 i2 `8 ]) o8 g/ i1 b
15.#define SAFETY_DOOR_SPINDLE_DELAY 4000 //安全門主軸延時6 d4 l+ C0 ]5 E& ?
16.#define SAFETY_DOOR_COOLANT_DELAY 1000 //安全門冷卻液延時8 j8 |7 P' u7 S1 r2 E
17.#define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS) //啟用CoreXY運動學。" M/ V$ ^" o8 E% V
18.#define COREXY // Default disabled. Uncomment to enable.改變X和Y軸的運動原理
; V, K% b' c7 N% s# ^( f19.#define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.反轉針銷邏輯的控制命令
" [* p/ D1 A/ Q- Y# g( D. S, E3 F20.#define INVERT_SPINDLE_ENABLE_PIN // 反轉主軸使銷從low-disabled) T2 N1 D! Q& y4 @
21.#define REPORT_CONTROL_PIN_STATE //啟用控制銷狀態反饋狀態報告。1 Y, A9 T7 j$ F1 z" v
22.#define FORCE_INITIALIZATION_ALARM //啟用和用戶安裝限位開關,Grbl將啟動報警狀態指示7 k! J+ ?+ }7 f* w3 f
23.#define REPORT_GUI_MODE // gui允許最小的報告反饋模式
$ @+ \# ]" c% T0 U! f# g4 x24.#define ACCELERATION_TICKS_PER_SECOND 100 //加速度的時間分辨率管理子系統。
  _. S! o. U/ @! g# W25.#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING //自適應多軸步平滑(積累)是一種先進的功能
" U4 a1 I( ]' M- S; ?; ?9 o26.#define MAX_STEP_RATE_HZ 30000 //設置最大一步速率可以寫成Grbl設置
8 A. j' N9 H0 \* j0 [27.#define DISABLE_LIMIT_PIN_PULL_UP //以下選項禁用內部上拉電阻
9 F# q1 u3 }" h1 q5 P7 G+ Y28.#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS //設置哪個軸長度補償應用的工具。假設軸總是與選擇軸工具面向負方向0 G7 F/ [5 w1 ?4 U7 O
29.#define VARIABLE_SPINDLE //允許變量軸輸出電壓不同的轉速值。
5 t$ o8 l. j2 k+ z$ ~30.#define SPINDLE_MAX_RPM 1000.0  // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.
1 F/ Z( W; h) _   #define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.# o* {2 ?2 ]2 }, ^% v3 F' y( m4 I
31.#define MINIMUM_SPINDLE_PWM 5 //使用的變量軸輸出。這迫使PWM輸出最小占空比時啟用。0 Y+ X6 S8 n4 j2 g- m
32.#define USE_SPINDLE_DIR_AS_ENABLE_PIN //主軸方向使能M4被刪除
; H) f- d; ]0 b/ _. Q4 \33.#define REPORT_ECHO_LINE_RECEIVED //應該對所有正常線路送到Grbl- j+ i/ D9 _% d
34.#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min) //最小規劃師結速度。設置默認最小連接速度規劃計劃
! T' X9 N% ]) L1 X" y) q/ N9 E3 B6 m; _9 }) M35.#define MINIMUM_FEED_RATE 1.0 // (mm/min)//設置計劃將允許的最小進給速率
  J' B8 D3 ?2 T7 b3 R, p36.#define N_ARC_CORRECTION 12 //弧生成迭代次數之前小角度近似精確的弧線軌跡8 N7 c; n' [. m" `* b
37.#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)//定義值設置機器ε截止來確定電弧是一個原點了?
9 q9 a2 N/ X* ^38.#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds) //延時增加表現在住。默認值設置為50毫秒
5 ]& G. n  I" o# r7 c39.#define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.; w9 e+ N0 a  g, U# e
40.#define BLOCK_BUFFER_SIZE 18  //線性運動規劃師緩沖區的數量在任何給出時間計劃
2 n, R- ]3 o; r8 B  V41.#define SEGMENT_BUFFER_SIZE 6 //控制之間的中間段緩沖大小的步驟執行算法) ^' V( n3 h, m7 v# w
42.#define LINE_BUFFER_SIZE 80 //行執行串行輸入流的緩沖區大小。
& V3 D. t9 M: G4 [9 S+ n43.define RX_BUFFER_SIZE 128 //串行發送和接收緩沖區大小; ]( `6 V/ T5 n% Y8 s1 w- C! k- B
44.#define TX_BUFFER_SIZE 648 b& B, M- q  I- z, I
45.#define ENABLE_XONXOFF        ////切換為串行通信發送流軟件流控制。
1 F- G' {: c5 H3 F8 _46.#define ENABLE_SOFTWARE_DEBOUNCE //一個簡單的軟件消除抖動特性硬限位開關。! c# E& b, f2 G. m6 t' T
47.#define HARD_LIMIT_FORCE_STATE_CHECK        //Grbl檢查硬限位開關的狀態/ K1 W5 A% ^, _- A+ y5 b( z! C
48.// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:編譯時錯誤檢查的定義值:% C& ~2 V8 `1 p+ ?- p6 k5 f
$ s- L- U( z# R7 f' H
___________________________________________________________________________________________________
* Z2 e% O& p) v* J/ s/*
' K. h5 A, C; ~, K; q  config.h - compile time configuration
# y# N0 f4 _- q$ E  Part of Grbl4 J9 c2 D" M8 o7 O9 h
9 W- J  U, L" }
  Copyright (c) 2012-2015 Sungeun K. Jeon$ ]  x) c( c3 ^) A
  Copyright (c) 2009-2011 Simen Svale Skogsrud/ |( h! g3 }0 w. V

7 L9 Q" W7 @6 `' M( T7 c  Grbl is free software: you can redistribute it and/or modify
3 b& }5 Y2 k! h( r  it under the terms of the GNU General Public License as published by* G; h- E& u" O# W# ?
  the Free Software Foundation, either version 3 of the License, or
: K6 H2 b1 o& n: V% _* u/ g  (at your option) any later version.
! ~$ q, a7 L  u/ g& J- C0 p. S+ O9 t4 n' D; _7 g5 ~$ Q, k
  Grbl is distributed in the hope that it will be useful,
& s  g- w5 v  N6 k, _  but WITHOUT ANY WARRANTY; without even the implied warranty of
" v5 R: {9 q  Y5 u  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the, i' P. k" E, `6 p) ?- s" f
  GNU General Public License for more details.9 I, m0 Q5 g  T3 S% E' U

. k" B9 M$ I" k) Y# Q) g5 b7 i  You should have received a copy of the GNU General Public License
4 s1 ^, g$ ?( e  M" M7 J- g  along with Grbl.  If not, see <http://www.gnu.org/licenses/>.
5 T9 f) o- `- P/ J# y+ x8 rconfig.h  -編譯時配置,Grbl的一部分, L6 k$ j4 G8 W6 V9 ^: A3 X

5 N4 A" q+ D' Q版權(c)2012 - 2015 Sungeun K. Jeon( K& a+ t2 m4 [7 I6 F! `
版權(c)2009 - 2011 Simen Svale Skogsrud
! _" Y0 f% w, F6 Q4 |. s
! J8 T5 F+ y1 }. J5 ?- x0 VGrbl是免費軟件:可以重新分配和/或修改
8 J) f7 u# q/ q* ~- jGNU通用公共許可證的條款下發布的自由軟件基金會,版本3的許可,或(任您選)其后的版本。
$ d* }  T0 n) a9 ?/ n* @% L: M0 p+ n8 T, ~( c
Grbl分布,希望這將是有用的,但是沒有任何保證;沒有即使的默示保證適銷性或健身為特定目的。看到7 j- e4 o/ a- z$ A) E8 |' R% s3 c" g
GNU通用公共許可證的更多細節。
# w7 U0 V. \6 G+ A6 i
; S$ ]/ T2 U$ L; W, U你應該收到了GNU通用公共許可證的副本
' x3 R* {5 s2 u; P& Y# i$ H0 U連同Grbl。如果沒有,看< http://www.gnu.org/licenses/ >。( e& e6 e: R# b8 q: K
8 z# n, ?* Y. t7 _
*/9 W$ R: @& u: t/ J1 B
  
, u4 [4 R1 [5 v% o, ?// This file contains compile-time configurations for Grbl's internal system. For the most part,+ d' j+ n  p& ^0 l
// users will not need to directly modify these, but they are here for specific needs, i.e.
! u. C+ O1 G: E- C, h! N# \// performance tuning or adjusting to non-typical machines.
5 }! D2 ]% y. H9 Y//這個文件包含編譯時配置Grbl的內部系統。在大多數情況下,
6 i9 v% y3 @5 u3 Z//用戶不需要直接修改這些,但是他們在這里為特定的需求,即。
4 m( I; |% L# l* K# x' g//性能調優或適應非典型的機器。
6 d1 [) ^7 U$ N) s, W9 x& l0 L  L* G. C, ~7 t  d5 x
// IMPORTANT: Any changes here requires a full re-compiling of the source code to propagate them.4 K' N$ w) U1 D" G
//重要:任何變化需要一個完整的基于源代碼的傳播。0 ~/ ~; |: {8 O# r: T# L8 i  {

: c) Y9 ]4 t6 O: b5 J#ifndef config_h7 E  B2 L( p6 P! M! E/ x
#define config_h
' \& x! s: s! S7 `" F#include "grbl.h" // For Arduino IDE compatibility.
. W% }/ ?  {+ b( Z& W* p; b' B& D; h: b6 A
// Default settings. Used when resetting EEPROM. Change to desired name in defaults.h
, ?  F, k! Y% S& T1 Y// 默認設置。在重置eepm時使用。在defaults.h改變想要的名字0 \3 z" v+ t# ^
0 _4 a* p  b  L5 {( E) d5 f
#define DEFAULTS_GENERIC* F* }9 M& K, v& F" j: _

9 y1 C1 h& Y5 L, K* ]0 _9 l// Serial baud rate
1 s# D+ r3 k% |/ x) f. D) c: [#define BAUD_RATE 115200                //配置串口波特率1152004 W8 v2 X/ L/ a+ l
3 b  C* x" A* p9 q; V; C/ K
// Default cpu mappings. Grbl officially supports the Arduino Uno only. Other processor types
  t& I6 @: R3 a- V3 [" S// may exist from user-supplied templates or directly user-defined in cpu_map.h  c( o7 @+ n8 ?1 m; E* R7 ]
//默認cpu映射。Grbl正式支持Arduino Uno。其他類型的處理器可能存在cpu_map.h直接從用戶提供的模板或用戶定義的
  j# |) ]5 Q! v5 i, `. O# M5 w) W& T- I
% U$ y- J# k$ o8 |#define CPU_MAP_ATMEGA328P // Arduino Uno CPU
% S6 {2 A* F+ n; ?# H6 |5 E
  S7 e3 Y4 v1 c5 `6 s2 i0 w// Define realtime command special characters. These characters are 'picked-off' directly from the. v2 L( T6 h( n6 w
// serial read data stream and are not passed to the grbl line execution parser. Select characters, U7 W8 Y  V2 C; ]* c
// that do not and must not exist in the streamed g-code program. ASCII control characters may be
: w$ X+ p$ {- {* Y& q% V5 i3 Q# J// used, if they are available per user setup. Also, extended ASCII codes (>127), which are never in ' u/ a% M9 O) c, p. S) e
// g-code programs, maybe selected for interface programs.
" ^' g( R) x: m1 g4 f( z- Y// NOTE: If changed, manually update help message in report.c.
1 Q* c" {  M6 L1 ]: ~& N9 m$ r& q$ [# }8 u% q6 X+ k
//定義實時命令特殊字符。這些字符是直接從“各個擊破”串口讀取數據流并沒有傳遞到grbl行執行解析器。選擇角色9 e0 G0 _8 s+ S3 X) q( O
//不,不能存在于程序流刀位點。ASCII控制字符- ~# U1 R: a5 [4 u% Z
//使用,如果他們是可用的每個用戶設置。同時,擴展的ASCII碼(> 127),從來沒有
! o( [' _" R/ j" K8 C% {2 E//刀位點的程序,也許選擇界面程序。" J8 V  J4 k+ Z- b! S/ r
//注意:如果改變,手動更新report.c幫助信息。
" W" z. k: J. [3 _+ V: h
" d/ H8 m  J6 f+ }" L# U: N( ]#define CMD_STATUS_REPORT '?'1 r! [% w8 F0 n# b$ {
#define CMD_FEED_HOLD '!'
9 [: R/ G6 T$ D6 _+ p) F/ F#define CMD_CYCLE_START '~'. s5 a1 |* d$ D; h0 }
#define CMD_RESET 0x18 // ctrl-x.+ g; A; f. Q% Y. l! C2 P& H9 M
#define CMD_SAFETY_DOOR '@'
3 T8 K! ]/ |0 O" b- [2 C
( e+ e9 }5 l! e0 s% e0 y2 U$ t// If homing is enabled, homing init lock sets Grbl into an alarm state upon power up. This forces1 ]' j' s) d  Z; W3 L% d( Q
// the user to perform the homing cycle (or override the locks) before doing anything else. This is$ M( I; v- Y  Q0 Q) H  ~
// mainly a safety feature to remind the user to home, since position is unknown to Grbl.
  A3 A8 f6 o( w" N6 r. c
! X! S. ?0 g, E, ^& A' ?//如果啟用了回原點,導航初始化鎖集Grbl進入警報狀態啟動。這就迫使$ {: x9 p+ [6 N2 ?9 o+ g
//用戶執行歸航周期(或覆蓋鎖)在做任何其他事情之前。這是
: U' k/ I+ I5 g! Z//主要安全功能,提醒用戶家里,因為Grbl位置是未知的。" a/ `! p& o5 ~; J& X5 U7 s7 {" q
5 _* W2 ~2 L9 Z7 p2 m
#define HOMING_INIT_LOCK // Comment to disable% \* d9 }, ?) y" }* T
5 c" V8 g3 |& r8 f
// Define the homing cycle patterns with bitmasks. The homing cycle first performs a search mode
  Y/ O$ o% V: ~4 k* h// to quickly engage the limit switches, followed by a slower locate mode, and finished by a short- t# ?" A( x/ Q
// pull-off motion to disengage the limit switches. The following HOMING_CYCLE_x defines are executed 4 J) z+ I* C  E- P# c
// in order starting with suffix 0 and completes the homing routine for the specified-axes only. If' b4 j( n7 a! |( F( z
// an axis is omitted from the defines, it will not home, nor will the system update its position.- s6 C! v' F( f5 j6 x
// Meaning that this allows for users with non-standard cartesian machines, such as a lathe (x then z,/ M% K7 E5 `) k
// with no y), to configure the homing cycle behavior to their needs. / h( q4 G  Z+ L5 Q9 I
// NOTE: The homing cycle is designed to allow sharing of limit pins, if the axes are not in the same0 y9 i. C" Q# `1 D
// cycle, but this requires some pin settings changes in cpu_map.h file. For example, the default homing
3 g# E5 P( W3 U$ v: G// cycle can share the Z limit pin with either X or Y limit pins, since they are on different cycles.
5 q5 T0 d' T& p/ M- x! a// By sharing a pin, this frees up a precious IO pin for other purposes. In theory, all axes limit pins* ^* h# D' L1 y) h
// may be reduced to one pin, if all axes are homed with seperate cycles, or vice versa, all three axes
6 I* ]) \4 k! `// on separate pin, but homed in one cycle. Also, it should be noted that the function of hard limits . A! @% y% z, x
// will not be affected by pin sharing.! [! ^7 W. p7 P# e. k
//定義導航循環模式的位掩碼。歸航周期首先執行一個搜索模式' Y# {! z9 |1 _$ _0 @: S. y
//快速進行限位開關,其次是較慢的定位模式,完成了由一個短& ]0 _& ~) x4 G
//拖出運動脫離限位開關。以下HOMING_CYCLE_x定義執行
9 A+ n- I8 ~& I0 r  U//為了與后綴0開始并完成specified-axes只尋的例程。如果
5 j) J+ F% }9 U0 F//定義省略一個軸,它會不在家,也不會系統更新它的位置。. M6 f- g2 N9 ?# L" E: j
//意義,這允許用戶與非標準笛卡爾的機器,比如車床(x,z,
, G0 \/ d, Z8 s//沒有y),配置導航循環行為對他們的需求。
% X# [' _( ^7 Y) C4 P6 v//注意:歸航周期允許共享限制針,如果軸不相同
1 w: X* w9 l# o" i) N//循環,但這需要一些銷設置cpu_map的變化。h文件。例如,默認的導航
  c4 s! Y/ ~7 _4 C" W, c( u  }4 q/ W+ m//循環可以分享Z限位銷X或Y限制針,因為它們是在不同的周期。
/ D  L8 n# {) ~- B6 O. ^1 N5 W$ S//通過共享一個銷,這騰出寶貴的IO銷用于其他目的。從理論上講,所有軸限制別針
" O  q3 g! y6 {//可能會減少到一個銷,如果所有軸與分離周期居住的地方,反之亦然,所有三個軸
! h+ M% a. W' h6 W: K% l2 Q//在不同銷,但這時候一個周期。同時,應該注意的是,硬限制的功能. {- K$ [3 H! x- W
//將不會影響銷共享。9 M! u: y/ W4 z- v& l- L
//注意:默認設置為一個傳統的硬件數控機器。z軸首次明確,其次是X和Y。  u8 b2 |* d* [

$ ~9 c1 a9 B) A# n# r( @$ t// NOTE: Defaults are set for a traditional 3-axis CNC machine. Z-axis first to clear, followed by X & Y.
5 E  n7 E: E& V2 M" h$ a#define HOMING_CYCLE_0 (1<<Z_AXIS)                // REQUIRED: First move Z to clear workspace. 第一步Z清除工作區。4 j6 u3 W5 A, ]* a8 z
#define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // OPTIONAL: Then move X,Y at the same time.然后X,Y在同一時間。# a  F$ Q- R# F" N, @) o; p
// #define HOMING_CYCLE_2                         // OPTIONAL: Uncomment and add axes mask to enable
; p5 ~( |3 V" m
* u0 c) l  o& E+ Y// Number of homing cycles performed after when the machine initially jogs to limit switches.8 ?+ p7 e0 o0 T3 Q
// This help in preventing overshoot and should improve repeatability. This value should be one or   C% h2 C) j: L; P+ u- Y5 T
// greater.
5 G' @% i+ k7 ?( |- L% c//執行回原點循環次數后,當機器最初慢跑限位開關。這個幫助防止過度,應該提高重復性。這個值應該是一個或大。$ v  B& ]$ X, d
5 p% |( L: Z# A3 X1 {- i5 \
#define N_HOMING_LOCATE_CYCLE 1 // Integer (1-128)4 Q/ k* k: J* k; i" z, z

% d2 f* a1 o% Z% {// After homing, Grbl will set by default the entire machine space into negative space, as is typical
' j1 V; ^( Z1 ^2 y) D// for professional CNC machines, regardless of where the limit switches are located. Uncomment this
" c9 y! r7 g- \/ r) N" f( [// define to force Grbl to always set the machine origin at the homed location despite switch orientation.+ m( e! Q2 w( ]& \+ O

: r- O2 d# q4 `+ y: {//導航后,默認Grbl將整個機器空間留白,是典型的專業數控機器,不管限位開關所在的地方。! i$ T9 Q. d" X$ g- ]* b
//取消這定義迫使Grbl總是在這時候位置設置機器原點盡管開關方向。4 u9 O# P, V, z5 R9 D

8 r; O) O; g$ C// #define HOMING_FORCE_SET_ORIGIN // Uncomment to enable.
6 j4 b+ }: i: {; ~) f  n' Z" v( w

. b# ?, O" R3 K, j5 l! f( v// Number of blocks Grbl executes upon startup. These blocks are stored in EEPROM, where the size- k) C( d4 c. i4 A% b
// and addresses are defined in settings.h. With the current settings, up to 2 startup blocks may/ V7 E$ Y9 j$ _. I5 O/ u1 k: s
// be stored and executed in order. These startup blocks would typically be used to set the g-code
1 s; _% v( V  X& D// parser state depending on user preferences.
% b7 V- e) L2 m7 o
# d$ @1 e) y2 V  u9 s$ S$ j; e//塊Grbl啟動時執行的數量。這些塊存儲在eepm,大小4 `7 P, K% ?0 i9 X6 E
//和地址在settings.h中定義。與當前設置,可能2啟動塊
# t4 j, i+ w4 C. X; t. I9 Z$ O//存儲和執行。這些啟動塊通常被用來設置刀位點$ K5 x# K) x6 y% e3 c: n/ v
//解析器的狀態取決于用戶首選項。
4 B/ e$ \% q& B  b% x4 j3 e/ P0 M; C1 r/ X+ c) C% K" X( I. t
#define N_STARTUP_LINE 2 // Integer (1-2)" l8 }# L! I. z2 r, p# O  G+ ^

& {  J4 v" ?7 |) }& n; g// Number of floating decimal points printed by Grbl for certain value types. These settings are 4 F2 t" ?# Y0 h) P1 u( _  t/ M
// determined by realistic and commonly observed values in CNC machines. For example, position- X4 {6 m( M2 z; q" U
// values cannot be less than 0.001mm or 0.0001in, because machines can not be physically more
* a3 n6 S* j  F5 L6 O& c// precise this. So, there is likely no need to change these, but you can if you need to here.
# ]0 a0 ^# ~$ W( s// NOTE: Must be an integer value from 0 to ~4. More than 4 may exhibit round-off errors.
# ]) n+ m& C8 G( Y4 ~. K
# K4 n* f5 l- [2 H! Y// Grbl浮動小數點的數字印刷的特定的值類型。這些設置是& A6 P/ E2 P. y2 M0 @4 ?
//一般由現實和觀測值在數控機器。例如,位置, \( i6 S% @$ w1 N, v! }
//值不能小于0.001毫米或0.0001,因為機器不能身體更多- R# }+ @1 E0 s1 g
//精確。因此,有可能不需要改變這些,但你可以在這里如果你需要。; j+ f( s  o) \& \
//注意:必須是一個整數值從0 ~ 4。超過4可能出現舍入錯誤。
9 C7 j; i9 Y6 _( j% ~- o' a4 s$ t5 x3 `3 A
#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 協調或位置價值英寸
9 W- }2 b8 G0 B#define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 協調在毫米或位置價值
' [2 O) V# N" S6 f7 N- V. J) U, j#define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分鐘的速度值
+ _! S# P" K0 s6 R  A# f2 r#define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分鐘
4 t2 s2 I' B  W+ |#define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 對浮點小數設置值
4 |% m, v/ D! N( h- Y  l
: E: q1 g" t/ e9 o// If your machine has two limits switches wired in parallel to one axis, you will need to enable
: j2 I5 g5 T1 _. ^* s8 J8 L// this feature. Since the two switches are sharing a single pin, there is no way for Grbl to tell0 {7 o. Z' t& A) ]) T8 Q6 J( g
// which one is enabled. This option only effects homing, where if a limit is engaged, Grbl will
6 R( M3 e: `# @8 Z- \1 G( b+ M// alarm out and force the user to manually disengage the limit switch. Otherwise, if you have one
1 N. K2 ?' B+ W+ |  ~! o  v// limit switch for each axis, don't enable this option. By keeping it disabled, you can perform a
" r( Q: s- U# w, }6 _* L// homing cycle while on the limit switch and not have to move the machine off of it.
5 t4 W; V2 u, |  D0 c) l. x# ]. B( o# _& q
//如果你的機器有兩個極限開關連接在平行于一個軸,您需要啟用
# U; q4 y4 }+ @! m7 s0 u//這個特性。自從兩個交換機共享一個銷,沒有辦法Grbl告訴
1 u  M% P: v& h; r//啟用哪一個。此選項僅影響歸航,如果限制,Grbl意志
. S' D* v9 N- g7 o//報警,迫使用戶手動松開限位開關。否則,如果你有一個0 P- T- h+ ^$ n+ X5 q6 W/ S9 F
//為每個軸限位開關,不啟用該選項。通過保持禁用,您可以執行1 e3 H* w! V) |. J3 G! Z* h, f
//導航循環在限位開關并沒有將這臺機器。9 k$ W& i! D( N6 k( C, E0 r# E

& L6 S7 s3 W6 _// #define LIMITS_TWO_SWITCHES_ON_AXES
" Q" u( N2 Z6 y$ P8 e: u! W* Q# k! L" C: y7 I3 p
// Allows GRBL to track and report gcode line numbers.  Enabling this means that the planning buffer% ~; R: q5 H" \0 a
// goes from 18 or 16 to make room for the additional line number data in the plan_block_t struct
/ R, I3 s" e% B6 r/ B, }5 k
% W$ E* @: t% v) i# t% K( q; N- E//允許GRBL跟蹤和報告gcode行號。使這意味著計劃緩沖從18歲或16歲,為額外的行號plan_block_t結構中的數據- y% N3 P) K! n3 c$ s/ z/ a

) _0 w  R# x' k: x1 v* F1 T" Y// #define USE_LINE_NUMBERS // Disabled by default. Uncomment to enable.
' ]/ T: _3 u+ Z  ]
, X# x2 `: [. I* Z// Allows GRBL to report the real-time feed rate.  Enabling this means that GRBL will be reporting more # b% w( }% E1 H& u+ J2 _
// data with each status update.% v/ s7 m7 N% Y
// NOTE: This is experimental and doesn't quite work 100%. Maybe fixed or refactored later.5 u, G3 j8 R8 S7 M) T6 i( @
//允許GRBL報告實時進給速率。使這意味著GRBL將報告數據和狀態更新。
" l& ~$ g! \0 F% I- R//注意:這是實驗和100%沒有工作。也許以后固定或重構。* l/ G4 v5 b( _3 p

) ?* W' H1 H3 ^# N0 j5 W9 v// #define REPORT_REALTIME_RATE // Disabled by default. Uncomment to enable.
' v* p( j/ G1 r+ f+ A/ t# }. N  T1 g! b% U0 O; n, F; n
// Upon a successful probe cycle, this option provides immediately feedback of the probe coordinates: h) l& m, K2 l$ O2 _
// through an automatically generated message. If disabled, users can still access the last probe
+ V! v6 M+ |0 l// coordinates through Grbl '$#' print parameters.# B- x/ i9 \& @1 J
//在一個成功的調查周期,這個選項提供立即反饋的探測器坐標+ [0 k/ K9 y" ~2 q) \
//通過一個自動生成的消息。如果禁用,用戶仍然能夠訪問調查
4 m7 M4 W) q3 u1 t, ?! C! E//坐標通過Grbl $ #的打印參數。3 O+ C, Z2 M% h0 a
6 f: `7 P$ G6 \8 J2 r
#define MESSAGE_PROBE_COORDINATES // Enabled by default. Comment to disable.
" K8 R) g7 y+ y: _! K) T+ m
4 |% x1 G( h( I0 R// Enables a second coolant control pin via the mist coolant g-code command M7 on the Arduino Uno5 A7 M7 C# n# \% f" \
// analog pin 5. Only use this option if you require a second coolant control pin.
7 n5 u2 y- ]' Y0 B9 [9 o8 B// NOTE: The M8 flood coolant control pin on analog pin 4 will still be functional regardless.
1 N1 \4 W) S* h- R// #define ENABLE_M7 // Disabled by default. Uncomment to enable.
: \$ r3 Z9 U3 y6 Y4 Q  z( X. T/ h! E- ]" e* Q+ K
// This option causes the feed hold input to act as a safety door switch. A safety door, when triggered,
: X; w! p7 S; M1 W0 @2 }/ ^// immediately forces a feed hold and then safely de-energizes the machine. Resuming is blocked until& s$ d! j4 k+ E
// the safety door is re-engaged. When it is, Grbl will re-energize the machine and then resume on the
3 |4 {2 W( F3 ^7 ?! R; U: t// previous tool path, as if nothing happened.8 Z8 k( z# F1 q
// #define ENABLE_SAFETY_DOOR_INPUT_PIN // Default disabled. Uncomment to enable.: U; o4 x5 M( f" j2 m

7 ]; P1 h$ r# f% M// After the safety door switch has been toggled and restored, this setting sets the power-up delay
; b8 X2 P: x$ ]) N% v2 ?// between restoring the spindle and coolant and resuming the cycle.
  V# ^0 q2 ]; \: y; l: \// NOTE: Delay value is defined in milliseconds from zero to 65,535. 3 M6 H+ Z& i$ \- R  f! L0 \
2 c, ?6 W, V8 t/ F1 Z& Z- ^9 ^8 c8 F
//定義導航循環模式的位掩碼。歸航周期首先執行一個搜索模式  b+ h' l3 C* q! }/ A, ]
//快速進行限位開關,其次是較慢的定位模式,完成了由一個短
& q* S8 o: V+ d- G  D//拖出運動脫離限位開關。以下HOMING_CYCLE_x定義執行
% \( _6 J( _: u+ ~+ E' k//為了與后綴0開始并完成specified-axes只尋的例程。如果, L. Z' w8 f3 Z! s7 S! L& I( c
//定義省略一個軸,它會不在家,也不會系統更新它的位置。# ^5 k3 n* z; e5 |7 |
//意義,這允許用戶與非標準笛卡爾的機器,比如車床(x,z,7 d+ U# P7 w3 C  }. v9 N* d2 b
//沒有y),配置導航循環行為對他們的需求。: r+ v' |  D$ z4 o' D. X
//注意:歸航周期允許共享限制針,如果軸不相同% H4 p, {9 |4 g3 S" d
//循環,但這需要一些銷設置cpu_map的變化。h文件。例如,默認的導航
- g( U$ ~# R$ G0 S2 T7 Z//循環可以分享Z限位銷X或Y限制針,因為它們是在不同的周期。
, s/ x% Z% y' U/ G. [: w//通過共享一個銷,這騰出寶貴的IO銷用于其他目的。從理論上講,所有軸限制別針+ Z& `$ R6 }7 C& @* N- Z9 k
//可能會減少到一個銷,如果所有軸與分離周期居住的地方,反之亦然,所有三個軸0 f0 l/ f4 j. k
//在不同銷,但這時候一個周期。同時,應該注意的是,硬限制的功能
* C* n. {5 O( C' R% G$ Z- ~+ c: \//將不會影響銷共享。! x' J3 T" `" ?% p! r6 N8 t
//注意:默認設置為一個傳統的硬件數控機器。z軸首次明確,其次是X和Y。4 L' H  {% m" ?% A1 S

# O: A) Y' h7 _- x" R( r; @
% k5 s2 @% t/ K3 c4 k; u& z# M/ w#define SAFETY_DOOR_SPINDLE_DELAY 4000% ?' _; Y  T+ P1 c  I! h) Z
#define SAFETY_DOOR_COOLANT_DELAY 10001 G* ]+ S" m- N  g. n% k+ Y7 y

. d  I- s: x8 g. j// Enable CoreXY kinematics. Use ONLY with CoreXY machines. 1 ~5 L6 B) u! {% a$ I
// IMPORTANT: If homing is enabled, you must reconfigure the homing cycle #defines above to ; B. ~' b  m5 I; o
//啟用CoreXY運動學。只使用與CoreXY機器。2 Z" j; r% ~1 |3 i0 ~. N( O
//重要:如果啟用了自動尋的,你必須重新配置導航循環#定義上面$ F: j4 j# p0 O

! U! ?! w, h$ J( D# {+ ]: V// #define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS)
5 n4 j& {, @- Q7 h4 y2 R/ P
- {; c" S+ V+ i) r* y) R// NOTE: This configuration option alters the motion of the X and Y axes to principle of operation
/ T# ~9 G% l% |3 a$ g0 i$ h// defined at (http://corexy.com/theory.html). Motors are assumed to positioned and wired exactly as. M/ I" e. O/ r
// described, if not, motions may move in strange directions. Grbl assumes the CoreXY A and B motors
6 M* `4 b! Q# _$ j  m8 f  K- W// have the same steps per mm internally.' B( d: D' L( t8 c) ?; z
//注意:這種配置選項改變X和Y軸的運動原理,操作. v& {4 j1 v! E8 k' v6 i. \, k; s
//定義(http://corexy.com/theory.html)。汽車被認為定位和連接一樣
6 Z0 e8 ~, k7 q: D//描述,如果沒有,運動可能會奇怪的方向移動。A和B Grbl假設CoreXY馬達
3 c, n/ Z! N1 z# m$ _& ]0 [! m//每毫米內部有相同的步驟。6 _& j$ h, z" P' l$ Z$ R
1 H9 K  N! o, E: R3 _, ~  G
// #define COREXY // Default disabled. Uncomment to enable.- P; l( ?1 M& [

& |. q* M- C$ n# N$ p// Inverts pin logic of the control command pins. This essentially means when this option is enabled
; L& ^, s; l4 Y4 U8 f* _# N// you can use normally-closed switches, rather than the default normally-open switches.
; b# p, O6 d+ c7 q0 h* W// NOTE: Will eventually be added to Grbl settings in v1.0.8 V' t. k( d( u6 L
//反轉針銷邏輯的控制命令。這實質上意味著當啟用這個選項: C( v+ f5 r" u
//可以使用閉合開關,而不是默認的常開開關。3 a* q4 ^- d9 E  T
//注意:最終將被添加到在v1.0 Grbl設置。
1 a) T8 G! ]$ y9 a+ G- S5 e$ @1 }( i$ f6 |! s. i( m. g6 `
// #define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.
& ]4 Q2 C, t/ _3 {7 I+ P0 t/ u' H9 v' u
// Inverts the spindle enable pin from low-disabled/high-enabled to low-enabled/high-disabled. Useful
! s$ s' J9 q% a! {/ I( f// for some pre-built electronic boards./ w+ K' j! k1 k. r
// NOTE: If VARIABLE_SPINDLE is enabled(default), this option has no effect as the PWM output and 2 s# X$ I( T; A/ P9 x3 r
// spindle enable are combined to one pin. If you need both this option and spindle speed PWM, 8 V" \# l9 j* T% i
// uncomment the config option USE_SPINDLE_DIR_AS_ENABLE_PIN below.
& s6 c) I. o! F5 i//反轉主軸使銷從low-disabled / high-enabled low-enabled / high-disabled。有用的9 C" K) W& a0 t4 {' C; ^
//預構建的電子板。8 q, z9 w- W) f" f. C
//注意:如果啟用了VARIABLE_SPINDLE(默認),這個選項作為PWM輸出并沒有影響
. o+ I5 e; I& ~: }. M( P& z7 b5 O//銷軸使結合。如果你需要這個選項和主軸轉速PWM,
' k# J/ J4 }+ g' F  W( |+ ?& o//取消注釋以下配置選項USE_SPINDLE_DIR_AS_ENABLE_PIN
6 U6 b/ Y3 d  {% g- u6 C% e/ m
// #define INVERT_SPINDLE_ENABLE_PIN // Default disabled. Uncomment to enable.
2 |: k7 Q+ q" l
8 p# K* H8 J) P* p// Enable control pin states feedback in status reports. The data is presented as simple binary of$ V8 E% u' i9 S4 z
// the control pin port (0 (low) or 1(high)), masked to show only the input pins. Non-control pins on the
& t0 L0 ^- ^- I( V! t6 |5 h9 W( h3 n; O// port will always show a 0 value. See cpu_map.h for the pin bitmap. As with the limit pin reporting,
  o1 m. `* a; Z- Y+ r* G// we do not recommend keeping this option enabled. Try to only use this for setting up a new CNC.
5 Z. S' T+ J5 H, t+ ]  d  c//啟用控制銷狀態反饋狀態報告。作為簡單的二進制數據
  b& A5 c, h: C; S. N; ^& I  I* M//控制針端口(0(低)或1(高)),蒙面,只顯示輸入插腳。非控制性針上
  |# L' Y* Z! e9 {//端口總是顯示0值。看到cpu_map。針位圖h。與限制銷報告,7 i% h# R& \" |8 Q8 |  N5 p
//我們不推薦保持啟用這個選項。盡量只使用這個設置一個新的數控。$ H) H9 p6 S4 T1 u
7 ^5 t/ Q- L! d' `( u, C" f
// #define REPORT_CONTROL_PIN_STATE // Default disabled. Uncomment to enable.! v/ q: x) n2 L

- f' q0 Z1 ?1 t2 V; p) c5 i  c// When Grbl powers-cycles or is hard reset with the Arduino reset button, Grbl boots up with no ALARM
% k# M8 d5 P* W( p# H// by default. This is to make it as simple as possible for new users to start using Grbl. When homing
4 ^  X$ u6 A* t8 T// is enabled and a user has installed limit switches, Grbl will boot up in an ALARM state to indicate
: f$ c, F: R; {0 C+ }// Grbl doesn't know its position and to force the user to home before proceeding. This option forces
0 Y$ ?, V/ {2 y5 p0 `/ p2 W% V// Grbl to always initialize into an ALARM state regardless of homing or not. This option is more for
7 I8 y7 N) A2 g, ^* ?// OEMs and LinuxCNC users that would like this power-cycle behavior.
( g  D" [" N  S4 T+ J1 w# d//當Grbl powers-cycles還是硬重置Arduino復位按鈕,Grbl啟動沒有報警
( H% ?- @" n+ @8 h  c* A//默認情況下。這是為了讓新用戶盡可能簡單使用Grbl開始。當歸航+ ?) t5 h6 I7 t+ x0 M7 e
//啟用和用戶安裝限位開關,Grbl將啟動報警狀態指示
& l: R* ^3 {' l. z9 I// Grbl不知道它的位置,迫使用戶在繼續之前回家。這個選項部隊7 T+ c0 o- t* P' w
// Grbl總是初始化進入警報狀態不管歸航。這個選項是更多" u& ^. o! J- D
//原始設備制造商和LinuxCNC用戶這樣的控制行為。: |( W+ a# G0 D0 w. w- c  v
: H1 D, p2 T7 f4 q6 Y/ W# w- R9 d6 }! Q
// #define FORCE_INITIALIZATION_ALARM // Default disabled. Uncomment to enable.* F6 s" o/ J3 ^; Q5 Q

& K2 o  I1 y" T6 y4 ^// ---------------------------------------------------------------------------------------
, y2 e+ M3 A+ u  U+ u// ADVANCED CONFIGURATION OPTIONS://高級配置選項:
, r5 Y" k. n. I) p
( C! ^( }/ Q# J* K% ?* s// Enables minimal reporting feedback mode for GUIs, where human-readable strings are not as important.
4 \& O5 {. X: Y! s// This saves nearly 2KB of flash space and may allow enough space to install other/future features.. y5 j/ d. B7 f& d8 P) Y' }  ~
// GUIs will need to install a look-up table for the error-codes that Grbl sends back in their place.
0 V: Q: L" c5 \9 I: P$ X( w# H( M// NOTE: This feature is new and experimental. Make sure the GUI you are using supports this mode.7 U, i& ^4 e( N- N, ]% ~$ \

9 V+ I* o7 T8 t4 c; {3 G3 }. O// gui允許最小的報告反饋模式,人類可讀的字符串在哪里不重要。
& q- q/ r4 e8 e5 d//這個節省近2 kb的閃存空間,允許足夠的空間來安裝其他/未來的功能。" \+ U! C# B3 V$ K% g9 ~
// gui需要安裝一個查找表的錯誤代碼Grbl發回。
" x' p8 X3 \9 B; V( x* k% S//注意:此功能是新的和實驗。確保您使用的GUI支持這種模式。
$ x) i; o. z, P. w
8 Z6 o* s- I8 P5 F+ D2 A1 l- {" A4 `// #define REPORT_GUI_MODE // Default disabled. Uncomment to enable.
4 C$ ?3 e; N2 e/ X$ e0 j/ s" Y' \; ?" ^- Y
// The temporal resolution of the acceleration management subsystem. A higher number gives smoother
* K8 s7 b& w! i; H. v3 u// acceleration, particularly noticeable on machines that run at very high feedrates, but may negatively
( D3 V, G& b; L  e// impact performance. The correct value for this parameter is machine dependent, so it's advised to4 R6 \; Q& Y% v/ u
// set this only as high as needed. Approximate successful values can widely range from 50 to 200 or more.5 T0 P! U/ I2 W7 m/ c8 D
// NOTE: Changing this value also changes the execution time of a segment in the step segment buffer. 6 }1 o" o# r! O$ y2 L
// When increasing this value, this stores less overall time in the segment buffer and vice versa. Make( W/ }  q# F/ X3 w- q) Z( H4 O. x2 c
// certain the step segment buffer is increased/decreased to account for these changes.: `+ t! {1 p% p4 J+ k1 ]
//加速度的時間分辨率管理子系統。更多更平穩
/ S0 F. R5 ?9 X/ q+ G- I//加速度,特別明顯的機器上,運行在非常高的進料速度,但可能負面
: _0 [* w% w5 @. F//影響性能。正確的值為這個參數是依賴于機器的,所以建議
' J2 s" J  J) L8 A; V: ^7 j//這只設置為高。近似成功的價值觀可以廣泛的范圍從50到200或者更多。* H5 R2 ]) Y; D+ E8 r
//注意:改變這個值也變化的部分步驟的執行時間緩沖。) M5 M. N+ U* I$ e# h+ B
//增加這個值時,這個商店部分緩沖區的總時間減少,反之亦然。使3 b0 l8 n: Q5 t
//特定步驟段緩沖是考慮這些變化增加/減少。
+ }3 W/ z- q, f5 H  o9 v% U  _" Y( `$ ~* T5 i& a3 ]
#define ACCELERATION_TICKS_PER_SECOND 100  //加速度的時間分辨率管理子系統。更多更平穩) x: j; \' T  j' |& {
5 |9 f/ o: Q3 w: A6 s: g' m
// Adaptive Multi-Axis Step Smoothing (AMASS) is an advanced feature that does what its name implies, + d0 n0 O, b$ g# Y+ |5 f4 n( Y/ e8 v, U
// smoothing the stepping of multi-axis motions. This feature smooths motion particularly at low step: h" V9 a+ @  ]/ u
// frequencies below 10kHz, where the aliasing between axes of multi-axis motions can cause audible 3 }' s5 T, _' i
// noise and shake your machine. At even lower step frequencies, AMASS adapts and provides even better
" L: i( w7 u0 [7 w4 E// step smoothing. See stepper.c for more details on the AMASS system works.( c! T4 N0 Y9 {* n5 g( o; I% U
//自適應多軸步平滑(積累)是一種先進的功能,它的名字所暗示的那樣,: P! B0 @) u, l8 H: c( J3 v
//平滑的多軸步進運動。這個特性平滑運動尤其是在低一步
. Y& J) x3 v% N% Y7 I//頻率低于10 khz,軸之間的混疊的多軸運動可能導致音響
9 \6 V) ~$ @# d//噪音和震動你的機器。在更低的頻率步,積累適應并提供更好: E8 l! C. }5 M) F4 O8 a
//步驟平滑。看到步進。c更多細節的積累系統的工作原理。
3 C+ o) h- Y4 K1 k
% ~& F: x# U6 Q5 O2 z+ T$ v- o#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING  // Default enabled. Comment to disable.//自適應多軸步平滑" V! c, n# }/ x4 }0 a& V( g

7 O, P& d0 }" G! B// Sets the maximum step rate allowed to be written as a Grbl setting. This option enables an error
6 y) E: \$ |3 G. C// check in the settings module to prevent settings values that will exceed this limitation. The maximum
* X) L* G( K8 s" N7 B% \// step rate is strictly limited by the CPU speed and will change if something other than an AVR running
# ~7 ~6 o( m2 A8 E// at 16MHz is used.% s& |9 R( j1 p% `8 o. `
// NOTE: For now disabled, will enable if flash space permits.* w* A. e* P1 k) W8 b6 m7 q
//設置最大一步速率可以寫成Grbl設置。這個選項可以使一個錯誤
4 r2 s1 x# k  H5 n0 ~//設置模塊中檢查,防止設置值將超過這個限制。的最大# v; B$ r! `/ ^- R+ c- w/ G, C- m
//步驟嚴格限制的CPU速度也會改變如果是其他AVR運行$ m: d# n: m7 U: I2 e# C
//使用16兆赫。* R# N: t& C2 a+ p+ }" L
//注意:現在殘疾,將使如果flash空間許可。
4 B- [- T2 E! ]! [5 v/ g! i, P( B: l0 f7 j0 u. F2 r7 b- F
// #define MAX_STEP_RATE_HZ 30000 // Hz 設置最大一步速率& s  D& y4 d5 A3 g; h0 K/ A

$ m, A$ {- T, O9 Q' u5 E// By default, Grbl sets all input pins to normal-high operation with their internal pull-up resistors: B8 r8 F" `/ k' g$ D
// enabled. This simplifies the wiring for users by requiring only a switch connected to ground, $ T6 m; n  D& G. h
// although its recommended that users take the extra step of wiring in low-pass filter to reduce
2 D, E/ D$ c# _% `9 \- f// electrical noise detected by the pin. If the user inverts the pin in Grbl settings, this just flips7 ?% e, E- C' P# H) m9 h% N
// which high or low reading indicates an active signal. In normal operation, this means the user 2 `9 l8 L% o1 b- _
// needs to connect a normal-open switch, but if inverted, this means the user should connect a # Q  M5 K" o* ]" T. y- w( ~. H- {
// normal-closed switch. $ c& W# x4 Q8 [  H' g) I- E
// The following options disable the internal pull-up resistors, sets the pins to a normal-low % |2 @% w- R5 `3 w, K2 K
// operation, and switches must be now connect to Vcc instead of ground. This also flips the meaning
$ r, v1 g0 j; n2 r1 [5 I) b" p: V// of the invert pin Grbl setting, where an inverted setting now means the user should connect a $ S, v; u' t' n% _; p4 E2 E
// normal-open switch and vice versa.
1 A. \/ l% E" u! r/ X& `- J4 D' e// NOTE: All pins associated with the feature are disabled, i.e. XYZ limit pins, not individual axes., h3 W5 x, M5 j6 w: b
// WARNING: When the pull-ups are disabled, this requires additional wiring with pull-down resistors!: ~- a3 W3 {$ K
//默認情況下,Grbl所有輸入引腳設置為正常高操作的內部上拉電阻
& [4 q5 ^% |( T5 x, S6 E* R0 |& H//啟用。這簡化了布線為用戶只需要一個開關連接到地面,3 r' Y* q. I/ P4 M9 O( X( G# O6 c
//雖然其建議用戶采取額外的步驟,在低通濾波器來減少布線
# s, p) Y! [; r9 L//電噪音檢測銷。如果用戶反轉的銷Grbl設置,這只是翻轉
% O* I4 p( p) r# `* q5 J$ F//讀高或低表明一個積極的信號。在正常操作中,這意味著用戶
  H; s2 L3 P( E* i& p1 A3 Z//需要連接一個常開開關,但如果倒,這意味著用戶應該連接
$ r+ [* o* R$ T+ k- f1 e// normal-closed開關。  x/ |0 V; _3 }( _+ A" d. P
//以下選項禁用內部上拉電阻,一般低設置別針
- ^( O% m' k! j8 P+ J& B- w//操作,現在開關必須連接到Vcc代替地面。這也掀的意思
. @! i. R4 l  p- B//反銷Grbl設置,一個倒置的設置現在意味著用戶應該連接
0 }" E7 X% h0 D# o//常開開關,反之亦然。
( s; c0 e$ _0 D% X% K- ]//注意:所有針與功能被禁用,例如XYZ限制針,而不是單獨的軸。
0 F: B8 R6 u/ g7 k4 e) L( f//警告:引體向上被禁用時,這需要額外的布線與下拉電阻!: f" J6 Y+ W; h- n2 q# e& L5 h

) |6 w5 r2 m; f  _4 b  k+ Z) c//#define DISABLE_LIMIT_PIN_PULL_UP //以下選項禁用內部上拉電阻2 y: j0 X6 o0 `; |- S
//#define DISABLE_PROBE_PIN_PULL_UP
5 y( I# K+ I; J5 I+ n' s6 J" S//#define DISABLE_CONTROL_PIN_PULL_UP
% i# L( b( l! c0 m* v& Q  ^' B9 u! o2 n, I3 {: b% P6 k
// Sets which axis the tool length offset is applied. Assumes the spindle is always parallel with
+ J0 D4 i4 R* Z+ O  R" h// the selected axis with the tool oriented toward the negative direction. In other words, a positive9 B- ]! @0 s+ C- c: e# ?* Z
// tool length offset value is subtracted from the current location.
: ?. d* O7 I8 f1 O' R- ?1 q7 G# p//設置哪個軸長度補償應用的工具。假設軸總是與
) l1 M1 Q6 F+ \% W, w//選擇軸工具面向負方向。換句話說,一個積極的
' O8 B- K6 [' _8 X- o, b//工具長度偏移值減去從當前位置。, S4 m% L/ s# n# i8 z
1 [2 s# C; J1 @
#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS // Default z-axis. Valid values are X_AXIS, Y_AXIS, or Z_AXIS.設置哪個軸長度補償應用的工具
6 W0 s$ v8 \4 S" Q$ J+ R9 E/ N, f: Y% p! }6 m' M7 N( Q
// Enables variable spindle output voltage for different RPM values. On the Arduino Uno, the spindle
3 W) A9 _6 `/ a+ Z// enable pin will output 5V for maximum RPM with 256 intermediate levels and 0V when disabled.( {( b. p" J: q& I  D
// NOTE: IMPORTANT for Arduino Unos! When enabled, the Z-limit pin D11 and spindle enable pin D12 switch!
! q4 F! J; _; W3 o1 F% V7 X// The hardware PWM output on pin D11 is required for variable spindle output voltages.! _# u( p1 _5 K; a% ]8 i) J
//允許變量軸輸出電壓不同的轉速值。Arduino Uno,主軸0 F6 |- F7 t6 c( ?+ s# V9 R
//啟用銷將輸出5 v的最高轉速256中級水平和0 v時禁用。
; @1 ~8 L# {3 j" D& D% \//注意:重要Arduino凱澤本人!當啟用時,Z-limit銷這里和軸銷D12開關!5 _% V2 W8 ]0 \5 H% p5 ?
//硬件PWM輸出銷這里需要變量軸輸出電壓。, J1 l) V. b# Z. c$ b
+ [0 G& l/ F) e: I% z: P, ?( ^# X
#define VARIABLE_SPINDLE // Default enabled. Comment to disable.//允許主軸輸出電壓不同的轉速值3 Q' s/ @$ I; g9 S, X0 r) F, n/ K
8 A- Z# U2 c; {" j+ {. Q
// Used by the variable spindle output only. These parameters set the maximum and minimum spindle speed( E8 L0 g1 T% U% L
// "S" g-code values to correspond to the maximum and minimum pin voltages. There are 256 discrete and . M8 ^5 p. W0 a. t# Z* i8 w
// equally divided voltage bins between the maximum and minimum spindle speeds. So for a 5V pin, 1000
, @% `' _# G3 F+ n( a" c// max rpm, and 250 min rpm, the spindle output voltage would be set for the following "S" commands: & X( c6 f; D* @2 }3 t3 s
// "S1000" @ 5V, "S250" @ 0.02V, and "S625" @ 2.5V (mid-range). The pin outputs 0V when disabled.( ]2 [3 c3 @4 v% v+ `
//使用的變量軸輸出。這些參數設置最大和最小軸轉速( E+ n) C$ u: X/ S) Z& d
//“S”刀位點值對應于銷電壓的最大值和最小值。有256個離散和3 t! j/ b/ W& M$ q1 y& {1 S1 Z" s
//電壓平均分配箱主軸速度的最大值和最小值之間。所以對于一個5 v銷,1000
5 f* Z' S5 ~: K) n& P. S/ s! [// max rpm,250分鐘rpm,主軸輸出電壓將為以下“S”命令:7 z/ {- K0 p. J0 h9 |8 J6 Q6 v: D
// @“S1000 5 v,“S250”@ 0.02 v,“S625”@ 2.5 v(中檔)。銷輸出0 v時禁用。
0 z6 A! \) S7 N; q$ A# m' ~) m
' R7 G9 c8 g8 y#define SPINDLE_MAX_RPM 1000.0 // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.
9 U* z- R) r7 v4 I. v#define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.& B* o+ t. m7 ^  ]" q$ H' M

1 F) D! Q$ j5 a- a, v8 u& a// Used by variable spindle output only. This forces the PWM output to a minimum duty cycle when enabled.' {' K9 V" U5 o: r. v' Q
// When disabled, the PWM pin will still read 0V. Most users will not need this option, but it may be
- K7 r; m& \7 I2 g$ R- ?// useful in certain scenarios. This setting does not update the minimum spindle RPM calculations. Any
5 @# L- f6 Y  f. j4 x$ ~// spindle RPM output lower than this value will be set to this value./ r. M6 Z  N! ]) w4 |" `$ e
//使用的變量軸輸出。這迫使PWM輸出最小占空比時啟用。& x! G' p- ~" o6 G
//當禁用,PWM銷仍讀0 v。大多數用戶不需要這個選項,但是它可能是
" p, i; t5 j2 K/ x3 a; d//在某些情況下很有用。這個設置不會更新最小主軸轉速計算。任何( s8 C6 R9 f+ M( A, }9 v) u
//輸出軸轉速低于這個值將被設置為這個值。, J/ I2 {  p9 |6 e6 ~$ N
9 p8 [5 H) {8 r0 P! P3 Y
// #define MINIMUM_SPINDLE_PWM 5 // Default disabled. Uncomment to enable. Integer (0-255)
, T5 Y" O0 S! [$ F6 a- J
6 `" X$ X% \: w! ^. V- N( I. {// By default on a 328p(Uno), Grbl combines the variable spindle PWM and the enable into one pin to help
7 Z5 H& Y0 D! q6 F5 s, m! t// preserve I/O pins. For certain setups, these may need to be separate pins. This configure option uses
1 R6 z5 G. g  i; F// the spindle direction pin(D13) as a separate spindle enable pin along with spindle speed PWM on pin D11.
& F8 P: L- }$ l1 Q5 C// NOTE: This configure option only works with VARIABLE_SPINDLE enabled and a 328p processor (Uno). 0 g9 ^  c* ?1 W2 }5 k, }) V  J$ J/ Z
// NOTE: With no direction pin, the spindle clockwise M4 g-code command will be removed. M3 and M5 still work.3 e1 j' ~+ I8 f; r5 Q3 f) V3 Y( d
// NOTE: BEWARE! The Arduino bootloader toggles the D13 pin when it powers up. If you flash Grbl with+ K* H# I% L6 q. D. [$ t
// a programmer (you can use a spare Arduino as "Arduino as ISP". Search the web on how to wire this.), + l! f' Q5 r# j$ ?; \' Y
// this D13 LED toggling should go away. We haven't tested this though. Please report how it goes!
. Q& g1 f, Q$ Q. G) y" [+ g. q//默認ATmega328 p(Uno),Grbl結合變量軸PWM和使到一個銷的幫助
" x- F2 \; U7 K4 Q//保存I / O管腳。對于某些設置,這些可能需要單獨的別針。這個配置選項使用
0 b+ w5 A# p; G! R- W+ Y//方向軸銷(D13)作為一個單獨的軸銷上啟用銷以及主軸轉速PWM這里。0 Q- m' i2 p$ X
//注意:該配置選項僅適用于VARIABLE_SPINDLE啟用和328 p處理器(Uno)。
9 ^9 W2 `4 c" J+ j% I- x! G//注意:沒有方向銷,主軸順時針M4刀位點命令將被刪除。M3和M5仍然工作。; S& y9 c- S$ t# W
//注意:小心!Arduino引導裝載程序切換D13銷的權力。如果flash Grbl
4 D% r5 D2 B& r//程序員(您可以使用一個備用Arduino“Arduino ISP”。搜索網絡如何線),
: m/ w$ F( a2 g% K" E% [//這D13導致切換應該消失。我們還沒有測試這個。請報告將會怎樣!
! S. y7 P0 }" Y, w* K  C8 S' J% _& J" U; L! D
// #define USE_SPINDLE_DIR_AS_ENABLE_PIN // Default disabled. Uncomment to enable.
3 `9 l2 ~: w& z0 M7 O  O5 P: R. o! K% h& G) V' a
// With this enabled, Grbl sends back an echo of the line it has received, which has been pre-parsed (spaces0 E5 @. q; ^. e9 ^) _; {
// removed, capitalized letters, no comments) and is to be immediately executed by Grbl. Echoes will not be $ t4 H9 p3 z! V& Q7 _
// sent upon a line buffer overflow, but should for all normal lines sent to Grbl. For example, if a user
! {) `( h: |; I! s( ~, j// sendss the line 'g1 x1.032 y2.45 (test comment)', Grbl will echo back in the form '[echo: G1X1.032Y2.45]'.# h% W* n5 g, r' L8 M% a8 S! s7 h
// NOTE: Only use this for debugging purposes!! When echoing, this takes up valuable resources and can effect
0 r2 E( _6 w9 V// performance. If absolutely needed for normal operation, the serial write buffer should be greatly increased
3 B$ O# F! p2 P5 u2 i' l3 L: @// to help minimize transmission waiting within the serial write protocol.
5 Z* I% m" a- ^6 H$ k) V% H3 X
7 G! t5 _4 g4 S& [& s8 O//啟用,Grbl發回的回聲線已收到,已預編譯(空間
* L$ D, L9 ~" l3 r/ _//移除,大寫字母,沒有評論),由Grbl立即執行。回聲將不會" O4 o% s  z- e
//發送一個線緩沖區溢位,但應該對所有正常線路送到Grbl。例如,如果一個用戶
( O) o' M+ K  S- T//發送線的g1 x1.032 y2.45(測試評論)形式”,Grbl將回聲”(回聲:G1X1.032Y2.45]”。
7 Q+ O2 o1 e/ O! l//注意:只使用這個調試! !當呼應,這占用了寶貴的資源,可以影響
% `9 c( D$ d) ]) s! Y* L//性能。如果正常運行所需的絕對,串行寫入緩沖器應該大大增加
( b, [; U& t/ F4 e//幫助最小化傳輸等系列內寫協議。
, P! e0 `$ y+ T$ Q; V! _* k0 N% m1 G1 p4 t" x' w
// #define REPORT_ECHO_LINE_RECEIVED // Default disabled. Uncomment to enable.
0 U, r. U5 s. X5 q" W" t6 ?* j# V/ ]: T( N6 F3 Z% g6 o
// Minimum planner junction speed. Sets the default minimum junction speed the planner plans to at
4 k0 l4 X) }0 j1 U// every buffer block junction, except for starting from rest and end of the buffer, which are always! X$ ^# }4 t6 e) Q, B
// zero. This value controls how fast the machine moves through junctions with no regard for acceleration4 A% J; o+ |- n( @* [" ]
// limits or angle between neighboring block line move directions. This is useful for machines that can't
7 v2 x, G7 b7 L7 b, L" q// tolerate the tool dwelling for a split second, i.e. 3d printers or laser cutters. If used, this value; ~3 x3 N$ R  N
// should not be much greater than zero or to the minimum value necessary for the machine to work.
: x( \' ^, Y' X' t, t# D; I7 ]3 C- z& I# `  s! _. n/ t9 K
//最小規劃師結速度。設置默認最小連接速度規劃計劃
1 Z9 q& s( y3 ~//每一個緩沖塊接頭,除了從結束休息和緩沖區,它總是% W7 u, g' D. E+ j
// 0。這個值控制機器的速度穿過路口,沒有考慮加速度% n. s0 g( q# ^/ M& ~; Y  B
//限制或相鄰塊之間的角線方向移動。這是有用的機器,不能/ h5 d, I- u& ]7 x+ h$ F4 J& g
//容忍工具居住某一剎那,即3 d打印機或激光切割機。如果使用這個值
: ~+ {, f0 e8 V//不應大于零或機器工作所需的最小值。4 e; f0 a9 h2 \6 E# s+ F

' Q: E" ]8 G* J6 F& C* B1 n9 j: z: [#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min); r9 z/ a" O5 C

7 I. A  S- h1 Y* t# p1 W# I3 y5 `// Sets the minimum feed rate the planner will allow. Any value below it will be set to this minimum+ s4 b9 h: m1 |/ f, @2 Z) \
// value. This also ensures that a planned motion always completes and accounts for any floating-point; Q1 K7 K9 x* P
// round-off errors. Although not recommended, a lower value than 1.0 mm/min will likely work in smaller
  J! L& n8 L, W1 O// machines, perhaps to 0.1mm/min, but your success may vary based on multiple factors.
7 E9 u1 Y/ d' n//設置計劃將允許的最小進給速率。任何價值低于它將被設置為最低值。這也保證了運動計劃總是完成,占任何浮點
4 a: _' e$ [( `2 ?( c2 G% M: f7 M//舍入錯誤。雖然不推薦,價值低于1.0毫米/分鐘可能會在較小的工作  k+ S0 {% k  w, _* U
//機器,也許到0.1毫米/分鐘,但你的成功基于多種因素可能會有所不同。* [( C/ p) R" p1 r

4 H  G" Q# u' {, u& k#define MINIMUM_FEED_RATE 1.0 // (mm/min)//設置計劃將允許的最小進給速率5 d( X$ o9 ?+ m6 ~2 S3 c

5 E4 H/ c3 w; P# H! y' o; R: A// Number of arc generation iterations by small angle approximation before exact arc trajectory . M  i& H  E; i
// correction with expensive sin() and cos() calcualtions. This parameter maybe decreased if there
) A! s2 z- X: r- J// are issues with the accuracy of the arc generations, or increased if arc execution is getting
0 |( l, ~4 U# ^// bogged down by too many trig calculations. 8 f8 q. B8 M+ X# S# H) \$ R
//弧生成迭代次數之前小角度近似精確的弧線軌跡
4 g+ H0 }5 L. ^' `3 g( B, Q- l5 T' W, U% p//修正與昂貴的sin()和cos()calcualtions。如果有這個參數可能減少. C+ K+ g2 `( k# {
//與弧一代又一代的準確性問題,或如果電弧執行得到增加+ ~7 Y! y; K, e
//太多的三角計算的泥潭。
9 g9 j# L/ \! g' z2 O: P/ U
' e% k7 z9 a7 R3 n$ ?! v# I#define N_ARC_CORRECTION 12 // Integer (1-255)
$ A) y$ d3 d0 p6 J
1 s! s; k9 v2 I, s5 |// The arc G2/3 g-code standard is problematic by definition. Radius-based arcs have horrible numerical - O2 y- C; X/ O! ~
// errors when arc at semi-circles(pi) or full-circles(2*pi). Offset-based arcs are much more accurate
0 T9 B; Q' W4 k- ~) a// but still have a problem when arcs are full-circles (2*pi). This define accounts for the floating 1 j% K# v7 A, Z, z
// point issues when offset-based arcs are commanded as full circles, but get interpreted as extremely
% ]4 }  ]( r) _// small arcs with around machine epsilon (1.2e-7rad) due to numerical round-off and precision issues.9 Q' R& _  _  c1 O8 q+ b$ a
// This define value sets the machine epsilon cutoff to determine if the arc is a full-circle or not.
8 U; m8 Q- D; k  |  a) N3 b// NOTE: Be very careful when adjusting this value. It should always be greater than 1.2e-7 but not too8 h' e" t4 H: I% t# b/ A+ @' ^$ N
// much greater than this. The default setting should capture most, if not all, full arc error situations.$ ?5 x; C. a5 Z/ C7 X
//弧G2/3刀位點的標準定義是有問題的。Radius-based弧有可怕的數值
, U6 o* X! J2 q. z4 c' Z  z& V//錯誤當電弧在半圓(π)或原點(2 *π)。Offset-based弧更準確" P5 M4 \: ~, {! Z) v% u) ~& f3 S
//但仍有一個問題當弧原點(2 *π)。這個定義占浮動
+ j0 T: y1 s7 v; {+ F# n//當offset-based弧吩咐點問題完整的圓,但解釋為極$ P& i% b: M& ^8 v
//小弧機周圍ε(1.2 e-7rad)由于數字舍入和精度問題。: {! a  y  L6 O" f; x, c
//定義值設置機器ε截止來確定電弧是一個原點了。
  H' G3 t  C4 F  A4 @  j//注意:調整這個值時非常小心。它應該總是大于1.2 e -但不要太* v6 q9 `4 H' d
//比這大得多。默認設置應該捕獲大部分,如果不是全部,全部錯誤的情況。% V0 g/ w' `9 F' n/ y
9 V- k) j, i; A
#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)
+ H% w. d' v; q& F2 o; T, {" t* Z, @+ [0 p. f& I" y" V  {8 p
// Time delay increments performed during a dwell. The default value is set at 50ms, which provides
! g2 d; ]' j( x3 W( C7 r// a maximum time delay of roughly 55 minutes, more than enough for most any application. Increasing
+ X3 m& m' z+ R// this delay will increase the maximum dwell time linearly, but also reduces the responsiveness of $ x8 ~8 y) X$ S" O2 _
// run-time command executions, like status reports, since these are performed between each dwell $ H' Y% D2 p+ a" D. h% V
// time step. Also, keep in mind that the Arduino delay timer is not very accurate for long delays.: L% K# D. f7 k& N( n2 g9 l
//延時增加表現在住。默認值設置為50毫秒,它提供了
5 h  R8 P- r1 |6 L# o. n. b& W//最大延時約55分鐘,足夠對大多數任何應用程序。增加; z3 {$ e. K, R2 f, b) p
//這種延遲將增加線性最大停留時間,也減少了響應能力
7 G5 v5 z7 L: H# y//運行命令執行狀態報告一樣,因為這些每個住之間執行
  j$ |3 e  e  a7 R//時間步。還有,記住,Arduino延遲計時器不是很準確的長時間延誤。
7 G$ ?) W' y( O/ E7 @
7 r2 T6 R3 T) a* t2 e7 v' H+ K. L0 X7 X#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds)
; \' X8 L5 |4 l9 D7 f, T& A# M; o+ j7 h: S
// Creates a delay between the direction pin setting and corresponding step pulse by creating. i2 ]9 Y5 k+ A# Y9 H3 B
// another interrupt (Timer2 compare) to manage it. The main Grbl interrupt (Timer1 compare) 5 ?0 F6 j' t) u: B8 W  x, A/ Q! a
// sets the direction pins, and does not immediately set the stepper pins, as it would in % i4 L/ g# ^( a: f
// normal operation. The Timer2 compare fires next to set the stepper pins after the step ' k; |6 q9 Q0 e+ m7 r7 r( R
// pulse delay time, and Timer2 overflow will complete the step pulse, except now delayed
3 q8 e) ~# r& I% S// by the step pulse time plus the step pulse delay. (Thanks langwadt for the idea!)
& W' q- z* w% e) V  i* z/ X0 `// NOTE: Uncomment to enable. The recommended delay must be > 3us, and, when added with the
' V! ^* B( s4 z+ `) e8 w" s// user-supplied step pulse time, the total time must not exceed 127us. Reported successful
: M/ H/ `; r5 q  i7 N3 p// values for certain setups have ranged from 5 to 20us.
4 ?$ @3 J+ D" S7 w" q2 K5 `1 z3 U/ Q) c2 v//創建一個方向銷之間的延遲脈沖通過創建設置和相應的步驟6 ^5 M  S+ n0 F2 y, u) \' p
//另一個中斷(Timer2比較)來管理它。主要Grbl中斷(Timer1比較)
. v5 g) v, G  |) R# U! z( f" R* e//設置方向針,不立即設置步進針,因為它會在6 ~% z" A# S2 l. X
//正常操作。Timer2比較火旁邊設置步進針后一步' _. O1 d: V  U- |1 y! [/ d
//脈沖延遲時間,Timer2溢出脈沖將完成的步驟,現在延遲除外4 C" G: v  G: d- M' B9 S/ @
//脈沖時間加上的一步一步脈沖延遲。(感謝langwadt主意!): x, V7 ]7 p0 W' j/ `$ r) U- ?
//注意:取消啟用。必須> 3,建議延遲,當添加的
1 q9 ~' c4 f& n' |( j0 t/ t//用戶提供的步驟脈沖時間,總時間不得超過127美元。成功的報道
7 W0 R. S* e" n! y//值對某些設置范圍從5到20。& \" i6 z6 H" K  y4 L. M  _' u
. Y4 _$ P) Q; {( ~
// #define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.
3 ]& {3 ?( R) P6 N% `; t& r! W' W) S! e# B. o
// The number of linear motions in the planner buffer to be planned at any give time. The vast; X0 w$ r) S( C
// majority of RAM that Grbl uses is based on this buffer size. Only increase if there is extra 4 F' d6 I3 C$ w0 u/ T3 ?
// available RAM, like when re-compiling for a Mega or Sanguino. Or decrease if the Arduino$ N, u4 _! Y( a. H' g9 I7 F
// begins to crash due to the lack of available RAM or if the CPU is having trouble keeping( n9 S+ w9 g& w& F
// up with planning new incoming motions as they are executed.
+ L: U$ {" b" x# I! r//線性運動規劃師緩沖區的數量在任何給出時間計劃。絕大8 h$ B  C1 p) q1 u8 j
//多數RAM Grbl使用基于這個緩沖區的大小。如果有額外的只會增加
% V* @0 y1 e* v' \4 J& t* D//可用內存,比如當基于大型或Sanguino。如果Arduino或減少' f4 Q) ~; P9 d5 ?) z4 W
//開始崩潰由于缺乏可用的RAM或者CPU是難以保持
9 A  T9 T2 _) _9 S6 @//與規劃新傳入的動作執行。
+ m/ V4 R3 U" w2 z, s* g# q) h! H4 \& g' f! R% ^
// #define BLOCK_BUFFER_SIZE 18  // Uncomment to override default in planner.h." D& S/ @' O* F
/ X+ T* Q6 Y/ j, d$ ]; q& w2 u
// Governs the size of the intermediary step segment buffer between the step execution algorithm
# _# c) _9 y, Y  i6 p// and the planner blocks. Each segment is set of steps executed at a constant velocity over a8 W* R/ ?8 l( y1 s" p6 h2 ?6 Q
// fixed time defined by ACCELERATION_TICKS_PER_SECOND. They are computed such that the planner0 K! t& \2 ^8 E3 J, C! t# N
// block velocity profile is traced exactly. The size of this buffer governs how much step . g( J' v7 u7 Q" d  Z" S
// execution lead time there is for other Grbl processes have to compute and do their thing
! L, {" z# S) z) a4 {( T8 V3 i// before having to come back and refill this buffer, currently at ~50msec of step moves.2 y, v" q+ D/ C: L
//控制之間的中間段緩沖大小的步驟執行算法
8 g* D) u1 ^: m0 d+ O' d, R' Y) R//和規劃師塊。每一部分的步驟執行在一個恒定的速度1 k3 _: T8 [1 j% A' l& }
//固定的時間由ACCELERATION_TICKS_PER_SECOND定義的。他們計算的計劃% L& C$ U( W+ m: N  l  o; ]5 l
//塊速度剖面追蹤到底。這個緩沖區的大小控制多少步驟
1 y/ C5 _, `6 z1 I7 s, P9 D//執行時間有其他Grbl過程需要計算和做他們的事情
' G/ `/ Q$ l9 H7 q. g4 K5 A' J//之前必須回來重新填充這個緩沖區,目前移動~ 50毫秒的一步。
/ i3 a6 g* ]- [1 I- p! U/ i' j/ H& {
0 S& M. I6 l& L- S* C// #define SEGMENT_BUFFER_SIZE 6 // Uncomment to override default in stepper.h.
5 N# B+ Q- r9 e  Y" p' [% r+ ]' }0 o# I, S" {
// Line buffer size from the serial input stream to be executed. Also, governs the size of
) b. z8 `0 d5 a7 {// each of the startup blocks, as they are each stored as a string of this size. Make sure: P' j4 K) R$ W" a  V- i% s' @
// to account for the available EEPROM at the defined memory address in settings.h and for& d! ~  ^- }6 x; F- u+ B. V( \8 e) }! G
// the number of desired startup blocks.
, v& u# s" M6 G0 ?! Z- c// NOTE: 80 characters is not a problem except for extreme cases, but the line buffer size 6 m2 i2 X4 s2 ]7 F+ r! |1 X/ D3 A" z
// can be too small and g-code blocks can get truncated. Officially, the g-code standards ) r( Y/ D1 h  G+ p
// support up to 256 characters. In future versions, this default will be increased, when
4 [- J% {8 U- ]2 Z// we know how much extra memory space we can re-invest into this." k& D  X* y/ ?0 \7 w; E7 @
//行執行串行輸入流的緩沖區大小。同時,大小的控制
: U# W! [0 M% A' P, f//每個啟動模塊,它們分別存儲為字符串的大小。確保
& f) b% k4 R6 t: Y. G; ~//占可用eepm定義內存地址的設置。h和) R7 W9 v) q$ ^+ D& S- z
//需要啟動塊的數量。
$ M9 X- z3 x  N! A3 k//注意:80個字符不是一個問題,除了極端的情況下,但線緩沖區大小
# p( e1 ?: a2 _% c//可以太小和刀位點塊可以截斷。正式,刀位點標準$ w1 |2 h: \4 c% r0 X: p% u
//支持多達256個字符。在未來的版本中,這個違約將會增加,當2 @. ?2 V; Q5 g4 o* Y. n4 Q& A1 n8 y
//我們知道多少額外內存空間的時候我們可以再投資。
" T, d9 s/ }9 \# O  l. m- h
( L& U0 }" l$ [) s+ i- [& z1 P// #define LINE_BUFFER_SIZE 80  // Uncomment to override default in protocol.h2 c/ Q. \# |6 B2 O
  2 `, S/ _' ^( Q8 s
// Serial send and receive buffer size. The receive buffer is often used as another streaming
8 z4 ?( V# L1 G6 n/ I// buffer to store incoming blocks to be processed by Grbl when its ready. Most streaming
3 T. U- m. P$ U( x7 {. d; O" m// interfaces will character count and track each block send to each block response. So,
& i( f* w# v; B, }0 H6 ?// increase the receive buffer if a deeper receive buffer is needed for streaming and avaiable3 z8 l, e# g. z5 V. r0 V% N  T! A
// memory allows. The send buffer primarily handles messages in Grbl. Only increase if large& F! Q" `, p6 z) p6 c  G& w
// messages are sent and Grbl begins to stall, waiting to send the rest of the message.
# G, y3 B/ q9 b: ~9 i# {// NOTE: Buffer size values must be greater than zero and less than 256.1 H, U, A, `2 i- x
// #define RX_BUFFER_SIZE 128 // Uncomment to override defaults in serial.h/ h4 m  I/ P( R. K
//串行發送和接收緩沖區大小。接收緩沖區通常用作另一個流  u2 w5 S/ W; L5 i9 t" `
//緩沖存儲傳入的塊來處理Grbl當它準備好了。最流8 z! s8 V5 j; S6 l5 e; R
//接口將字符計數和跟蹤每一塊發送給每個塊的回應。所以,
  _; @! V& x- P$ k3 |$ O//增加接收緩沖區如果需要更深層次的接收緩沖區為流,、3 W, e; W) j' k4 |0 V
//內存允許。Grbl發送緩沖主要處理消息。只會增加如果大
6 L( {# u% E) {3 Z- `& N$ d. h4 H//消息發送和Grbl開始停滯,等待發送其余的消息。
& ?" z# o: T+ ?# H//注意:緩沖區大小值必須大于零,小于256。* X( r4 L. L5 ?1 A0 P
// # define RX_BUFFER_SIZE 128 / /取消serial.h覆蓋默認值7 Q4 ]) i8 x5 v- W: f
2 ]9 e4 S* r  p/ k

$ v  A6 l, s  A3 L5 ~1 ?: I) q// #define TX_BUFFER_SIZE 64
7 F7 Y6 H/ w" G3 ^  
/ E, ?/ X9 A. f6 k" w, {/ _// Toggles XON/XOFF software flow control for serial communications. Not officially supported5 J- Y) u+ f6 t
// due to problems involving the Atmega8U2 USB-to-serial chips on current Arduinos. The firmware) e, _; j1 k5 L
// on these chips do not support XON/XOFF flow control characters and the intermediate buffer
1 A- b. g4 y5 M7 x2 E// in the chips cause latency and overflow problems with standard terminal programs. However, ; O0 c7 e: o& o% ?( p  Z5 ^5 m! l9 d
// using specifically-programmed UI's to manage this latency problem has been confirmed to work.6 P/ u* t; I; A4 Q, `
// As well as, older FTDI FT232RL-based Arduinos(Duemilanove) are known to work with standard$ F- L( S$ y! z- p
// terminal programs since their firmware correctly manage these XON/XOFF characters. In any
  n& M) k3 s  x7 q, F- \$ ^// case, please report any successes to grbl administrators!
* m9 E- H% z5 x! U//切換為串行通信發送樸通/發送葡開軟件流控制。不是官方支持# b+ T2 u  A3 r4 U% J9 \) s+ w( i
//由于問題涉及Atmega8U2 USB-to-serial當前arduino芯片。固件
/ {+ V& R: Y5 A! \//在這些芯片不支持發送樸通/發送葡開流控制字符和中間緩沖區
+ Q4 R, E! R# g) M  c//芯片導致延遲和溢出問題的標準終端程序。然而,
- o$ Y* W9 r- e1 i//使用specifically-programmed UI的管理這個延遲問題已經確認工作。4 W) R4 a- d' R0 U1 o; ~
//以及老FTDI FT232RL-based arduino(Duemilanove)是已知的標準
6 h! S& Z$ |8 Y' D/ ]9 |* J7 }$ \- E//終端程序因為他們正確的固件管理這些發送樸通/發送葡開的角色。在任何
) s% I, z- m0 S% t: h//情況,請報告任何成功grbl管理員!
; A' I( ~4 Q# H, [3 t% m
* `" N2 |4 s; N' C$ U8 @7 r& H// #define ENABLE_XONXOFF // Default disabled. Uncomment to enable.
* _! L# k  {8 o" Y/ z7 _2 Y3 L/ H& I
// A simple software debouncing feature for hard limit switches. When enabled, the interrupt
) D; g. @- u1 [  `( y// monitoring the hard limit switch pins will enable the Arduino's watchdog timer to re-check
, d8 Q2 ~- D" ]// the limit pin state after a delay of about 32msec. This can help with CNC machines with 2 ~3 Z/ {, M; c, M8 c$ H; Z
// problematic false triggering of their hard limit switches, but it WILL NOT fix issues with , s  h* R- U. |( z% m
// electrical interference on the signal cables from external sources. It's recommended to first, w% O6 m4 Y1 J. A& d! a
// use shielded signal cables with their shielding connected to ground (old USB/computer cables & G( G9 C% g4 P
// work well and are cheap to find) and wire in a low-pass circuit into each limit pin.
+ y) h5 `! \# t4 y* |$ ]3 H8 }//一個簡單的軟件消除抖動特性硬限位開關。當啟用時,中斷4 N$ ]# P8 `1 `! i
//監控硬限位開關針將使Arduino的看門狗定時器重新審視
% g9 ^# \. v; J//銷的極限狀態后約32毫秒的延遲。這可以幫助與數控機器
& f! V- T) I$ J$ D//問題錯誤引發的硬限位開關,但是它不會解決問題
1 B( |) A2 [# E- S3 o7 V+ S' q//電干擾信號電纜從外部來源。首先它的建議( d+ P, Y' q, d/ K% G4 t6 c# W
//使用屏蔽信號電纜的屏蔽連接到地面(老USB /計算機電纜6 g' B- ^  [, b/ a5 T2 y" j5 ^
//工作得很好,很便宜)和線低通電路到每個限位銷。
" F2 ?( k5 |7 L: Z
; W" N2 `$ x: x) i  ]// #define ENABLE_SOFTWARE_DEBOUNCE // Default disabled. Uncomment to enable.) ?" s; w8 v. [7 J, a5 K2 m

; G9 H7 L7 i  m, v. M// Force Grbl to check the state of the hard limit switches when the processor detects a pin
  B1 S: d- ?- `) B. X// change inside the hard limit ISR routine. By default, Grbl will trigger the hard limits
, g, E( n" T8 K" J1 E4 n// alarm upon any pin change, since bouncing switches can cause a state check like this to
* F8 C8 b7 A# x// misread the pin. When hard limits are triggered, they should be 100% reliable, which is the) _7 c" l( c9 I6 Q
// reason that this option is disabled by default. Only if your system/electronics can guarantee8 O/ O" U: \7 l. [& E
// that the switches don't bounce, we recommend enabling this option. This will help prevent. i0 i. p7 S4 f3 K( [
// triggering a hard limit when the machine disengages from the switch.* R0 j6 {) t. i! {. f' `, I+ ]4 s6 u
// NOTE: This option has no effect if SOFTWARE_DEBOUNCE is enabled.7 D  a% D3 E# l( P) i/ \7 ^+ j
//力Grbl檢查硬限位開關的狀態,當處理器檢測到一個銷
* T* f1 y5 X2 o8 U//改變內部硬限制ISR例行公事。默認情況下,Grbl將觸發硬限制
! s$ J! E- O8 B6 i& A* a//報警在任何銷更改,因為跳開關可以導致這樣的狀態檢查- W0 d  B  y7 I  O
//誤讀了銷。硬限制觸發時,他們應該100%可靠,這是
+ _- D4 F( `. x$ M: H//原因,這個選項默認是禁用的。只有在你的系統/電子產品可以保證
1 m) W0 J+ L3 \% H7 N$ V//開關不反彈,我們建議啟用這個選項。這將有助于防止4 K4 e4 H( N' p: @6 H+ {; a
//觸發機退出時硬限制開關。; i6 t0 c6 `# _) ~% E
//注意:這個選項如果啟用了SOFTWARE_DEBOUNCE沒有影響。
9 z8 q( X' t% D* [3 Q
9 X: b/ a: u5 g6 N) T7 g  }9 Y5 ~) ?// #define HARD_LIMIT_FORCE_STATE_CHECK // Default disabled. Uncomment to enable.6 Y4 \( e" x8 K0 B' c6 a8 c$ E

- c$ z( }3 ]2 i5 b! V  F1 _) r
$ Q* g, D' x8 y: U3 l* y5 x" h+ K// ---------------------------------------------------------------------------------------5 ~. W1 T" J* C: o- V+ _8 z, s/ ?) G
// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:編譯時錯誤檢查的定義值:
" r" J3 E% z9 V  o" `6 b+ x. E/ \( M
#ifndef HOMING_CYCLE_0' e2 V" c+ \2 l8 n
  #error "Required HOMING_CYCLE_0 not defined.", m$ j! E5 v" Y. D5 g
#endif% N& U6 ^1 J: R& ]3 b! [; V

. u0 L+ [9 v4 g#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(VARIABLE_SPINDLE)
% R& s2 m+ {: `1 p# N1 k  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with VARIABLE_SPINDLE enabled": S/ y+ X: s* X* l1 S
#endif
/ B) @) L( E8 F* f" h& O0 v' F2 D3 L3 m! Q. d" Z% F0 g
#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(CPU_MAP_ATMEGA328P)' m1 _7 [$ a$ w- J$ C
  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with a 328p processor"8 z+ c1 i' a+ A7 P( b; i8 Q0 x
#endif# q' _; L4 ]' v* ^1 O5 ~' V

) n$ C' M# a+ Q( s- w// ---------------------------------------------------------------------------------------+ @5 t& S  ^% T( X+ c  H

+ s: {* {9 n5 d8 j3 W! Y7 v% e
#endif
" f5 B3 E$ {. [+ j. J
  \# \4 {% @3 f: r- A! U
% s0 |9 q# r! U* D( [
& Q/ e% e1 n6 ]* i- [
+ H, }0 l. m3 L8 Q; A  @( `) m
" W1 g2 ]# N7 L  r. E2 l. u: r6 j1 l& x0 x6 Y, J
: t! X  c% b2 J9 b. g( p+ ^
" Q) F. e) i7 c5 |- C  K' \) w

! W' Q, t  w$ f
9 H, I. @- p1 H7 `! n! L
" @" x1 k3 \3 M$ z
& h$ O; [; x. ?7 a8 n1 ~; B$ X$ g& [. l& s& x3 g

) i; s3 n" F6 e- p
2 B9 S! t5 @2 H& m( R& E! j1 I/ S( p

本帖子中包含更多資源

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

×

評分

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

查看全部評分

回復

使用道具 舉報

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

+ ~# ]8 P0 A6 V! S4 C- f! L8 K' ?
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 | 只看該作者
補充
6 g. I" t/ s( H0 t程序運行protocol_execute_realtime(); /運行實時命令。3 G  t$ T6 z9 S, d% S: J
// Executes run-time commands, when required. This is called from various check points in the main
6 M) v3 e; F  N6 W// program, primarily where there may be a while loop waiting for a buffer to clear space or any
! M. B+ A0 r( }1 f; ?// point where the execution time from the last check point may be more than a fraction of a second.& f0 l1 p9 o& }
// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code& u. m% a' m9 w6 j3 G$ C( O4 J
// parsing and planning functions. This function also serves as an interface for the interrupts to * O) c# t/ L. x2 q: K
// set the system realtime flags, where only the main program handles them, removing the need to) k" d$ O) t, w+ Y. P
// define more computationally-expensive volatile variables. This also provides a controlled way to
8 Q1 t8 [7 z' x0 `& f4 o/ f+ L// execute certain tasks without having two or more instances of the same task, such as the planner1 z5 r9 i: S) a  X- q
// recalculating the buffer upon a feedhold or override.  b2 }3 y/ {4 t4 x
// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,
/ _7 L. E( ~( G( x& P// limit switches, or the main program.4 A  S9 @  N* v1 {( V) q  `% N

$ O0 i3 |# W* z! r( l6 W//執行運行時間命令,在需要時。這就是所謂的從各種主程序要檢查站- j" T! _5 f* V& ]
//,主要是那里可能是一個while循環等待緩沖區空間或任何, t8 Y+ e  P( \4 u2 |- z9 F
//執行時間從過去的止點可以超過幾分之一秒。
' [8 _5 W7 P& d//這是一種異步執行實時命令(又名多任務)grbl的刀位點
3 ?# }- A% {7 h9 ?//解析和規劃功能。這個函數也可以作為一個接口,用于中斷: l4 D' Q) h( c9 i7 L+ k+ o" V
//設置系統實時的旗幟,只有主程序處理,消除的需要3 o. c) Y  T3 |0 n
//定義更多的計算昂貴volatile變量。這也提供了一種控制方法
. ^" P( r0 W+ a# h9 x, j4 r6 V$ w//執行某些任務不相同的兩個或多個實例的任務,比如計劃
: J2 X( M/ E0 @# w5 d//重新計算緩沖feedhold或覆蓋。
# ^) d3 u, [# T, B0 K/ {  B//注意:sys_rt_exec_state變量標志設置任何過程,步驟或串行中斷,插腳引線,
7 a, {! `, m5 P9 H//限位開關或主程序。
! n9 I7 M3 Q4 j' `8 B4 b  C) Wvoid protocol_execute_realtime()5 ^' U1 v8 ?' N. l2 ]3 @
{
* Z  q1 ^6 c+ t& ^        // Temp variable to avoid calling volatile multiple times.' ?0 ^  K9 r0 I( q
        // 臨時變量來避免多次調用不穩定。& Y5 t1 o' {2 u# J5 X" q* Q
        uint8_t rt_exec;
4 V7 }; K# [: F, i/ a" Q) y; @        do{3 k$ a5 d* r' X' c( K: L5 s
          if (rt_exec) {                 // 有標志位置位進入8 M* S5 e) V" C* H4 \5 L; B! R* b1 p
       
# R% ~% v6 s* D1 H( K: N! G+ p0 c; x            sys.state = STATE_ALARM; // 設置系統為報警狀態
% s& Q0 o: c0 D! v7 g7 I      report_alarm_message(ALARM_HARD_LIMIT_ERROR);        //報告報警信息為接近極限值
; O7 Z0 e0 d6 s; C+ ^8 X7 t' m, l5 m    } else if (rt_exec & EXEC_ALARM_SOFT_LIMIT) {                        //報告執行軟件限位報警' [9 x0 d. C* j; z
      report_alarm_message(ALARM_SOFT_LIMIT_ERROR);        //報告出現軟件限位報警2 T( F- n- @1 R! i# [0 U
    } else if (rt_exec & EXEC_ALARM_ABORT_CYCLE) {                //執行停止循環報警      ) X3 [( G5 D$ j  {
      report_alarm_message(ALARM_ABORT_CYCLE);                //出現終止循環報警
1 I# h# ?& \+ @( k( C' q: u8 `    } else if (rt_exec & EXEC_ALARM_PROBE_FAIL) {                        //執行探查失敗報警
/ }2 N) ?( M0 \" o/ w      report_alarm_message(ALARM_PROBE_FAIL);                        //出現探查失敗報警& f7 h: A9 ~2 S" S
    } else if (rt_exec & EXEC_ALARM_HOMING_FAIL) {                //執行返回原點失敗報警  Q4 l. X% q# I
      report_alarm_message(ALARM_HOMING_FAIL);                //出現返回原點失敗報警" x4 S' N* k. w# E- t" t! v
    }
' a3 T! C# G' U& M5 y0 R& m
* z- E4 b! {% ^; |; n; U    // Halt everything upon a critical event flag. Currently hard and soft limits flag this.- ~! V+ x# K6 M1 H
    // 停止一切在一個關鍵事件標志。目前硬和軟限制標志, b* f6 h+ T# t0 k# F
           if (rt_exec & EXEC_CRITICAL_EVENT) {                //如果系統是循環事件進入. D0 ^* O2 h: v, d5 m8 J
             report_feedback_message(MESSAGE_CRITICAL_EVENT);        //報告反饋信息: W! d% }% k( u; M
              bit_false_atomic(sys_rt_exec_state,EXEC_RESET);                         //清除目前的復位狀態  ~: Q8 o/ n6 [% x

: C; q  I* L3 P$ Z        bit_false_atomic(sys_rt_exec_alarm,0xFF);                                 // 清除所有報警標志
% m( d2 ~3 I# Z* Y  v6 t. ]        }        * g% R; D6 T: A7 |7 }, a
! ]1 b6 f! \1 D- O3 N, }1 c" d' h
上面代碼將rt_exec = sys_rt_exec_alarm ,如果rt_exec為真,打印不同報警信息% u2 s6 N4 `0 R' k
和限位保護信息,然后清除報警狀態( \7 h: u7 c6 T
___________________________________________________________________________9 a. ^: I0 w7 \: b) v
沒有報警進行執行下面代碼,執行了終止命令,串口打印命令
4 c  J, d7 M) x+ u! a7 \         // Check amd execute realtime commands        校驗和執行實時命令
+ a9 }! g  T. A) _" a          rt_exec = sys_rt_exec_state; // Copy volatile sys_rt_exec_state
# q$ E! T# h7 z' `# [3 t% I7 _9 U; u. ^7 ^$ P. m3 G
        if (rt_exec) { // 輸入標志是正確的執行
3 j# N+ u  l0 ~! K/ ^! m1 ^% u; K5 t: \+ |5 E
            // Execute system abort. 執行系統終止命令& d/ [7 i3 O8 [5 `* f$ ^
            if (rt_exec & EXEC_RESET) {/ n6 M: P9 {7 R: r) ]
              sys.abort = true;  // Only place this is set true.
: O0 x, D/ E! o" N              return; // Nothing else to do but exit.! P/ X4 g; j- x. }( c+ c
        }
. g0 y; S6 z9 {( v8 C2 X! @
! ^1 q( W" p7 c+ E) t# Z# P            // Execute and serial print status 執行和串口打印狀態
$ N  j( S2 b) _4 M* s* y: `            if (rt_exec & EXEC_STATUS_REPORT) { ) y4 s! P+ R) s8 r0 f
              report_realtime_status();        //報告實時狀態
/ W9 p( \  K* K* F, ^$ e/ Q( x              bit_false_atomic(sys_rt_exec_state,EXEC_STATUS_REPORT);        //清除報告狀態清零6 g$ t5 M) m, Q6 Q8 t0 a" y2 u2 f' E9 r
            }2 f6 {0 I% V( \4 `# V
_____________________________________________________________________________
: ~5 K+ H2 _$ J: ]! a% M. h+ z, j下面代碼# ^% I) f, W" L# ~1 ^: d
//執行狀態。& R! G; _/ H6 R1 Z; n! N9 F3 A
//注意:所涉及的數學計算持有應該足夠低對大多數人來說,即使不是全部,
$ ~; O; M' W/ b//操作場景。一旦啟動,系統進入暫停狀態' g( Q; A1 l. l6 k
//主程序流程,直到重置或恢復。
. R! y$ p$ {; d' m" G) N待辦事項:檢查模式?如何處理呢?可能沒有,因為它只會在空閑,然后重置Grbl。
, T) v3 T+ g0 B, ?狀態檢查容許狀態的方法。
4 g- O( N2 `5 b2 k3 ]' V
+ `2 @# i9 H3 C: i5 \4 I        //如果全局各自報警標志位其中(執行取消動作) | (執行進給保持) | (執行安全門)任意一位為真進入: H! y" X# t' k+ b& W
            if (rt_exec & (EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR)) {       
- ?7 [( p9 a+ L( o. M1 Y' V6 Y- Z4 l0 Y$ U" B
        //如果是循環狀態執行暫停狀態  ?1 ?* j- Q! m; }0 ^
        if (sys.state == STATE_CYCLE) {
4 X1 h/ X. x/ V$ f0 k* x8 L+ m. N        st_update_plan_block_parameters(); //通知stepper module驗算減速。
! F, u, ]9 V* m        sys.suspend = SUSPEND_ENABLE_HOLD; // 開始暫停標志+ p7 m, R4 L# M: v3 L, F
        }
$ ]* M$ ]' A/ G& {
; F6 L$ d! [* p5 |! E        // 如果,Grbl空閑不在運動。簡單的指示暫停就緒狀態。
9 N0 K% Y5 m* U        if (sys.state == STATE_IDLE) { sys.suspend = SUSPEND_ENABLE_READY; }
  U5 ^1 @1 @1 U2 G  e6 N* Z
  w$ e5 S: L; L6 C
: e) P3 d1 M; S, Y7 _- g        //執行和標志和減速運動取消并返回空閑。主要由探測使用周期$ O( o5 Q: K5 T# t* \& \
        //停止和取消剩余的運動。      
: F* y, m$ O, R7 n0 N  J7 [) z. i        if (rt_exec & EXEC_MOTION_CANCEL) {1 [9 o7 c2 N8 e' x
          if (sys.state == STATE_CYCLE) { sys.state = STATE_MOTION_CANCEL; }/ I: T5 i8 }+ W: `0 Z, A, Z# F
          sys.suspend |= SUSPEND_MOTION_CANCEL;
3 c) _: a# M9 v" s4 f" q! F        }! ~- F) J. y1 v8 ]4 H

( b9 u9 r% [+ W6 D5 F        // 只在循環時執行進給保持減速
2 F, }  b7 q7 l2 y! M$ j+ q) F( C         if (rt_exec & EXEC_FEED_HOLD) {
1 a. V+ y2 P/ U& O6 P        //只有安全門為1才執行保持進給狀態賦值
2 y- K/ ?( y, o1 _          if (bit_isfalse(sys.state,STATE_SAFETY_DOOR)) { sys.state = STATE_HOLD; }
, S7 \+ i- h2 d9 O) P        }
- I$ m5 G+ [# a% w: J/ P7 R. G4 `0 Z4 Q# P/ h
        if (rt_exec & EXEC_SAFETY_DOOR) {
: }2 V- v1 I$ `" {! M1 j          report_feedback_message(MESSAGE_SAFETY_DOOR_AJAR); : G" x/ ?7 ~" ]5 ^! V
/ /如果已經活躍,準備好重新開始,CYCLE_STOP標志設置為強制斷開。& |8 y' J3 G7 `; b# b/ y  G% J
/ /注意:只是暫時設置“rt_exec”變量,不是動蕩的“rt_exec_state”變量。
% \. C: u6 h3 W. m          if (sys.suspend & SUSPEND_ENABLE_READY) { bit_true(rt_exec,EXEC_CYCLE_STOP); }
4 k" f- E/ w1 J  a& B& g          sys.suspend |= SUSPEND_ENERGIZE;
+ W  j, h, U, D          sys.state = STATE_SAFETY_DOOR;, a: `; V" z0 E
        }
0 i' R& V! K- {' B$ ^, E4 e8 c4 n+ y. r' K
bit_false_atomic(sys_rt_exec_state,(EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR));      K3 p2 S, R7 j* [' T
7 m. O$ Z( {4 _. B7 M( [
}+ w+ y( C. ~3 \+ O# r" a
以上代碼執行了
8 V% M# k0 G3 J) Z0 r1.如果全局各自報警標志位其中(執行取消動作) | (執行進給保持) | (執行安全門)任意一位為真進入
) T2 {( b/ P; D7 C2.系統為閑著狀態, 開始循環狀態, 回原點狀態, 控制取消狀態, 開始保持狀態, 開始安全門狀態時進入
# E& }# d& R( Q( m( |3.如果是循環狀態執行暫停狀態
0 O- @4 k$ R* u. {4.如果系統閑置狀態執行暫停就緒狀態; g" g, c# `0 R2 U1 j6 J1 G# Z* u7 L
5.執行動作取消* w, z8 Y6 B2 h2 B
6.如果是保持進給狀態,執行保持進給狀態6 }* l+ U' c+ ^# D
7.執行安全門狀態1 v* Y9 G7 @/ f) @% ?
最后執行bit_false_atomic清標志清除(執行取消動作)(執行進給保持)(執行安全門)標志位                  ; E5 `# d* Z7 o: `' v1 Y3 C5 e( H7 ^0 k* B
_____________________________________________________________________________
8 _* H4 K: k5 S4 ^) A) R% N7 j8 ~# f7 w* O1 U8 j' o: w6 ?
    // Execute a cycle start by starting the stepper interrupt to begin executing the blocks in queue.
9 [% U  D/ C+ @1 T2 A' `/ V  Z    // 執行一個循環開始啟動步進開始執行中斷隊列的街區1 v0 P& z# T. j5 F7 ?& M  g) I
    if (rt_exec & EXEC_CYCLE_START) {        //循環開始狀態進入6 b% `; s# O  a- E
      // Block if called at same time as the hold commands: feed hold, motion cancel, and safety door.
( q  O0 U$ Z! _+ ~( _8 P      // Ensures auto-cycle-start doesn't resume a hold without an explicit user-input.
6 `) T: U/ M7 t& `8 ^- I8 N          //塊如果在同時舉行的命令:保持進給,運動取消,和安全的門。 //確保auto-cycle-start沒有簡歷沒有顯式的用戶輸入。
1 h* C) w' _2 k' j- s          
2 [7 Y9 B4 {  r& o! O3 Z8 N      if (!(rt_exec & (EXEC_FEED_HOLD | EXEC_MOTION_CANCEL | EXEC_SAFETY_DOOR))) {   //狀態機如果不是保持進給,運動取消,和安全的門。 7 V, j' i7 N  q4 H
        // Cycle start only when IDLE or when a hold is complete and ready to resume.
7 e" A2 O8 `2 Q: o/ {1 {2 x        // NOTE: SAFETY_DOOR is implicitly blocked. It reverts to HOLD when the door is closed.* \. x: b: S8 E" N5 Z8 m" U
                //循環開始時只有當閑置或持有完成并準備簡歷。
5 ?7 K( R! ~0 o* A                //注意:SAFETY_DOOR是隱式地屏蔽。它返回的時候門是關閉的。   
/ B: C4 \1 p' T7 f8 N
' Z. `6 k7 `- G4 o# e) A+ g                // 如果系統狀態為閑著狀態,系統狀態為開始進給或運動取消,暫停標志為位重新開始
" }! P7 l' V- T        if ((sys.state == STATE_IDLE) || ((sys.state & (STATE_HOLD | STATE_MOTION_CANCEL)) && (sys.suspend & SUSPEND_ENABLE_READY))) {
+ B" L, ~- ~$ X          // Re-energize powered components, if disabled by SAFETY_DOOR.4 x" y, m- ]4 Y$ v; ^
          //        由SAFETY_DOOR重振組件供電,如果禁用。, n7 h  m$ E+ f( z% T# G
          if (sys.suspend & SUSPEND_ENERGIZE) { : O3 t* A4 \) \. s2 Q+ I$ v; _
            // Delayed Tasks: Restart spindle and coolant, delay to power-up, then resume cycle.# d$ R: [" g+ n. M: g. ]3 @. [# r/ [9 j
            //延遲任務:重新啟動主軸和冷卻劑,延遲升高,然后恢復周期。
6 O! ]2 r% @$ t( V/ O            if (gc_state.modal.spindle != SPINDLE_DISABLE) {   //主軸模式不是失能進入# v/ }* x& T+ A  q0 A% g4 V: c6 o
              spindle_set_state(gc_state.modal.spindle, gc_state.spindle_speed); //設置狀態和速度
7 f; J1 e: y2 M. @/ M. J5 h              //待辦事項:阻塞函數調用。最終需要一個非阻塞。' N/ M* j/ f; Z6 W& u+ o
                delay_ms(SAFETY_DOOR_SPINDLE_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.
" V5 H; \- k1 {            }9 n+ B- ?8 U, l1 T
            if (gc_state.modal.coolant != COOLANT_DISABLE) { 5 {2 f* ]% Z1 T. p, m. T3 O+ }
              coolant_set_state(gc_state.modal.coolant);
5 }( |1 J1 c2 v' C              delay_ms(SAFETY_DOOR_COOLANT_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.+ `/ M# V: R/ a/ M" a- \/ Q/ C
            }
4 L6 X7 ^3 e% y2 z+ I8 D            // TODO: Install return to pre-park position./ j* N! F7 D' k
          }! p( Y: `. |8 `' ?0 m% L
______________________________________________________________________________________________________________
2 D4 B* f  G' t) J) i9 e; n          // Start cycle only if queued motions exist in planner buffer and the motion is not canceled.
. T! E: d$ Y# X                  ' l/ ?/ a! L2 Q! u4 v! N7 }
                  //只有在隊列馬達存在規定的緩沖,并且動機沒有讓取消,才會循環
& s7 Z0 q3 K5 V$ ~: |: B/ N7 _                  
5 `, a. g6 b4 C6 e$ z* _          if (plan_get_current_block() && bit_isfalse(sys.suspend,SUSPEND_MOTION_CANCEL)) {. K: Y# f- {% V+ l8 Y. t8 `' P
            sys.state = STATE_CYCLE;, B0 H1 l2 _4 f+ n
            st_prep_buffer(); // Initialize step segment buffer before beginning cycle.初始化步開始循環之前
, X/ A  ?0 o. t; A4 K6 i' B# e            st_wake_up();
+ D2 c5 Y9 W# i, O          } else { // Otherwise, do nothing. Set and resume IDLE state.否則,什么也不做,設置和復位空閑模式5 S7 J( ^& m1 Z: {/ \9 f  y2 g* C
            sys.state = STATE_IDLE;
2 W: e3 ^3 k( ~/ ^          }5 _4 P& \- T: @5 A9 C; @4 U
          sys.suspend = SUSPEND_DISABLE; // Break suspend state.5 z; S/ w- q; l
        }
% ~. w* g) N( K" v' S5 G      }   
* Q  P/ C0 K1 ^0 U# Y      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_START);        + }% G% M% [5 i6 y9 }- o
    }
, z) M/ H: v+ N* f% Z1 p7 I6 L4 q" ~9 v
_______________________________________________________________________________________________________
' J" c! y) i5 J( d% D7 d    // Reinitializes the cycle plan and stepper system after a feed hold for a resume. Called by ! t2 t6 b0 N: s4 B
    // realtime command execution in the main program, ensuring that the planner re-plans safely.  z9 ~( P* D: J1 y. J- A, K7 E
    // NOTE: Bresenham algorithm variables are still maintained through both the planner and stepper
$ Z$ X: C* H) B& M6 W# a/ B    // cycle reinitializations. The stepper path should continue exactly as if nothing has happened.   0 r4 m) |( S8 x& x0 z" |. S& `
    // NOTE: EXEC_CYCLE_STOP is set by the stepper subsystem when a cycle or feed hold completes./ [% N6 I) `- g, {( F

& N2 f& K4 v/ O7 F1 i! L        //重新啟動后循環計劃和步進系統的進給保持簡歷。通過實時命令執行主程序,確保安全計劃重新計劃。
5 N7 o, S  `6 L4 A7 z        //注意:畫線算法變量仍保持通過規劃師和步進# {( j9 V3 R7 W; `6 v  I7 r
        //循環僅。步進路徑應該繼續,好像什么都沒發生一樣。       
! k& d7 v8 Z& u' X, h0 H( P/ C2 s        //注意:EXEC_CYCLE_STOP由步進子系統周期或進給保持時完成。2 o8 v/ e+ G! @
, P" l1 i  L; k& E
    if (rt_exec & EXEC_CYCLE_STOP) {                         //如果是循環停止狀態進入
5 k  ~1 K( z$ ~' h* h6 V9 T9 y      if (sys.state & (STATE_HOLD | STATE_SAFETY_DOOR)) {# ~3 G1 q" Y, S* W6 \9 M6 a
        // Hold complete. Set to indicate ready to resume.  Remain in HOLD or DOOR states until user
0 Q3 S" k2 q' V, T; G4 W# H        // has issued a resume command or reset.
) h/ Z. f% {9 s1 o4 P9 l& b% e' y  E; o5 H. a. i3 o4 i9 ~
                //保存完整。設置為指示準備簡歷。繼續持有或門狀態,直到用戶3 u/ K3 E1 k1 A7 y" U
                //已發布了一份簡歷命令或重置。
' C9 q9 A# K9 d, ]3 D3 @               
1 r+ y6 s$ G! Y/ s% C- z0 }        if (sys.suspend & SUSPEND_ENERGIZE) { // De-energize system if safety door has been opened. 如果安全的門已被打開。斷開系統
- X. c& l. ]# J( V, L6 r( k          spindle_stop();
; S0 W3 G! _7 \9 u. K          coolant_stop();# [9 ^/ K, U8 d- \) `/ S
          // TODO: Install parking motion here. 安裝停車動作。
9 Q3 |* @% B+ z0 l. _: ^        }9 j; }6 O. r4 a0 p
        bit_true(sys.suspend,SUSPEND_ENABLE_READY);3 h7 m( S5 {/ f, c* G- M; b2 F
      } else { // Motion is complete. Includes CYCLE, HOMING, and MOTION_CANCEL states. 電機完成,循環,回原點,,MOTION_CANCEL- ?( s1 J. z: j& f& ~( e
        sys.suspend = SUSPEND_DISABLE;
* N) ^- x7 ~& y9 b, A8 ^4 ~        sys.state = STATE_IDLE;& T8 p: Q3 i- u4 {0 d& ?  J
      }5 u7 P) V5 @1 k3 V
      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_STOP);3 c0 e9 m, M/ Z  u. O+ j( L* b
    }
3 l' D5 {4 N1 F3 {    * S4 @. U/ j  ]( `
  }* x+ W. M' P& t5 \
___________________________________________________________________________________________________
  k9 a, h9 J" Z2 R
' I! \4 n9 a- a$ W, o6 M  // Overrides flag byte (sys.override) and execution should be installed here, since they , c0 b# H  a1 T" ]3 M' p1 e
  // are realtime and require a direct and controlled interface to the main stepper program.. o; c. e# i& x9 Z% t! ]3 j" z# ]- c
$ E. M# G; _5 J7 `
  //重寫標志字節(sys.override)和執行應該安裝在這里,因為他們, b- L, R! p- n9 L4 u1 r- G5 Z
  //實時和需要直接和控制接口的主要步進程序。
* b  R/ r: ?1 b) p7 m: l3 n) ^+ B& z# ~7 `

7 @" w9 t& ~) D  // Reload step segment buffer 重新加載步段緩沖
6 r( L$ l, ]9 y7 W2 z: v  if (sys.state & (STATE_CYCLE | STATE_HOLD | STATE_MOTION_CANCEL | STATE_SAFETY_DOOR | STATE_HOMING)) { st_prep_buffer(); } ) B' l- N, {# h6 d  j' ^5 E* z  I  T
) o3 d$ y! m9 `! n: {
  // If safety door was opened, actively check when safety door is closed and ready to resume.
3 G  f6 }2 U8 E8 ~$ @5 t  // NOTE: This unlocks the SAFETY_DOOR state to a HOLD state, such that CYCLE_START can activate a resume.       
1 q  u' n1 z+ ]! U0 [
5 k8 J$ T) _& h( T6 R9 k0 E+ q//如果安全的門被打開,積極檢查當安全門關閉,準備簡歷。- V& Z- `) {" g
  //注意:這解鎖SAFETY_DOOR狀態保持狀態,這樣CYCLE_START可以激活一個簡歷。
4 L: G! P; L$ e5 t! S( G
& c6 H) n. Q  J  t  if (sys.state == STATE_SAFETY_DOOR) {                 //安全門狀態進入
0 ~% O2 E- t: e' K    if (bit_istrue(sys.suspend,SUSPEND_ENABLE_READY)) { - o! n2 A" ~" i
      if (!(system_check_safety_door_ajar())) {
: y* J+ m. `" w  U5 ^        sys.state = STATE_HOLD; // Update to HOLD state to indicate door is closed and ready to resume. 更新保存狀態指示門關閉,準備簡歷。) i& X+ U) l: u# \0 Q# K- f
      }4 S- R( `6 y9 b* o
    }4 O. {1 G& B( P( ]2 v$ z' I, B
  }0 k3 ?9 G: X8 [! K3 f9 x: ~

0 H) p7 g* }2 v; W& y1 h  } while(sys.suspend); // Check for system suspend state before exiting.0 S/ f3 M& E+ K9 x
  5 I! H) u% j" H8 q3 U
}  
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-7-6 21:41 , Processed in 0.100012 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.5 Licensed

© 2001-2025 Discuz! Team.

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