机械社区

 找回密码
 注册会员

QQ登录

只需一步,快速开始

搜索
查看: 18813|回复: 15

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

[复制链接]
发表于 2016-8-20 23:56:23 | 显示全部楼层 |阅读模式
本帖最后由 1五湖四海1 于 2016-8-21 00:09 编辑
* F; Y) @, M; M/ M8 f9 D/ L3 `' M- L4 V
    以前制作过CNC雕刻机,是用MACH3作为上位机控制,硬件是采用PC接并口输出脉冲和方向使能信号经过隔离驱动步进电机驱动器,步进电机驱动是采用TB6560芯片控制。最后就接到步进电机。机械是用铝合金制作,主要部件有三个1605的滚珠丝杠,多个运动滑块等制作。用这台DIY CNC雕刻机可以雕刻木头塑料等东西。当时没有一直玩下去,现在发现网上有用单片机制作的雕刻机挺精巧的现在分享给大家。
5 s- I: u4 o9 U9 Y   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个运动来规划运行速度,以实现平稳的加速和无冲击的转弯。很棒吧!开始玩起。$ d$ f! g$ U6 j+ r+ b" R" o2 J4 D
    还没有雕刻机的机械部分可以用废旧光驱制作个微型雕刻机运动平台。雕刻机最重要的是主控程序这次用 Arduino/AVR328单片机,价格在15元左右,主控程序是上面提到的目前很火的开源
的GRBL,还有一种基于STM32平台的开源主控程序Dlion也不错可以替代grbl。如果从性能比较这两个方案,显然是stm32平台运行速度更快毕竟他是32单片机呀!
/ z0 Q7 Y5 S" J- c; N/ O0 e3 `
0 M7 g. Q% H! Y1 k& D! H

2 i$ M* W/ z9 Y! {, Q    下面介绍小这个些主控程序主要干的事,通过串口PC和主控板通讯,PC命令给控制板,控制板接收命令做不同的响应,PC可以发G代码给主控板,接收完成后可以自动开始雕刻任务。
: h- O. D) k7 L- M; S          在介绍下G代码因为G代码是雕刻机的核心部分  o5 z: v2 B7 E& F, i6 _6 |
G代码是数控程序中的指令。一般都称为G指令。
& \. a9 f9 y. e  }8 [6 sG00------快速定位9 w# P' ^" [1 r7 r" c- B6 @  J7 D
G01------直线插补
$ T0 `5 K9 ]* G2 a. N& k0 M5 c$ uG02------顺时针方向圆弧插补9 _' q9 B* j% I
G03------逆时针方向圆弧插补/ _3 k3 k+ p" K1 q6 Q: R; e# m* H. C
G04------定时暂停% E1 [8 C/ G- H4 A
G05------通过中间点圆弧插补/ [: E8 \" M4 F% n
G06------抛物线插补- @  _% }/ R* F9 u7 Q* E
G07------Z 样条曲线插补
( z2 x; O9 F( x, PG08------进给加速
' ?/ Y7 n  N7 r4 V5 I# [7 y9 wG09------进给减速& g2 {6 s/ x3 u1 R; H
G10------数据设置$ `4 h' m. z3 g; z1 f
G16------极坐标编程
8 X# T# u( M3 a5 r6 L; K5 D7 uG17------加工XY平面& s( n6 ?) w& g( P: }
G18------加工XZ平面% [6 t* h# e/ I
G19------加工YZ平面

: {, L, L! N/ K1 ?- J核心就是解析G代码,完成步进电机驱动,和控制主轴开启关闭,还有插补算法,直线插补,圆弧插补,还有一些步进电机的加减速算法。" ~8 P3 k, f* Q* X3 _$ S% p
下面对grbl主结构做介绍
( p! I4 o8 w8 K) m; ]main()主函数首先执行下面初始化函数
" ~& u2 u/ L9 X1 G        serial_init();                           // 设置串口波特率和中断! |1 \9 L6 [- d8 }& ^1 E" i! y) y6 X
        settings_init();                         // 从ROM加载grbl设置
( w3 ]8 F. B$ P6 W2 t* v: L        stepper_init();                          // 配置步进方向和中断定时器
7 Z0 d4 b3 d2 S! H$ D' T  b* f        system_init();                           // 配置引脚分配别针和pin-change中断2 p) y9 \9 E3 I6 f  C
        memset(&sys, 0, sizeof(system_t));          // 清除所有系统变量
+ ~4 {, Z/ a) ~2 u! v" u7 i        sys.abort = true;                           // 中止标识位置位9 C/ D) i/ S+ J8 Y2 r6 y6 S9 B8 F5 O
        sei();                                         // 使能中断  |3 l: n5 u8 b  H7 k9 C: ]
  #ifdef HOMING_INIT_LOCK                        // 宏运算(settings.flags & (1 << 4)) != 0结果flags等于执行sys.state = STATE_ALARM
' n4 v8 O# v9 L- l                                                // 系统状态赋值为报警状态
( K) M7 }( N2 L) U2 }& I3 ~, i3 k            if (bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE)) { sys.state = STATE_ALARM; }, l5 g- }$ d; R* P' |
  #endif
1 P+ s0 M+ }: [6 J- }9 v_____________________________________________________________________________________________________________________________________
/ m+ ]! Z' e% L% v5 \接下来是一些主要部分初始化
3 a: T' z" k4 p0 cfor(;;) {) P7 h1 ]9 X- J0 ?- }
        serial_reset_read_buffer();         //清除串口读缓冲区& U* t4 {- w3 w8 B: c, P: B
        gc_init();                         //初始化G代码功能函数" ~/ k6 X) F- \* c: r* D: k  x
        spindle_init();                        //主轴初始化
3 s; v" W: v  Z: P' M        coolant_init();                        //冷却液初始化% _3 ?# @6 u0 r$ j+ O7 Z6 a
        limits_init();                         //极限开关初始化
$ y, Z- \/ f. w! g        probe_init();                        //探测部件初始化
- U+ l  k& ^- I* X" B; q1 X( j        plan_reset();                         //清除块缓冲区和规划师变量% ~) C0 `8 H5 G3 _; a) h8 Y
        st_reset();                         //清除步进系统变量。2 t9 G8 r% X% C/ ?/ E6 ^
) l% h1 B/ f1 [- x1 H- h

  K' E& {8 k* f# z4 I2 @        //下面两行清除同步gcode和策划师职位当前系统位置。
9 @- N- X  l6 ~& q* E7 Y
        plan_sync_position();
; g* V6 W6 G1 F- w% N        gc_sync_position();
5 b. f6 D8 l: I) j4 p1 l0 E+ U5 {& U. `/ q1 e

; E" S/ A5 y6 j$ Z9 f2 b        //复位系统变量+ o7 G8 i& i8 [" v- h2 e$ F
        sys.abort = false;                //系统中止标志- M5 ?( \7 n6 q% {
        sys_rt_exec_state = 0;                //系统标志位变量状态管理。看到EXEC位掩码。7 w2 z+ V- {/ S1 E2 h. W" |
        sys_rt_exec_alarm = 0;                //系统标志位变量设置不同的警报。6 H/ v; q8 @, M) M" A9 Y" X" \7 l) h
        sys.suspend = false;                //系统暂停标志位变量管理,取消,和安全保护。, r% P2 f! e/ u1 r2 @( y
        sys.soft_limit = false;                //限位开关限制状态机错误。(布尔)
2 k# J9 G* R  i" o' \# u: A& {1 ]2 e/ C  |! B
5 u) N) b9 Q  z4 d5 D$ f
        protocol_main_loop();                //主协议循环
$ S: @- w4 T. {! X}        //
2 ]0 ^/ K% i6 }8 n: ^3 a7 Z9 @$ ]_____________________________________________________________________________________________________________________________) [' u- h+ A( \4 c( f" X6 Z9 ~( A
进入void protocol_main_loop()函数) j  G4 Q3 b2 @: C: |  G1 D& q
{& A7 Y6 M! W% u2 g
        report_init_message();                // 打印欢迎信息 9 m6 O/ ~; s" n( c
        //重启后检验和报告报警状态如果错误重启初始化。$ T5 d7 w% h# M
        if (sys.state == STATE_ALARM) {9 I  D, Q9 N$ u2 R& P' ^3 ?. \
            report_feedback_message(MESSAGE_ALARM_LOCK); //打印信息0 s+ G+ N/ D* p: q* n
          } else {
& i8 p) ~+ j' P& {, @            // 如果没有报警说明一切正常!但还是要检查安全门.
0 b( B# A* n' O# u            if (system_check_safety_door_ajar()) {2 U7 R: ]8 a. T9 m* ?7 G; ]
                     bit_true(sys_rt_exec_state, EXEC_SAFETY_DOOR);
; h# A( F7 R, j) g                     protocol_execute_realtime(); // 进入安全模式。应该返回空闲状态。7 R( }2 G/ U+ I( H3 j5 H
            }         else {& H4 G, W, g2 b  z3 J$ ?8 g; H
              sys.state = STATE_IDLE; // .设置系统做好准备。清除所有国家国旗。" P3 C+ ]0 I/ D* n
            } 7 @+ u9 R' q! T- H- a
            system_execute_startup(line);    //开始执行系统脚本2 M" B" Y6 j" x( K+ K6 `
  }
. i+ I: Y4 e1 N9 o. l# s- g7 e( e
! J$ }5 r( G7 C$ W$ R5 B, E
( T0 w5 ?  j4 ~) e  t. O  // 这是主循环!在系统中止时这是出口回到主函数来重置系统。7 p, s) R! W6 L+ k# E% |' I% h' a
  // ---------------------------------------------------------------------------------  # z5 k* p$ b# s. I5 g" ^
  % o5 s/ l7 J0 s6 |8 d
        uint8_t comment = COMMENT_NONE;
$ [/ ^  Z2 `# j2 u: U        uint8_t char_counter = 0;* l6 \5 T: _, u' h
        uint8_t c;
. P. Q  s/ R3 b! n6 @$ A: Z8 Z_______________________________________________________________________________________________________________________________: O/ L2 I2 b1 Q1 b) k: m1 B0 L1 o. P
接下来进入for(;;)循环                //下面代码是G代码解析核心部分,程序中comment(注释)变量会被赋不同值,代表发符号有‘(’‘)’‘;’
' t" ]% p( r  o5 W! {+ X0 p{
8 a7 A* V& G/ C4 {$ m% K+ Q8 k" F//串行数据输入一行的的过程,作为数据。执行一个
0 h* F7 S5 Q$ S8 g5 Q  y0 g2 o//所有数据初始过滤去除空格和注释。 3 B- k" V/ H$ N4 E
//注意:注释,空格和程序段删除(如果支持的话)处理技术% x4 g  [5 h0 F; ?
//在G代码解析器,它有助于压缩到Grbl传入的数据: |2 X! x, i4 o# N* r6 F, y
//线缓冲区,这是有限的。刀位点标准实际上州一行不行
! H3 S& v" `7 `$ u//不能超过256个字符,Arduino Uno没有更多内存空间。& i. C' g' j! \' m! G
//有更好的处理器,它会很容易把这个初步解析的' t7 ~" v% y+ y/ K& A2 B$ O
//分离任务共享的刀位点解析器和Grbl系统命令。                                                                ; @  q0 }7 n% K, N8 L
    while((c = serial_read()) != SERIAL_NO_DATA) {                             //读取串口数据,有数据执行下面代码$ u2 |7 n9 ~4 N- g* E- G2 C
      if ((c == '\n') || (c == '\r')) { // End of line reached                //如果数据是/r,/n代表一行结束$ k: G- M0 i3 a: r, I
        line[char_counter] = 0; // Set string termination character.        //设置结束标志
5 Z8 I$ l6 Z" a7 b' r" Z        protocol_execute_line(line); // Line is complete. Execute it!        //一行完成执行此函数
- A* i' _2 }; g# `. C        comment = COMMENT_NONE;                                                //注释清零
  B6 H- \0 g7 I9 {3 e* @        char_counter = 0;                                                    //字符计数清零2 Q8 O& v4 b4 k4 m1 n: M
    T4 b# K+ v  q" ]6 c; m/ y- ^
        else {
* G' R! u$ n( Z8 o        if (comment != COMMENT_NONE) {
. \4 t, S( Q4 @" [! }                                                     //扔掉所有注释字符
, }) w9 F' z! l          if (c == ')') {! j$ T: p! x3 T- P; N6 c6 S
            //最后注释。重新开始。但是如果有分号类型的注释。$ F0 v  }8 m% X) [/ L+ R( W( _( i2 y
            if (comment == COMMENT_TYPE_PARENTHESES) { comment = COMMENT_NONE; }
, _* M0 G" z3 A; \; Y$ @% r          }- V$ Q6 I% f, X( S! z6 Q
      } else {8 B6 V$ F, t5 d
          if (c <= ' ') {
2 k$ ]0 O  O  ?4 U            //扔掉whitepace和控制字符
/ O4 s6 _, t3 E  m" A          } else if (c == '/') {
; H9 L0 U  K3 X$ h1 j# X2 z- B5 p* I3 [            //块删除不支持将忽略字符。; T2 r" ?9 \5 I$ {3 H
            //注意:如果支持,只需要检查系统是否启用了块删除。! S: {) P2 Z  V+ i
          } else if (c == '(') {5 u+ D9 Z3 Y( f6 ]/ d6 T2 R
            // Enable comments flag and ignore all characters until ')' or EOL.6 Z! h( h% Z8 k* I) V8 C! L
            // NOTE: This doesn't follow the NIST definition exactly, but is good enough for now." R2 [  j! j3 l1 A0 i: v6 X$ K6 W
            // In the future, we could simply remove the items within the comments, but retain the& ]/ d! R& z$ e4 M9 m7 K
            // comment control characters, so that the g-code parser can error-check it.5 b: a; U% _& H8 n- B) h& N: |
            comment = COMMENT_TYPE_PARENTHESES;! y, G' x% ^, E9 q! u
          } else if (c == ';') {
# r' k! Z- M6 z! Q            //注意:','注释EOL LinuxCNC定义。没有国家标准。: z: G# }* p9 {
            comment = COMMENT_TYPE_SEMICOLON;" ?/ c6 k8 w1 Y' V
% {, ~6 |& Q4 o' h; \1 o" u0 Z
2 U" f& L1 _4 p9 W4 h
_____________________________________________________________________________________________________________________________________
0 A. M  k, U2 a, b          } else if (char_counter >= (LINE_BUFFER_SIZE-1)) {                        //串口接收数据大于80字符时
3 v, r# G3 y5 z( p: J( p            // Detect line buffer overflow. Report error and reset line buffer.        检测缓冲区溢出。报告错误和复位线缓冲区。5 J, {! ?$ Q- I* A" R5 u6 Q2 Z
            report_status_message(STATUS_OVERFLOW);                                //打印溢出信息
! c" c1 K  v+ u( |0 I& ]/ u            comment = COMMENT_NONE;
& d, |. q) k" P' @1 C9 X            char_counter = 0;+ z1 _$ ]& B+ x4 k! Y. z& I  L8 @- M
          } else if (c >= 'a' && c <= 'z') { // Upcase lowercase                        //小写改大写
9 x, O! F! S$ p  R2 K  X            line[char_counter++] = c-'a'+'A';! T3 f# S2 v& T& ]
          } else {
& ]7 f; a* |  f            line[char_counter++] = c;: Z( q! {& A3 H
          }+ d' n6 i1 P: C- K- [
        }- P+ U0 @2 q: ]; i
      }1 _# p1 X  c6 d& P" t- i, Y
    }
5 p, n! L% j9 `/ m8 I/ r% B____________________________________________________________________________________________________________________________________/ A8 z% @! X5 X0 t: N
        //如果没有其他字符在串行处理读取缓冲区和执行,这表明以完成,自动启动,如果启用,任何队列动作。6 n* ]0 q1 v# k3 L0 w3 m! N
        protocol_auto_cycle_start();                //自动开始协议循环. [$ k/ g; W/ y& ]! ]7 B& y. I
        8 \0 r/ `" U) p8 S% d
            protocol_execute_realtime();                  //运行实时命令。4 b# v, r" i# W: x- l
            if (sys.abort) { return; }                 //中止标识置位程序循环重置系统。            
  U# a1 ~% ^. x. u  }
% S  B4 l, t, h% q, ^1 y) A' p  return;                         //一般程序不会执行到这里$ t# c9 l$ P) ?& J0 e
}' E# _& [4 {- }6 d/ Q
____________________________________________________________________________________________________________________________________1 T4 M5 }8 g7 n, f4 k9 C1 Z2 }% e' V
正常情况下,读取完G代码程序会进入protocol_auto_cycle_start();//自动开始协议循环 函数下面介绍此函数
4 ?- T$ k3 `  j! P$ K* Q. W// Auto-cycle start has two purposes: 1. Resumes a plan_synchronize() call from a function that4 K1 R* e3 A/ g( f
// requires the planner buffer to empty (spindle enable, dwell, etc.) 2. As a user setting that
. k8 n% Y; ]+ `3 v// automatically begins the cycle when a user enters a valid motion command manually. This is 4 `( M: g9 |" m
// intended as a beginners feature to help new users to understand g-code. It can be disabled; h. D! b# u5 I: d
// as a beginner tool, but (1.) still operates. If disabled, the operation of cycle start is. H" P: C* B( ]) v! i0 w$ u
// manually issuing a cycle start command whenever the user is ready and there is a valid motion
  I. x% h- X; Q// command in the planner queue.# F; ^  F$ J7 m9 C5 V
// NOTE: This function is called from the main loop, buffer sync, and mc_line() only and executes 5 c: L: ~" G+ A. k5 W
// when one of these conditions exist respectively: There are no more blocks sent (i.e. streaming
( ~/ s  }9 {2 h// is finished, single commands), a command that needs to wait for the motions in the buffer to
4 _- ^+ ]/ q; ~2 Q// execute calls a buffer sync, or the planner buffer is full and ready to go.* P# E1 U  s/ h0 i, U4 {
//自动开始有两个目的:1。回复一个plan_synchronize()调用的函数2 d+ w6 [) ?0 g/ N7 `( F' O
//需要规划师缓冲区空(主轴启用、住等)2。作为一个用户设置# @: m, B2 N! ^- G
//自动循环开始当一个用户输入一个有效的运动命令手动。这是
, H( t" f6 O7 A6 @9 ?8 E//作为一个初学者的特性来帮助新用户了解刀位点。它可以被禁用
# C3 O7 H/ _2 T6 p5 t/ z//作为一个初学者工具,但(1)仍然运作。如果禁用,运行周期开始
% _$ N" [' D! E//手动发出一个周期开始命令每当用户准备好,有一个有效的运动
1 S: ~$ L9 Z9 G) m//命令的规划师队列。
7 ?# ]  J1 {0 H+ ]% v//注意:这个函数被称为从主循环缓冲区同步,mc_line只()并执行
! ^' }  q, a4 b0 q//当其中一个条件分别存在:没有更多的块(即流发送
7 Z2 p) w' M  K" b9 J2 V( F//完成后,单一的命令),一个命令,需要等待缓冲的动作/ D) V+ p4 ^( g1 M# [
//执行调用一个缓冲区同步,或规划师缓冲区满了,准备好了。5 r- O& w  x5 l9 p, `# A
void protocol_auto_cycle_start() { bit_true_atomic(sys_rt_exec_state, EXEC_CYCLE_START); } ) L. _% G) r( ~" {9 e
_______________________________________________________________________________________________
3 U/ b2 E6 U; w  T. w" @" a) G接下来程序运行protocol_execute_realtime(); /运行实时命令。2 M! w% }6 b9 f3 j+ C
// Executes run-time commands, when required. This is called from various check points in the main
" w$ J: E: E: \4 ]6 Q// program, primarily where there may be a while loop waiting for a buffer to clear space or any
- s' j- T( W* i* O0 h3 @1 i$ s// point where the execution time from the last check point may be more than a fraction of a second.
& \1 W" s: M/ N5 x% ^% U// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code
- ^6 |) `* p, S* d- I9 L# h// parsing and planning functions. This function also serves as an interface for the interrupts to - q1 h& o+ ?* `# J& n0 j, |& i
// set the system realtime flags, where only the main program handles them, removing the need to
* I) M6 E! W# F) u- d// define more computationally-expensive volatile variables. This also provides a controlled way to % Q/ J: g, S6 j4 M
// execute certain tasks without having two or more instances of the same task, such as the planner
& p+ ?* N% c1 _6 j7 r7 W3 ^; ^// recalculating the buffer upon a feedhold or override.
9 b5 g# a) F. \  {# W// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,  `% x2 Y$ m: P0 [% ?
// limit switches, or the main program.
% Q( u! Q2 U' q, d( jvoid protocol_execute_realtime()
9 l, f6 R: J( W( v( u; M8 T3 I# | uint8_t rt_exec; // Temp variable to avoid calling volatile multiple times.临时变量来避免多次调用不稳定。
% ^# b  f/ ?! b5 N! |就先分享到这吧!; j* ]9 e2 s% B' Z0 W

& @& ^$ F; y3 P- f, ^& u- l# E" g& L" E) g* ~

# @( k1 E7 Z  X6 @. f. t  E1 T; _; u0 l+ b: A! L* `# @: P5 ?# s

2 n! l2 q$ X5 n; L# N! `
0 Z* q' O" g% J! c. T! S, |
+ C1 F. f7 F  R/ ~8 z% A: U) X' w5 T- V( H# D
. L2 U% D# N& i  P1 D! G: \& {
4 W+ W5 i' c2 g7 k

. [: s4 `# ^$ Y  j- l( ~( V$ c/ k3 `' x0 Q: o5 u. c, I
2 T" U2 l& k7 u$ `8 v1 f$ k4 x. I
8 ^9 M. J' p  [3 A; ~% A

0 |9 I# G, {  F4 Q
0 J. ?$ c' j' d9 a- F& _% T2 s1 H5 J: z8 ^) r8 j5 }/ R
( Q1 E* V; k9 B* [4 n7 d

: ?' @/ ^- s; g4 o
1 n; |7 B( g( B9 k

, O  e+ T5 w/ e3 s
4 K' `( c' j( E; r+ z* a3 r3 A- [/ G, b% U+ d6 ?1 k
补充内容 (2016-8-25 22:40):
/ B( f0 W( G5 u; O8 Z配置说明' h. [, t& U3 [, V, i" }7 j; |$ E
//这个文件包含编译时配置Grbl的内部系统。在大多数情况下,, ?! Z3 G6 s; u* f
//用户不需要直接修改这些,但是他们在这里为特定的需求,即。
3 z5 x" z: S8 l) q4 g//性能调优或适应非典型的机器。
3 r& i! J% i& r1 k6 Y! O) \主要配置项:  Z; O8 F% A% t$ J
1.#define DEFAULTS_GENERIC        //在重置eepm时使用。在defaults.h改变想要的名字8 I; M" h& U# Y8 U
2.#define BAUD_RATE 115200        //配置串口波特率115200
4 e$ G5 F2 W$ Q8 o3 o5 J3.#define CPU_MAP_ATMEGA328P         // Arduino Uno CPU% U$ l% b; r* K* S4 q$ N8 X
4.#define CMD_STATUS_REPORT '?'        //定义实时命令特殊字符7 Z+ z2 x0 w  p% {
5.#define HOMING_INIT_LOCK         //回原点保护锁
1 _! h; _  N$ x8 \6.#define HOMING_CYCLE_0 (1<<Z_AXIS)              // 第一步Z清除工作区。& r7 `; P. h6 |5 _
  #define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // 然后X,Y在同一时间。
, X+ o6 S  F! n* C7.#define N_HOMING_LOCATE_CYCLE 1 //回原点循环次数9 I  L: r3 S( J7 Q
8.#define HOMING_FORCE_SET_ORIGIN //取消这定义迫使Grbl总是在这时候位置设置机器原点尽管开关方向。- s* l" N1 p- j2 Y7 C% {4 c
9.#define N_STARTUP_LINE 2 //块Grbl启动时执行的数量。
: p6 [8 p4 s  r+ h10.#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 协调或位置价值英寸# G. ^! b; l) p5 {0 ]" z
   #define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 协调在毫米或位置价值
) g: c8 S" J) ~4 m/ Q+ T   #define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分钟的速度值
" C3 J+ i/ r# H8 d   #define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分钟7 @# {+ u: D& \+ m
   #define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 对浮点小数设置值7 E$ D, \) i2 y  i3 G! ]/ j) q
11.#define LIMITS_TWO_SWITCHES_ON_AXES //如果你的机器有两个极限开关连接在平行于一个轴,您需要启用这个特性
  Y: ]7 t5 q% j* H12.#define USE_LINE_NUMBERS         //允许GRBL跟踪和报告gcode行号
6 w! U3 }  t7 p( g9 V2 _( s3 r; F13.#define REPORT_REALTIME_RATE //允许GRBL报告实时进给速率, n) o- J+ r* O" D  u# c
14.#define MESSAGE_PROBE_COORDINATES  //坐标通过Grbl $ #的打印参数?. X/ x6 p- _+ C! b: c: T; H! y( X
15.#define SAFETY_DOOR_SPINDLE_DELAY 4000 //安全门主轴延时& R6 K; l& z1 S7 t2 q4 S+ x
16.#define SAFETY_DOOR_COOLANT_DELAY 1000 //安全门冷却液延时
( Q( |$ _7 k( y) t17.#define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS) //启用CoreXY运动学。: x6 i. o% w' n* T
18.#define COREXY // Default disabled. Uncomment to enable.改变X和Y轴的运动原理  _7 `' L2 ?) g* o9 ?
19.#define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.反转针销逻辑的控制命令3 d- P* e: N6 R3 d
20.#define INVERT_SPINDLE_ENABLE_PIN // 反转主轴使销从low-disabled
" C; m- g: D& ~7 b# y) n" O! s21.#define REPORT_CONTROL_PIN_STATE //启用控制销状态反馈状态报告。7 ^; @& d) b6 k' r& D, S6 F
22.#define FORCE_INITIALIZATION_ALARM //启用和用户安装限位开关,Grbl将启动报警状态指示, t9 M! Y( j4 w, h  I
23.#define REPORT_GUI_MODE // gui允许最小的报告反馈模式5 f2 z! {4 W: |3 m/ U: k4 X- v
24.#define ACCELERATION_TICKS_PER_SECOND 100 //加速度的时间分辨率管理子系统。
& E! h5 [* U$ n& j8 S6 _: d25.#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING //自适应多轴步平滑(积累)是一种先进的功能
& v: g: o  `1 r  y26.#define MAX_STEP_RATE_HZ 30000 //设置最大一步速率可以写成Grbl设置, Y; a& S4 [# ^2 j
27.#define DISABLE_LIMIT_PIN_PULL_UP //以下选项禁用内部上拉电阻# q$ Q2 l4 Z3 ?5 D
28.#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS //设置哪个轴长度补偿应用的工具。假设轴总是与选择轴工具面向负方向
, C+ r( w7 r. |$ i6 T3 W1 o29.#define VARIABLE_SPINDLE //允许变量轴输出电压不同的转速值。
* e! b" }8 e/ b" W. K$ k30.#define SPINDLE_MAX_RPM 1000.0  // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.
: A( K1 A3 G, C! {   #define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.. S( b0 i( N" U6 K& p2 p7 W
31.#define MINIMUM_SPINDLE_PWM 5 //使用的变量轴输出。这迫使PWM输出最小占空比时启用。& d  p* D& F4 b/ V, x
32.#define USE_SPINDLE_DIR_AS_ENABLE_PIN //主轴方向使能M4被删除
% \3 u# f& X- H; K  ^6 i* B4 D; O33.#define REPORT_ECHO_LINE_RECEIVED //应该对所有正常线路送到Grbl+ G4 ?/ X" T5 T0 F* @
34.#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min) //最小规划师结速度。设置默认最小连接速度规划计划
/ `3 K9 ]3 M# Q35.#define MINIMUM_FEED_RATE 1.0 // (mm/min)//设置计划将允许的最小进给速率
- Y4 |# O& Q+ h$ O6 E/ L8 I36.#define N_ARC_CORRECTION 12 //弧生成迭代次数之前小角度近似精确的弧线轨迹$ Z5 C5 n! Q0 D0 Q% `8 T1 \
37.#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)//定义值设置机器ε截止来确定电弧是一个原点了?
% S* ?/ a5 u: N2 y; A( ~38.#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds) //延时增加表现在住。默认值设置为50毫秒
5 m0 I: j* r7 L; I0 x, \39.#define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.. m& g- w) y/ ^; ^  v
40.#define BLOCK_BUFFER_SIZE 18  //线性运动规划师缓冲区的数量在任何给出时间计划0 t# V5 v& u! b0 G7 J( @% p
41.#define SEGMENT_BUFFER_SIZE 6 //控制之间的中间段缓冲大小的步骤执行算法0 `, z, [7 j' I  U- E
42.#define LINE_BUFFER_SIZE 80 //行执行串行输入流的缓冲区大小。
% _! [  ?4 G0 Q0 U: y* g43.define RX_BUFFER_SIZE 128 //串行发送和接收缓冲区大小! |& t: h. |3 e+ ^* U* o  j7 C& K
44.#define TX_BUFFER_SIZE 64/ w6 R; l5 m# X4 f4 L
45.#define ENABLE_XONXOFF        ////切换为串行通信发送流软件流控制。
( u! ^* \/ Q" F- B5 N/ b46.#define ENABLE_SOFTWARE_DEBOUNCE //一个简单的软件消除抖动特性硬限位开关。
& ?1 r/ T" x: {47.#define HARD_LIMIT_FORCE_STATE_CHECK        //Grbl检查硬限位开关的状态( v8 h+ m  O! Z( }
48.// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:编译时错误检查的定义值:% Q" s% Y1 R: A9 i& [! O* D0 S; k/ ^0 _. }
' j0 x2 A) W: B1 R. D
___________________________________________________________________________________________________2 x/ _; n4 w0 H) |6 F& w
/*
: W9 Y) B4 m3 F  config.h - compile time configuration
* ^- ]6 R( T* T# }  Part of Grbl
: C. [( C& I) p! u0 }/ M3 V4 Q9 O: C! n/ l
  Copyright (c) 2012-2015 Sungeun K. Jeon
) a7 R( s( A9 d/ ]/ ^  Copyright (c) 2009-2011 Simen Svale Skogsrud
- U" Q& }/ W$ t0 x# K( N1 Y
1 K( j# ]& O; T2 W2 y0 ?* Y  Grbl is free software: you can redistribute it and/or modify
: }4 ]4 P6 f1 y# g  it under the terms of the GNU General Public License as published by
6 G4 A: Y+ F- h6 Z  the Free Software Foundation, either version 3 of the License, or
) C: B4 s) h6 n- ~+ N  (at your option) any later version.0 I$ w( @2 W$ l1 B. d8 v
! k& L+ S9 ]( m
  Grbl is distributed in the hope that it will be useful,4 w* V0 f0 {3 ^& J: B
  but WITHOUT ANY WARRANTY; without even the implied warranty of
( c6 U0 }3 n& x2 C0 F  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# ^8 i+ d- i0 b+ s/ n( k: M  GNU General Public License for more details.
: x8 D7 c6 M/ t* ?
1 P, R% R( [5 p  You should have received a copy of the GNU General Public License' C9 u" T$ h( O# B3 B6 Z# b
  along with Grbl.  If not, see <http://www.gnu.org/licenses/>.
0 _. K! ^/ ~! iconfig.h  -编译时配置,Grbl的一部分
) v: X, D# G' n3 U. ]3 _( u& v6 U7 ^
版权(c)2012 - 2015 Sungeun K. Jeon1 W' Z0 q/ Z3 j  y  `0 O; z' d/ D
版权(c)2009 - 2011 Simen Svale Skogsrud
% t% Y! k* S4 }2 l6 l5 j" h* B0 n0 J% ], U) z6 x+ G/ u
Grbl是免费软件:可以重新分配和/或修改( l3 u* ^/ M$ |! ?/ H
GNU通用公共许可证的条款下发布的自由软件基金会,版本3的许可,或(任您选)其后的版本。
) @9 \5 z# k$ q2 q/ G" G
& E3 t% ?( W& l8 k, ~; }Grbl分布,希望这将是有用的,但是没有任何保证;没有即使的默示保证适销性或健身为特定目的。看到
& ?- S) C% v- ZGNU通用公共许可证的更多细节。
1 Z# ^/ ^- \) [5 f6 P
. P1 o% V9 @2 Q& e! x+ T7 T: y3 z你应该收到了GNU通用公共许可证的副本
& S7 H- u! \0 F- y) R' d( y+ F连同Grbl。如果没有,看< http://www.gnu.org/licenses/ >。
/ I5 K  \* |8 m) ^( _ ! Y4 H0 v9 h- E1 x
*/
' N( G6 E8 Q/ w# t8 c; @% G2 T& [; I  ' U* |6 K" d' |# L8 h* t( T
// This file contains compile-time configurations for Grbl's internal system. For the most part,' C( [: S! _1 {0 ]
// users will not need to directly modify these, but they are here for specific needs, i.e.
" J# E2 n0 l! W. S8 S5 t& k// performance tuning or adjusting to non-typical machines.
7 u% s, e* G1 g5 m; l3 C//这个文件包含编译时配置Grbl的内部系统。在大多数情况下,6 E+ ?" q0 G! b" j% h8 H
//用户不需要直接修改这些,但是他们在这里为特定的需求,即。
0 n7 P4 H' k# P//性能调优或适应非典型的机器。
* N/ B4 `, b2 F& g/ }# X! s' j7 R" a2 E  _6 J6 ~2 G9 b1 M) }
// IMPORTANT: Any changes here requires a full re-compiling of the source code to propagate them.
- C. f! O- [- f6 Q( L//重要:任何变化需要一个完整的基于源代码的传播。
; \% h& ~* V. H( {. [6 y) s, p# ~. B( v9 a. e
#ifndef config_h
# x1 h! Y/ e5 `3 h6 d#define config_h
% i, P) p7 k6 f" ~7 U. M#include "grbl.h" // For Arduino IDE compatibility.
5 v* c; m+ {2 q" n
  W( w- A" O9 R- {+ ~1 X// Default settings. Used when resetting EEPROM. Change to desired name in defaults.h
; }/ \5 b9 \; H8 d) ]// 默认设置。在重置eepm时使用。在defaults.h改变想要的名字
: }6 w/ q) D: E' X; j3 R9 V! Z: B& }  i' n0 O5 ?
#define DEFAULTS_GENERIC
% P; ~9 x. D" s% ~
/ a" y. o- T+ A( w5 V% r) J// Serial baud rate
0 ~/ ^9 X5 {: |# \#define BAUD_RATE 115200                //配置串口波特率115200
7 N& b- o1 n0 {  \! k' z/ r  V( U
// Default cpu mappings. Grbl officially supports the Arduino Uno only. Other processor types: _! J) U* ^# ?: @# V$ @
// may exist from user-supplied templates or directly user-defined in cpu_map.h# y. a% u) a- H1 D0 h
//默认cpu映射。Grbl正式支持Arduino Uno。其他类型的处理器可能存在cpu_map.h直接从用户提供的模板或用户定义的/ H- f# w/ M" V1 t

& o2 U( M! j; u" a% h* A- f#define CPU_MAP_ATMEGA328P // Arduino Uno CPU
* W  J% |7 r: H& d- R$ |2 t
( B4 ?. p1 `) V8 g( E// Define realtime command special characters. These characters are 'picked-off' directly from the; C4 e/ e% h( v1 [
// serial read data stream and are not passed to the grbl line execution parser. Select characters/ \9 q0 F0 V  r% S+ H/ E
// that do not and must not exist in the streamed g-code program. ASCII control characters may be 2 c9 x' f  w: c  _! n
// used, if they are available per user setup. Also, extended ASCII codes (>127), which are never in . h) k: u% ~3 r
// g-code programs, maybe selected for interface programs.
* I2 E  T# F6 F! U. Y- M$ r$ a8 s// NOTE: If changed, manually update help message in report.c.: s: o  C( r' J- w  A

! a+ O8 A& D5 A//定义实时命令特殊字符。这些字符是直接从“各个击破”串口读取数据流并没有传递到grbl行执行解析器。选择角色
# V: s2 A0 I  z2 q& r6 A//不,不能存在于程序流刀位点。ASCII控制字符
( Y: f. E) a6 I+ @+ Z: s//使用,如果他们是可用的每个用户设置。同时,扩展的ASCII码(> 127),从来没有" u1 \, D6 j0 u- C
//刀位点的程序,也许选择界面程序。& l- w6 B* \1 v& Z, j: D: n
//注意:如果改变,手动更新report.c帮助信息。
9 [$ p5 s" I0 K# f+ ^% D, ?+ F% _  e' Q7 e3 b
#define CMD_STATUS_REPORT '?'' O, _  e. P& G9 M! C8 b8 L5 [
#define CMD_FEED_HOLD '!'
( Q$ u2 o" n  H/ e+ e" h9 r#define CMD_CYCLE_START '~'
7 m, Q: s+ t& s5 y  j% x6 ^; M#define CMD_RESET 0x18 // ctrl-x.
/ x7 }# m  G+ T3 V#define CMD_SAFETY_DOOR '@': G0 ~7 q# w) [4 R: e# O: a- q

& z9 E2 H, o! _: M3 v3 O+ \// If homing is enabled, homing init lock sets Grbl into an alarm state upon power up. This forces
+ ~0 Z8 T0 s- I  f/ W3 v// the user to perform the homing cycle (or override the locks) before doing anything else. This is
; D( a: O5 v6 H: Q3 ^: h) e$ ]' _// mainly a safety feature to remind the user to home, since position is unknown to Grbl.
; R; {6 W3 j5 e" U+ H+ q" `8 D
//如果启用了回原点,导航初始化锁集Grbl进入警报状态启动。这就迫使7 e, j* q# ^9 @3 ~, H- R3 C5 N6 k
//用户执行归航周期(或覆盖锁)在做任何其他事情之前。这是: a4 z0 z; h$ P6 X; n
//主要安全功能,提醒用户家里,因为Grbl位置是未知的。% W$ y# y& d5 G# q& A

  a& |2 Y% p' N5 Q1 B#define HOMING_INIT_LOCK // Comment to disable
0 m( C2 ^3 |, H# _
2 V- a% d/ F6 _: W+ J- ^3 m// Define the homing cycle patterns with bitmasks. The homing cycle first performs a search mode3 D; i/ w. j5 F: Q$ I
// to quickly engage the limit switches, followed by a slower locate mode, and finished by a short
8 ]! V6 Y# h. ?+ m7 E// pull-off motion to disengage the limit switches. The following HOMING_CYCLE_x defines are executed   |9 J& P7 v8 `! r! i+ v
// in order starting with suffix 0 and completes the homing routine for the specified-axes only. If, J$ @0 J4 x$ k+ F; l$ r
// an axis is omitted from the defines, it will not home, nor will the system update its position.
: Y% b# m0 s6 y7 O' Q// Meaning that this allows for users with non-standard cartesian machines, such as a lathe (x then z,  w, x0 f& J% |! N
// with no y), to configure the homing cycle behavior to their needs. 4 Q2 c( W! }# k1 M
// NOTE: The homing cycle is designed to allow sharing of limit pins, if the axes are not in the same
2 h2 O0 p, h: |4 m+ K// cycle, but this requires some pin settings changes in cpu_map.h file. For example, the default homing3 ]0 J: U4 Z# S4 }: `" e7 b
// cycle can share the Z limit pin with either X or Y limit pins, since they are on different cycles.
/ n& S" K  M! P+ Z// By sharing a pin, this frees up a precious IO pin for other purposes. In theory, all axes limit pins
4 ]/ u7 n/ a% [+ m// may be reduced to one pin, if all axes are homed with seperate cycles, or vice versa, all three axes
: h* X+ T6 L9 i4 W- s% b/ {; m// on separate pin, but homed in one cycle. Also, it should be noted that the function of hard limits
& x0 g, M7 _1 w( d// will not be affected by pin sharing.4 u$ H0 ]5 q. a. f: S$ s
//定义导航循环模式的位掩码。归航周期首先执行一个搜索模式
; W, x' ^) P; `/ Q# ?7 q3 I//快速进行限位开关,其次是较慢的定位模式,完成了由一个短
  F, F# [5 q$ n6 o" M) O- G//拖出运动脱离限位开关。以下HOMING_CYCLE_x定义执行
- v- c4 C4 M' L) |//为了与后缀0开始并完成specified-axes只寻的例程。如果/ t. f/ R6 W8 w0 O& V
//定义省略一个轴,它会不在家,也不会系统更新它的位置。
0 d! P9 D3 |5 m: j' }//意义,这允许用户与非标准笛卡尔的机器,比如车床(x,z,
( C! n9 `; ^! c" h//没有y),配置导航循环行为对他们的需求。9 N% G0 h$ N& f+ b+ S7 g( D6 F# G
//注意:归航周期允许共享限制针,如果轴不相同
; Q. b* {- s5 i( [5 t//循环,但这需要一些销设置cpu_map的变化。h文件。例如,默认的导航8 L$ A% L( n& ], s. N% @# K4 [8 C! N$ s! \/ \
//循环可以分享Z限位销X或Y限制针,因为它们是在不同的周期。
. N. r, Q0 J% p2 Q2 A* L//通过共享一个销,这腾出宝贵的IO销用于其他目的。从理论上讲,所有轴限制别针
- b, q" H. I, c//可能会减少到一个销,如果所有轴与分离周期居住的地方,反之亦然,所有三个轴1 t) q# e, I. U( u. w7 Q$ P% I
//在不同销,但这时候一个周期。同时,应该注意的是,硬限制的功能
  k2 K  K9 u$ V4 L9 t//将不会影响销共享。+ F* _( {2 [4 n+ \- s* |$ d
//注意:默认设置为一个传统的硬件数控机器。z轴首次明确,其次是X和Y。
& k+ K. Q- [* T  K  K& l0 _/ U6 e- E! o" F4 q- N' l
// NOTE: Defaults are set for a traditional 3-axis CNC machine. Z-axis first to clear, followed by X & Y.
. E% j) ]) m, \* ^6 T8 U#define HOMING_CYCLE_0 (1<<Z_AXIS)                // REQUIRED: First move Z to clear workspace. 第一步Z清除工作区。
! p& f$ G% v/ }6 j1 m- ~9 o#define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // OPTIONAL: Then move X,Y at the same time.然后X,Y在同一时间。$ ^" H+ m( m/ J7 |- Q% a
// #define HOMING_CYCLE_2                         // OPTIONAL: Uncomment and add axes mask to enable2 ^, x! Y, C5 V2 Q+ \2 t( ?# W

; Q+ @8 _; p" p. q8 d" T% f// Number of homing cycles performed after when the machine initially jogs to limit switches.
' H( y" [) A( d6 Y  W# Y5 o0 v// This help in preventing overshoot and should improve repeatability. This value should be one or 0 c# q  h: `3 [0 W1 D
// greater.
' n2 u- h, q/ S: w3 E//执行回原点循环次数后,当机器最初慢跑限位开关。这个帮助防止过度,应该提高重复性。这个值应该是一个或大。# W  b! u$ a! Q5 `9 C) H& d& B1 o

5 y. f- h4 v% k* {/ ^#define N_HOMING_LOCATE_CYCLE 1 // Integer (1-128)
3 C3 O: j2 C5 l. h# x0 y) m& s- N
# r. X% H0 U" o1 g+ I- w/ C// After homing, Grbl will set by default the entire machine space into negative space, as is typical
. N; a% j5 e! N% u* @/ l0 [// for professional CNC machines, regardless of where the limit switches are located. Uncomment this
  D0 t. P0 A) }& @// define to force Grbl to always set the machine origin at the homed location despite switch orientation.  \, K/ m4 z/ f
8 x, m' E+ A: L* ]
//导航后,默认Grbl将整个机器空间留白,是典型的专业数控机器,不管限位开关所在的地方。
; J: [$ f$ v- R8 d$ G//取消这定义迫使Grbl总是在这时候位置设置机器原点尽管开关方向。
( @5 P/ x+ i# X$ R3 C+ z3 ]% o8 x6 f( K; [1 t; Z. ]
// #define HOMING_FORCE_SET_ORIGIN // Uncomment to enable.$ D7 ?5 l1 m, w* j+ r3 C

  c  G6 `5 F" V6 r2 \4 a" B% F3 \  d5 l; ]8 w
// Number of blocks Grbl executes upon startup. These blocks are stored in EEPROM, where the size
2 C3 N2 T9 R% S) g1 @( A6 [. Y2 s// and addresses are defined in settings.h. With the current settings, up to 2 startup blocks may
6 P* y4 n  ~: ~// be stored and executed in order. These startup blocks would typically be used to set the g-code+ l5 k& |0 O$ Q1 j6 }# {
// parser state depending on user preferences.
) m: Q6 ^+ f2 X2 @2 t) V# K* @* O  ^0 k; W0 V3 ^7 ^, U
//块Grbl启动时执行的数量。这些块存储在eepm,大小
* D. W: F" N$ W' \: t. D$ J//和地址在settings.h中定义。与当前设置,可能2启动块
  e4 a7 U: m4 A/ h$ v( c8 i; f. ]//存储和执行。这些启动块通常被用来设置刀位点
0 W! ~. ~9 G0 ]4 _$ M' F8 V//解析器的状态取决于用户首选项。
- f  }. ~# z+ F" Y# {* G. u
7 ^- l7 I+ A2 d  k' H: B1 W#define N_STARTUP_LINE 2 // Integer (1-2)
( M/ M( t- `! t( {) V% ^- a  H: c& N. N  L4 O0 _3 G3 H
// Number of floating decimal points printed by Grbl for certain value types. These settings are
# L; D* }+ H0 g- B: `6 F7 j// determined by realistic and commonly observed values in CNC machines. For example, position
8 ~( w: e, Q1 ~% K" \// values cannot be less than 0.001mm or 0.0001in, because machines can not be physically more0 i: s8 ^% I1 V; w
// precise this. So, there is likely no need to change these, but you can if you need to here.0 O1 N) n; g( d) S1 s
// NOTE: Must be an integer value from 0 to ~4. More than 4 may exhibit round-off errors.
/ y' E/ G( i+ _9 M$ T' h) I
. i& [& n& D0 c; l# }. ]9 v8 S// Grbl浮动小数点的数字印刷的特定的值类型。这些设置是( Z$ W8 L- g8 P
//一般由现实和观测值在数控机器。例如,位置3 k3 N6 i) Y% Y' e$ D
//值不能小于0.001毫米或0.0001,因为机器不能身体更多
. x. g( c- E' x- H3 {//精确。因此,有可能不需要改变这些,但你可以在这里如果你需要。
' l8 H! |4 D6 T" C7 j0 c( ?. D//注意:必须是一个整数值从0 ~ 4。超过4可能出现舍入错误。
8 e2 l8 D$ o6 e* }
) Q6 g8 u; g4 k3 B#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 协调或位置价值英寸
4 m+ C8 j1 F$ O$ b0 W: I#define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 协调在毫米或位置价值
5 l' P) J. U- T% S, b' c' c#define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分钟的速度值$ x( `4 m% b/ |
#define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分钟  M3 G" Q1 ?1 q
#define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 对浮点小数设置值
1 O7 K# a* r8 H. J( d
9 n  {" D) c' l' S" w// If your machine has two limits switches wired in parallel to one axis, you will need to enable) ]* {; P. {/ j, _/ ]6 x2 f2 A
// this feature. Since the two switches are sharing a single pin, there is no way for Grbl to tell
0 i$ `9 `' }2 Z4 W" s/ Y// which one is enabled. This option only effects homing, where if a limit is engaged, Grbl will * N' b8 N8 W. i" W
// alarm out and force the user to manually disengage the limit switch. Otherwise, if you have one5 ?/ o) A& j5 T4 q' K
// limit switch for each axis, don't enable this option. By keeping it disabled, you can perform a& y( Y' p) e+ y7 i
// homing cycle while on the limit switch and not have to move the machine off of it.
& j7 d+ F) N6 ~* S  t/ D
8 E6 e/ P1 p0 t- W8 K4 K//如果你的机器有两个极限开关连接在平行于一个轴,您需要启用  x8 I+ Q2 A" _
//这个特性。自从两个交换机共享一个销,没有办法Grbl告诉) s, \/ a1 K" ?$ X% L+ G) o1 R
//启用哪一个。此选项仅影响归航,如果限制,Grbl意志
6 \! S# _( U4 h/ j1 Y//报警,迫使用户手动松开限位开关。否则,如果你有一个3 }$ s, h& W" D  D
//为每个轴限位开关,不启用该选项。通过保持禁用,您可以执行
6 D& ~$ Y5 v6 T: _9 q( P; o- N! Z//导航循环在限位开关并没有将这台机器。
! r( l7 Q/ T7 E  t1 D: m, E2 \- S) E, T8 v2 n
// #define LIMITS_TWO_SWITCHES_ON_AXES
8 d6 W+ q, [+ f% {; g$ |7 W8 ^8 v& o% z( ]; D: j* r
// Allows GRBL to track and report gcode line numbers.  Enabling this means that the planning buffer
# S. ?: S$ c- ?* b0 q// goes from 18 or 16 to make room for the additional line number data in the plan_block_t struct- U* e+ P7 M7 Z$ |" u8 L

" P/ m9 k% f. m- g, s) x//允许GRBL跟踪和报告gcode行号。使这意味着计划缓冲从18岁或16岁,为额外的行号plan_block_t结构中的数据& O. U0 X4 A. s9 H. Z% J

+ j2 ]6 O- Z, w7 b// #define USE_LINE_NUMBERS // Disabled by default. Uncomment to enable., v7 u  g- Z4 H- @$ v( g5 T$ ?

2 E5 |  ~- R8 _/ |7 d( |! V9 G" j* x// Allows GRBL to report the real-time feed rate.  Enabling this means that GRBL will be reporting more 6 p; y* q% }  U0 H& c& W2 {% C3 p6 m, g
// data with each status update.
* `/ F5 C5 M/ e: Y2 }+ d// NOTE: This is experimental and doesn't quite work 100%. Maybe fixed or refactored later.
, Q% g- v0 |! l1 P/ m. Q. s//允许GRBL报告实时进给速率。使这意味着GRBL将报告数据和状态更新。
% m# _, K7 T1 q. l$ t! }# T- l' D5 f//注意:这是实验和100%没有工作。也许以后固定或重构。
/ ]; N4 ~1 q1 L# p* G9 s
8 S3 g: g2 @/ o2 e0 a" ^( ]// #define REPORT_REALTIME_RATE // Disabled by default. Uncomment to enable.
. y) H# n( L& `7 K, z! h! @7 o; {7 \- w. M; O/ I& o' g
// Upon a successful probe cycle, this option provides immediately feedback of the probe coordinates  M- ?+ ~  c+ `% B; @9 ^& a) }
// through an automatically generated message. If disabled, users can still access the last probe
5 \2 o# y- C: }% ]// coordinates through Grbl '$#' print parameters.5 L6 }2 A3 {9 ]2 W
//在一个成功的调查周期,这个选项提供立即反馈的探测器坐标0 `1 o0 u) \. w: ~- m2 L
//通过一个自动生成的消息。如果禁用,用户仍然能够访问调查# ^( w$ T: B+ W
//坐标通过Grbl $ #的打印参数。
4 c- z* b; T' _0 ]! @  Z: Z3 I3 Q# }; u
#define MESSAGE_PROBE_COORDINATES // Enabled by default. Comment to disable.! C& K7 t0 \2 [; X7 D
( D/ O' z+ T2 W1 t( w5 @( l
// Enables a second coolant control pin via the mist coolant g-code command M7 on the Arduino Uno
* m/ x* `7 `) n8 B, k4 T. ^// analog pin 5. Only use this option if you require a second coolant control pin.
) e4 K& e  x1 p, H% [// NOTE: The M8 flood coolant control pin on analog pin 4 will still be functional regardless.3 f2 O$ r4 }6 G( x( h! X
// #define ENABLE_M7 // Disabled by default. Uncomment to enable.; p; I' Z. D4 H6 q( O# \+ V& O' i2 v
" v/ o: K$ W- J5 K! z
// This option causes the feed hold input to act as a safety door switch. A safety door, when triggered,
8 k: R' f7 E. `// immediately forces a feed hold and then safely de-energizes the machine. Resuming is blocked until) {) E% a. w; ]8 b
// the safety door is re-engaged. When it is, Grbl will re-energize the machine and then resume on the
5 y  v2 b6 i1 V) @; M7 F1 [// previous tool path, as if nothing happened.
3 J( U6 P/ _9 D" |7 G: s5 g// #define ENABLE_SAFETY_DOOR_INPUT_PIN // Default disabled. Uncomment to enable.7 a, Z( L' T: D8 }' b3 y
( q" O  S7 t% {; Q
// After the safety door switch has been toggled and restored, this setting sets the power-up delay
5 e3 j! T! j, C7 T' y! G// between restoring the spindle and coolant and resuming the cycle.  K# G0 k8 [$ Q
// NOTE: Delay value is defined in milliseconds from zero to 65,535.
6 a4 H+ z/ u: s4 C8 c3 i) l7 ^: P) R
//定义导航循环模式的位掩码。归航周期首先执行一个搜索模式  Z- P: h7 w/ Y- ]/ `
//快速进行限位开关,其次是较慢的定位模式,完成了由一个短
& R! `! O- u( b. ?//拖出运动脱离限位开关。以下HOMING_CYCLE_x定义执行8 s  U2 I% V% K# ~2 [6 v! C
//为了与后缀0开始并完成specified-axes只寻的例程。如果# j+ m1 I5 v8 T( C6 B1 b9 Z
//定义省略一个轴,它会不在家,也不会系统更新它的位置。
+ w# @3 |, T% V5 X//意义,这允许用户与非标准笛卡尔的机器,比如车床(x,z,
" M9 O: z0 U( u" E8 a& R( i//没有y),配置导航循环行为对他们的需求。* r& L* j/ Z" _& v7 f" A' t) g2 i
//注意:归航周期允许共享限制针,如果轴不相同! M# i' R" l4 P- d3 Y( e
//循环,但这需要一些销设置cpu_map的变化。h文件。例如,默认的导航
2 H0 p" G: {6 M1 p//循环可以分享Z限位销X或Y限制针,因为它们是在不同的周期。0 _3 K( _0 h/ g
//通过共享一个销,这腾出宝贵的IO销用于其他目的。从理论上讲,所有轴限制别针* D  N' P6 Z6 t2 W, s  P; W
//可能会减少到一个销,如果所有轴与分离周期居住的地方,反之亦然,所有三个轴
* O7 j; x4 ?! ~! b" l+ x//在不同销,但这时候一个周期。同时,应该注意的是,硬限制的功能
/ A& e- B( ]/ K/ d2 O: P- @0 V//将不会影响销共享。3 r$ W7 v( @4 Q# e& x
//注意:默认设置为一个传统的硬件数控机器。z轴首次明确,其次是X和Y。# |+ U2 ?* U0 }

9 r/ I( X% W0 a' l$ x0 o
- u3 p5 L5 Y0 Y( x  E#define SAFETY_DOOR_SPINDLE_DELAY 4000
: d' t* o* r! {( S#define SAFETY_DOOR_COOLANT_DELAY 10002 `" \3 `' q$ ~. R- U2 \" `' D
, p" h( T4 [# W) s6 [; p
// Enable CoreXY kinematics. Use ONLY with CoreXY machines.
6 X+ a9 w: f4 ~5 L: C4 m* _! E" u// IMPORTANT: If homing is enabled, you must reconfigure the homing cycle #defines above to   |3 J, B5 s! ]" D
//启用CoreXY运动学。只使用与CoreXY机器。
! R) G1 i5 V- y2 Y$ w, P$ V5 L//重要:如果启用了自动寻的,你必须重新配置导航循环#定义上面
3 w5 f+ E, z# ]( c: D9 ]1 U9 ^" \! S
// #define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS)
- F$ `- q6 E, P" H! X! m5 s; c2 V; `
// NOTE: This configuration option alters the motion of the X and Y axes to principle of operation
/ \' N( A5 h8 ?8 h! g. X1 O// defined at (http://corexy.com/theory.html). Motors are assumed to positioned and wired exactly as
1 a# i  z% _( T& ~% y, n// described, if not, motions may move in strange directions. Grbl assumes the CoreXY A and B motors4 x$ X7 d+ G' r
// have the same steps per mm internally.
6 M( B2 q/ _' f" j- {! o% `$ Q9 n% [//注意:这种配置选项改变X和Y轴的运动原理,操作( z" c9 l8 a3 k* c( O
//定义(http://corexy.com/theory.html)。汽车被认为定位和连接一样: b8 L' d8 U% S$ ?1 ?7 i9 p+ u! F+ x
//描述,如果没有,运动可能会奇怪的方向移动。A和B Grbl假设CoreXY马达% o2 s9 Y8 J0 C2 ?: ~; k! t
//每毫米内部有相同的步骤。/ o2 Y2 y  A* S( E3 [

8 I1 q% P& _/ W// #define COREXY // Default disabled. Uncomment to enable.2 `: x5 S# W9 @0 B; [; Q9 p

: g- W% K( o: x5 f2 [& I// Inverts pin logic of the control command pins. This essentially means when this option is enabled: @. a$ E  [% y6 {; {0 u" J, K/ ?
// you can use normally-closed switches, rather than the default normally-open switches.- V3 Q  K8 V% M1 w7 v
// NOTE: Will eventually be added to Grbl settings in v1.0.
2 D& U$ T( T  l, t* @! ^//反转针销逻辑的控制命令。这实质上意味着当启用这个选项
! r) v" J" X2 \3 f1 z6 r% W//可以使用闭合开关,而不是默认的常开开关。
- t5 ?. \- Z/ R1 E* n//注意:最终将被添加到在v1.0 Grbl设置。
+ D* G5 P- [& _& @% E0 P1 }- c+ q4 b
( n8 r: e/ c  F5 o// #define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.6 b0 Q  g; U! G9 [

  l. \- M+ m) c+ b. s2 h- H7 v% {// Inverts the spindle enable pin from low-disabled/high-enabled to low-enabled/high-disabled. Useful6 H7 ]0 z' I3 I6 E2 f( ^0 M$ S
// for some pre-built electronic boards.
! e5 T7 ?+ X6 z& }8 r. X// NOTE: If VARIABLE_SPINDLE is enabled(default), this option has no effect as the PWM output and
. F1 G2 `6 n, H, c! {// spindle enable are combined to one pin. If you need both this option and spindle speed PWM,
7 R( ]" m* D  V// uncomment the config option USE_SPINDLE_DIR_AS_ENABLE_PIN below.6 z! d' N: c9 t3 M2 n
//反转主轴使销从low-disabled / high-enabled low-enabled / high-disabled。有用的
1 F7 }" _( V' M9 s/ u//预构建的电子板。
4 B! J  V4 Y! ~# a//注意:如果启用了VARIABLE_SPINDLE(默认),这个选项作为PWM输出并没有影响
9 `$ S. \, U6 R, H" G- ~//销轴使结合。如果你需要这个选项和主轴转速PWM,+ S1 T9 E. K& j( @. \
//取消注释以下配置选项USE_SPINDLE_DIR_AS_ENABLE_PIN
' o. E1 H3 l/ y/ l! l( s# X! @0 F" r# T& a2 @/ B
// #define INVERT_SPINDLE_ENABLE_PIN // Default disabled. Uncomment to enable.
9 }5 M5 [* v4 j/ l+ z2 G0 D, F: K; y; g  i; i0 S
// Enable control pin states feedback in status reports. The data is presented as simple binary of
8 T6 ^+ g: e" D2 E" C// the control pin port (0 (low) or 1(high)), masked to show only the input pins. Non-control pins on the 6 @# R" ?( i4 @' y) u
// port will always show a 0 value. See cpu_map.h for the pin bitmap. As with the limit pin reporting,5 N6 J( Q; s5 S5 F" g9 T
// we do not recommend keeping this option enabled. Try to only use this for setting up a new CNC.
" v" t# ^4 y5 x1 l/ ~//启用控制销状态反馈状态报告。作为简单的二进制数据
  t$ k6 h% K0 D) A' k# }- K//控制针端口(0(低)或1(高)),蒙面,只显示输入插脚。非控制性针上
. o. M$ q. N% E) {//端口总是显示0值。看到cpu_map。针位图h。与限制销报告,% ~' R3 X) K! B7 [1 ]+ U( _
//我们不推荐保持启用这个选项。尽量只使用这个设置一个新的数控。
0 N+ X' s7 V8 }6 Z2 e4 y1 F
, U- v. q; r- d$ g+ N) N0 e// #define REPORT_CONTROL_PIN_STATE // Default disabled. Uncomment to enable.- a; U% F+ g; ]; T6 z8 k, K3 ~
+ J% u1 ]- }9 P6 `+ s
// When Grbl powers-cycles or is hard reset with the Arduino reset button, Grbl boots up with no ALARM, L6 Q( C1 F/ P1 h* J$ e! t. g
// by default. This is to make it as simple as possible for new users to start using Grbl. When homing
# ?- S% S" B! _3 j% \# A// is enabled and a user has installed limit switches, Grbl will boot up in an ALARM state to indicate
& s$ e) L3 O8 L// Grbl doesn't know its position and to force the user to home before proceeding. This option forces4 e. D# R/ S) w4 V5 L
// Grbl to always initialize into an ALARM state regardless of homing or not. This option is more for
% D5 X% p8 g7 H  ~// OEMs and LinuxCNC users that would like this power-cycle behavior./ u% Q3 d/ C' P8 L& o
//当Grbl powers-cycles还是硬重置Arduino复位按钮,Grbl启动没有报警2 I& c( C6 `, h  u
//默认情况下。这是为了让新用户尽可能简单使用Grbl开始。当归航
) t6 N2 C2 }) i) N2 H//启用和用户安装限位开关,Grbl将启动报警状态指示% z2 Z5 m% v5 ]2 `, k
// Grbl不知道它的位置,迫使用户在继续之前回家。这个选项部队8 [4 j" i$ T  d# K2 }$ ?6 J
// Grbl总是初始化进入警报状态不管归航。这个选项是更多
* H* A# w0 [! T$ D4 U  }% j//原始设备制造商和LinuxCNC用户这样的控制行为。
/ C+ H+ w4 X! H) S! p% F6 O0 g* m  o
// #define FORCE_INITIALIZATION_ALARM // Default disabled. Uncomment to enable.
* f+ n8 h3 }, v+ E) r0 N6 c: T/ `/ C- r$ l4 X$ D* K/ T9 A
// ---------------------------------------------------------------------------------------; K0 F8 {4 d) D: h; X
// ADVANCED CONFIGURATION OPTIONS://高级配置选项:
! p, k9 v- S5 |$ _/ Y0 g; d: W$ u# k  }, j- E. A9 a
// Enables minimal reporting feedback mode for GUIs, where human-readable strings are not as important.
! ~5 {" Y/ a0 m// This saves nearly 2KB of flash space and may allow enough space to install other/future features.
0 k: |3 x( ]! t% Y. J+ g  X( z// GUIs will need to install a look-up table for the error-codes that Grbl sends back in their place.
& m. ~- B5 k% |* x0 S' W// NOTE: This feature is new and experimental. Make sure the GUI you are using supports this mode.
3 |1 ~& r6 t. |. v0 {/ _3 A; C
* D2 d6 X$ z9 A* q# a// gui允许最小的报告反馈模式,人类可读的字符串在哪里不重要。
' ~0 E0 f8 i/ A- D0 {/ A3 b//这个节省近2 kb的闪存空间,允许足够的空间来安装其他/未来的功能。
, n4 C* K0 o6 W: h% V8 t1 `// gui需要安装一个查找表的错误代码Grbl发回。( I& Z8 a) w. R( Q
//注意:此功能是新的和实验。确保您使用的GUI支持这种模式。" q2 x/ o, n0 l5 A3 A+ p- d9 e7 `+ {9 |

# U' V& c: O- N- d3 C. x3 t6 V// #define REPORT_GUI_MODE // Default disabled. Uncomment to enable.$ |1 @4 \$ N0 V

! {) O, n+ ], i6 ]& J7 R// The temporal resolution of the acceleration management subsystem. A higher number gives smoother
; {. g5 Y! o, d3 ^" T4 X// acceleration, particularly noticeable on machines that run at very high feedrates, but may negatively
1 ~0 E2 g% \8 J$ x// impact performance. The correct value for this parameter is machine dependent, so it's advised to0 a! m6 D3 H# N
// set this only as high as needed. Approximate successful values can widely range from 50 to 200 or more.
+ e- C; T' l- Z  U+ Y8 i// NOTE: Changing this value also changes the execution time of a segment in the step segment buffer. ) F, e5 T- C2 }7 E+ v
// When increasing this value, this stores less overall time in the segment buffer and vice versa. Make  A0 A# F; L+ _4 V& A6 r; k
// certain the step segment buffer is increased/decreased to account for these changes.
1 ]4 A) W6 {+ z! S7 q* G//加速度的时间分辨率管理子系统。更多更平稳
# C8 G* Y. l% ]- r" L//加速度,特别明显的机器上,运行在非常高的进料速度,但可能负面5 C+ \+ b. u, ]) W9 M5 b
//影响性能。正确的值为这个参数是依赖于机器的,所以建议" t8 r0 `8 R/ v1 }0 _% g1 T8 ~: B6 d
//这只设置为高。近似成功的价值观可以广泛的范围从50到200或者更多。
' W- D; A2 J7 W; }7 ~//注意:改变这个值也变化的部分步骤的执行时间缓冲。  |. f* J2 \# |5 k$ u
//增加这个值时,这个商店部分缓冲区的总时间减少,反之亦然。使# y; u$ f/ Q* `
//特定步骤段缓冲是考虑这些变化增加/减少。. d+ C4 a: [) y, t1 q

8 j5 u% N0 N/ {, @' e#define ACCELERATION_TICKS_PER_SECOND 100  //加速度的时间分辨率管理子系统。更多更平稳
" x! S" }, g3 J# z0 t" D
" x5 `9 B6 U$ k' c; W6 @// Adaptive Multi-Axis Step Smoothing (AMASS) is an advanced feature that does what its name implies, % P3 A* x! Z# S$ k) i3 s( {* b/ Y
// smoothing the stepping of multi-axis motions. This feature smooths motion particularly at low step
7 \' I7 {1 G! h% [; j; W. y, J" V// frequencies below 10kHz, where the aliasing between axes of multi-axis motions can cause audible   d9 E" [( Z  v4 h
// noise and shake your machine. At even lower step frequencies, AMASS adapts and provides even better
+ R, N! Z+ f; V/ y7 m, `) B// step smoothing. See stepper.c for more details on the AMASS system works.2 E0 u. l7 a) g
//自适应多轴步平滑(积累)是一种先进的功能,它的名字所暗示的那样,: K  x; `5 K% D2 i1 P
//平滑的多轴步进运动。这个特性平滑运动尤其是在低一步4 N7 Y! j6 U2 e" h+ v
//频率低于10 khz,轴之间的混叠的多轴运动可能导致音响; P( D8 E8 Z/ G+ m& ^4 A# @
//噪音和震动你的机器。在更低的频率步,积累适应并提供更好$ G9 R: l1 C0 P, r0 l; C0 y
//步骤平滑。看到步进。c更多细节的积累系统的工作原理。
: s$ _! }# x0 Z
; I- q" ?' N/ t6 j$ \#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING  // Default enabled. Comment to disable.//自适应多轴步平滑
1 R" O2 {8 A+ q6 Z7 [
3 B# G. B: O* o  P$ o. o! A8 l// Sets the maximum step rate allowed to be written as a Grbl setting. This option enables an error
# z) b: y" }1 G7 e// check in the settings module to prevent settings values that will exceed this limitation. The maximum
8 \! ~; {) q# U( L+ ?9 @& J( `* V// step rate is strictly limited by the CPU speed and will change if something other than an AVR running
. v5 @' J; L( \( u* z/ Q3 D3 k// at 16MHz is used.
' ^+ I& j" w$ f3 p. \* C2 c& F// NOTE: For now disabled, will enable if flash space permits.& D( C2 g% g3 q% n4 \2 K+ ~: h
//设置最大一步速率可以写成Grbl设置。这个选项可以使一个错误
& q$ w6 @; x4 l//设置模块中检查,防止设置值将超过这个限制。的最大
! X! P! {6 h% F2 o" I//步骤严格限制的CPU速度也会改变如果是其他AVR运行+ M1 ]' f, v# J/ _- t* g
//使用16兆赫。
4 f, U" P  e. l* N) X4 x//注意:现在残疾,将使如果flash空间许可。
- S* q9 k+ G- h+ Y" C# d4 n, f8 o. P" d( r, m
// #define MAX_STEP_RATE_HZ 30000 // Hz 设置最大一步速率% V7 c/ E1 Q$ W/ M  C; d1 v

. H8 f: M* Q$ J# S8 a% N+ y+ b// By default, Grbl sets all input pins to normal-high operation with their internal pull-up resistors
# ?, z/ p0 h/ K8 q// enabled. This simplifies the wiring for users by requiring only a switch connected to ground, % u0 v( k! y# p2 C5 n) Z
// although its recommended that users take the extra step of wiring in low-pass filter to reduce0 X$ C2 z/ \8 {1 e' f/ I2 Y
// electrical noise detected by the pin. If the user inverts the pin in Grbl settings, this just flips0 U. {* o+ }% }% Y; ^; ?# X7 S
// which high or low reading indicates an active signal. In normal operation, this means the user
' {" u6 A* a6 \, V" Q1 e; s- g# g// needs to connect a normal-open switch, but if inverted, this means the user should connect a
8 J- W9 e- E9 K6 z: A" M* C// normal-closed switch.
6 O2 v, d7 B1 o// The following options disable the internal pull-up resistors, sets the pins to a normal-low 5 `3 I  k, C6 o7 \/ t
// operation, and switches must be now connect to Vcc instead of ground. This also flips the meaning 9 S, d6 i- p  ^( [% p) h7 V
// of the invert pin Grbl setting, where an inverted setting now means the user should connect a
4 l, x% E& h1 J7 S// normal-open switch and vice versa.% T! p8 g" C% H: f
// NOTE: All pins associated with the feature are disabled, i.e. XYZ limit pins, not individual axes.3 q4 _% b/ N0 V$ i+ v! B* F
// WARNING: When the pull-ups are disabled, this requires additional wiring with pull-down resistors!! s' o, M8 K3 \1 P. ]6 X
//默认情况下,Grbl所有输入引脚设置为正常高操作的内部上拉电阻
$ @; l2 _: ^8 T, [//启用。这简化了布线为用户只需要一个开关连接到地面,! O* I& Q: c6 z1 _' O
//虽然其建议用户采取额外的步骤,在低通滤波器来减少布线( z9 T" V. U' w2 U8 O- ?. ^* L
//电噪音检测销。如果用户反转的销Grbl设置,这只是翻转# ]& v' Z9 h( x: U
//读高或低表明一个积极的信号。在正常操作中,这意味着用户
. I  x0 j7 X. E. ~//需要连接一个常开开关,但如果倒,这意味着用户应该连接; E, P, t' f3 A* _  G! t
// normal-closed开关。4 F, E$ p, l, ^. ~) Z
//以下选项禁用内部上拉电阻,一般低设置别针' a; N: e9 L9 t" S. \4 ?
//操作,现在开关必须连接到Vcc代替地面。这也掀的意思- l- _! f+ c' N# c( p
//反销Grbl设置,一个倒置的设置现在意味着用户应该连接3 R- u0 ^* S$ D& R( ]( W
//常开开关,反之亦然。5 B3 [0 c( t" P
//注意:所有针与功能被禁用,例如XYZ限制针,而不是单独的轴。8 P6 b+ d) V' d6 V, d$ r7 Q
//警告:引体向上被禁用时,这需要额外的布线与下拉电阻!+ A+ ]' z/ z$ t6 w& }7 {
' _: I; S. h- }. t" ^* v
//#define DISABLE_LIMIT_PIN_PULL_UP //以下选项禁用内部上拉电阻
! S) ~3 C1 A' ]! A5 N2 h0 B4 S//#define DISABLE_PROBE_PIN_PULL_UP
8 y0 ]  i0 z$ @1 D. e- a3 f5 Z//#define DISABLE_CONTROL_PIN_PULL_UP5 P5 Q& B$ b. |( e
/ T, B( y3 t0 h# u9 c
// Sets which axis the tool length offset is applied. Assumes the spindle is always parallel with & R  A# j1 `- \0 r  F
// the selected axis with the tool oriented toward the negative direction. In other words, a positive
" H* s& q2 e; p  }9 M& Q: a// tool length offset value is subtracted from the current location.- n0 A' [  ^. \6 [3 e
//设置哪个轴长度补偿应用的工具。假设轴总是与# g1 N3 {, V: j+ I# m
//选择轴工具面向负方向。换句话说,一个积极的" T  `4 {6 J9 H, R
//工具长度偏移值减去从当前位置。
2 C3 G, w$ x7 C! V& y3 |
, x# {5 p! I! U  Z  ]  u6 [( `#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS // Default z-axis. Valid values are X_AXIS, Y_AXIS, or Z_AXIS.设置哪个轴长度补偿应用的工具  P/ {5 W& A% S2 _0 d4 {

8 x6 _& i5 k& A% i// Enables variable spindle output voltage for different RPM values. On the Arduino Uno, the spindle1 I2 f$ c! A# N; K
// enable pin will output 5V for maximum RPM with 256 intermediate levels and 0V when disabled.( M# z9 D, J3 G5 e: J) [/ B
// NOTE: IMPORTANT for Arduino Unos! When enabled, the Z-limit pin D11 and spindle enable pin D12 switch!
  d. [5 a0 l  @& G, i+ S// The hardware PWM output on pin D11 is required for variable spindle output voltages.8 o" l: S. n4 Z# _' F
//允许变量轴输出电压不同的转速值。Arduino Uno,主轴
. v/ e6 Y" v$ y! O//启用销将输出5 v的最高转速256中级水平和0 v时禁用。
; n1 M6 \" E! t3 F+ y//注意:重要Arduino凯泽本人!当启用时,Z-limit销这里和轴销D12开关!/ k: P9 A/ L- v6 A( @
//硬件PWM输出销这里需要变量轴输出电压。
; e2 A% y. w* M! L2 y% y" }% x- o! h1 t' z. A8 [* T0 l; d
#define VARIABLE_SPINDLE // Default enabled. Comment to disable.//允许主轴输出电压不同的转速值
* s$ \6 q* E" N- S$ b, S4 k3 }' x& ^$ g
// Used by the variable spindle output only. These parameters set the maximum and minimum spindle speed1 o4 X: N0 W, T. n) g) k7 O4 L
// "S" g-code values to correspond to the maximum and minimum pin voltages. There are 256 discrete and 5 x7 t9 z, Y! k7 R4 \1 r
// equally divided voltage bins between the maximum and minimum spindle speeds. So for a 5V pin, 1000, c# n2 }! d6 W) q  C
// max rpm, and 250 min rpm, the spindle output voltage would be set for the following "S" commands:
0 E; l3 @* b8 I// "S1000" @ 5V, "S250" @ 0.02V, and "S625" @ 2.5V (mid-range). The pin outputs 0V when disabled.9 p# v  o0 `$ W. H$ i
//使用的变量轴输出。这些参数设置最大和最小轴转速/ \2 c- L) d% n
//“S”刀位点值对应于销电压的最大值和最小值。有256个离散和' Z* W# n* ]. @
//电压平均分配箱主轴速度的最大值和最小值之间。所以对于一个5 v销,1000
2 }( y7 \+ r2 v, w9 Q// max rpm,250分钟rpm,主轴输出电压将为以下“S”命令:& X6 b$ X( K: R5 C5 l
// @“S1000 5 v,“S250”@ 0.02 v,“S625”@ 2.5 v(中档)。销输出0 v时禁用。
" P$ a/ ]# t- D7 C+ \
: o: t/ z/ \8 s. A1 ~; A#define SPINDLE_MAX_RPM 1000.0 // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.
( H9 k6 c! J- i) `#define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.
0 @+ H" k4 ?+ Z+ m* Q/ S& W
9 j" A: e  N! z// Used by variable spindle output only. This forces the PWM output to a minimum duty cycle when enabled.7 F9 d( V5 }- F5 A* C3 u6 M9 m
// When disabled, the PWM pin will still read 0V. Most users will not need this option, but it may be
; O( A3 J6 l( \' ^, m0 ]9 S$ F, L2 q// useful in certain scenarios. This setting does not update the minimum spindle RPM calculations. Any+ l" f; ]! T- I7 M& L
// spindle RPM output lower than this value will be set to this value.8 m' b% o  k- v+ I% ]5 [) v" z) e
//使用的变量轴输出。这迫使PWM输出最小占空比时启用。
7 k( x! G0 Y2 f1 V; e; k+ q5 J0 I5 ^//当禁用,PWM销仍读0 v。大多数用户不需要这个选项,但是它可能是; S9 _# J# L0 v- o: \* y% A( t/ Q0 X
//在某些情况下很有用。这个设置不会更新最小主轴转速计算。任何: C$ W( b" N3 l. `9 `% t7 k
//输出轴转速低于这个值将被设置为这个值。
" a& Y' y3 F9 z/ W. T- p+ A
+ U& a8 u) k) U& d- @// #define MINIMUM_SPINDLE_PWM 5 // Default disabled. Uncomment to enable. Integer (0-255)
4 r& M. b4 F  N$ {+ X( m7 t: q- V' ^% e( X+ e
// By default on a 328p(Uno), Grbl combines the variable spindle PWM and the enable into one pin to help & h  v6 I4 }, H: U+ G7 U7 o
// preserve I/O pins. For certain setups, these may need to be separate pins. This configure option uses
" \% S/ I* P% \3 g) D/ @// the spindle direction pin(D13) as a separate spindle enable pin along with spindle speed PWM on pin D11. . D* j" ]- S4 \* l1 u. e: F1 Y+ Q
// NOTE: This configure option only works with VARIABLE_SPINDLE enabled and a 328p processor (Uno). 1 {' r( ]: @/ i
// NOTE: With no direction pin, the spindle clockwise M4 g-code command will be removed. M3 and M5 still work.3 p+ ^1 h6 H. V
// NOTE: BEWARE! The Arduino bootloader toggles the D13 pin when it powers up. If you flash Grbl with7 x2 H5 [2 Q8 Z
// a programmer (you can use a spare Arduino as "Arduino as ISP". Search the web on how to wire this.), % c8 Y& e* j6 _& J0 {6 h9 Z% N
// this D13 LED toggling should go away. We haven't tested this though. Please report how it goes!7 w: e" ~' d. K8 K5 f/ @" J
//默认ATmega328 p(Uno),Grbl结合变量轴PWM和使到一个销的帮助
) P7 P, q7 l! _% K//保存I / O管脚。对于某些设置,这些可能需要单独的别针。这个配置选项使用
2 ^, R; v9 V3 O! d! p//方向轴销(D13)作为一个单独的轴销上启用销以及主轴转速PWM这里。1 X7 |  [# k9 g  z) Q( V8 k; h- t, f' l
//注意:该配置选项仅适用于VARIABLE_SPINDLE启用和328 p处理器(Uno)。: d$ Y' Q# S! o+ p8 @6 X0 z
//注意:没有方向销,主轴顺时针M4刀位点命令将被删除。M3和M5仍然工作。  y: R9 F6 v! e' n& m2 ~
//注意:小心!Arduino引导装载程序切换D13销的权力。如果flash Grbl
4 X7 U& o; O( n8 l- D& M+ Q& |6 ?//程序员(您可以使用一个备用Arduino“Arduino ISP”。搜索网络如何线),
3 \0 K& S/ ^4 O" s//这D13导致切换应该消失。我们还没有测试这个。请报告将会怎样!6 e+ y" \* V; P) I

0 ~" b) P9 e$ q  h$ h! {8 H// #define USE_SPINDLE_DIR_AS_ENABLE_PIN // Default disabled. Uncomment to enable.4 O* L' ^5 d% ^4 v: F

' Y+ W% j  l; |* b// With this enabled, Grbl sends back an echo of the line it has received, which has been pre-parsed (spaces3 ^# v2 `8 X2 R' A& I( y0 ?
// removed, capitalized letters, no comments) and is to be immediately executed by Grbl. Echoes will not be " Y5 g/ }$ R. u3 E3 M
// sent upon a line buffer overflow, but should for all normal lines sent to Grbl. For example, if a user
- Q$ N8 u4 }* B3 D5 z$ d// sendss the line 'g1 x1.032 y2.45 (test comment)', Grbl will echo back in the form '[echo: G1X1.032Y2.45]'.
& c- y3 r: z- P// NOTE: Only use this for debugging purposes!! When echoing, this takes up valuable resources and can effect
: H/ J  b: E3 `/ A& k// performance. If absolutely needed for normal operation, the serial write buffer should be greatly increased( ]2 d6 R: U8 r7 S
// to help minimize transmission waiting within the serial write protocol.4 }& ^9 A# h/ }  S: r# x" q; r
& q# Q) Q- h! V2 a& I
//启用,Grbl发回的回声线已收到,已预编译(空间
/ ]0 L1 G8 x" q5 I8 j$ p//移除,大写字母,没有评论),由Grbl立即执行。回声将不会
$ t0 p0 x( D! D' ]* F0 a5 C//发送一个线缓冲区溢位,但应该对所有正常线路送到Grbl。例如,如果一个用户2 x8 X" p3 i$ ~; e& }: h, Z1 G
//发送线的g1 x1.032 y2.45(测试评论)形式”,Grbl将回声”(回声:G1X1.032Y2.45]”。% {' \* _+ d; `9 O& G2 \
//注意:只使用这个调试! !当呼应,这占用了宝贵的资源,可以影响
% ~1 C" x" k, C! l//性能。如果正常运行所需的绝对,串行写入缓冲器应该大大增加
$ J" w1 W# t# v: W: r2 J//帮助最小化传输等系列内写协议。0 B/ t9 k; y. k- m( p, v+ s0 ~5 c
( I. ?! V; E) @7 |
// #define REPORT_ECHO_LINE_RECEIVED // Default disabled. Uncomment to enable.( b& M* c# F( p( y; q6 K! n

7 s- T' Q1 R  h/ a. Q// Minimum planner junction speed. Sets the default minimum junction speed the planner plans to at6 c, ]/ V; f; V5 J$ V8 [
// every buffer block junction, except for starting from rest and end of the buffer, which are always$ l8 y  M, Y! `0 _% p
// zero. This value controls how fast the machine moves through junctions with no regard for acceleration" p! x6 ~: I! d, {8 C3 d
// limits or angle between neighboring block line move directions. This is useful for machines that can't
! Z* h1 @1 o% x// tolerate the tool dwelling for a split second, i.e. 3d printers or laser cutters. If used, this value
9 V+ q+ e  G. B2 [" H// should not be much greater than zero or to the minimum value necessary for the machine to work.
' d& s  K2 M7 l( ^( G( l
2 p2 F* O( A6 [& `( a& `: E# e) ~' H' N//最小规划师结速度。设置默认最小连接速度规划计划
  x5 I+ a3 ~* @  _8 v4 t3 H0 T5 l//每一个缓冲块接头,除了从结束休息和缓冲区,它总是8 o/ N% a  Q: f
// 0。这个值控制机器的速度穿过路口,没有考虑加速度6 E7 z/ |! Q+ }+ R8 U1 w
//限制或相邻块之间的角线方向移动。这是有用的机器,不能/ f$ x2 o. \# N8 t/ h2 w
//容忍工具居住某一刹那,即3 d打印机或激光切割机。如果使用这个值
1 M* }' `/ U2 ]//不应大于零或机器工作所需的最小值。
, l5 d+ y9 J) @: y  ]
! ~+ l# D& ?4 A4 H$ t& }( W1 ~#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min)
7 F: U9 V( o: X" K, ^$ v2 v5 v
' P  |, E- o1 L) H// Sets the minimum feed rate the planner will allow. Any value below it will be set to this minimum
9 y0 _! E9 L7 _// value. This also ensures that a planned motion always completes and accounts for any floating-point
. V% p& _  D, C* Z8 a// round-off errors. Although not recommended, a lower value than 1.0 mm/min will likely work in smaller$ ?: r1 h4 m, v9 N
// machines, perhaps to 0.1mm/min, but your success may vary based on multiple factors.$ J( G0 e3 v1 _* r; `: d) S
//设置计划将允许的最小进给速率。任何价值低于它将被设置为最低值。这也保证了运动计划总是完成,占任何浮点
! @; k" l! [# S" m8 C8 X: f9 F8 J. R//舍入错误。虽然不推荐,价值低于1.0毫米/分钟可能会在较小的工作3 B/ i0 y( A! _; Z/ ]- `
//机器,也许到0.1毫米/分钟,但你的成功基于多种因素可能会有所不同。0 ?$ _/ W$ n7 b8 N. D
' A2 t* }. _2 v  y3 `
#define MINIMUM_FEED_RATE 1.0 // (mm/min)//设置计划将允许的最小进给速率) S7 j+ u/ A% S6 D! y2 W+ @

8 _" }+ x2 M- n) }- D- f// Number of arc generation iterations by small angle approximation before exact arc trajectory
1 [0 {- e" N' k# w! t# K( d% x// correction with expensive sin() and cos() calcualtions. This parameter maybe decreased if there 3 ~/ d1 L1 G* d2 _. G* c
// are issues with the accuracy of the arc generations, or increased if arc execution is getting
9 A0 {/ F  n! _3 p4 ~/ W// bogged down by too many trig calculations.
8 N7 v1 T+ G3 k% W' I0 c//弧生成迭代次数之前小角度近似精确的弧线轨迹! j; {$ T! m  O! H, I9 o
//修正与昂贵的sin()和cos()calcualtions。如果有这个参数可能减少9 B, {, n# a9 ~1 l' }" f/ [
//与弧一代又一代的准确性问题,或如果电弧执行得到增加
. N3 Z) _, F* o. B: J8 U* E//太多的三角计算的泥潭。5 h! m7 _' r5 D. i9 n. b2 w
: ?3 |! X& A+ |9 ?7 ?
#define N_ARC_CORRECTION 12 // Integer (1-255)
8 u; H- j% u* }4 {4 L+ o
. _6 S2 }  P# Q2 y// The arc G2/3 g-code standard is problematic by definition. Radius-based arcs have horrible numerical % n5 z( P( ]; q+ n& f
// errors when arc at semi-circles(pi) or full-circles(2*pi). Offset-based arcs are much more accurate   w$ p2 M8 K1 [9 N# k
// but still have a problem when arcs are full-circles (2*pi). This define accounts for the floating ' g, g: |) u  A% X0 t% Q
// point issues when offset-based arcs are commanded as full circles, but get interpreted as extremely
9 _& V: q# Y1 O# G// small arcs with around machine epsilon (1.2e-7rad) due to numerical round-off and precision issues.
. Z& f/ `' v0 e// This define value sets the machine epsilon cutoff to determine if the arc is a full-circle or not.1 Z8 i' m7 A4 {
// NOTE: Be very careful when adjusting this value. It should always be greater than 1.2e-7 but not too
4 C( I/ s( ]% d+ V9 V: n// much greater than this. The default setting should capture most, if not all, full arc error situations.
, T; t$ C# k  H5 c//弧G2/3刀位点的标准定义是有问题的。Radius-based弧有可怕的数值
* f2 {% E1 H% g5 K- [9 S//错误当电弧在半圆(π)或原点(2 *π)。Offset-based弧更准确
1 m0 U; q; H- F; h8 u//但仍有一个问题当弧原点(2 *π)。这个定义占浮动
  @* ?: X# W  q9 [0 s//当offset-based弧吩咐点问题完整的圆,但解释为极% A, D6 e- F5 N2 t2 \6 E  ^+ w1 ]
//小弧机周围ε(1.2 e-7rad)由于数字舍入和精度问题。
; P8 y! c& t7 M4 X1 [5 K6 v" D1 b# C( l//定义值设置机器ε截止来确定电弧是一个原点了。
1 V% T. t, k& W& N//注意:调整这个值时非常小心。它应该总是大于1.2 e -但不要太
% R: ~( \8 Y6 _9 ^* Q//比这大得多。默认设置应该捕获大部分,如果不是全部,全部错误的情况。
( X: V4 C$ K' m, O* l' b: x
( b" f1 _. d: c. }3 K; g! x& h#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)1 s) n# a  a- R3 G! O( A8 f
1 [5 a, [' d, }% r
// Time delay increments performed during a dwell. The default value is set at 50ms, which provides( j9 o! B; \. e- B
// a maximum time delay of roughly 55 minutes, more than enough for most any application. Increasing
3 v. t" ~4 K/ V# M" G// this delay will increase the maximum dwell time linearly, but also reduces the responsiveness of   k9 I! K, q# Y  K7 G2 T) D1 {  \
// run-time command executions, like status reports, since these are performed between each dwell & S# `0 P4 r/ A7 Z7 C7 \
// time step. Also, keep in mind that the Arduino delay timer is not very accurate for long delays./ t$ M' c' ~" B5 x$ ?' j
//延时增加表现在住。默认值设置为50毫秒,它提供了
/ B' w0 F" ]+ {$ V- k//最大延时约55分钟,足够对大多数任何应用程序。增加
' s- P: x% G# y" o. B. U//这种延迟将增加线性最大停留时间,也减少了响应能力
- ?  f2 \% F- e  `1 e  _//运行命令执行状态报告一样,因为这些每个住之间执行
5 Y4 v/ D- R# b) L! a9 [! [. n& z//时间步。还有,记住,Arduino延迟计时器不是很准确的长时间延误。
: [" |+ x/ r7 c$ p# h, ~5 }) v- ~& V/ _9 ~0 Q" ~4 e
#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds)
' i. V5 }0 v( W+ N; d1 Z8 F7 r% P. w+ ^$ Q# h' v/ d& M. `
// Creates a delay between the direction pin setting and corresponding step pulse by creating
# \+ O1 q4 m; T, l  x// another interrupt (Timer2 compare) to manage it. The main Grbl interrupt (Timer1 compare)
7 n) y( e! `" C+ @2 d// sets the direction pins, and does not immediately set the stepper pins, as it would in
3 U: q6 r5 k6 B" K+ D- P: D// normal operation. The Timer2 compare fires next to set the stepper pins after the step
( B& E8 ^* d# m( O* |4 ^" `// pulse delay time, and Timer2 overflow will complete the step pulse, except now delayed
& o3 @- D& q/ |1 c2 g3 m// by the step pulse time plus the step pulse delay. (Thanks langwadt for the idea!)
9 ?/ t% R. M( c// NOTE: Uncomment to enable. The recommended delay must be > 3us, and, when added with the
/ {1 o1 J" P  s- ?5 b// user-supplied step pulse time, the total time must not exceed 127us. Reported successful
+ l' x& t- o, N// values for certain setups have ranged from 5 to 20us.7 y; @& m" j% \( y0 q
//创建一个方向销之间的延迟脉冲通过创建设置和相应的步骤
9 w+ |- }$ }6 s# h" ]  p//另一个中断(Timer2比较)来管理它。主要Grbl中断(Timer1比较)
8 e9 n( n$ B5 I7 }+ |8 j& y9 ?//设置方向针,不立即设置步进针,因为它会在
1 l  k* H, F  F  Q4 E7 \6 k//正常操作。Timer2比较火旁边设置步进针后一步
6 \6 C  z: w7 Z) `8 q) f//脉冲延迟时间,Timer2溢出脉冲将完成的步骤,现在延迟除外6 m- b; [. I* U9 ?$ `+ X- s4 n
//脉冲时间加上的一步一步脉冲延迟。(感谢langwadt主意!)
" M  b- }  c) l  x! H" }//注意:取消启用。必须> 3,建议延迟,当添加的
0 t# Y. {. s; C; Y. c//用户提供的步骤脉冲时间,总时间不得超过127美元。成功的报道8 s% C6 y! B. h. H; y7 s0 K5 x! r
//值对某些设置范围从5到20。
4 ^5 T2 {2 \- L+ S$ ?, n! `( @" Y2 K) N
// #define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.
3 C- ?3 _/ A6 t' t, v# i8 k
7 V/ E& i/ h1 K% D8 t* L: e// The number of linear motions in the planner buffer to be planned at any give time. The vast0 y- D# c1 Y6 V/ F. O: k8 ?6 e
// majority of RAM that Grbl uses is based on this buffer size. Only increase if there is extra
4 D, N) X  V( l0 c1 B// available RAM, like when re-compiling for a Mega or Sanguino. Or decrease if the Arduino: \3 U( p9 ?# X% u9 m" e
// begins to crash due to the lack of available RAM or if the CPU is having trouble keeping0 [- m, D: R3 T+ Z6 ?6 x3 @
// up with planning new incoming motions as they are executed.
- ?$ O& H1 l' u//线性运动规划师缓冲区的数量在任何给出时间计划。绝大
) I9 B5 i; O) y' o2 M4 Y//多数RAM Grbl使用基于这个缓冲区的大小。如果有额外的只会增加
, S# H2 O6 O) m# ^9 T; p//可用内存,比如当基于大型或Sanguino。如果Arduino或减少5 f* I! d9 d4 C. i- Y7 f, h9 p. y
//开始崩溃由于缺乏可用的RAM或者CPU是难以保持
* |& ?- y5 s3 w1 @1 P//与规划新传入的动作执行。
* m+ i& w  e; l  e
0 B' o5 ?( W: J& W+ Q: ]// #define BLOCK_BUFFER_SIZE 18  // Uncomment to override default in planner.h.- Q7 S1 F/ a- g
7 y& a% P9 o" U9 _2 c) C
// Governs the size of the intermediary step segment buffer between the step execution algorithm0 G" ~# }. n: i# @9 z5 e0 S/ i7 {
// and the planner blocks. Each segment is set of steps executed at a constant velocity over a2 d% d6 {# S# d4 ~1 a' Y# S# q5 ^
// fixed time defined by ACCELERATION_TICKS_PER_SECOND. They are computed such that the planner
/ w( q, L: M7 h/ x2 s// block velocity profile is traced exactly. The size of this buffer governs how much step
1 D- [  p* q4 k2 ]$ p; K+ K+ |// execution lead time there is for other Grbl processes have to compute and do their thing
8 n/ a6 f/ H! e5 F1 U, ~// before having to come back and refill this buffer, currently at ~50msec of step moves.
2 e/ P: `% ^- c" A; M//控制之间的中间段缓冲大小的步骤执行算法; [' K& _# {0 N# z
//和规划师块。每一部分的步骤执行在一个恒定的速度6 I5 G- n% g3 a8 I
//固定的时间由ACCELERATION_TICKS_PER_SECOND定义的。他们计算的计划
0 A* z7 U& s% c1 l//块速度剖面追踪到底。这个缓冲区的大小控制多少步骤2 _( |& x6 C9 K7 u7 t; d) q
//执行时间有其他Grbl过程需要计算和做他们的事情' V+ n' b! a$ h' E/ |8 I
//之前必须回来重新填充这个缓冲区,目前移动~ 50毫秒的一步。
" g0 z7 ?. Y' H/ `9 s2 _, K: u/ y0 Y; l8 S4 T4 M  w6 \
// #define SEGMENT_BUFFER_SIZE 6 // Uncomment to override default in stepper.h.' N) k# J' y4 D& f

+ z/ M# k7 J2 ~5 \( f5 @  @// Line buffer size from the serial input stream to be executed. Also, governs the size of 4 E  K$ V" Y* F" S9 m- I
// each of the startup blocks, as they are each stored as a string of this size. Make sure
2 T8 L6 P+ ]7 ^& X7 A0 S( {// to account for the available EEPROM at the defined memory address in settings.h and for: b6 O7 Y0 R0 w( E: K- S3 F) m9 @
// the number of desired startup blocks.
) E- ^$ U9 R+ J3 K: [& B// NOTE: 80 characters is not a problem except for extreme cases, but the line buffer size : e  R7 s/ t2 Y& s; k! E7 R' ^
// can be too small and g-code blocks can get truncated. Officially, the g-code standards & s1 S0 L, F% g% o9 {) {% l, ^6 ]
// support up to 256 characters. In future versions, this default will be increased, when 3 J& |  q7 |" B3 ~
// we know how much extra memory space we can re-invest into this.1 v$ P# l( ^0 l& _- ~) i4 a
//行执行串行输入流的缓冲区大小。同时,大小的控制2 n8 b$ `9 {% L; `* I/ O
//每个启动模块,它们分别存储为字符串的大小。确保
& q& W' j5 _" ]- Z! n//占可用eepm定义内存地址的设置。h和
3 ^6 Z- z3 G0 q5 t! `//需要启动块的数量。
( O# F9 _- t7 f' H//注意:80个字符不是一个问题,除了极端的情况下,但线缓冲区大小
; G# g8 j) y/ G//可以太小和刀位点块可以截断。正式,刀位点标准+ w9 j# G  Z4 f' _$ `. z8 \( {. x
//支持多达256个字符。在未来的版本中,这个违约将会增加,当0 r9 [+ @( s1 w* J: w2 r
//我们知道多少额外内存空间的时候我们可以再投资。
! W/ ]% O5 Z* [
; s0 G' v4 Y% j// #define LINE_BUFFER_SIZE 80  // Uncomment to override default in protocol.h" _7 i2 G  [; X9 a
  9 g) L! v# G& \: F! F1 [
// Serial send and receive buffer size. The receive buffer is often used as another streaming6 G- V0 e. C/ G% b* H! n) \9 b3 t! O
// buffer to store incoming blocks to be processed by Grbl when its ready. Most streaming
& _: q+ {3 Y0 c2 ~/ V( D0 }// interfaces will character count and track each block send to each block response. So,
) ], _  ~& Z' I4 W* i& y( f2 e// increase the receive buffer if a deeper receive buffer is needed for streaming and avaiable
  M2 r9 X3 o- U// memory allows. The send buffer primarily handles messages in Grbl. Only increase if large
3 S  k4 c, U  _" J1 l9 Q! G// messages are sent and Grbl begins to stall, waiting to send the rest of the message.
4 l" s& p/ u- G6 `& [: T6 j2 K. a// NOTE: Buffer size values must be greater than zero and less than 256.$ g. w! B* @9 H, A# f) l$ ?
// #define RX_BUFFER_SIZE 128 // Uncomment to override defaults in serial.h
7 D2 C! U/ Q9 V5 v//串行发送和接收缓冲区大小。接收缓冲区通常用作另一个流
5 w: w% T; N4 p7 U1 o& p; x//缓冲存储传入的块来处理Grbl当它准备好了。最流
/ B& S, w' J9 I) \2 z- d0 Q//接口将字符计数和跟踪每一块发送给每个块的回应。所以,# t% I6 H3 }0 t8 H& R" ~
//增加接收缓冲区如果需要更深层次的接收缓冲区为流,、
( l* C' X1 C8 H( k7 R. M/ p/ e, L//内存允许。Grbl发送缓冲主要处理消息。只会增加如果大
$ `& u# J( n# A3 d//消息发送和Grbl开始停滞,等待发送其余的消息。
2 `  F: s6 K  O% f7 j5 s- L//注意:缓冲区大小值必须大于零,小于256。: n: A/ k3 B; X$ b6 ~( i
// # define RX_BUFFER_SIZE 128 / /取消serial.h覆盖默认值
5 X  W+ y: t1 c, ?. I2 @+ d4 [& s1 Z6 A3 v6 h" Y4 o) \
; t  ]7 \- s  B& C8 l- E
// #define TX_BUFFER_SIZE 64
( f# [  s/ ]* R  A  
+ D- D& a' \8 D0 N6 x// Toggles XON/XOFF software flow control for serial communications. Not officially supported! k& G. V7 ]. S" O3 ~
// due to problems involving the Atmega8U2 USB-to-serial chips on current Arduinos. The firmware4 J% V( m- l' g" ~
// on these chips do not support XON/XOFF flow control characters and the intermediate buffer 2 B2 _* A. F- E5 x  i  h
// in the chips cause latency and overflow problems with standard terminal programs. However, % r; s/ m, {4 `" I1 {2 O
// using specifically-programmed UI's to manage this latency problem has been confirmed to work.
6 C7 G/ N1 T; M// As well as, older FTDI FT232RL-based Arduinos(Duemilanove) are known to work with standard
9 L  }2 {: Y1 p; Y// terminal programs since their firmware correctly manage these XON/XOFF characters. In any
6 W5 D& R8 O, t) v7 `// case, please report any successes to grbl administrators!5 C; i+ G" \* @1 B0 J
//切换为串行通信发送朴通/发送葡开软件流控制。不是官方支持
; v  t; t% H* h# B8 s//由于问题涉及Atmega8U2 USB-to-serial当前arduino芯片。固件
# Y) d6 g1 L. }- C//在这些芯片不支持发送朴通/发送葡开流控制字符和中间缓冲区1 \/ T/ E5 X- U* `$ S  x& |9 q
//芯片导致延迟和溢出问题的标准终端程序。然而,# C8 `( R" [4 n7 A
//使用specifically-programmed UI的管理这个延迟问题已经确认工作。
, |" \8 v+ l" H//以及老FTDI FT232RL-based arduino(Duemilanove)是已知的标准% Q- _& z$ ^- S% L, S) ?+ n: u1 q
//终端程序因为他们正确的固件管理这些发送朴通/发送葡开的角色。在任何5 _4 w/ k% v2 z  L+ _( y9 u7 h6 j
//情况,请报告任何成功grbl管理员!- I* l3 n, e: n! g5 R& x% q3 |! T
( i" F: M% o8 I- c& x
// #define ENABLE_XONXOFF // Default disabled. Uncomment to enable.0 u- c. y; e& {  k0 M4 I

2 u1 Z  a/ V% F, S// A simple software debouncing feature for hard limit switches. When enabled, the interrupt
! m' N1 ^4 i* i0 t6 F( }9 \+ ~// monitoring the hard limit switch pins will enable the Arduino's watchdog timer to re-check
9 |. c4 w  s0 I1 R// the limit pin state after a delay of about 32msec. This can help with CNC machines with 0 R2 u+ Y: C0 C& V* `
// problematic false triggering of their hard limit switches, but it WILL NOT fix issues with
& U+ m- x8 ^" S// electrical interference on the signal cables from external sources. It's recommended to first# C) G9 X3 x* P2 b( R( t: P2 f
// use shielded signal cables with their shielding connected to ground (old USB/computer cables 6 L5 v/ h& o7 ]% {
// work well and are cheap to find) and wire in a low-pass circuit into each limit pin.
4 Q  y; e8 r- c" R: s//一个简单的软件消除抖动特性硬限位开关。当启用时,中断( u/ o* l2 V# Z3 g$ L
//监控硬限位开关针将使Arduino的看门狗定时器重新审视0 w& {) i3 \: I, R8 ~2 Q
//销的极限状态后约32毫秒的延迟。这可以帮助与数控机器
2 }  W, e6 o% o) k  t//问题错误引发的硬限位开关,但是它不会解决问题- b# v( f# x. e' s
//电干扰信号电缆从外部来源。首先它的建议' J2 b3 }1 c6 T4 F2 D
//使用屏蔽信号电缆的屏蔽连接到地面(老USB /计算机电缆
2 [2 W( y- a& V: ]" j5 d//工作得很好,很便宜)和线低通电路到每个限位销。* W8 x9 v' Y, B
& t' T& [. G& w9 Y8 g3 i5 j3 {' q
// #define ENABLE_SOFTWARE_DEBOUNCE // Default disabled. Uncomment to enable.8 O1 J* v+ [: w1 ?1 \" e
7 O, f8 x7 Y  S( R& V: z
// Force Grbl to check the state of the hard limit switches when the processor detects a pin- ~. U" c, i9 u' ?2 J+ {' A, w
// change inside the hard limit ISR routine. By default, Grbl will trigger the hard limits
5 w2 x1 Y9 e' z* c3 h// alarm upon any pin change, since bouncing switches can cause a state check like this to 8 e; U9 E; Y! ^1 K" S
// misread the pin. When hard limits are triggered, they should be 100% reliable, which is the& ]7 v, J9 e9 P/ d( h8 i+ M: U
// reason that this option is disabled by default. Only if your system/electronics can guarantee
2 B) h1 D% i# d. P. x// that the switches don't bounce, we recommend enabling this option. This will help prevent( b; K' I' m: I+ a: g
// triggering a hard limit when the machine disengages from the switch.
6 r' u! o; U( y0 H! d, \  D! |// NOTE: This option has no effect if SOFTWARE_DEBOUNCE is enabled.
% [1 Q4 k% ]2 o& J; m: @8 E//力Grbl检查硬限位开关的状态,当处理器检测到一个销: a" u( a1 ?' q7 o# _
//改变内部硬限制ISR例行公事。默认情况下,Grbl将触发硬限制
# \) \$ l3 s% v( t6 p//报警在任何销更改,因为跳开关可以导致这样的状态检查! j. Q4 c, C$ e5 Z% A5 B
//误读了销。硬限制触发时,他们应该100%可靠,这是
( P/ b2 W  A7 p7 {1 @//原因,这个选项默认是禁用的。只有在你的系统/电子产品可以保证$ Z3 U' E; O: R: R" j; b2 F6 g
//开关不反弹,我们建议启用这个选项。这将有助于防止
+ n5 P* C* r4 U/ x8 x( h8 d* X//触发机退出时硬限制开关。: x4 R5 [, f0 e2 k6 Z0 K
//注意:这个选项如果启用了SOFTWARE_DEBOUNCE没有影响。
1 K0 J; u8 s! ~7 v7 R# t
# d( }; F5 p" I. _, W// #define HARD_LIMIT_FORCE_STATE_CHECK // Default disabled. Uncomment to enable.
$ N2 n& o! C& [* z# c
" l7 |; F0 _5 ]# ~
. F, M% B5 R, A- g- b// ---------------------------------------------------------------------------------------: E  q- b& r# P, i* r
// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:编译时错误检查的定义值:
6 X" m) [* N8 s+ n/ `: _! V: z  `7 w/ J+ Z
#ifndef HOMING_CYCLE_09 |7 N  l3 g( w, e: R+ O, A: Y" y
  #error "Required HOMING_CYCLE_0 not defined."
3 E" A. M& ?! A, J2 `& _5 p/ V#endif
0 m3 @7 d$ D% |
! E/ z  t4 `  |! f& K9 c+ U0 A#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(VARIABLE_SPINDLE)+ p* H# ~4 p, V$ ~
  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with VARIABLE_SPINDLE enabled"
9 U+ C  @  S/ `#endif
& r9 |+ X8 {. }9 H' n( w2 Q1 u0 \% P4 o; b
#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(CPU_MAP_ATMEGA328P)% o; q# Q% A2 P: d* U- ?. K7 \- V
  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with a 328p processor"
2 e& n. y- C" i* _7 Z; ~#endif
8 y+ N6 v9 ~) ?7 t/ W$ S2 v2 i! D& v! |6 g1 n
// ---------------------------------------------------------------------------------------
2 T# N8 a% B9 p  `( i
* P* ~1 V. Z- N5 d
* Q2 j1 r! B, Z6 O6 w6 x#endif( g" P# Y. W( M/ O0 C

4 }# J' E- O3 q) ]  ^' L
& j# }2 C1 s8 w+ e+ r" s# e8 `8 z$ `8 F+ Q1 |
/ O* I. A# D: O- R0 k

2 v3 H& K. G* _! H6 Q. `% n4 C  [
+ b, c3 J( k- B/ J+ R5 S9 E2 u
7 _! u, q: F  z" c0 r) e
- Q3 \2 h" R. ]5 D% x3 N. t
) a* z9 Y  r7 b7 t; Y; K. z% m: z7 A* `+ ^. N4 _
0 R0 y8 u6 R( W2 x/ a# _
! v1 i3 I; p4 _3 Z1 ]! a% t
( w- Q! }7 Z0 d3 E+ k! K

* H' n; ^! h% ]7 k
7 Y, J9 F; n% s3 b9 b. A& Q  l% r( f3 |) k! Z

本帖子中包含更多资源

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

x

评分

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

查看全部评分

回复

使用道具 举报

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

使用道具 举报

 楼主| 发表于 2016-8-21 00:14:16 | 显示全部楼层

5 A( D- \7 V. E/ M3 V6 V% z
回复 支持 反对

使用道具 举报

发表于 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 | 显示全部楼层
补充; _/ F; Y" s& H4 c6 u' o
程序运行protocol_execute_realtime(); /运行实时命令。& Z0 _- X7 K( ]8 k9 r' E
// Executes run-time commands, when required. This is called from various check points in the main9 a/ ?: p; r. P! G6 f
// program, primarily where there may be a while loop waiting for a buffer to clear space or any* P. g9 s( z7 U6 z& ?5 U9 o
// point where the execution time from the last check point may be more than a fraction of a second.
( y4 Q6 `8 l! G, l// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code
, j. p* h8 c* q3 O" v; R; Z// parsing and planning functions. This function also serves as an interface for the interrupts to * ~4 c: w& N: S) ?; @+ U- S
// set the system realtime flags, where only the main program handles them, removing the need to: `  A* M# x, Y0 n2 |
// define more computationally-expensive volatile variables. This also provides a controlled way to 5 l8 n( ]6 [* y; g7 q7 M
// execute certain tasks without having two or more instances of the same task, such as the planner  T2 v. x1 ]/ D5 s1 z
// recalculating the buffer upon a feedhold or override.6 I1 {4 X3 f" S' C. T7 u
// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,, I4 Q0 [2 [, ]; _" {" u8 P' e
// limit switches, or the main program.
6 g! p: A0 W& J8 @; y3 @+ j+ T9 O: M# r/ s6 H. t2 }0 k
//执行运行时间命令,在需要时。这就是所谓的从各种主程序要检查站
1 Z8 n. k0 v' I8 }//,主要是那里可能是一个while循环等待缓冲区空间或任何
1 b- s9 D: f5 V//执行时间从过去的止点可以超过几分之一秒。! N1 x0 r3 ~4 _0 `
//这是一种异步执行实时命令(又名多任务)grbl的刀位点; C- {5 E" j7 c
//解析和规划功能。这个函数也可以作为一个接口,用于中断
! K* S) ^7 g& J# W; k//设置系统实时的旗帜,只有主程序处理,消除的需要' k( L3 i  O; w/ y
//定义更多的计算昂贵volatile变量。这也提供了一种控制方法
8 \* P( z3 }7 s& [# E3 J//执行某些任务不相同的两个或多个实例的任务,比如计划8 N/ s# J4 f' j# u
//重新计算缓冲feedhold或覆盖。- d) P, d7 r1 X+ ~2 J! ]
//注意:sys_rt_exec_state变量标志设置任何过程,步骤或串行中断,插脚引线,0 u7 T3 z# n1 x- b
//限位开关或主程序。
! j5 g' L( s- _& M+ i0 Bvoid protocol_execute_realtime()
& @/ U2 J( e1 p( e{3 `5 K4 @& k) w* g; I3 S: O4 p
        // Temp variable to avoid calling volatile multiple times.
! c$ Q2 R5 A  W5 F        // 临时变量来避免多次调用不稳定。
" k1 U+ `7 E3 o        uint8_t rt_exec;
% Q7 x. z: _% f6 J5 J  _        do{
5 P- `  J6 y2 r3 r! i          if (rt_exec) {                 // 有标志位置位进入& @& H! G* d8 U7 c: d
       
! C. X4 Q6 k3 I' `            sys.state = STATE_ALARM; // 设置系统为报警状态
4 U# L8 X0 r4 ]( d9 e      report_alarm_message(ALARM_HARD_LIMIT_ERROR);        //报告报警信息为接近极限值
  z+ o8 ~4 D+ p# f    } else if (rt_exec & EXEC_ALARM_SOFT_LIMIT) {                        //报告执行软件限位报警+ j* ~0 W& Y8 T2 T( y* h
      report_alarm_message(ALARM_SOFT_LIMIT_ERROR);        //报告出现软件限位报警9 a6 y% _2 ~7 a
    } else if (rt_exec & EXEC_ALARM_ABORT_CYCLE) {                //执行停止循环报警      
  H; j" f' y5 R- K8 r      report_alarm_message(ALARM_ABORT_CYCLE);                //出现终止循环报警
" q* ~5 V& O' m/ f2 t5 f- e    } else if (rt_exec & EXEC_ALARM_PROBE_FAIL) {                        //执行探查失败报警) Q; N2 v6 o" g) A' C
      report_alarm_message(ALARM_PROBE_FAIL);                        //出现探查失败报警5 w0 k) p, K5 ^/ s$ ~
    } else if (rt_exec & EXEC_ALARM_HOMING_FAIL) {                //执行返回原点失败报警! I7 C6 J) U$ x4 j* E
      report_alarm_message(ALARM_HOMING_FAIL);                //出现返回原点失败报警
- e" O! O+ e5 k- @( O: `4 u    }
0 g0 b% K! U7 q3 y5 y# S3 Y
, T$ C9 f! X/ w( I    // Halt everything upon a critical event flag. Currently hard and soft limits flag this.! U4 ?- _9 F8 r! i( G7 Z
    // 停止一切在一个关键事件标志。目前硬和软限制标志2 M& N/ g. x$ X+ f$ a& W+ M
           if (rt_exec & EXEC_CRITICAL_EVENT) {                //如果系统是循环事件进入
; S- s, ?$ F$ n! |" P: w, ^! u3 F* u) S             report_feedback_message(MESSAGE_CRITICAL_EVENT);        //报告反馈信息" p4 b0 L- l; [1 v
              bit_false_atomic(sys_rt_exec_state,EXEC_RESET);                         //清除目前的复位状态* z/ h9 G5 }- x1 S
$ F1 p: [+ k' G7 e$ o
        bit_false_atomic(sys_rt_exec_alarm,0xFF);                                 // 清除所有报警标志
( K& B  y  I9 q2 b        }        9 n6 H: }, I5 C; b. o

" B. h% v6 i4 C1 z* P- D上面代码将rt_exec = sys_rt_exec_alarm ,如果rt_exec为真,打印不同报警信息
. U. O5 e2 c& }和限位保护信息,然后清除报警状态
) I' X; ?1 U8 K; Y% M0 A0 \( l___________________________________________________________________________
7 m. ^) {. e( V" Y8 Z- s8 o; H3 e没有报警进行执行下面代码,执行了终止命令,串口打印命令, b7 \6 d' F( R. {! t& b( l
        // Check amd execute realtime commands        校验和执行实时命令. f# ?7 \$ o/ A, Q' C
          rt_exec = sys_rt_exec_state; // Copy volatile sys_rt_exec_state4 m3 ^( e5 [( {, C/ s5 b* |$ [$ B: o

5 |4 t4 m, c. U/ f        if (rt_exec) { // 输入标志是正确的执行
" j; q. D& b. C9 V& }9 A( O2 z" B: @  z
            // Execute system abort. 执行系统终止命令
& E, D! f8 f8 u! `! d3 C6 ^            if (rt_exec & EXEC_RESET) {; x! T6 j$ K# f! R' o
              sys.abort = true;  // Only place this is set true.
0 e2 [6 q) N- B8 [              return; // Nothing else to do but exit./ Y0 W1 @  I4 ]5 q, h  D9 U+ g
        }
5 i( f& n' Y' n  m9 N: l* y* [4 a1 I( }& y+ Y7 E2 Y: j8 M. z( p
            // Execute and serial print status 执行和串口打印状态
3 |1 w6 V" {. w- F- |! {) e8 X            if (rt_exec & EXEC_STATUS_REPORT) { 3 J* Z! j; {3 M8 U/ h
              report_realtime_status();        //报告实时状态
8 D( u1 ~* G3 j2 ~              bit_false_atomic(sys_rt_exec_state,EXEC_STATUS_REPORT);        //清除报告状态清零  Q/ j. e5 a/ z* I, x0 C! F
            }
9 t# c* o8 E( z# f* j_____________________________________________________________________________
# b2 D2 ~4 h1 ?8 i  F( s$ o下面代码5 k- |/ ^8 b6 t5 J
//执行状态。
4 p, R9 e1 P0 E( B//注意:所涉及的数学计算持有应该足够低对大多数人来说,即使不是全部,
4 ~3 y9 Y5 c& D- n1 |8 J9 g+ k//操作场景。一旦启动,系统进入暂停状态
/ @2 V, X( Z9 E. ~4 C: m" t! @//主程序流程,直到重置或恢复。
2 Y  V( S: Q+ K$ ]待办事项:检查模式?如何处理呢?可能没有,因为它只会在空闲,然后重置Grbl。
) g6 U. ~* \: a6 c4 Q状态检查容许状态的方法。
- j" M& D# d. R, I* l2 F( c' ^' s, K
        //如果全局各自报警标志位其中(执行取消动作) | (执行进给保持) | (执行安全门)任意一位为真进入, b- }; r- m0 |) h
            if (rt_exec & (EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR)) {       
4 K, `+ b( j3 _6 J4 N7 B( D; H: c1 F
        //如果是循环状态执行暂停状态4 |' U! |. V" g, j, o" O& _
        if (sys.state == STATE_CYCLE) {
5 a8 X; C& R- j" Y        st_update_plan_block_parameters(); //通知stepper module验算减速。
* \; I1 _$ c" y$ z        sys.suspend = SUSPEND_ENABLE_HOLD; // 开始暂停标志
* l7 u8 U' `: J7 I# C( {4 k        }
- \$ P( Y. U) L: m: w& m6 a2 J. w8 u; ?  S. q$ t# [2 u  R- F
        // 如果,Grbl空闲不在运动。简单的指示暂停就绪状态。
4 {. }) z3 \" n4 p1 V& Z( Q- X        if (sys.state == STATE_IDLE) { sys.suspend = SUSPEND_ENABLE_READY; }! o# Y3 C/ ?1 ]' M
6 Z) `5 _( u, G" h; n8 ]

' G4 U' }( y0 R5 q' M" P3 z8 c9 u        //执行和标志和减速运动取消并返回空闲。主要由探测使用周期
2 d3 T5 N# X* C' P) b" K        //停止和取消剩余的运动。      
$ v" D' _0 B! i& p' V7 V        if (rt_exec & EXEC_MOTION_CANCEL) {- N7 O- U* f- f  q* S. I. x2 }
          if (sys.state == STATE_CYCLE) { sys.state = STATE_MOTION_CANCEL; }
$ z/ o) G6 o, y6 C9 N          sys.suspend |= SUSPEND_MOTION_CANCEL; " X. H) D2 j' b: V
        }
( u1 {4 J* s' q- A
5 ], _2 T: o/ w. X4 H        // 只在循环时执行进给保持减速0 G3 M9 ?7 c) `% G
         if (rt_exec & EXEC_FEED_HOLD) {
. F3 i/ S& }6 N        //只有安全门为1才执行保持进给状态赋值1 c' p" C8 G) u
          if (bit_isfalse(sys.state,STATE_SAFETY_DOOR)) { sys.state = STATE_HOLD; }- i! \0 R, n4 A- K6 ]3 z
        }
$ n/ g* q4 q$ Y% A+ Z; D+ _3 ?6 X% y( O- g1 _( Y6 m
        if (rt_exec & EXEC_SAFETY_DOOR) {
9 U  f1 l9 y2 z  l8 z. X          report_feedback_message(MESSAGE_SAFETY_DOOR_AJAR);
" i, \, U) u+ i% Z3 Z+ z/ /如果已经活跃,准备好重新开始,CYCLE_STOP标志设置为强制断开。; [0 j7 Z3 l) i6 f
/ /注意:只是暂时设置“rt_exec”变量,不是动荡的“rt_exec_state”变量。
) C. b0 C% M1 q2 c* r          if (sys.suspend & SUSPEND_ENABLE_READY) { bit_true(rt_exec,EXEC_CYCLE_STOP); }
+ ~7 O( {( G5 W  M; l9 D6 p  C          sys.suspend |= SUSPEND_ENERGIZE;
% _) L9 [/ p. J* h* E6 v          sys.state = STATE_SAFETY_DOOR;
- K3 d- T( P8 {8 B        }
+ ]/ n+ @, F4 x3 I/ q" F' z6 r+ i! x, Q9 J
bit_false_atomic(sys_rt_exec_state,(EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR));   
4 @" B9 F+ [$ l" o: O$ n8 s" U9 x& R  d8 q) N. k
}
$ D5 L& J6 y( w3 L以上代码执行了; X/ b, c: a( {- c8 I. m5 C
1.如果全局各自报警标志位其中(执行取消动作) | (执行进给保持) | (执行安全门)任意一位为真进入) `; L8 N+ o. {: W" W
2.系统为闲着状态, 开始循环状态, 回原点状态, 控制取消状态, 开始保持状态, 开始安全门状态时进入
# ~. N8 R* g0 W) n3.如果是循环状态执行暂停状态
# W# n0 j* f  D3 a2 B' G4.如果系统闲置状态执行暂停就绪状态
$ E2 \6 `. o; _8 F  d2 c5.执行动作取消
% b- I# W, e5 ]2 p! w8 {. K6.如果是保持进给状态,执行保持进给状态! b! E. s6 Z8 M; |" s/ L  m8 w  K, U
7.执行安全门状态
3 Y5 b+ _3 V7 V3 B* b/ P最后执行bit_false_atomic清标志清除(执行取消动作)(执行进给保持)(执行安全门)标志位                 
3 x3 G. V: h5 u) U7 s9 ?# P1 D# @_____________________________________________________________________________
$ `9 w$ ]/ E' ^; m$ a1 s
) T+ q. u4 d$ }, c* T* ]    // Execute a cycle start by starting the stepper interrupt to begin executing the blocks in queue.
% C# X. d. K; F0 p3 p/ N    // 执行一个循环开始启动步进开始执行中断队列的街区! G% ^: u& L+ q0 ]) n/ t- Q
    if (rt_exec & EXEC_CYCLE_START) {        //循环开始状态进入
- v# r( a. [. f" P* [$ Z/ E* c( Q      // Block if called at same time as the hold commands: feed hold, motion cancel, and safety door.' Z" f2 x$ d8 ~  ^. P- G
      // Ensures auto-cycle-start doesn't resume a hold without an explicit user-input.
9 D, s  c+ H" a8 O          //块如果在同时举行的命令:保持进给,运动取消,和安全的门。 //确保auto-cycle-start没有简历没有显式的用户输入。# e- b0 a& H/ d1 R9 i9 C, d
          
7 t- p/ i% Y" u2 ?      if (!(rt_exec & (EXEC_FEED_HOLD | EXEC_MOTION_CANCEL | EXEC_SAFETY_DOOR))) {   //状态机如果不是保持进给,运动取消,和安全的门。
  L/ s% S* _- L: h$ m        // Cycle start only when IDLE or when a hold is complete and ready to resume.
$ L9 a5 Z2 a9 x0 l" T5 o# ?        // NOTE: SAFETY_DOOR is implicitly blocked. It reverts to HOLD when the door is closed.: m) z- `$ x% ^6 [0 P
                //循环开始时只有当闲置或持有完成并准备简历。% U* E" I. Q* i/ a5 f
                //注意:SAFETY_DOOR是隐式地屏蔽。它返回的时候门是关闭的。   
- V! ~7 a4 \$ {1 Q) {
2 x2 k, n3 @3 {7 l1 s2 u6 B                // 如果系统状态为闲着状态,系统状态为开始进给或运动取消,暂停标志为位重新开始
# N' g0 V9 U! w        if ((sys.state == STATE_IDLE) || ((sys.state & (STATE_HOLD | STATE_MOTION_CANCEL)) && (sys.suspend & SUSPEND_ENABLE_READY))) {. A, X7 S% R; m8 w4 e
          // Re-energize powered components, if disabled by SAFETY_DOOR.2 A" T6 n  T. T" f  z! }: V
          //        由SAFETY_DOOR重振组件供电,如果禁用。
! H! v$ i, A. u! G7 C1 a3 p          if (sys.suspend & SUSPEND_ENERGIZE) { 8 }* r" k- |# E) P
            // Delayed Tasks: Restart spindle and coolant, delay to power-up, then resume cycle.
& s# k3 ~- [+ z  }3 x3 X' P" ~            //延迟任务:重新启动主轴和冷却剂,延迟升高,然后恢复周期。
2 ~5 e( l1 {. J) V0 }* Q            if (gc_state.modal.spindle != SPINDLE_DISABLE) {   //主轴模式不是失能进入) d" l. Z! ~7 o* l# v* y& X& a
              spindle_set_state(gc_state.modal.spindle, gc_state.spindle_speed); //设置状态和速度/ P; w! w0 |1 F6 r/ [2 n9 @
              //待办事项:阻塞函数调用。最终需要一个非阻塞。1 ?6 Y* l! `4 k5 j' P  ^# o
                delay_ms(SAFETY_DOOR_SPINDLE_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually., @8 d! b8 O4 r. S) n
            }
$ V0 X# `2 x: X            if (gc_state.modal.coolant != COOLANT_DISABLE) { ( C  i9 L6 l( w# ?2 D
              coolant_set_state(gc_state.modal.coolant);
7 S) t% o+ a1 T+ l0 _0 l% g' A              delay_ms(SAFETY_DOOR_COOLANT_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.
+ d8 l# y( V5 a4 X8 x9 T            }( z% A" t# v' ~, G4 t9 w. H
            // TODO: Install return to pre-park position.
1 S' `9 N: p! h+ U5 R' x; S          }
! x. V0 b! a, Q8 X______________________________________________________________________________________________________________
0 Q4 p" _$ @! b: c5 x! S          // Start cycle only if queued motions exist in planner buffer and the motion is not canceled.
. W6 a. ]; k( I5 K                  # M- D: Y& T; e' _+ x) f
                  //只有在队列马达存在规定的缓冲,并且动机没有让取消,才会循环
. E; p1 s- u: b1 a                  $ j3 p+ p  u: E/ J. z
          if (plan_get_current_block() && bit_isfalse(sys.suspend,SUSPEND_MOTION_CANCEL)) {0 W7 W% I5 c& H, P* e9 A0 {6 A
            sys.state = STATE_CYCLE;
. u- c% M  [/ e, V, t5 {( B( {            st_prep_buffer(); // Initialize step segment buffer before beginning cycle.初始化步开始循环之前9 f2 r  I% A. b* j$ O& C
            st_wake_up();
( s- j+ X0 K7 p' x1 h  T          } else { // Otherwise, do nothing. Set and resume IDLE state.否则,什么也不做,设置和复位空闲模式  K3 I: i$ l2 `' z
            sys.state = STATE_IDLE;
7 p( t1 M  o4 Z" g* Z          }! j5 j  {, \0 L0 A
          sys.suspend = SUSPEND_DISABLE; // Break suspend state.
1 i: ?3 }; _6 ]        }
" l( Y+ i$ S/ i/ `- o      }   
. j9 u0 j: _# n      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_START);        3 a8 D1 i1 K0 Q/ n
    }/ j, d+ j( T' @3 {5 w5 I" l0 I. E) T  v

  u2 P2 G$ ]& t/ j% Q_______________________________________________________________________________________________________1 t& `( s; e' K6 k- v
    // Reinitializes the cycle plan and stepper system after a feed hold for a resume. Called by 0 r5 H' \; L2 e# `5 B) u0 A
    // realtime command execution in the main program, ensuring that the planner re-plans safely.& T) T, s: u1 B5 P% K
    // NOTE: Bresenham algorithm variables are still maintained through both the planner and stepper+ T" s3 J) p* }; t6 P- U
    // cycle reinitializations. The stepper path should continue exactly as if nothing has happened.   ; w" E% I; j. T. @4 P0 T
    // NOTE: EXEC_CYCLE_STOP is set by the stepper subsystem when a cycle or feed hold completes.
' Q* T" Y0 M# k5 F2 d- `" B3 u% a6 \9 T2 g; T- G! P' ~& j
        //重新启动后循环计划和步进系统的进给保持简历。通过实时命令执行主程序,确保安全计划重新计划。) _, T' Q. Z8 p  q
        //注意:画线算法变量仍保持通过规划师和步进
/ C7 s1 }' Y) `3 M) V        //循环仅。步进路径应该继续,好像什么都没发生一样。       
2 ~6 q( r" j2 ~0 V4 L        //注意:EXEC_CYCLE_STOP由步进子系统周期或进给保持时完成。
) U$ ?# X' k1 ~' ]7 A
; q3 `" k4 @2 W6 W9 U5 Y% u    if (rt_exec & EXEC_CYCLE_STOP) {                         //如果是循环停止状态进入2 W" R" K+ p* u7 G- G( I
      if (sys.state & (STATE_HOLD | STATE_SAFETY_DOOR)) {, w. h4 U: t) l( L+ O
        // Hold complete. Set to indicate ready to resume.  Remain in HOLD or DOOR states until user+ O+ b9 y9 j2 |* b5 N9 L) ^
        // has issued a resume command or reset.+ D0 ~6 m* p/ d: _- }

1 D; G) k- Z2 L) b" N  k                //保存完整。设置为指示准备简历。继续持有或门状态,直到用户# w1 M& T2 r# _' b' x+ H" S% ~
                //已发布了一份简历命令或重置。
1 Q$ V/ f) d6 j9 |$ R9 }               
2 P) \$ `8 l/ Z( \/ |+ q7 a0 @5 M        if (sys.suspend & SUSPEND_ENERGIZE) { // De-energize system if safety door has been opened. 如果安全的门已被打开。断开系统
" ]* z% \0 O: n% |3 V& {# V          spindle_stop();( e3 R- O# V8 e7 s5 e  m9 P9 [$ ]
          coolant_stop();  u2 Y) U2 k, h, ^1 A; i2 E
          // TODO: Install parking motion here. 安装停车动作。
* a" ]; j! D, K) E4 K        }
  y# M& o- s  P0 L+ x        bit_true(sys.suspend,SUSPEND_ENABLE_READY);. |0 n! |, O9 y2 g: \5 R( B
      } else { // Motion is complete. Includes CYCLE, HOMING, and MOTION_CANCEL states. 电机完成,循环,回原点,,MOTION_CANCEL' T; l" J$ A6 I5 `3 H9 l; {, Y
        sys.suspend = SUSPEND_DISABLE;
' i5 ]1 J6 X5 R& f" b$ A( \, C        sys.state = STATE_IDLE;' ^6 |+ o6 N2 T/ ~
      }
8 {" d8 }! R2 _1 w. Y* I8 G* U      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_STOP);5 w4 U( L3 Y' l4 D. a
    }
1 q( C% A3 R) D! i. f- s  J   
0 ~+ T7 U8 x* r' N* x% O  }3 {0 }' L: [( h" _4 U' y
___________________________________________________________________________________________________- f9 A3 |, k3 Z
8 M! q' j5 R5 n: Q7 j2 u: j$ N2 k
  // Overrides flag byte (sys.override) and execution should be installed here, since they - ^" s- q' c$ U; H9 ^
  // are realtime and require a direct and controlled interface to the main stepper program.* _) j8 `- E, O0 n- b8 i6 b3 z

" i$ c' `# A9 a5 _0 W3 a+ d  //重写标志字节(sys.override)和执行应该安装在这里,因为他们
" C. p# v: [# m* N& ]  Y$ v% B7 l  //实时和需要直接和控制接口的主要步进程序。# r/ e1 K4 m6 j, N2 I2 S
4 ~& s) b: D0 B8 B9 \/ V

0 S9 R: Y+ k) Q7 Q/ j9 b  // Reload step segment buffer 重新加载步段缓冲6 T# i+ c( A! r+ f6 m$ D- D  S
  if (sys.state & (STATE_CYCLE | STATE_HOLD | STATE_MOTION_CANCEL | STATE_SAFETY_DOOR | STATE_HOMING)) { st_prep_buffer(); } # s) R0 O$ y$ m

. J8 l4 ~* T2 N! f  // If safety door was opened, actively check when safety door is closed and ready to resume./ f: k! s. l$ u
  // NOTE: This unlocks the SAFETY_DOOR state to a HOLD state, such that CYCLE_START can activate a resume.       
; M# e) f; q. u2 C4 b
5 A  v+ H# `# `0 x; W+ j; p//如果安全的门被打开,积极检查当安全门关闭,准备简历。
2 j: h1 t5 I( d6 C  //注意:这解锁SAFETY_DOOR状态保持状态,这样CYCLE_START可以激活一个简历。
) A4 y/ r; x; w( l$ S7 B# j4 |
* p! `5 B8 B" [  if (sys.state == STATE_SAFETY_DOOR) {                 //安全门状态进入
, E5 h0 M% P& d: `$ d    if (bit_istrue(sys.suspend,SUSPEND_ENABLE_READY)) {
6 h8 `% u# x0 s/ p      if (!(system_check_safety_door_ajar())) {+ l3 T& e7 ?5 L  {0 N1 Z
        sys.state = STATE_HOLD; // Update to HOLD state to indicate door is closed and ready to resume. 更新保存状态指示门关闭,准备简历。" p9 X; ^( t0 C6 Z( s, p9 F
      }5 d0 u! y( d* t
    }
* P, \) o9 A$ X, O  }  K6 w; R; {  z6 N2 r4 h9 `5 L0 w/ M

6 V/ A" L9 m+ g- V& W4 I  } while(sys.suspend); // Check for system suspend state before exiting.: N% M  t4 f* J
  % _2 A# ]) j% O% H0 }  e
}  
回复 支持 反对

使用道具 举报

发表于 2016-8-25 09:31:12 | 显示全部楼层
楼主这些代码。是网上搜来,然后自己组合的吗?全是自己想的,那是牛逼了

点评

外国的开源软件grbl,在研究它,将打注释了下而已,研究透彻了好移植的其他平台应用,学习阶段。 https://github.com/grbl/grbl  详情 回复 发表于 2016-8-25 22:19
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

小黑屋|手机版|Archiver|机械社区 ( 京ICP备10217105号-1,京ICP证050210号,浙公网安备33038202004372号 )

GMT+8, 2025-5-2 22:28 , Processed in 0.132660 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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