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

 找回密碼
 注冊會員

QQ登錄

只需一步,快速開始

搜索
查看: 19136|回復: 15

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

[復制鏈接]
1#
發表于 2016-8-20 23:56:23 | 只看該作者 |倒序瀏覽 |閱讀模式
本帖最后由 1五湖四海1 于 2016-8-21 00:09 編輯 * z0 _5 u. F! ?8 p9 ?) d
& @1 R  n! L5 v# C
    以前制作過CNC雕刻機,是用MACH3作為上位機控制,硬件是采用PC接并口輸出脈沖和方向使能信號經過隔離驅動步進電機驅動器,步進電機驅動是采用TB6560芯片控制。最后就接到步進電機。機械是用鋁合金制作,主要部件有三個1605的滾珠絲杠,多個運動滑塊等制作。用這臺DIY CNC雕刻機可以雕刻木頭塑料等東西。當時沒有一直玩下去,現在發現網上有用單片機制作的雕刻機挺精巧的現在分享給大家。4 o$ }' W" H  \5 _. D- W8 n
   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 @7 b9 H! J: C" Q    還沒有雕刻機的機械部分可以用廢舊光驅制作個微型雕刻機運動平臺。雕刻機最重要的是主控程序這次用 Arduino/AVR328單片機,價格在15元左右,主控程序是上面提到的目前很火的開源
的GRBL,還有一種基于STM32平臺的開源主控程序Dlion也不錯可以替代grbl。如果從性能比較這兩個方案,顯然是stm32平臺運行速度更快畢竟他是32單片機呀!! V5 Y- `/ J5 u" ?

/ J8 M0 N; R+ [9 G1 P. d

6 O. Y1 m* b( M9 j% n7 O    下面介紹小這個些主控程序主要干的事,通過串口PC和主控板通訊,PC命令給控制板,控制板接收命令做不同的響應,PC可以發G代碼給主控板,接收完成后可以自動開始雕刻任務。: G+ K! w# J& h: @5 @+ h
          在介紹下G代碼因為G代碼是雕刻機的核心部分
4 `, P8 `* V; e4 p+ [+ I3 OG代碼是數控程序中的指令。一般都稱為G指令。
; o( i6 _" ~+ i& sG00------快速定位
  x/ O6 i) h' T& n6 _  I7 KG01------直線插補
% t4 @3 {) q8 u: m% b4 e) XG02------順時針方向圓弧插補7 m2 R. z& C' K$ C, d6 {& l
G03------逆時針方向圓弧插補4 s7 ~. u2 h1 O: i
G04------定時暫停" l/ O9 D5 @+ @" v
G05------通過中間點圓弧插補
. u7 l5 x. C/ k8 v" j; s5 bG06------拋物線插補' W  b% M: [! U: N9 V
G07------Z 樣條曲線插補
: L7 u7 Z4 e4 I; D; T0 r- |G08------進給加速
8 m% g, @8 D- F1 m: q' Z. UG09------進給減速
$ _# R) Y  j4 T9 AG10------數據設置* t: i7 y8 M6 T2 |0 O
G16------極坐標編程
' ?  q+ t* y" P% S" {7 f/ x' {G17------加工XY平面
/ n; f* E6 {; g* q" u- SG18------加工XZ平面
. ?/ V: ^$ U# I: ~, J! v' y$ RG19------加工YZ平面
: w. q, r5 B$ u6 z) |
核心就是解析G代碼,完成步進電機驅動,和控制主軸開啟關閉,還有插補算法,直線插補,圓弧插補,還有一些步進電機的加減速算法。, H- P' F7 X/ |& ~
下面對grbl主結構做介紹3 W; P1 Z2 g# m
main()主函數首先執行下面初始化函數
) U+ w0 @2 _0 a! `7 P        serial_init();                           // 設置串口波特率和中斷2 N/ @. R; K& j9 ~3 k
        settings_init();                         // 從ROM加載grbl設置( D* n1 _: d7 G3 G- f, t9 b
        stepper_init();                          // 配置步進方向和中斷定時器; d% y) K- q; z9 h
        system_init();                           // 配置引腳分配別針和pin-change中斷% R( y# T* A2 u7 j$ z; P& I$ D& t
        memset(&sys, 0, sizeof(system_t));          // 清除所有系統變量
( C% W- c; R2 s: D7 @' l2 a. b        sys.abort = true;                           // 中止標識位置位! w, g3 A8 Q8 D/ _
        sei();                                         // 使能中斷
' n. f# }. E5 L6 `' ?) o  #ifdef HOMING_INIT_LOCK                        // 宏運算(settings.flags & (1 << 4)) != 0結果flags等于執行sys.state = STATE_ALARM
6 I  S4 F+ C, e; i1 f                                                // 系統狀態賦值為報警狀態. V9 w/ U9 p5 _+ C
            if (bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE)) { sys.state = STATE_ALARM; }( g1 ~) O1 Z/ X# o1 i6 ?6 e2 @( X. Y
  #endif% d: I9 L  C$ _8 w
_____________________________________________________________________________________________________________________________________
3 @7 s7 r4 z% K5 `# b5 _3 @接下來是一些主要部分初始化
2 s, T0 R2 U2 N+ l5 a' ifor(;;) {$ a& f9 c7 Y) q; r; r
        serial_reset_read_buffer();         //清除串口讀緩沖區" J( v$ o- D- Q% m$ r
        gc_init();                         //初始化G代碼功能函數5 K' r7 O5 X- @" d* P  B1 q8 U" ~
        spindle_init();                        //主軸初始化' c4 l: O6 i- H' M
        coolant_init();                        //冷卻液初始化
) A& G' s( P+ H8 i& ?5 ^8 ?        limits_init();                         //極限開關初始化$ g/ M, Q# U2 @  l! {4 L
        probe_init();                        //探測部件初始化/ U2 E5 X2 j" X. _/ B1 O6 A
        plan_reset();                         //清除塊緩沖區和規劃師變量
4 H% |$ G9 [2 P& B        st_reset();                         //清除步進系統變量。
$ C+ H5 o/ N# [  _3 k
! r) e3 d! I! n$ H* o) V8 n, e) U8 _8 J
        //下面兩行清除同步gcode和策劃師職位當前系統位置。, s( V! Z, Q0 Z- G  I
        plan_sync_position();
5 B& v8 M4 H: E, W  ]        gc_sync_position();
7 N+ y1 `$ F0 }3 E; ^: e2 e8 {. r
6 y5 E4 G/ X5 A* u
8 w, H0 R6 Z/ }; A3 I* ~" H7 L0 B        //復位系統變量$ B+ \6 B7 U7 r" x' o! M- w* P8 {
        sys.abort = false;                //系統中止標志' ?; A8 x9 U" @, R( E
        sys_rt_exec_state = 0;                //系統標志位變量狀態管理。看到EXEC位掩碼。- K3 f9 e! G/ H* ]; F7 a9 |; I; h
        sys_rt_exec_alarm = 0;                //系統標志位變量設置不同的警報。5 I3 B* r+ o& I  D4 o  ?
        sys.suspend = false;                //系統暫停標志位變量管理,取消,和安全保護。
$ I. f9 J# u& I" r& L        sys.soft_limit = false;                //限位開關限制狀態機錯誤。(布爾)$ t6 [: f( I# h* @' C. J+ C0 N

8 @' I8 U. g4 V: L' A# `1 |, m
7 C" H* w# J. r. ?2 ~7 r6 s8 K2 s        protocol_main_loop();                //主協議循環
7 d1 F; d+ G( |}        //
1 L- i% k9 Z/ o8 p* n_____________________________________________________________________________________________________________________________; b7 N" a: }* [( y% Y, P/ g: ?
進入void protocol_main_loop()函數
. s( Q3 F3 ?7 A- k1 i{
# v9 X3 f# Y% k4 d6 J8 p- r4 ]        report_init_message();                // 打印歡迎信息 * s  _0 Z% }" W$ k6 a
        //重啟后檢驗和報告報警狀態如果錯誤重啟初始化。
9 Q( q& T1 A  {4 I+ ?) g3 R0 K) _
        if (sys.state == STATE_ALARM) {4 @" t4 Y: C) t. l# P) T: a
            report_feedback_message(MESSAGE_ALARM_LOCK); //打印信息" [; ]% v- j/ [7 C4 l# J3 ?
          } else {
7 b# t5 B! R7 ^/ t2 ^6 T* R/ D            // 如果沒有報警說明一切正常!但還是要檢查安全門.
2 i: {7 f( K: ~# H) O* `            if (system_check_safety_door_ajar()) {* U, W: p1 q2 z
                     bit_true(sys_rt_exec_state, EXEC_SAFETY_DOOR);
) w9 W' B  v1 f0 k7 U                     protocol_execute_realtime(); // 進入安全模式。應該返回空閑狀態。- x/ _2 K8 O) S$ }. v
            }         else {
) k# f; v: n8 T4 q$ I3 e0 x              sys.state = STATE_IDLE; // .設置系統做好準備。清除所有國家國旗。4 `/ z0 {' I6 v+ ~  j% I* i3 R
            }
, ?7 ~  U0 Z6 a3 D( a/ |5 E            system_execute_startup(line);    //開始執行系統腳本+ K- G' o* m% H5 E4 U" u
  } , n' Y0 ~; E! Q+ ^# F# Q: g

  i/ A! y! O, h, r) V2 D, a
. N! K) v) M" K; C  // 這是主循環!在系統中止時這是出口回到主函數來重置系統。
: y" p9 r* ]0 [  S& V1 L  // ---------------------------------------------------------------------------------  
  s+ L. V9 q: P$ R4 A  ( m0 n; I$ L3 y0 ]9 a
        uint8_t comment = COMMENT_NONE;
; l8 @1 `$ O! p; P3 ~; d        uint8_t char_counter = 0;
% g& I' y  D2 l( f$ N        uint8_t c;
; x* j* |6 K) e: Q_______________________________________________________________________________________________________________________________6 x  O2 C4 o$ a# l- ?8 x
接下來進入for(;;)循環                //下面代碼是G代碼解析核心部分,程序中comment(注釋)變量會被賦不同值,代表發符號有‘(’‘)’‘;’; [8 H& n/ W( A! V- S5 f
{
" K) Y% l! E. e! N7 J- e* o//串行數據輸入一行的的過程,作為數據。執行一個% b* L, Y- P1 x* f, e
//所有數據初始過濾去除空格和注釋。 9 T, ~* W2 g1 `) Y1 q
//注意:注釋,空格和程序段刪除(如果支持的話)處理技術
  R! w- M; X0 U' q; g2 v% F//在G代碼解析器,它有助于壓縮到Grbl傳入的數據
* C' C! Q  A/ A2 Z5 v1 b( b//線緩沖區,這是有限的。刀位點標準實際上州一行不行  d6 i. e: N# I2 u8 g& }. G, K
//不能超過256個字符,Arduino Uno沒有更多內存空間。
$ G7 O- o7 E- Y5 W; U7 B//有更好的處理器,它會很容易把這個初步解析的% E# r* C. j5 W. L
//分離任務共享的刀位點解析器和Grbl系統命令。                                                               
) V2 v" l, b1 s    while((c = serial_read()) != SERIAL_NO_DATA) {                             //讀取串口數據,有數據執行下面代碼; H7 n; B2 p8 L0 G. i( ^3 {
      if ((c == '\n') || (c == '\r')) { // End of line reached                //如果數據是/r,/n代表一行結束; \- e$ S0 m) M7 |6 ]
        line[char_counter] = 0; // Set string termination character.        //設置結束標志( }# F+ K3 u) x! L( v8 A& X
        protocol_execute_line(line); // Line is complete. Execute it!        //一行完成執行此函數
( W. W+ I5 X7 _+ P* |        comment = COMMENT_NONE;                                                //注釋清零
" q) i3 Z) {7 g' R% p" j        char_counter = 0;                                                    //字符計數清零5 ^( }6 v5 C" z, |( q
  
8 F2 q4 u: M8 L3 v, Q$ c        else {
0 y# c+ e/ w( K: {, l; f        if (comment != COMMENT_NONE) {. k2 S; z) R/ h! I& F2 [' Y5 v
                                                     //扔掉所有注釋字符
0 q: D+ t8 ^( s. c. L: K          if (c == ')') {. [# {0 J+ ]" ?
            //最后注釋。重新開始。但是如果有分號類型的注釋。  `4 ~. A, ?. q; |$ d; ~
            if (comment == COMMENT_TYPE_PARENTHESES) { comment = COMMENT_NONE; }
) j$ f4 V3 d: A( [          }( D4 T9 C. _4 ~% z9 m9 u
      } else {( F+ n1 A- i: G% ~( O
          if (c <= ' ') {
! a7 t& \! ?* h& _. K( q            //扔掉whitepace和控制字符6 [# e) h, @' M$ c. i1 k
          } else if (c == '/') {
! C. W) }5 L# P( d* X! N5 ]            //塊刪除不支持將忽略字符。/ n/ O+ z* p0 X- y' f4 x. b  n
            //注意:如果支持,只需要檢查系統是否啟用了塊刪除。
5 P* O9 P+ B0 v7 J" n          } else if (c == '(') {
$ L& g0 z6 @. b. k2 F0 |            // Enable comments flag and ignore all characters until ')' or EOL.4 D9 _# ?5 |$ c) R
            // NOTE: This doesn't follow the NIST definition exactly, but is good enough for now.' ^0 M# a, w. H0 I' D
            // In the future, we could simply remove the items within the comments, but retain the
, x0 z7 t) R- q4 `. c8 i, R5 C            // comment control characters, so that the g-code parser can error-check it.
- ^. F2 M+ p6 u: P" C+ ~            comment = COMMENT_TYPE_PARENTHESES;
% ^9 B. M4 x, Z2 j# H          } else if (c == ';') {" f& Z, @- V. ^! _
            //注意:','注釋EOL LinuxCNC定義。沒有國家標準。" w/ S; i8 M' f1 V7 y
            comment = COMMENT_TYPE_SEMICOLON;
: x; u2 R& V7 [/ N/ p! g3 m! G5 I
( d: P/ }; b$ N- M7 K& q  V8 ?6 R; Z5 j' [) `
_____________________________________________________________________________________________________________________________________
1 S  q/ p3 a) U) F0 Y' X8 j          } else if (char_counter >= (LINE_BUFFER_SIZE-1)) {                        //串口接收數據大于80字符時6 D5 E+ u& {6 k0 h! t  o/ f% F
            // Detect line buffer overflow. Report error and reset line buffer.        檢測緩沖區溢出。報告錯誤和復位線緩沖區。
) ~& L. u# Y- I; m            report_status_message(STATUS_OVERFLOW);                                //打印溢出信息2 F  O: \% i4 z9 v; {7 r
            comment = COMMENT_NONE;( g$ M) W1 B% Y6 d8 v2 g
            char_counter = 0;) p" Y1 V' a2 V5 f5 M6 v2 _; W% M/ Q
          } else if (c >= 'a' && c <= 'z') { // Upcase lowercase                        //小寫改大寫
' M1 ?/ J8 M3 a- z9 s$ {* @3 O! u            line[char_counter++] = c-'a'+'A';
3 L, I7 c4 U; c0 l! u          } else {2 r. @2 g' l( T1 n9 r% J, Q. V1 x
            line[char_counter++] = c;- D8 E7 ^7 w. ]! k7 l
          }
' a0 p# }9 m/ I. t7 J5 |) e4 K# b        }/ s% K8 T# a; C+ r; @0 z* z. u6 t' T
      }5 W& h- h% b. v4 n4 b
    }
9 N5 s. a2 v$ ~2 Z; z; y____________________________________________________________________________________________________________________________________0 h/ Z" l, l% p; T7 [
        //如果沒有其他字符在串行處理讀取緩沖區和執行,這表明以完成,自動啟動,如果啟用,任何隊列動作。
4 c+ B6 _% O# l) L        protocol_auto_cycle_start();                //自動開始協議循環& K" i  f7 n& y: i) |
        1 Y2 l' ?* ~6 q# m/ W5 Q/ f
            protocol_execute_realtime();                  //運行實時命令。
; e6 o. |: Q) K# h0 A( t            if (sys.abort) { return; }                 //中止標識置位程序循環重置系統。            
& V2 K. k# B6 m  } # Z+ a# P) ?$ c3 f
  return;                         //一般程序不會執行到這里8 R# M9 ~8 h4 }0 r9 C% q
}2 B" A7 F, K* }( N6 |6 ~
____________________________________________________________________________________________________________________________________
: U( l% M$ O4 X/ R0 [! z3 V# v正常情況下,讀取完G代碼程序會進入protocol_auto_cycle_start();//自動開始協議循環 函數下面介紹此函數+ a) I& s: x* x- f/ H; o& G% t, R
// Auto-cycle start has two purposes: 1. Resumes a plan_synchronize() call from a function that
1 G% r  X8 U/ b; C. Q// requires the planner buffer to empty (spindle enable, dwell, etc.) 2. As a user setting that   @* K* Z+ E; T5 d" l9 s2 g
// automatically begins the cycle when a user enters a valid motion command manually. This is
4 u; q& {5 M" N4 I+ Z3 o$ K// intended as a beginners feature to help new users to understand g-code. It can be disabled
: r/ X' r' ]; u& i& ?: g// as a beginner tool, but (1.) still operates. If disabled, the operation of cycle start is- U& [$ m$ }* k# J
// manually issuing a cycle start command whenever the user is ready and there is a valid motion 6 ~- W8 b5 T' u) w% I6 h$ P8 V  H
// command in the planner queue.
: D0 Q2 i8 W, E* |* v// NOTE: This function is called from the main loop, buffer sync, and mc_line() only and executes
1 `, a" w- Q  o+ l( R. i7 O// when one of these conditions exist respectively: There are no more blocks sent (i.e. streaming ( z# Y# v7 k/ v& ~" }' }1 e
// is finished, single commands), a command that needs to wait for the motions in the buffer to * ^9 \: O1 L! Y& F( b9 [
// execute calls a buffer sync, or the planner buffer is full and ready to go.& Z+ r0 l" q) b$ z! e& \0 D
//自動開始有兩個目的:1。回復一個plan_synchronize()調用的函數
8 r9 ?" L0 V) l( u//需要規劃師緩沖區空(主軸啟用、住等)2。作為一個用戶設置
# S2 m9 E5 @% x# \; E2 q. X6 ~  n2 O//自動循環開始當一個用戶輸入一個有效的運動命令手動。這是
1 `0 F& [$ }$ ^" l  K//作為一個初學者的特性來幫助新用戶了解刀位點。它可以被禁用
/ Q7 _0 a: f. m: e//作為一個初學者工具,但(1)仍然運作。如果禁用,運行周期開始
) i% j  t/ Y$ C/ ^( J# ]//手動發出一個周期開始命令每當用戶準備好,有一個有效的運動( `# _' ~- S7 W" _9 U+ G5 N
//命令的規劃師隊列。
9 w  O! F& r( \) B8 \//注意:這個函數被稱為從主循環緩沖區同步,mc_line只()并執行
, s7 i6 j3 v9 t( m//當其中一個條件分別存在:沒有更多的塊(即流發送2 P% U6 l+ o3 W6 n6 |8 c4 e
//完成后,單一的命令),一個命令,需要等待緩沖的動作( n; o8 e- X- M) O
//執行調用一個緩沖區同步,或規劃師緩沖區滿了,準備好了。1 Y! @. c: D6 X' w- F* X" {6 d
void protocol_auto_cycle_start() { bit_true_atomic(sys_rt_exec_state, EXEC_CYCLE_START); } ' `0 o" C: W+ E4 j$ d
_______________________________________________________________________________________________) P+ l+ M  F7 _4 b( d" \
接下來程序運行protocol_execute_realtime(); /運行實時命令。* P1 H( d; S, {- W
// Executes run-time commands, when required. This is called from various check points in the main$ B0 l' E* Y" l0 ~
// program, primarily where there may be a while loop waiting for a buffer to clear space or any* P. O2 a$ c5 n7 `, j8 c
// point where the execution time from the last check point may be more than a fraction of a second." Z  I; P3 Z9 b$ l- b9 d
// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code
) t: y3 L; Y+ ]2 @// parsing and planning functions. This function also serves as an interface for the interrupts to 8 e' c. i+ i$ H- J: o, Z
// set the system realtime flags, where only the main program handles them, removing the need to
! i$ p$ |4 K. l4 r$ p) X// define more computationally-expensive volatile variables. This also provides a controlled way to
, b7 u. e) y$ \9 @, V2 P* f) q0 a// execute certain tasks without having two or more instances of the same task, such as the planner
; y/ Z/ ]  w5 V2 V8 N// recalculating the buffer upon a feedhold or override., ^  R7 \4 {3 S2 K9 @! H
// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,
$ l7 j) e+ e4 b, o// limit switches, or the main program.
. i/ r& C5 X  l4 ]8 d* t* Uvoid protocol_execute_realtime()
9 P; O% h. {; d7 t uint8_t rt_exec; // Temp variable to avoid calling volatile multiple times.臨時變量來避免多次調用不穩定。, Y0 m6 O0 |  i4 k7 E2 d+ U8 F
就先分享到這吧!
, B1 r# G6 M& a6 w% [0 i
: L: f. I1 E1 Q/ `( R/ v% _+ Z
) f+ y+ z# F2 ~- \' L; y' Z# T* R# {4 B% z$ |/ D

4 v) y; t# K5 S, g# h' r! ]+ }5 f. a! S$ I$ U5 k

8 P, N3 }) H" h: y: o8 Z% ^2 l! x$ n9 [: D0 I+ s
4 k% Y2 s2 }( i! ^+ U
4 X! |  ~5 Z8 v
' g$ P# R" G8 h* W& `# ^( J

, C6 s! X, k% m& V( t* ?
1 P* M# w( J/ O; x! K2 G7 h/ C
" u) ]+ G3 y$ j1 P+ J, _
* _: B1 O5 ]9 Q: h. t) t! r4 ?; U% J
1 X3 U; }9 g7 L1 B; s6 d# J# E- ?: I3 ]( ~! @, @9 [+ j- ^

) s% U/ {: [0 U* r2 X7 ?7 n8 l2 r0 N; S" w- z7 y2 G% r- k

, r8 m3 Z, f  |! o

9 H8 `+ O% \7 p' y* I$ p  O7 `! _* @! t" g, ~# z# m% Z0 b
. F) v0 o& l# H, M
7 a3 x7 H4 `/ \* ~9 z4 g
補充內容 (2016-8-25 22:40):
- ~- H' _2 y9 L配置說明
$ l* u# F( @7 w. I" q//這個文件包含編譯時配置Grbl的內部系統。在大多數情況下,
- ]- U1 z  n( ?- K7 A//用戶不需要直接修改這些,但是他們在這里為特定的需求,即。2 |: O: f9 K3 I0 U
//性能調優或適應非典型的機器。" f; T: s9 |6 c
主要配置項:
4 w6 H: G  b7 s1.#define DEFAULTS_GENERIC        //在重置eepm時使用。在defaults.h改變想要的名字4 h0 H0 F* V( X  l. _4 D+ J
2.#define BAUD_RATE 115200        //配置串口波特率115200' i& Q3 u) {( ?1 O
3.#define CPU_MAP_ATMEGA328P         // Arduino Uno CPU
7 a& d3 t& Z" {  u$ d4.#define CMD_STATUS_REPORT '?'        //定義實時命令特殊字符
2 ~( S% j2 t& i  _* W7 c, D3 o5.#define HOMING_INIT_LOCK         //回原點保護鎖7 [' j0 `3 U  s8 j3 d0 S
6.#define HOMING_CYCLE_0 (1<<Z_AXIS)              // 第一步Z清除工作區。1 h4 U+ O# M0 C4 Y/ u* Y
  #define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // 然后X,Y在同一時間。6 G& ?$ ?4 u: M8 e/ x
7.#define N_HOMING_LOCATE_CYCLE 1 //回原點循環次數. W. a3 F" y# w) @; U; `
8.#define HOMING_FORCE_SET_ORIGIN //取消這定義迫使Grbl總是在這時候位置設置機器原點盡管開關方向。7 t  o+ b, R3 w. }1 s
9.#define N_STARTUP_LINE 2 //塊Grbl啟動時執行的數量。
( n/ S) z3 ], w10.#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 協調或位置價值英寸
4 _) l7 [) J5 g# G9 C' e   #define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 協調在毫米或位置價值  t. g# |- r5 i/ g
   #define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分鐘的速度值) x$ K1 C6 p. V- O; O
   #define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分鐘
& c& v, p' ?/ a   #define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 對浮點小數設置值
5 {9 z; h# t7 K, P11.#define LIMITS_TWO_SWITCHES_ON_AXES //如果你的機器有兩個極限開關連接在平行于一個軸,您需要啟用這個特性
/ u, Y8 P! v: C12.#define USE_LINE_NUMBERS         //允許GRBL跟蹤和報告gcode行號
! j! j" F- w, {! V3 G. H' H# m13.#define REPORT_REALTIME_RATE //允許GRBL報告實時進給速率
8 V) w, t4 L2 n, X- |3 [14.#define MESSAGE_PROBE_COORDINATES  //坐標通過Grbl $ #的打印參數?
# ~( ^" @# G; o6 |0 s" f* c9 {15.#define SAFETY_DOOR_SPINDLE_DELAY 4000 //安全門主軸延時
" }1 E# Y9 g- V; m& H8 {2 U- ^* g16.#define SAFETY_DOOR_COOLANT_DELAY 1000 //安全門冷卻液延時
+ t- M9 k4 ^/ T' J! Z' o17.#define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS) //啟用CoreXY運動學。$ R/ e' ^# d2 ?, J/ H
18.#define COREXY // Default disabled. Uncomment to enable.改變X和Y軸的運動原理
- l# |. M+ N' m0 o  r19.#define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.反轉針銷邏輯的控制命令
4 u5 n% C" [0 U( [6 q. |" Y20.#define INVERT_SPINDLE_ENABLE_PIN // 反轉主軸使銷從low-disabled  }6 f, o. r! h4 P, M, M% z" Z3 p
21.#define REPORT_CONTROL_PIN_STATE //啟用控制銷狀態反饋狀態報告。
/ v/ h2 }/ B* ?' t2 a22.#define FORCE_INITIALIZATION_ALARM //啟用和用戶安裝限位開關,Grbl將啟動報警狀態指示
1 a: G2 }5 A8 e) m3 |23.#define REPORT_GUI_MODE // gui允許最小的報告反饋模式/ v/ v+ T9 L1 l1 a6 K9 I( x
24.#define ACCELERATION_TICKS_PER_SECOND 100 //加速度的時間分辨率管理子系統。. \4 h9 X$ H5 h0 h1 |( W
25.#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING //自適應多軸步平滑(積累)是一種先進的功能 $ J2 T" t" q: t
26.#define MAX_STEP_RATE_HZ 30000 //設置最大一步速率可以寫成Grbl設置$ d1 ?  E0 t" f; `4 }( M8 E. K* x! w
27.#define DISABLE_LIMIT_PIN_PULL_UP //以下選項禁用內部上拉電阻3 ^1 p& |# H2 u5 x. h* E2 f
28.#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS //設置哪個軸長度補償應用的工具。假設軸總是與選擇軸工具面向負方向! s% U9 e; |+ B% [8 {
29.#define VARIABLE_SPINDLE //允許變量軸輸出電壓不同的轉速值。  ]) A5 j7 c( }+ h1 U& Z+ Y9 d
30.#define SPINDLE_MAX_RPM 1000.0  // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.
- a( M+ G0 D0 @; B% @   #define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.
* t2 z6 R4 o& H31.#define MINIMUM_SPINDLE_PWM 5 //使用的變量軸輸出。這迫使PWM輸出最小占空比時啟用。* Q: S7 ?$ o# \, I2 S
32.#define USE_SPINDLE_DIR_AS_ENABLE_PIN //主軸方向使能M4被刪除
. Z3 s, q; R7 V6 a. R33.#define REPORT_ECHO_LINE_RECEIVED //應該對所有正常線路送到Grbl
+ b+ t0 ?9 {1 u% k34.#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min) //最小規劃師結速度。設置默認最小連接速度規劃計劃
5 h, ^5 m; }1 G0 w5 M4 S& w35.#define MINIMUM_FEED_RATE 1.0 // (mm/min)//設置計劃將允許的最小進給速率
+ [; S0 S! ~4 t3 A36.#define N_ARC_CORRECTION 12 //弧生成迭代次數之前小角度近似精確的弧線軌跡! B' s! u- I: s5 A
37.#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)//定義值設置機器ε截止來確定電弧是一個原點了?
- r# a4 O3 W# P8 Y& Z! B38.#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds) //延時增加表現在住。默認值設置為50毫秒2 C: v: j- t) X9 v# O# `* q* [
39.#define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.
% t0 ]7 @4 u( `- R) Q4 h40.#define BLOCK_BUFFER_SIZE 18  //線性運動規劃師緩沖區的數量在任何給出時間計劃6 T! H3 z1 I) w9 i5 k
41.#define SEGMENT_BUFFER_SIZE 6 //控制之間的中間段緩沖大小的步驟執行算法
2 }, v, U) p9 P; o( t0 O42.#define LINE_BUFFER_SIZE 80 //行執行串行輸入流的緩沖區大小。: Q) }* G4 N9 P6 O8 n( D
43.define RX_BUFFER_SIZE 128 //串行發送和接收緩沖區大小) i! k1 }7 W. l9 |- m
44.#define TX_BUFFER_SIZE 64# n5 J9 _6 a- d/ Q- {4 y
45.#define ENABLE_XONXOFF        ////切換為串行通信發送流軟件流控制。% O, E  U/ A, L/ l  r3 N7 }
46.#define ENABLE_SOFTWARE_DEBOUNCE //一個簡單的軟件消除抖動特性硬限位開關。
( t: w5 H( K; M/ v4 @* b3 w47.#define HARD_LIMIT_FORCE_STATE_CHECK        //Grbl檢查硬限位開關的狀態
1 a: S1 Y. B& @9 H; i/ [48.// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:編譯時錯誤檢查的定義值:
3 k! K/ x# C) {" `  K" ?" P1 q' A2 l  `& ~* z
___________________________________________________________________________________________________
# p- {; b9 f- f  p# W- b6 Y- N7 g# w6 U/*
' K& W* B# T, ]1 K% g  config.h - compile time configuration) _8 @2 C4 n0 @
  Part of Grbl2 A$ x  p1 R$ P  @0 P& S
  Y' c) \  E* _( E4 P
  Copyright (c) 2012-2015 Sungeun K. Jeon
4 }  t$ u2 u8 S4 R  Copyright (c) 2009-2011 Simen Svale Skogsrud
; t& ~6 c$ X. Y" K1 R
9 y  C$ d2 l+ v5 S; w; J  Grbl is free software: you can redistribute it and/or modify
$ q; E0 y2 T7 Q5 G  it under the terms of the GNU General Public License as published by
4 z6 K( Q- ]' i  the Free Software Foundation, either version 3 of the License, or8 \0 F! W( O. C: [. H, c7 L
  (at your option) any later version.
, q6 j. a2 ^" X; O- ?. x
* [. Y3 U; H( u" I  Grbl is distributed in the hope that it will be useful,
" n4 c: R* i4 S" F  but WITHOUT ANY WARRANTY; without even the implied warranty of4 l# V: I- S! p5 P' V! t, K
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
; W$ m6 i5 U) X6 q  GNU General Public License for more details., G& ]2 x# H% I; T

) D9 V% w( z; j8 R) o+ \  You should have received a copy of the GNU General Public License
$ A, F, G  o( w8 \  along with Grbl.  If not, see <http://www.gnu.org/licenses/>.# W- W  L8 Y* y9 t2 c
config.h  -編譯時配置,Grbl的一部分
, Q4 d8 R; ]0 k1 e8 P7 p* y# ~3 D
" `$ `4 u" w  u5 P2 S版權(c)2012 - 2015 Sungeun K. Jeon, o. @8 ^- z) D  T
版權(c)2009 - 2011 Simen Svale Skogsrud
6 m0 ?' \3 t" y
$ C+ Q5 A+ o' AGrbl是免費軟件:可以重新分配和/或修改, T1 L, T' G3 [. D4 S
GNU通用公共許可證的條款下發布的自由軟件基金會,版本3的許可,或(任您選)其后的版本。; \+ l  O/ T( |& p: N
9 B9 P2 r! X! G* Q- r6 d
Grbl分布,希望這將是有用的,但是沒有任何保證;沒有即使的默示保證適銷性或健身為特定目的。看到
8 Z( K' o1 H, q# @  s7 Y# cGNU通用公共許可證的更多細節。' I+ Z# D8 h" g! d( i
+ {: m" j! w- B. s8 H7 V8 n2 ~
你應該收到了GNU通用公共許可證的副本
- z' K6 N! n% ]* t' Z7 @連同Grbl。如果沒有,看< http://www.gnu.org/licenses/ >。
3 s/ _( |6 J: H; I2 ~+ ], t
5 M- A5 `4 A1 Z*/! g" W  p1 u  @
  
5 n9 e: z' J8 w- _5 \// This file contains compile-time configurations for Grbl's internal system. For the most part,
; F$ a, f: u: N# v; y) }// users will not need to directly modify these, but they are here for specific needs, i.e.
1 }: T2 t) N$ u$ b7 [2 p; r, T4 c// performance tuning or adjusting to non-typical machines.+ R  f. g  Q+ e. x  J! q# m6 g8 K
//這個文件包含編譯時配置Grbl的內部系統。在大多數情況下,
' H' R) M( }5 |2 y7 H//用戶不需要直接修改這些,但是他們在這里為特定的需求,即。7 ?: }& H. \) N$ |$ t
//性能調優或適應非典型的機器。5 z0 q3 d0 \& b% q$ f# E9 h3 u
  j; m0 t1 O5 `: `+ x
// IMPORTANT: Any changes here requires a full re-compiling of the source code to propagate them.8 ^' u) G3 _. E& G
//重要:任何變化需要一個完整的基于源代碼的傳播。7 ^7 M, i* F4 @% y8 c5 M5 C

3 F: R' h7 }9 _& I. U#ifndef config_h
5 M+ s! j) ^6 k6 c#define config_h. @( K8 X0 Q% d2 n! h
#include "grbl.h" // For Arduino IDE compatibility.4 E. t$ r- O0 T! P

" |4 Z# r# A% R  S3 e6 F// Default settings. Used when resetting EEPROM. Change to desired name in defaults.h) }0 K8 A, D0 F/ \% X" c. l$ `- x+ q0 E
// 默認設置。在重置eepm時使用。在defaults.h改變想要的名字
& P8 c6 V$ e5 y5 X: d- {1 o$ U6 `& }  H$ v4 i
#define DEFAULTS_GENERIC
& o) b+ c- e* M7 @( _" z' z) ^& k8 p  a% t( b4 F/ {# d5 C: [
// Serial baud rate
& g$ H& o' {0 h" t+ z6 z: k6 U1 G#define BAUD_RATE 115200                //配置串口波特率1152003 B1 K, q# J, g$ I) F3 d

; @/ P4 `5 _7 N9 J2 I4 |// Default cpu mappings. Grbl officially supports the Arduino Uno only. Other processor types' Z; h% W) \; g5 y* U- N
// may exist from user-supplied templates or directly user-defined in cpu_map.h
( X2 P: F! y5 E- E$ l% C//默認cpu映射。Grbl正式支持Arduino Uno。其他類型的處理器可能存在cpu_map.h直接從用戶提供的模板或用戶定義的
5 b- K( M" M- W0 _  e
$ d& H& b0 @$ N" q% i$ J/ X#define CPU_MAP_ATMEGA328P // Arduino Uno CPU8 U* q. h* x; Q9 x$ ~" z& F  z' S0 b
& F/ u: S" v9 K) G  `
// Define realtime command special characters. These characters are 'picked-off' directly from the% r3 d/ {+ y0 P6 D
// serial read data stream and are not passed to the grbl line execution parser. Select characters
: [) Q+ \$ e6 R7 w! j9 d0 J// that do not and must not exist in the streamed g-code program. ASCII control characters may be
' B4 `  v3 I$ K, P/ H% e// used, if they are available per user setup. Also, extended ASCII codes (>127), which are never in / s- X3 e5 m9 Q8 }+ s4 u
// g-code programs, maybe selected for interface programs.5 u7 z' A' `7 k* W" W' W
// NOTE: If changed, manually update help message in report.c.
0 A  f' ~- c- f# b8 r# y7 T
$ v/ \, |( q$ g( a* }' e//定義實時命令特殊字符。這些字符是直接從“各個擊破”串口讀取數據流并沒有傳遞到grbl行執行解析器。選擇角色+ T0 l$ u% e# Y6 w
//不,不能存在于程序流刀位點。ASCII控制字符
7 |) _5 e8 K0 a. m7 G- t7 D//使用,如果他們是可用的每個用戶設置。同時,擴展的ASCII碼(> 127),從來沒有  y3 \' r; l% A! b) I3 l
//刀位點的程序,也許選擇界面程序。
  ~9 W  o1 V. u" C5 n) R( O//注意:如果改變,手動更新report.c幫助信息。
+ d! O% S& }4 \4 s% O7 ?! |9 ~7 j3 \6 ]5 U: {
#define CMD_STATUS_REPORT '?'
* U) k2 Y# ^+ @& |7 }; L#define CMD_FEED_HOLD '!'/ N4 Q6 p) K$ u
#define CMD_CYCLE_START '~'6 _- x0 z6 x- M/ ?, ~1 j1 ^
#define CMD_RESET 0x18 // ctrl-x.
1 @' h& d6 [4 Z+ K8 m& S9 J5 ]6 D#define CMD_SAFETY_DOOR '@'/ S" \. R1 m- z' l) a6 Z2 t- X
# W& ?( _' Q$ B2 F) O1 }8 R, p; K
// If homing is enabled, homing init lock sets Grbl into an alarm state upon power up. This forces2 h& C: ^% A8 a7 X3 P: W1 ~$ G
// the user to perform the homing cycle (or override the locks) before doing anything else. This is
$ L& m+ Y/ w. c; _// mainly a safety feature to remind the user to home, since position is unknown to Grbl.7 K( l# |0 |% O/ b5 P" H) K
$ Y) X8 R% ^, \
//如果啟用了回原點,導航初始化鎖集Grbl進入警報狀態啟動。這就迫使
! R5 X) \& A! I( c0 J/ p( f9 }//用戶執行歸航周期(或覆蓋鎖)在做任何其他事情之前。這是
6 [* `$ E7 r# v0 B" z//主要安全功能,提醒用戶家里,因為Grbl位置是未知的。6 `& d5 O+ M, T* `; [

8 t  D; {6 Y0 }8 |% A#define HOMING_INIT_LOCK // Comment to disable9 `! N5 T% x/ m$ W
9 I% A4 c1 D% T' g/ w* u, }) j
// Define the homing cycle patterns with bitmasks. The homing cycle first performs a search mode. Y. B1 p, v3 [5 o  \
// to quickly engage the limit switches, followed by a slower locate mode, and finished by a short
& W+ z' ?% Z' W4 R. Q; a8 m// pull-off motion to disengage the limit switches. The following HOMING_CYCLE_x defines are executed
' _8 \0 }' x# l// in order starting with suffix 0 and completes the homing routine for the specified-axes only. If
# U) V6 H. G+ f// an axis is omitted from the defines, it will not home, nor will the system update its position.# r) }  k# g3 @6 I
// Meaning that this allows for users with non-standard cartesian machines, such as a lathe (x then z,
& v' ?+ `9 y; H// with no y), to configure the homing cycle behavior to their needs.
) c3 Z+ @4 y- X// NOTE: The homing cycle is designed to allow sharing of limit pins, if the axes are not in the same4 b. w7 q; P' u8 ~% v
// cycle, but this requires some pin settings changes in cpu_map.h file. For example, the default homing4 B3 C8 l6 y1 Z7 U9 X/ \; \4 [
// cycle can share the Z limit pin with either X or Y limit pins, since they are on different cycles.7 l; J3 a* ?$ w6 k. d
// By sharing a pin, this frees up a precious IO pin for other purposes. In theory, all axes limit pins
' c1 ]( L2 A" S+ z: R0 [// may be reduced to one pin, if all axes are homed with seperate cycles, or vice versa, all three axes
7 ?- `+ B6 X. P3 B// on separate pin, but homed in one cycle. Also, it should be noted that the function of hard limits 2 ^: V8 Y( q2 i2 l* B
// will not be affected by pin sharing.
/ H/ [1 M  e8 b7 i0 \0 K* s//定義導航循環模式的位掩碼。歸航周期首先執行一個搜索模式' X1 C7 e2 E5 f. }) r; N; g+ N
//快速進行限位開關,其次是較慢的定位模式,完成了由一個短
) o* G5 W$ ]8 i: ~  d//拖出運動脫離限位開關。以下HOMING_CYCLE_x定義執行/ o1 q  e0 q: p  }
//為了與后綴0開始并完成specified-axes只尋的例程。如果' d% s; S) B9 Y/ k3 G% V
//定義省略一個軸,它會不在家,也不會系統更新它的位置。) m9 F( `' c* k5 s+ Z0 {, z
//意義,這允許用戶與非標準笛卡爾的機器,比如車床(x,z,6 _% h0 B3 k/ S1 W* W& J+ T. W& Z" w/ _: X
//沒有y),配置導航循環行為對他們的需求。! ]4 r* I1 G' x4 }; J* j
//注意:歸航周期允許共享限制針,如果軸不相同
% f8 n3 {5 n* u, A8 b+ u//循環,但這需要一些銷設置cpu_map的變化。h文件。例如,默認的導航+ j5 Z/ [+ J; t+ w
//循環可以分享Z限位銷X或Y限制針,因為它們是在不同的周期。  \) d6 C8 v( `! @
//通過共享一個銷,這騰出寶貴的IO銷用于其他目的。從理論上講,所有軸限制別針2 H! s0 A5 l1 F) [, B6 G  c
//可能會減少到一個銷,如果所有軸與分離周期居住的地方,反之亦然,所有三個軸
' h' K- [' U$ S8 p' J//在不同銷,但這時候一個周期。同時,應該注意的是,硬限制的功能; k% B$ t: ?) D! L
//將不會影響銷共享。0 m% R( C, T$ ~  m: z& i8 w; u" _
//注意:默認設置為一個傳統的硬件數控機器。z軸首次明確,其次是X和Y。
5 u/ `4 H  \' y8 |9 @# ^, A+ C" o
// NOTE: Defaults are set for a traditional 3-axis CNC machine. Z-axis first to clear, followed by X & Y.
5 C* d+ \8 k$ s, w; I5 d#define HOMING_CYCLE_0 (1<<Z_AXIS)                // REQUIRED: First move Z to clear workspace. 第一步Z清除工作區。4 x. W4 I2 u* d% F" ^; `7 D5 r  \9 ^# L* N
#define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // OPTIONAL: Then move X,Y at the same time.然后X,Y在同一時間。& N/ @$ i8 `' j% V' f4 i
// #define HOMING_CYCLE_2                         // OPTIONAL: Uncomment and add axes mask to enable
6 B, ]0 {" |+ m9 D: R8 S# b( w6 a$ C* i! ^! C
// Number of homing cycles performed after when the machine initially jogs to limit switches.
( Z+ ]( ]: j% I" |# f// This help in preventing overshoot and should improve repeatability. This value should be one or - g. ^- T! x4 @! H9 {  N4 p
// greater.$ o3 F( q; S, j( x7 R. X
//執行回原點循環次數后,當機器最初慢跑限位開關。這個幫助防止過度,應該提高重復性。這個值應該是一個或大。. s& W: y" l- K. s+ d1 s) y, V3 h

6 I( ~, y6 z" l/ S: S/ F/ N#define N_HOMING_LOCATE_CYCLE 1 // Integer (1-128)# J/ d3 o5 z" x

+ q: s0 i' }) x  V( W  m) U* ]6 R* y// After homing, Grbl will set by default the entire machine space into negative space, as is typical4 i( g5 I  u3 y1 H& i  [
// for professional CNC machines, regardless of where the limit switches are located. Uncomment this
% e: b* w& r: r+ @, V# l// define to force Grbl to always set the machine origin at the homed location despite switch orientation.
/ `( g9 E  z  X0 W9 d4 x3 T: T% w5 y! R0 l0 y  I
//導航后,默認Grbl將整個機器空間留白,是典型的專業數控機器,不管限位開關所在的地方。
* ?+ B' l. ~  r+ n# f& L9 k0 T& P//取消這定義迫使Grbl總是在這時候位置設置機器原點盡管開關方向。7 B% ^) ^  X" P1 e  X0 M

: V& d* g7 G8 _! Y' `// #define HOMING_FORCE_SET_ORIGIN // Uncomment to enable.5 z& v& r- l6 T. w& `  m
( r' X# k! E7 c7 y

0 S  g5 u, {. a// Number of blocks Grbl executes upon startup. These blocks are stored in EEPROM, where the size
# {5 H2 m$ |7 T// and addresses are defined in settings.h. With the current settings, up to 2 startup blocks may! @6 W. F$ X1 x1 M
// be stored and executed in order. These startup blocks would typically be used to set the g-code" C3 y4 V6 m* |; J% A1 M
// parser state depending on user preferences./ s. H( X( K8 q8 G- T) s

  `1 g8 _, r: x- P% u" b: p4 Z* R. R//塊Grbl啟動時執行的數量。這些塊存儲在eepm,大小* X- J8 K9 T* T% f; {5 B2 V& M9 _
//和地址在settings.h中定義。與當前設置,可能2啟動塊
" i: f1 V( U1 ]# L: B% ?7 C//存儲和執行。這些啟動塊通常被用來設置刀位點
% t3 E! [) j5 H0 D" F- X* v* Q//解析器的狀態取決于用戶首選項。) Z7 Q3 h- B% r& X

* y7 @7 B, W" I8 K#define N_STARTUP_LINE 2 // Integer (1-2)
" k, }1 z6 C! Z0 \. J2 l( v5 b$ ?/ P" I. p; d
// Number of floating decimal points printed by Grbl for certain value types. These settings are
9 R) }: h8 b- G( m// determined by realistic and commonly observed values in CNC machines. For example, position% b/ }8 L$ J' l
// values cannot be less than 0.001mm or 0.0001in, because machines can not be physically more* ?3 g( W, z, W8 p# |9 h
// precise this. So, there is likely no need to change these, but you can if you need to here.( }- ~! {2 ]* s3 B* T6 ]
// NOTE: Must be an integer value from 0 to ~4. More than 4 may exhibit round-off errors.* {* A$ s! Z9 Z; s! c6 K
6 O( c! |# K7 I' U+ Q5 p2 u
// Grbl浮動小數點的數字印刷的特定的值類型。這些設置是. [/ R$ |/ z! S* |
//一般由現實和觀測值在數控機器。例如,位置
+ D- y' c3 R, X7 g6 M, f) L//值不能小于0.001毫米或0.0001,因為機器不能身體更多& Q% M: N& b# p7 |" @
//精確。因此,有可能不需要改變這些,但你可以在這里如果你需要。' d$ P5 _  F& V. n/ x
//注意:必須是一個整數值從0 ~ 4。超過4可能出現舍入錯誤。
- Y, z) [8 i7 C: E
& E. m$ D5 n) t#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 協調或位置價值英寸
8 p* e$ W* [/ S& @7 M#define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 協調在毫米或位置價值
8 }1 _6 q1 C  @# I7 \#define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分鐘的速度值$ p1 D7 c) j6 C6 R1 r
#define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分鐘; z5 ^7 t. B- \$ T
#define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 對浮點小數設置值
+ {  r- |. V# d* Q
. t9 m, Q  ~3 h/ A// If your machine has two limits switches wired in parallel to one axis, you will need to enable
$ [/ {- @! K0 H: k5 _2 {) d, j// this feature. Since the two switches are sharing a single pin, there is no way for Grbl to tell
6 ?  W4 Q' ~& }+ x" e// which one is enabled. This option only effects homing, where if a limit is engaged, Grbl will
9 W' b$ S" i, `) ]% e8 a, |% ?// alarm out and force the user to manually disengage the limit switch. Otherwise, if you have one
6 `, c1 c) X' G" y// limit switch for each axis, don't enable this option. By keeping it disabled, you can perform a" f+ V7 X7 m$ ^! d+ C4 J
// homing cycle while on the limit switch and not have to move the machine off of it.) z% S( t+ y, a/ f

4 P" G0 _* y. H' D: |//如果你的機器有兩個極限開關連接在平行于一個軸,您需要啟用9 R# e8 x# c3 M- a: ]7 k' ~# g4 ^
//這個特性。自從兩個交換機共享一個銷,沒有辦法Grbl告訴; p- n7 M' g7 M7 W9 A% Y6 G
//啟用哪一個。此選項僅影響歸航,如果限制,Grbl意志
% m# k5 y- Q3 y$ b# x2 }//報警,迫使用戶手動松開限位開關。否則,如果你有一個% z7 r6 @! J- d
//為每個軸限位開關,不啟用該選項。通過保持禁用,您可以執行
  T7 A. {0 R: p% N2 O! h: _4 T//導航循環在限位開關并沒有將這臺機器。9 F% Q/ x' S! x9 R

% R9 H* d6 ?% }; l8 Y# @" p// #define LIMITS_TWO_SWITCHES_ON_AXES- w$ _/ i7 @3 n9 \3 k
! a- s* a( M8 @/ ]8 q7 b; Y& z
// Allows GRBL to track and report gcode line numbers.  Enabling this means that the planning buffer
, E) d! p! W8 U! j7 |9 Z4 l// goes from 18 or 16 to make room for the additional line number data in the plan_block_t struct
8 o4 m8 ^! v  |- Z2 ~" m- k' T3 P) i
//允許GRBL跟蹤和報告gcode行號。使這意味著計劃緩沖從18歲或16歲,為額外的行號plan_block_t結構中的數據
6 H, R8 Z& D" c% j2 L$ |7 I% Y  T3 m: s! z
// #define USE_LINE_NUMBERS // Disabled by default. Uncomment to enable.7 {% M  d, W" ~/ T& i) }. W- L
5 Z7 P# D1 D1 b# o5 T
// Allows GRBL to report the real-time feed rate.  Enabling this means that GRBL will be reporting more 0 S4 i" l7 U$ X5 R; c
// data with each status update.
) P  i  l3 C* @0 m$ O% ^/ {// NOTE: This is experimental and doesn't quite work 100%. Maybe fixed or refactored later.! H$ _2 s1 |" u
//允許GRBL報告實時進給速率。使這意味著GRBL將報告數據和狀態更新。2 l: _2 ~6 M* Z; Y' h3 {9 V
//注意:這是實驗和100%沒有工作。也許以后固定或重構。+ s! `7 d  g# P  y) k) D

) g6 d# r. I- N# l. c6 Z// #define REPORT_REALTIME_RATE // Disabled by default. Uncomment to enable.$ N) P9 E9 d6 K# e
2 N4 V3 x& U; E+ H
// Upon a successful probe cycle, this option provides immediately feedback of the probe coordinates. h6 |; E/ L. N0 ]6 V1 X
// through an automatically generated message. If disabled, users can still access the last probe& |" i, v( _8 D; H7 x
// coordinates through Grbl '$#' print parameters.
( ~0 y' e( t9 m' a3 a2 ^& h  ~! r//在一個成功的調查周期,這個選項提供立即反饋的探測器坐標" z* M: w/ |5 ^8 E+ o/ J0 X
//通過一個自動生成的消息。如果禁用,用戶仍然能夠訪問調查1 y' n! b& K, `% E. Q, j
//坐標通過Grbl $ #的打印參數。% x, I! }7 g* D, R- P. B

* S  e) x  E4 @& \#define MESSAGE_PROBE_COORDINATES // Enabled by default. Comment to disable.2 ?! E8 c1 d7 O

4 l0 k$ q; B' z) _  V9 ?* r// Enables a second coolant control pin via the mist coolant g-code command M7 on the Arduino Uno0 G/ b9 g1 k- x, H9 c+ Q( J) p
// analog pin 5. Only use this option if you require a second coolant control pin.* e, d0 f  U% e
// NOTE: The M8 flood coolant control pin on analog pin 4 will still be functional regardless.6 Q" _9 e9 m; `/ M2 N' g
// #define ENABLE_M7 // Disabled by default. Uncomment to enable.
" Z/ w0 K- ~7 J2 X- n- s" g; t7 E: o% ~7 s0 D
// This option causes the feed hold input to act as a safety door switch. A safety door, when triggered,
. y: N, |; G5 n// immediately forces a feed hold and then safely de-energizes the machine. Resuming is blocked until
; `! p4 e* L4 @' t. l+ a// the safety door is re-engaged. When it is, Grbl will re-energize the machine and then resume on the
# K+ \# B; y: P// previous tool path, as if nothing happened.
# S& |* z8 L7 Z6 j// #define ENABLE_SAFETY_DOOR_INPUT_PIN // Default disabled. Uncomment to enable.9 A1 Z. ?  M1 k& Q: E! w/ M4 C" K

) S5 t5 k1 D- V" w# s// After the safety door switch has been toggled and restored, this setting sets the power-up delay6 ^' g6 ?7 N% U: v7 @* U2 m
// between restoring the spindle and coolant and resuming the cycle.* t3 K6 M6 d6 S/ B/ D4 S
// NOTE: Delay value is defined in milliseconds from zero to 65,535. , [  c: G# U# Z, `1 P+ g* Z* M
2 d7 B- i* [/ U9 T$ p
//定義導航循環模式的位掩碼。歸航周期首先執行一個搜索模式! k3 T/ ?7 p* O2 w  G( F6 A
//快速進行限位開關,其次是較慢的定位模式,完成了由一個短. ^; E! g6 S) ~! Z) b1 _
//拖出運動脫離限位開關。以下HOMING_CYCLE_x定義執行" C" B  i- E9 Q2 H' h# I( b, W
//為了與后綴0開始并完成specified-axes只尋的例程。如果
2 l- ]3 m/ \# _; ~, U8 k//定義省略一個軸,它會不在家,也不會系統更新它的位置。
3 {7 J) r% d$ K/ k" @//意義,這允許用戶與非標準笛卡爾的機器,比如車床(x,z,% L( P; j1 c8 f9 r! T
//沒有y),配置導航循環行為對他們的需求。
# W/ d6 S4 L' o/ l//注意:歸航周期允許共享限制針,如果軸不相同
6 W# A+ b/ ?4 D% U3 Y//循環,但這需要一些銷設置cpu_map的變化。h文件。例如,默認的導航
( n5 m: i7 P8 V$ C4 F//循環可以分享Z限位銷X或Y限制針,因為它們是在不同的周期。  O; L( Q. A0 Y7 h" l& ]/ K/ C
//通過共享一個銷,這騰出寶貴的IO銷用于其他目的。從理論上講,所有軸限制別針
% L, f* Z: `' N: A//可能會減少到一個銷,如果所有軸與分離周期居住的地方,反之亦然,所有三個軸! G" \5 Z  R( j+ ~+ R! V" j
//在不同銷,但這時候一個周期。同時,應該注意的是,硬限制的功能: m. A: v5 {. m
//將不會影響銷共享。0 G! O; C5 F- \  F- j& }
//注意:默認設置為一個傳統的硬件數控機器。z軸首次明確,其次是X和Y。
! k: X% R3 f/ W$ v7 g' V( G' }" \2 z0 G& t& T5 q9 p9 J# y6 A

1 S) ~: l: ?, c#define SAFETY_DOOR_SPINDLE_DELAY 4000
. \" ^' }4 S5 ~, w( q#define SAFETY_DOOR_COOLANT_DELAY 1000
1 r; o5 W4 j# r* e, e+ S. n/ z( j3 U+ e% |
// Enable CoreXY kinematics. Use ONLY with CoreXY machines.
) _: N: ]1 ~# r2 r) E// IMPORTANT: If homing is enabled, you must reconfigure the homing cycle #defines above to   Z5 Z2 S% E8 }4 j
//啟用CoreXY運動學。只使用與CoreXY機器。
6 J6 [0 ^9 g% H//重要:如果啟用了自動尋的,你必須重新配置導航循環#定義上面
; ?1 V4 Z2 a& Q' F  u
  `6 @( A1 k' L/ Q. h// #define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS)
- {0 h7 N1 k. U: E. }1 ~1 s* M
& |# {( u* f/ \' B4 A# X7 L- T// NOTE: This configuration option alters the motion of the X and Y axes to principle of operation
& B( k& L0 V( y2 A4 ]// defined at (http://corexy.com/theory.html). Motors are assumed to positioned and wired exactly as
% ~- o: D6 b7 Q  d/ B# W) @// described, if not, motions may move in strange directions. Grbl assumes the CoreXY A and B motors
5 G" p# M/ g% ^; d3 h' B4 w// have the same steps per mm internally.. E% u8 D3 H! |$ m" r, N
//注意:這種配置選項改變X和Y軸的運動原理,操作9 n3 a: M* O; ]; b9 r9 n  d9 H
//定義(http://corexy.com/theory.html)。汽車被認為定位和連接一樣- x  J; S, @. q3 \) p2 K7 O
//描述,如果沒有,運動可能會奇怪的方向移動。A和B Grbl假設CoreXY馬達3 J2 u0 C8 w. k6 {9 a: g$ ?
//每毫米內部有相同的步驟。
- y, m9 ?. X$ s' [/ W, n: p  Q, M: `* z8 E) o- @
// #define COREXY // Default disabled. Uncomment to enable.$ A  f* X0 i$ s. @6 F5 B3 `
& z$ @* |; j2 \, Q& U" w5 W+ M
// Inverts pin logic of the control command pins. This essentially means when this option is enabled
$ R; f" E1 g/ H" L" T4 ]// you can use normally-closed switches, rather than the default normally-open switches.
9 [6 z; ]5 }, `6 E; d0 }1 }# n5 c// NOTE: Will eventually be added to Grbl settings in v1.0.8 A' V; M6 i4 ]* Z, q
//反轉針銷邏輯的控制命令。這實質上意味著當啟用這個選項3 A0 B0 \& C+ x
//可以使用閉合開關,而不是默認的常開開關。, p! Y- `1 u. W$ Y0 G0 f
//注意:最終將被添加到在v1.0 Grbl設置。
, p0 Z9 `2 ?& ]3 U8 p; q0 h4 }
; F- G2 q9 C) t/ v% D// #define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.! [9 Q( J  _( v
/ _" b3 E' G/ u0 J% \6 h
// Inverts the spindle enable pin from low-disabled/high-enabled to low-enabled/high-disabled. Useful7 r( \+ |! ]  k6 j# B
// for some pre-built electronic boards.
. e, P4 _# J, k9 C1 b+ b// NOTE: If VARIABLE_SPINDLE is enabled(default), this option has no effect as the PWM output and + [$ j4 [5 N2 h; c
// spindle enable are combined to one pin. If you need both this option and spindle speed PWM,
6 I# R9 b/ U* y# y; j& m// uncomment the config option USE_SPINDLE_DIR_AS_ENABLE_PIN below.0 [% X. ~. T! S6 h
//反轉主軸使銷從low-disabled / high-enabled low-enabled / high-disabled。有用的
5 @5 ]! w+ L$ P. }0 l0 b% O% x  V8 `4 b//預構建的電子板。
* T/ X6 Z' q1 M+ Q; I. T; Z//注意:如果啟用了VARIABLE_SPINDLE(默認),這個選項作為PWM輸出并沒有影響
8 ^0 b+ h% R; w0 J//銷軸使結合。如果你需要這個選項和主軸轉速PWM,0 {) Q9 Q$ U( i' n9 T) j7 P
//取消注釋以下配置選項USE_SPINDLE_DIR_AS_ENABLE_PIN/ q6 A( E' [$ ]4 T7 t, R

* }, F6 F/ N; E" G1 r+ q// #define INVERT_SPINDLE_ENABLE_PIN // Default disabled. Uncomment to enable.# C* m. ~. z$ B
: V$ W/ |; @. K0 F
// Enable control pin states feedback in status reports. The data is presented as simple binary of
' v& U% q3 a8 }* N// the control pin port (0 (low) or 1(high)), masked to show only the input pins. Non-control pins on the
9 _" u! u* ?0 r0 @" Q4 N$ H// port will always show a 0 value. See cpu_map.h for the pin bitmap. As with the limit pin reporting,5 w1 o$ J! b: O; n/ U$ X; c
// we do not recommend keeping this option enabled. Try to only use this for setting up a new CNC.
" o& y4 \9 m7 P) `* z//啟用控制銷狀態反饋狀態報告。作為簡單的二進制數據
3 o. |: u0 m1 o, H//控制針端口(0(低)或1(高)),蒙面,只顯示輸入插腳。非控制性針上8 D/ t* |6 u* a+ z
//端口總是顯示0值。看到cpu_map。針位圖h。與限制銷報告,$ F/ m! s' a0 p2 D7 y1 y
//我們不推薦保持啟用這個選項。盡量只使用這個設置一個新的數控。2 M9 m# {) j  m9 m* w5 D& e

# z+ S3 `9 e7 |% u1 C9 _7 g+ g// #define REPORT_CONTROL_PIN_STATE // Default disabled. Uncomment to enable.
6 |7 W) J; ^$ O2 P
4 V9 e& ]1 N+ E+ E2 l6 V8 \% p( j// When Grbl powers-cycles or is hard reset with the Arduino reset button, Grbl boots up with no ALARM
6 |5 \* g& i8 ~! x: A  d% U( B+ f// by default. This is to make it as simple as possible for new users to start using Grbl. When homing
- I* N# K7 n8 k8 z) `+ N9 |; R// is enabled and a user has installed limit switches, Grbl will boot up in an ALARM state to indicate
3 c+ ]9 \; b0 f% a// Grbl doesn't know its position and to force the user to home before proceeding. This option forces" H" {+ J$ C% N
// Grbl to always initialize into an ALARM state regardless of homing or not. This option is more for$ N  A$ `( S+ m  S8 ^0 C0 \; a& U
// OEMs and LinuxCNC users that would like this power-cycle behavior.4 K3 m/ `$ z$ Q& j
//當Grbl powers-cycles還是硬重置Arduino復位按鈕,Grbl啟動沒有報警1 v6 E1 i1 L% E) n8 w& z" B; S4 K
//默認情況下。這是為了讓新用戶盡可能簡單使用Grbl開始。當歸航
+ {. u- E+ J. M. `6 n; Y7 J//啟用和用戶安裝限位開關,Grbl將啟動報警狀態指示/ V& v$ T" L* P5 t
// Grbl不知道它的位置,迫使用戶在繼續之前回家。這個選項部隊
- Q/ l9 {' ?" C  k9 i0 L) T4 M// Grbl總是初始化進入警報狀態不管歸航。這個選項是更多; l! @% }% T$ F
//原始設備制造商和LinuxCNC用戶這樣的控制行為。
$ s' ^: H; \% `1 U" a& R+ R, [; ]) Y
// #define FORCE_INITIALIZATION_ALARM // Default disabled. Uncomment to enable., Q/ h) h7 s: E
; I# T7 d7 E5 q( N
// ---------------------------------------------------------------------------------------8 b- f2 X' g2 Y) y( N8 I! e5 o( _
// ADVANCED CONFIGURATION OPTIONS://高級配置選項:
5 ^( I: w& g: ]) e+ ^0 U) q
7 R3 R- J  d7 {( r" e3 d- n* m// Enables minimal reporting feedback mode for GUIs, where human-readable strings are not as important.
, w# D: g- w0 N/ W// This saves nearly 2KB of flash space and may allow enough space to install other/future features.
& h$ z# f8 g! [+ R// GUIs will need to install a look-up table for the error-codes that Grbl sends back in their place.
5 \8 J+ h8 ?6 T. U' U8 i// NOTE: This feature is new and experimental. Make sure the GUI you are using supports this mode.: P) O( m1 L6 i% S; L
( ~. \1 c& z- Y) D/ {
// gui允許最小的報告反饋模式,人類可讀的字符串在哪里不重要。  Z. Q7 n) V$ Q& Q
//這個節省近2 kb的閃存空間,允許足夠的空間來安裝其他/未來的功能。
5 p3 q; T& [) B2 y// gui需要安裝一個查找表的錯誤代碼Grbl發回。6 p7 `. U9 F; i! w
//注意:此功能是新的和實驗。確保您使用的GUI支持這種模式。% h* e. e0 C' w$ Z3 \3 H
3 I, q( R3 q* H& E
// #define REPORT_GUI_MODE // Default disabled. Uncomment to enable.
+ g5 ]5 R8 l( Y2 P
4 r7 d0 r, j0 ?( g' y$ h. X, L// The temporal resolution of the acceleration management subsystem. A higher number gives smoother
* U+ U* q$ C% E& x// acceleration, particularly noticeable on machines that run at very high feedrates, but may negatively( j1 E  I; W4 L: y& J5 i4 n2 {
// impact performance. The correct value for this parameter is machine dependent, so it's advised to+ A4 t9 I* N+ F. J: T5 R' w% t
// set this only as high as needed. Approximate successful values can widely range from 50 to 200 or more.+ y' k7 A4 v! A
// NOTE: Changing this value also changes the execution time of a segment in the step segment buffer. : U) m9 N7 ^: w+ {4 s( Q: A" V
// When increasing this value, this stores less overall time in the segment buffer and vice versa. Make4 I- F6 I8 K5 |; G
// certain the step segment buffer is increased/decreased to account for these changes.- U! D  Q  O' h/ c; n. K9 T
//加速度的時間分辨率管理子系統。更多更平穩8 p* M1 B. Z2 j. R& A
//加速度,特別明顯的機器上,運行在非常高的進料速度,但可能負面/ e, ^" j# H; A# q9 j
//影響性能。正確的值為這個參數是依賴于機器的,所以建議1 `3 X: s: l4 C/ `/ _
//這只設置為高。近似成功的價值觀可以廣泛的范圍從50到200或者更多。
7 A% o3 q, \/ V: [# j//注意:改變這個值也變化的部分步驟的執行時間緩沖。
8 k  H% L0 V; k* S( i( s//增加這個值時,這個商店部分緩沖區的總時間減少,反之亦然。使
( `1 G5 ^4 [) M+ C9 X//特定步驟段緩沖是考慮這些變化增加/減少。& S8 j& H$ T0 T9 u' d9 {- ^
7 ~$ `) |+ M8 p: i4 n3 _* C1 ]0 M# p6 \" ^
#define ACCELERATION_TICKS_PER_SECOND 100  //加速度的時間分辨率管理子系統。更多更平穩
* K- g& G6 \8 O. o" z7 m( R6 M0 w' G& Y3 |, y: }# Q0 z. c" [8 G+ L
// Adaptive Multi-Axis Step Smoothing (AMASS) is an advanced feature that does what its name implies, * @4 D. ]: D5 c/ c) j9 g7 [
// smoothing the stepping of multi-axis motions. This feature smooths motion particularly at low step
4 N& m$ Y* N9 m; R9 ]1 i+ v0 y// frequencies below 10kHz, where the aliasing between axes of multi-axis motions can cause audible ( M) M4 R" F/ i+ j
// noise and shake your machine. At even lower step frequencies, AMASS adapts and provides even better5 I; D1 W3 g1 y. [/ q  c
// step smoothing. See stepper.c for more details on the AMASS system works.- m( i, a: \6 a. L* `4 R6 t1 w
//自適應多軸步平滑(積累)是一種先進的功能,它的名字所暗示的那樣,3 c1 M7 M$ x, Z' R
//平滑的多軸步進運動。這個特性平滑運動尤其是在低一步5 L  o) R& ^6 _7 N6 S# z2 Z5 T
//頻率低于10 khz,軸之間的混疊的多軸運動可能導致音響1 J& P2 ?; s- _3 h5 Y* r
//噪音和震動你的機器。在更低的頻率步,積累適應并提供更好
1 E# o  B+ Z+ ]9 I//步驟平滑。看到步進。c更多細節的積累系統的工作原理。0 N5 e+ A9 a( h3 i  F0 B0 u
) f8 U' C. F# n+ ~
#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING  // Default enabled. Comment to disable.//自適應多軸步平滑( o: o# ~5 Q. c6 G0 T

8 I- V4 Y, N8 N0 F+ B  k' x+ I// Sets the maximum step rate allowed to be written as a Grbl setting. This option enables an error , z- e  x9 |5 W9 O5 Z: n
// check in the settings module to prevent settings values that will exceed this limitation. The maximum
! r. b1 Z& H4 t// step rate is strictly limited by the CPU speed and will change if something other than an AVR running
& @" B4 Q) X0 X0 w// at 16MHz is used.  O- z2 u8 K3 O% F# `9 C7 G( r
// NOTE: For now disabled, will enable if flash space permits.
! O% T) T' ^% L4 j2 j//設置最大一步速率可以寫成Grbl設置。這個選項可以使一個錯誤$ _9 [  q2 [! ~8 H
//設置模塊中檢查,防止設置值將超過這個限制。的最大6 y: @' h* |* b8 V
//步驟嚴格限制的CPU速度也會改變如果是其他AVR運行
- y1 ^/ `" x+ z/ @: C$ L//使用16兆赫。
8 n  V+ m. E* M//注意:現在殘疾,將使如果flash空間許可。  Z7 P: _  D7 `% A% i* W! S0 `

, P" v+ x; o2 {, c3 L// #define MAX_STEP_RATE_HZ 30000 // Hz 設置最大一步速率
/ X5 j4 X1 Z# Z$ m7 s
. [+ X& F5 Y- x// By default, Grbl sets all input pins to normal-high operation with their internal pull-up resistors! C7 s. G6 U( j) S2 W
// enabled. This simplifies the wiring for users by requiring only a switch connected to ground,
$ ^4 Q$ [9 N# i) m( O/ k// although its recommended that users take the extra step of wiring in low-pass filter to reduce) V, p+ |: C3 g% t5 M
// electrical noise detected by the pin. If the user inverts the pin in Grbl settings, this just flips" ^5 ~# K# j! u3 ~4 a+ ~& _3 ]: ]+ G
// which high or low reading indicates an active signal. In normal operation, this means the user
( u0 L. T4 p6 ~9 @* I// needs to connect a normal-open switch, but if inverted, this means the user should connect a
) [, ?6 s; p3 Q0 g/ ^' v- r! s5 X// normal-closed switch.
. ~; x: D- p+ D// The following options disable the internal pull-up resistors, sets the pins to a normal-low ( g8 U% q1 i; |) Z. f
// operation, and switches must be now connect to Vcc instead of ground. This also flips the meaning & s8 o* [) b8 g( N2 N9 ]* y
// of the invert pin Grbl setting, where an inverted setting now means the user should connect a % y- W* f# m) ?& E
// normal-open switch and vice versa.
6 ]+ }/ I2 J/ s7 Y1 F" [) C// NOTE: All pins associated with the feature are disabled, i.e. XYZ limit pins, not individual axes.
" N  n! k* @; v9 b( f7 I// WARNING: When the pull-ups are disabled, this requires additional wiring with pull-down resistors!
! S  Y# B0 z2 H//默認情況下,Grbl所有輸入引腳設置為正常高操作的內部上拉電阻9 }( ~: [( w% j9 d/ d: K, D" p
//啟用。這簡化了布線為用戶只需要一個開關連接到地面,
& F, X% ^- w* o9 F) Y% l' k; S//雖然其建議用戶采取額外的步驟,在低通濾波器來減少布線. Y, d" [$ Y: O
//電噪音檢測銷。如果用戶反轉的銷Grbl設置,這只是翻轉, \& t" W5 V+ k7 E  }: \- l
//讀高或低表明一個積極的信號。在正常操作中,這意味著用戶
4 T- K0 Y* ]4 d5 S//需要連接一個常開開關,但如果倒,這意味著用戶應該連接
, L9 ?! O5 Q0 F6 W: @// normal-closed開關。& ?; m2 T, J) L6 K& T  P$ s
//以下選項禁用內部上拉電阻,一般低設置別針% H& U; u3 A, S: P- p3 H
//操作,現在開關必須連接到Vcc代替地面。這也掀的意思3 ^1 Z/ p$ O! k4 p8 [: h0 R9 x
//反銷Grbl設置,一個倒置的設置現在意味著用戶應該連接1 K+ M0 a) {0 o1 F
//常開開關,反之亦然。3 Q  I* u, {) ]" U  x, @
//注意:所有針與功能被禁用,例如XYZ限制針,而不是單獨的軸。
+ r% v0 Y' _" `# I3 c8 I//警告:引體向上被禁用時,這需要額外的布線與下拉電阻!
2 L# T6 d5 I& N) x, h6 }3 K3 W: X+ t
//#define DISABLE_LIMIT_PIN_PULL_UP //以下選項禁用內部上拉電阻% d4 P5 U6 P( t+ }2 }, w2 \+ T8 x
//#define DISABLE_PROBE_PIN_PULL_UP0 ]- b+ c% D7 n7 p& Z& }
//#define DISABLE_CONTROL_PIN_PULL_UP# M; |% G5 O. l
( n- q/ P9 I$ i1 o  ?' |1 L
// Sets which axis the tool length offset is applied. Assumes the spindle is always parallel with
4 G1 p7 N6 P% s6 `$ B  T// the selected axis with the tool oriented toward the negative direction. In other words, a positive
3 Z" W, _$ G9 S% t5 Q; g// tool length offset value is subtracted from the current location.* }. R3 ?: g) }2 R. V
//設置哪個軸長度補償應用的工具。假設軸總是與
* m& z8 w7 Z! d0 F9 u0 N& G; X) @//選擇軸工具面向負方向。換句話說,一個積極的" Z: x- t% F& U: V
//工具長度偏移值減去從當前位置。  C8 V4 S. R& j, D7 ]2 ~7 p

; ]$ ^) i$ L7 [9 N3 a3 ]& k* e#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS // Default z-axis. Valid values are X_AXIS, Y_AXIS, or Z_AXIS.設置哪個軸長度補償應用的工具
0 \& T+ B0 v9 ?( t# I7 W3 b" r9 t+ d6 }+ @% H8 v
// Enables variable spindle output voltage for different RPM values. On the Arduino Uno, the spindle9 p5 o: w8 M; `9 A# w; L8 ^
// enable pin will output 5V for maximum RPM with 256 intermediate levels and 0V when disabled.+ J, U& H! l% p0 f6 B# A
// NOTE: IMPORTANT for Arduino Unos! When enabled, the Z-limit pin D11 and spindle enable pin D12 switch!
* h$ L0 l( \$ j- G! y3 N; H// The hardware PWM output on pin D11 is required for variable spindle output voltages.
; G3 f8 w4 g+ b. F% D1 I//允許變量軸輸出電壓不同的轉速值。Arduino Uno,主軸. \* t1 _2 `( M3 s0 _
//啟用銷將輸出5 v的最高轉速256中級水平和0 v時禁用。
* L5 p8 N$ ]' v, r& Y& M$ j//注意:重要Arduino凱澤本人!當啟用時,Z-limit銷這里和軸銷D12開關!: @( i1 g' l4 D* G' K+ a& C* m2 Y
//硬件PWM輸出銷這里需要變量軸輸出電壓。
. I) r. A" R* n+ }$ d+ D# _6 P( F" `$ p# q
#define VARIABLE_SPINDLE // Default enabled. Comment to disable.//允許主軸輸出電壓不同的轉速值& x( b- V0 a- J& T1 U
2 x1 T) ]6 i" `) j
// Used by the variable spindle output only. These parameters set the maximum and minimum spindle speed
4 q: g5 T  S% t5 g7 Y// "S" g-code values to correspond to the maximum and minimum pin voltages. There are 256 discrete and / g, y% @9 o# t. P6 V
// equally divided voltage bins between the maximum and minimum spindle speeds. So for a 5V pin, 1000+ ]  t9 e' D0 u7 z- d, u0 H; Q
// max rpm, and 250 min rpm, the spindle output voltage would be set for the following "S" commands: 1 |% u+ Y* T  o2 @4 C: [! A
// "S1000" @ 5V, "S250" @ 0.02V, and "S625" @ 2.5V (mid-range). The pin outputs 0V when disabled.( q1 S5 N6 l2 i& G! t: y" b# A
//使用的變量軸輸出。這些參數設置最大和最小軸轉速, S* s- J4 Y3 Q3 x$ a1 c5 I* S* _
//“S”刀位點值對應于銷電壓的最大值和最小值。有256個離散和
8 y; ?( j9 k+ ~, a8 ?//電壓平均分配箱主軸速度的最大值和最小值之間。所以對于一個5 v銷,10003 ~# q& z# L9 u7 y  Q. X+ Y
// max rpm,250分鐘rpm,主軸輸出電壓將為以下“S”命令:0 b* h% K& K# `
// @“S1000 5 v,“S250”@ 0.02 v,“S625”@ 2.5 v(中檔)。銷輸出0 v時禁用。" B* c# C" n2 C$ c" D3 K' J+ I

5 B1 k/ e" o* q- }: z6 x#define SPINDLE_MAX_RPM 1000.0 // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.
3 V# t; e  V1 j; t9 u& j#define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM., ]1 r8 s% [6 U6 ~' [

5 O1 S: i) B, [& |; E7 f; x// Used by variable spindle output only. This forces the PWM output to a minimum duty cycle when enabled.- g+ ?: S, W/ }! D' m* }" _
// When disabled, the PWM pin will still read 0V. Most users will not need this option, but it may be
& Z  s5 a1 F; w  V9 U4 ]9 y$ X// useful in certain scenarios. This setting does not update the minimum spindle RPM calculations. Any7 |' b6 X  ~" ?  M$ }9 T
// spindle RPM output lower than this value will be set to this value.
5 p1 u4 ^# I2 _/ z6 K//使用的變量軸輸出。這迫使PWM輸出最小占空比時啟用。
6 C3 O" y) a) F, U  L. {' t//當禁用,PWM銷仍讀0 v。大多數用戶不需要這個選項,但是它可能是; l# H. a- Z) M& k$ Y
//在某些情況下很有用。這個設置不會更新最小主軸轉速計算。任何0 c3 I* g3 o. D: `$ N) l
//輸出軸轉速低于這個值將被設置為這個值。4 q& y) j) W3 n. p! W% Q3 G/ N
9 P$ o& a% `5 i" E# S( y
// #define MINIMUM_SPINDLE_PWM 5 // Default disabled. Uncomment to enable. Integer (0-255)' w) W0 z& b" v7 K
# G* b( @; r; D
// By default on a 328p(Uno), Grbl combines the variable spindle PWM and the enable into one pin to help
+ l& z  s( ~  S# P% m- A0 `// preserve I/O pins. For certain setups, these may need to be separate pins. This configure option uses6 B5 ~. T# B- j# W
// the spindle direction pin(D13) as a separate spindle enable pin along with spindle speed PWM on pin D11.
6 @: ?6 F' f8 `9 O" i' ^// NOTE: This configure option only works with VARIABLE_SPINDLE enabled and a 328p processor (Uno).
7 m# X3 z* {, Z) t$ `- F4 h* F( d// NOTE: With no direction pin, the spindle clockwise M4 g-code command will be removed. M3 and M5 still work.) d% I1 q6 I* o7 r& _9 l, |3 L
// NOTE: BEWARE! The Arduino bootloader toggles the D13 pin when it powers up. If you flash Grbl with/ [. _& a: e" ^, R# `; r8 I: E# i! j
// a programmer (you can use a spare Arduino as "Arduino as ISP". Search the web on how to wire this.),
2 [$ W! J' F1 P8 ~, w// this D13 LED toggling should go away. We haven't tested this though. Please report how it goes!
/ g& H; d5 W" w! d//默認ATmega328 p(Uno),Grbl結合變量軸PWM和使到一個銷的幫助/ f) A( T, z+ U& v( F3 r0 H
//保存I / O管腳。對于某些設置,這些可能需要單獨的別針。這個配置選項使用
& j7 n7 [( f) s$ M$ _//方向軸銷(D13)作為一個單獨的軸銷上啟用銷以及主軸轉速PWM這里。2 F* |% p0 e! p; ~( L5 Z
//注意:該配置選項僅適用于VARIABLE_SPINDLE啟用和328 p處理器(Uno)。
% w( e; y) S% r4 h( ~! @( Y//注意:沒有方向銷,主軸順時針M4刀位點命令將被刪除。M3和M5仍然工作。
- _3 Z7 l3 }  X7 F//注意:小心!Arduino引導裝載程序切換D13銷的權力。如果flash Grbl
" z# E& ~& T+ n4 }7 W* {//程序員(您可以使用一個備用Arduino“Arduino ISP”。搜索網絡如何線),4 @5 @: L9 Y) B0 V$ l- n$ y0 J2 j
//這D13導致切換應該消失。我們還沒有測試這個。請報告將會怎樣!; [9 A3 w- X6 g" ?6 Z

" i1 O* R1 i) R6 i, c: L' \// #define USE_SPINDLE_DIR_AS_ENABLE_PIN // Default disabled. Uncomment to enable.
2 J, F7 @" [% O7 J! c6 v9 Z
# X  V) M0 K6 D# I. C3 \7 Q' g$ Y// With this enabled, Grbl sends back an echo of the line it has received, which has been pre-parsed (spaces$ V; ^- @, u6 t0 H& ~! B
// removed, capitalized letters, no comments) and is to be immediately executed by Grbl. Echoes will not be 5 x$ S% O( I5 L0 t5 V# G1 s  Y  u8 z
// sent upon a line buffer overflow, but should for all normal lines sent to Grbl. For example, if a user
$ ~  ]. E8 P$ d% e* U8 `// sendss the line 'g1 x1.032 y2.45 (test comment)', Grbl will echo back in the form '[echo: G1X1.032Y2.45]'.
+ s. }9 I' I% {7 R// NOTE: Only use this for debugging purposes!! When echoing, this takes up valuable resources and can effect
5 ~3 h+ d/ |# e% }7 o$ O' Q// performance. If absolutely needed for normal operation, the serial write buffer should be greatly increased/ i! b2 H' L4 Y
// to help minimize transmission waiting within the serial write protocol.- H$ U( Q2 x: @* T8 i

& L" W8 P& N3 h* U, Z//啟用,Grbl發回的回聲線已收到,已預編譯(空間
7 z5 o3 M/ ^% ~( Y0 e1 K! Q" B/ O6 A//移除,大寫字母,沒有評論),由Grbl立即執行。回聲將不會
+ z9 y: P6 n' p$ [$ {$ i$ H//發送一個線緩沖區溢位,但應該對所有正常線路送到Grbl。例如,如果一個用戶
! @5 F& i8 j! Z$ i//發送線的g1 x1.032 y2.45(測試評論)形式”,Grbl將回聲”(回聲:G1X1.032Y2.45]”。: Q  D9 M- ?0 U7 {: k8 P
//注意:只使用這個調試! !當呼應,這占用了寶貴的資源,可以影響
. m5 h) N  z! i9 b) `5 k* c//性能。如果正常運行所需的絕對,串行寫入緩沖器應該大大增加
" L) o/ x6 w7 a& a) c8 [# l9 ^//幫助最小化傳輸等系列內寫協議。- ^3 Z. U/ Z5 v: ?6 }* R; a! [

: L( h, I  \* e* J4 u: J) p// #define REPORT_ECHO_LINE_RECEIVED // Default disabled. Uncomment to enable.  y, q! Z# Y2 [+ D# K

7 ^" m8 D. Y7 X0 B// Minimum planner junction speed. Sets the default minimum junction speed the planner plans to at
3 F4 z  e$ V( j# h* \4 |8 A$ Y// every buffer block junction, except for starting from rest and end of the buffer, which are always
) \! C% s: q1 \+ O// zero. This value controls how fast the machine moves through junctions with no regard for acceleration
9 q  ]/ X3 B, u2 v2 ?( Y& @// limits or angle between neighboring block line move directions. This is useful for machines that can't
% \6 G7 S! I. l// tolerate the tool dwelling for a split second, i.e. 3d printers or laser cutters. If used, this value
$ K& @/ e* `! f9 b, [// should not be much greater than zero or to the minimum value necessary for the machine to work.
6 E% c$ E  |: f. c+ q0 x$ o
/ X: i: `! D+ e3 j. }//最小規劃師結速度。設置默認最小連接速度規劃計劃
7 Z' k* Q1 N$ c! W8 {//每一個緩沖塊接頭,除了從結束休息和緩沖區,它總是. v1 |; S% [% t1 |* l8 f, V8 p& j8 b: u
// 0。這個值控制機器的速度穿過路口,沒有考慮加速度' [( A4 h- l2 X5 E
//限制或相鄰塊之間的角線方向移動。這是有用的機器,不能5 B( }4 K, q( @5 o  ^4 m: G6 ^
//容忍工具居住某一剎那,即3 d打印機或激光切割機。如果使用這個值
/ p& B' o: w6 h- O; ^) B//不應大于零或機器工作所需的最小值。
) |, D8 H$ ]( e) `4 i; ]* t* u( t6 A5 J& X; c* F
#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min)
6 q% k! w; ^4 d* h& u' Z
; }9 {+ ^6 r& \6 B, D: n, S// Sets the minimum feed rate the planner will allow. Any value below it will be set to this minimum
* C) U7 I7 J9 }7 l2 L) L0 d// value. This also ensures that a planned motion always completes and accounts for any floating-point. N& A& J( c2 O% P' O
// round-off errors. Although not recommended, a lower value than 1.0 mm/min will likely work in smaller
! q1 @# j# x0 I7 m! M, v// machines, perhaps to 0.1mm/min, but your success may vary based on multiple factors.- K7 D" _* Y9 C. Y4 @/ l
//設置計劃將允許的最小進給速率。任何價值低于它將被設置為最低值。這也保證了運動計劃總是完成,占任何浮點
6 W& Q: D% H! n# ?" E9 w5 V//舍入錯誤。雖然不推薦,價值低于1.0毫米/分鐘可能會在較小的工作
$ r! K( B( [2 E7 j//機器,也許到0.1毫米/分鐘,但你的成功基于多種因素可能會有所不同。' `3 K2 A9 ?4 n6 B. ^
: T7 X0 [) c1 C$ n
#define MINIMUM_FEED_RATE 1.0 // (mm/min)//設置計劃將允許的最小進給速率
% R, S* D; c& }3 }
: J! H' M( Z, o3 M+ Y// Number of arc generation iterations by small angle approximation before exact arc trajectory
8 m5 k- J3 o! `8 u( o// correction with expensive sin() and cos() calcualtions. This parameter maybe decreased if there
( g5 F; S( s  ^* d, e// are issues with the accuracy of the arc generations, or increased if arc execution is getting
; H) V2 ~4 E8 y' k: N2 J" N// bogged down by too many trig calculations.
1 w8 e' [5 ?8 F- L//弧生成迭代次數之前小角度近似精確的弧線軌跡
4 W& L0 X; J& k4 {6 ~  i1 E//修正與昂貴的sin()和cos()calcualtions。如果有這個參數可能減少
- W8 n% E: z% V//與弧一代又一代的準確性問題,或如果電弧執行得到增加4 E2 w2 d# v9 q$ R
//太多的三角計算的泥潭。0 e5 }! `* h$ C; A. p" y" o% y

# v$ {: _/ L, C' I( b$ B#define N_ARC_CORRECTION 12 // Integer (1-255)% C. s2 v, f$ }: f/ V
* q  A; T+ F5 ~# u& g6 b
// The arc G2/3 g-code standard is problematic by definition. Radius-based arcs have horrible numerical * }" C' x, h3 \) p8 J0 p( T' @
// errors when arc at semi-circles(pi) or full-circles(2*pi). Offset-based arcs are much more accurate
; d4 s4 ]8 L/ t% V5 ?. D1 N// but still have a problem when arcs are full-circles (2*pi). This define accounts for the floating ( l" ]7 j9 B4 Y
// point issues when offset-based arcs are commanded as full circles, but get interpreted as extremely
' J( {' i/ e* d4 ?% H$ h// small arcs with around machine epsilon (1.2e-7rad) due to numerical round-off and precision issues.
& V; ~  Y  x  l8 q. C9 }: U4 R// This define value sets the machine epsilon cutoff to determine if the arc is a full-circle or not.
: u: X' a- ^9 D8 Q% A1 ^: W// NOTE: Be very careful when adjusting this value. It should always be greater than 1.2e-7 but not too8 ~5 Z8 T, W! x$ r$ A2 I
// much greater than this. The default setting should capture most, if not all, full arc error situations.2 a8 R1 _9 x0 F0 Y. g
//弧G2/3刀位點的標準定義是有問題的。Radius-based弧有可怕的數值
' R) d  {- v! ?- n//錯誤當電弧在半圓(π)或原點(2 *π)。Offset-based弧更準確
5 B' r; o- L# t+ s  |//但仍有一個問題當弧原點(2 *π)。這個定義占浮動3 f: W* V' X: V; V1 |
//當offset-based弧吩咐點問題完整的圓,但解釋為極
' D) n  m3 g& e5 z/ m) H: K0 T//小弧機周圍ε(1.2 e-7rad)由于數字舍入和精度問題。# T! Z4 B5 x8 W0 `3 c' K
//定義值設置機器ε截止來確定電弧是一個原點了。5 x* p# L- M1 Z) F
//注意:調整這個值時非常小心。它應該總是大于1.2 e -但不要太
) J. U6 {; `. B* S$ r//比這大得多。默認設置應該捕獲大部分,如果不是全部,全部錯誤的情況。
0 F3 w( I' _6 O2 m
3 A5 K& P  q9 O' \- E#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)
6 i, O$ S7 U, K% ~' S- k
2 p% l/ p+ l7 F7 H7 L9 J// Time delay increments performed during a dwell. The default value is set at 50ms, which provides- ]: @7 ^$ G" r
// a maximum time delay of roughly 55 minutes, more than enough for most any application. Increasing
& w1 E+ S7 x! b) S& H5 ]' ]* g  v// this delay will increase the maximum dwell time linearly, but also reduces the responsiveness of
4 x0 d) F" O& Z4 m// run-time command executions, like status reports, since these are performed between each dwell
9 h$ ]8 T& N& d// time step. Also, keep in mind that the Arduino delay timer is not very accurate for long delays.# [$ _( Z" U0 `) N; h8 _2 o; H
//延時增加表現在住。默認值設置為50毫秒,它提供了/ @; @' d* S6 n& K5 X6 O9 y
//最大延時約55分鐘,足夠對大多數任何應用程序。增加$ q+ {6 ^1 G! F5 v" i7 _. u
//這種延遲將增加線性最大停留時間,也減少了響應能力2 ?* M5 }+ D+ W. U+ R8 P8 U
//運行命令執行狀態報告一樣,因為這些每個住之間執行+ Z: ^6 U3 g/ F8 z7 n  X1 x  t7 D
//時間步。還有,記住,Arduino延遲計時器不是很準確的長時間延誤。+ c: G9 Z& |7 ?1 Z

  ?/ \# f# e" a, p#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds)4 X1 F4 k" r  h! U$ `- ^# h

9 |) V" ]4 t/ U- ?% `+ A// Creates a delay between the direction pin setting and corresponding step pulse by creating
( I5 E( ?; z4 o! x' z. R, U# x/ M// another interrupt (Timer2 compare) to manage it. The main Grbl interrupt (Timer1 compare) 3 x# O1 l6 `" o
// sets the direction pins, and does not immediately set the stepper pins, as it would in
- ?& f, ^" s/ i1 w5 |( x$ [// normal operation. The Timer2 compare fires next to set the stepper pins after the step . D+ b+ t  u8 i1 o9 X/ }- r
// pulse delay time, and Timer2 overflow will complete the step pulse, except now delayed
# H5 K3 i! s8 R! R// by the step pulse time plus the step pulse delay. (Thanks langwadt for the idea!)
. Y' U0 \: D0 ?2 {' v// NOTE: Uncomment to enable. The recommended delay must be > 3us, and, when added with the# z1 f- s$ n9 n  I, T8 \- E7 s
// user-supplied step pulse time, the total time must not exceed 127us. Reported successful/ m0 g: T3 O2 W' d& Z1 F" T
// values for certain setups have ranged from 5 to 20us.
$ M. w* n- N5 p0 h. q//創建一個方向銷之間的延遲脈沖通過創建設置和相應的步驟
& [" K8 K* d0 K; ^. c. f//另一個中斷(Timer2比較)來管理它。主要Grbl中斷(Timer1比較)
& E) Z/ k7 H6 g) j) I1 ], B# f, ~//設置方向針,不立即設置步進針,因為它會在- D% m; X4 V- _- D8 N
//正常操作。Timer2比較火旁邊設置步進針后一步
( o' D/ b2 Z0 e2 N5 e. p! x' K- g//脈沖延遲時間,Timer2溢出脈沖將完成的步驟,現在延遲除外% ]# I6 B0 f4 `; e5 j# [
//脈沖時間加上的一步一步脈沖延遲。(感謝langwadt主意!)& `7 O& z* j2 n: S) k
//注意:取消啟用。必須> 3,建議延遲,當添加的
; P$ P$ r6 |2 m//用戶提供的步驟脈沖時間,總時間不得超過127美元。成功的報道
7 J; s3 O3 C6 S& J& b# k//值對某些設置范圍從5到20。' y" E- t+ H" c+ f) Q) p
" i4 [: P2 G8 c* O
// #define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.- X' B7 T- J2 ^% i" }5 [  y
; j3 R3 T. t, A+ d. G
// The number of linear motions in the planner buffer to be planned at any give time. The vast8 Z( E* z  g. ?  s5 L: ?6 u$ W8 \
// majority of RAM that Grbl uses is based on this buffer size. Only increase if there is extra
  J$ l2 y9 ~& n5 `/ r5 I! v  P// available RAM, like when re-compiling for a Mega or Sanguino. Or decrease if the Arduino( {5 N4 @7 z. e% A5 r1 M
// begins to crash due to the lack of available RAM or if the CPU is having trouble keeping4 w' o$ l- E8 \1 t( e% [6 |0 v
// up with planning new incoming motions as they are executed. ' `- K7 B# Q  v9 X; ]# e$ n
//線性運動規劃師緩沖區的數量在任何給出時間計劃。絕大! o$ J9 x& Q( v; s  M; H9 G/ A1 q
//多數RAM Grbl使用基于這個緩沖區的大小。如果有額外的只會增加
4 Y) L5 H3 w" s0 R' j//可用內存,比如當基于大型或Sanguino。如果Arduino或減少
( l4 {# B5 P# G, ~3 G/ k1 @- k9 ^//開始崩潰由于缺乏可用的RAM或者CPU是難以保持6 J8 q* [7 n/ N% W5 `, t) M
//與規劃新傳入的動作執行。
) Q5 f2 |  a( o" G# ]" q
$ o/ T4 J- O' ^) b/ T. d// #define BLOCK_BUFFER_SIZE 18  // Uncomment to override default in planner.h.
  J- r# e. I% A7 s! W6 M% k1 i2 c& X" N2 p2 E
// Governs the size of the intermediary step segment buffer between the step execution algorithm7 r$ T* }' o" R  K# w
// and the planner blocks. Each segment is set of steps executed at a constant velocity over a
' @/ W0 E/ n3 o6 |  r* R// fixed time defined by ACCELERATION_TICKS_PER_SECOND. They are computed such that the planner3 ^$ u# i2 ~5 U. B2 Z9 W9 o) r7 O) T1 U
// block velocity profile is traced exactly. The size of this buffer governs how much step 1 L4 }# F4 W7 f3 i1 G  e, A, n" Z
// execution lead time there is for other Grbl processes have to compute and do their thing 9 v: Z  }( k4 r# s7 u
// before having to come back and refill this buffer, currently at ~50msec of step moves.! _1 H8 X+ g6 P- M; o
//控制之間的中間段緩沖大小的步驟執行算法# y3 H  Q2 d7 N
//和規劃師塊。每一部分的步驟執行在一個恒定的速度- n7 n* E( y/ L
//固定的時間由ACCELERATION_TICKS_PER_SECOND定義的。他們計算的計劃7 K' ~+ X. ^( U2 c0 Y
//塊速度剖面追蹤到底。這個緩沖區的大小控制多少步驟+ c1 g, b! p" z; t5 R  T2 k
//執行時間有其他Grbl過程需要計算和做他們的事情/ p7 }! D. C. ?: G0 l, g) @
//之前必須回來重新填充這個緩沖區,目前移動~ 50毫秒的一步。& G: \! h' S. n; s: I
1 E! ?. ~+ O' n
// #define SEGMENT_BUFFER_SIZE 6 // Uncomment to override default in stepper.h.
" _. i5 G! X8 v- J) W
6 M. o1 r8 e6 ]// Line buffer size from the serial input stream to be executed. Also, governs the size of 3 n, y  K2 M; s& H
// each of the startup blocks, as they are each stored as a string of this size. Make sure
/ z/ b& ?, m5 H2 H- f7 E// to account for the available EEPROM at the defined memory address in settings.h and for
+ V: c1 q$ K4 W8 v% W// the number of desired startup blocks.  f- I1 R/ }2 O
// NOTE: 80 characters is not a problem except for extreme cases, but the line buffer size
% F# |( [) h, q9 M, p$ T// can be too small and g-code blocks can get truncated. Officially, the g-code standards
1 b- q3 D( C; [1 U// support up to 256 characters. In future versions, this default will be increased, when * B& X2 k( n4 E9 b9 u$ J
// we know how much extra memory space we can re-invest into this.
* ], Q# ~8 D9 A6 w( j/ s//行執行串行輸入流的緩沖區大小。同時,大小的控制
8 s5 [1 O5 o9 y/ [! c- p* B//每個啟動模塊,它們分別存儲為字符串的大小。確保- d8 Z1 P6 J  U5 I
//占可用eepm定義內存地址的設置。h和9 ~, q1 |3 K) l% @  y$ [
//需要啟動塊的數量。
8 A3 A& N& h% U! ]- Y//注意:80個字符不是一個問題,除了極端的情況下,但線緩沖區大小5 W* K+ w  g0 m. Y4 w8 u- C
//可以太小和刀位點塊可以截斷。正式,刀位點標準# |& |  N& q% {" K3 z4 e6 F! r) ?. c
//支持多達256個字符。在未來的版本中,這個違約將會增加,當) q5 q2 V! n# R+ K7 X9 o
//我們知道多少額外內存空間的時候我們可以再投資。
2 P7 p' h5 h( P; @/ ]  D; E9 J0 A  K. ^) @" h. J; c: V& f$ E6 U! J
// #define LINE_BUFFER_SIZE 80  // Uncomment to override default in protocol.h' b7 `8 R% I! b( ~, t( P
  
. I, ]! N! r5 }+ A6 q  V  i% T- P// Serial send and receive buffer size. The receive buffer is often used as another streaming2 N# c' G! A# a+ k
// buffer to store incoming blocks to be processed by Grbl when its ready. Most streaming
1 R3 _) D: ~8 f4 t( ?8 _% \8 h// interfaces will character count and track each block send to each block response. So, 5 c7 T3 {# A: _3 m
// increase the receive buffer if a deeper receive buffer is needed for streaming and avaiable
+ \5 S! R9 f  }/ n9 a7 _& F9 \# w// memory allows. The send buffer primarily handles messages in Grbl. Only increase if large
1 N# `  ~! ~. O$ S/ m8 {// messages are sent and Grbl begins to stall, waiting to send the rest of the message.
6 ?) e6 h7 e( D6 @' F% R" y4 C// NOTE: Buffer size values must be greater than zero and less than 256.! @; w# D4 ^* l" U
// #define RX_BUFFER_SIZE 128 // Uncomment to override defaults in serial.h7 i) r. _+ u, P6 Q0 N
//串行發送和接收緩沖區大小。接收緩沖區通常用作另一個流. ]9 f  }" G9 [
//緩沖存儲傳入的塊來處理Grbl當它準備好了。最流8 I& D9 C9 W/ Z4 t
//接口將字符計數和跟蹤每一塊發送給每個塊的回應。所以,$ o5 u& S/ n5 Q2 f  V' g
//增加接收緩沖區如果需要更深層次的接收緩沖區為流,、& u6 s- g; n/ T' d) b4 p# l" z" `) }
//內存允許。Grbl發送緩沖主要處理消息。只會增加如果大" _; U. _9 g; x
//消息發送和Grbl開始停滯,等待發送其余的消息。0 T% _( c4 u' ~4 X! l
//注意:緩沖區大小值必須大于零,小于256。/ e6 L' `# c0 Z6 D# \$ j
// # define RX_BUFFER_SIZE 128 / /取消serial.h覆蓋默認值
2 [% a" q2 B# O) P) F
- T/ ~. e/ M* X8 f
2 _" D1 f; ]3 \* x$ T; X9 N// #define TX_BUFFER_SIZE 64
$ F% ^, @0 `* w( z" |  j3 I    f. D! r/ b& J# |2 c# y# |% l
// Toggles XON/XOFF software flow control for serial communications. Not officially supported
8 X, _) ]  o& i2 c1 X- `// due to problems involving the Atmega8U2 USB-to-serial chips on current Arduinos. The firmware
$ B% `# e$ h  H# F% H2 B) v// on these chips do not support XON/XOFF flow control characters and the intermediate buffer
6 d& D+ }8 w1 D' n$ O* t; Z// in the chips cause latency and overflow problems with standard terminal programs. However, 3 _9 e) y. F; |
// using specifically-programmed UI's to manage this latency problem has been confirmed to work.8 C7 E: X# z) Y0 \' p
// As well as, older FTDI FT232RL-based Arduinos(Duemilanove) are known to work with standard
$ @4 T$ \. ?/ Q  P) ]- t9 V  n// terminal programs since their firmware correctly manage these XON/XOFF characters. In any7 j+ R4 f* f  a+ m, a
// case, please report any successes to grbl administrators!( }1 ?7 ^0 h+ S0 W* n9 z
//切換為串行通信發送樸通/發送葡開軟件流控制。不是官方支持4 r+ c* K6 S2 u) Y; U8 d( T' S2 L
//由于問題涉及Atmega8U2 USB-to-serial當前arduino芯片。固件
6 V9 \7 q& U( {. E* T& H" [1 B//在這些芯片不支持發送樸通/發送葡開流控制字符和中間緩沖區/ ~+ S; D+ y1 O( Y8 D' B
//芯片導致延遲和溢出問題的標準終端程序。然而,  X  r# W  [+ M- Y3 j
//使用specifically-programmed UI的管理這個延遲問題已經確認工作。! @: j0 i% }% \4 G. x' A
//以及老FTDI FT232RL-based arduino(Duemilanove)是已知的標準) {8 l' W; f! \" ]
//終端程序因為他們正確的固件管理這些發送樸通/發送葡開的角色。在任何4 w+ T: V& e- x& Y
//情況,請報告任何成功grbl管理員!
: N' z% T% J2 z$ {( U1 W, J1 i
: m4 O* X  W" ^, s1 o, b; N6 s) Y// #define ENABLE_XONXOFF // Default disabled. Uncomment to enable.' O: k  [  I$ [7 O5 x# @: B

* G0 s# R7 A0 R% a1 Y* I// A simple software debouncing feature for hard limit switches. When enabled, the interrupt + z* U8 h8 q" `  I( O
// monitoring the hard limit switch pins will enable the Arduino's watchdog timer to re-check ; X7 G" E. R! v8 R2 }, v
// the limit pin state after a delay of about 32msec. This can help with CNC machines with ( c' I5 ?5 g- K% h
// problematic false triggering of their hard limit switches, but it WILL NOT fix issues with ; {# o0 ^" ]1 V, B- G
// electrical interference on the signal cables from external sources. It's recommended to first
; {# a2 A; c. R! B6 r// use shielded signal cables with their shielding connected to ground (old USB/computer cables
! n2 x! r4 }1 ~+ Y0 g1 M// work well and are cheap to find) and wire in a low-pass circuit into each limit pin.
. T1 ^( X2 |+ u$ E* w* B6 T+ n//一個簡單的軟件消除抖動特性硬限位開關。當啟用時,中斷
" i, i; G3 f4 p7 ?9 j9 ~//監控硬限位開關針將使Arduino的看門狗定時器重新審視
! W: `- g  `  I) y7 e3 b& s//銷的極限狀態后約32毫秒的延遲。這可以幫助與數控機器; c( v3 x- y" c- v3 Z
//問題錯誤引發的硬限位開關,但是它不會解決問題7 _/ a4 a/ _8 S. l6 ~( a
//電干擾信號電纜從外部來源。首先它的建議) t( @* X0 A9 K( Y( n
//使用屏蔽信號電纜的屏蔽連接到地面(老USB /計算機電纜1 X' N8 M7 i9 z
//工作得很好,很便宜)和線低通電路到每個限位銷。  r; ^" i5 a+ c* C

1 F6 ?. q3 ^4 {  k7 ]5 [' y// #define ENABLE_SOFTWARE_DEBOUNCE // Default disabled. Uncomment to enable.' }* O( @; C6 `0 ]3 I
$ {+ S& h6 p7 x6 O) c7 ]
// Force Grbl to check the state of the hard limit switches when the processor detects a pin
0 O9 U. i% F$ q' C: o// change inside the hard limit ISR routine. By default, Grbl will trigger the hard limits3 q, [( v  z- G# Y+ P. e
// alarm upon any pin change, since bouncing switches can cause a state check like this to + b3 s* b. A# F" E- F0 u$ h
// misread the pin. When hard limits are triggered, they should be 100% reliable, which is the
& \. Q3 p& d. a0 u9 k$ n  y// reason that this option is disabled by default. Only if your system/electronics can guarantee
1 @( e9 N: g4 E// that the switches don't bounce, we recommend enabling this option. This will help prevent
3 F2 k. d( m1 P2 B& e// triggering a hard limit when the machine disengages from the switch.
- ^2 }& V. b/ p$ I* e5 e  P// NOTE: This option has no effect if SOFTWARE_DEBOUNCE is enabled.8 F1 M: d+ h# v- n2 ^1 U
//力Grbl檢查硬限位開關的狀態,當處理器檢測到一個銷
0 ?: U% q( F4 p  X) T//改變內部硬限制ISR例行公事。默認情況下,Grbl將觸發硬限制
# Q1 b8 \$ u* L5 _7 _/ W. e//報警在任何銷更改,因為跳開關可以導致這樣的狀態檢查
1 Y4 K" l* \6 X. V/ Q//誤讀了銷。硬限制觸發時,他們應該100%可靠,這是3 ?5 X  x- G( D3 R
//原因,這個選項默認是禁用的。只有在你的系統/電子產品可以保證
+ x7 V& Q* s. Z6 |/ }% `//開關不反彈,我們建議啟用這個選項。這將有助于防止7 Y( M$ p  b3 T- N3 {
//觸發機退出時硬限制開關。* W/ T. t( L1 n
//注意:這個選項如果啟用了SOFTWARE_DEBOUNCE沒有影響。
& c2 m( [) h9 o# `3 V& n2 ~5 ^+ g8 Q0 \7 H7 A* ?7 G! z* u- i
// #define HARD_LIMIT_FORCE_STATE_CHECK // Default disabled. Uncomment to enable.
. c& t- [+ q$ J+ Q! M, d( A) U8 `
( ]% d: e" W6 V3 Y
// ---------------------------------------------------------------------------------------: e# ]! Y7 D1 O  P0 P, s
// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:編譯時錯誤檢查的定義值:
4 Q- S8 u0 v2 M! ?. ]& t% O+ g" U$ Z  ^; S1 `; D
#ifndef HOMING_CYCLE_0) d- \% F2 G+ w! m( ?' c" [
  #error "Required HOMING_CYCLE_0 not defined."( ]" q1 l+ Y( P7 F
#endif
, p# @  k0 m7 D; W) B" M4 M) V# w" {
$ Z9 L3 H7 I) H. L' F7 ^#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(VARIABLE_SPINDLE)0 t( e- T1 r+ H0 W# K, K, q
  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with VARIABLE_SPINDLE enabled"$ G% d/ P3 v8 ]& L) ^1 H1 J
#endif
" `8 c( p% r; R8 D
( m9 ~, [; l) p! |! p2 w: {  o#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(CPU_MAP_ATMEGA328P)
4 a  j8 I2 F7 z- P. {: `5 t/ O  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with a 328p processor"2 [6 m" Q: E7 b8 `
#endif
( O+ Q) r5 G/ s6 A+ b
5 R# {0 k8 `5 B, \! S; C; l# ]9 h  f// ---------------------------------------------------------------------------------------0 H* ^5 P" ^5 l" H

! O+ X. w) k# p+ F6 l
! }, O; F# ^8 P1 m% d#endif
" ]8 d; t: z7 v/ b* s
/ V5 q) i$ k( i( ]8 ]! X. f1 q! m  t: G: N/ Y
8 L8 Q# ?1 r0 `" e% o) e

1 ^0 ?) ~/ Y$ g. y* I- d2 O0 m, X, x7 a7 L( S4 l1 l1 s0 [. a

: L5 d, i1 A! W+ V& N- n4 N
9 E' i4 Y$ C4 Q& a! g* f  N6 O9 c; s) A/ H4 Z
9 I, o& D* A. I& d

' _. h; Y+ I- g/ v; B# z% L( ?
) I# V- e$ m5 [6 {
3 {; m2 M. V* N4 n; q% o7 N
' g8 L7 T6 t" Z2 t. Z6 g0 D" b4 e
) j7 a. R: c& z- e. y5 Q' E: O$ w

) z  y) ~- C3 y. n4 |5 N

本帖子中包含更多資源

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

×

評分

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

查看全部評分

回復

使用道具 舉報

2#
 樓主| 發表于 2016-8-21 00:11:42 | 只看該作者
那些沒有用的照片不知道怎么就上去了好討厭。
3#
 樓主| 發表于 2016-8-21 00:14:16 | 只看該作者
7 p: k( o8 a: f: A4 u" ^' u1 b
4#
發表于 2016-8-21 05:50:22 | 只看該作者
      樓主厲害!
5#
發表于 2016-8-21 08:22:05 | 只看該作者
謝謝樓主,先收藏一下,慢慢學習
6#
發表于 2016-8-23 15:11:25 | 只看該作者
這是什么寶貝?
7#
發表于 2016-8-23 15:11:47 | 只看該作者
換了個瀏覽器Chrome,試試能否發言了。
8#
發表于 2016-8-23 20:12:33 | 只看該作者
樓主厲害
回復

使用道具 舉報

9#
 樓主| 發表于 2016-8-23 23:03:17 | 只看該作者
補充
2 W$ c+ |+ E* Y; G( Y0 q1 \5 p程序運行protocol_execute_realtime(); /運行實時命令。
4 U/ p0 C; L- [% p5 @  m// Executes run-time commands, when required. This is called from various check points in the main  x# e8 P7 w) G8 Z
// program, primarily where there may be a while loop waiting for a buffer to clear space or any$ L4 Q& B0 a  v. x
// point where the execution time from the last check point may be more than a fraction of a second.
$ C3 |* o" g5 v2 [/ w: i9 c// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code! {6 A/ y, E# X: q  r' G' g) @
// parsing and planning functions. This function also serves as an interface for the interrupts to " h$ I/ \, w4 S& q. R/ U5 m
// set the system realtime flags, where only the main program handles them, removing the need to
  f; O* z0 r! e7 Z4 P4 @// define more computationally-expensive volatile variables. This also provides a controlled way to
/ J/ u( \5 s) G( e6 u6 X// execute certain tasks without having two or more instances of the same task, such as the planner
  t* P; I' g$ L. L4 k2 @% i// recalculating the buffer upon a feedhold or override.
8 @, d8 U. K( Q+ r// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,
) v5 z& T8 Y8 ~: a1 f// limit switches, or the main program.
; h! l; ^4 G$ z3 w0 b0 V
- w2 W" s$ c$ ~/ |' z, h+ @4 I//執行運行時間命令,在需要時。這就是所謂的從各種主程序要檢查站
& g* C0 M. ]) P1 _//,主要是那里可能是一個while循環等待緩沖區空間或任何
$ X# @, X4 z9 T/ I, |& x//執行時間從過去的止點可以超過幾分之一秒。; W% J2 J  l5 M, V' Z# C# s
//這是一種異步執行實時命令(又名多任務)grbl的刀位點+ [; s' l0 q3 |+ A
//解析和規劃功能。這個函數也可以作為一個接口,用于中斷9 q2 Z' G/ n2 j# \  J
//設置系統實時的旗幟,只有主程序處理,消除的需要; D7 y0 m& q$ j+ Q; f9 `+ U7 E
//定義更多的計算昂貴volatile變量。這也提供了一種控制方法2 ]$ r* h/ U1 F
//執行某些任務不相同的兩個或多個實例的任務,比如計劃# m& u/ Y" U1 d3 \- q0 G+ g/ |
//重新計算緩沖feedhold或覆蓋。
: v6 o- O( C9 [9 g0 p//注意:sys_rt_exec_state變量標志設置任何過程,步驟或串行中斷,插腳引線,+ F. H1 W  B; H3 \3 ?; s
//限位開關或主程序。
1 E: V, A/ X/ g  I. f$ Jvoid protocol_execute_realtime()& y. \/ o" m  T9 s
{
1 p7 F/ {" P+ a        // Temp variable to avoid calling volatile multiple times.
# n5 r" Y* p& Q        // 臨時變量來避免多次調用不穩定。
3 A# I( d/ N7 c7 n- B. e        uint8_t rt_exec;
+ q) V& ]& v9 E9 f# B6 w        do{
6 X3 F3 O; S% s* A# I          if (rt_exec) {                 // 有標志位置位進入
/ N: a' f) \4 I* Y. j6 z       
% {; d/ c( e$ z% q; \: O. O: M4 C            sys.state = STATE_ALARM; // 設置系統為報警狀態
; }' Y  Z4 `. F8 l* A      report_alarm_message(ALARM_HARD_LIMIT_ERROR);        //報告報警信息為接近極限值
+ ^) S/ a) H: X& Q- y2 x- R) ]    } else if (rt_exec & EXEC_ALARM_SOFT_LIMIT) {                        //報告執行軟件限位報警
1 Z2 Z$ \; X; e8 G      report_alarm_message(ALARM_SOFT_LIMIT_ERROR);        //報告出現軟件限位報警
1 |: `. u4 \$ N5 r- |$ U9 @    } else if (rt_exec & EXEC_ALARM_ABORT_CYCLE) {                //執行停止循環報警      
! |# o" u8 a' w) z9 q. }6 G      report_alarm_message(ALARM_ABORT_CYCLE);                //出現終止循環報警
- G8 z# y* }: ?5 q    } else if (rt_exec & EXEC_ALARM_PROBE_FAIL) {                        //執行探查失敗報警* m, D1 D& m' `
      report_alarm_message(ALARM_PROBE_FAIL);                        //出現探查失敗報警
2 S3 c* v; S+ W$ `/ k    } else if (rt_exec & EXEC_ALARM_HOMING_FAIL) {                //執行返回原點失敗報警# R4 {* v4 i5 p
      report_alarm_message(ALARM_HOMING_FAIL);                //出現返回原點失敗報警+ Z: I5 q3 _" a3 l+ W
    }
2 A3 @/ M% Y: c% _
3 x- s# J/ W; z, R    // Halt everything upon a critical event flag. Currently hard and soft limits flag this.! [9 D9 M9 ?! c5 y& B4 i* \; P% w
    // 停止一切在一個關鍵事件標志。目前硬和軟限制標志9 H8 J) ^5 _4 U* d
           if (rt_exec & EXEC_CRITICAL_EVENT) {                //如果系統是循環事件進入
8 z  J0 ]2 M  U  ^             report_feedback_message(MESSAGE_CRITICAL_EVENT);        //報告反饋信息
) K, p$ O5 R9 d( S5 M- J( g" O              bit_false_atomic(sys_rt_exec_state,EXEC_RESET);                         //清除目前的復位狀態
- C* |9 R' B( C- I* E& l- G1 [' i, e7 Z5 N2 l& G' e0 K/ B
        bit_false_atomic(sys_rt_exec_alarm,0xFF);                                 // 清除所有報警標志/ `+ B' S# L3 f1 V; g1 i9 Y! h- f
        }       
/ d- C5 O2 L$ _3 B. C, s
0 E. ?1 X6 u# \上面代碼將rt_exec = sys_rt_exec_alarm ,如果rt_exec為真,打印不同報警信息: r' _3 t. z; p9 _! U7 K$ i
和限位保護信息,然后清除報警狀態
/ a. F/ Y2 ?$ W6 r! T+ \" Z___________________________________________________________________________. M$ n0 @- n2 W) R2 H
沒有報警進行執行下面代碼,執行了終止命令,串口打印命令9 @/ L1 l7 u# s* U' Q" S
        // Check amd execute realtime commands        校驗和執行實時命令
2 i* _/ U9 {4 D5 X2 e$ e          rt_exec = sys_rt_exec_state; // Copy volatile sys_rt_exec_state8 ~" Q) q+ u( Z7 l% {
0 b7 Y6 Q7 C, d6 x  Z7 h$ w* c. }
        if (rt_exec) { // 輸入標志是正確的執行, n; S1 U. H/ K: R- Y
2 L1 q; O' Y1 @0 }
            // Execute system abort. 執行系統終止命令% M# b% w8 R* F" ^
            if (rt_exec & EXEC_RESET) {- E7 H# j' w9 e' [8 V9 O' d
              sys.abort = true;  // Only place this is set true.
( l3 b: L1 c/ k8 t- u6 O              return; // Nothing else to do but exit.! f" }. ^9 _& E; I3 J3 z$ p
        }
9 S; P4 Z1 Q7 x4 w0 A8 C: F4 e) m$ k/ R! E$ o
            // Execute and serial print status 執行和串口打印狀態4 b4 A& }( ^4 ~' X! S. `+ g
            if (rt_exec & EXEC_STATUS_REPORT) {
* I8 _, z# q. a% ]2 }: s              report_realtime_status();        //報告實時狀態
$ ^; [/ K: J. B# d1 [              bit_false_atomic(sys_rt_exec_state,EXEC_STATUS_REPORT);        //清除報告狀態清零
/ ~" Z5 H. W4 R) u+ x" b            }8 k# R7 e, B. p
_____________________________________________________________________________
5 }7 C$ G7 Q( r+ D8 M$ [! p  N下面代碼0 {1 H  M% U  ]7 [& g
//執行狀態。
/ l' g: ?3 H; U$ l//注意:所涉及的數學計算持有應該足夠低對大多數人來說,即使不是全部,6 d6 D- X7 @& J) w7 H1 B
//操作場景。一旦啟動,系統進入暫停狀態
& z4 J1 m( T2 i//主程序流程,直到重置或恢復。8 T: D. ~$ A' c2 V; [, ^: I
待辦事項:檢查模式?如何處理呢?可能沒有,因為它只會在空閑,然后重置Grbl。
5 O9 c: y1 w3 F: m% g7 S$ X狀態檢查容許狀態的方法。' h6 J) e5 N- L5 r

! V- }# B8 F. l3 a& D7 z        //如果全局各自報警標志位其中(執行取消動作) | (執行進給保持) | (執行安全門)任意一位為真進入
( X9 V( P2 J. j+ d            if (rt_exec & (EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR)) {       
( Z7 Y3 z+ m% `/ r
* s4 B$ O' g/ {' k' i        //如果是循環狀態執行暫停狀態
, _  N) g. W. \" {' m- d        if (sys.state == STATE_CYCLE) {/ u. B" h7 [* S  R1 ?* G
        st_update_plan_block_parameters(); //通知stepper module驗算減速。1 C' L; Y3 y  t( T# ]1 [
        sys.suspend = SUSPEND_ENABLE_HOLD; // 開始暫停標志
% v0 b2 U  W4 N4 o8 z3 f- z        }4 w& E# M. ^" D$ V; \
# k9 u4 s- _: G2 p/ @  ?
        // 如果,Grbl空閑不在運動。簡單的指示暫停就緒狀態。
6 D! o1 S' z& T$ L1 F8 }# d        if (sys.state == STATE_IDLE) { sys.suspend = SUSPEND_ENABLE_READY; }! W+ k0 M) @; K0 \. x+ ?- u

0 I4 f( S" |! {" j: Q3 d) R( k# }; s# c& F# b' g2 T
        //執行和標志和減速運動取消并返回空閑。主要由探測使用周期
5 t' |3 ?1 \! t        //停止和取消剩余的運動。      
# ~( A1 y' e' t& ]2 l' d6 ~        if (rt_exec & EXEC_MOTION_CANCEL) {- I9 i2 c" r, u& o. U
          if (sys.state == STATE_CYCLE) { sys.state = STATE_MOTION_CANCEL; }# U* W6 l, I% s
          sys.suspend |= SUSPEND_MOTION_CANCEL; 6 f4 E' |3 X  J& z; _+ D: z8 r
        }) u4 }( P2 C- C: G: ^2 ?. n/ z( \
7 z$ U5 Q. X! o! ~0 P( o& x2 \
        // 只在循環時執行進給保持減速
& p9 d0 g9 c, U9 ?( @& _% ]         if (rt_exec & EXEC_FEED_HOLD) {5 I/ m& y. E8 t+ X) Z+ e
        //只有安全門為1才執行保持進給狀態賦值2 M. p/ j/ h3 [1 K% W8 P
          if (bit_isfalse(sys.state,STATE_SAFETY_DOOR)) { sys.state = STATE_HOLD; }
! ^, L2 C' w6 c        }
' [6 S2 h& A1 {# j5 V$ P& t! K1 P# u& x# h
        if (rt_exec & EXEC_SAFETY_DOOR) {
1 X1 G( j) ]+ x, q8 C          report_feedback_message(MESSAGE_SAFETY_DOOR_AJAR);
, @; S! {5 A, M% x. R* L- X/ /如果已經活躍,準備好重新開始,CYCLE_STOP標志設置為強制斷開。
$ X- S! {0 A) \8 I3 ~4 i/ /注意:只是暫時設置“rt_exec”變量,不是動蕩的“rt_exec_state”變量。
- C* v! N# ~7 x  _$ K+ O          if (sys.suspend & SUSPEND_ENABLE_READY) { bit_true(rt_exec,EXEC_CYCLE_STOP); }+ J" D) C, `& `& S& A5 F
          sys.suspend |= SUSPEND_ENERGIZE;
3 ?/ @4 W" Q6 K& \( M! m          sys.state = STATE_SAFETY_DOOR;
& }7 b! u# M4 B        }
. F2 @' s: H# c! y6 [6 T. D! O4 d5 D: x/ N, {# ~3 B5 o
bit_false_atomic(sys_rt_exec_state,(EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR));   
( u  L5 }& g" g% b8 E; c4 z  @. _  Y6 P; i
}, a' g3 ~# \& E& R# f
以上代碼執行了
0 O5 H  J4 B3 u( A8 Y- J1.如果全局各自報警標志位其中(執行取消動作) | (執行進給保持) | (執行安全門)任意一位為真進入+ R& d% K( F* h# T( |( p( W
2.系統為閑著狀態, 開始循環狀態, 回原點狀態, 控制取消狀態, 開始保持狀態, 開始安全門狀態時進入) A1 Y1 [$ @8 H
3.如果是循環狀態執行暫停狀態
1 g3 o7 |& `0 C. e3 j8 {( P4.如果系統閑置狀態執行暫停就緒狀態
4 q+ J/ N! u+ B' D) {" @2 x5.執行動作取消. A  {! X7 {  _
6.如果是保持進給狀態,執行保持進給狀態+ I4 p* D- p, M2 m5 R6 Q9 p
7.執行安全門狀態
1 `4 K; W  C4 e3 k7 q最后執行bit_false_atomic清標志清除(執行取消動作)(執行進給保持)(執行安全門)標志位                 
7 ~) Q3 Y" M7 Y, H4 A/ W$ A_____________________________________________________________________________
" s! e6 ?' M& f& I+ ?+ E' u0 ?) ]0 g6 k1 B4 Z9 Z7 L9 p* L- F
    // Execute a cycle start by starting the stepper interrupt to begin executing the blocks in queue.
. p  z7 \2 \8 D5 q; Z. u7 Y$ L    // 執行一個循環開始啟動步進開始執行中斷隊列的街區- @$ ~+ B3 L* M$ q
    if (rt_exec & EXEC_CYCLE_START) {        //循環開始狀態進入0 L- i) b4 ]. U- t
      // Block if called at same time as the hold commands: feed hold, motion cancel, and safety door.
- K+ F4 \6 h6 ^; W# |# R      // Ensures auto-cycle-start doesn't resume a hold without an explicit user-input.) V( p, }  C4 W) O+ X3 M3 Q( [2 O
          //塊如果在同時舉行的命令:保持進給,運動取消,和安全的門。 //確保auto-cycle-start沒有簡歷沒有顯式的用戶輸入。) n+ B9 m" i* X  ^0 j
           5 O8 {3 l4 {, b. D! ?
      if (!(rt_exec & (EXEC_FEED_HOLD | EXEC_MOTION_CANCEL | EXEC_SAFETY_DOOR))) {   //狀態機如果不是保持進給,運動取消,和安全的門。
/ q- X8 t; }2 ^& o        // Cycle start only when IDLE or when a hold is complete and ready to resume.
" q# |% g% @7 @        // NOTE: SAFETY_DOOR is implicitly blocked. It reverts to HOLD when the door is closed." x5 d3 G* ~* O% ?* L! L
                //循環開始時只有當閑置或持有完成并準備簡歷。+ n+ f9 p* |6 s  H# b$ P
                //注意:SAFETY_DOOR是隱式地屏蔽。它返回的時候門是關閉的。   
0 w4 c; P& z  m1 S, E# ]. N* R1 A
                // 如果系統狀態為閑著狀態,系統狀態為開始進給或運動取消,暫停標志為位重新開始
! _- P7 l% _' c1 ^0 w! ?- I        if ((sys.state == STATE_IDLE) || ((sys.state & (STATE_HOLD | STATE_MOTION_CANCEL)) && (sys.suspend & SUSPEND_ENABLE_READY))) {
" D  ~( ]* W% b/ T  H          // Re-energize powered components, if disabled by SAFETY_DOOR.2 _9 C' n2 T& t/ D  Q' x
          //        由SAFETY_DOOR重振組件供電,如果禁用。* ~' @: N6 r0 l% v2 }. ~5 U4 M
          if (sys.suspend & SUSPEND_ENERGIZE) {
& A& r  i2 c# B  J+ ?! t4 j            // Delayed Tasks: Restart spindle and coolant, delay to power-up, then resume cycle.
# F$ r8 ]1 z0 M            //延遲任務:重新啟動主軸和冷卻劑,延遲升高,然后恢復周期。( I* I; n5 [& T& Q1 H9 }
            if (gc_state.modal.spindle != SPINDLE_DISABLE) {   //主軸模式不是失能進入2 M% ?" l- a0 r# l1 X$ x- U
              spindle_set_state(gc_state.modal.spindle, gc_state.spindle_speed); //設置狀態和速度
/ K/ k! W* z; i' e" [. l              //待辦事項:阻塞函數調用。最終需要一個非阻塞。# [9 V- ^4 N% x( `6 c0 A" ^
                delay_ms(SAFETY_DOOR_SPINDLE_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.
2 Y2 j% ~3 J3 T; R            }
& J* ]* R1 H9 L9 C7 h: G            if (gc_state.modal.coolant != COOLANT_DISABLE) { 5 ~: p& L& E' c8 J7 s- o" V
              coolant_set_state(gc_state.modal.coolant);
, m0 [( j# C, R$ X' Y+ I              delay_ms(SAFETY_DOOR_COOLANT_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.$ B* K' a* o% D! r  ~$ k
            }
1 ^! M; u0 P" g7 _8 O; b( l* V            // TODO: Install return to pre-park position.  b- k, f- e: ]) g1 x0 u2 z5 s( E  |
          }, Z+ f  r/ S( V# a, |
______________________________________________________________________________________________________________
& v$ A, Q; B4 h8 b' D          // Start cycle only if queued motions exist in planner buffer and the motion is not canceled.
7 w  y. X: O! W                  ( @+ j* e+ r; F& W* M% X
                  //只有在隊列馬達存在規定的緩沖,并且動機沒有讓取消,才會循環/ b' J! p8 S5 b6 Y$ A
                  
6 e! G! `" r0 H* o          if (plan_get_current_block() && bit_isfalse(sys.suspend,SUSPEND_MOTION_CANCEL)) {, g: G0 X+ T: V3 ~+ i
            sys.state = STATE_CYCLE;
! h# V" h" q5 V, S) ]            st_prep_buffer(); // Initialize step segment buffer before beginning cycle.初始化步開始循環之前4 H. i" Y- d3 h; ^, E5 S% `
            st_wake_up();/ i$ Y3 `) \: a% L0 i$ r: z% [
          } else { // Otherwise, do nothing. Set and resume IDLE state.否則,什么也不做,設置和復位空閑模式
" B& F" y% J: ~* l# V; q5 z+ s            sys.state = STATE_IDLE;1 @8 Z. n: Z. l5 a
          }5 r& I& n0 l( J- O  P0 I( o
          sys.suspend = SUSPEND_DISABLE; // Break suspend state.
9 [6 ]3 ?5 i* M* x        }
1 m7 K2 u0 ^0 j: i      }   
# ^8 i+ Z: b) r. H      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_START);        8 p% m2 q" C' L
    }
9 F- w2 ^) v" f( _9 P& z: p4 S9 H5 k. L
_______________________________________________________________________________________________________/ P% J' k' ~+ ~- x
    // Reinitializes the cycle plan and stepper system after a feed hold for a resume. Called by 6 t3 i# w4 }; R" G, ]  Z& q4 W
    // realtime command execution in the main program, ensuring that the planner re-plans safely.
( U, b6 k9 ^9 O    // NOTE: Bresenham algorithm variables are still maintained through both the planner and stepper; O# ^6 {& v  |2 Y
    // cycle reinitializations. The stepper path should continue exactly as if nothing has happened.   
" N; J) d8 Z2 l' N! Y& x1 _    // NOTE: EXEC_CYCLE_STOP is set by the stepper subsystem when a cycle or feed hold completes., m4 Y8 b% v3 Y; ~  v

- B: d2 C" C6 F9 Z        //重新啟動后循環計劃和步進系統的進給保持簡歷。通過實時命令執行主程序,確保安全計劃重新計劃。8 M) y. X+ t% i( `
        //注意:畫線算法變量仍保持通過規劃師和步進
/ G. Y8 ^5 s8 p) B9 e, @        //循環僅。步進路徑應該繼續,好像什么都沒發生一樣。        6 T& v" z$ w, w& b& d$ j9 p- m( }
        //注意:EXEC_CYCLE_STOP由步進子系統周期或進給保持時完成。. V, D: m4 Q  A2 Y7 i
4 P, D) A% R1 w. J/ G' c% N
    if (rt_exec & EXEC_CYCLE_STOP) {                         //如果是循環停止狀態進入
. n! L, I% }8 m" O& z      if (sys.state & (STATE_HOLD | STATE_SAFETY_DOOR)) {  [9 }% q) S5 e( ?
        // Hold complete. Set to indicate ready to resume.  Remain in HOLD or DOOR states until user
( G$ l1 O# s9 @% o! L& k        // has issued a resume command or reset.- ]4 k  `5 ~5 F9 [4 d4 R) h" \

" n0 G5 Q% [! `; {7 p# a                //保存完整。設置為指示準備簡歷。繼續持有或門狀態,直到用戶+ U0 i1 J0 ^9 S' {3 H! w
                //已發布了一份簡歷命令或重置。- }$ }$ i# R2 A' o- p) f9 x1 c
               
+ k6 ?0 [# Q! S' ]4 z5 _4 V        if (sys.suspend & SUSPEND_ENERGIZE) { // De-energize system if safety door has been opened. 如果安全的門已被打開。斷開系統
4 Q7 p0 }+ Z" P8 }          spindle_stop();
! [5 F, u" V! P; S          coolant_stop();( R8 f1 c6 {* v: J
          // TODO: Install parking motion here. 安裝停車動作。
7 ~. ?5 D1 Q% y# i3 D        }
0 R4 x! P8 L+ R, z        bit_true(sys.suspend,SUSPEND_ENABLE_READY);$ G/ T6 z  q# D( ?( W" s
      } else { // Motion is complete. Includes CYCLE, HOMING, and MOTION_CANCEL states. 電機完成,循環,回原點,,MOTION_CANCEL
& m/ _( y+ @$ ?$ `7 D        sys.suspend = SUSPEND_DISABLE;
% v+ \* B9 W. I" F' b        sys.state = STATE_IDLE;( u0 V4 L$ @3 s% \4 h
      }
- N) O4 A6 u! J4 j* v+ G# [      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_STOP);9 h+ F; F, ^6 K, U6 H
    }+ h: X+ {$ R- u. i4 ]
      L( p5 O, W+ ]* z  t# e
  }5 x5 D9 G8 x- \8 c; `9 s
___________________________________________________________________________________________________) U: @/ L0 d" o6 _* A
6 H  p' `/ M& O. n9 h
  // Overrides flag byte (sys.override) and execution should be installed here, since they 0 O# G0 q9 D0 _) R0 V; z5 M* r
  // are realtime and require a direct and controlled interface to the main stepper program.- U! p3 Q. f# f5 b: r4 V' X1 t) j
9 a2 {5 j8 w$ w
  //重寫標志字節(sys.override)和執行應該安裝在這里,因為他們, M1 i( h9 x8 T- u# Q6 h# d6 A4 w: k
  //實時和需要直接和控制接口的主要步進程序。
6 `) Q* L7 M* w3 [& Z- V/ }- G% c* \5 T8 _6 L& O8 D

: X! O! z; o5 r* x  // Reload step segment buffer 重新加載步段緩沖
6 g& M/ M" {4 g6 R. p% Y  if (sys.state & (STATE_CYCLE | STATE_HOLD | STATE_MOTION_CANCEL | STATE_SAFETY_DOOR | STATE_HOMING)) { st_prep_buffer(); }
1 r9 [6 t# Z! X/ f+ t( p% t2 X' w2 |7 {3 E# c. c* [2 q+ l
  // If safety door was opened, actively check when safety door is closed and ready to resume.
; B" o& k2 q$ M- I+ y; o4 X0 a  // NOTE: This unlocks the SAFETY_DOOR state to a HOLD state, such that CYCLE_START can activate a resume.        2 m* F5 G; L. F& L

, H( r7 }. Y- T//如果安全的門被打開,積極檢查當安全門關閉,準備簡歷。9 g# i7 z8 X5 G/ y# r' W# Y! q& H( @
  //注意:這解鎖SAFETY_DOOR狀態保持狀態,這樣CYCLE_START可以激活一個簡歷。; r4 L  X+ t! d! I/ L: m

. N. R5 ^7 t. s  if (sys.state == STATE_SAFETY_DOOR) {                 //安全門狀態進入! \) j# r4 Y5 F& y9 v6 K
    if (bit_istrue(sys.suspend,SUSPEND_ENABLE_READY)) {
' ~2 v# f; z- ~0 [! J      if (!(system_check_safety_door_ajar())) {; E  l$ O. ]4 [4 r# P
        sys.state = STATE_HOLD; // Update to HOLD state to indicate door is closed and ready to resume. 更新保存狀態指示門關閉,準備簡歷。! }) |/ u" x) ~5 p- E
      }: V' p) ~0 q: J
    }  h4 C- M3 Z3 f3 ~( Z; h0 A
  }
" F! F1 H' B* c' i# H% F
& r: @- j3 X5 x  } while(sys.suspend); // Check for system suspend state before exiting.
9 v8 V. a! h1 j: j  
  z; G0 @9 o- Z}  
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-20 04:03 , Processed in 0.220057 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.5 Licensed

© 2001-2025 Discuz! Team.

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