机械社区

 找回密码
 注册会员

QQ登录

只需一步,快速开始

搜索
查看: 17104|回复: 15

单片机MCP制作数控雕刻机3D打印机

[复制链接]
发表于 2016-8-20 23:56:23 | 显示全部楼层 |阅读模式
本帖最后由 1五湖四海1 于 2016-8-21 00:09 编辑
0 W' Z& z  a1 I- K& y6 k( j  H9 v: \3 `% ]) q9 Y( f1 D' ]
    以前制作过CNC雕刻机,是用MACH3作为上位机控制,硬件是采用PC接并口输出脉冲和方向使能信号经过隔离驱动步进电机驱动器,步进电机驱动是采用TB6560芯片控制。最后就接到步进电机。机械是用铝合金制作,主要部件有三个1605的滚珠丝杠,多个运动滑块等制作。用这台DIY CNC雕刻机可以雕刻木头塑料等东西。当时没有一直玩下去,现在发现网上有用单片机制作的雕刻机挺精巧的现在分享给大家。, R0 Y9 M4 m7 g/ W: v8 ]4 L" x$ h
   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个运动来规划运行速度,以实现平稳的加速和无冲击的转弯。很棒吧!开始玩起。- }9 |& X/ q8 A! R* c
    还没有雕刻机的机械部分可以用废旧光驱制作个微型雕刻机运动平台。雕刻机最重要的是主控程序这次用 Arduino/AVR328单片机,价格在15元左右,主控程序是上面提到的目前很火的开源
的GRBL,还有一种基于STM32平台的开源主控程序Dlion也不错可以替代grbl。如果从性能比较这两个方案,显然是stm32平台运行速度更快毕竟他是32单片机呀!
8 d5 l- t. C3 ]- J5 q, s5 X, A# l; z$ \4 A& p, m/ n/ f

( T% D0 O; k: i& }! ^! U    下面介绍小这个些主控程序主要干的事,通过串口PC和主控板通讯,PC命令给控制板,控制板接收命令做不同的响应,PC可以发G代码给主控板,接收完成后可以自动开始雕刻任务。
5 e( h8 z, n! e! A# u3 ]1 E          在介绍下G代码因为G代码是雕刻机的核心部分
5 P; I- N+ l, m6 b8 ?; m% m9 W, sG代码是数控程序中的指令。一般都称为G指令。0 U) W. R. P/ g% ^3 @
G00------快速定位" ?8 M& F( h8 R: X& F$ b: m1 H
G01------直线插补% h) r! G/ I& I( N4 ?1 x6 v
G02------顺时针方向圆弧插补  c: t" o7 I7 B
G03------逆时针方向圆弧插补9 a7 y6 j! Z% b7 O' P
G04------定时暂停
8 _1 V  Y& q1 c) fG05------通过中间点圆弧插补
' z6 H0 {9 ?, SG06------抛物线插补3 r! C) i+ N+ M- n
G07------Z 样条曲线插补
7 l& w3 g/ I9 t6 a0 u8 _7 m/ M) O& \G08------进给加速
' V8 b. \  s% S" p. m" `' xG09------进给减速" K. P) Y7 h+ G
G10------数据设置
4 |6 t' f0 U' {$ i* H6 i/ s0 gG16------极坐标编程
$ M) d4 `4 `6 P+ q4 B" FG17------加工XY平面! N: _9 I- k/ Y8 d" H+ g
G18------加工XZ平面* K) R) l' ]# B: ?
G19------加工YZ平面
/ V; [; X! I: j* d1 q
核心就是解析G代码,完成步进电机驱动,和控制主轴开启关闭,还有插补算法,直线插补,圆弧插补,还有一些步进电机的加减速算法。; j1 O; @% e0 |; [+ e! n- C8 B
下面对grbl主结构做介绍+ x/ \3 w( q; I% ^
main()主函数首先执行下面初始化函数
: P  u* I* b& o- d8 ]: h        serial_init();                           // 设置串口波特率和中断. s6 I' t. v) e" y4 a2 \! l
        settings_init();                         // 从ROM加载grbl设置
! T6 z) L" Y4 W$ H4 }. Z$ M  _        stepper_init();                          // 配置步进方向和中断定时器8 w* O" Z0 L4 N9 Y1 s9 e
        system_init();                           // 配置引脚分配别针和pin-change中断
: d: [" N* b' j9 A6 w        memset(&sys, 0, sizeof(system_t));          // 清除所有系统变量+ ^" v( @1 e+ T/ t+ j) _
        sys.abort = true;                           // 中止标识位置位+ P/ m5 n: S+ _0 A* H: M: O6 |
        sei();                                         // 使能中断
8 t, W5 L* A' F# o  #ifdef HOMING_INIT_LOCK                        // 宏运算(settings.flags & (1 << 4)) != 0结果flags等于执行sys.state = STATE_ALARM
% g/ r3 v! B# _. F0 `  `" r6 C! m: D" h                                                // 系统状态赋值为报警状态
, |8 Z# X4 B# |3 _8 C7 ?1 P9 ]; m            if (bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE)) { sys.state = STATE_ALARM; }( ^3 Y$ I! J: K( N  S0 M
  #endif
4 E! @9 `; M! P* V) L_____________________________________________________________________________________________________________________________________
7 F7 s! I! h0 i) f! u接下来是一些主要部分初始化+ g& F8 s# }4 P0 F
for(;;) {- O! ]( J/ A* T/ J* x0 T" G5 o0 z
        serial_reset_read_buffer();         //清除串口读缓冲区
/ N8 S* K8 A4 S7 G) f        gc_init();                         //初始化G代码功能函数4 D' K6 v- s) x1 N4 Z/ h
        spindle_init();                        //主轴初始化
0 o3 g: C1 F2 u' N. Q        coolant_init();                        //冷却液初始化
5 S+ e6 H  j3 f% m" Q        limits_init();                         //极限开关初始化
9 W' G% J* j# L, ]) _# O2 }        probe_init();                        //探测部件初始化
: [9 s' J  u: V) U/ x' [        plan_reset();                         //清除块缓冲区和规划师变量
- g2 E, M8 C- Z4 |; X        st_reset();                         //清除步进系统变量。
  [* m7 M; r; h7 B4 X/ S1 {& |
: z% z2 B! i2 |' M9 D* W: ?4 s% @: h$ @* d3 j& {
        //下面两行清除同步gcode和策划师职位当前系统位置。
7 _% C% \+ B& K( S# V, `( L6 L3 x
        plan_sync_position();
  c: {! \  Q& h  ]' e. H* M  q        gc_sync_position();
. W0 ?2 z6 i/ c% b. V
) j" b0 g  e( s9 q  k3 d+ s) }
/ k* b2 n% a0 I0 @! q1 }        //复位系统变量
0 @+ A4 q2 W  n! r3 `        sys.abort = false;                //系统中止标志
5 M! A6 R7 V. u' K* }        sys_rt_exec_state = 0;                //系统标志位变量状态管理。看到EXEC位掩码。) i# E3 m4 c. c7 r$ e- s
        sys_rt_exec_alarm = 0;                //系统标志位变量设置不同的警报。* r) D- f# R: q) N" E# n& n
        sys.suspend = false;                //系统暂停标志位变量管理,取消,和安全保护。
* O. D3 o) A, R, Z( v5 N        sys.soft_limit = false;                //限位开关限制状态机错误。(布尔)5 k; H# }/ D5 R' w) `

, x9 L( `! d2 @) Y0 r! m$ L  d" }1 ?; H$ t5 f2 C6 {; Z
        protocol_main_loop();                //主协议循环8 c0 k6 T( v2 B3 B) z
}        //
0 x: n7 q4 K* V5 D8 Z_____________________________________________________________________________________________________________________________+ L( X' i+ e  D. [" |1 N* k
进入void protocol_main_loop()函数, w" y+ @9 O$ M9 A* {0 p; t
{1 Q$ v7 E, m8 i- r: q" t
        report_init_message();                // 打印欢迎信息 % c! n, ~+ y) [- [4 ^$ ]  O8 ]2 H  {
        //重启后检验和报告报警状态如果错误重启初始化。- P+ Z! J: p' T+ K
        if (sys.state == STATE_ALARM) {- w1 d4 U  @1 n. v3 c
            report_feedback_message(MESSAGE_ALARM_LOCK); //打印信息2 E& L' e4 C6 T
          } else {' L( [9 W. f+ K( |/ p+ h) H
            // 如果没有报警说明一切正常!但还是要检查安全门. : ^! Y4 e4 _  @6 T. Q, u
            if (system_check_safety_door_ajar()) {
) L% Z; c# l* C$ P6 m                     bit_true(sys_rt_exec_state, EXEC_SAFETY_DOOR);( X9 U' Q$ ?' V4 V4 Z
                     protocol_execute_realtime(); // 进入安全模式。应该返回空闲状态。
' g& c/ w/ n; k: p3 X            }         else {' Y, v6 [9 F- p4 o2 f3 ?
              sys.state = STATE_IDLE; // .设置系统做好准备。清除所有国家国旗。& e$ `7 W# l& A* i2 ]* V
            } + @: E# C5 e4 ?/ p# |% U4 z* M" P/ }& s
            system_execute_startup(line);    //开始执行系统脚本
- l7 V5 Z' p; a" a  }
; Y$ F& ~  {5 k/ X6 o. ]  {
+ j% Z, I' I* z# q- u3 A8 ^2 l& n, ~5 M1 y) \
  // 这是主循环!在系统中止时这是出口回到主函数来重置系统。' ^* R6 G. y4 J+ e+ K/ `
  // ---------------------------------------------------------------------------------  - L2 b& f4 `- p1 d6 U
  
; k6 S% n7 U; ]3 J  Q- G        uint8_t comment = COMMENT_NONE;) }5 x/ T8 c! A
        uint8_t char_counter = 0;& i: W- j' a& C$ N
        uint8_t c;
1 S  Q$ Y9 {# L' L7 T_______________________________________________________________________________________________________________________________
5 W% w" y" s. j. n接下来进入for(;;)循环                //下面代码是G代码解析核心部分,程序中comment(注释)变量会被赋不同值,代表发符号有‘(’‘)’‘;’! G6 `7 f! V1 z  b7 ?
{  z( z9 l8 m0 ~% @' |2 X
//串行数据输入一行的的过程,作为数据。执行一个# X; N# _. x! S" U6 T- K; D7 \
//所有数据初始过滤去除空格和注释。
5 ?$ W; B" v) O% d2 n3 Y' a//注意:注释,空格和程序段删除(如果支持的话)处理技术! x2 ^$ r! X* P2 f; _! |) F
//在G代码解析器,它有助于压缩到Grbl传入的数据
; ~& M5 ]1 e$ @- M4 B! M& f; P//线缓冲区,这是有限的。刀位点标准实际上州一行不行
+ A3 `! d* y5 n/ M9 S//不能超过256个字符,Arduino Uno没有更多内存空间。4 j, ^* Y; _  p% Q+ c3 N
//有更好的处理器,它会很容易把这个初步解析的6 }8 ^- {! P+ W' W
//分离任务共享的刀位点解析器和Grbl系统命令。                                                               
0 C+ |" r( s3 p    while((c = serial_read()) != SERIAL_NO_DATA) {                             //读取串口数据,有数据执行下面代码7 d  t" S5 `9 ]! G2 m
      if ((c == '\n') || (c == '\r')) { // End of line reached                //如果数据是/r,/n代表一行结束3 P' p2 p. O) ?6 I# I( D
        line[char_counter] = 0; // Set string termination character.        //设置结束标志5 D. O; W+ x. m4 D
        protocol_execute_line(line); // Line is complete. Execute it!        //一行完成执行此函数
4 o+ i, c5 a2 j6 L2 j        comment = COMMENT_NONE;                                                //注释清零
1 O( u, k0 `# b) O3 L& j        char_counter = 0;                                                    //字符计数清零
! I$ O% R4 \# D* B4 U. U  v  7 v) L  a( m; N1 `* w4 C: F
        else {
# m2 R- D9 Z% }& v        if (comment != COMMENT_NONE) {
' v9 ^- Z" W, T4 ^2 H                                                     //扔掉所有注释字符, T' ], Q, g: b8 A( ]2 r1 Q: v8 X
          if (c == ')') {
& f, H3 {  C* p  r9 v2 p7 F0 f            //最后注释。重新开始。但是如果有分号类型的注释。4 o/ I% _1 i' T; n. F+ z( `
            if (comment == COMMENT_TYPE_PARENTHESES) { comment = COMMENT_NONE; }
% ?5 I5 G! j  ^+ [- a, ?( m- w! l          }
  A8 ~" Y7 d& Y2 j; k      } else {% {' d( q) c2 I" p
          if (c <= ' ') { $ K5 n; B  @: O. _; {
            //扔掉whitepace和控制字符
# ?9 b  x1 u! F1 u9 c          } else if (c == '/') { 3 e, M" h) N" |6 f
            //块删除不支持将忽略字符。$ E9 X8 q3 e7 m+ p
            //注意:如果支持,只需要检查系统是否启用了块删除。
+ `$ p, K8 S; \4 Q. j0 v! j          } else if (c == '(') {
( V/ b. V2 z% `4 Y: Z4 R: I            // Enable comments flag and ignore all characters until ')' or EOL.
# a. b0 p' S: W8 ]- d            // NOTE: This doesn't follow the NIST definition exactly, but is good enough for now.2 k& }" o3 ]2 S! h& S
            // In the future, we could simply remove the items within the comments, but retain the. ~- K( ?& I9 R
            // comment control characters, so that the g-code parser can error-check it.; L4 u1 [& D) Z" ~! W: h6 V' h1 w
            comment = COMMENT_TYPE_PARENTHESES;
. _% ]# @: R1 |: A1 |) S          } else if (c == ';') {
! N$ {2 |* }$ P) T- b            //注意:','注释EOL LinuxCNC定义。没有国家标准。0 h/ d9 x# E8 ?& e- g( D
            comment = COMMENT_TYPE_SEMICOLON;* ^) ]! _8 @- {' g; I- U7 O

3 W1 ^& x) d+ r( e6 B+ Q/ [, g0 P  j- k$ x6 ]9 T
_____________________________________________________________________________________________________________________________________
' o) }9 h- b/ H. i/ @          } else if (char_counter >= (LINE_BUFFER_SIZE-1)) {                        //串口接收数据大于80字符时5 z9 c( J% [% `9 J$ S. e
            // Detect line buffer overflow. Report error and reset line buffer.        检测缓冲区溢出。报告错误和复位线缓冲区。
; K, ?% O3 h5 H7 u( E: z            report_status_message(STATUS_OVERFLOW);                                //打印溢出信息7 m2 z# O2 G: |! o
            comment = COMMENT_NONE;* J( G+ R! j" k- ~1 [
            char_counter = 0;! C" u1 a! q( [; z3 _
          } else if (c >= 'a' && c <= 'z') { // Upcase lowercase                        //小写改大写5 h- |. [2 V+ u4 \4 [1 @5 k
            line[char_counter++] = c-'a'+'A';
8 T* y/ D+ x0 p) V! T* N8 F! P/ l          } else {+ k7 J: V; p4 [8 B9 U6 b5 g5 E
            line[char_counter++] = c;' F/ z' h  X/ U# I0 l$ V
          }7 @0 d) E' |: i- H- H: E
        }
4 B2 y. [( a: k) X6 M$ U/ W# x, y) a      }
1 X4 i, S7 V- Z% y4 d    }
3 W5 D/ m8 O; g9 j* i____________________________________________________________________________________________________________________________________' d7 f: R. r( _
        //如果没有其他字符在串行处理读取缓冲区和执行,这表明以完成,自动启动,如果启用,任何队列动作。: H( v( P- f/ ]# |
        protocol_auto_cycle_start();                //自动开始协议循环
! V/ }& C# j$ x8 W- P, |: Y        8 i6 |& `, Z) Y  L" t' I$ m5 |
            protocol_execute_realtime();                  //运行实时命令。8 P4 {- H& u- p" ?+ n0 \/ e3 {3 G; |
            if (sys.abort) { return; }                 //中止标识置位程序循环重置系统。            
+ Q: m  j% }( r  v1 A# r# o  }
: H* D! K4 ^! }/ W# m! L2 H* G" f  return;                         //一般程序不会执行到这里
1 u3 J* r, I* n7 q$ r' N}  O, ?, l; W' D* O7 D
____________________________________________________________________________________________________________________________________
+ u" z6 J6 [% ^. Z& E) [6 j, K正常情况下,读取完G代码程序会进入protocol_auto_cycle_start();//自动开始协议循环 函数下面介绍此函数2 v3 d5 Y+ q5 r2 h/ @2 r2 s6 G: r' O3 [
// Auto-cycle start has two purposes: 1. Resumes a plan_synchronize() call from a function that9 Z  h5 n' Q- W# ~+ e$ m2 u
// requires the planner buffer to empty (spindle enable, dwell, etc.) 2. As a user setting that
$ M/ v) g6 r( x8 K% w) u// automatically begins the cycle when a user enters a valid motion command manually. This is " Z: {9 k( m6 w
// intended as a beginners feature to help new users to understand g-code. It can be disabled
9 B1 y# \0 f7 D// as a beginner tool, but (1.) still operates. If disabled, the operation of cycle start is
% e% ?; d" _6 r( N* u3 N( i// manually issuing a cycle start command whenever the user is ready and there is a valid motion
) K8 I7 g) t9 {( n6 C/ M( H+ T' i// command in the planner queue.9 o- s/ [% x' J. g
// NOTE: This function is called from the main loop, buffer sync, and mc_line() only and executes
) A# L5 J5 d, J; R8 }1 o6 F// when one of these conditions exist respectively: There are no more blocks sent (i.e. streaming
  A9 A. U$ U% A5 A. d( A// is finished, single commands), a command that needs to wait for the motions in the buffer to 3 M0 R* E* @- K5 X+ {& R
// execute calls a buffer sync, or the planner buffer is full and ready to go.
4 ?5 D: ~; u$ `$ c5 k3 p- b1 I" X0 F//自动开始有两个目的:1。回复一个plan_synchronize()调用的函数
- E  p. T& n( J5 W; ?//需要规划师缓冲区空(主轴启用、住等)2。作为一个用户设置1 G7 ?8 e4 |0 M
//自动循环开始当一个用户输入一个有效的运动命令手动。这是
, E8 s* J/ G  h0 W//作为一个初学者的特性来帮助新用户了解刀位点。它可以被禁用
, I7 k. i5 x6 b6 f//作为一个初学者工具,但(1)仍然运作。如果禁用,运行周期开始) |' |9 m3 T# b
//手动发出一个周期开始命令每当用户准备好,有一个有效的运动
$ \# o% a) B7 G  ?//命令的规划师队列。
5 @$ Z2 ]5 J$ e. n1 v( r5 Q//注意:这个函数被称为从主循环缓冲区同步,mc_line只()并执行
+ S+ R# s# `: y, m! O& K+ R/ ~5 K6 s//当其中一个条件分别存在:没有更多的块(即流发送+ L1 }( P; c7 G- ]$ h
//完成后,单一的命令),一个命令,需要等待缓冲的动作% Q) X: b" J: S' }: _7 c" G
//执行调用一个缓冲区同步,或规划师缓冲区满了,准备好了。
& P) E6 \& D( G9 t9 tvoid protocol_auto_cycle_start() { bit_true_atomic(sys_rt_exec_state, EXEC_CYCLE_START); }
  V) _/ O7 K: Y( P+ b# C_______________________________________________________________________________________________% m8 l6 I; b+ ]5 ?" F3 u. }
接下来程序运行protocol_execute_realtime(); /运行实时命令。
& W; c% P: @) {6 y- D// Executes run-time commands, when required. This is called from various check points in the main
" R; I) s7 m7 E) O% d+ s5 M+ w0 P- J// program, primarily where there may be a while loop waiting for a buffer to clear space or any" S9 Y4 {7 G2 B1 F; q4 I) v
// point where the execution time from the last check point may be more than a fraction of a second.1 O' W6 s, z" k0 }5 `! d
// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code4 ~* f# z; B% `+ o# G
// parsing and planning functions. This function also serves as an interface for the interrupts to ; X' ?$ E9 O5 S; z9 P2 O1 U: |
// set the system realtime flags, where only the main program handles them, removing the need to% F" V/ m5 Q" J6 ]
// define more computationally-expensive volatile variables. This also provides a controlled way to
+ P9 t1 E9 q3 I; B3 @  c0 x5 d/ B// execute certain tasks without having two or more instances of the same task, such as the planner
: Q# f/ u) A3 B; S/ j8 ?// recalculating the buffer upon a feedhold or override.
/ N9 R4 w/ y7 Z! T# i/ g6 s// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,1 P3 z6 J- U2 }$ x5 }, e2 D2 k% u: D
// limit switches, or the main program.
! s4 l5 j4 W- o# f: Uvoid protocol_execute_realtime()
4 @; S2 E. N" g; C  ?" I' V' k uint8_t rt_exec; // Temp variable to avoid calling volatile multiple times.临时变量来避免多次调用不稳定。
& D8 y% i& ]# ^就先分享到这吧!
0 s" y* D3 K  z1 f7 z* y; h5 G8 O: B$ ?6 W9 y
  r1 p4 _; e8 {) h: P; f
$ C! q* r: F. N- @4 {0 I$ h
8 S6 k; h/ L' [: w: m# E

: d# F8 H) W& d+ N* O7 J2 O& F6 T
7 r" c) [2 B: |4 Q% G4 K
* F, Z. b# b+ ]* d2 h' R! s6 q! |. X8 ]9 Q
7 @, ]( d' Y* U- i+ x# F, Z

, d* c, j) }: L5 x4 K
' J4 u2 y, c; _: Q/ {
; A/ F4 Q% G! f: X, u( e
% e# P- J4 x0 _7 S2 I: ~1 }7 Y9 d2 c' Y% O8 N

7 D1 T( K2 ]0 w2 N: O
5 M' o; C; W) r, S8 O% G) c
5 o1 Z2 d. @- d1 }) y4 n1 B, ?* H) }( U9 p

& Q' A! ~) w0 \/ l! q# S$ f
/ y3 C9 ?* c, ?2 V$ W; _. O+ a7 f

$ g7 G- a# z# Y- L* i' K( L! v0 @, X# e! \5 p2 U9 f8 \
$ P+ h# }7 c$ {+ J8 y" [. K
补充内容 (2016-8-25 22:40):
% d2 X9 g; `* G# M3 P6 ?" `: Y配置说明
' ^7 v# f! d1 s2 V% y4 }) \, u//这个文件包含编译时配置Grbl的内部系统。在大多数情况下,
: u8 N: q! [/ c//用户不需要直接修改这些,但是他们在这里为特定的需求,即。
; n, J" z# w5 C//性能调优或适应非典型的机器。
# I, T; x- \+ U+ |! [4 V% _主要配置项:# q1 Z, A) o) N6 m% D
1.#define DEFAULTS_GENERIC        //在重置eepm时使用。在defaults.h改变想要的名字3 ^- {; T! K7 F- V
2.#define BAUD_RATE 115200        //配置串口波特率1152004 p' o9 r- f% o
3.#define CPU_MAP_ATMEGA328P         // Arduino Uno CPU
) E! R% ~0 J& H$ d. ^9 b4.#define CMD_STATUS_REPORT '?'        //定义实时命令特殊字符4 O, p! ?" g/ \6 J( E6 z) C4 n% h
5.#define HOMING_INIT_LOCK         //回原点保护锁
+ E1 K2 |4 T/ D, N$ R6.#define HOMING_CYCLE_0 (1<<Z_AXIS)              // 第一步Z清除工作区。
1 D/ v6 w$ {* {! b, q  #define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // 然后X,Y在同一时间。2 W" p& ~$ w6 u6 i! b& {
7.#define N_HOMING_LOCATE_CYCLE 1 //回原点循环次数6 b% ?8 k, t9 n! |% z
8.#define HOMING_FORCE_SET_ORIGIN //取消这定义迫使Grbl总是在这时候位置设置机器原点尽管开关方向。
/ g/ d/ ?, T& b$ \9.#define N_STARTUP_LINE 2 //块Grbl启动时执行的数量。
3 ?3 [) \. b1 J9 [( ^# Z0 f0 W, u  A10.#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 协调或位置价值英寸9 N4 w6 ~8 o9 ^& p: V) `
   #define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 协调在毫米或位置价值3 y# U- c/ h$ F2 M1 b9 c: C
   #define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分钟的速度值# i% N1 d6 ~$ l" l" U! d
   #define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分钟: n/ P7 y8 W- @" H
   #define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 对浮点小数设置值1 e+ ?; l$ B& g
11.#define LIMITS_TWO_SWITCHES_ON_AXES //如果你的机器有两个极限开关连接在平行于一个轴,您需要启用这个特性
% W& f+ y  P8 P& m4 q7 }/ g12.#define USE_LINE_NUMBERS         //允许GRBL跟踪和报告gcode行号+ M7 l) h' z" D% B' Y9 b
13.#define REPORT_REALTIME_RATE //允许GRBL报告实时进给速率
- w" u% I' _6 |14.#define MESSAGE_PROBE_COORDINATES  //坐标通过Grbl $ #的打印参数?
( d$ W4 m& B' K: r. i15.#define SAFETY_DOOR_SPINDLE_DELAY 4000 //安全门主轴延时3 L9 r- d2 {. P# n" e/ H
16.#define SAFETY_DOOR_COOLANT_DELAY 1000 //安全门冷却液延时
; @1 t# w* i. ]: M6 \* T/ N, o8 [17.#define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS) //启用CoreXY运动学。
2 o! }. w9 x; }# E2 O) G: [18.#define COREXY // Default disabled. Uncomment to enable.改变X和Y轴的运动原理) H: m# F5 F6 Y: P. k: l/ N& ~
19.#define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.反转针销逻辑的控制命令% ~) {, ?# |9 b+ \
20.#define INVERT_SPINDLE_ENABLE_PIN // 反转主轴使销从low-disabled
: c  R' a9 R6 X$ j$ V& `7 B21.#define REPORT_CONTROL_PIN_STATE //启用控制销状态反馈状态报告。
7 s: }. L1 a- E4 T- p6 X# Y22.#define FORCE_INITIALIZATION_ALARM //启用和用户安装限位开关,Grbl将启动报警状态指示) F% K7 j! `( J; S- z% Q0 C: \
23.#define REPORT_GUI_MODE // gui允许最小的报告反馈模式# u; X7 B2 j6 L! }
24.#define ACCELERATION_TICKS_PER_SECOND 100 //加速度的时间分辨率管理子系统。
- `, S+ h, Y, V/ {25.#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING //自适应多轴步平滑(积累)是一种先进的功能 % E) \6 A7 M$ x5 y6 b6 b, E1 E" b$ W
26.#define MAX_STEP_RATE_HZ 30000 //设置最大一步速率可以写成Grbl设置
1 N8 s8 l. g1 j& |27.#define DISABLE_LIMIT_PIN_PULL_UP //以下选项禁用内部上拉电阻
8 S) A9 [6 P2 P* O28.#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS //设置哪个轴长度补偿应用的工具。假设轴总是与选择轴工具面向负方向  J- l3 Y2 U" B
29.#define VARIABLE_SPINDLE //允许变量轴输出电压不同的转速值。) \# F% [1 n. B) y( l: |5 |" |
30.#define SPINDLE_MAX_RPM 1000.0  // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.
( |5 b1 Z7 @. A  F$ r& B   #define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.! q3 j- O% w! L
31.#define MINIMUM_SPINDLE_PWM 5 //使用的变量轴输出。这迫使PWM输出最小占空比时启用。
6 N( D8 d0 [. w) E' f) E32.#define USE_SPINDLE_DIR_AS_ENABLE_PIN //主轴方向使能M4被删除' o3 N- `& K3 o5 i
33.#define REPORT_ECHO_LINE_RECEIVED //应该对所有正常线路送到Grbl7 |) Z+ r# W, ~* c6 B
34.#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min) //最小规划师结速度。设置默认最小连接速度规划计划/ ]5 `5 |2 P& `, l; f  r! l  Q
35.#define MINIMUM_FEED_RATE 1.0 // (mm/min)//设置计划将允许的最小进给速率
; z/ i/ l" g5 u6 F1 o, ~36.#define N_ARC_CORRECTION 12 //弧生成迭代次数之前小角度近似精确的弧线轨迹& V: {& @  [# `, q. [! m! R; C
37.#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)//定义值设置机器ε截止来确定电弧是一个原点了?0 g/ Q! J+ C2 a3 z
38.#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds) //延时增加表现在住。默认值设置为50毫秒
9 k, @$ a0 G* B$ v9 _( `39.#define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.
+ u2 H& x6 C2 f  _4 b9 d40.#define BLOCK_BUFFER_SIZE 18  //线性运动规划师缓冲区的数量在任何给出时间计划
) ~4 [0 b+ f7 n3 n41.#define SEGMENT_BUFFER_SIZE 6 //控制之间的中间段缓冲大小的步骤执行算法
0 o# A, j5 ~) k, y* }/ K42.#define LINE_BUFFER_SIZE 80 //行执行串行输入流的缓冲区大小。
. _9 E3 k& u6 _7 |43.define RX_BUFFER_SIZE 128 //串行发送和接收缓冲区大小( P1 w8 G9 W! e
44.#define TX_BUFFER_SIZE 64
3 \* x; b- d/ Z5 l2 r) ]7 `. a45.#define ENABLE_XONXOFF        ////切换为串行通信发送流软件流控制。5 H7 q9 d( p, q! Z
46.#define ENABLE_SOFTWARE_DEBOUNCE //一个简单的软件消除抖动特性硬限位开关。# S6 M5 I* p, p# V$ _- A3 s* V
47.#define HARD_LIMIT_FORCE_STATE_CHECK        //Grbl检查硬限位开关的状态
( [& v! W2 ]" F- b% h1 o2 i1 q48.// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:编译时错误检查的定义值:0 Y+ M7 i4 {0 {0 S) r
7 d3 m8 \: C% [% Q+ e6 `
___________________________________________________________________________________________________: B0 e" C$ F* f" M1 o1 n! O
/*/ U( ?8 w6 p) t7 `
  config.h - compile time configuration! f2 y/ P9 N6 Q
  Part of Grbl6 G8 i$ I7 `1 a
8 w6 f, K8 c3 G0 c6 b
  Copyright (c) 2012-2015 Sungeun K. Jeon) R; W/ e2 r2 [4 E5 ?7 C
  Copyright (c) 2009-2011 Simen Svale Skogsrud3 q+ n+ K, s" P$ o
4 N1 s$ i9 e3 c
  Grbl is free software: you can redistribute it and/or modify
! }$ ]% R3 x5 s4 Q5 E  it under the terms of the GNU General Public License as published by
( b1 q4 @( @) z9 g# _- M- N# I% b  the Free Software Foundation, either version 3 of the License, or
0 ~1 e4 g" J- [1 }) z) `, ]- r  (at your option) any later version.4 G" a0 @: T4 Y3 ~% g: v3 A5 `8 \' a
) s5 A; g) u  M; @6 @
  Grbl is distributed in the hope that it will be useful,
5 `% f, \; }8 A: g/ ~  but WITHOUT ANY WARRANTY; without even the implied warranty of
' n. h  C& S3 f+ n, i  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the& D6 u% J" m: E; u
  GNU General Public License for more details.
1 ^" n, W8 i8 d) H+ x7 ?2 I2 k8 Q4 b% O8 j' Y
  You should have received a copy of the GNU General Public License
5 d$ N: u& {- @- u  along with Grbl.  If not, see <http://www.gnu.org/licenses/>.$ J6 F. M0 u( j( C7 G0 C
config.h  -编译时配置,Grbl的一部分# G5 e! ]& o8 C% I( j: ^' Y& w% P

9 j4 R# O7 X% }& x版权(c)2012 - 2015 Sungeun K. Jeon
2 o  N. O3 L5 F版权(c)2009 - 2011 Simen Svale Skogsrud- N# h" l6 i! T( I
+ a& J+ ~! s+ J; B* P
Grbl是免费软件:可以重新分配和/或修改$ H' I! _1 a  i1 V- @7 b4 Z0 H
GNU通用公共许可证的条款下发布的自由软件基金会,版本3的许可,或(任您选)其后的版本。' l/ n- O( [! S0 k

5 S& A: F  `- }9 MGrbl分布,希望这将是有用的,但是没有任何保证;没有即使的默示保证适销性或健身为特定目的。看到3 w: `; c- h" h& b( ~
GNU通用公共许可证的更多细节。
& _) ?% {$ p/ ]1 j. x/ \
* l6 x4 p2 p; {你应该收到了GNU通用公共许可证的副本
- P; u3 g  `8 c连同Grbl。如果没有,看< http://www.gnu.org/licenses/ >。
' j  ]: G4 r( ]8 q
) @: Y# ?: |1 R& [* e9 I*/
: m. ~/ U* u6 D& _: Q  # v, E/ D6 V. M, N, M
// This file contains compile-time configurations for Grbl's internal system. For the most part,
2 I+ I* |2 R7 H/ U' H) ?// users will not need to directly modify these, but they are here for specific needs, i.e." M/ T5 {: k" D0 C1 C2 e  M
// performance tuning or adjusting to non-typical machines.
& H& C6 J7 y$ }0 l5 C% E1 S//这个文件包含编译时配置Grbl的内部系统。在大多数情况下,
- l- M0 `  Q2 v" ~) a7 K+ S//用户不需要直接修改这些,但是他们在这里为特定的需求,即。1 L) a$ `) B# [* O3 k
//性能调优或适应非典型的机器。
4 c: j" F0 F. w: a* J0 t" o/ \  H' _7 [
// IMPORTANT: Any changes here requires a full re-compiling of the source code to propagate them.
1 t3 t# G; x) a+ z$ n; x//重要:任何变化需要一个完整的基于源代码的传播。( z* p  X5 N) ~# t4 H: `9 h
8 a2 \% d- G" N$ J7 K
#ifndef config_h
4 k4 z  g4 R/ `- n/ p: ?6 Q#define config_h
* N) n& _3 h9 t; V#include "grbl.h" // For Arduino IDE compatibility.$ F9 K- F1 r5 E7 n. w' e- U6 P

7 l4 O4 f/ C0 I8 r// Default settings. Used when resetting EEPROM. Change to desired name in defaults.h
6 q  W* n, @. \& W1 X( x( M7 ]! m// 默认设置。在重置eepm时使用。在defaults.h改变想要的名字
/ c$ v* }' Z3 j$ y& v9 i
" S: P7 h8 u4 O#define DEFAULTS_GENERIC1 T6 }: |4 A4 ]/ K6 ^

1 i. v: y& Z# i4 m, s1 q' a// Serial baud rate
2 x* N$ d" A* t! Q#define BAUD_RATE 115200                //配置串口波特率1152009 H) N) X+ p* H& O

! q7 K  n- X$ I6 ~' b; i' F// Default cpu mappings. Grbl officially supports the Arduino Uno only. Other processor types
7 S2 ~4 z( }) |3 w' g// may exist from user-supplied templates or directly user-defined in cpu_map.h( a8 i7 b/ @4 h
//默认cpu映射。Grbl正式支持Arduino Uno。其他类型的处理器可能存在cpu_map.h直接从用户提供的模板或用户定义的
( Y" V& s9 |/ s; O) m6 H9 M% L" g+ |1 U! E- r  e
#define CPU_MAP_ATMEGA328P // Arduino Uno CPU
. y% }9 K  u/ g) m% A$ G  Y
$ _& b, z! n: F- G# D3 v, v) z+ j// Define realtime command special characters. These characters are 'picked-off' directly from the
) i* V$ D6 I9 m// serial read data stream and are not passed to the grbl line execution parser. Select characters
% s$ Z1 v: l# P( F// that do not and must not exist in the streamed g-code program. ASCII control characters may be
, R) ~. P+ d3 x; \// used, if they are available per user setup. Also, extended ASCII codes (>127), which are never in % a" G9 u; z/ l, e6 \
// g-code programs, maybe selected for interface programs.
! }1 m( \5 U, D# J, _9 n// NOTE: If changed, manually update help message in report.c.! i" w  E& y( Y( n8 r$ V) H! [

- c( d7 E% J5 e2 n# X% ?//定义实时命令特殊字符。这些字符是直接从“各个击破”串口读取数据流并没有传递到grbl行执行解析器。选择角色# x( z9 t+ f' i4 i
//不,不能存在于程序流刀位点。ASCII控制字符% Y7 R* E- w' B- W" W
//使用,如果他们是可用的每个用户设置。同时,扩展的ASCII码(> 127),从来没有8 A. E& Z' N& [4 \" q
//刀位点的程序,也许选择界面程序。
" g/ _* J/ \" G/ X8 Z//注意:如果改变,手动更新report.c帮助信息。8 Q. O2 \; G! j" e
7 @& f' a) w4 }0 I- M) z6 ?' _
#define CMD_STATUS_REPORT '?'
; W" Z, `4 T2 b- @6 s! F1 p3 E# ~#define CMD_FEED_HOLD '!'
1 Z$ j; [! Y* |6 u+ J" H2 X#define CMD_CYCLE_START '~'
" B) T+ t' x9 V3 S#define CMD_RESET 0x18 // ctrl-x./ o5 q% x8 t  F) w
#define CMD_SAFETY_DOOR '@', K& I( H; h, E* v1 {. i

1 |8 L( H- U/ e5 a+ v/ E& d8 L: B// If homing is enabled, homing init lock sets Grbl into an alarm state upon power up. This forces
& q; E$ Y& n1 O# s$ S% h// the user to perform the homing cycle (or override the locks) before doing anything else. This is
. u2 l4 o' T; [// mainly a safety feature to remind the user to home, since position is unknown to Grbl.
- a9 p+ V! i1 R- z# B1 [/ S( F; X3 s8 {/ L1 L: V. Z4 ~
//如果启用了回原点,导航初始化锁集Grbl进入警报状态启动。这就迫使
/ W+ F) e6 w0 n//用户执行归航周期(或覆盖锁)在做任何其他事情之前。这是
) ~  L0 F& l3 d4 ~& V8 N* G  _//主要安全功能,提醒用户家里,因为Grbl位置是未知的。% D6 ]9 t) u8 U# R4 O
8 m! L$ o/ M+ N" V; }' s. [0 q
#define HOMING_INIT_LOCK // Comment to disable+ @( e7 p) ?. a( k# g6 h

- d2 u, `% T7 d8 S# E8 T// Define the homing cycle patterns with bitmasks. The homing cycle first performs a search mode
- o, Q6 }" W9 R2 Y0 F$ Q4 d// to quickly engage the limit switches, followed by a slower locate mode, and finished by a short
0 {( P" a3 T! Q) D; l0 v% y2 v. N// pull-off motion to disengage the limit switches. The following HOMING_CYCLE_x defines are executed * f+ I2 U8 C! U4 p# g. T
// in order starting with suffix 0 and completes the homing routine for the specified-axes only. If; E6 q* H  h# {1 Y. s: S- f
// an axis is omitted from the defines, it will not home, nor will the system update its position.
8 U% s/ ]. O& D$ I* [// Meaning that this allows for users with non-standard cartesian machines, such as a lathe (x then z,% Y8 N! k, Q; @; t0 t0 @1 r+ n% M
// with no y), to configure the homing cycle behavior to their needs.
; ?. k$ o% M( B4 a: H, F// NOTE: The homing cycle is designed to allow sharing of limit pins, if the axes are not in the same1 A2 f  k: T2 x4 Z5 q
// cycle, but this requires some pin settings changes in cpu_map.h file. For example, the default homing
9 J8 \1 R0 o7 M/ t* ]// cycle can share the Z limit pin with either X or Y limit pins, since they are on different cycles.
4 k; O( ^2 @0 J# z6 l// By sharing a pin, this frees up a precious IO pin for other purposes. In theory, all axes limit pins
$ l" y  I( O/ B2 E, g// may be reduced to one pin, if all axes are homed with seperate cycles, or vice versa, all three axes
; |. ^5 w. n1 L' r0 I7 U0 ~// on separate pin, but homed in one cycle. Also, it should be noted that the function of hard limits
2 F$ a* o& [% i/ w  n4 ?// will not be affected by pin sharing.
8 [' ]4 c: X7 p: _//定义导航循环模式的位掩码。归航周期首先执行一个搜索模式. T1 G/ H( K! s; Y# j- Z
//快速进行限位开关,其次是较慢的定位模式,完成了由一个短$ r" P& G/ i7 c: B3 ?
//拖出运动脱离限位开关。以下HOMING_CYCLE_x定义执行$ [0 A' }) o* W% v+ `; V
//为了与后缀0开始并完成specified-axes只寻的例程。如果" E/ i9 K6 r( |2 X; v8 p6 x$ v
//定义省略一个轴,它会不在家,也不会系统更新它的位置。% a, L0 l! Q/ [) t/ H- A, D# Z
//意义,这允许用户与非标准笛卡尔的机器,比如车床(x,z,
, V1 p8 t: p; R' _$ `//没有y),配置导航循环行为对他们的需求。- d$ j2 t+ Q/ o7 ?! D0 v; s, A
//注意:归航周期允许共享限制针,如果轴不相同$ B5 M6 z; K$ l
//循环,但这需要一些销设置cpu_map的变化。h文件。例如,默认的导航
+ x4 Z" c) R2 L: \# e! y//循环可以分享Z限位销X或Y限制针,因为它们是在不同的周期。7 a4 D) B" K2 t8 C
//通过共享一个销,这腾出宝贵的IO销用于其他目的。从理论上讲,所有轴限制别针. H2 Z- M7 B- K& p% e
//可能会减少到一个销,如果所有轴与分离周期居住的地方,反之亦然,所有三个轴1 d3 J% u$ c4 T; b4 @) Y% X' B
//在不同销,但这时候一个周期。同时,应该注意的是,硬限制的功能* l% E# k' m) ]6 b2 w
//将不会影响销共享。7 p6 H# c! X3 s, E5 ]: Q1 i. ?2 K
//注意:默认设置为一个传统的硬件数控机器。z轴首次明确,其次是X和Y。  P/ ^4 i( A8 P: j0 W$ Y6 C
) E- R* S. a! _9 l6 `/ O/ {4 u% t
// NOTE: Defaults are set for a traditional 3-axis CNC machine. Z-axis first to clear, followed by X & Y.
! M. z8 P! ^3 j1 K3 @5 I5 H#define HOMING_CYCLE_0 (1<<Z_AXIS)                // REQUIRED: First move Z to clear workspace. 第一步Z清除工作区。! j, I$ z8 h" m
#define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // OPTIONAL: Then move X,Y at the same time.然后X,Y在同一时间。# ~& a+ s$ u7 |* J; a9 S2 X
// #define HOMING_CYCLE_2                         // OPTIONAL: Uncomment and add axes mask to enable
  B& W# D. H# a$ D9 `( [1 d% R
- ~& m; G: X- j4 K1 w// Number of homing cycles performed after when the machine initially jogs to limit switches.) W. R( |' y* s) A& \
// This help in preventing overshoot and should improve repeatability. This value should be one or
4 u) N$ w) ?$ d2 X6 k. [6 X// greater." g8 m/ [5 o; W5 D4 h
//执行回原点循环次数后,当机器最初慢跑限位开关。这个帮助防止过度,应该提高重复性。这个值应该是一个或大。
2 k+ M/ @1 N. V' v# W) Z9 w6 g2 f3 `& {1 Z" A: _/ o  J# f
#define N_HOMING_LOCATE_CYCLE 1 // Integer (1-128)
" B/ g# E+ K# A; f: J+ Q% O7 I* \
) F  N# n: c: X, r5 \  q( N8 z// After homing, Grbl will set by default the entire machine space into negative space, as is typical, u4 b+ s: ]6 f5 R+ B
// for professional CNC machines, regardless of where the limit switches are located. Uncomment this
* w. C0 k1 m# m1 |// define to force Grbl to always set the machine origin at the homed location despite switch orientation.
3 M  B( G. B8 i  L2 a6 f" n4 D2 h+ H$ \" i9 O7 s1 w: P0 E
//导航后,默认Grbl将整个机器空间留白,是典型的专业数控机器,不管限位开关所在的地方。
" z$ `5 r' [! U3 M4 Z6 v7 J//取消这定义迫使Grbl总是在这时候位置设置机器原点尽管开关方向。
; W" J  m8 @* P" l5 e/ ^$ a1 ^: A
) `: d: A; _6 x6 m5 m// #define HOMING_FORCE_SET_ORIGIN // Uncomment to enable.
4 k! ]& b+ {' a- `3 t! E6 Q
5 s" O1 b' d  J3 p$ J1 _: m( \5 x& A1 @* R! m
// Number of blocks Grbl executes upon startup. These blocks are stored in EEPROM, where the size3 z# ~! {+ x4 r
// and addresses are defined in settings.h. With the current settings, up to 2 startup blocks may& v; U2 U! a0 q. ?1 I/ o& z
// be stored and executed in order. These startup blocks would typically be used to set the g-code" u) R0 q6 V) y6 S
// parser state depending on user preferences.
' @7 x3 R, [, a' O4 S0 s" n, r) t+ T1 p  f: X9 D% M, l
//块Grbl启动时执行的数量。这些块存储在eepm,大小3 [' }# N3 d* w1 R9 q/ `
//和地址在settings.h中定义。与当前设置,可能2启动块
* X, ?3 U- W# @2 ^//存储和执行。这些启动块通常被用来设置刀位点% O6 Z' B) f+ b- z: ]' s% _' i, n1 J7 g
//解析器的状态取决于用户首选项。1 S8 r$ d& h1 I- r; H8 ^
$ B1 j5 R( c2 }) t& b4 K& I3 h* j5 P' C  c
#define N_STARTUP_LINE 2 // Integer (1-2)$ X% }2 R: ^0 y- C% T0 N

' U% Z, E/ d( I6 \/ s7 b$ O// Number of floating decimal points printed by Grbl for certain value types. These settings are   m( y' O% L9 \% q" |( o9 Q
// determined by realistic and commonly observed values in CNC machines. For example, position
: d3 ?' {( }( m0 _& D( J7 X// values cannot be less than 0.001mm or 0.0001in, because machines can not be physically more" Z/ W) d9 ?6 ~% Z( M$ A
// precise this. So, there is likely no need to change these, but you can if you need to here.
# Z7 q7 j/ r& }1 e& p// NOTE: Must be an integer value from 0 to ~4. More than 4 may exhibit round-off errors.
0 o& y0 a$ h" e% C9 E+ w5 Q
6 N$ e8 D, g3 Z. _+ S// Grbl浮动小数点的数字印刷的特定的值类型。这些设置是
# w) Z# I6 }1 {- t//一般由现实和观测值在数控机器。例如,位置. P7 d% o* s3 i% U/ N
//值不能小于0.001毫米或0.0001,因为机器不能身体更多
9 g* V. O- Z6 ^- L; f' `  I. Q7 B//精确。因此,有可能不需要改变这些,但你可以在这里如果你需要。/ c! `* k5 W( J  {  ^$ c
//注意:必须是一个整数值从0 ~ 4。超过4可能出现舍入错误。
. @3 @+ n; A, U' [6 G! ^6 e8 [$ a1 P" X+ D; O
#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 协调或位置价值英寸
* W/ s, q+ Z" A8 b  E#define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 协调在毫米或位置价值6 Q9 p5 K1 t2 ]
#define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分钟的速度值
: A6 L2 H" f, ~#define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分钟  l- g; M! V& Q2 o( M, O
#define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 对浮点小数设置值
9 [9 q+ T! O) B
2 j% A) r7 z9 x/ R  I* T// If your machine has two limits switches wired in parallel to one axis, you will need to enable) z, A2 @' s% A, C7 G" m& y
// this feature. Since the two switches are sharing a single pin, there is no way for Grbl to tell  Q5 m4 J& @, W  V5 ?3 g; K, U
// which one is enabled. This option only effects homing, where if a limit is engaged, Grbl will
- E7 ]1 y" @) N4 t3 N2 z6 N" s// alarm out and force the user to manually disengage the limit switch. Otherwise, if you have one( |0 P1 i' ?2 a/ f4 `
// limit switch for each axis, don't enable this option. By keeping it disabled, you can perform a. ]+ h0 o) Q8 Q6 P; B. |
// homing cycle while on the limit switch and not have to move the machine off of it.1 d4 e, G. B* _# t* W0 C! b
& B4 J+ z' d  K2 ~
//如果你的机器有两个极限开关连接在平行于一个轴,您需要启用
$ ^& Q& U4 H! e" U//这个特性。自从两个交换机共享一个销,没有办法Grbl告诉6 G6 N% J8 V, Y9 a1 e$ u) T* b
//启用哪一个。此选项仅影响归航,如果限制,Grbl意志
0 [% F! A, M9 o, ]" G$ v  {//报警,迫使用户手动松开限位开关。否则,如果你有一个) H/ _! w3 B# N7 K, D0 K+ B
//为每个轴限位开关,不启用该选项。通过保持禁用,您可以执行
' x* A3 R9 t$ I0 S! X//导航循环在限位开关并没有将这台机器。
6 p+ k( M. O3 a
2 U% Y. k* F( J% i+ R/ v  K// #define LIMITS_TWO_SWITCHES_ON_AXES. p' p4 x3 z9 k

) }8 J& i4 B3 E4 |// Allows GRBL to track and report gcode line numbers.  Enabling this means that the planning buffer8 C+ w7 z  I3 c
// goes from 18 or 16 to make room for the additional line number data in the plan_block_t struct
( x- {9 N! s7 Q1 K0 B/ m3 e8 u% E2 e6 Q. B
//允许GRBL跟踪和报告gcode行号。使这意味着计划缓冲从18岁或16岁,为额外的行号plan_block_t结构中的数据$ P2 |8 I3 b; n, q" N! B# y1 p
( I6 k" h7 @4 i8 w$ N$ V
// #define USE_LINE_NUMBERS // Disabled by default. Uncomment to enable.
# o" Z  V( c! `2 B2 w; r
. C/ K' {9 [3 _) q& U- H! |+ d// Allows GRBL to report the real-time feed rate.  Enabling this means that GRBL will be reporting more / A6 `" L4 d; E& j7 U
// data with each status update.
. k. b1 Y5 ]  f  I- g( T// NOTE: This is experimental and doesn't quite work 100%. Maybe fixed or refactored later.- H( k9 Y; T3 t; S( z  y
//允许GRBL报告实时进给速率。使这意味着GRBL将报告数据和状态更新。
( Q/ K8 u) N8 X  {//注意:这是实验和100%没有工作。也许以后固定或重构。5 D( ~) q( G+ x! R; F

1 ~5 i3 M3 d6 c, I/ X// #define REPORT_REALTIME_RATE // Disabled by default. Uncomment to enable., x; h1 A* k8 e6 N

( s1 G' Q. _. ^# a' I, G// Upon a successful probe cycle, this option provides immediately feedback of the probe coordinates+ w7 k3 M( r( A, k) t
// through an automatically generated message. If disabled, users can still access the last probe1 F+ e5 J( }4 f
// coordinates through Grbl '$#' print parameters.
* S9 Q% ~4 B" \$ F//在一个成功的调查周期,这个选项提供立即反馈的探测器坐标
5 P  [- Q  A) T1 p  k//通过一个自动生成的消息。如果禁用,用户仍然能够访问调查
; M! A, e) \; j" V//坐标通过Grbl $ #的打印参数。: e  O  T. E9 |5 ]- q* |+ {
" w: q$ s. w+ F6 `9 P: k9 H8 f
#define MESSAGE_PROBE_COORDINATES // Enabled by default. Comment to disable., v  D$ ?1 d- m9 a1 t2 d: Q8 Q  }

5 U, d) K9 k6 G7 D8 _; a% D// Enables a second coolant control pin via the mist coolant g-code command M7 on the Arduino Uno
; H5 l- k7 k' C: x// analog pin 5. Only use this option if you require a second coolant control pin.
& l/ b! j7 Q: v0 p: c// NOTE: The M8 flood coolant control pin on analog pin 4 will still be functional regardless.
6 M" U8 w+ X0 ]5 a2 s( q5 W6 p// #define ENABLE_M7 // Disabled by default. Uncomment to enable.5 t% [3 `1 X: {2 u- }3 P' E
0 v, v& Q4 f# N1 d& U
// This option causes the feed hold input to act as a safety door switch. A safety door, when triggered,5 F) d# r" {* b! ~3 J
// immediately forces a feed hold and then safely de-energizes the machine. Resuming is blocked until7 }( }8 J- ?& X2 [  p/ j/ N
// the safety door is re-engaged. When it is, Grbl will re-energize the machine and then resume on the
  G6 y; E* u& i" f, n// previous tool path, as if nothing happened.
, t$ P- k4 y5 S8 C2 k  M2 i1 j// #define ENABLE_SAFETY_DOOR_INPUT_PIN // Default disabled. Uncomment to enable.0 q6 J9 H( ~) D# w7 Y

& _! Q) y* [5 v& a/ x// After the safety door switch has been toggled and restored, this setting sets the power-up delay8 |7 D+ L/ [( w) V0 b8 j9 g
// between restoring the spindle and coolant and resuming the cycle.
7 A/ K- k2 w- N, k// NOTE: Delay value is defined in milliseconds from zero to 65,535. 9 q9 u( g, j$ F8 X. I2 x. v
: W! e) S2 B3 {2 C( B) g
//定义导航循环模式的位掩码。归航周期首先执行一个搜索模式
: k" \  l3 _9 ]& y* p: a$ F//快速进行限位开关,其次是较慢的定位模式,完成了由一个短0 w1 n+ c/ K# ^: T* N
//拖出运动脱离限位开关。以下HOMING_CYCLE_x定义执行
) k7 s& Z6 \# k( O$ J//为了与后缀0开始并完成specified-axes只寻的例程。如果5 p5 c7 j5 i$ z) g$ B
//定义省略一个轴,它会不在家,也不会系统更新它的位置。
5 @9 M* |8 c4 }) f//意义,这允许用户与非标准笛卡尔的机器,比如车床(x,z,
2 V+ C) j3 y6 ~: L//没有y),配置导航循环行为对他们的需求。5 [0 s* C4 S. Q
//注意:归航周期允许共享限制针,如果轴不相同
$ a9 r4 n$ l* m. B9 x//循环,但这需要一些销设置cpu_map的变化。h文件。例如,默认的导航( T4 S. s# S: p& P7 n  {
//循环可以分享Z限位销X或Y限制针,因为它们是在不同的周期。! F2 J. q7 g3 \; G
//通过共享一个销,这腾出宝贵的IO销用于其他目的。从理论上讲,所有轴限制别针  h4 E8 ]5 b+ h. Q) o% Q( t
//可能会减少到一个销,如果所有轴与分离周期居住的地方,反之亦然,所有三个轴
$ {9 I9 _1 @; ^6 \//在不同销,但这时候一个周期。同时,应该注意的是,硬限制的功能
' ?# ~6 Y" F# n+ v; `7 ?5 \//将不会影响销共享。
1 H+ p8 e& Y9 c$ x//注意:默认设置为一个传统的硬件数控机器。z轴首次明确,其次是X和Y。
# ^5 p9 y, |" O6 O$ ~) ~) K! V8 X, T' Z% n* N+ O( X2 n1 r" B4 m

& D. N/ G0 Y$ m/ X# H* v0 ?; ?' N#define SAFETY_DOOR_SPINDLE_DELAY 4000
0 C; V5 `) ~1 W5 ?#define SAFETY_DOOR_COOLANT_DELAY 10002 e8 M. v; g4 o7 z& d  V) r0 a% h
$ H, E* X; _% n) y; b& L) Z0 p) e
// Enable CoreXY kinematics. Use ONLY with CoreXY machines.
0 R1 D/ ~5 O) E* k7 m) z. s% r. }// IMPORTANT: If homing is enabled, you must reconfigure the homing cycle #defines above to 0 A( Q! r/ w$ \
//启用CoreXY运动学。只使用与CoreXY机器。  Y9 E* s. P1 l+ P) H( q( ?2 Q
//重要:如果启用了自动寻的,你必须重新配置导航循环#定义上面
# u7 U5 K/ l- w$ K2 Y# @9 ]( }' |7 Y& ]. G# Q
// #define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS)7 d5 G, C. u  ]9 N' t- m0 G6 ~

2 `1 ]6 g4 K; ]/ U# \2 K7 l0 N// NOTE: This configuration option alters the motion of the X and Y axes to principle of operation
* @, c6 ~% ]) d, b% Y2 f( h// defined at (http://corexy.com/theory.html). Motors are assumed to positioned and wired exactly as
' D* l% U0 q0 l2 [6 A// described, if not, motions may move in strange directions. Grbl assumes the CoreXY A and B motors7 l0 @5 d+ U$ P* E
// have the same steps per mm internally.
+ W, S6 q- |" [//注意:这种配置选项改变X和Y轴的运动原理,操作
5 L: v  j- L  L4 K  [# ~8 M  I//定义(http://corexy.com/theory.html)。汽车被认为定位和连接一样" A3 s0 A5 ?1 T, R7 E; @3 a
//描述,如果没有,运动可能会奇怪的方向移动。A和B Grbl假设CoreXY马达4 i6 a1 m0 G2 |( u, t
//每毫米内部有相同的步骤。8 J& j9 A- }8 D; y0 W
# ~& z8 b$ Z% w4 S2 M$ ^
// #define COREXY // Default disabled. Uncomment to enable.
4 j  \2 W$ j2 W# a4 a. p1 _/ h9 @8 y1 b6 J% I: B. }/ ~& @+ g
// Inverts pin logic of the control command pins. This essentially means when this option is enabled
" Z* Y) N* T$ M// you can use normally-closed switches, rather than the default normally-open switches.) @% D. j$ B  a! x
// NOTE: Will eventually be added to Grbl settings in v1.0.# _7 f- H/ ?* G- q$ }, }& V
//反转针销逻辑的控制命令。这实质上意味着当启用这个选项
3 c) w5 N2 d7 T1 j//可以使用闭合开关,而不是默认的常开开关。" G9 k1 V- V9 N/ ]
//注意:最终将被添加到在v1.0 Grbl设置。; c1 m7 V; B* d& T2 C! E

# y! h$ S2 C/ Y1 S* d// #define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.8 [% N/ L4 `  H. U6 R) }
; i2 p: a  }5 ?
// Inverts the spindle enable pin from low-disabled/high-enabled to low-enabled/high-disabled. Useful0 W3 H7 w) F; ~5 j
// for some pre-built electronic boards.( I1 b/ P# A7 M( A0 z
// NOTE: If VARIABLE_SPINDLE is enabled(default), this option has no effect as the PWM output and 2 H. M( p, c, o
// spindle enable are combined to one pin. If you need both this option and spindle speed PWM, 0 K5 I- V# ?9 r: J2 L# u( B
// uncomment the config option USE_SPINDLE_DIR_AS_ENABLE_PIN below.# o* K: g8 ]* v3 g+ ~% \5 F
//反转主轴使销从low-disabled / high-enabled low-enabled / high-disabled。有用的$ l# f% E0 W% K2 M* L2 R# e
//预构建的电子板。
0 u7 g# S! c$ b, ~4 y//注意:如果启用了VARIABLE_SPINDLE(默认),这个选项作为PWM输出并没有影响
  P" G0 j. Z# K- g7 v//销轴使结合。如果你需要这个选项和主轴转速PWM,/ g" c# h  W1 P: a$ P: V9 ~9 M: q
//取消注释以下配置选项USE_SPINDLE_DIR_AS_ENABLE_PIN) `0 x2 d$ t) z) C: T6 A
. {4 X8 K( l6 x4 U0 z: u) v
// #define INVERT_SPINDLE_ENABLE_PIN // Default disabled. Uncomment to enable.
4 O6 u' T9 f0 h6 s! P) z5 ^  w8 N' b8 A" c- D) l) u0 k
// Enable control pin states feedback in status reports. The data is presented as simple binary of- z4 ?. u" b  S9 U( g% H; n
// the control pin port (0 (low) or 1(high)), masked to show only the input pins. Non-control pins on the ( ]- T3 [8 c* }8 F
// port will always show a 0 value. See cpu_map.h for the pin bitmap. As with the limit pin reporting,9 U% [) e! n; m4 [, E! A
// we do not recommend keeping this option enabled. Try to only use this for setting up a new CNC.+ p( [( L% K6 D; i9 p$ `4 Q
//启用控制销状态反馈状态报告。作为简单的二进制数据
& R1 W- x* c* Y//控制针端口(0(低)或1(高)),蒙面,只显示输入插脚。非控制性针上5 V4 i& r4 \( B5 T, O2 x
//端口总是显示0值。看到cpu_map。针位图h。与限制销报告,
- e$ }; ^! D$ @* H# T. _% m/ F//我们不推荐保持启用这个选项。尽量只使用这个设置一个新的数控。
% b9 W7 w) f+ n" i& ?4 y. C0 E* S3 P& n/ e6 G. ]% T3 ^
// #define REPORT_CONTROL_PIN_STATE // Default disabled. Uncomment to enable.. }& O5 M# |6 T- I6 R1 A

8 r6 _- W  u1 X7 T// When Grbl powers-cycles or is hard reset with the Arduino reset button, Grbl boots up with no ALARM
: u" e( `" R$ Q6 ]+ ^$ r// by default. This is to make it as simple as possible for new users to start using Grbl. When homing. O; \4 j; W3 R9 ~
// is enabled and a user has installed limit switches, Grbl will boot up in an ALARM state to indicate
3 d7 C9 `/ X4 a/ ^2 L// Grbl doesn't know its position and to force the user to home before proceeding. This option forces
' l' I4 j8 o7 q7 n// Grbl to always initialize into an ALARM state regardless of homing or not. This option is more for
" m4 `( |1 s8 y0 I4 ^// OEMs and LinuxCNC users that would like this power-cycle behavior., m. p- Q2 Z; P/ ]
//当Grbl powers-cycles还是硬重置Arduino复位按钮,Grbl启动没有报警
) j5 p5 _) ^4 R/ x//默认情况下。这是为了让新用户尽可能简单使用Grbl开始。当归航
! q* U; p6 _6 [; B2 e//启用和用户安装限位开关,Grbl将启动报警状态指示
; a/ t. L' t, F, f7 r7 Q0 I// Grbl不知道它的位置,迫使用户在继续之前回家。这个选项部队
. y. v/ |; n9 ^7 ?# h// Grbl总是初始化进入警报状态不管归航。这个选项是更多8 z0 Z1 Z7 S9 ]% d$ z$ ~
//原始设备制造商和LinuxCNC用户这样的控制行为。* V) {. t2 N# O$ z

  ~' ?" n  e- {9 Y* j// #define FORCE_INITIALIZATION_ALARM // Default disabled. Uncomment to enable.- b5 ~) I! O* J/ [* b; h1 N
& N* X4 l$ [6 k: V% ?: ]5 ^/ m
// ---------------------------------------------------------------------------------------4 @+ A. B" B5 p0 O/ O" I  ^  ~  S
// ADVANCED CONFIGURATION OPTIONS://高级配置选项:6 `' P4 b0 b/ ^, T0 ^3 k# ~

1 u4 t& Q! j% D// Enables minimal reporting feedback mode for GUIs, where human-readable strings are not as important.( a5 [5 `5 q3 x! f8 p7 _5 F4 F
// This saves nearly 2KB of flash space and may allow enough space to install other/future features.
  h! S& m3 m- E5 x$ H// GUIs will need to install a look-up table for the error-codes that Grbl sends back in their place.
! f% h  @) o# J// NOTE: This feature is new and experimental. Make sure the GUI you are using supports this mode.
# Q! y0 A3 \4 W& [, s# g+ T3 h' a! i
// gui允许最小的报告反馈模式,人类可读的字符串在哪里不重要。, K  r6 {* d. \2 A2 X/ k1 H
//这个节省近2 kb的闪存空间,允许足够的空间来安装其他/未来的功能。
  W; F2 S2 t: Y, K4 V  H// gui需要安装一个查找表的错误代码Grbl发回。1 ~( I) n" v9 d9 ~2 d( c
//注意:此功能是新的和实验。确保您使用的GUI支持这种模式。" l# U" h: A# P8 q7 z& H
: q1 U3 N* J2 D
// #define REPORT_GUI_MODE // Default disabled. Uncomment to enable.
9 L  a( q% D- J1 V, n+ V; h% L! F* _9 ?9 l6 Y! S9 E
// The temporal resolution of the acceleration management subsystem. A higher number gives smoother! a4 Z' ?& U& P! l: M2 q
// acceleration, particularly noticeable on machines that run at very high feedrates, but may negatively  k% y6 A9 n8 D- z/ Q' y9 L, ?# _6 J
// impact performance. The correct value for this parameter is machine dependent, so it's advised to* W. ?. \( {' I# G5 K
// set this only as high as needed. Approximate successful values can widely range from 50 to 200 or more.
& Z6 N0 W' T: Y// NOTE: Changing this value also changes the execution time of a segment in the step segment buffer. * J) ~; I8 Y) F$ |7 u5 S# ]2 E
// When increasing this value, this stores less overall time in the segment buffer and vice versa. Make
( Q1 S7 e' _, I/ O// certain the step segment buffer is increased/decreased to account for these changes./ [3 T4 K4 A7 H( i" J" O
//加速度的时间分辨率管理子系统。更多更平稳
5 j0 T% p* |9 _6 A//加速度,特别明显的机器上,运行在非常高的进料速度,但可能负面
; k: \9 x' |* U: j/ }//影响性能。正确的值为这个参数是依赖于机器的,所以建议  I. L1 y* s& Z- i
//这只设置为高。近似成功的价值观可以广泛的范围从50到200或者更多。
: y: r  r! ]* P$ `* V//注意:改变这个值也变化的部分步骤的执行时间缓冲。3 h- ?. O6 b' R$ e: P3 @! r. k
//增加这个值时,这个商店部分缓冲区的总时间减少,反之亦然。使* K3 k/ K5 S% d5 Q$ r
//特定步骤段缓冲是考虑这些变化增加/减少。
' i8 p! l5 D) ]6 i2 z6 |7 b* r( `0 ]; {! ^) B! P% c3 j
#define ACCELERATION_TICKS_PER_SECOND 100  //加速度的时间分辨率管理子系统。更多更平稳* C. o& }: r0 ?# }3 H

$ v2 V: a' p( Q2 X) Z: U// Adaptive Multi-Axis Step Smoothing (AMASS) is an advanced feature that does what its name implies, 6 q5 \" @% v8 |
// smoothing the stepping of multi-axis motions. This feature smooths motion particularly at low step7 q% L" |+ @8 y4 k/ F. A, m
// frequencies below 10kHz, where the aliasing between axes of multi-axis motions can cause audible $ Q( q$ ^: b6 o0 l  h# Q; m, [- s: ?
// noise and shake your machine. At even lower step frequencies, AMASS adapts and provides even better) I4 d. F6 [% X, L
// step smoothing. See stepper.c for more details on the AMASS system works.
9 r/ E. z" P, L+ w0 H4 T//自适应多轴步平滑(积累)是一种先进的功能,它的名字所暗示的那样,% S) Y& z- N) ~- \. f
//平滑的多轴步进运动。这个特性平滑运动尤其是在低一步
! P5 p0 _7 ^: d1 z+ e6 Z//频率低于10 khz,轴之间的混叠的多轴运动可能导致音响3 X7 j2 [+ r5 @6 ?3 k3 H! u
//噪音和震动你的机器。在更低的频率步,积累适应并提供更好9 }4 u+ a! t' d  U
//步骤平滑。看到步进。c更多细节的积累系统的工作原理。
4 W2 v& l; w0 r& H; ]
+ F' P7 V: `0 K  W' {#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING  // Default enabled. Comment to disable.//自适应多轴步平滑
# Q9 N7 p# g! o
4 f7 l; `& W* T7 W! J/ e$ d* a" h  z4 {// Sets the maximum step rate allowed to be written as a Grbl setting. This option enables an error 8 X3 Y/ X; |4 U" I$ I, ?) }
// check in the settings module to prevent settings values that will exceed this limitation. The maximum9 v4 r+ J% \/ I5 b$ E& P& e: M
// step rate is strictly limited by the CPU speed and will change if something other than an AVR running% v& d. @$ F2 o' c; S* I# y
// at 16MHz is used.
- ^0 N! F- g2 A; b" G// NOTE: For now disabled, will enable if flash space permits.
6 b+ ~  e, Z. M4 W//设置最大一步速率可以写成Grbl设置。这个选项可以使一个错误
1 z% [! Q$ |' D1 D4 M6 k0 z//设置模块中检查,防止设置值将超过这个限制。的最大
2 a4 y) r1 P* m0 i" o+ M//步骤严格限制的CPU速度也会改变如果是其他AVR运行# p# I: c" j+ _& R0 s
//使用16兆赫。' W2 T/ E/ n9 I; L, L2 R* C, T
//注意:现在残疾,将使如果flash空间许可。
* p3 m' B+ k' A/ F+ b7 d( I  x8 ~# }+ H4 H) ^6 Y% c
// #define MAX_STEP_RATE_HZ 30000 // Hz 设置最大一步速率8 X& ~' _9 H$ e
1 i! h9 ^' r: p
// By default, Grbl sets all input pins to normal-high operation with their internal pull-up resistors
6 X% z4 b& U( g  l, P: O  s. H1 t( E// enabled. This simplifies the wiring for users by requiring only a switch connected to ground,
. W/ z; L# ]  H- z+ l- h// although its recommended that users take the extra step of wiring in low-pass filter to reduce
+ X0 K6 S0 X( e" d  X' w$ w' a1 P// electrical noise detected by the pin. If the user inverts the pin in Grbl settings, this just flips
& ~3 T( s& D+ ?- S. F( e// which high or low reading indicates an active signal. In normal operation, this means the user
- B$ a/ d2 M! \, ~, ]( Y/ z5 \// needs to connect a normal-open switch, but if inverted, this means the user should connect a # T: y% g+ R' C$ L# y; Q8 a
// normal-closed switch. , X/ p: O9 t# b  w! C1 K5 I% a  w  m: W
// The following options disable the internal pull-up resistors, sets the pins to a normal-low 6 y1 R% v; ^1 ]% p
// operation, and switches must be now connect to Vcc instead of ground. This also flips the meaning 1 j" I# a$ @! C2 j/ I9 u
// of the invert pin Grbl setting, where an inverted setting now means the user should connect a , T- B- x; o. N/ f, @
// normal-open switch and vice versa.  ~6 L  G( T# C; f( A8 i
// NOTE: All pins associated with the feature are disabled, i.e. XYZ limit pins, not individual axes.
; d  V+ R8 ?5 o) W; l! R) \// WARNING: When the pull-ups are disabled, this requires additional wiring with pull-down resistors!; ~# r/ F! y# P1 N, h
//默认情况下,Grbl所有输入引脚设置为正常高操作的内部上拉电阻. J4 n) @; Y1 `* C& r7 Y+ `
//启用。这简化了布线为用户只需要一个开关连接到地面,. N* S7 T% s( u% J; }2 w$ Q
//虽然其建议用户采取额外的步骤,在低通滤波器来减少布线
$ s* P1 p' x0 T, i8 q; N8 q# B- W//电噪音检测销。如果用户反转的销Grbl设置,这只是翻转# k/ U' e  x2 C" [5 ?, Y
//读高或低表明一个积极的信号。在正常操作中,这意味着用户
1 W0 d1 ]/ b) W7 E9 c! o/ S" z//需要连接一个常开开关,但如果倒,这意味着用户应该连接
$ W! i; K/ g& F9 S! A% I// normal-closed开关。
" g5 \0 F3 k9 h# ^/ ]' Y5 `//以下选项禁用内部上拉电阻,一般低设置别针( u) O. V/ N3 F
//操作,现在开关必须连接到Vcc代替地面。这也掀的意思
$ v1 |* J8 P8 A% \+ Z* K: m//反销Grbl设置,一个倒置的设置现在意味着用户应该连接
( D+ r: ^/ I- ^' ?( g//常开开关,反之亦然。" Z: T$ M1 U. h. R
//注意:所有针与功能被禁用,例如XYZ限制针,而不是单独的轴。
! `* E9 W0 t8 h! F" j//警告:引体向上被禁用时,这需要额外的布线与下拉电阻!
: h+ E% r4 O, T4 K, }- y* L2 u* X# T, o
% X  o- z+ O" T, d8 R9 z//#define DISABLE_LIMIT_PIN_PULL_UP //以下选项禁用内部上拉电阻/ t& S; q5 f; v. x
//#define DISABLE_PROBE_PIN_PULL_UP+ y! F. t- e: j* N; Y: I
//#define DISABLE_CONTROL_PIN_PULL_UP
" e- c9 I4 [4 L( f0 @" l5 M  X6 b; y9 I- N8 o% s4 C0 l
// Sets which axis the tool length offset is applied. Assumes the spindle is always parallel with ) x" R7 ?# e: X6 r$ `! ?1 j
// the selected axis with the tool oriented toward the negative direction. In other words, a positive
: y5 R' Q4 Z; U/ E' C$ S9 _# e! u* Q// tool length offset value is subtracted from the current location.4 u+ G/ u- w7 ?8 \
//设置哪个轴长度补偿应用的工具。假设轴总是与
' Z1 {: g1 Y- z//选择轴工具面向负方向。换句话说,一个积极的; H- p+ l7 v9 h
//工具长度偏移值减去从当前位置。$ |5 Q4 ?- \) v! [2 U: c
5 V7 `5 D. W. D  O( J3 ?
#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS // Default z-axis. Valid values are X_AXIS, Y_AXIS, or Z_AXIS.设置哪个轴长度补偿应用的工具
, r, [& E. ~) v& }+ X% d& B6 ]; b: r  ?, o* h# f% |+ ?5 o
// Enables variable spindle output voltage for different RPM values. On the Arduino Uno, the spindle# `0 I+ |( S6 g6 R4 g
// enable pin will output 5V for maximum RPM with 256 intermediate levels and 0V when disabled.- d" J5 [5 t% X2 @" C
// NOTE: IMPORTANT for Arduino Unos! When enabled, the Z-limit pin D11 and spindle enable pin D12 switch!  ~4 \+ o4 Y6 v' z
// The hardware PWM output on pin D11 is required for variable spindle output voltages.. E3 I% H- g3 j2 ^1 ~% i1 f. H5 C$ Q& |& w
//允许变量轴输出电压不同的转速值。Arduino Uno,主轴# U$ C, d% A% J2 w+ m
//启用销将输出5 v的最高转速256中级水平和0 v时禁用。$ T, D0 A, ~9 x. x/ f
//注意:重要Arduino凯泽本人!当启用时,Z-limit销这里和轴销D12开关!
* M# k, `( Q6 E! ?7 O//硬件PWM输出销这里需要变量轴输出电压。) U' }) t7 c& M1 _% p  a

, ~5 C8 K6 H0 i& S" q( b#define VARIABLE_SPINDLE // Default enabled. Comment to disable.//允许主轴输出电压不同的转速值+ c" u; C9 X: P7 s- \, ^1 A6 v2 q
6 x! m  ]+ }, m3 |; V' J: p
// Used by the variable spindle output only. These parameters set the maximum and minimum spindle speed
  T$ O* |+ c' V: |* V( N) n// "S" g-code values to correspond to the maximum and minimum pin voltages. There are 256 discrete and / y6 ]" c7 ?' ~
// equally divided voltage bins between the maximum and minimum spindle speeds. So for a 5V pin, 1000/ W5 R. q5 l8 X8 R' R
// max rpm, and 250 min rpm, the spindle output voltage would be set for the following "S" commands: 3 w5 G7 y% s/ V8 \6 H
// "S1000" @ 5V, "S250" @ 0.02V, and "S625" @ 2.5V (mid-range). The pin outputs 0V when disabled." u: ^4 a) e3 e8 i9 C
//使用的变量轴输出。这些参数设置最大和最小轴转速
- o$ X6 m$ E' i% n- ^//“S”刀位点值对应于销电压的最大值和最小值。有256个离散和
' v4 a+ p1 g1 j  ~//电压平均分配箱主轴速度的最大值和最小值之间。所以对于一个5 v销,1000
9 E$ u7 R4 n- s5 _// max rpm,250分钟rpm,主轴输出电压将为以下“S”命令:  S6 ?* q; A0 M) F) l
// @“S1000 5 v,“S250”@ 0.02 v,“S625”@ 2.5 v(中档)。销输出0 v时禁用。
/ P, f/ I; k8 s% H' k8 y9 j, K' j* S3 S3 v3 `/ [  f
#define SPINDLE_MAX_RPM 1000.0 // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.* @/ L/ T6 \' v+ n% R
#define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.2 U; l, [8 w* s+ I. f; u8 _& B! v0 B
5 x. \( }' {# x, `
// Used by variable spindle output only. This forces the PWM output to a minimum duty cycle when enabled.
& V  O/ j/ C& S5 U, g& q+ B: S// When disabled, the PWM pin will still read 0V. Most users will not need this option, but it may be
- S% j8 e0 @; V: T, C9 {, \// useful in certain scenarios. This setting does not update the minimum spindle RPM calculations. Any
' J% r2 K. H* l0 T1 {( A% r4 |& |* e9 a// spindle RPM output lower than this value will be set to this value.& ?& _6 @; f; n! U4 c
//使用的变量轴输出。这迫使PWM输出最小占空比时启用。
  h& y7 H3 a( b- t0 a9 p//当禁用,PWM销仍读0 v。大多数用户不需要这个选项,但是它可能是+ w; c+ l! E) [$ {- k3 R
//在某些情况下很有用。这个设置不会更新最小主轴转速计算。任何
; H8 F- K1 Z- F3 D- z//输出轴转速低于这个值将被设置为这个值。
' D8 J/ m" @7 y) G8 \: i: F# b7 I/ V4 w
// #define MINIMUM_SPINDLE_PWM 5 // Default disabled. Uncomment to enable. Integer (0-255)
: z. `; w; c$ K5 ~: j
) T7 p5 L& ]( p4 M6 `9 k- b2 e; ~* x// By default on a 328p(Uno), Grbl combines the variable spindle PWM and the enable into one pin to help # n' G: y8 M! E
// preserve I/O pins. For certain setups, these may need to be separate pins. This configure option uses
+ B4 O/ T, g' x+ E// the spindle direction pin(D13) as a separate spindle enable pin along with spindle speed PWM on pin D11.
6 I/ |1 w8 _) h& b+ M* h# _// NOTE: This configure option only works with VARIABLE_SPINDLE enabled and a 328p processor (Uno).
6 D7 o4 p. ^6 V, {// NOTE: With no direction pin, the spindle clockwise M4 g-code command will be removed. M3 and M5 still work.
$ i. i+ _: d3 M// NOTE: BEWARE! The Arduino bootloader toggles the D13 pin when it powers up. If you flash Grbl with
, P! w5 h; c  G+ ?# _// a programmer (you can use a spare Arduino as "Arduino as ISP". Search the web on how to wire this.),
' N9 ~* g- r, q+ l1 o// this D13 LED toggling should go away. We haven't tested this though. Please report how it goes!8 v4 d; V! h2 ^$ Z1 `" k9 W
//默认ATmega328 p(Uno),Grbl结合变量轴PWM和使到一个销的帮助5 ]4 I" {, t: q* \( b
//保存I / O管脚。对于某些设置,这些可能需要单独的别针。这个配置选项使用
$ I* o/ e/ B( k) N; m9 A//方向轴销(D13)作为一个单独的轴销上启用销以及主轴转速PWM这里。
0 ^% n& d! J3 S/ |//注意:该配置选项仅适用于VARIABLE_SPINDLE启用和328 p处理器(Uno)。& h4 w3 g9 D! Z- Y2 }8 x& I
//注意:没有方向销,主轴顺时针M4刀位点命令将被删除。M3和M5仍然工作。" `7 k& j' }7 G( t9 `
//注意:小心!Arduino引导装载程序切换D13销的权力。如果flash Grbl
7 O$ o# b4 @' f7 i) l/ Y+ b//程序员(您可以使用一个备用Arduino“Arduino ISP”。搜索网络如何线),' D9 f. h( s1 d, O9 |
//这D13导致切换应该消失。我们还没有测试这个。请报告将会怎样!: v. m3 [6 ?9 a1 a
# N8 T6 D; A9 n9 G# `1 t" v5 O# C/ U
// #define USE_SPINDLE_DIR_AS_ENABLE_PIN // Default disabled. Uncomment to enable., ~- G8 @* M& [2 P
3 s) _7 c* E4 n3 Q; Q( |* o' Z
// With this enabled, Grbl sends back an echo of the line it has received, which has been pre-parsed (spaces+ o) A2 ^" x( f0 G8 D) {3 n1 T
// removed, capitalized letters, no comments) and is to be immediately executed by Grbl. Echoes will not be ' R) F# K/ }; n; H
// sent upon a line buffer overflow, but should for all normal lines sent to Grbl. For example, if a user . q. f. e) N5 [, w' }5 Q
// sendss the line 'g1 x1.032 y2.45 (test comment)', Grbl will echo back in the form '[echo: G1X1.032Y2.45]'.) C7 }0 J5 I' X5 z0 O- {' h
// NOTE: Only use this for debugging purposes!! When echoing, this takes up valuable resources and can effect
6 y  Q$ b9 N6 i& p3 s$ `* n. F9 E// performance. If absolutely needed for normal operation, the serial write buffer should be greatly increased' G% c( l0 d7 T& j
// to help minimize transmission waiting within the serial write protocol.% G2 G9 P. s$ J; D, a3 E' x9 F

  z# M1 U2 a5 v//启用,Grbl发回的回声线已收到,已预编译(空间$ f  H# v: G' R/ q8 ]; n' ^
//移除,大写字母,没有评论),由Grbl立即执行。回声将不会
% {, S2 J" m: {: H+ H+ _9 C//发送一个线缓冲区溢位,但应该对所有正常线路送到Grbl。例如,如果一个用户
" V1 I8 G3 ]2 H8 H; }//发送线的g1 x1.032 y2.45(测试评论)形式”,Grbl将回声”(回声:G1X1.032Y2.45]”。7 u1 ?; ^6 D' _; k& [$ `
//注意:只使用这个调试! !当呼应,这占用了宝贵的资源,可以影响8 x9 u" _% x6 N) c* O4 o
//性能。如果正常运行所需的绝对,串行写入缓冲器应该大大增加: @5 s) N6 X' l. ~& w
//帮助最小化传输等系列内写协议。
# t0 ~8 J# B1 W3 A. L
  u5 M9 R/ K% r7 q8 x  [% ^// #define REPORT_ECHO_LINE_RECEIVED // Default disabled. Uncomment to enable.
/ v! Z: t" r; |2 ?9 p: V
+ O( ^# A- ^7 L; E% B// Minimum planner junction speed. Sets the default minimum junction speed the planner plans to at
* v  ^) g& v. L3 G1 n& F4 |  d// every buffer block junction, except for starting from rest and end of the buffer, which are always+ B. f" o; @( m: p9 X; J1 h
// zero. This value controls how fast the machine moves through junctions with no regard for acceleration, F' x5 C, y4 ]7 o5 h; S9 Y% Z
// limits or angle between neighboring block line move directions. This is useful for machines that can't
2 U& f# q% I4 U. x$ b// tolerate the tool dwelling for a split second, i.e. 3d printers or laser cutters. If used, this value0 ]+ R) k8 s- }) S- ]
// should not be much greater than zero or to the minimum value necessary for the machine to work.
) ^8 n( e: V$ Z( `. a- v$ x
6 Q- a1 ]8 a$ S: e//最小规划师结速度。设置默认最小连接速度规划计划4 i- K- j5 r, u5 s1 X
//每一个缓冲块接头,除了从结束休息和缓冲区,它总是2 D4 c: u3 l% W" l, f$ `, y
// 0。这个值控制机器的速度穿过路口,没有考虑加速度
- U8 i; b: @+ d& H6 b//限制或相邻块之间的角线方向移动。这是有用的机器,不能
& T5 _+ J, Y0 }# u- x//容忍工具居住某一刹那,即3 d打印机或激光切割机。如果使用这个值( w. X6 Q4 ]9 q9 l3 I: w  g$ K
//不应大于零或机器工作所需的最小值。% F/ B8 X8 d5 p
7 T; `1 q5 k% {  h& K
#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min)
4 L! ^3 b% T# A) i' d
3 \6 s1 M& M7 b* w// Sets the minimum feed rate the planner will allow. Any value below it will be set to this minimum) F$ F" _3 {* O8 c
// value. This also ensures that a planned motion always completes and accounts for any floating-point
. S7 X* m4 G. t4 L1 c// round-off errors. Although not recommended, a lower value than 1.0 mm/min will likely work in smaller
$ P, {5 H& S/ k) T// machines, perhaps to 0.1mm/min, but your success may vary based on multiple factors.
# L+ u% {4 L0 ?! F4 X//设置计划将允许的最小进给速率。任何价值低于它将被设置为最低值。这也保证了运动计划总是完成,占任何浮点
0 F- a2 f' c1 k8 j7 \4 E//舍入错误。虽然不推荐,价值低于1.0毫米/分钟可能会在较小的工作
8 [3 v6 W0 |' x5 l% q+ h2 J//机器,也许到0.1毫米/分钟,但你的成功基于多种因素可能会有所不同。
& N- [- |* X! {5 e( X& s5 A# {8 X- s  K' i' v
#define MINIMUM_FEED_RATE 1.0 // (mm/min)//设置计划将允许的最小进给速率9 [9 I8 B0 }  M% ^. ?0 n

) C9 {3 W6 H, j' j% `4 \5 I// Number of arc generation iterations by small angle approximation before exact arc trajectory
9 P3 K  x- |/ h- K# A% H( e// correction with expensive sin() and cos() calcualtions. This parameter maybe decreased if there ; `  L2 c  o, K' Y4 m
// are issues with the accuracy of the arc generations, or increased if arc execution is getting
7 D7 e4 m+ T6 K// bogged down by too many trig calculations. 9 I' O: l( M- g
//弧生成迭代次数之前小角度近似精确的弧线轨迹' \1 X% G  j6 F1 {5 M
//修正与昂贵的sin()和cos()calcualtions。如果有这个参数可能减少; W6 C& R$ |& _5 w
//与弧一代又一代的准确性问题,或如果电弧执行得到增加4 i! R2 s& j. `) b$ h* |* B6 @; n
//太多的三角计算的泥潭。% F; c  ]4 `: e* Q
3 z! Y0 v) f3 ?) y1 Q2 n& v
#define N_ARC_CORRECTION 12 // Integer (1-255)
' J" u/ V3 [& V: o3 E. a( y( l' C3 M+ d& s& J
// The arc G2/3 g-code standard is problematic by definition. Radius-based arcs have horrible numerical . W2 U6 m! F. l( t. ~/ O! z" o
// errors when arc at semi-circles(pi) or full-circles(2*pi). Offset-based arcs are much more accurate - h$ ]" ~+ [7 i! k
// but still have a problem when arcs are full-circles (2*pi). This define accounts for the floating
: [% h2 f  v4 g! L8 Y// point issues when offset-based arcs are commanded as full circles, but get interpreted as extremely
, h0 i7 W1 U, `' \  P// small arcs with around machine epsilon (1.2e-7rad) due to numerical round-off and precision issues.: l# i" j' z* |8 y  A4 }: C" E1 @. A
// This define value sets the machine epsilon cutoff to determine if the arc is a full-circle or not.
& \2 |, D. k& q5 r; U" X+ u// NOTE: Be very careful when adjusting this value. It should always be greater than 1.2e-7 but not too
  v7 O+ A. o/ Z2 N$ E// much greater than this. The default setting should capture most, if not all, full arc error situations." C: s4 U/ T6 v. i  v, p+ F3 C* O
//弧G2/3刀位点的标准定义是有问题的。Radius-based弧有可怕的数值! K7 S0 ^" \9 e5 w; y2 L" L
//错误当电弧在半圆(π)或原点(2 *π)。Offset-based弧更准确
6 x$ ^# W: D+ v( h9 U8 c//但仍有一个问题当弧原点(2 *π)。这个定义占浮动8 _3 ^6 F, J/ A% g) \' K
//当offset-based弧吩咐点问题完整的圆,但解释为极
; m; [  _6 k, f$ D//小弧机周围ε(1.2 e-7rad)由于数字舍入和精度问题。
4 K" H6 X% T3 x: t3 `9 I//定义值设置机器ε截止来确定电弧是一个原点了。; {5 W5 B6 g5 G  I6 A4 b% C
//注意:调整这个值时非常小心。它应该总是大于1.2 e -但不要太2 g0 I5 E. b3 s) z* x$ ]
//比这大得多。默认设置应该捕获大部分,如果不是全部,全部错误的情况。
( o3 L! D8 J/ x; b7 T
$ |4 m0 I! `. G% I* @& n. b#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)) r2 o! _) [. R
  s2 \& T! W* O( V: l: @1 n
// Time delay increments performed during a dwell. The default value is set at 50ms, which provides% N# P8 d3 N7 }  \+ G4 }, `0 C" k4 A9 t
// a maximum time delay of roughly 55 minutes, more than enough for most any application. Increasing
! Q9 ~1 P0 S) m* d" a% v// this delay will increase the maximum dwell time linearly, but also reduces the responsiveness of . N) m5 i4 p0 E
// run-time command executions, like status reports, since these are performed between each dwell
+ e8 u: d; g9 T; B) M// time step. Also, keep in mind that the Arduino delay timer is not very accurate for long delays./ O+ B# l8 Y4 b
//延时增加表现在住。默认值设置为50毫秒,它提供了9 L  Q$ C0 `. T4 p# @3 D
//最大延时约55分钟,足够对大多数任何应用程序。增加& Z, Z. V3 W6 x: [/ \  g: r2 W+ x
//这种延迟将增加线性最大停留时间,也减少了响应能力9 B) n& m; a( p8 [7 R
//运行命令执行状态报告一样,因为这些每个住之间执行) y$ K2 w6 m5 f- O, G+ |8 d' x
//时间步。还有,记住,Arduino延迟计时器不是很准确的长时间延误。" w5 O! M6 w' d

1 P& R7 Q' L0 |5 f8 k#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds)5 _+ l9 y4 H# r1 r5 ~

  v: i9 G% Z. I; ^9 b8 `9 N// Creates a delay between the direction pin setting and corresponding step pulse by creating
; a, {3 H* G+ Z8 S% S+ t9 K// another interrupt (Timer2 compare) to manage it. The main Grbl interrupt (Timer1 compare)
6 C* `- S" h7 ]9 ^) Q! b- }% Z" j// sets the direction pins, and does not immediately set the stepper pins, as it would in
& O! @: H3 R* `' V& g// normal operation. The Timer2 compare fires next to set the stepper pins after the step
, V( q. e: j. x  H) J; g" v// pulse delay time, and Timer2 overflow will complete the step pulse, except now delayed
3 q$ ]+ I+ J; I' P* ~$ A  I/ v3 t// by the step pulse time plus the step pulse delay. (Thanks langwadt for the idea!)
- F. [- i, V% T+ O3 G6 ]// NOTE: Uncomment to enable. The recommended delay must be > 3us, and, when added with the  h* x$ J% ]- t
// user-supplied step pulse time, the total time must not exceed 127us. Reported successful
7 N4 K0 H1 J2 z% x* l# c// values for certain setups have ranged from 5 to 20us.
, y7 O- |1 D2 B; i3 Y& I//创建一个方向销之间的延迟脉冲通过创建设置和相应的步骤
2 v1 K9 I% P" O4 B//另一个中断(Timer2比较)来管理它。主要Grbl中断(Timer1比较)
) J0 T1 ^! }4 r* f) c' N/ w//设置方向针,不立即设置步进针,因为它会在
# ?' n8 N6 ~1 u, }0 b2 A2 u% I//正常操作。Timer2比较火旁边设置步进针后一步
. b( ], E2 ?; M  J. s//脉冲延迟时间,Timer2溢出脉冲将完成的步骤,现在延迟除外% ?  T) j) _3 B2 A
//脉冲时间加上的一步一步脉冲延迟。(感谢langwadt主意!)7 S" w6 ~* D6 q/ ?# @
//注意:取消启用。必须> 3,建议延迟,当添加的
( L9 v% f$ V! K2 b' i9 \//用户提供的步骤脉冲时间,总时间不得超过127美元。成功的报道1 n" @8 O( @* D4 F# `
//值对某些设置范围从5到20。
! C1 u5 L, ?' @2 B* F# N7 I
/ R" D, }) g# W// #define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.
1 d# e1 Z4 r4 u% d$ H
. w+ Q1 o# p( w/ e7 E5 x// The number of linear motions in the planner buffer to be planned at any give time. The vast1 {* ~, G( |' w2 Y0 @* q
// majority of RAM that Grbl uses is based on this buffer size. Only increase if there is extra
9 r! j8 k( j* c( U// available RAM, like when re-compiling for a Mega or Sanguino. Or decrease if the Arduino
2 q' q* J- [  k0 u- [: e" l* z& m// begins to crash due to the lack of available RAM or if the CPU is having trouble keeping: N* B9 h/ e& {' O
// up with planning new incoming motions as they are executed. : Q' w) `! w9 `* v$ M/ R  g7 J
//线性运动规划师缓冲区的数量在任何给出时间计划。绝大/ R9 S9 u; T+ l6 @  w! n
//多数RAM Grbl使用基于这个缓冲区的大小。如果有额外的只会增加
. _" Q: d. F! Q9 Z! N//可用内存,比如当基于大型或Sanguino。如果Arduino或减少4 h7 {2 |) X) n. W/ }( h0 |
//开始崩溃由于缺乏可用的RAM或者CPU是难以保持& x0 v& V! ^0 W0 x
//与规划新传入的动作执行。
- I8 ?8 |; N# Y" o! ^8 n4 Y* K5 [+ {! L0 u5 p6 |
// #define BLOCK_BUFFER_SIZE 18  // Uncomment to override default in planner.h.$ y9 l6 Q) L9 K, g# t( J

5 E* E+ s8 I4 o9 f// Governs the size of the intermediary step segment buffer between the step execution algorithm
2 [1 `9 y! K3 M  I// and the planner blocks. Each segment is set of steps executed at a constant velocity over a( r' `+ e/ i) U9 j# E2 s8 {0 z' i0 E
// fixed time defined by ACCELERATION_TICKS_PER_SECOND. They are computed such that the planner& [% A3 l  I6 V2 Z( Z% B9 g
// block velocity profile is traced exactly. The size of this buffer governs how much step - H7 k* h  h" q& e0 v* z; o
// execution lead time there is for other Grbl processes have to compute and do their thing
9 Q0 s7 |- l% R5 m// before having to come back and refill this buffer, currently at ~50msec of step moves.
" ]4 E+ D1 D/ R7 G( k+ h% d2 Z- W//控制之间的中间段缓冲大小的步骤执行算法
% J' `- c+ y+ ]( H//和规划师块。每一部分的步骤执行在一个恒定的速度3 |. ]! U( A. t" @) A' ]& e  N
//固定的时间由ACCELERATION_TICKS_PER_SECOND定义的。他们计算的计划
+ W2 Q: p3 u% c//块速度剖面追踪到底。这个缓冲区的大小控制多少步骤" u& p( |5 t, O8 U4 r
//执行时间有其他Grbl过程需要计算和做他们的事情) W0 h/ ?) `- M
//之前必须回来重新填充这个缓冲区,目前移动~ 50毫秒的一步。( I* K/ c7 H) F$ \& F% `: S; x

  s4 x) s: R9 N! j+ Y// #define SEGMENT_BUFFER_SIZE 6 // Uncomment to override default in stepper.h.
1 Z0 x& [3 \0 b) T8 u$ e2 N
8 C7 h4 j  i- w0 a  F. L, ~* F8 D// Line buffer size from the serial input stream to be executed. Also, governs the size of
2 P, ]  p* K$ @6 m: C( `  O0 D& q// each of the startup blocks, as they are each stored as a string of this size. Make sure  x, u( G9 c% s
// to account for the available EEPROM at the defined memory address in settings.h and for) [6 s- J6 G" c  V
// the number of desired startup blocks.
8 S8 g' w' o" ~# y( Z" U& Z, }// NOTE: 80 characters is not a problem except for extreme cases, but the line buffer size
0 b9 F; a) H7 [! K  {: g6 U7 v// can be too small and g-code blocks can get truncated. Officially, the g-code standards . Z' I+ o/ ]2 ]/ x, ^
// support up to 256 characters. In future versions, this default will be increased, when
! C: l! O6 s' d$ C) Y6 `3 U// we know how much extra memory space we can re-invest into this.
: M, h! `; ^: g2 E& T: t//行执行串行输入流的缓冲区大小。同时,大小的控制
7 O% Q" T7 R: U% n1 v; E& S//每个启动模块,它们分别存储为字符串的大小。确保
4 N( d* A  K+ k/ V( S/ g8 J//占可用eepm定义内存地址的设置。h和
7 S6 b. m9 W! g# r3 F7 m& z- i/ E5 f//需要启动块的数量。$ o. u, r- z! n! c
//注意:80个字符不是一个问题,除了极端的情况下,但线缓冲区大小
. ]2 P0 v9 R: ~1 I3 `//可以太小和刀位点块可以截断。正式,刀位点标准
0 j$ k8 ~2 A: a/ L  w1 m3 L9 P//支持多达256个字符。在未来的版本中,这个违约将会增加,当
, ]. w( C# ^+ r# ]$ J//我们知道多少额外内存空间的时候我们可以再投资。6 o+ U: h( d3 T( X6 g- e7 s

0 q6 p+ H1 z2 k: P$ s8 m// #define LINE_BUFFER_SIZE 80  // Uncomment to override default in protocol.h+ U3 K* U" P1 P* e; o. ~6 y
  
' {# d! x% E! N7 k6 j// Serial send and receive buffer size. The receive buffer is often used as another streaming
( @0 k/ f, n; t; T5 [// buffer to store incoming blocks to be processed by Grbl when its ready. Most streaming
; n2 K7 K4 m- A, y+ w// interfaces will character count and track each block send to each block response. So, ! M6 k# r) a6 u- i- _' }
// increase the receive buffer if a deeper receive buffer is needed for streaming and avaiable  O, e- ]5 l2 n1 }4 D
// memory allows. The send buffer primarily handles messages in Grbl. Only increase if large
/ b& ?% B9 O1 n" y* H// messages are sent and Grbl begins to stall, waiting to send the rest of the message.$ p% V# N; K! N" z  v
// NOTE: Buffer size values must be greater than zero and less than 256.1 E7 k% i6 ^2 |2 K2 t  u) ?
// #define RX_BUFFER_SIZE 128 // Uncomment to override defaults in serial.h/ c6 p7 c6 p0 l
//串行发送和接收缓冲区大小。接收缓冲区通常用作另一个流( f9 m$ y% U) x+ V
//缓冲存储传入的块来处理Grbl当它准备好了。最流
0 x" ?( y  g" o//接口将字符计数和跟踪每一块发送给每个块的回应。所以,( ?3 `- M2 B% L! p! Y2 c* J
//增加接收缓冲区如果需要更深层次的接收缓冲区为流,、
! v, V! z: ~# k, l//内存允许。Grbl发送缓冲主要处理消息。只会增加如果大
% c) Q- G8 A6 Y  i' ], T6 O//消息发送和Grbl开始停滞,等待发送其余的消息。1 b  D4 U; p- p0 y' y) {
//注意:缓冲区大小值必须大于零,小于256。
2 ^% z) d% K9 `* E3 c// # define RX_BUFFER_SIZE 128 / /取消serial.h覆盖默认值6 v4 k: ?" ^' z+ b6 q1 U" u

% V9 O4 f  p) O) A' A! }8 Q
" S$ n* `! N" K// #define TX_BUFFER_SIZE 645 U0 i5 ^* T# h" E, A0 V
  9 }- U7 ?' V, o' @9 `! a
// Toggles XON/XOFF software flow control for serial communications. Not officially supported
, I" ]8 f' Z' j9 f, m& g7 [// due to problems involving the Atmega8U2 USB-to-serial chips on current Arduinos. The firmware
5 @1 @& w! k- w. ~7 d) [0 \9 n8 |// on these chips do not support XON/XOFF flow control characters and the intermediate buffer 3 c8 l2 ^7 u' k( Q0 q; X. `" ~+ R0 S
// in the chips cause latency and overflow problems with standard terminal programs. However, ) F8 f* R8 M& d3 D6 h
// using specifically-programmed UI's to manage this latency problem has been confirmed to work.- Z5 q  h2 E" @8 M0 f  L
// As well as, older FTDI FT232RL-based Arduinos(Duemilanove) are known to work with standard
+ E9 L2 A- L6 \. G// terminal programs since their firmware correctly manage these XON/XOFF characters. In any$ J7 O- {- P/ h
// case, please report any successes to grbl administrators!
1 G( \4 ~; v# `/ d7 @  l//切换为串行通信发送朴通/发送葡开软件流控制。不是官方支持2 ~+ z6 X) K7 }8 v
//由于问题涉及Atmega8U2 USB-to-serial当前arduino芯片。固件# |4 W( d8 A, Z" F3 c; L& e
//在这些芯片不支持发送朴通/发送葡开流控制字符和中间缓冲区" \$ b9 l9 r* s- T
//芯片导致延迟和溢出问题的标准终端程序。然而,
% k7 H/ u5 G) e: w( A//使用specifically-programmed UI的管理这个延迟问题已经确认工作。
# B$ B  I; v5 q' ^% d' g//以及老FTDI FT232RL-based arduino(Duemilanove)是已知的标准4 f2 T( q- \8 S1 |' v- {" }* U- M
//终端程序因为他们正确的固件管理这些发送朴通/发送葡开的角色。在任何
' ^9 N! D4 X  E: [, q1 h//情况,请报告任何成功grbl管理员!6 _3 @8 F8 R7 Q" `- @
) [  B9 h: P% ~, `8 a5 `* y$ i% X
// #define ENABLE_XONXOFF // Default disabled. Uncomment to enable.
/ r/ q9 K" j3 @5 D- G; r. t
  |) {" g( B% P6 R# K# y+ ~5 i& Y// A simple software debouncing feature for hard limit switches. When enabled, the interrupt % `1 k% N; [8 [- \" O
// monitoring the hard limit switch pins will enable the Arduino's watchdog timer to re-check
* z4 F- O" N. u( U" @9 E2 {// the limit pin state after a delay of about 32msec. This can help with CNC machines with 3 ~- Q; S: B) T. u3 V% v; L5 Z+ _4 C
// problematic false triggering of their hard limit switches, but it WILL NOT fix issues with
( Q9 A9 X' c) N5 j// electrical interference on the signal cables from external sources. It's recommended to first
9 t, T$ h+ O+ ]4 M/ n; c1 Y6 ~// use shielded signal cables with their shielding connected to ground (old USB/computer cables 5 _' \( _6 v9 e# x% q
// work well and are cheap to find) and wire in a low-pass circuit into each limit pin.; v2 h2 L: C# N' e
//一个简单的软件消除抖动特性硬限位开关。当启用时,中断9 `% p: h8 F8 V, u2 r4 c
//监控硬限位开关针将使Arduino的看门狗定时器重新审视) p- Y  B( F  K( C( {0 w# ]5 q. X  w
//销的极限状态后约32毫秒的延迟。这可以帮助与数控机器1 f% O( a. Y) B$ s$ v, j& k
//问题错误引发的硬限位开关,但是它不会解决问题
' A+ F- A0 o' n. \3 W6 N//电干扰信号电缆从外部来源。首先它的建议
. C# g6 i/ v( X' ~: ~//使用屏蔽信号电缆的屏蔽连接到地面(老USB /计算机电缆3 Q; J& _- c  l$ Y' P( O- m' i3 t+ x
//工作得很好,很便宜)和线低通电路到每个限位销。, f) V. \3 s5 G

. ^4 S+ g& g+ u6 R0 G// #define ENABLE_SOFTWARE_DEBOUNCE // Default disabled. Uncomment to enable.
2 [& l: Z7 {9 |4 `4 L6 q
! E) w" d! h& J+ k3 S// Force Grbl to check the state of the hard limit switches when the processor detects a pin
$ O5 W& u6 v% e' T# _) d// change inside the hard limit ISR routine. By default, Grbl will trigger the hard limits
3 E( I" w# }4 B: _// alarm upon any pin change, since bouncing switches can cause a state check like this to
+ {2 ~0 I6 j) g// misread the pin. When hard limits are triggered, they should be 100% reliable, which is the
# R+ p, Y/ m0 S: A2 U) h// reason that this option is disabled by default. Only if your system/electronics can guarantee" f6 L. P1 _8 V6 n& H5 \
// that the switches don't bounce, we recommend enabling this option. This will help prevent5 H* y! X5 S9 Z% h( Z
// triggering a hard limit when the machine disengages from the switch.
" R# p. X' h5 M0 G// NOTE: This option has no effect if SOFTWARE_DEBOUNCE is enabled.
: Z+ O2 U/ p- m' |//力Grbl检查硬限位开关的状态,当处理器检测到一个销, c' T- m$ t9 k" \! V
//改变内部硬限制ISR例行公事。默认情况下,Grbl将触发硬限制* p* C7 s. O/ m* e
//报警在任何销更改,因为跳开关可以导致这样的状态检查
, k+ B$ I) V7 J# E//误读了销。硬限制触发时,他们应该100%可靠,这是% Y) }7 |/ K, `" `4 ~1 U
//原因,这个选项默认是禁用的。只有在你的系统/电子产品可以保证
& _) g: N' v% r2 o& A0 w6 y//开关不反弹,我们建议启用这个选项。这将有助于防止6 l" B/ H9 U+ ?( r0 D
//触发机退出时硬限制开关。9 p) o* O5 L8 d. P/ o$ Z
//注意:这个选项如果启用了SOFTWARE_DEBOUNCE没有影响。
6 S" l, }' d3 L2 E) v  r& h; s+ Y! j# L: l+ _* w. A
// #define HARD_LIMIT_FORCE_STATE_CHECK // Default disabled. Uncomment to enable.; ~  x/ R1 T6 p; L& U$ w

9 I) F: r1 J0 z* z& b, ]. ?
( b7 j% ?" F8 ^// ---------------------------------------------------------------------------------------
: r# a$ Y. g) ]4 X0 _" p9 M2 N// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:编译时错误检查的定义值:
  u$ w& r5 o8 {: w# v- S, X. o! a& S- i, L, y3 [
#ifndef HOMING_CYCLE_0
! |$ ]" ]# r, }0 u0 x6 W# P  #error "Required HOMING_CYCLE_0 not defined."
% S/ w& a3 f* h: H: Y9 h( p6 P1 f7 p#endif
( O+ g2 S) `" F4 @* r" H/ W7 x2 ]
#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(VARIABLE_SPINDLE)
8 v, [$ o9 n; F: P/ ?0 I  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with VARIABLE_SPINDLE enabled"$ Y' A( k& {7 e0 f/ y, @
#endif
7 i- j, J4 c8 P3 E8 L* K: D+ w1 y( \! z1 G+ y
#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(CPU_MAP_ATMEGA328P)
) `' B6 G4 ~' ^! c  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with a 328p processor"4 k# }6 i# X; t2 C
#endif
; N9 ~( l' T  N- r5 \5 c! g% p# C+ o
// ---------------------------------------------------------------------------------------, Z- B4 ]% p1 g# r0 k7 B( t: `; |

' k3 V3 U4 G/ H2 T/ M
; j% u% [3 _0 a" Z- F- q; L- j- S#endif
: {4 H1 E+ q6 k5 R/ q0 l: o' y. C4 \* ?2 G. v& ]/ N
/ c2 N$ b: W1 e
9 x/ M$ f$ x6 V7 M" r" p/ ^, O: s

% E$ ]# x& P' g0 m( ?
$ H* _' s( d9 L; ?/ L* @1 x% g# U0 A) o2 ^: h5 i

' x) C" n; G6 [& z% P2 [9 W8 D$ f/ x) X

/ l' v  }. v! I8 N; j) b- ~8 c7 s7 |% r; Q$ b& D) y" o

1 Z0 T# b# q. y1 `+ w/ s0 j3 j. w% \+ ~& u, ~( p

  r; {. a8 ~. Z. b: m' A$ m; h0 R/ ]( k/ B% j0 o
" m! S6 _0 X. y' @8 t. r5 k5 a0 a

, `* O, h. ]) P- @3 g

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册会员

x

评分

参与人数 2威望 +201 收起 理由
mrplplplpl + 1 思想深刻,见多识广!
管理团队 + 200

查看全部评分

回复

使用道具 举报

 楼主| 发表于 2016-8-21 00:11:42 | 显示全部楼层
那些没有用的照片不知道怎么就上去了好讨厌。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2016-8-21 00:14:16 | 显示全部楼层
4 t  W3 y- e) H$ a3 b0 X' N
回复 支持 反对

使用道具 举报

发表于 2016-8-21 05:50:22 | 显示全部楼层
      楼主厉害!
回复 支持 反对

使用道具 举报

发表于 2016-8-21 08:22:05 | 显示全部楼层
谢谢楼主,先收藏一下,慢慢学习
回复 支持 反对

使用道具 举报

发表于 2016-8-23 15:11:25 | 显示全部楼层
这是什么宝贝?
回复 支持 反对

使用道具 举报

发表于 2016-8-23 15:11:47 | 显示全部楼层
换了个浏览器Chrome,试试能否发言了。
回复 支持 反对

使用道具 举报

发表于 2016-8-23 20:12:33 | 显示全部楼层
楼主厉害
回复

使用道具 举报

 楼主| 发表于 2016-8-23 23:03:17 | 显示全部楼层
补充
; Z8 s  w' r( ^' R, O* P& f程序运行protocol_execute_realtime(); /运行实时命令。" W( i9 |6 K8 S4 V- T8 \, T
// Executes run-time commands, when required. This is called from various check points in the main
" R. t* L( A$ e% p// program, primarily where there may be a while loop waiting for a buffer to clear space or any8 J8 R( k' _1 \8 P! W8 _
// point where the execution time from the last check point may be more than a fraction of a second.
# s: M: H5 D$ G6 F// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code
- y( f1 X2 g# }% c4 U// parsing and planning functions. This function also serves as an interface for the interrupts to 5 A$ @$ X: j' G" u
// set the system realtime flags, where only the main program handles them, removing the need to
- l- c, z: [0 G( z4 |9 U: E// define more computationally-expensive volatile variables. This also provides a controlled way to
! w- y- L1 h+ l. @3 u- }" j// execute certain tasks without having two or more instances of the same task, such as the planner
( M0 T' M' y  c* a4 H// recalculating the buffer upon a feedhold or override.! M( w9 |% t5 Y- z2 g
// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,
$ G/ X; ]9 W' Z// limit switches, or the main program.
" o7 ~- ~& t7 _/ z5 X0 I4 Y- y7 Y5 C( \+ C. }+ u  ?
//执行运行时间命令,在需要时。这就是所谓的从各种主程序要检查站! }& d+ ]/ ]+ Q- X" ^
//,主要是那里可能是一个while循环等待缓冲区空间或任何
) C+ L% [/ v% I3 x, z//执行时间从过去的止点可以超过几分之一秒。& @. X% X- x( S' ^) o  r
//这是一种异步执行实时命令(又名多任务)grbl的刀位点
$ C" X6 G5 S$ f( @9 Z2 B5 k( K//解析和规划功能。这个函数也可以作为一个接口,用于中断8 B$ r( F7 b8 _, l
//设置系统实时的旗帜,只有主程序处理,消除的需要0 t9 X, N  M4 ~9 d. v$ z" |
//定义更多的计算昂贵volatile变量。这也提供了一种控制方法1 ]# G5 ?  V, y
//执行某些任务不相同的两个或多个实例的任务,比如计划
2 i6 V$ g& Q) _//重新计算缓冲feedhold或覆盖。
) d9 z+ O/ F2 H# ~# l//注意:sys_rt_exec_state变量标志设置任何过程,步骤或串行中断,插脚引线,% c. p" q3 L8 X3 T9 [6 z+ h
//限位开关或主程序。! u- b7 m4 z6 V# W) o, @
void protocol_execute_realtime()
" X' J# c. L$ r% g* \{# A+ F2 B$ q! n+ a6 D8 J! n/ G9 u
        // Temp variable to avoid calling volatile multiple times.
% N) B5 I7 k. _9 N+ r* u1 f! X# d" Q        // 临时变量来避免多次调用不稳定。
: V5 ~+ R  g& ]9 O. m        uint8_t rt_exec;
7 W6 k" g0 B4 E3 I        do{* [# i7 S7 j8 s5 o  E; L- R
          if (rt_exec) {                 // 有标志位置位进入5 G6 D; m7 N" M& u" T
        2 N( b8 a6 E' m
            sys.state = STATE_ALARM; // 设置系统为报警状态3 p; k4 x1 r/ }) d7 ^/ v& a% C
      report_alarm_message(ALARM_HARD_LIMIT_ERROR);        //报告报警信息为接近极限值) ]9 |: ^& o6 T% \& c, k
    } else if (rt_exec & EXEC_ALARM_SOFT_LIMIT) {                        //报告执行软件限位报警
- m2 }5 D& r' x) V3 L+ b      report_alarm_message(ALARM_SOFT_LIMIT_ERROR);        //报告出现软件限位报警' F7 q( i8 M1 s# @+ g
    } else if (rt_exec & EXEC_ALARM_ABORT_CYCLE) {                //执行停止循环报警      
! ], Z% d/ r1 c+ }7 T  A/ I+ A: W      report_alarm_message(ALARM_ABORT_CYCLE);                //出现终止循环报警; J. ]+ v: n9 z1 _" m. ?8 i
    } else if (rt_exec & EXEC_ALARM_PROBE_FAIL) {                        //执行探查失败报警
3 v$ Z0 e7 c9 m8 g      report_alarm_message(ALARM_PROBE_FAIL);                        //出现探查失败报警
7 ~5 t3 u0 V2 R. L$ E. \2 k' p    } else if (rt_exec & EXEC_ALARM_HOMING_FAIL) {                //执行返回原点失败报警
; c% R; Z% g6 d3 t      report_alarm_message(ALARM_HOMING_FAIL);                //出现返回原点失败报警
& e  ~0 E7 @* U- o3 [2 ?    }6 U4 [! M7 I+ P* W( J
; p# ^0 e& K! S
    // Halt everything upon a critical event flag. Currently hard and soft limits flag this.
! p9 @$ l( J/ C& C1 m! z& \    // 停止一切在一个关键事件标志。目前硬和软限制标志
, Y/ F5 v3 ~0 M$ C6 E           if (rt_exec & EXEC_CRITICAL_EVENT) {                //如果系统是循环事件进入. C& g0 E- x3 n/ A. R0 K' ~
             report_feedback_message(MESSAGE_CRITICAL_EVENT);        //报告反馈信息/ l, u! o7 @5 k7 C- C, {/ m, p+ K
              bit_false_atomic(sys_rt_exec_state,EXEC_RESET);                         //清除目前的复位状态
+ Y9 p, p- t7 r1 V3 v; A0 c' u2 O1 i3 k! }& y
        bit_false_atomic(sys_rt_exec_alarm,0xFF);                                 // 清除所有报警标志) R* n* G# K# M# j+ H
        }        ' h% |6 ]( I+ y! h4 o  L6 w
( F3 h1 a4 U5 z
上面代码将rt_exec = sys_rt_exec_alarm ,如果rt_exec为真,打印不同报警信息1 D* R6 |) ^7 C: {8 v4 f$ p8 X
和限位保护信息,然后清除报警状态
2 Q) k- C9 m  X# A* A' X, K3 l: ?___________________________________________________________________________9 m* {! j6 f. ^+ ?+ o  I! l
没有报警进行执行下面代码,执行了终止命令,串口打印命令
  G9 P8 {  L, P( l         // Check amd execute realtime commands        校验和执行实时命令
. Q1 F8 Q# @6 M2 W          rt_exec = sys_rt_exec_state; // Copy volatile sys_rt_exec_state
, q% `  C3 Z( j5 g7 K2 [# l5 r7 ^
        if (rt_exec) { // 输入标志是正确的执行4 o7 ?; a' q. c7 Q9 a

/ V5 d/ o3 R+ o1 z1 |            // Execute system abort. 执行系统终止命令
2 I* C1 R0 ]- x+ s2 _3 h0 v8 [* O: i            if (rt_exec & EXEC_RESET) {$ P, Z  r0 V. f& i$ Q+ X3 }
              sys.abort = true;  // Only place this is set true.
4 D6 u9 i2 C! d, \. t              return; // Nothing else to do but exit.
* R2 ]/ u( ~# m# Q! \. T        }
. n7 h4 {; j5 u9 s5 D* w" E$ C" ]' k/ z
            // Execute and serial print status 执行和串口打印状态
! T* o( g# |  B! O            if (rt_exec & EXEC_STATUS_REPORT) {
) ~+ I. v2 ?' r# S              report_realtime_status();        //报告实时状态
2 b& s% y) U! C+ [& B% v/ X              bit_false_atomic(sys_rt_exec_state,EXEC_STATUS_REPORT);        //清除报告状态清零% D: H" Y4 U! [; ^7 p: W$ l) l5 }
            }
! \1 ]4 D  j, b! O6 a; X_____________________________________________________________________________
5 }2 X! V5 ^  p. R4 J下面代码
  O6 e2 z* d; O/ W//执行状态。- G+ g" N7 m, V( r
//注意:所涉及的数学计算持有应该足够低对大多数人来说,即使不是全部,
% J2 \$ n- b9 Q8 {//操作场景。一旦启动,系统进入暂停状态" [# ]8 h8 [. @
//主程序流程,直到重置或恢复。$ g+ r) \1 L* M. e- S4 W
待办事项:检查模式?如何处理呢?可能没有,因为它只会在空闲,然后重置Grbl。- C: J! F) a* e: v1 }4 D2 h
状态检查容许状态的方法。
2 l9 Y7 h' O1 |0 k/ E/ \  W2 U5 {! d7 `. U* R" p! q
        //如果全局各自报警标志位其中(执行取消动作) | (执行进给保持) | (执行安全门)任意一位为真进入7 B1 S! U0 C; u; Z: ?8 A
            if (rt_exec & (EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR)) {       
: x/ v- u3 v( U
" C7 i$ N  _: b+ C- ]        //如果是循环状态执行暂停状态
2 a- @$ `1 ?# w2 X        if (sys.state == STATE_CYCLE) {
8 z* U8 @3 `( f7 A. J; e* f) a        st_update_plan_block_parameters(); //通知stepper module验算减速。
; G4 f* V( d) E& k' B        sys.suspend = SUSPEND_ENABLE_HOLD; // 开始暂停标志7 v" U' O+ ]% c0 v, T# d7 s
        }
4 H" j# t1 b3 e+ h2 M/ D" Y+ |: f* v+ l* `0 `9 X/ ]) b  H; K
        // 如果,Grbl空闲不在运动。简单的指示暂停就绪状态。! V, m0 M3 I& G# O" E% U
        if (sys.state == STATE_IDLE) { sys.suspend = SUSPEND_ENABLE_READY; }
) F3 U7 t7 \/ b6 `7 H1 @' m6 \. M4 i/ D

0 |  H- h/ s# ]        //执行和标志和减速运动取消并返回空闲。主要由探测使用周期
! t) s* T! n+ h        //停止和取消剩余的运动。       # T1 L3 F2 d; A0 b( I
        if (rt_exec & EXEC_MOTION_CANCEL) {# s" ^# u0 x8 M% r1 `& U0 A; E
          if (sys.state == STATE_CYCLE) { sys.state = STATE_MOTION_CANCEL; }, n% C4 ]( d2 J& K! n6 d4 L
          sys.suspend |= SUSPEND_MOTION_CANCEL;
- c! ^% J* h0 ^& |! S" a% j        }6 [2 j/ E1 k3 G4 A
9 E' Z* w4 H; W5 j
        // 只在循环时执行进给保持减速
. j5 L3 \' R6 B- R8 i; y         if (rt_exec & EXEC_FEED_HOLD) {' |' u+ S. C* J6 [' H( K
        //只有安全门为1才执行保持进给状态赋值
& R7 @/ _7 N, E  u, r% a" @          if (bit_isfalse(sys.state,STATE_SAFETY_DOOR)) { sys.state = STATE_HOLD; }3 c1 _$ S; a8 l! h. V. |( R- w- ?
        }: L: T6 f. |/ `7 Q1 u

4 R- J2 e7 h" G) ?$ G+ n# K        if (rt_exec & EXEC_SAFETY_DOOR) {
: H7 ~( e' U/ S( u: ^5 V          report_feedback_message(MESSAGE_SAFETY_DOOR_AJAR); 1 Z2 V- Z3 d# W
/ /如果已经活跃,准备好重新开始,CYCLE_STOP标志设置为强制断开。
# Q: h1 Z0 Z6 Y# s, D6 ?% @( q/ /注意:只是暂时设置“rt_exec”变量,不是动荡的“rt_exec_state”变量。$ P' b; X) M' E: @+ @' }
          if (sys.suspend & SUSPEND_ENABLE_READY) { bit_true(rt_exec,EXEC_CYCLE_STOP); }+ C; B5 E6 b! G/ d8 p$ r
          sys.suspend |= SUSPEND_ENERGIZE;9 \) W, p! b! M1 n. h
          sys.state = STATE_SAFETY_DOOR;
4 E' U1 `" N8 _; j+ P% D: @        }9 l! T2 m9 H! b0 c+ p* K

1 Y: \5 ~. c6 i( D4 q0 A. w& Cbit_false_atomic(sys_rt_exec_state,(EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR));    % k/ ]6 d& X' x) |4 n
( O3 X) P' q( k$ E( \5 t6 ]4 s
}3 A" e! l9 F: S  N3 P9 N
以上代码执行了! r7 k! Y0 e8 w5 ^
1.如果全局各自报警标志位其中(执行取消动作) | (执行进给保持) | (执行安全门)任意一位为真进入- J" v, Y, ]2 }2 L
2.系统为闲着状态, 开始循环状态, 回原点状态, 控制取消状态, 开始保持状态, 开始安全门状态时进入
& r5 D" u8 I$ I$ K% U% W: J5 j- j3.如果是循环状态执行暂停状态
! B9 r8 s" C0 \) e; S4.如果系统闲置状态执行暂停就绪状态: E& A2 \* k/ E3 L& M4 P: W0 S- @
5.执行动作取消# }* U# H  L& H; M0 Z
6.如果是保持进给状态,执行保持进给状态9 Y1 B) k; j# Z% o
7.执行安全门状态
0 {: w2 L% q. s5 m- a: q最后执行bit_false_atomic清标志清除(执行取消动作)(执行进给保持)(执行安全门)标志位                 
0 v9 U, I" h4 w; S9 ^+ \" v, \_____________________________________________________________________________
! D) a7 f, ~, I) R, Y# I3 L& S( {" o% |) Q! \
    // Execute a cycle start by starting the stepper interrupt to begin executing the blocks in queue.. |, m, x* x. h0 D: h
    // 执行一个循环开始启动步进开始执行中断队列的街区3 Y  \. q9 x8 {! N2 k0 Q+ e5 v4 v
    if (rt_exec & EXEC_CYCLE_START) {        //循环开始状态进入
+ _3 h; k; z1 Z9 z      // Block if called at same time as the hold commands: feed hold, motion cancel, and safety door.  O  n3 M# w) e# Y! t# `9 u
      // Ensures auto-cycle-start doesn't resume a hold without an explicit user-input.' o/ M* u+ P# M, m
          //块如果在同时举行的命令:保持进给,运动取消,和安全的门。 //确保auto-cycle-start没有简历没有显式的用户输入。
3 |6 w, J9 F$ q9 r6 Z% ]           # ~% B8 [. x" H% \3 ]" @6 i/ i
      if (!(rt_exec & (EXEC_FEED_HOLD | EXEC_MOTION_CANCEL | EXEC_SAFETY_DOOR))) {   //状态机如果不是保持进给,运动取消,和安全的门。 & k7 j  {( P* G$ G# G
        // Cycle start only when IDLE or when a hold is complete and ready to resume.
& m+ s  |- [( f8 V* l/ ?        // NOTE: SAFETY_DOOR is implicitly blocked. It reverts to HOLD when the door is closed.
! W# ^+ D- x$ i1 U  c2 q" ]                //循环开始时只有当闲置或持有完成并准备简历。
( @) f. t5 o, N; ~& n% ~. k3 ^) B                //注意:SAFETY_DOOR是隐式地屏蔽。它返回的时候门是关闭的。    $ X" F9 r# \' g, n

* o8 d+ K# F5 _! ?# B4 @  ~3 s                // 如果系统状态为闲着状态,系统状态为开始进给或运动取消,暂停标志为位重新开始
  ]9 R( A* \4 c9 U1 o        if ((sys.state == STATE_IDLE) || ((sys.state & (STATE_HOLD | STATE_MOTION_CANCEL)) && (sys.suspend & SUSPEND_ENABLE_READY))) {2 S4 u; x- H$ \+ Q* Y1 W
          // Re-energize powered components, if disabled by SAFETY_DOOR.
6 Y/ J' g2 a5 {" B          //        由SAFETY_DOOR重振组件供电,如果禁用。
( C: y" t& B% |0 {5 w% V6 h) V) H          if (sys.suspend & SUSPEND_ENERGIZE) {
! J8 N$ |( Z# ^0 y3 r& L" x# m9 U            // Delayed Tasks: Restart spindle and coolant, delay to power-up, then resume cycle.
- Y! o/ B* l0 P8 x2 w            //延迟任务:重新启动主轴和冷却剂,延迟升高,然后恢复周期。
0 Z+ U" J4 j2 D            if (gc_state.modal.spindle != SPINDLE_DISABLE) {   //主轴模式不是失能进入
0 d# C7 R/ k, Q+ y- N2 i) e              spindle_set_state(gc_state.modal.spindle, gc_state.spindle_speed); //设置状态和速度
' S- u4 w' ]) k: L) \              //待办事项:阻塞函数调用。最终需要一个非阻塞。
3 q3 Z4 h8 c8 E- m                delay_ms(SAFETY_DOOR_SPINDLE_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.
1 S9 x7 ^, O; j* X% w            }
$ K5 V, u; ?& [0 F* o" F            if (gc_state.modal.coolant != COOLANT_DISABLE) { + Y  b7 [% q* ?  U
              coolant_set_state(gc_state.modal.coolant); & r8 x0 A8 T9 w7 t3 S
              delay_ms(SAFETY_DOOR_COOLANT_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually." O0 U3 z9 E1 f% z# O# C/ t
            }. V$ S) L1 h$ n
            // TODO: Install return to pre-park position.
! Y7 O2 g: M* Y          }/ P9 R1 J) [0 u) P6 _% Z; ]
______________________________________________________________________________________________________________, ]8 G# n3 ^3 X9 B
          // Start cycle only if queued motions exist in planner buffer and the motion is not canceled.
+ A7 `1 V4 f  f  u                  $ J9 p9 ^/ i9 A7 u/ ^
                  //只有在队列马达存在规定的缓冲,并且动机没有让取消,才会循环! y, w! H6 x' j; H$ i: H# K3 S& x
                  
) T3 ^5 q# N! [4 h2 i6 n1 {& F          if (plan_get_current_block() && bit_isfalse(sys.suspend,SUSPEND_MOTION_CANCEL)) {% `( c; i2 M/ W! \( o' X% Y( q  P
            sys.state = STATE_CYCLE;
, Q; K+ f( G$ D" v1 G3 ~6 S' \7 {            st_prep_buffer(); // Initialize step segment buffer before beginning cycle.初始化步开始循环之前
; p. R8 w) A( D  Q            st_wake_up();
$ @5 l- M* w' L# n3 M. {+ k          } else { // Otherwise, do nothing. Set and resume IDLE state.否则,什么也不做,设置和复位空闲模式0 V4 X+ Y4 M# B, @# g$ {3 O& `  _
            sys.state = STATE_IDLE;
, ^$ i' S" J* V. {9 ~          }
' K7 o, B" W. I' D8 B. ~: ^          sys.suspend = SUSPEND_DISABLE; // Break suspend state.# ]+ ]2 Y4 F" M3 e4 X( }+ |
        }3 _7 r+ U( O+ ?
      }   
5 f$ t/ w; `- v: I/ E$ f. i      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_START);       
- Z( W6 f% B4 g  D" W/ _6 Y1 M# ]3 Y8 s    }# e8 x. q4 [8 ?3 }/ L9 o
. W4 e/ l& ]1 k% A4 x: y+ R
_______________________________________________________________________________________________________: Y, @+ V6 A+ v3 k
    // Reinitializes the cycle plan and stepper system after a feed hold for a resume. Called by
$ g' W* n4 P: ~; F    // realtime command execution in the main program, ensuring that the planner re-plans safely.
: E; R& N* ?( u3 i3 u    // NOTE: Bresenham algorithm variables are still maintained through both the planner and stepper. t# @, S; `& R% f# M5 f
    // cycle reinitializations. The stepper path should continue exactly as if nothing has happened.   
& [! _- ~( P7 W& ~- I+ B: ^4 v    // NOTE: EXEC_CYCLE_STOP is set by the stepper subsystem when a cycle or feed hold completes.
. A% v- X5 a9 Y  H7 D4 s  q
7 v" V6 E1 E$ l8 h6 X+ K* B) }        //重新启动后循环计划和步进系统的进给保持简历。通过实时命令执行主程序,确保安全计划重新计划。
0 h! u# z9 U" T, [  p% F/ ]        //注意:画线算法变量仍保持通过规划师和步进
+ b, L: w  G3 G        //循环仅。步进路径应该继续,好像什么都没发生一样。       
( P9 C4 [  A( b7 y        //注意:EXEC_CYCLE_STOP由步进子系统周期或进给保持时完成。" D: b# |4 z. m: W, ~, q

; h9 b8 q% h4 f$ h; w, A2 O    if (rt_exec & EXEC_CYCLE_STOP) {                         //如果是循环停止状态进入
& n- ^4 n; J7 X      if (sys.state & (STATE_HOLD | STATE_SAFETY_DOOR)) {4 r8 `% R8 l% s+ L0 T- A4 A
        // Hold complete. Set to indicate ready to resume.  Remain in HOLD or DOOR states until user
$ n1 y$ B$ @) {2 J2 P2 B* R        // has issued a resume command or reset.7 k* j- K% L; [- U9 I  t( L
- `2 p6 R9 Y" N+ D; y( S/ M
                //保存完整。设置为指示准备简历。继续持有或门状态,直到用户6 ?1 l1 U5 g' x6 B
                //已发布了一份简历命令或重置。. a  @/ [& M3 P9 Y' _  @" }
               
1 P! Y$ z4 M/ {9 L1 G. K5 f" n        if (sys.suspend & SUSPEND_ENERGIZE) { // De-energize system if safety door has been opened. 如果安全的门已被打开。断开系统
3 z3 q; B8 {1 N8 \! a1 @; W' L- X          spindle_stop();
. v/ T/ k3 i/ O6 G9 A          coolant_stop();
& [" c2 j4 M8 G. I9 E$ E          // TODO: Install parking motion here. 安装停车动作。3 {6 f* |+ a" Z3 z4 f
        }
' V# y2 \0 {4 K: r8 c7 H        bit_true(sys.suspend,SUSPEND_ENABLE_READY);
/ W8 z8 m7 b/ K2 o. @( ^2 ]      } else { // Motion is complete. Includes CYCLE, HOMING, and MOTION_CANCEL states. 电机完成,循环,回原点,,MOTION_CANCEL5 n1 ?1 i4 J  O. G
        sys.suspend = SUSPEND_DISABLE;
' g# R9 }) l$ u8 b        sys.state = STATE_IDLE;
7 f* g% I$ ?" N9 ]      }
. ?5 E4 y0 }% w( G. T2 g% p4 s. ~      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_STOP);
- u) h0 Y1 l6 j4 G% `0 w, g% D4 W    }6 D7 ^" l! s0 }9 B& Y
   
7 ~- c2 w7 i' r6 ]7 L; R  }
& t7 r& B: _8 V/ j. j$ m) O' M___________________________________________________________________________________________________7 e9 T& ?& n9 N* X
8 X: u$ s5 `" l/ a# v3 c1 K
  // Overrides flag byte (sys.override) and execution should be installed here, since they
) L% S6 K5 L: h! `; h  // are realtime and require a direct and controlled interface to the main stepper program.
' t3 f* u+ k  c# A" H* U9 j8 d, z/ `1 H
  //重写标志字节(sys.override)和执行应该安装在这里,因为他们- g' d3 ]4 t( h9 B& y/ ?2 ~
  //实时和需要直接和控制接口的主要步进程序。7 O0 {9 W0 O/ E& A) a
+ l, N+ G; E& G1 M! Y3 L$ ^
/ @; s7 {) w7 @1 }3 F
  // Reload step segment buffer 重新加载步段缓冲0 L. i+ Y: `2 t* }4 d
  if (sys.state & (STATE_CYCLE | STATE_HOLD | STATE_MOTION_CANCEL | STATE_SAFETY_DOOR | STATE_HOMING)) { st_prep_buffer(); } ! u" ~$ G, G* c9 }, u0 l# ?
# T, E/ [1 U! x3 E( k; t" Q1 _  m
  // If safety door was opened, actively check when safety door is closed and ready to resume.6 }( r7 K+ }6 R9 _! H& r
  // NOTE: This unlocks the SAFETY_DOOR state to a HOLD state, such that CYCLE_START can activate a resume.        + s  G" k& B- T- P  M
. f2 ?9 k3 c+ i. ^
//如果安全的门被打开,积极检查当安全门关闭,准备简历。
' z, Q9 m; a2 r! l7 t0 ~  //注意:这解锁SAFETY_DOOR状态保持状态,这样CYCLE_START可以激活一个简历。
7 j/ b3 V0 S- z) s  S# J2 l9 h7 U( g  V! b4 H3 {
  if (sys.state == STATE_SAFETY_DOOR) {                 //安全门状态进入
4 V5 e5 `: L7 u$ J8 y, b    if (bit_istrue(sys.suspend,SUSPEND_ENABLE_READY)) { . @1 S1 a2 K' N2 D5 U
      if (!(system_check_safety_door_ajar())) {/ J! J$ v& o- Y2 F% ^1 Y9 @8 l
        sys.state = STATE_HOLD; // Update to HOLD state to indicate door is closed and ready to resume. 更新保存状态指示门关闭,准备简历。- |$ M& {, e, t) M, l# |
      }' p) E4 o1 f- |8 Z+ M
    }
% R1 P) Q2 E7 L6 k9 g/ U3 I  }
0 p8 a. D& M3 O, |& q# o+ v2 }  E$ G: f. Q" Z8 E3 ~
  } while(sys.suspend); // Check for system suspend state before exiting.
5 b4 v9 k9 y3 ?8 d2 N7 v* O  
/ `+ _2 x) \+ x$ p3 _! U( M& E. z0 t7 Z}  
回复 支持 反对

使用道具 举报

发表于 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, 2024-4-29 00:02 , Processed in 0.084139 second(s), 22 queries , Gzip On.

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表