机械必威体育网址

 找回密码
 注册会员

QQ登录

只需一步,快速开始

搜索
查看: 18086|回复: 15
打印 上一主题 下一主题

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

[复制链接]
跳转到指定楼层
1#
发表于 2016-8-20 23:56:23 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 1五湖四海1 于 2016-8-21 00:09 编辑
* [2 P/ a4 l: b$ A0 r1 m- \: i, P8 v, ?1 P' }1 O
    以前制作过CNC雕刻机,是用MACH3作为上位机控制,硬件是采用PC接并口输出脉冲和方向使能信号经过隔离驱动步进电机驱动器,步进电机驱动是采用TB6560芯片控制。最后就接到步进电机。机械是用铝合金制作,主要部件有三个1605的滚珠丝杠,多个运动滑块等制作。用这台DIY CNC雕刻机可以雕刻木头塑料等东西。当时没有一直玩下去,现在发现网上有用单片机制作的雕刻机挺精巧的现在分享给大家。' L. j. w" t) _, w4 \3 s
   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个运动来规划运行速度,以实现平稳的加速和无冲击的转弯。很棒吧!开始玩起。; A4 ~; m8 w# Y7 ~7 P
    还没有雕刻机的机械部分可以用废旧光驱制作个微型雕刻机运动平台。雕刻机最重要的是主控程序这次用 Arduino/AVR328单片机,价格在15元左右,主控程序是上面提到的目前很火的开源
的GRBL,还有一种基于STM32平台的开源主控程序Dlion也不错可以替代grbl。如果从性能比较这两个方案,显然是stm32平台运行速度更快毕竟他是32单片机呀!+ Y- E* w/ z7 j" k( }5 T

# u8 P9 `5 r% d+ b* v" F' n, S0 x

5 B. ^7 E# y$ G! K) z3 k* T, j: v    下面介绍小这个些主控程序主要干的事,通过串口PC和主控板通讯,PC命令给控制板,控制板接收命令做不同的响应,PC可以发G代码给主控板,接收完成后可以自动开始雕刻任务。
8 S/ u8 x: g+ r* Z3 w          在介绍下G代码因为G代码是雕刻机的核心部分
& U4 m5 ~0 P* l" w! lG代码是数控程序中的指令。一般都称为G指令。) p3 x  h' j4 C' y- T9 j
G00------快速定位
6 I; `  |$ ?8 |. }4 N5 u4 o3 zG01------直线插补
( n2 ^/ U5 N5 p% }3 F" bG02------顺时针方向圆弧插补. r/ ~' \! U# W- q5 @: c5 E
G03------逆时针方向圆弧插补
0 d1 c& u  P$ c, eG04------定时暂停
; |5 X2 \5 q4 eG05------通过中间点圆弧插补
. N' Z- ^8 Y- C7 i6 NG06------抛物线插补
4 ?" Q+ o) Y6 N+ D9 ?. MG07------Z 样条曲线插补2 G" f# G4 a( O7 W
G08------进给加速. W; O" _+ z! {. J( B; n
G09------进给减速
5 ?$ r0 e! E4 N6 G2 u4 T; t: YG10------数据设置
, F7 j: A& H9 {5 J) g! LG16------极坐标编程
2 L( n8 Z9 Y% u8 C1 M( KG17------加工XY平面% Y& q* t* G& I
G18------加工XZ平面: p- S5 L9 a( }9 T/ A. ?
G19------加工YZ平面
9 A7 N! x9 ?# @3 L/ O& C. R
核心就是解析G代码,完成步进电机驱动,和控制主轴开启关闭,还有插补算法,直线插补,圆弧插补,还有一些步进电机的加减速算法。1 T) O6 B% i! C% q; J( E! r; t
下面对grbl主结构做介绍
/ Q  O! }4 S' B7 q' _7 @" B# jmain()主函数首先执行下面初始化函数
9 D8 A/ k1 W0 z8 Z/ [2 n3 {        serial_init();                           // 设置串口波特率和中断7 P6 S7 [! X' z9 l
        settings_init();                         // 从ROM加载grbl设置* s# ]/ {& k8 p6 S, C5 a9 p" ]* r2 w! n( }
        stepper_init();                          // 配置步进方向和中断定时器" i& E% w3 W" T7 O
        system_init();                           // 配置引脚分配别针和pin-change中断+ Q0 x7 p$ Q+ i( t4 m, l
        memset(&sys, 0, sizeof(system_t));          // 清除所有系统变量
( z5 \) ]. H, w! y% U        sys.abort = true;                           // 中止标识位置位3 Z6 P) b  h) w1 x! @
        sei();                                         // 使能中断3 p; C. z( _/ |' C
  #ifdef HOMING_INIT_LOCK                        // 宏运算(settings.flags & (1 << 4)) != 0结果flags等于执行sys.state = STATE_ALARM8 [, ~8 ^, X) y+ W; t9 i8 O. D
                                                // 系统状态赋值为报警状态
+ w, R7 d  _8 c! Q! Z            if (bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE)) { sys.state = STATE_ALARM; }
, N3 Q: {- {. j3 J: A8 w# s  #endif6 h+ m( Z$ k- T
_____________________________________________________________________________________________________________________________________
7 \% R& v( [# c# w接下来是一些主要部分初始化( t" I- B0 ~4 ~' C* N9 i
for(;;) {
& F' z4 j+ U; B% \        serial_reset_read_buffer();         //清除串口读缓冲区
; o" J/ H9 P! e1 m. c3 n  S# o- s% Z        gc_init();                         //初始化G代码功能函数
# W& b! ]7 f/ R4 i) P8 }5 J  p. L        spindle_init();                        //主轴初始化
/ ?4 d+ N+ V+ S        coolant_init();                        //冷却液初始化
2 R" H# d- ~+ b  t& ]  N+ X+ J        limits_init();                         //极限开关初始化2 E1 A+ A0 l; O7 Q% g8 N
        probe_init();                        //探测部件初始化
7 r# x: U. _2 B        plan_reset();                         //清除块缓冲区和规划师变量
( b; n( N( d. J! q. a* L        st_reset();                         //清除步进系统变量。- K6 W/ H  n3 y4 ~1 w

: p8 h9 X& ~: @* e, z/ F
: D. Z; p' i* [, m& k' b  j% K* A        //下面两行清除同步gcode和策划师职位当前系统位置。
5 E& p( _. A6 T* ?6 C5 Y
        plan_sync_position();$ n/ ~; K5 ]7 Q' O1 [; T# L. y
        gc_sync_position();0 P. S3 |/ Y( n  K4 W. I: Z8 t4 J

' I  t- L; P1 y  \
# H3 U$ w" A& i# a2 P        //复位系统变量
# a& {* b5 u  X, `  n) x        sys.abort = false;                //系统中止标志
& w; u* Z8 I  U% I8 }        sys_rt_exec_state = 0;                //系统标志位变量状态管理。看到EXEC位掩码。
7 U  J" W" p0 S4 t+ p3 b. B+ P+ c& t        sys_rt_exec_alarm = 0;                //系统标志位变量设置不同的警报。; @/ B% i2 p: q
        sys.suspend = false;                //系统暂停标志位变量管理,取消,和安全保护。
5 j  c: c" N. c" _% P' K$ s        sys.soft_limit = false;                //限位开关限制状态机错误。(布尔)- T: p; \7 ^9 g6 S, y* |

9 [6 {& b" y: v2 K7 v6 W
1 W5 |8 B/ g: p" p; K        protocol_main_loop();                //主协议循环
3 Y9 F7 K( l/ p- |; Z& D7 ~}        //
( i# q6 C8 S+ r$ B_____________________________________________________________________________________________________________________________, v! e8 N, D$ A5 R
进入void protocol_main_loop()函数- h5 F: }% ]' @) ]; v3 o6 Z+ A
{
, p( C5 r9 R* ?& U# X        report_init_message();                // 打印欢迎信息 . L4 W$ P3 |6 Q7 h
        //重启后检验和报告报警状态如果错误重启初始化。
9 [% N2 Z( b$ z( o4 W7 U
        if (sys.state == STATE_ALARM) {
( x% P2 v& J9 ^, y- \& F  r( J            report_feedback_message(MESSAGE_ALARM_LOCK); //打印信息/ C5 i: i) Y' v: {  m! N' ^- u
          } else {
0 J5 v8 Q& u* P8 V7 N            // 如果没有报警说明一切正常!但还是要检查安全门. ( E( L' ~1 b/ w& _; d9 n2 h) [0 I
            if (system_check_safety_door_ajar()) {
5 r0 @% B' X: u+ u: C8 _% o( N4 ?' C                     bit_true(sys_rt_exec_state, EXEC_SAFETY_DOOR);: l( a% v8 h, p% _. ^
                     protocol_execute_realtime(); // 进入安全模式。应该返回空闲状态。2 \. Z) B) i4 R* F. _8 f
            }         else {. x. \2 d' v: I* J9 \
              sys.state = STATE_IDLE; // .设置系统做好准备。清除所有国家国旗。
% p  D; E9 v4 N1 ~# d7 o            } 5 n# G) |9 l! [1 z  u9 q' Y* v
            system_execute_startup(line);    //开始执行系统脚本5 n0 J2 D' q8 _* ~, R3 l
  }
- {! J- n. Y; Y* G" l
" k: }8 o  b6 q6 @8 W# f2 D% u; p! A2 Q! y0 M; K, Z
  // 这是主循环!在系统中止时这是出口回到主函数来重置系统。5 \7 h- ]1 B& F% G/ Y
  // ---------------------------------------------------------------------------------  
# _# V; d6 b! t: ?% B! y  
0 h6 O* A( m7 q5 n        uint8_t comment = COMMENT_NONE;4 ~. _  X: q$ |+ v
        uint8_t char_counter = 0;
) A9 _& z8 K- I9 l4 s        uint8_t c;
0 E  U; o8 a3 l& g9 Q% ~_______________________________________________________________________________________________________________________________% S- w! v8 C: R: M$ T0 x
接下来进入for(;;)循环                //下面代码是G代码解析核心部分,程序中comment(注释)变量会被赋不同值,代表发符号有‘(’‘)’‘;’6 o. H: h5 j7 z8 T8 s
{: I" C1 H& U" M- M+ x2 e/ G: a
//串行数据输入一行的的过程,作为数据。执行一个6 p4 P! J' e' G1 Z' j4 Y8 ^
//所有数据初始过滤去除空格和注释。
% a5 ^. x/ b. o" _3 B1 o! {//注意:注释,空格和程序段删除(如果支持的话)处理技术8 n4 ~7 E8 f, B5 X# U9 C
//在G代码解析器,它有助于压缩到Grbl传入的数据3 d0 o% e+ v" p" ]
//线缓冲区,这是有限的。刀位点标准实际上州一行不行
, _1 m" F  P" C//不能超过256个字符,Arduino Uno没有更多内存空间。. X. O  `, `1 x0 I, _$ s; h
//有更好的处理器,它会很容易把这个初步解析的* d1 L9 {  H: t) N4 ~
//分离任务共享的刀位点解析器和Grbl系统命令。                                                               
8 q* b& J8 N$ |* `    while((c = serial_read()) != SERIAL_NO_DATA) {                             //读取串口数据,有数据执行下面代码
" K5 S2 U( M# |7 A3 {$ C) S      if ((c == '\n') || (c == '\r')) { // End of line reached                //如果数据是/r,/n代表一行结束
- ^  j2 c; G/ C' b4 u9 y2 j        line[char_counter] = 0; // Set string termination character.        //设置结束标志
  c4 k# i4 o# M# B! M# E, z        protocol_execute_line(line); // Line is complete. Execute it!        //一行完成执行此函数
2 w& {/ q/ h+ k8 C% l/ }  W7 s        comment = COMMENT_NONE;                                                //注释清零
2 t5 E7 n' E! _" A6 ?9 S1 A        char_counter = 0;                                                    //字符计数清零/ X$ z" q$ U6 y6 f. x+ k
  1 n0 p2 Q6 v/ K
        else {# F+ q" A& M# w, \) h! A: j& C. [
        if (comment != COMMENT_NONE) {8 x- \+ T9 Z) L
                                                     //扔掉所有注释字符
& i, Q  k7 i2 N$ E          if (c == ')') {
! F. X, t0 E0 G! K8 J            //最后注释。重新开始。但是如果有分号类型的注释。. t7 |8 D8 |$ p. e/ A* u/ V
            if (comment == COMMENT_TYPE_PARENTHESES) { comment = COMMENT_NONE; }4 S+ @- H$ D& i# e
          }7 g9 e: R7 h% R& F
      } else {' \1 K) K: f" ?( D' A
          if (c <= ' ') { 9 M2 O1 P# Z( n5 m2 ~; j
            //扔掉whitepace和控制字符
& O1 a3 d( h: T1 a) [+ D          } else if (c == '/') {
5 C/ b# q6 b) K: T            //块删除不支持将忽略字符。7 r# |: ]( i) \* Q; k
            //注意:如果支持,只需要检查系统是否启用了块删除。, M( M1 B0 I8 I9 k& y
          } else if (c == '(') {" ?6 \9 D! a3 S. {4 |' ]4 |' O/ A
            // Enable comments flag and ignore all characters until ')' or EOL.
# T$ A0 W8 t. _0 c# k6 H6 @0 K( v/ d            // NOTE: This doesn't follow the NIST definition exactly, but is good enough for now.5 m' N% O7 W' h+ a  h6 I
            // In the future, we could simply remove the items within the comments, but retain the  ]6 e% u6 J6 N2 {2 t* G0 r# P
            // comment control characters, so that the g-code parser can error-check it., {2 S0 J! E$ W/ i( ~
            comment = COMMENT_TYPE_PARENTHESES;
) F- u' a2 }6 ]; ~          } else if (c == ';') {; t$ v7 t/ X' W! j4 O
            //注意:','注释EOL LinuxCNC定义。没有国家标准。) \8 Z8 s9 |3 k* n
            comment = COMMENT_TYPE_SEMICOLON;
9 Y$ j6 w* X$ _% r8 G
2 I+ M) G) F4 N/ N/ {; |9 b8 _
% j$ c% T: Z( R6 \$ d. p% B% E_____________________________________________________________________________________________________________________________________9 r' c7 g3 m3 M7 U/ P; c
          } else if (char_counter >= (LINE_BUFFER_SIZE-1)) {                        //串口接收数据大于80字符时1 g! k' L8 r3 R. ^% C3 j, P% m  J
            // Detect line buffer overflow. Report error and reset line buffer.        检测缓冲区溢出。报告错误和复位线缓冲区。
" h( X) x" ]" n3 v  D            report_status_message(STATUS_OVERFLOW);                                //打印溢出信息6 `+ k- f% `" Q
            comment = COMMENT_NONE;9 _5 v0 D8 @1 K$ U
            char_counter = 0;9 s1 u, H7 `, G( m/ Z0 m  \5 s& ]
          } else if (c >= 'a' && c <= 'z') { // Upcase lowercase                        //小写改大写
0 I1 N! q% p0 @3 u# A4 \) U            line[char_counter++] = c-'a'+'A';1 s5 S; h$ ^& h9 M7 r: r
          } else {6 P5 j+ B1 S8 k/ i
            line[char_counter++] = c;8 s' D$ L7 e! s' D2 a6 y
          }
7 p/ x: m4 D+ f  J+ a& q        }
2 J: ^8 C# I7 a      }6 g4 Z/ i5 a( j8 C( e, M
    }3 Z% W2 d( Y: {6 V0 X
____________________________________________________________________________________________________________________________________
& x! k8 \) t. g& d- m        //如果没有其他字符在串行处理读取缓冲区和执行,这表明以完成,自动启动,如果启用,任何队列动作。* B, |8 T; }7 g4 g2 {
        protocol_auto_cycle_start();                //自动开始协议循环
( u& u  y& u# z% e/ R: Z        9 _; n$ x" ]/ ]' G4 E4 Q/ X3 c
            protocol_execute_realtime();                  //运行实时命令。
' I% x" S% W1 z            if (sys.abort) { return; }                 //中止标识置位程序循环重置系统。            ) A  s& V" R2 c9 q) C; R2 r0 q
  }
1 U9 q" B4 U  O4 l' i# H3 G  return;                         //一般程序不会执行到这里
2 C  e* Q( L: a( A}1 v6 s8 ]6 A- h# n+ i7 B  @5 h
____________________________________________________________________________________________________________________________________
7 }# U' p! m  U7 U, T& K正常情况下,读取完G代码程序会进入protocol_auto_cycle_start();//自动开始协议循环 函数下面介绍此函数2 m0 k$ i7 l( }' p3 z& }
// Auto-cycle start has two purposes: 1. Resumes a plan_synchronize() call from a function that
/ P0 _$ U* w3 I4 N' V// requires the planner buffer to empty (spindle enable, dwell, etc.) 2. As a user setting that
4 P2 {! j( G  c( F& O" w// automatically begins the cycle when a user enters a valid motion command manually. This is / j" }3 Z% Y3 ?' `
// intended as a beginners feature to help new users to understand g-code. It can be disabled
( [( t3 D( \, l$ {// as a beginner tool, but (1.) still operates. If disabled, the operation of cycle start is
- N$ B7 G" \) g8 p// manually issuing a cycle start command whenever the user is ready and there is a valid motion ; |9 |& i% }7 J. F( O
// command in the planner queue.# K. a) G$ W+ [  f& K; ]
// NOTE: This function is called from the main loop, buffer sync, and mc_line() only and executes / {, z! d- d- Y" N; |  i, _# l
// when one of these conditions exist respectively: There are no more blocks sent (i.e. streaming
! ?% e  h# y* N! N// is finished, single commands), a command that needs to wait for the motions in the buffer to " A% E# F, R7 C2 ~2 v6 i
// execute calls a buffer sync, or the planner buffer is full and ready to go.
! f) ^/ x* Q! t/ _+ `3 I: J4 I//自动开始有两个目的:1。回复一个plan_synchronize()调用的函数/ I; m* r% F1 y) e
//需要规划师缓冲区空(主轴启用、住等)2。作为一个用户设置- b+ E0 Y2 e. J& ?
//自动循环开始当一个用户输入一个有效的运动命令手动。这是1 q7 U- J2 F/ ?* i% m* ]
//作为一个初学者的特性来帮助新用户了解刀位点。它可以被禁用2 M7 \0 F, I- m/ q! R4 O! n
//作为一个初学者工具,但(1)仍然运作。如果禁用,运行周期开始, O1 @2 G9 C$ r
//手动发出一个周期开始命令每当用户准备好,有一个有效的运动- i# X& V" A9 i7 {
//命令的规划师队列。2 F  t1 ]4 k- y# ]5 R; q
//注意:这个函数被称为从主循环缓冲区同步,mc_line只()并执行8 S  A+ w; a/ ~0 R2 X) ]& i5 V
//当其中一个条件分别存在:没有更多的块(即流发送2 C1 P/ I0 U/ U8 d# n: C
//完成后,单一的命令),一个命令,需要等待缓冲的动作
9 r' V/ r4 D. H* Y2 ^* v//执行调用一个缓冲区同步,或规划师缓冲区满了,准备好了。1 Q) i- D  A. b2 S+ x. t$ g
void protocol_auto_cycle_start() { bit_true_atomic(sys_rt_exec_state, EXEC_CYCLE_START); } 3 g+ M$ [  e5 r$ o3 t& h  P$ o
_______________________________________________________________________________________________8 [2 O3 ^8 y5 M, v
接下来程序运行protocol_execute_realtime(); /运行实时命令。
2 L1 u  M1 o7 q5 |* Q$ N4 @// Executes run-time commands, when required. This is called from various check points in the main9 h3 @$ Z% ]' A  U
// program, primarily where there may be a while loop waiting for a buffer to clear space or any
  Y% v; _5 J8 i- a. ~9 I" M% S// point where the execution time from the last check point may be more than a fraction of a second.# n( \. J6 d. j! N% R
// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code
+ J: D$ [/ \& {. j. n// parsing and planning functions. This function also serves as an interface for the interrupts to
* Q  u  k% D! X6 v// set the system realtime flags, where only the main program handles them, removing the need to
( K' w$ T9 B1 C. p, |6 @; b// define more computationally-expensive volatile variables. This also provides a controlled way to ' _- b, f# Y  Z% b# A8 `2 R
// execute certain tasks without having two or more instances of the same task, such as the planner$ N" t3 {: U9 c: H3 R5 U' Z
// recalculating the buffer upon a feedhold or override.
" V# w& [- w( x// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,
  P, X2 T( M* U* ]- W: e// limit switches, or the main program.0 e4 B; j! J; I- W1 S# p1 O
void protocol_execute_realtime()( N3 w+ x( S  p; R2 d
uint8_t rt_exec; // Temp variable to avoid calling volatile multiple times.临时变量来避免多次调用不稳定。- ]5 O7 A1 Y% H* {% E
就先分享到这吧!% i2 x. n5 [: v1 I6 g  R
( K  V+ y6 c9 H- [. }. G
: ]/ g7 g+ x: S6 r% y0 D

( V$ X3 t, R8 W9 V- t! o+ Z. L
: x8 m( V) Q, x6 D  b" e5 U% J2 N/ L7 W' P1 z

4 S, n* z8 K, n7 A/ i( r
  _$ h+ ]* l3 P' W% l" E" |3 ]! _2 D4 n+ A2 ]0 h- j, U

9 W7 t7 ?% m1 Z* c* f" P- B
0 I, ]! c. g, e8 {& l
0 ^8 Z* g+ z. b+ X) A
! {7 r: P/ ^3 ~: ^& i# U
/ y/ _" ^; F- d% b& h. I5 c8 @+ B
: [3 q% E& n; P: D6 o

( p0 P- \" l9 y; a7 g1 _7 v( H+ ~4 J( n+ z1 b- h( G" ]

) m, |' p  ^2 m' R( Q6 V) S
" N( V- I: _7 ^3 a) f4 X8 @& J
. T) @1 f2 s  H9 N: J1 C

0 c- z  o$ V2 E
; O. T7 X* r) j, k' I" _
+ ?& ?- Y2 P5 Q, w补充内容 (2016-8-25 22:40):' m4 t1 B1 E: f$ q! v, ]5 o- q: S
配置说明
- B  t! W* v& Z' O//这个文件包含编译时配置Grbl的内部系统。在大多数情况下,
. ?7 L; J9 k) y8 W7 n+ R2 d6 N//用户不需要直接修改这些,但是他们在这里为特定的需求,即。& o6 r! v+ l* C3 b8 l6 r) m4 B
//性能调优或适应非典型的机器。& s2 d/ ^5 ^3 R. E
主要配置项:2 `  V% n2 N% D
1.#define DEFAULTS_GENERIC        //在重置eepm时使用。在defaults.h改变想要的名字
* @4 n5 U: |8 `2.#define BAUD_RATE 115200        //配置串口波特率1152005 M7 b2 n5 u! N# Z
3.#define CPU_MAP_ATMEGA328P         // Arduino Uno CPU/ ]( H6 c" j% D. [! [) V
4.#define CMD_STATUS_REPORT '?'        //定义实时命令特殊字符" x, w$ L, _8 Q0 z( D9 [4 {
5.#define HOMING_INIT_LOCK         //回原点保护锁+ k3 l' z& F1 P8 @9 _
6.#define HOMING_CYCLE_0 (1<<Z_AXIS)              // 第一步Z清除工作区。* \* s% v/ E/ `" _) c3 E7 ^; d
  #define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // 然后X,Y在同一时间。
1 p( Y! }. B/ m  W/ a9 i# j  B6 W7.#define N_HOMING_LOCATE_CYCLE 1 //回原点循环次数
- n$ }. U0 N% f; f& W7 E8.#define HOMING_FORCE_SET_ORIGIN //取消这定义迫使Grbl总是在这时候位置设置机器原点尽管开关方向。+ c7 }7 c7 B+ L6 G
9.#define N_STARTUP_LINE 2 //块Grbl启动时执行的数量。/ \- _- l2 ~- k7 n
10.#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 协调或位置价值英寸/ L9 V% H/ Y; H$ ~
   #define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 协调在毫米或位置价值  G6 _3 Q5 m3 ?
   #define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分钟的速度值
! c; u. w1 J% O* d$ ^: w   #define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分钟
, f; D7 P9 Y1 P! j   #define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 对浮点小数设置值! T. P) k$ U3 K7 f9 g
11.#define LIMITS_TWO_SWITCHES_ON_AXES //如果你的机器有两个极限开关连接在平行于一个轴,您需要启用这个特性+ {5 z" _. P4 n3 _
12.#define USE_LINE_NUMBERS         //允许GRBL跟踪和报告gcode行号
5 Y+ F3 A7 \3 D: J! Z3 j: a13.#define REPORT_REALTIME_RATE //允许GRBL报告实时进给速率
+ b9 l# i! O- x* d( X/ ^: P" X: j14.#define MESSAGE_PROBE_COORDINATES  //坐标通过Grbl $ #的打印参数?
% b! J# W! Y7 ]9 W, G15.#define SAFETY_DOOR_SPINDLE_DELAY 4000 //安全门主轴延时
- @, }  f' @; @  U16.#define SAFETY_DOOR_COOLANT_DELAY 1000 //安全门冷却液延时
: N' B# V& l* S' S3 @8 b) n17.#define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS) //启用CoreXY运动学。, V* u+ T3 S% P8 a
18.#define COREXY // Default disabled. Uncomment to enable.改变X和Y轴的运动原理% w3 y# @2 L5 Q9 g& D& _( B
19.#define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.反转针销逻辑的控制命令) \) D2 L( Q4 j" f; {. i$ J
20.#define INVERT_SPINDLE_ENABLE_PIN // 反转主轴使销从low-disabled
! \+ R, ~# Q6 J( N21.#define REPORT_CONTROL_PIN_STATE //启用控制销状态反馈状态报告。
" V$ x) f+ [6 R8 ]1 b22.#define FORCE_INITIALIZATION_ALARM //启用和用户安装限位开关,Grbl将启动报警状态指示
: I; K- s8 j0 C1 `/ V/ @( G23.#define REPORT_GUI_MODE // gui允许最小的报告反馈模式
* x7 T, }  o6 R! P1 M8 N! o  F24.#define ACCELERATION_TICKS_PER_SECOND 100 //加速度的时间分辨率管理子系统。
* X; v2 B- S$ \% Y25.#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING //自适应多轴步平滑(积累)是一种先进的功能
9 i! r1 x" M6 K: O$ X" D+ L26.#define MAX_STEP_RATE_HZ 30000 //设置最大一步速率可以写成Grbl设置/ U: ?( A, t# F3 q) w" u
27.#define DISABLE_LIMIT_PIN_PULL_UP //以下选项禁用内部上拉电阻
9 ^* x' h# t! g. \, O) J( S$ L28.#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS //设置哪个轴长度补偿应用的工具。假设轴总是与选择轴工具面向负方向
9 m4 w( r( ~  U; w4 I29.#define VARIABLE_SPINDLE //允许变量轴输出电压不同的转速值。5 Z( _8 ]# X7 K
30.#define SPINDLE_MAX_RPM 1000.0  // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.- _- u/ j6 h" ]- [
   #define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.
! [3 x+ m' ~6 G; ~* o' F31.#define MINIMUM_SPINDLE_PWM 5 //使用的变量轴输出。这迫使PWM输出最小占空比时启用。! H- c: ~- c( e
32.#define USE_SPINDLE_DIR_AS_ENABLE_PIN //主轴方向使能M4被删除
% ]+ O7 D0 B! Z' ]33.#define REPORT_ECHO_LINE_RECEIVED //应该对所有正常线路送到Grbl
: `7 h) \+ k0 f6 F+ T+ R34.#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min) //最小规划师结速度。设置默认最小连接速度规划计划0 P. N8 W6 u0 ~# |6 |
35.#define MINIMUM_FEED_RATE 1.0 // (mm/min)//设置计划将允许的最小进给速率( z4 u! R" \9 R5 S
36.#define N_ARC_CORRECTION 12 //弧生成迭代次数之前小角度近似精确的弧线轨迹+ m8 A# y2 Z: |
37.#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)//定义值设置机器ε截止来确定电弧是一个原点了?) q) W  r/ D5 o  r: \9 r2 d; B1 K
38.#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds) //延时增加表现在住。默认值设置为50毫秒
5 I; g0 W, E% O7 Q  ~39.#define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.
' I+ Y  S+ w5 q4 t3 Y$ V40.#define BLOCK_BUFFER_SIZE 18  //线性运动规划师缓冲区的数量在任何给出时间计划
) H; @6 W7 N5 w  o2 e41.#define SEGMENT_BUFFER_SIZE 6 //控制之间的中间段缓冲大小的步骤执行算法
( Y% W) t  K) U+ e$ F0 e6 V/ G( I42.#define LINE_BUFFER_SIZE 80 //行执行串行输入流的缓冲区大小。
& g( S3 k4 b+ i, B43.define RX_BUFFER_SIZE 128 //串行发送和接收缓冲区大小
) A- F% ?  |3 y44.#define TX_BUFFER_SIZE 64/ i' e  p; {: s+ D" d/ d$ e
45.#define ENABLE_XONXOFF        ////切换为串行通信发送流软件流控制。' i4 `% B2 E/ o& h5 m
46.#define ENABLE_SOFTWARE_DEBOUNCE //一个简单的软件消除抖动特性硬限位开关。
0 S8 x$ h' a$ n' e! O, F47.#define HARD_LIMIT_FORCE_STATE_CHECK        //Grbl检查硬限位开关的状态
+ h4 G, P- }" \, u2 H0 p48.// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:编译时错误检查的定义值:5 ]; T3 i7 k: k6 q) _

9 ?5 V, a9 q4 G: s___________________________________________________________________________________________________
8 {6 ]  b- ^3 u- u8 Y3 m! |/*, B  d' K! b; Z. z
  config.h - compile time configuration
* Q$ X# a6 i5 Z; |  Part of Grbl
8 i( W8 A, o  s1 G3 d2 F& e% E# u9 g4 w) E, m& y2 p
  Copyright (c) 2012-2015 Sungeun K. Jeon
4 Q% P" |7 _9 c  _$ v/ g6 @  Copyright (c) 2009-2011 Simen Svale Skogsrud2 V8 U$ w$ X6 W' N9 k4 j  C% ]$ J

# ~- |# h# s/ F( ]9 D  A  Grbl is free software: you can redistribute it and/or modify* k% _0 `1 \9 J3 n/ h
  it under the terms of the GNU General Public License as published by
9 @+ L" Q- r2 p) s& e  the Free Software Foundation, either version 3 of the License, or' ~4 n' ]  }- X& a" O
  (at your option) any later version.
8 ^3 K+ c) N( W% L* i: ^: A, o0 u; Q  Z; l
( I* ~0 F9 h+ d. |! ~1 H  Grbl is distributed in the hope that it will be useful,2 j2 A: _4 Y9 o; ?* E, k# a& o# e
  but WITHOUT ANY WARRANTY; without even the implied warranty of
* T  T& _' W# u+ q: _0 ?  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the% v- q5 Q  b! S" d/ z
  GNU General Public License for more details.
" C( \. f& v7 n( C0 u: o5 @) h7 F. [0 X, ]5 [9 q
  You should have received a copy of the GNU General Public License
3 g2 \) E8 x8 o" P  along with Grbl.  If not, see <http://www.gnu.org/licenses/>.0 B# z: }; [$ a& }
config.h  -编译时配置,Grbl的一部分# y/ ~" P: U5 |6 o" d
- A4 g2 O( \, b. o
版权(c)2012 - 2015 Sungeun K. Jeon# O) W' ]( V: `# q' H* L: V! G( q
版权(c)2009 - 2011 Simen Svale Skogsrud
1 d4 c0 U9 Z. X$ E/ o* w* K+ j" i$ n& c! ~% c9 Y- K
Grbl是免费软件:可以重新分配和/或修改) C; x: G$ ^! B
GNU通用公共许可证的条款下发布的自由软件基金会,版本3的许可,或(任您选)其后的版本。
) [) D* e% r1 p0 a
1 l: l$ v2 o3 fGrbl分布,希望这将是有用的,但是没有任何保证;没有即使的默示保证适销性或健身为特定目的。看到6 c: ~/ G* D0 \5 z' {0 Q1 x
GNU通用公共许可证的更多细节。
  {% X+ w% H* n0 U6 ^( I" Q
' C  ?. Q2 O8 L7 j$ \) ~你应该收到了GNU通用公共许可证的副本
, ]. |" a0 i" r; C3 u4 T/ n连同Grbl。如果没有,看< http://www.gnu.org/licenses/ >。
( b" r2 `7 _* Q$ V9 L6 f1 Q
6 D; d2 F9 N" l*/
9 a& g0 n$ D8 p+ g/ X  E  
8 H2 ?2 J- x. s% `: l2 j// This file contains compile-time configurations for Grbl's internal system. For the most part,& s( [' Z2 w; h2 l
// users will not need to directly modify these, but they are here for specific needs, i.e.; d2 n  u; y6 a( I7 I, D
// performance tuning or adjusting to non-typical machines.
5 P8 ]% u4 e3 O9 g9 F; c! @9 t//这个文件包含编译时配置Grbl的内部系统。在大多数情况下,
- f5 H( z4 N. A/ d0 [% l' A//用户不需要直接修改这些,但是他们在这里为特定的需求,即。
+ ^- H1 `& k. y2 n3 O//性能调优或适应非典型的机器。
! p1 B. J: D7 G& V7 t* Q# E8 x3 P+ x, Y8 B
// IMPORTANT: Any changes here requires a full re-compiling of the source code to propagate them.
: \7 d3 c$ |' L//重要:任何变化需要一个完整的基于源代码的传播。/ L$ r. K7 i* m% \1 L% T

0 Q" |) ?( s: F5 d- N5 B  J& {#ifndef config_h) M4 H1 n( g- B6 S
#define config_h
2 m: f9 `* p6 ]/ F& @8 a4 T* J, T0 L#include "grbl.h" // For Arduino IDE compatibility.
8 ]% m5 |, E- r4 x1 U4 m
& I& M, K) Z  m0 d2 D// Default settings. Used when resetting EEPROM. Change to desired name in defaults.h, v, x0 l6 Z& @
// 默认设置。在重置eepm时使用。在defaults.h改变想要的名字
$ M: k% f" `# N) v' k+ ]
& l2 ^8 q( z: u: U% |) E! C#define DEFAULTS_GENERIC
8 o" z' v& c( g! X* [( v( T3 O  e$ U6 x1 Z/ |  Y  O3 {3 U8 Q
// Serial baud rate
  K; T% U- `2 v/ ]# s#define BAUD_RATE 115200                //配置串口波特率115200  d5 t) Q% e. y  y) t/ _

6 l; \' B8 t  X4 Y. n  H// Default cpu mappings. Grbl officially supports the Arduino Uno only. Other processor types
! ?9 v  s+ d; V// may exist from user-supplied templates or directly user-defined in cpu_map.h5 }% e) U7 C- f; g% A  b/ ]
//默认cpu映射。Grbl正式支持Arduino Uno。其他类型的处理器可能存在cpu_map.h直接从用户提供的模板或用户定义的
( M2 X8 P+ k3 R1 o3 P: D* Q3 B' l2 ?2 `8 m2 w
#define CPU_MAP_ATMEGA328P // Arduino Uno CPU
$ \  x% u) _% o+ P3 ?( h0 W9 R6 _+ \+ h3 _
// Define realtime command special characters. These characters are 'picked-off' directly from the. r  I8 {% ]# B* ?9 G' R8 T
// serial read data stream and are not passed to the grbl line execution parser. Select characters; B; ]7 C0 r9 F
// that do not and must not exist in the streamed g-code program. ASCII control characters may be
( u* Q* A6 S" j& y' L) z// used, if they are available per user setup. Also, extended ASCII codes (>127), which are never in ' q: i. _# \. ^; M* h5 Y
// g-code programs, maybe selected for interface programs.& }) ~3 X1 X( z) B* V
// NOTE: If changed, manually update help message in report.c.
2 y$ ]! s, o+ o% _& o
- t# @9 @* L! u6 w7 @/ Q* \" d( {//定义实时命令特殊字符。这些字符是直接从“各个击破”串口读取数据流并没有传递到grbl行执行解析器。选择角色
& e, @6 _" `% g$ P//不,不能存在于程序流刀位点。ASCII控制字符
- I& \/ X7 s! X2 A" \( K//使用,如果他们是可用的每个用户设置。同时,扩展的ASCII码(> 127),从来没有
  S5 r& }5 w! U1 U' g5 d//刀位点的程序,也许选择界面程序。- M* D" U3 Q  C8 y' U/ }( ]9 i
//注意:如果改变,手动更新report.c帮助信息。
. [' K* u( v7 Y9 [3 Z; T3 A  Z1 T# H7 ?0 H( h. t" y* c7 O+ S* |
#define CMD_STATUS_REPORT '?'6 D1 o% b) x( v( w# g, E
#define CMD_FEED_HOLD '!'
; g( o, i0 o" {, f0 [3 h0 |; v#define CMD_CYCLE_START '~'6 i( s0 N- @0 F5 E
#define CMD_RESET 0x18 // ctrl-x.) d: U3 K2 _% }4 ~3 Y  n
#define CMD_SAFETY_DOOR '@') R# H  M  k" i( d; G

, l: \+ l! d6 u8 P( Y5 B; Z, s0 j// If homing is enabled, homing init lock sets Grbl into an alarm state upon power up. This forces5 m/ x3 \/ \% f0 F
// the user to perform the homing cycle (or override the locks) before doing anything else. This is+ C9 W$ d$ {" {2 y) I1 @( G
// mainly a safety feature to remind the user to home, since position is unknown to Grbl.
4 ]' R( I5 ?$ N5 ?" O0 d% |% g1 N0 a
3 Z2 g3 w) N$ L2 I//如果启用了回原点,导航初始化锁集Grbl进入警报状态启动。这就迫使+ Q* }4 ?8 r* U4 N$ e
//用户执行归航周期(或覆盖锁)在做任何其他事情之前。这是
0 L3 o' q' a! Q0 q3 k* n: R" O6 s//主要安全功能,提醒用户家里,因为Grbl位置是未知的。7 y2 e. n3 N0 _6 c4 ?% u
% ^, j) w: c& B& R. V
#define HOMING_INIT_LOCK // Comment to disable* p. P) T! Z1 J4 ~% ~0 z
$ M6 |- N2 l9 r' \
// Define the homing cycle patterns with bitmasks. The homing cycle first performs a search mode
7 s% R  Y: Z/ R, e// to quickly engage the limit switches, followed by a slower locate mode, and finished by a short
( L6 c8 z( v* p0 ]// pull-off motion to disengage the limit switches. The following HOMING_CYCLE_x defines are executed
& d# F, l: Y6 A// in order starting with suffix 0 and completes the homing routine for the specified-axes only. If5 l& y3 \, l& \
// an axis is omitted from the defines, it will not home, nor will the system update its position.$ D4 W7 d8 t: a4 F% m7 z# E) W
// Meaning that this allows for users with non-standard cartesian machines, such as a lathe (x then z,( N, }) h. t8 i! o' k9 \
// with no y), to configure the homing cycle behavior to their needs. 1 |  Q6 |. I) P
// NOTE: The homing cycle is designed to allow sharing of limit pins, if the axes are not in the same- m2 `  v6 K& k
// cycle, but this requires some pin settings changes in cpu_map.h file. For example, the default homing! F- t6 k: G5 a$ v( s' _& e
// cycle can share the Z limit pin with either X or Y limit pins, since they are on different cycles.
, V+ |( o: f4 s( }8 e// By sharing a pin, this frees up a precious IO pin for other purposes. In theory, all axes limit pins
* n# w9 Y+ e& x# D  M% j// may be reduced to one pin, if all axes are homed with seperate cycles, or vice versa, all three axes
0 U: L$ A6 Q/ E1 f  A  U. k7 r! p// on separate pin, but homed in one cycle. Also, it should be noted that the function of hard limits 9 _5 W( T9 r3 _
// will not be affected by pin sharing.5 ]( A4 U6 ^6 W" I+ d7 C$ b& s
//定义导航循环模式的位掩码。归航周期首先执行一个搜索模式7 p: U' L% ]* D0 P& i1 |
//快速进行限位开关,其次是较慢的定位模式,完成了由一个短4 ^7 f9 n/ Y. ^' K+ h3 X: \* {
//拖出运动脱离限位开关。以下HOMING_CYCLE_x定义执行) s& b$ v& b4 ]2 D
//为了与后缀0开始并完成specified-axes只寻的例程。如果& k% P6 Z# j9 x
//定义省略一个轴,它会不在家,也不会系统更新它的位置。
( K- H; n' Z5 Y# j4 D8 C7 k//意义,这允许用户与非标准笛卡尔的机器,比如车床(x,z,0 ^& |- M2 @) {$ ^
//没有y),配置导航循环行为对他们的需求。
; c# M' x. |! F//注意:归航周期允许共享限制针,如果轴不相同6 w; x( Y9 ^" r: D) p% p7 T" t
//循环,但这需要一些销设置cpu_map的变化。h文件。例如,默认的导航! u; ~: W  K! s/ W; Y
//循环可以分享Z限位销X或Y限制针,因为它们是在不同的周期。7 \7 ?$ K2 h5 d/ I7 c/ }
//通过共享一个销,这腾出宝贵的IO销用于其他目的。从理论上讲,所有轴限制别针3 D1 n" V3 r2 M
//可能会减少到一个销,如果所有轴与分离周期居住的地方,反之亦然,所有三个轴/ c3 u1 V9 e+ [7 o* d  l8 y
//在不同销,但这时候一个周期。同时,应该注意的是,硬限制的功能' [/ g! @7 ~* R5 v6 e8 L4 T
//将不会影响销共享。; x+ y0 @1 M7 @' C5 }
//注意:默认设置为一个传统的硬件数控机器。z轴首次明确,其次是X和Y。  F1 h( ^, J5 g$ B8 ^- r

$ e" {6 {# ]9 C. C: |: a) z8 G3 ~// NOTE: Defaults are set for a traditional 3-axis CNC machine. Z-axis first to clear, followed by X & Y.
1 `' `* ^6 `. R: ~#define HOMING_CYCLE_0 (1<<Z_AXIS)                // REQUIRED: First move Z to clear workspace. 第一步Z清除工作区。
& T0 o+ ?" m" m1 |#define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // OPTIONAL: Then move X,Y at the same time.然后X,Y在同一时间。
! n9 x6 T+ Q9 H/ I9 I( r+ P// #define HOMING_CYCLE_2                         // OPTIONAL: Uncomment and add axes mask to enable: b* q4 @$ X! ^+ P, _

2 l, N( n9 V' `2 C" S) M9 e* G// Number of homing cycles performed after when the machine initially jogs to limit switches.
7 D% O" r: z( l- [2 `+ L// This help in preventing overshoot and should improve repeatability. This value should be one or ; l0 i1 h+ L: W0 P- q- Z( q) q
// greater.
% m/ k. m+ W, a* A+ _//执行回原点循环次数后,当机器最初慢跑限位开关。这个帮助防止过度,应该提高重复性。这个值应该是一个或大。1 n" F4 |: a6 x5 A: S

0 r" q6 G1 V$ k/ }#define N_HOMING_LOCATE_CYCLE 1 // Integer (1-128)$ U! R, ?( f* V& w$ `% N/ z
  p* F! B5 s$ z7 X# S0 R2 x1 O6 i
// After homing, Grbl will set by default the entire machine space into negative space, as is typical
- T- w4 `5 }, f; H// for professional CNC machines, regardless of where the limit switches are located. Uncomment this
9 Q- ?- z6 _: Y$ h/ G0 W; `7 l// define to force Grbl to always set the machine origin at the homed location despite switch orientation.) k4 k7 a( a0 S: F- Z$ S
5 H! e7 C$ O9 K# g: M4 Y7 k. `' O* V
//导航后,默认Grbl将整个机器空间留白,是典型的专业数控机器,不管限位开关所在的地方。/ y' |4 s0 K8 M& D' C3 I: m- |/ f( T
//取消这定义迫使Grbl总是在这时候位置设置机器原点尽管开关方向。
% L9 y& b4 v/ J: w6 s4 K( H
% _& Z; e! W3 p$ j. d; J// #define HOMING_FORCE_SET_ORIGIN // Uncomment to enable.
1 l/ b( I2 s/ e+ M
8 c9 K( C/ h: e* `5 w8 X. {8 C! O& [4 M: G0 F
// Number of blocks Grbl executes upon startup. These blocks are stored in EEPROM, where the size  A- i7 ?5 b% l& ?% t2 v
// and addresses are defined in settings.h. With the current settings, up to 2 startup blocks may3 I5 ?3 s! S3 _
// be stored and executed in order. These startup blocks would typically be used to set the g-code
6 c6 k. n, i5 Z: y, {2 s8 ^// parser state depending on user preferences.2 y' t6 ?# S8 c5 `" Y* u0 t3 d
" u6 }/ Q& i- i9 W
//块Grbl启动时执行的数量。这些块存储在eepm,大小+ e# N- x+ o0 A
//和地址在settings.h中定义。与当前设置,可能2启动块
7 U8 ^7 A: z2 k- v7 V0 v" l+ h//存储和执行。这些启动块通常被用来设置刀位点
, r6 ^2 C2 v( \: ?9 q' C% \4 y//解析器的状态取决于用户首选项。
9 P" j! I5 f5 G. g, `; g) q
! b# f, M) d3 o#define N_STARTUP_LINE 2 // Integer (1-2)! q5 n* y* O6 ^
  P/ b3 G; f# s. p. O  x
// Number of floating decimal points printed by Grbl for certain value types. These settings are # m7 q) S3 c! F0 d! j
// determined by realistic and commonly observed values in CNC machines. For example, position5 \& j' M; E3 A) u/ r2 F& L
// values cannot be less than 0.001mm or 0.0001in, because machines can not be physically more
. K5 h- t  m' W( R  F, E$ q$ L, r// precise this. So, there is likely no need to change these, but you can if you need to here.! z- Z5 v9 M" S1 X' {; j
// NOTE: Must be an integer value from 0 to ~4. More than 4 may exhibit round-off errors.3 w( z, Y9 m! I* b  X, ]
0 W  o8 j/ g5 I. S% ^6 M2 O
// Grbl浮动小数点的数字印刷的特定的值类型。这些设置是7 l7 N/ h8 m4 c# x3 n# p+ i$ G
//一般由现实和观测值在数控机器。例如,位置
( w/ {5 m, D: `' G//值不能小于0.001毫米或0.0001,因为机器不能身体更多8 e. \/ I) [4 y% s4 v7 f
//精确。因此,有可能不需要改变这些,但你可以在这里如果你需要。( D4 J4 B/ P. R% L! h
//注意:必须是一个整数值从0 ~ 4。超过4可能出现舍入错误。; ]; d  A+ _9 k  J7 p* k

  g7 A( v9 B3 s#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 协调或位置价值英寸
2 ]4 o" E' r2 P' S! d#define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 协调在毫米或位置价值" d0 q8 h/ h; n$ D
#define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分钟的速度值. S0 R% d% G7 C. U% \
#define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分钟# B" f. Z& Y( Y$ G+ f) l
#define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 对浮点小数设置值# j/ D, _: r5 I, Z- e9 Q  B" X

; F  e5 y7 E, _7 u2 x// If your machine has two limits switches wired in parallel to one axis, you will need to enable2 J( z* d6 u: }' ^( P3 t! G
// this feature. Since the two switches are sharing a single pin, there is no way for Grbl to tell
8 O! o% l0 _5 ^+ P' B// which one is enabled. This option only effects homing, where if a limit is engaged, Grbl will
$ ^% A& L$ O) j% o+ L6 U9 q' s+ Q// alarm out and force the user to manually disengage the limit switch. Otherwise, if you have one& c, s+ Q+ i! Z, Q! n/ k5 A$ P
// limit switch for each axis, don't enable this option. By keeping it disabled, you can perform a
5 g% r( Z6 V" Q+ ]9 j6 M2 g// homing cycle while on the limit switch and not have to move the machine off of it.( Y* @1 `! B$ o6 r  `# W, x+ s# b. a
# u4 m6 T& R' ^2 J$ W; a
//如果你的机器有两个极限开关连接在平行于一个轴,您需要启用7 [- k4 @# X* f: i3 ^
//这个特性。自从两个交换机共享一个销,没有办法Grbl告诉
( y* z& D2 t" ]) P# x//启用哪一个。此选项仅影响归航,如果限制,Grbl意志
7 G) P- o+ l6 |4 ]- }( `0 U//报警,迫使用户手动松开限位开关。否则,如果你有一个2 W; K3 T/ i  x
//为每个轴限位开关,不启用该选项。通过保持禁用,您可以执行( G# M) N7 i9 }& x2 O
//导航循环在限位开关并没有将这台机器。4 s1 r$ V/ |; v, F. w* k! E* V4 Q
, U$ l1 P2 D6 C2 n, [
// #define LIMITS_TWO_SWITCHES_ON_AXES
( F; x, W- h& T3 D/ R
. z: H# M  f7 O1 E+ q: M0 h// Allows GRBL to track and report gcode line numbers.  Enabling this means that the planning buffer* i7 r% G6 Z( l% x6 W/ L
// goes from 18 or 16 to make room for the additional line number data in the plan_block_t struct
$ a  u3 s0 i, @2 m. f
! M6 y4 Y4 J: U- f' O//允许GRBL跟踪和报告gcode行号。使这意味着计划缓冲从18岁或16岁,为额外的行号plan_block_t结构中的数据
" w/ Q: ?! [, X
- C# P6 G5 r8 O# y// #define USE_LINE_NUMBERS // Disabled by default. Uncomment to enable.+ ]  O! u) D3 T, u8 i  c5 a
/ F5 G1 A5 h! }' `) \3 C
// Allows GRBL to report the real-time feed rate.  Enabling this means that GRBL will be reporting more
5 u6 h; W$ n8 u" F// data with each status update.
6 W, O) T# _8 I$ \( m, ]. Y2 F// NOTE: This is experimental and doesn't quite work 100%. Maybe fixed or refactored later.
6 [- ^. i$ W# o+ Z2 Z/ J/ }//允许GRBL报告实时进给速率。使这意味着GRBL将报告数据和状态更新。
  s! u$ P1 d4 }, O: b2 k//注意:这是实验和100%没有工作。也许以后固定或重构。
" S5 _8 r- O0 s; B
1 O0 V6 Y" T4 s$ x3 S+ {0 f// #define REPORT_REALTIME_RATE // Disabled by default. Uncomment to enable.2 A8 M7 r9 U+ V2 F. i6 D4 s$ |$ g9 V

( i4 m% b! w# w// Upon a successful probe cycle, this option provides immediately feedback of the probe coordinates/ D4 F4 [2 _) c
// through an automatically generated message. If disabled, users can still access the last probe9 Q7 U( Z2 q) q: d5 Y) i
// coordinates through Grbl '$#' print parameters.8 p* l: _5 Y# P! f( ~
//在一个成功的调查周期,这个选项提供立即反馈的探测器坐标
3 P! [5 M8 R$ s/ V3 ]: |5 j//通过一个自动生成的消息。如果禁用,用户仍然能够访问调查2 L0 M( i4 X! T5 U. Y
//坐标通过Grbl $ #的打印参数。* [3 a0 h- @$ {# f& M. e

& a* M2 w4 u+ ^- u) Y, ~, C3 f#define MESSAGE_PROBE_COORDINATES // Enabled by default. Comment to disable.! H4 h: q  X& S: U% g' ]
5 e, N8 y3 y0 f; P, [
// Enables a second coolant control pin via the mist coolant g-code command M7 on the Arduino Uno( `- e3 Z7 x3 q- t$ L
// analog pin 5. Only use this option if you require a second coolant control pin.1 }5 a/ W" S, q
// NOTE: The M8 flood coolant control pin on analog pin 4 will still be functional regardless.1 t; k! F* X2 m/ Z# X- m! Z, O
// #define ENABLE_M7 // Disabled by default. Uncomment to enable.
* A% m6 z; Q4 W9 H8 x( o3 c. _: g5 R/ e. P
// This option causes the feed hold input to act as a safety door switch. A safety door, when triggered,. I1 [6 a3 n- U
// immediately forces a feed hold and then safely de-energizes the machine. Resuming is blocked until
7 T' a+ A1 s! M4 F8 t// the safety door is re-engaged. When it is, Grbl will re-energize the machine and then resume on the2 u9 r) D# G  u
// previous tool path, as if nothing happened.7 A/ q: Z5 v+ H# h8 R9 ]% M$ Y! p
// #define ENABLE_SAFETY_DOOR_INPUT_PIN // Default disabled. Uncomment to enable.5 K9 I& R! w" Q' i! j

' x9 o" V' S3 E2 V0 [! G% M// After the safety door switch has been toggled and restored, this setting sets the power-up delay, N: T8 s' ^: F! `+ O6 H; v
// between restoring the spindle and coolant and resuming the cycle.
0 X" l% _1 O, M) I// NOTE: Delay value is defined in milliseconds from zero to 65,535. & F2 B8 k; g8 z3 F: ~

7 D5 c; P$ Z# N3 N$ i4 T4 \//定义导航循环模式的位掩码。归航周期首先执行一个搜索模式: D  s1 L3 ]: K6 q2 g5 Y
//快速进行限位开关,其次是较慢的定位模式,完成了由一个短
3 L2 L3 Z6 P" w; _//拖出运动脱离限位开关。以下HOMING_CYCLE_x定义执行
7 V" a# K% k: i/ X//为了与后缀0开始并完成specified-axes只寻的例程。如果2 x: d/ x; B, c3 o
//定义省略一个轴,它会不在家,也不会系统更新它的位置。
* n" W; _- T: s/ L  T- L//意义,这允许用户与非标准笛卡尔的机器,比如车床(x,z,
% s2 j% A6 T" e" k7 p' d//没有y),配置导航循环行为对他们的需求。$ ~5 p6 g8 p) M; {& X) I' F
//注意:归航周期允许共享限制针,如果轴不相同. h  O8 [4 O6 J' ?
//循环,但这需要一些销设置cpu_map的变化。h文件。例如,默认的导航
' [% z" m% @$ g' [8 A7 }9 X5 R2 J//循环可以分享Z限位销X或Y限制针,因为它们是在不同的周期。: a" A" s  w5 g; R8 i9 p
//通过共享一个销,这腾出宝贵的IO销用于其他目的。从理论上讲,所有轴限制别针8 |% X8 P6 a8 e9 i' C0 C* u/ a
//可能会减少到一个销,如果所有轴与分离周期居住的地方,反之亦然,所有三个轴
  D: s' ~3 J. R# {# F5 [//在不同销,但这时候一个周期。同时,应该注意的是,硬限制的功能# g: m' A2 V7 W! l. O* C0 ?" |  _
//将不会影响销共享。
+ W% S/ C& v0 T. D) g, \//注意:默认设置为一个传统的硬件数控机器。z轴首次明确,其次是X和Y。; S+ r( K% Z# f& [( j
0 u( j9 W' W( v. s$ {

. I' M  U5 T" q  Z& e1 e: h#define SAFETY_DOOR_SPINDLE_DELAY 4000
& t% I  K1 n6 }/ U9 ?+ K) ~1 s0 K0 [#define SAFETY_DOOR_COOLANT_DELAY 10006 |; _" u/ f2 V/ h) P) P
& W3 h3 d# T2 ]6 V
// Enable CoreXY kinematics. Use ONLY with CoreXY machines.
/ q# m$ u- ]  @( i+ S9 d# E* X// IMPORTANT: If homing is enabled, you must reconfigure the homing cycle #defines above to - x) E/ t) i! i# _" A8 _/ ~
//启用CoreXY运动学。只使用与CoreXY机器。6 f8 J! G/ H6 F6 |1 O+ _
//重要:如果启用了自动寻的,你必须重新配置导航循环#定义上面
& h3 P7 I$ n7 g/ x( o# c: Y1 Q6 G
// #define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS)
+ }5 I5 {  }; h( p7 z+ e
: C3 H- O) @4 I// NOTE: This configuration option alters the motion of the X and Y axes to principle of operation2 I$ p  O6 p' J; t7 V" t. ^
// defined at (http://corexy.com/theory.html). Motors are assumed to positioned and wired exactly as
  B, Z8 O) y2 ]$ o3 t// described, if not, motions may move in strange directions. Grbl assumes the CoreXY A and B motors
: N3 J# r% v4 R// have the same steps per mm internally.# J6 k4 ^$ T, O8 }+ }7 J# l7 u
//注意:这种配置选项改变X和Y轴的运动原理,操作$ I4 r5 h# T$ Q0 f2 o9 d
//定义(http://corexy.com/theory.html)。汽车被认为定位和连接一样; O7 x0 ~' H. o+ Z0 X; t
//描述,如果没有,运动可能会奇怪的方向移动。A和B Grbl假设CoreXY马达
+ S: [) R1 O5 m" ?; y//每毫米内部有相同的步骤。
, p# f5 g& o, D3 t5 W$ o2 a
6 j% Q- ^3 I/ i  \// #define COREXY // Default disabled. Uncomment to enable.$ ]4 s4 Y# D% o- @

5 b: W. I7 s* R& N6 {  w* g// Inverts pin logic of the control command pins. This essentially means when this option is enabled
5 c5 T' c. D$ B, Q" H5 b// you can use normally-closed switches, rather than the default normally-open switches.+ H' z" ~; `" A1 E* I
// NOTE: Will eventually be added to Grbl settings in v1.0.! G! J- Z% V# R3 s( {/ ]. O
//反转针销逻辑的控制命令。这实质上意味着当启用这个选项  v7 E. Q$ R- Z  J- [0 Q; p
//可以使用闭合开关,而不是默认的常开开关。0 J2 \( U6 o! S' N
//注意:最终将被添加到在v1.0 Grbl设置。% E" e- n+ C0 M& U7 b4 X3 e

0 \" E! A% ?5 Y0 j5 s- H4 b( q/ ~// #define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.
/ a7 G3 k" N2 Y) g; x0 T) b9 w5 i6 X/ }8 t1 |$ m
// Inverts the spindle enable pin from low-disabled/high-enabled to low-enabled/high-disabled. Useful! v, l+ c* d" S
// for some pre-built electronic boards.8 B% P# T2 f! d% V6 ]
// NOTE: If VARIABLE_SPINDLE is enabled(default), this option has no effect as the PWM output and
; N4 I0 I/ J( k  @4 d// spindle enable are combined to one pin. If you need both this option and spindle speed PWM, $ |* E0 f, @- Z& g) H
// uncomment the config option USE_SPINDLE_DIR_AS_ENABLE_PIN below.
1 V! K- W' K- Q) I  q( b//反转主轴使销从low-disabled / high-enabled low-enabled / high-disabled。有用的
: r6 B. L$ _$ I' e* n//预构建的电子板。, s8 }) b* T" B6 l4 F% m; W
//注意:如果启用了VARIABLE_SPINDLE(默认),这个选项作为PWM输出并没有影响
: _. `! h- M5 d9 p//销轴使结合。如果你需要这个选项和主轴转速PWM,. N* h. M* o) M" U$ I% T6 d" z4 {
//取消注释以下配置选项USE_SPINDLE_DIR_AS_ENABLE_PIN
9 A( X) r4 Z* Z1 p4 ]  X. {
2 F$ [1 v( K; T$ x// #define INVERT_SPINDLE_ENABLE_PIN // Default disabled. Uncomment to enable.; U; g4 U' m( A! ?

$ c* t, s, i+ E) N9 D; S// Enable control pin states feedback in status reports. The data is presented as simple binary of
: Z6 x$ [$ R" _  O// the control pin port (0 (low) or 1(high)), masked to show only the input pins. Non-control pins on the ! a4 L3 x( S' @! n! @
// port will always show a 0 value. See cpu_map.h for the pin bitmap. As with the limit pin reporting,, m2 V0 D& d* Y# v4 g
// we do not recommend keeping this option enabled. Try to only use this for setting up a new CNC.; q# c; I3 x: n9 S; y1 q0 E) t
//启用控制销状态反馈状态报告。作为简单的二进制数据: n4 G0 b. W6 T% K$ }+ @- m. T
//控制针端口(0(低)或1(高)),蒙面,只显示输入插脚。非控制性针上% P7 D6 j) F, x1 Q- Y0 m) x
//端口总是显示0值。看到cpu_map。针位图h。与限制销报告,# x5 s/ p+ k8 b, `; _
//我们不推荐保持启用这个选项。尽量只使用这个设置一个新的数控。* y3 i' q7 [) r& F
* w9 @0 r* q# }# I
// #define REPORT_CONTROL_PIN_STATE // Default disabled. Uncomment to enable.
* B# C3 p* R& l
( x0 b! K& M4 q9 s// When Grbl powers-cycles or is hard reset with the Arduino reset button, Grbl boots up with no ALARM. P) O  z9 ^# c& c2 {6 W; A
// by default. This is to make it as simple as possible for new users to start using Grbl. When homing2 P2 l7 L$ f! }+ s; J2 W+ F
// is enabled and a user has installed limit switches, Grbl will boot up in an ALARM state to indicate
$ {% n7 e1 A( E9 o) z/ n// Grbl doesn't know its position and to force the user to home before proceeding. This option forces8 Z9 M3 F: e/ E& |8 T
// Grbl to always initialize into an ALARM state regardless of homing or not. This option is more for
9 j7 X1 e& x6 ?8 H9 Y* z// OEMs and LinuxCNC users that would like this power-cycle behavior.
! x' k0 v% m8 Y- P' Y  o. T//当Grbl powers-cycles还是硬重置Arduino复位按钮,Grbl启动没有报警
" i9 A- P: g4 N+ z) t, l//默认情况下。这是为了让新用户尽可能简单使用Grbl开始。当归航0 C$ C5 `& _) m: {7 `+ f# B+ T* L( ]
//启用和用户安装限位开关,Grbl将启动报警状态指示( y# u7 t% R/ n1 ]0 g" c" C
// Grbl不知道它的位置,迫使用户在继续之前回家。这个选项部队' h+ @" R% f" d
// Grbl总是初始化进入警报状态不管归航。这个选项是更多3 Z- I* e$ \) q& Z; l) \
//原始设备制造商和LinuxCNC用户这样的控制行为。
% R9 Z2 k: i2 h2 M9 A8 q  M9 A) [/ \; s
// #define FORCE_INITIALIZATION_ALARM // Default disabled. Uncomment to enable.6 J# p: a" M& ~3 q4 }

8 }% @8 L% s" m- p! m! r// ---------------------------------------------------------------------------------------2 N; b, m( s* R
// ADVANCED CONFIGURATION OPTIONS://高级配置选项:% D# X2 f' N  v9 n
7 F5 O4 \1 S7 X9 C2 ?
// Enables minimal reporting feedback mode for GUIs, where human-readable strings are not as important.
2 f4 y: {  x, a7 I) f& M: X// This saves nearly 2KB of flash space and may allow enough space to install other/future features.- {) j4 b* d. b) `) }
// GUIs will need to install a look-up table for the error-codes that Grbl sends back in their place., l. n% O: e3 v0 b
// NOTE: This feature is new and experimental. Make sure the GUI you are using supports this mode." [: @- D) k7 z( O
# k: ?+ ^5 h+ B* p8 P
// gui允许最小的报告反馈模式,人类可读的字符串在哪里不重要。. y! m! U& _( _& S
//这个节省近2 kb的闪存空间,允许足够的空间来安装其他/未来的功能。9 Q( V/ G. v  g1 G
// gui需要安装一个查找表的错误代码Grbl发回。
% Y! F0 s3 L0 r0 E//注意:此功能是新的和实验。确保您使用的GUI支持这种模式。
8 F  f( C0 p  ~! Z  ^
. f/ g+ n* \2 K5 q: M// #define REPORT_GUI_MODE // Default disabled. Uncomment to enable.8 j/ E9 i: C% F! N! A" z

9 Z$ u" H7 i( p% n1 E  R2 N4 ]( S// The temporal resolution of the acceleration management subsystem. A higher number gives smoother
3 l8 C# a, Y$ Q! j# ?$ u// acceleration, particularly noticeable on machines that run at very high feedrates, but may negatively) n5 M. j6 \6 f/ k! Z
// impact performance. The correct value for this parameter is machine dependent, so it's advised to$ Q3 {0 m' z' s  T- @
// set this only as high as needed. Approximate successful values can widely range from 50 to 200 or more.
$ r  l9 L# b4 t5 n& N// NOTE: Changing this value also changes the execution time of a segment in the step segment buffer. . j9 h* w% h3 L& G6 ]
// When increasing this value, this stores less overall time in the segment buffer and vice versa. Make" Z3 I5 s9 T) E) d/ F0 O
// certain the step segment buffer is increased/decreased to account for these changes.
' t; ^3 n7 X: w$ b) ~//加速度的时间分辨率管理子系统。更多更平稳* X' N" z! a! p, ?2 Q8 |9 n( _
//加速度,特别明显的机器上,运行在非常高的进料速度,但可能负面7 D- o6 Y. z5 s
//影响性能。正确的值为这个参数是依赖于机器的,所以建议
2 l: {9 @. E. u; j//这只设置为高。近似成功的价值观可以广泛的范围从50到200或者更多。
& V4 \) L/ ~8 ]% F& q//注意:改变这个值也变化的部分步骤的执行时间缓冲。
8 |0 A6 [0 m" Q, T//增加这个值时,这个商店部分缓冲区的总时间减少,反之亦然。使
  E9 |8 M. r& E, r/ [//特定步骤段缓冲是考虑这些变化增加/减少。
9 t! Y  C  g- E) k$ w, R; S3 [' |) ?% g0 p7 i' S# i4 z
#define ACCELERATION_TICKS_PER_SECOND 100  //加速度的时间分辨率管理子系统。更多更平稳
/ C3 I3 J5 g  j8 R) S; N' q9 D
' W; j9 Q: v! ?: C5 b# n// Adaptive Multi-Axis Step Smoothing (AMASS) is an advanced feature that does what its name implies, $ w: E8 j6 g" P0 l8 y% z
// smoothing the stepping of multi-axis motions. This feature smooths motion particularly at low step$ i* k0 B9 m. C, w/ u
// frequencies below 10kHz, where the aliasing between axes of multi-axis motions can cause audible
% s% M* b0 S% s  @8 [+ ]! R// noise and shake your machine. At even lower step frequencies, AMASS adapts and provides even better
& Z% G. O2 v0 }2 |* p// step smoothing. See stepper.c for more details on the AMASS system works.
+ i& t1 t) O' X; j% u( c. C; g+ w//自适应多轴步平滑(积累)是一种先进的功能,它的名字所暗示的那样,# ]2 h  C8 A; \. h' e) A2 N
//平滑的多轴步进运动。这个特性平滑运动尤其是在低一步
: Y4 z+ o! e3 D+ n  f8 _8 t/ M, Y//频率低于10 khz,轴之间的混叠的多轴运动可能导致音响
1 Y( u+ t, F$ ~' U& G  n' S" U2 D7 F//噪音和震动你的机器。在更低的频率步,积累适应并提供更好
( O% R& h, n) k; x& G//步骤平滑。看到步进。c更多细节的积累系统的工作原理。' e4 X* j- D# f8 G) r0 F8 p! B
3 }' R+ Z, H5 `
#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING  // Default enabled. Comment to disable.//自适应多轴步平滑' i! ~9 o* A  F4 N7 r8 c
5 ?9 z6 X$ ]7 [8 a' P& U
// Sets the maximum step rate allowed to be written as a Grbl setting. This option enables an error
9 T' }$ ], R0 D8 }8 u( E// check in the settings module to prevent settings values that will exceed this limitation. The maximum3 r, c- F7 E$ M9 l2 y8 o
// step rate is strictly limited by the CPU speed and will change if something other than an AVR running
4 x2 M; J) G6 D8 J// at 16MHz is used.7 t8 n8 H. L: z% F9 ^
// NOTE: For now disabled, will enable if flash space permits.
. Z2 O2 H* c3 ~/ f: N* B//设置最大一步速率可以写成Grbl设置。这个选项可以使一个错误! G" A- E2 `. _# R& d
//设置模块中检查,防止设置值将超过这个限制。的最大0 A/ m; G# Y  ^: I
//步骤严格限制的CPU速度也会改变如果是其他AVR运行, a: |) m; F' u! O
//使用16兆赫。
* N. f2 d5 g" Z( D  M//注意:现在残疾,将使如果flash空间许可。1 q/ L$ l; D" M  o9 j# b$ R
- w, T' g* W! }3 I' R) d7 t2 W: g
// #define MAX_STEP_RATE_HZ 30000 // Hz 设置最大一步速率3 Q3 d0 Z% v! @- p( ~% o% m
8 r0 c4 P; h; w# {3 m$ C
// By default, Grbl sets all input pins to normal-high operation with their internal pull-up resistors6 f2 I* T/ ]. Q
// enabled. This simplifies the wiring for users by requiring only a switch connected to ground, + i3 ^% h/ L8 u( M0 f" z' i
// although its recommended that users take the extra step of wiring in low-pass filter to reduce* H$ n' k& c1 ?
// electrical noise detected by the pin. If the user inverts the pin in Grbl settings, this just flips
0 {7 `9 l( N8 k! x5 E// which high or low reading indicates an active signal. In normal operation, this means the user
4 {! U# E/ [. Z: U' d5 \// needs to connect a normal-open switch, but if inverted, this means the user should connect a
: f$ y$ W8 G& B9 I+ y' R" t// normal-closed switch. 6 [! }. H% ~( O! j* o
// The following options disable the internal pull-up resistors, sets the pins to a normal-low
0 t3 W. j/ p. Y* q4 d  o+ O// operation, and switches must be now connect to Vcc instead of ground. This also flips the meaning
; N& i5 o( ^5 w/ d// of the invert pin Grbl setting, where an inverted setting now means the user should connect a ! ^: {9 ~- ?& C( G! p  E
// normal-open switch and vice versa.5 }3 U0 g- I' h# E* d0 l
// NOTE: All pins associated with the feature are disabled, i.e. XYZ limit pins, not individual axes.' \7 x# D; \3 B* ?( L+ Z. ?
// WARNING: When the pull-ups are disabled, this requires additional wiring with pull-down resistors!' A8 T. c# d1 [: b
//默认情况下,Grbl所有输入引脚设置为正常高操作的内部上拉电阻# T% G$ F+ b3 w7 l) V! V
//启用。这简化了布线为用户只需要一个开关连接到地面,0 K" g' B! r7 y6 q) `( ]) V
//虽然其建议用户采取额外的步骤,在低通滤波器来减少布线
" \; W5 T' E" _, S8 F2 |3 t, B! T//电噪音检测销。如果用户反转的销Grbl设置,这只是翻转
! K- Y) y5 A- W: N//读高或低表明一个积极的信号。在正常操作中,这意味着用户, U, _) k2 f+ S
//需要连接一个常开开关,但如果倒,这意味着用户应该连接$ i# p. I1 {# `' z
// normal-closed开关。
' j, G8 Q# N' a4 b+ w# H//以下选项禁用内部上拉电阻,一般低设置别针4 T; m& r: ~) K2 J
//操作,现在开关必须连接到Vcc代替地面。这也掀的意思
9 r3 S8 S, {/ R: p3 W1 a' ?//反销Grbl设置,一个倒置的设置现在意味着用户应该连接- p( h+ K$ g- z
//常开开关,反之亦然。! }* h) z; C1 ?% U) G. h& ?
//注意:所有针与功能被禁用,例如XYZ限制针,而不是单独的轴。
5 J$ j& y% Q1 k; F//警告:引体向上被禁用时,这需要额外的布线与下拉电阻!. R: `& ]( J9 K& m6 |
6 |* j# a0 A: W0 m! X7 k
//#define DISABLE_LIMIT_PIN_PULL_UP //以下选项禁用内部上拉电阻8 F: R$ |$ x* m7 [1 D
//#define DISABLE_PROBE_PIN_PULL_UP
, o9 P1 `" p; u' m: T//#define DISABLE_CONTROL_PIN_PULL_UP: {# f( W9 i* w  g

1 l9 P4 l6 ~9 E4 g! Y! X! R6 l; I% I// Sets which axis the tool length offset is applied. Assumes the spindle is always parallel with 3 Y- x; \( R4 E( I) W$ I! U
// the selected axis with the tool oriented toward the negative direction. In other words, a positive8 x, M" H' p9 p9 f( K
// tool length offset value is subtracted from the current location.4 L! F4 S% Q4 E! A' y0 _5 d+ `
//设置哪个轴长度补偿应用的工具。假设轴总是与! ]4 \: b, ~" d. S
//选择轴工具面向负方向。换句话说,一个积极的1 s! H# }" N" r1 J  `: z
//工具长度偏移值减去从当前位置。
# @+ Z) k4 n" h5 \+ O
  d( Y! j8 J: v: D6 s% O9 V# C#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS // Default z-axis. Valid values are X_AXIS, Y_AXIS, or Z_AXIS.设置哪个轴长度补偿应用的工具0 v8 O4 Y1 L4 D% B3 h

; Y( P0 w% G/ `1 G1 Y) [% R// Enables variable spindle output voltage for different RPM values. On the Arduino Uno, the spindle
* `- X; b4 A/ z" N+ C+ O5 y// enable pin will output 5V for maximum RPM with 256 intermediate levels and 0V when disabled.
/ V  V5 e% `8 Y7 B// NOTE: IMPORTANT for Arduino Unos! When enabled, the Z-limit pin D11 and spindle enable pin D12 switch!
+ S) ^8 [. O! i% [/ p// The hardware PWM output on pin D11 is required for variable spindle output voltages.. u( M3 O0 q; U; s$ M  @
//允许变量轴输出电压不同的转速值。Arduino Uno,主轴
) ?# q, q$ q; A+ ^# r8 S8 a0 x//启用销将输出5 v的最高转速256中级水平和0 v时禁用。
7 O: I! U: Z4 ]( b+ ?/ g//注意:重要Arduino凯泽本人!当启用时,Z-limit销这里和轴销D12开关!
& a% r9 M1 x3 m2 J  r4 J' k//硬件PWM输出销这里需要变量轴输出电压。
1 K6 j; c% c* Q0 Q( {0 }6 g/ N0 l/ m! b: m) \2 {1 F1 Y
#define VARIABLE_SPINDLE // Default enabled. Comment to disable.//允许主轴输出电压不同的转速值
9 |( a& E: l/ }7 J0 [# X
% a" y# O' X" |! Z3 a! v# A! t// Used by the variable spindle output only. These parameters set the maximum and minimum spindle speed
0 {5 L# ]7 Q  u, O3 m8 _: n// "S" g-code values to correspond to the maximum and minimum pin voltages. There are 256 discrete and
" ^6 n% i& y# L- t// equally divided voltage bins between the maximum and minimum spindle speeds. So for a 5V pin, 1000
8 u$ U0 U6 \9 L1 u9 {# `# R. N// max rpm, and 250 min rpm, the spindle output voltage would be set for the following "S" commands: - a4 l% y. F$ B1 n) x4 s7 l1 x8 j
// "S1000" @ 5V, "S250" @ 0.02V, and "S625" @ 2.5V (mid-range). The pin outputs 0V when disabled.7 P* j7 n* D8 }4 q' V7 L
//使用的变量轴输出。这些参数设置最大和最小轴转速2 e! p+ P( w: T; k6 j
//“S”刀位点值对应于销电压的最大值和最小值。有256个离散和
  d$ b# y; v/ o4 d1 v5 ?//电压平均分配箱主轴速度的最大值和最小值之间。所以对于一个5 v销,1000& c9 B8 ?8 z9 i% l4 V# N4 M9 s
// max rpm,250分钟rpm,主轴输出电压将为以下“S”命令:6 q1 O: r! z  A/ H
// @“S1000 5 v,“S250”@ 0.02 v,“S625”@ 2.5 v(中档)。销输出0 v时禁用。
( b1 X* B; q+ w% e% w/ `7 W9 t! p8 }  M
#define SPINDLE_MAX_RPM 1000.0 // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.
+ T$ M# O2 v9 m; M, L# d#define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.. ?! n: g' m1 @4 Q! Q
' t/ g& M4 u4 q$ O# n. A+ I! A" T# W
// Used by variable spindle output only. This forces the PWM output to a minimum duty cycle when enabled.
! s, ?+ ~2 f4 T5 R; q6 {// When disabled, the PWM pin will still read 0V. Most users will not need this option, but it may be & I9 `: K3 D- N- \, T1 t4 n
// useful in certain scenarios. This setting does not update the minimum spindle RPM calculations. Any
1 Q% ]2 w/ ^) v/ ~8 g// spindle RPM output lower than this value will be set to this value.3 P0 H' L4 w8 f3 p2 s
//使用的变量轴输出。这迫使PWM输出最小占空比时启用。8 a8 [. \) N+ Z/ o" z- E6 s
//当禁用,PWM销仍读0 v。大多数用户不需要这个选项,但是它可能是
% I8 s% Z- [4 D% {) f2 K//在某些情况下很有用。这个设置不会更新最小主轴转速计算。任何. C. j' y9 s8 @. z; c" R
//输出轴转速低于这个值将被设置为这个值。0 u, P2 \4 g1 ?6 _  O3 E
# k' n( d2 J" v. D  [& v0 E8 p
// #define MINIMUM_SPINDLE_PWM 5 // Default disabled. Uncomment to enable. Integer (0-255), j  f  Q7 t* L/ ~

4 f% h$ ?4 i: p+ s- i5 Q, A// By default on a 328p(Uno), Grbl combines the variable spindle PWM and the enable into one pin to help
# Z" C- d, e7 E: h. {6 o1 C// preserve I/O pins. For certain setups, these may need to be separate pins. This configure option uses* V/ W4 Q/ \, q7 j5 E
// the spindle direction pin(D13) as a separate spindle enable pin along with spindle speed PWM on pin D11.
+ U9 m) m& E3 l; F9 {/ K+ s// NOTE: This configure option only works with VARIABLE_SPINDLE enabled and a 328p processor (Uno).
, r5 x( |+ W0 X8 C8 w  M6 ^// NOTE: With no direction pin, the spindle clockwise M4 g-code command will be removed. M3 and M5 still work.1 c/ i) l' i. h8 X5 `7 C
// NOTE: BEWARE! The Arduino bootloader toggles the D13 pin when it powers up. If you flash Grbl with
3 I6 d4 m# R, H3 U// a programmer (you can use a spare Arduino as "Arduino as ISP". Search the web on how to wire this.),
: N8 u& ^4 G0 Q. W// this D13 LED toggling should go away. We haven't tested this though. Please report how it goes!5 J) |: v$ \9 Z6 @5 \: f
//默认ATmega328 p(Uno),Grbl结合变量轴PWM和使到一个销的帮助' B8 l# t$ n, g" B% V% C
//保存I / O管脚。对于某些设置,这些可能需要单独的别针。这个配置选项使用: h: f  j0 o, m7 N/ S$ t5 ~" z
//方向轴销(D13)作为一个单独的轴销上启用销以及主轴转速PWM这里。
9 r, P7 I- }- {//注意:该配置选项仅适用于VARIABLE_SPINDLE启用和328 p处理器(Uno)。
; M3 N$ k: W4 [6 F* }//注意:没有方向销,主轴顺时针M4刀位点命令将被删除。M3和M5仍然工作。
8 a* k: e) Z0 R9 F3 g; l8 r7 a//注意:小心!Arduino引导装载程序切换D13销的权力。如果flash Grbl
# l. v- F7 K8 f: e2 {( v//程序员(您可以使用一个备用Arduino“Arduino ISP”。搜索网络如何线),2 ^$ j% o, d$ t) s  H) W
//这D13导致切换应该消失。我们还没有测试这个。请报告将会怎样!
( A- c# Y; s& h$ t( ?4 O: S$ x: }
// #define USE_SPINDLE_DIR_AS_ENABLE_PIN // Default disabled. Uncomment to enable.
, [1 _. W3 Z! S6 A5 n8 R/ D& i4 c4 P5 k' [+ ?
// With this enabled, Grbl sends back an echo of the line it has received, which has been pre-parsed (spaces& {$ V+ j! ]5 }# B# @( y5 A5 o
// removed, capitalized letters, no comments) and is to be immediately executed by Grbl. Echoes will not be - u; g' t. r7 ^: h5 u- Q% W
// sent upon a line buffer overflow, but should for all normal lines sent to Grbl. For example, if a user
" s6 t/ l/ d7 C2 P// sendss the line 'g1 x1.032 y2.45 (test comment)', Grbl will echo back in the form '[echo: G1X1.032Y2.45]'.
( g+ b5 O: u8 |8 m; _// NOTE: Only use this for debugging purposes!! When echoing, this takes up valuable resources and can effect
) H7 F: P$ f* Z7 ]3 p$ |// performance. If absolutely needed for normal operation, the serial write buffer should be greatly increased; {  d7 |' |3 k) u
// to help minimize transmission waiting within the serial write protocol.  Z' x- |) v$ L% a0 K% G5 y# r

+ n* F% E# m% i) {  l//启用,Grbl发回的回声线已收到,已预编译(空间
# }; T! O9 z; _//移除,大写字母,没有评论),由Grbl立即执行。回声将不会+ z( C5 c1 z3 }" K
//发送一个线缓冲区溢位,但应该对所有正常线路送到Grbl。例如,如果一个用户( q- Y( ]. n9 y2 L
//发送线的g1 x1.032 y2.45(测试评论)形式”,Grbl将回声”(回声:G1X1.032Y2.45]”。
+ y" `( r- W, G7 q//注意:只使用这个调试! !当呼应,这占用了宝贵的资源,可以影响
! k- q1 B3 J! [//性能。如果正常运行所需的绝对,串行写入缓冲器应该大大增加' L5 {! t# @2 T9 ]/ N
//帮助最小化传输等系列内写协议。
, D" Y6 T4 a+ N: n3 S
, `; q" `5 l7 v7 u2 p+ O6 d// #define REPORT_ECHO_LINE_RECEIVED // Default disabled. Uncomment to enable.; x: c* u- s) B# c4 d7 q& c
! [; J1 ^9 G  ]) S
// Minimum planner junction speed. Sets the default minimum junction speed the planner plans to at1 a, Z6 D- C3 e) z' s
// every buffer block junction, except for starting from rest and end of the buffer, which are always5 z4 M) c2 i- W% X! _
// zero. This value controls how fast the machine moves through junctions with no regard for acceleration
" n0 }" \# k! u3 S! e  m8 K// limits or angle between neighboring block line move directions. This is useful for machines that can't' m8 j/ S8 c: R2 U# M: L
// tolerate the tool dwelling for a split second, i.e. 3d printers or laser cutters. If used, this value
8 y* x& v, o3 ~1 K4 u9 @// should not be much greater than zero or to the minimum value necessary for the machine to work.
7 _0 D2 m' j; k( m
/ ?, j9 ?" A* Z1 [( n//最小规划师结速度。设置默认最小连接速度规划计划7 h8 ]" u3 u, y7 H
//每一个缓冲块接头,除了从结束休息和缓冲区,它总是
7 b7 ?* l3 `" @. s+ F$ e// 0。这个值控制机器的速度穿过路口,没有考虑加速度
, z9 e- t1 c- L4 d; B//限制或相邻块之间的角线方向移动。这是有用的机器,不能
; o5 V: S9 _. o* j2 j//容忍工具居住某一刹那,即3 d打印机或激光切割机。如果使用这个值
+ B/ J8 m, `  g* R# s. `//不应大于零或机器工作所需的最小值。0 f4 n6 n; [! I$ Q

6 D5 Y1 M. z/ e  Z" w3 I#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min)
/ ]! H0 T( C8 t1 B7 A( t+ ^4 \" R& G3 K$ m
// Sets the minimum feed rate the planner will allow. Any value below it will be set to this minimum- @' L9 x& \; K, d( m
// value. This also ensures that a planned motion always completes and accounts for any floating-point
, T  R3 p  f  T, U7 U// round-off errors. Although not recommended, a lower value than 1.0 mm/min will likely work in smaller  l2 ^) w% o" x- X4 Z
// machines, perhaps to 0.1mm/min, but your success may vary based on multiple factors.4 ?1 d( D% f1 V* C8 G$ A! h
//设置计划将允许的最小进给速率。任何价值低于它将被设置为最低值。这也保证了运动计划总是完成,占任何浮点
' X+ u: ~2 \) H//舍入错误。虽然不推荐,价值低于1.0毫米/分钟可能会在较小的工作7 {" F" W2 K. L3 e& n( b* m* e
//机器,也许到0.1毫米/分钟,但你的成功基于多种因素可能会有所不同。
! x1 r9 M6 u7 Y8 d
2 a+ h6 y. T- G) K* m#define MINIMUM_FEED_RATE 1.0 // (mm/min)//设置计划将允许的最小进给速率
- B0 b+ F, e1 G0 G' H1 B8 Y6 A
0 e- m' Y5 m) z1 ~% e// Number of arc generation iterations by small angle approximation before exact arc trajectory $ H2 x: F, \# }. L
// correction with expensive sin() and cos() calcualtions. This parameter maybe decreased if there   ~3 x; \0 R: x5 x9 _* c
// are issues with the accuracy of the arc generations, or increased if arc execution is getting
/ P2 @" Z, U  n// bogged down by too many trig calculations. 6 C% A& V* b& s1 v  I! h$ u
//弧生成迭代次数之前小角度近似精确的弧线轨迹
7 E; _, j, L. w& }( z% c( F//修正与昂贵的sin()和cos()calcualtions。如果有这个参数可能减少
5 S2 F! E, S; r  I7 g4 I- Y2 v//与弧一代又一代的准确性问题,或如果电弧执行得到增加
( U" D1 w+ E( o- r: M//太多的三角计算的泥潭。. I& N7 _' H5 ^+ L# K
" l/ B2 f. H- I5 T, M" V
#define N_ARC_CORRECTION 12 // Integer (1-255)
0 V+ {$ `/ J# h+ e
( c* ?4 B; W. j0 F' t. r1 T" N// The arc G2/3 g-code standard is problematic by definition. Radius-based arcs have horrible numerical % j) F4 i& D* R. \; g. \$ E
// errors when arc at semi-circles(pi) or full-circles(2*pi). Offset-based arcs are much more accurate 9 Y% [# @5 s7 d2 R6 F
// but still have a problem when arcs are full-circles (2*pi). This define accounts for the floating
  z" ^/ \% j$ p$ M// point issues when offset-based arcs are commanded as full circles, but get interpreted as extremely- [9 J( ]: s  z/ G! c
// small arcs with around machine epsilon (1.2e-7rad) due to numerical round-off and precision issues., P! J) O* E9 `4 `! a
// This define value sets the machine epsilon cutoff to determine if the arc is a full-circle or not.
' r0 |) b( V9 ]  b// NOTE: Be very careful when adjusting this value. It should always be greater than 1.2e-7 but not too/ J6 h" H6 D0 i9 Y0 U
// much greater than this. The default setting should capture most, if not all, full arc error situations.! y( v% M' G: |% ?* x
//弧G2/3刀位点的标准定义是有问题的。Radius-based弧有可怕的数值( E' Q0 I6 \" W, {  X( S
//错误当电弧在半圆(π)或原点(2 *π)。Offset-based弧更准确  ]6 N/ F" N# Y7 V* V
//但仍有一个问题当弧原点(2 *π)。这个定义占浮动! \4 [8 X5 W+ r" M
//当offset-based弧吩咐点问题完整的圆,但解释为极
& O+ U4 {. Y& B6 ^  G//小弧机周围ε(1.2 e-7rad)由于数字舍入和精度问题。6 {# r" G8 u: z* o6 c9 z  O* T
//定义值设置机器ε截止来确定电弧是一个原点了。
1 |: H0 i1 h7 R//注意:调整这个值时非常小心。它应该总是大于1.2 e -但不要太, T& z) N8 U* }- ^9 {$ ~& |
//比这大得多。默认设置应该捕获大部分,如果不是全部,全部错误的情况。
7 Q) w0 x6 U% k! o" E  i9 k8 d" N+ h( e! i+ a2 H, p, X1 v
#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)5 @8 Q4 j  K/ j3 Q! |. Z- o* ~

, `0 V0 O- M  w+ A3 O// Time delay increments performed during a dwell. The default value is set at 50ms, which provides# k' o; a. }  u" S- M6 h
// a maximum time delay of roughly 55 minutes, more than enough for most any application. Increasing
: W" x4 N5 @8 j// this delay will increase the maximum dwell time linearly, but also reduces the responsiveness of
8 Z* ]" y/ U- ?: t& l3 ^4 y9 N// run-time command executions, like status reports, since these are performed between each dwell 2 y* A% j3 V. S3 `( v0 G6 K1 N, g
// time step. Also, keep in mind that the Arduino delay timer is not very accurate for long delays.( M5 @) j! c0 w) _4 @
//延时增加表现在住。默认值设置为50毫秒,它提供了% v, l- h% }* q
//最大延时约55分钟,足够对大多数任何应用程序。增加2 s. U$ o* c0 E6 O5 z- q% H
//这种延迟将增加线性最大停留时间,也减少了响应能力4 f! D9 z4 T" e+ b
//运行命令执行状态报告一样,因为这些每个住之间执行8 N; d6 E, l/ s: z* Z( I
//时间步。还有,记住,Arduino延迟计时器不是很准确的长时间延误。
, Q4 @0 R( p$ R3 Q1 e5 v. D) u
$ |4 L$ z3 n' m# x+ i( S#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds)
' r& k2 f2 z) ~& q* U3 [% D% e4 z9 T# r8 _3 u
// Creates a delay between the direction pin setting and corresponding step pulse by creating7 L+ Z( [: g  x
// another interrupt (Timer2 compare) to manage it. The main Grbl interrupt (Timer1 compare) 1 R# }& A/ B$ c! r2 d  \6 s
// sets the direction pins, and does not immediately set the stepper pins, as it would in " M8 D* U2 K1 I8 B
// normal operation. The Timer2 compare fires next to set the stepper pins after the step ; `% Q" `/ t( I
// pulse delay time, and Timer2 overflow will complete the step pulse, except now delayed
3 u- ?9 n( r" |- i  Y; m// by the step pulse time plus the step pulse delay. (Thanks langwadt for the idea!)! C5 v/ k  C/ Y2 v' Y
// NOTE: Uncomment to enable. The recommended delay must be > 3us, and, when added with the
7 n" t' g& {' Z// user-supplied step pulse time, the total time must not exceed 127us. Reported successful
9 ~% k% i4 Y, E, H// values for certain setups have ranged from 5 to 20us.% g. T- C3 M! X. u; y
//创建一个方向销之间的延迟脉冲通过创建设置和相应的步骤- E4 k0 D9 ]3 F
//另一个中断(Timer2比较)来管理它。主要Grbl中断(Timer1比较)$ d* z$ p3 v& F+ z0 V
//设置方向针,不立即设置步进针,因为它会在
9 m7 U( a- Z0 Z/ Z# x8 e//正常操作。Timer2比较火旁边设置步进针后一步
" q8 V$ }  G" Y0 [//脉冲延迟时间,Timer2溢出脉冲将完成的步骤,现在延迟除外
. Q+ J) G7 |4 T) t9 u//脉冲时间加上的一步一步脉冲延迟。(感谢langwadt主意!)* V+ ~9 }) j  _! E7 y4 n; e8 A$ G
//注意:取消启用。必须> 3,建议延迟,当添加的
1 h! w9 K1 D  {: U9 n9 F//用户提供的步骤脉冲时间,总时间不得超过127美元。成功的报道( `# I: r8 s- F& X9 r4 H
//值对某些设置范围从5到20。6 V3 [4 h) A4 G! f

( d( L7 u) H' {! \// #define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.
- }1 b1 B8 ]9 b- }& O
. C' Z: H- K) ]! i$ ?! k$ t// The number of linear motions in the planner buffer to be planned at any give time. The vast* R0 m2 n* h! k# `! Z( @
// majority of RAM that Grbl uses is based on this buffer size. Only increase if there is extra . A$ g' U# C. A) ~& b4 n$ L& N1 t% D
// available RAM, like when re-compiling for a Mega or Sanguino. Or decrease if the Arduino/ v& b. L/ C  v  l! C
// begins to crash due to the lack of available RAM or if the CPU is having trouble keeping
( x2 k9 [; z7 L* U3 ]// up with planning new incoming motions as they are executed.
# @: O6 t! P- p, s# e: [: i//线性运动规划师缓冲区的数量在任何给出时间计划。绝大( c" T3 C4 c% W
//多数RAM Grbl使用基于这个缓冲区的大小。如果有额外的只会增加
- M8 r, i' c$ m2 V6 O//可用内存,比如当基于大型或Sanguino。如果Arduino或减少8 S  \0 O6 O) K, ^5 {5 X
//开始崩溃由于缺乏可用的RAM或者CPU是难以保持$ B; s' o- O; I- Q& d5 w& H- {6 }
//与规划新传入的动作执行。
0 e# U: d' ]6 k" u7 z! g4 A( K0 J: s
// #define BLOCK_BUFFER_SIZE 18  // Uncomment to override default in planner.h.
+ L8 Q5 K. j! P4 N  o: L$ `) N% }+ E2 y7 K+ P2 G
// Governs the size of the intermediary step segment buffer between the step execution algorithm: m9 G6 c) m, F& R- g
// and the planner blocks. Each segment is set of steps executed at a constant velocity over a& S. }% G- z- d% D- Q" K
// fixed time defined by ACCELERATION_TICKS_PER_SECOND. They are computed such that the planner
7 A* u0 N! {" S' ]( x, H1 A) V" X// block velocity profile is traced exactly. The size of this buffer governs how much step " A* p9 _3 c; l
// execution lead time there is for other Grbl processes have to compute and do their thing * v; Q; `! Q- B! R7 D) p
// before having to come back and refill this buffer, currently at ~50msec of step moves.1 U' Y' N, N7 X+ G/ z( p
//控制之间的中间段缓冲大小的步骤执行算法4 u( I' w. p$ d5 U. B* g
//和规划师块。每一部分的步骤执行在一个恒定的速度$ V& s4 @( F2 R' z
//固定的时间由ACCELERATION_TICKS_PER_SECOND定义的。他们计算的计划. I( A' t8 h* A6 N
//块速度剖面追踪到底。这个缓冲区的大小控制多少步骤8 Q( {1 Y: H  `& c7 t
//执行时间有其他Grbl过程需要计算和做他们的事情* t) B& c  X5 v8 J1 g. ?6 B% m
//之前必须回来重新填充这个缓冲区,目前移动~ 50毫秒的一步。3 W" `5 L1 y2 v* ^5 a* f$ m  h

+ M/ b+ k2 `( l& N; s// #define SEGMENT_BUFFER_SIZE 6 // Uncomment to override default in stepper.h.
5 I& K- ~' N$ V, w7 m
1 H) K- {3 x: J: Q/ Z// Line buffer size from the serial input stream to be executed. Also, governs the size of 1 _- ?: o8 _( B. |, C
// each of the startup blocks, as they are each stored as a string of this size. Make sure
# @+ ^3 e8 r& v& x& q2 I, ^9 e// to account for the available EEPROM at the defined memory address in settings.h and for2 ?$ g& X( O) Y0 G8 {* i% T% a
// the number of desired startup blocks.4 ]  }9 V0 A' a# v7 Z1 ]
// NOTE: 80 characters is not a problem except for extreme cases, but the line buffer size
8 @0 X. `* `( a0 _4 S2 A! M9 Y// can be too small and g-code blocks can get truncated. Officially, the g-code standards " v( |( j) w% v
// support up to 256 characters. In future versions, this default will be increased, when
5 E: `- h' v( m+ p// we know how much extra memory space we can re-invest into this.! J- @: x: y9 d/ w
//行执行串行输入流的缓冲区大小。同时,大小的控制% x1 J/ s& T5 |; o# P
//每个启动模块,它们分别存储为字符串的大小。确保
" A1 p3 J0 M( l) a: `$ `0 y& @//占可用eepm定义内存地址的设置。h和
, a! q  A3 o% X+ m  S5 [//需要启动块的数量。9 ^& C9 _5 D/ j1 {4 I
//注意:80个字符不是一个问题,除了极端的情况下,但线缓冲区大小
6 }# X! H& r- t. c//可以太小和刀位点块可以截断。正式,刀位点标准
( L; Q4 Q! l/ Y9 a  g//支持多达256个字符。在未来的版本中,这个违约将会增加,当# ~. K5 H, X( [% |* I! }
//我们知道多少额外内存空间的时候我们可以再投资。  _/ V5 O+ u% Q/ h

7 o3 t$ ?0 M, P$ D( h// #define LINE_BUFFER_SIZE 80  // Uncomment to override default in protocol.h$ n' B( z: ?0 ]7 P9 o2 w7 y
  + A* B! J) d. @9 ~( X. v# D$ P1 A
// Serial send and receive buffer size. The receive buffer is often used as another streaming
+ b. e# G" L' h, Z0 h& E6 C, _: c// buffer to store incoming blocks to be processed by Grbl when its ready. Most streaming  [' K+ r: L; m( I; t
// interfaces will character count and track each block send to each block response. So, 1 ?. @0 i! U! K6 Y- [( ]
// increase the receive buffer if a deeper receive buffer is needed for streaming and avaiable1 l- j$ f% @7 `9 Z5 n0 _- ?  F% q
// memory allows. The send buffer primarily handles messages in Grbl. Only increase if large
/ \, Y) f7 b6 B& l4 |: D// messages are sent and Grbl begins to stall, waiting to send the rest of the message.$ I- I+ S- Z9 j& j8 F9 j
// NOTE: Buffer size values must be greater than zero and less than 256.
8 o- E6 x9 c9 V& m: e3 a; s// #define RX_BUFFER_SIZE 128 // Uncomment to override defaults in serial.h* G$ Z# T  M) n" d' D8 Q& `
//串行发送和接收缓冲区大小。接收缓冲区通常用作另一个流8 q! S5 e& _4 d8 k
//缓冲存储传入的块来处理Grbl当它准备好了。最流
; g0 s  ~5 M* S: c8 L. Y//接口将字符计数和跟踪每一块发送给每个块的回应。所以,
! a5 C, l3 @! v0 h& W//增加接收缓冲区如果需要更深层次的接收缓冲区为流,、
) I/ g8 z$ }' d$ U4 a8 a5 T//内存允许。Grbl发送缓冲主要处理消息。只会增加如果大
+ Z9 \" O8 s4 g% `- ?! I2 Y% K//消息发送和Grbl开始停滞,等待发送其余的消息。' |/ y' h/ r9 K( F9 P
//注意:缓冲区大小值必须大于零,小于256。
- u+ Q2 a  f5 D8 v( {5 ]// # define RX_BUFFER_SIZE 128 / /取消serial.h覆盖默认值
6 x, s. Z4 K$ l! v" i9 i4 ]: g
7 _- C  ^. S# i. X
// #define TX_BUFFER_SIZE 64
- Y& [. d; U. \  # C( u2 P4 ~2 w' S, m; {6 c
// Toggles XON/XOFF software flow control for serial communications. Not officially supported
  r) C6 t7 }0 D// due to problems involving the Atmega8U2 USB-to-serial chips on current Arduinos. The firmware- F+ {- z# M1 O
// on these chips do not support XON/XOFF flow control characters and the intermediate buffer
- A, n, ]3 w7 @  |) C) ~// in the chips cause latency and overflow problems with standard terminal programs. However, " |" L) T: a0 ^# B' y7 Q
// using specifically-programmed UI's to manage this latency problem has been confirmed to work.3 _. V) Y6 l$ m6 [
// As well as, older FTDI FT232RL-based Arduinos(Duemilanove) are known to work with standard
& m9 i- s4 @- k, n9 U// terminal programs since their firmware correctly manage these XON/XOFF characters. In any
* n/ n8 _/ l$ K2 J: j4 o% I// case, please report any successes to grbl administrators!- C+ c9 b) }4 R4 n& l5 [8 y
//切换为串行通信发送朴通/发送葡开软件流控制。不是官方支持
( m/ ]8 U3 m, r//由于问题涉及Atmega8U2 USB-to-serial当前arduino芯片。固件
  G7 Y8 U  i5 H' R4 R//在这些芯片不支持发送朴通/发送葡开流控制字符和中间缓冲区
  a" {3 f7 R& d6 q//芯片导致延迟和溢出问题的标准终端程序。然而,
& p# G6 R( [3 i5 Y& t//使用specifically-programmed UI的管理这个延迟问题已经确认工作。
0 W& X. P0 h& ~3 r2 }//以及老FTDI FT232RL-based arduino(Duemilanove)是已知的标准: P4 \9 J+ o) s0 `) v1 \
//终端程序因为他们正确的固件管理这些发送朴通/发送葡开的角色。在任何. E, N* _; m7 E6 `
//情况,请报告任何成功grbl管理员!& g/ B* S% O* m$ H4 h- D1 E

9 ]/ F6 k2 B7 ?6 C6 F// #define ENABLE_XONXOFF // Default disabled. Uncomment to enable.
2 ?1 p2 u( f, J4 A* a
8 r) y8 F& |/ _// A simple software debouncing feature for hard limit switches. When enabled, the interrupt 3 p) e" b5 |4 G& f
// monitoring the hard limit switch pins will enable the Arduino's watchdog timer to re-check
* {/ Z1 q! u* ^2 c// the limit pin state after a delay of about 32msec. This can help with CNC machines with / q0 S) \8 b. u0 E3 L9 c
// problematic false triggering of their hard limit switches, but it WILL NOT fix issues with
2 J0 K( A3 n, Q) X. m// electrical interference on the signal cables from external sources. It's recommended to first9 z. Y, p$ q- w
// use shielded signal cables with their shielding connected to ground (old USB/computer cables ; s* J) N: S. @  d' A. Y' [! H
// work well and are cheap to find) and wire in a low-pass circuit into each limit pin.
: l9 b. t( L1 m# r  k" ^% |' l//一个简单的软件消除抖动特性硬限位开关。当启用时,中断
, G0 j( u& y1 h( Q1 Y//监控硬限位开关针将使Arduino的看门狗定时器重新审视* T+ S" }* w) K% r& `
//销的极限状态后约32毫秒的延迟。这可以帮助与数控机器
3 K" t8 P3 z. H+ W//问题错误引发的硬限位开关,但是它不会解决问题- _& H) D. w$ p7 }/ P
//电干扰信号电缆从外部来源。首先它的建议, Y+ j6 ^0 }# D" k5 o& _- V! Q
//使用屏蔽信号电缆的屏蔽连接到地面(老USB /计算机电缆# r/ ^0 w# E3 j0 S# ~
//工作得很好,很便宜)和线低通电路到每个限位销。/ W6 f$ ?/ m6 I7 \
% X  N0 ?4 \: v: W# \7 S; g4 R8 O
// #define ENABLE_SOFTWARE_DEBOUNCE // Default disabled. Uncomment to enable.. |4 m3 B$ p5 D

7 N  H0 ?5 ?; G+ R. [// Force Grbl to check the state of the hard limit switches when the processor detects a pin: i" e* i2 y# V3 j6 n( t
// change inside the hard limit ISR routine. By default, Grbl will trigger the hard limits
$ W5 G8 x2 ?! |3 K+ s. e4 W// alarm upon any pin change, since bouncing switches can cause a state check like this to , l% [- C( b( S; [8 |. P
// misread the pin. When hard limits are triggered, they should be 100% reliable, which is the
# u/ Z/ T1 v4 o7 U// reason that this option is disabled by default. Only if your system/electronics can guarantee5 r! m5 q6 |0 D/ V! V" J, L0 n2 r2 K4 d
// that the switches don't bounce, we recommend enabling this option. This will help prevent0 g7 ]: S% R% F# p  J% \
// triggering a hard limit when the machine disengages from the switch.
9 U( Q& Q' M. ~9 g// NOTE: This option has no effect if SOFTWARE_DEBOUNCE is enabled.
  O- l& H7 ]) d6 k2 Q, S& g//力Grbl检查硬限位开关的状态,当处理器检测到一个销8 n6 P+ I  w! v* n- f
//改变内部硬限制ISR例行公事。默认情况下,Grbl将触发硬限制3 M% q" `0 o/ D4 y3 o' r
//报警在任何销更改,因为跳开关可以导致这样的状态检查6 P' M4 d4 Q8 e
//误读了销。硬限制触发时,他们应该100%可靠,这是, S1 S2 n5 T  b7 M/ {- ^  l
//原因,这个选项默认是禁用的。只有在你的系统/电子产品可以保证4 Y2 a7 F& L$ a9 i5 ~+ h
//开关不反弹,我们建议启用这个选项。这将有助于防止+ \' p; O9 M/ Q  p
//触发机退出时硬限制开关。8 [7 a+ X! v0 Q- \8 W
//注意:这个选项如果启用了SOFTWARE_DEBOUNCE没有影响。
# [6 f4 y8 ~9 J+ q" M/ Y/ O* I$ Y9 S6 R9 i, o
// #define HARD_LIMIT_FORCE_STATE_CHECK // Default disabled. Uncomment to enable.' B- w! V' Q2 [& E

$ v/ C1 B8 c! r& V4 ]/ @/ j$ l' V5 D; h, U9 J. e- G5 a
// ---------------------------------------------------------------------------------------: g( F: U  Y3 h" l* B% ^& k! J
// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:编译时错误检查的定义值:( u6 v0 x8 u7 \; M# @$ S9 D
: G. h/ }" V+ j( i* E
#ifndef HOMING_CYCLE_0
( H" Y8 j4 x: I: K, T  #error "Required HOMING_CYCLE_0 not defined."
. i; }- K) X3 o1 m$ [  A& b' N2 G#endif
: I* D; p* A. J' T  }4 ?
. B1 ]) Y0 R  A" X% u/ o- g#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(VARIABLE_SPINDLE)! G# l8 E" @6 ~2 n5 K
  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with VARIABLE_SPINDLE enabled"
; r7 e( R! i3 z! Q; o#endif
8 x( H3 W' K  ]* d; _  H8 Y( B, J" z' s7 j* ^1 i& }. B
#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(CPU_MAP_ATMEGA328P)
" G0 ^! b7 P0 q8 Z! h0 Q  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with a 328p processor"& s7 t! ^( {5 m$ [5 C+ O
#endif
% k; J1 h$ g  P0 l' j3 e) `; j' ^8 T. b, o, `
// ---------------------------------------------------------------------------------------
: ]1 ~. w3 I8 h" |% E; `! ]" t
( r$ _4 x# f" m. A9 o  V4 V$ a2 b+ a' z# M; l
#endif
$ z' I. t* r! Q
* q* F4 J# _$ b* X- ]
4 a3 E# @0 G2 q, M- i
5 q" w* _% ?5 j1 b, t( x$ f
4 \0 R- O; H% Q0 N9 ~9 l% r. D, a( S" V0 i6 n

* W& d. d9 T; I  Y! @$ h; n& x- t5 i( {% R
' H) w6 j2 O+ K, g7 x* y* h
0 J5 m: t1 y. `+ ^
: ]' a9 V1 \0 p. B6 A* t

8 d2 M* S. j3 b7 O9 C  s+ S. a* i# @  r5 Z7 \8 J! G0 h+ G
- _! R0 x9 T: x9 `2 F9 W1 \6 c

! D) W9 Y) @' W* o) R" a
7 p8 J  q  a' K4 @* c3 O7 G& j: x. H

本帖子中包含更多资源

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

x

评分

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

查看全部评分

回复

使用道具 举报

2#
 楼主| 发表于 2016-8-21 00:11:42 | 只看该作者
那些没有用的照片不知道怎么就上去了好讨厌。
回复 支持 反对

使用道具 举报

3#
 楼主| 发表于 2016-8-21 00:14:16 | 只看该作者

% j2 U' _4 a7 r6 Y( L
回复 支持 反对

使用道具 举报

4#
发表于 2016-8-21 05:50:22 | 只看该作者
      楼主厉害!
回复 支持 反对

使用道具 举报

5#
发表于 2016-8-21 08:22:05 | 只看该作者
谢谢楼主,先收藏一下,慢慢学习
回复 支持 反对

使用道具 举报

6#
发表于 2016-8-23 15:11:25 | 只看该作者
这是什么宝贝?
回复 支持 反对

使用道具 举报

7#
发表于 2016-8-23 15:11:47 | 只看该作者
换了个浏览器Chrome,试试能否发言了。
回复 支持 反对

使用道具 举报

8#
发表于 2016-8-23 20:12:33 | 只看该作者
楼主厉害
回复

使用道具 举报

9#
 楼主| 发表于 2016-8-23 23:03:17 | 只看该作者
补充* L# H7 \8 z8 w7 A8 s: f# c) F6 I
程序运行protocol_execute_realtime(); /运行实时命令。
- O7 X# w, J7 M- G' V// Executes run-time commands, when required. This is called from various check points in the main' E* @4 I8 C4 M- d+ H% ^; \
// program, primarily where there may be a while loop waiting for a buffer to clear space or any) s2 J9 x+ V3 P( ~  [4 ]5 I
// point where the execution time from the last check point may be more than a fraction of a second.
; ^8 }. f2 g& J, A, k) V5 [" N! q// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code. V' w/ E7 x, H* n  U. j, k
// parsing and planning functions. This function also serves as an interface for the interrupts to 1 b+ g0 p, P, ^. q6 |2 e
// set the system realtime flags, where only the main program handles them, removing the need to/ z( `) g. L, O4 N& i% C
// define more computationally-expensive volatile variables. This also provides a controlled way to
6 T& g# h# i9 D0 c- r$ N# E1 s; y// execute certain tasks without having two or more instances of the same task, such as the planner8 W, P7 f: o% O  B9 Z& i
// recalculating the buffer upon a feedhold or override.* }& A5 ~2 e, t
// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,
9 }6 f& ?7 Y, R2 g) {7 E) n// limit switches, or the main program.! m5 H1 K. l- s, I

, @: s: q, _# |9 V, B//执行运行时间命令,在需要时。这就是所谓的从各种主程序要检查站- {& U0 p! f: C6 t. N  A( E! N5 `
//,主要是那里可能是一个while循环等待缓冲区空间或任何+ i4 {% R" @/ J) ]/ X! U
//执行时间从过去的止点可以超过几分之一秒。  z7 f1 f0 |3 ~) _- O, u$ c1 U
//这是一种异步执行实时命令(又名多任务)grbl的刀位点
: ^9 A  R: N4 }6 O) X//解析和规划功能。这个函数也可以作为一个接口,用于中断3 U4 e! i' x$ ~3 j
//设置系统实时的旗帜,只有主程序处理,消除的需要2 \9 M  b% L% V8 e
//定义更多的计算昂贵volatile变量。这也提供了一种控制方法
) R" w, x3 S! W+ v# P4 n- C//执行某些任务不相同的两个或多个实例的任务,比如计划
2 R" q5 B* B* d. }  b1 @//重新计算缓冲feedhold或覆盖。
+ r$ e: ~- n0 |//注意:sys_rt_exec_state变量标志设置任何过程,步骤或串行中断,插脚引线,
" l7 N) D/ A( D- I# p0 N( T1 ^//限位开关或主程序。9 Y0 H0 X& k# {5 A) {+ G
void protocol_execute_realtime()5 f) Q" T, M5 K7 c$ A) G3 z% w
{3 z# |- T3 D8 w, g
        // Temp variable to avoid calling volatile multiple times.
5 y" r- `( _) A7 U# n        // 临时变量来避免多次调用不稳定。
5 Y' R  R. P5 A6 y        uint8_t rt_exec; - b) e3 Z/ V# E
        do{  X9 B8 A6 z- ]
          if (rt_exec) {                 // 有标志位置位进入; t. k5 T& O) x5 [' {! C
        0 R2 L: `' Y& W2 q( ~# U" E5 E
            sys.state = STATE_ALARM; // 设置系统为报警状态  C' h8 b- l# g0 @) b1 R$ [
      report_alarm_message(ALARM_HARD_LIMIT_ERROR);        //报告报警信息为接近极限值
' J$ n6 z  d7 \4 f2 C' C6 s    } else if (rt_exec & EXEC_ALARM_SOFT_LIMIT) {                        //报告执行软件限位报警6 ~' o6 @, V  ~9 w+ A' B5 m
      report_alarm_message(ALARM_SOFT_LIMIT_ERROR);        //报告出现软件限位报警
, O  F$ K% q+ v; ^6 g. j    } else if (rt_exec & EXEC_ALARM_ABORT_CYCLE) {                //执行停止循环报警      
. G4 _% \; }5 d# Y5 w" C* s      report_alarm_message(ALARM_ABORT_CYCLE);                //出现终止循环报警8 {/ i. Z% a& G( G2 f5 t
    } else if (rt_exec & EXEC_ALARM_PROBE_FAIL) {                        //执行探查失败报警+ z0 D& P3 b$ I5 a& U
      report_alarm_message(ALARM_PROBE_FAIL);                        //出现探查失败报警
% W0 D$ J( d: Z: p    } else if (rt_exec & EXEC_ALARM_HOMING_FAIL) {                //执行返回原点失败报警
" I4 x/ w  m' o4 ~      report_alarm_message(ALARM_HOMING_FAIL);                //出现返回原点失败报警! ~  N9 [& E; D% A0 V7 |
    }4 c' q* D) i; `0 Z1 H0 H

6 [) k: `' p  |/ m& D    // Halt everything upon a critical event flag. Currently hard and soft limits flag this.
# R" y* N7 v$ R% l9 ?, p! ]# _6 h    // 停止一切在一个关键事件标志。目前硬和软限制标志0 P$ G5 ^6 t" j: @8 l6 Q" z* e8 d
           if (rt_exec & EXEC_CRITICAL_EVENT) {                //如果系统是循环事件进入
1 \. [6 ]7 n8 o4 k* V             report_feedback_message(MESSAGE_CRITICAL_EVENT);        //报告反馈信息
) H9 c4 X7 j* v+ @              bit_false_atomic(sys_rt_exec_state,EXEC_RESET);                         //清除目前的复位状态
+ d& @9 Y% {5 Z9 B9 g* P2 v; V
( }2 @: ~7 P; R2 |; X- @! w        bit_false_atomic(sys_rt_exec_alarm,0xFF);                                 // 清除所有报警标志6 W. z2 U" f. q3 k0 h0 R; E
        }        7 ]5 F/ A' C, ~

0 ~$ O! [$ x1 Z0 u上面代码将rt_exec = sys_rt_exec_alarm ,如果rt_exec为真,打印不同报警信息
! i* r( M3 `. j4 ^6 M- u( L和限位保护信息,然后清除报警状态% s/ F3 G* f( q" d4 U9 g
___________________________________________________________________________
- L2 a' D) y4 K9 z5 O. M2 c没有报警进行执行下面代码,执行了终止命令,串口打印命令. I: q( W+ s) j, G/ x% \
        // Check amd execute realtime commands        校验和执行实时命令/ \' C  e# U( C* g
          rt_exec = sys_rt_exec_state; // Copy volatile sys_rt_exec_state
0 N: c6 @- g! P; H. Y
7 ]8 Q/ U: {  l        if (rt_exec) { // 输入标志是正确的执行
" q& a9 M; b/ L4 {& [
. Y2 n0 {9 Z5 b- J5 M3 I& N" k            // Execute system abort. 执行系统终止命令
! A: K/ j: p; g0 d7 M& z; g            if (rt_exec & EXEC_RESET) {& f9 |; _. M. y3 M4 A0 Y
              sys.abort = true;  // Only place this is set true." g# `: v6 t7 m
              return; // Nothing else to do but exit.$ r6 t) v9 Y1 w3 @) I
        }+ ~9 H5 ]2 |8 L- G( X' ^

5 v) {1 C" O3 {  c; |( s            // Execute and serial print status 执行和串口打印状态
/ m" C. _+ F% v1 Y            if (rt_exec & EXEC_STATUS_REPORT) {
$ x" `3 s0 \7 C) K: Z: ^( f" H" e$ p5 ?              report_realtime_status();        //报告实时状态
( m2 n% O3 F* E  F              bit_false_atomic(sys_rt_exec_state,EXEC_STATUS_REPORT);        //清除报告状态清零
7 H0 l' n; N( o, t            }+ c5 _7 P6 B$ a' a$ c0 F" G3 K
_____________________________________________________________________________* v# A1 {3 L- |* @+ T
下面代码
2 q' J" ^2 x' N/ `) I; ?4 G, `//执行状态。
0 ~7 G% i5 F$ H; x7 K0 o- F//注意:所涉及的数学计算持有应该足够低对大多数人来说,即使不是全部,
; d7 H) P$ M7 E: u- {//操作场景。一旦启动,系统进入暂停状态
. S9 R! V* e7 k  C  p//主程序流程,直到重置或恢复。
6 l7 u& N5 v- K5 A! C9 B) x待办事项:检查模式?如何处理呢?可能没有,因为它只会在空闲,然后重置Grbl。
, e8 {9 r  K3 N  P/ S2 k状态检查容许状态的方法。! k1 V- R; m' A! \& C+ d$ W7 H

" K% k0 _6 L; i- Y2 s0 d        //如果全局各自报警标志位其中(执行取消动作) | (执行进给保持) | (执行安全门)任意一位为真进入2 n* h3 b6 [  z) u
            if (rt_exec & (EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR)) {        ' `" l+ i( i, L3 K

1 T8 n* c' R1 ?$ c, \        //如果是循环状态执行暂停状态( b* b# q/ J: J0 [
        if (sys.state == STATE_CYCLE) {
$ j7 w' M. v, V- w5 a! G3 P4 {$ O        st_update_plan_block_parameters(); //通知stepper module验算减速。: w  L* L% F$ J5 O7 e3 F3 B  l
        sys.suspend = SUSPEND_ENABLE_HOLD; // 开始暂停标志; @2 k2 d, ?: i+ I( P2 G: p: j
        }
8 l. p1 P. \" A+ M) N
% H2 f1 T+ K" ?1 W( @' r        // 如果,Grbl空闲不在运动。简单的指示暂停就绪状态。
& |$ H8 D* X3 s+ c8 k  p        if (sys.state == STATE_IDLE) { sys.suspend = SUSPEND_ENABLE_READY; }
+ ~3 b. S2 Y) }, n8 @+ j! O# L' t
) }0 A4 C/ v2 q! X' h4 i
2 Z3 ]8 \& ?* T/ t6 O4 a  r        //执行和标志和减速运动取消并返回空闲。主要由探测使用周期
0 R3 k8 x) x0 I; v        //停止和取消剩余的运动。      
* c6 n6 n0 B" y9 D8 J- p        if (rt_exec & EXEC_MOTION_CANCEL) {
; N  |) `, ?% O& k' ~$ i          if (sys.state == STATE_CYCLE) { sys.state = STATE_MOTION_CANCEL; }' \6 l; E0 _- F4 V: b' G0 d
          sys.suspend |= SUSPEND_MOTION_CANCEL;
6 R7 i/ u) e0 _7 s( `( i$ k        }
0 F3 P* K5 U' w5 A" ^( u0 A0 w  S0 I1 q2 p
        // 只在循环时执行进给保持减速
& N) y6 q" x" e         if (rt_exec & EXEC_FEED_HOLD) {
8 ^9 n1 J4 z( x        //只有安全门为1才执行保持进给状态赋值" B5 d$ ~6 U0 ]$ C. W
          if (bit_isfalse(sys.state,STATE_SAFETY_DOOR)) { sys.state = STATE_HOLD; }
) A* E3 f! Z) |        }
$ G% Y9 y$ j. d1 }4 B: A' I6 R
& U* k: }" o3 k1 `        if (rt_exec & EXEC_SAFETY_DOOR) {
' d8 ?, x& G9 n0 F          report_feedback_message(MESSAGE_SAFETY_DOOR_AJAR);
; P" y/ C' o: s5 Q2 f3 v+ X/ /如果已经活跃,准备好重新开始,CYCLE_STOP标志设置为强制断开。$ E2 K% x, L. M1 S
/ /注意:只是暂时设置“rt_exec”变量,不是动荡的“rt_exec_state”变量。1 W2 m4 }  B7 B( V5 \
          if (sys.suspend & SUSPEND_ENABLE_READY) { bit_true(rt_exec,EXEC_CYCLE_STOP); }
) I0 f9 K3 f6 i4 O          sys.suspend |= SUSPEND_ENERGIZE;6 d( Q$ w% h1 a
          sys.state = STATE_SAFETY_DOOR;
1 G) T7 p( F9 m6 ], Z        }# X( }9 c5 O2 m# ?9 s0 P

; R' \7 a& m! t. g: jbit_false_atomic(sys_rt_exec_state,(EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR));   
% ]/ r, U& e3 r: G
) w. k5 I1 w$ L2 u5 W) g}" z' [: s1 s! l( H  Q' H! g' |
以上代码执行了
9 E1 _3 }2 I$ ?/ j( s+ i2 G3 E1.如果全局各自报警标志位其中(执行取消动作) | (执行进给保持) | (执行安全门)任意一位为真进入$ H  R/ Z  L4 N9 _( g+ ?) F
2.系统为闲着状态, 开始循环状态, 回原点状态, 控制取消状态, 开始保持状态, 开始安全门状态时进入
* x6 m( x0 N; \9 T! g$ y' A3.如果是循环状态执行暂停状态  [3 w1 {  O' w) f8 R
4.如果系统闲置状态执行暂停就绪状态
8 J% r+ c' X! M' V0 x  i1 r5.执行动作取消3 j6 q+ C9 Z5 F4 @9 H
6.如果是保持进给状态,执行保持进给状态
# J! [. G, K5 t% O7.执行安全门状态, @6 {. o! N; O9 b! b
最后执行bit_false_atomic清标志清除(执行取消动作)(执行进给保持)(执行安全门)标志位                  ) H( W' K& X; C# t7 \& L: Y9 D
_____________________________________________________________________________: z: j: ]# J8 z6 [
; z2 a; p4 Z! j* |+ X9 d
    // Execute a cycle start by starting the stepper interrupt to begin executing the blocks in queue.- ^6 V8 u0 c* O' V3 u' ?( I: N
    // 执行一个循环开始启动步进开始执行中断队列的街区
  D5 Z9 z# C2 q    if (rt_exec & EXEC_CYCLE_START) {        //循环开始状态进入
/ ~  x) S" l7 L9 Q% Q7 z& k3 k6 H4 r      // Block if called at same time as the hold commands: feed hold, motion cancel, and safety door." t9 N$ Y8 q( J) ?
      // Ensures auto-cycle-start doesn't resume a hold without an explicit user-input.+ m1 J/ V1 S, K, y
          //块如果在同时举行的命令:保持进给,运动取消,和安全的门。 //确保auto-cycle-start没有简历没有显式的用户输入。" h8 H3 L& {- m  c3 y! R0 G
          
, Y; K8 ]8 k2 d  h/ d4 E      if (!(rt_exec & (EXEC_FEED_HOLD | EXEC_MOTION_CANCEL | EXEC_SAFETY_DOOR))) {   //状态机如果不是保持进给,运动取消,和安全的门。
: }/ M$ F9 ~4 O$ g1 ~        // Cycle start only when IDLE or when a hold is complete and ready to resume.6 S% r1 K) X: P6 U
        // NOTE: SAFETY_DOOR is implicitly blocked. It reverts to HOLD when the door is closed.& I8 g# F7 h0 z* w9 G4 ]6 s
                //循环开始时只有当闲置或持有完成并准备简历。
( K( V6 H% i1 o/ c5 ^                //注意:SAFETY_DOOR是隐式地屏蔽。它返回的时候门是关闭的。    ! p3 P7 X7 M% n
" B$ ?9 C1 r+ X# g0 {
                // 如果系统状态为闲着状态,系统状态为开始进给或运动取消,暂停标志为位重新开始  U9 r% N3 I  p7 X$ U2 X4 l
        if ((sys.state == STATE_IDLE) || ((sys.state & (STATE_HOLD | STATE_MOTION_CANCEL)) && (sys.suspend & SUSPEND_ENABLE_READY))) {
4 \3 w1 f3 M, ~& m% d3 L          // Re-energize powered components, if disabled by SAFETY_DOOR.
8 k; }8 M: S6 M7 b1 o2 M7 u          //        由SAFETY_DOOR重振组件供电,如果禁用。6 s, M4 n0 B, y' u
          if (sys.suspend & SUSPEND_ENERGIZE) { 5 ]! [1 Z- {0 S- O+ s+ g
            // Delayed Tasks: Restart spindle and coolant, delay to power-up, then resume cycle.& ?2 h7 ^* @* y
            //延迟任务:重新启动主轴和冷却剂,延迟升高,然后恢复周期。, r  i0 K0 v7 _" b1 P. x+ x: f
            if (gc_state.modal.spindle != SPINDLE_DISABLE) {   //主轴模式不是失能进入
, U$ V1 D4 o5 [: p  L5 O2 ]9 v              spindle_set_state(gc_state.modal.spindle, gc_state.spindle_speed); //设置状态和速度
: ]& ]# f+ L. u$ k3 C2 y7 P# @: m              //待办事项:阻塞函数调用。最终需要一个非阻塞。3 |( [2 Y: R  ]2 P+ C% i
                delay_ms(SAFETY_DOOR_SPINDLE_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually." A; b  K9 O; n, J& T2 y7 y  Z
            }( ~# u7 X/ }" H7 R% F1 t
            if (gc_state.modal.coolant != COOLANT_DISABLE) { : D. T$ Y- G* M( e8 `2 e$ W+ P
              coolant_set_state(gc_state.modal.coolant); # B9 \5 I" G2 }- G
              delay_ms(SAFETY_DOOR_COOLANT_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.
) \7 B0 B3 [( l: P( S& G- w            }0 E: N$ X$ F5 X# G) h( F: k" U& ^
            // TODO: Install return to pre-park position.1 O8 Y: u/ T; s! d2 l. c" F! G
          }4 J  Q3 Q* [! L8 ]1 }
______________________________________________________________________________________________________________0 x& n+ g; v6 M9 G8 M! `: [
          // Start cycle only if queued motions exist in planner buffer and the motion is not canceled.  a- H$ }8 e7 `3 f
                  
- ]9 L6 @% S4 I4 F8 {* I& r1 W& ^                  //只有在队列马达存在规定的缓冲,并且动机没有让取消,才会循环
5 W1 j2 n" W4 v3 w* j                  
) |, e: n9 Y- b% ?9 t. G  O0 e          if (plan_get_current_block() && bit_isfalse(sys.suspend,SUSPEND_MOTION_CANCEL)) {
5 k+ ]6 e. l2 Z2 g4 E' w3 u# _8 q# q; }            sys.state = STATE_CYCLE;
1 j0 u) U/ w! w3 T7 X# \            st_prep_buffer(); // Initialize step segment buffer before beginning cycle.初始化步开始循环之前
5 J$ F# J4 x; _            st_wake_up();; ^: S# J% x% w  }
          } else { // Otherwise, do nothing. Set and resume IDLE state.否则,什么也不做,设置和复位空闲模式
! O$ @' C: t$ c0 {/ G4 @! D  b; h            sys.state = STATE_IDLE;
9 ~/ V! D. N; M          }
; q, _1 D0 ^! P& K  J! l4 W4 i          sys.suspend = SUSPEND_DISABLE; // Break suspend state./ m5 ?  ?) O/ a# Y, A$ A; y! a
        }
+ b' |' d  l) b" s) q3 ~* l% {      }    . T' q2 p; A: _" y
      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_START);        - \( _4 s+ [/ v
    }
9 v6 ]. w8 O; Q# H  [8 n3 I! z+ Q
_______________________________________________________________________________________________________
) A& A2 y2 \' f: {7 Y    // Reinitializes the cycle plan and stepper system after a feed hold for a resume. Called by $ t% d5 E3 M1 e* a
    // realtime command execution in the main program, ensuring that the planner re-plans safely.
/ u, c! ?0 p. j% Z4 H    // NOTE: Bresenham algorithm variables are still maintained through both the planner and stepper5 s1 S6 j' u, q
    // cycle reinitializations. The stepper path should continue exactly as if nothing has happened.   
' W1 n3 v" O, n    // NOTE: EXEC_CYCLE_STOP is set by the stepper subsystem when a cycle or feed hold completes." Y( L) A. O# `6 l
& k, N0 }9 b# P- ?+ p! X' W$ K5 m9 v
        //重新启动后循环计划和步进系统的进给保持简历。通过实时命令执行主程序,确保安全计划重新计划。' i2 B1 R0 y9 Z( L
        //注意:画线算法变量仍保持通过规划师和步进
6 j+ K+ V( A( M- [/ _        //循环仅。步进路径应该继续,好像什么都没发生一样。       
$ A( H0 K1 k+ S$ g: y  q        //注意:EXEC_CYCLE_STOP由步进子系统周期或进给保持时完成。, s5 V$ E5 u' d! J+ W
- z! f1 l- m* t: @' N. d* l- H
    if (rt_exec & EXEC_CYCLE_STOP) {                         //如果是循环停止状态进入
' k6 G1 M5 X2 `+ u* ~      if (sys.state & (STATE_HOLD | STATE_SAFETY_DOOR)) {) A$ o/ R1 W7 o& z6 G, L  X
        // Hold complete. Set to indicate ready to resume.  Remain in HOLD or DOOR states until user
" e( }. J) m5 {5 e2 ^! k        // has issued a resume command or reset.: O7 Y+ a9 H( C5 r4 M
! @  u/ t! U! X. P
                //保存完整。设置为指示准备简历。继续持有或门状态,直到用户3 {  y* S( A$ Z! M
                //已发布了一份简历命令或重置。
9 _0 K" d. ?$ q+ p               
# J0 F( y8 |' T2 f/ j# d$ K9 a* f: U: U        if (sys.suspend & SUSPEND_ENERGIZE) { // De-energize system if safety door has been opened. 如果安全的门已被打开。断开系统4 x4 r5 @9 Z6 }+ U9 A* G
          spindle_stop();
* ^! N8 f+ G  Q. r2 m# Y          coolant_stop();
" C1 O* a9 V; M          // TODO: Install parking motion here. 安装停车动作。
  g. L; C9 z" e" w& M0 h        }" V/ B$ ^* A6 |$ B% ^& l
        bit_true(sys.suspend,SUSPEND_ENABLE_READY);4 }5 D, [. |) Y" L4 r1 \* P8 z- z
      } else { // Motion is complete. Includes CYCLE, HOMING, and MOTION_CANCEL states. 电机完成,循环,回原点,,MOTION_CANCEL& V, K4 c. `6 U
        sys.suspend = SUSPEND_DISABLE;3 N1 g: M4 y" E. {* n& [
        sys.state = STATE_IDLE;
7 k2 Q' q) u. \3 q9 I7 |      }  A0 q$ j: h& q" o& T
      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_STOP);
; b5 E& P1 S7 c- t& |4 J    }  H' h/ M. ~  F6 h
    ' a. p( W# g" N0 Z! g. @: f
  }; O" c7 f5 P+ h5 F( q5 T
___________________________________________________________________________________________________5 s4 S+ |& g6 J1 p

9 \" W) n1 S2 ?  // Overrides flag byte (sys.override) and execution should be installed here, since they
" S0 b/ C& {  j. T0 @1 _" a* _  // are realtime and require a direct and controlled interface to the main stepper program.
1 G5 R& u) A# M) i" H! M: B- P. y1 |: I; Q
  //重写标志字节(sys.override)和执行应该安装在这里,因为他们
8 D+ j  H: d9 b' S) A  //实时和需要直接和控制接口的主要步进程序。: }+ `; u" B( s6 O0 u" p

4 w) C1 J% _. r/ e7 W2 o2 b8 U5 c
% }% W1 l  S, T/ Z$ W  // Reload step segment buffer 重新加载步段缓冲1 I/ ^% Z; W4 F: Q; W  S5 }
  if (sys.state & (STATE_CYCLE | STATE_HOLD | STATE_MOTION_CANCEL | STATE_SAFETY_DOOR | STATE_HOMING)) { st_prep_buffer(); }
6 s, |$ e* c( }9 D) v. @
8 m- [9 R0 d' ?( ]  // If safety door was opened, actively check when safety door is closed and ready to resume.
: M0 v4 B6 {% a+ ]% u) M2 [  // NOTE: This unlocks the SAFETY_DOOR state to a HOLD state, such that CYCLE_START can activate a resume.        / Q5 M: w  z' f" W- Y4 G
9 h0 O8 ]- s8 x2 l
//如果安全的门被打开,积极检查当安全门关闭,准备简历。1 v; l. ]" [& ]# Y! w
  //注意:这解锁SAFETY_DOOR状态保持状态,这样CYCLE_START可以激活一个简历。
; o4 w6 z' V, E$ k$ M- a' G
, T% T9 }6 j# j* l  if (sys.state == STATE_SAFETY_DOOR) {                 //安全门状态进入& I0 x- \' y* N/ u* c. e" X
    if (bit_istrue(sys.suspend,SUSPEND_ENABLE_READY)) {
6 E) u6 w6 o: g2 Y$ T& H5 A1 {      if (!(system_check_safety_door_ajar())) {
* m3 `* Z' G9 Q" U; K1 K- `        sys.state = STATE_HOLD; // Update to HOLD state to indicate door is closed and ready to resume. 更新保存状态指示门关闭,准备简历。% k. ]5 L2 G3 @. H9 J9 c. S; I. t
      }
1 C, H2 Q4 w" w" y1 j5 M    }
! v6 o3 J: p: j/ |. |  }
$ v3 p" `$ `" R
( A. \8 N/ o: \, a  } while(sys.suspend); // Check for system suspend state before exiting.( z  ^; w1 _% [$ M* v2 r! P7 h
  $ m$ d5 B' `9 q
}  
回复 支持 反对

使用道具 举报

10#
发表于 2016-8-25 09:31:12 | 只看该作者
楼主这些代码。是网上搜来,然后自己组合的吗?全是自己想的,那是牛逼了

点评

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

使用道具 举报

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

本版积分规则

小黑屋|手机版|Archiver|机械必威体育网址 ( 京ICP备10217105号-1,京ICP证050210号,浙公网安备33038202004372号 )

GMT+8, 2024-11-16 12:46 , Processed in 0.085680 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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