机械必威体育网址

 找回密码
 注册会员

QQ登录

只需一步,快速开始

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

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

[复制链接]
跳转到指定楼层
1#
发表于 2016-8-20 23:56:23 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 1五湖四海1 于 2016-8-21 00:09 编辑
. z" t9 z; F% V2 u+ N
6 A% W) |7 k0 `# [: _2 X! I1 S    以前制作过CNC雕刻机,是用MACH3作为上位机控制,硬件是采用PC接并口输出脉冲和方向使能信号经过隔离驱动步进电机驱动器,步进电机驱动是采用TB6560芯片控制。最后就接到步进电机。机械是用铝合金制作,主要部件有三个1605的滚珠丝杠,多个运动滑块等制作。用这台DIY CNC雕刻机可以雕刻木头塑料等东西。当时没有一直玩下去,现在发现网上有用单片机制作的雕刻机挺精巧的现在分享给大家。
' _  n( o6 Q; `* _( w   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个运动来规划运行速度,以实现平稳的加速和无冲击的转弯。很棒吧!开始玩起。
& J" p- \" a, [+ O3 H: c; q% h2 R    还没有雕刻机的机械部分可以用废旧光驱制作个微型雕刻机运动平台。雕刻机最重要的是主控程序这次用 Arduino/AVR328单片机,价格在15元左右,主控程序是上面提到的目前很火的开源
的GRBL,还有一种基于STM32平台的开源主控程序Dlion也不错可以替代grbl。如果从性能比较这两个方案,显然是stm32平台运行速度更快毕竟他是32单片机呀!( g" ]7 X9 v& g8 o
! Y# W/ q; J& W2 D+ H% C; P
$ X2 A5 o# ^% z5 a) I2 [( p
    下面介绍小这个些主控程序主要干的事,通过串口PC和主控板通讯,PC命令给控制板,控制板接收命令做不同的响应,PC可以发G代码给主控板,接收完成后可以自动开始雕刻任务。
5 ]5 g$ X, N: `; p) p: \; `5 y          在介绍下G代码因为G代码是雕刻机的核心部分* a5 n' m" d8 }- H. U8 ~2 I/ ?
G代码是数控程序中的指令。一般都称为G指令。! T/ o! z: C. w
G00------快速定位
7 T+ ^5 M( A2 C( _+ x) C9 ~G01------直线插补
0 }8 U% G& S, K; XG02------顺时针方向圆弧插补
. {- w3 W" z2 b# nG03------逆时针方向圆弧插补
) K7 o+ A' K: E+ R0 J  r8 cG04------定时暂停
  g! i: p8 P) YG05------通过中间点圆弧插补0 b0 p# K- m/ K  e: P
G06------抛物线插补
- Q( Y2 L, k2 X* vG07------Z 样条曲线插补/ v. i" e* A. Z( T7 d
G08------进给加速
: h. X" C8 a8 {, N( m* D0 }G09------进给减速
( ^* l) O0 x3 Z$ F' i1 CG10------数据设置
3 b. n: Q+ X7 ]% ^6 h5 Z1 RG16------极坐标编程% W  F, a+ z& o0 u8 x& Q, m
G17------加工XY平面6 Q3 _6 ^/ g- I! {/ @) ~
G18------加工XZ平面
; |8 {8 N1 h# n/ G+ [  EG19------加工YZ平面

6 ?7 H+ D: V9 k2 ~0 D8 D核心就是解析G代码,完成步进电机驱动,和控制主轴开启关闭,还有插补算法,直线插补,圆弧插补,还有一些步进电机的加减速算法。4 S6 M: ~! x  V7 h& j
下面对grbl主结构做介绍
/ u  x5 W& S% E, Q- m0 vmain()主函数首先执行下面初始化函数& h: T7 B* E8 Z( @0 n. z
        serial_init();                           // 设置串口波特率和中断
' I0 S- t. m; [% Y5 L8 f( S' T        settings_init();                         // 从ROM加载grbl设置  B! B- `+ w6 [% @
        stepper_init();                          // 配置步进方向和中断定时器
/ i; {1 y( s0 ^) B* Q: [; z        system_init();                           // 配置引脚分配别针和pin-change中断
3 o% p" G- @$ y0 y# O        memset(&sys, 0, sizeof(system_t));          // 清除所有系统变量7 t" w, n: I9 [" v# g* ^
        sys.abort = true;                           // 中止标识位置位$ S- o7 n& D$ }0 @6 [7 S7 N' k
        sei();                                         // 使能中断, N) y* C  `! O/ s9 d) o9 w
  #ifdef HOMING_INIT_LOCK                        // 宏运算(settings.flags & (1 << 4)) != 0结果flags等于执行sys.state = STATE_ALARM
) X$ {( q' F! e0 o3 r3 S6 Y- R                                                // 系统状态赋值为报警状态# M. U+ f, R& {2 X' T$ L& u" g4 j. u
            if (bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE)) { sys.state = STATE_ALARM; }/ Z% f/ R5 L4 H$ U8 s
  #endif- t5 n- @9 p, Z  J+ w
_____________________________________________________________________________________________________________________________________
$ r# p4 D# ~! I- Q" S0 n& J接下来是一些主要部分初始化5 u& ^: {9 f) G' b* ?
for(;;) {
. _9 A! I& S' j        serial_reset_read_buffer();         //清除串口读缓冲区
' P( e5 z- X- I5 l6 `' W        gc_init();                         //初始化G代码功能函数" @1 `4 ^$ q6 {3 H/ d
        spindle_init();                        //主轴初始化6 @" O7 _3 G5 i6 e$ B8 l5 _1 u
        coolant_init();                        //冷却液初始化
' y  o% ?( M3 y3 \9 W2 P+ p/ ~        limits_init();                         //极限开关初始化
1 a4 W3 x, P, k# t$ p# ^        probe_init();                        //探测部件初始化
* c7 P; y- O4 N% G0 ~: v        plan_reset();                         //清除块缓冲区和规划师变量
# P  X. s3 w6 M% Z% R( f        st_reset();                         //清除步进系统变量。; q" c7 a* U; ^& o( B2 ^( Y
! }! ?5 z3 @; I; f8 W. O3 H
: E  k6 A2 x, o- o# ^
        //下面两行清除同步gcode和策划师职位当前系统位置。
+ M5 j0 n7 t* s* E( s& G+ M) A
        plan_sync_position();
6 p( l% e: V7 s; z1 A0 u! c        gc_sync_position();  ^8 y; n) X; \+ v! T

2 j, ]1 e) r) M1 O/ T( E: H1 @/ s) Z2 K5 s  G8 b% F9 C
        //复位系统变量4 N. x' S( [8 D3 w7 c% {% h
        sys.abort = false;                //系统中止标志1 P. B' [5 o2 E* l( \
        sys_rt_exec_state = 0;                //系统标志位变量状态管理。看到EXEC位掩码。
. O% V, ^$ o  z5 x0 c5 W        sys_rt_exec_alarm = 0;                //系统标志位变量设置不同的警报。9 M% m- X+ ^" Q1 L- C( U
        sys.suspend = false;                //系统暂停标志位变量管理,取消,和安全保护。
+ ~1 f3 n4 ?  F7 z        sys.soft_limit = false;                //限位开关限制状态机错误。(布尔)
- j  g! t# S+ X2 Y- p! L  {6 r+ ^9 l  g8 U( A2 l" U$ N

8 d* j( B1 `4 \; m- p        protocol_main_loop();                //主协议循环
* N$ O& c: R" Z- Z}        //3 r0 ^4 g) ~4 T2 q
_____________________________________________________________________________________________________________________________2 e& D$ K* w# v# @$ X
进入void protocol_main_loop()函数
2 w1 x- [( G8 x0 e7 e. d3 g{
! V9 l; R" e' `: b3 `$ h) c, w        report_init_message();                // 打印欢迎信息
4 X9 s, |* `! ]% g  n  [0 q        //重启后检验和报告报警状态如果错误重启初始化。9 l. s) ^7 B8 Y, ~
        if (sys.state == STATE_ALARM) {
5 v+ o% h' c1 ?5 `* \6 ^            report_feedback_message(MESSAGE_ALARM_LOCK); //打印信息3 e" ~: x' B" T* g' b
          } else {* m7 Z3 m6 b, }( X( r( h2 f
            // 如果没有报警说明一切正常!但还是要检查安全门.
+ g- j5 x9 j) ^$ J( ?3 a$ G            if (system_check_safety_door_ajar()) {: q4 {) l5 c( p5 y9 P+ k1 V
                     bit_true(sys_rt_exec_state, EXEC_SAFETY_DOOR);
$ t; U$ I' D) T1 _/ k4 l5 [! A1 r                     protocol_execute_realtime(); // 进入安全模式。应该返回空闲状态。* ^; U( @9 K# \3 R. B2 G; v+ G
            }         else {* @, T" {4 k& E! k" z/ g
              sys.state = STATE_IDLE; // .设置系统做好准备。清除所有国家国旗。' @; U$ ^5 M/ p) \4 f- q  k. a
            } 4 B, j. S$ a/ f8 @/ o9 ?
            system_execute_startup(line);    //开始执行系统脚本+ t/ a& Y* G( v. g# p
  } 9 B! V. E: I) T+ A% c- P
3 Z) C0 {9 U0 v
7 u; E7 G& \6 z. j8 P' f
  // 这是主循环!在系统中止时这是出口回到主函数来重置系统。8 Z9 O. @- d+ H$ v$ X& p* M/ j
  // ---------------------------------------------------------------------------------  2 Z' P3 o" {3 F* y1 S
  & s# ?" X8 D) |" ]- r6 X
        uint8_t comment = COMMENT_NONE;' [1 M1 l. J  y- P' M3 M& P) B: d5 d9 E
        uint8_t char_counter = 0;1 h; m; V8 s+ u
        uint8_t c;
: Z" S; Y, F! X  t. K_______________________________________________________________________________________________________________________________3 V+ Y0 p) b% |6 L& z2 @. f+ O" d( y
接下来进入for(;;)循环                //下面代码是G代码解析核心部分,程序中comment(注释)变量会被赋不同值,代表发符号有‘(’‘)’‘;’; T% d# B5 F; G( \$ s! H9 S6 g( f
{
# Z7 _: H# y; q3 F//串行数据输入一行的的过程,作为数据。执行一个; i# E# b* R' W
//所有数据初始过滤去除空格和注释。 / l0 W% n& u) F4 ]6 C, v0 ^
//注意:注释,空格和程序段删除(如果支持的话)处理技术2 u. N0 Q6 {- {# W- Y' U
//在G代码解析器,它有助于压缩到Grbl传入的数据
' k% t" S2 n; j3 Z0 H$ C+ W4 @4 @1 r//线缓冲区,这是有限的。刀位点标准实际上州一行不行0 g1 ?: i, V! I" e
//不能超过256个字符,Arduino Uno没有更多内存空间。
% c7 T( O3 G: m3 A//有更好的处理器,它会很容易把这个初步解析的
' `# [8 B* m0 `//分离任务共享的刀位点解析器和Grbl系统命令。                                                                2 d% W2 ]' O* j; T( [7 C
    while((c = serial_read()) != SERIAL_NO_DATA) {                             //读取串口数据,有数据执行下面代码, o! w% P- U( G5 j$ C
      if ((c == '\n') || (c == '\r')) { // End of line reached                //如果数据是/r,/n代表一行结束! \6 t2 }4 T+ c/ ^) i: W% p2 A
        line[char_counter] = 0; // Set string termination character.        //设置结束标志! w2 L6 b5 N3 _& E+ u
        protocol_execute_line(line); // Line is complete. Execute it!        //一行完成执行此函数% D$ |9 l% n; W6 y' g
        comment = COMMENT_NONE;                                                //注释清零2 r& a4 s5 @1 E# {; Y* S
        char_counter = 0;                                                    //字符计数清零  v2 U! r6 u+ G! }  e6 B
  ( }1 }* a0 D4 p+ A! m
        else {
4 E  E/ n; V) B% X' W/ Y        if (comment != COMMENT_NONE) {  p7 d% e  o3 \8 Q& g
                                                     //扔掉所有注释字符
4 Q2 Z# Q9 N2 Y" t9 _9 x% M          if (c == ')') {# d6 ]* `" `" _
            //最后注释。重新开始。但是如果有分号类型的注释。
3 L3 `+ n0 P6 j" G( Q! L4 G6 Q" O            if (comment == COMMENT_TYPE_PARENTHESES) { comment = COMMENT_NONE; }
$ h. e" Q: \; Q( Z          }
" K. ~3 j9 g  f% ~! L" S! g7 L8 Q      } else {
8 m. H5 r  j( v          if (c <= ' ') { ! C4 T# Z1 v- u1 O
            //扔掉whitepace和控制字符
9 q( i2 O- v( C9 Y" f! B  F          } else if (c == '/') {
6 v& r8 ^! t) e+ L            //块删除不支持将忽略字符。2 x9 n- v- U. F& G3 \
            //注意:如果支持,只需要检查系统是否启用了块删除。9 ^4 ~# w* H1 g0 e. j# A
          } else if (c == '(') {" G/ G: c' t4 `8 I
            // Enable comments flag and ignore all characters until ')' or EOL.( W7 D0 s. V9 O( t( ]! ]7 T
            // NOTE: This doesn't follow the NIST definition exactly, but is good enough for now.
8 M! f5 a; r! J) X8 X            // In the future, we could simply remove the items within the comments, but retain the0 y$ F' ~3 E) N1 R8 g, j
            // comment control characters, so that the g-code parser can error-check it.
! s& z, a/ {$ @1 p) X8 ^5 d; R            comment = COMMENT_TYPE_PARENTHESES;1 a- k5 p1 E* _7 ~% ~0 H/ Z' D( M
          } else if (c == ';') {
3 a6 e+ h5 |: i6 ~: L1 `2 G, @            //注意:','注释EOL LinuxCNC定义。没有国家标准。1 s/ ^& q( K( P1 E5 C
            comment = COMMENT_TYPE_SEMICOLON;
( f8 U; Z/ N/ b' C$ Q9 k/ ]3 C; b: I; }) O) l3 d3 W& H
0 k9 ]' q3 G# |) i- O# T; ^
_____________________________________________________________________________________________________________________________________6 [$ Q: w) i4 ~' J$ `2 j$ t; Y
          } else if (char_counter >= (LINE_BUFFER_SIZE-1)) {                        //串口接收数据大于80字符时' e# y0 L: v! h2 _) L; U
            // Detect line buffer overflow. Report error and reset line buffer.        检测缓冲区溢出。报告错误和复位线缓冲区。' V! L2 a1 B5 W$ b8 k8 y. w" o
            report_status_message(STATUS_OVERFLOW);                                //打印溢出信息2 X) ^, j5 ]' Z8 s- M3 |. M
            comment = COMMENT_NONE;
. ~1 Q! n4 D8 b$ [1 z            char_counter = 0;. S3 r( G8 ^. V2 a
          } else if (c >= 'a' && c <= 'z') { // Upcase lowercase                        //小写改大写0 m0 G% E/ Z8 V; L8 T
            line[char_counter++] = c-'a'+'A';
( V6 T; `: b8 N2 p, j" h9 N          } else {( Q. W1 V* Z) X9 a$ f/ D( B
            line[char_counter++] = c;
; ^0 H  |2 e! n# N; q8 K          }' m3 [; k: ^5 m+ a0 \+ L
        }
+ N4 w) a' r4 [- }4 v& g      }
) B- B; |! \5 X; s* p+ h+ F5 p    }
+ a  Z5 T( ]9 t3 @. J____________________________________________________________________________________________________________________________________
. U& X+ m3 W( f* @3 f# r& n        //如果没有其他字符在串行处理读取缓冲区和执行,这表明以完成,自动启动,如果启用,任何队列动作。
. X5 P1 d7 w8 |8 t6 t- ~) a        protocol_auto_cycle_start();                //自动开始协议循环
8 r! H( H  L! Q, K        + z' p! C. k3 v. Q$ v
            protocol_execute_realtime();                  //运行实时命令。5 y( @; D8 ]& f! W
            if (sys.abort) { return; }                 //中止标识置位程序循环重置系统。            
) _1 S3 @" u. y3 u9 R" m  J  } . \5 i$ ]: e/ l) m
  return;                         //一般程序不会执行到这里) d. u8 B6 `/ n1 A0 F
}4 b9 m9 E( C- q* z( }% }
____________________________________________________________________________________________________________________________________
, Y4 U0 L; u! I& d正常情况下,读取完G代码程序会进入protocol_auto_cycle_start();//自动开始协议循环 函数下面介绍此函数# T. r+ P' e% D1 V9 G
// Auto-cycle start has two purposes: 1. Resumes a plan_synchronize() call from a function that! G- n/ f3 V8 V( O; l% K* m: _
// requires the planner buffer to empty (spindle enable, dwell, etc.) 2. As a user setting that   \8 G+ j) T( m( {# }4 X( U0 P
// automatically begins the cycle when a user enters a valid motion command manually. This is & {4 {- f% M# u
// intended as a beginners feature to help new users to understand g-code. It can be disabled4 ~! l/ c& E6 Q0 Z: _" e7 M
// as a beginner tool, but (1.) still operates. If disabled, the operation of cycle start is
& z7 N8 `5 @8 j/ q// manually issuing a cycle start command whenever the user is ready and there is a valid motion ( c$ j$ h; s& h' k/ x- ]
// command in the planner queue.2 H5 S* p# u8 x
// NOTE: This function is called from the main loop, buffer sync, and mc_line() only and executes
! L. k( s3 A/ |2 y% W, C// when one of these conditions exist respectively: There are no more blocks sent (i.e. streaming ( b- O# j& Q2 `: ~, A" a
// is finished, single commands), a command that needs to wait for the motions in the buffer to ! o$ \1 |' |6 W  N+ P" e0 _, b
// execute calls a buffer sync, or the planner buffer is full and ready to go.
& M% }8 u+ p7 ?: b//自动开始有两个目的:1。回复一个plan_synchronize()调用的函数% t, c3 q, P3 c" g" y+ l" b" S/ p
//需要规划师缓冲区空(主轴启用、住等)2。作为一个用户设置. Q% ?. b" p3 S' d6 \4 s
//自动循环开始当一个用户输入一个有效的运动命令手动。这是3 K4 {' t% Z2 b  @
//作为一个初学者的特性来帮助新用户了解刀位点。它可以被禁用* ]/ C% s& ?" N0 u; k
//作为一个初学者工具,但(1)仍然运作。如果禁用,运行周期开始
( g+ N' M3 }& U$ V5 `* e//手动发出一个周期开始命令每当用户准备好,有一个有效的运动1 Z3 r9 n; n! V9 r9 z
//命令的规划师队列。" d! r7 V! W( ~9 }* M
//注意:这个函数被称为从主循环缓冲区同步,mc_line只()并执行
" u* O8 J2 ^% P* d//当其中一个条件分别存在:没有更多的块(即流发送8 o8 C$ L  T! M
//完成后,单一的命令),一个命令,需要等待缓冲的动作3 A4 E7 K6 N) W0 A# X( Q
//执行调用一个缓冲区同步,或规划师缓冲区满了,准备好了。2 J6 y# n& R2 b% H9 @2 s
void protocol_auto_cycle_start() { bit_true_atomic(sys_rt_exec_state, EXEC_CYCLE_START); } $ f2 Q5 F1 H* L3 O3 m
_______________________________________________________________________________________________
  _. \/ E% i9 G6 D; B  e接下来程序运行protocol_execute_realtime(); /运行实时命令。
0 P3 O; C# I8 T8 O) w7 G// Executes run-time commands, when required. This is called from various check points in the main3 o+ N- e; O5 M$ W% r9 E4 F% n
// program, primarily where there may be a while loop waiting for a buffer to clear space or any
( @- q& ]2 n3 T, v5 E// point where the execution time from the last check point may be more than a fraction of a second.
0 l3 l: S/ J' {2 R// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code
$ d" G9 o: n3 ]7 Y) q( H/ J// parsing and planning functions. This function also serves as an interface for the interrupts to
$ c9 P6 h3 y8 P, ]' W  }// set the system realtime flags, where only the main program handles them, removing the need to
6 f! a! F6 j! G6 y8 F% J// define more computationally-expensive volatile variables. This also provides a controlled way to
" I. u1 {3 |( @9 X// execute certain tasks without having two or more instances of the same task, such as the planner- _  A. }: Q' L7 }% B* x8 A
// recalculating the buffer upon a feedhold or override.
, m3 i6 j; e9 m: [2 T1 r// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,
2 ^/ E9 \! g8 T0 C7 ]// limit switches, or the main program.- f) f( m" y+ d  g; _- U7 P, q
void protocol_execute_realtime(). {3 N: T# B2 @4 j
uint8_t rt_exec; // Temp variable to avoid calling volatile multiple times.临时变量来避免多次调用不稳定。5 M5 H, s3 j  K# {
就先分享到这吧!$ f2 }% ?! f1 J% R: I

% }% U9 B! u& o5 J; v7 r& _5 N: }1 l2 U' P

+ ~; j2 g3 X+ y+ M/ |8 I' h' ~; E
. |/ X9 }$ R0 U* r5 w; j$ e* w. n' R6 O9 X. D6 t% F
9 J9 R/ Z( [  a( [5 [! L

% G" T) A6 i7 b$ v7 K) I2 n
- o) q1 Y* K& J$ b& p
) B, Q0 e" F3 l! z; d. w8 ~0 Q0 {; _  F

: c, V! k* e4 J* N
5 X( ~1 x; U6 K/ j5 V9 w
6 @' Y9 L4 f3 b: ~( n' J$ w8 a
# k: z! U2 o/ |  |5 A& y/ Q. @6 V0 k2 |

4 K/ ~- |. Z/ M( e3 s8 y5 k" a" Z1 T7 ~  P# U/ N% p
( c* F, u& F6 |) T( v& x, h

1 ]8 W+ k) r: z; Q- y/ i- I5 B! y
! F9 f9 o6 W( o  M, \- _8 ^
3 p* p  {% m" W' \2 ?4 S5 x! z
7 M) D1 w# }* L& c% v

0 O/ N9 S$ p) p# r$ X. d" {  H补充内容 (2016-8-25 22:40):
) g8 U2 S' S6 X- L8 w1 y配置说明
6 o) F( S3 K. h3 d$ H//这个文件包含编译时配置Grbl的内部系统。在大多数情况下,
; |0 S0 ^& r: N* \. s//用户不需要直接修改这些,但是他们在这里为特定的需求,即。
& T/ D. z6 n) p6 z0 ~& l//性能调优或适应非典型的机器。
* r0 U" K2 F" |% ^8 m5 e+ A# S主要配置项:
9 V$ n- o2 S0 z% l8 l8 v& @1.#define DEFAULTS_GENERIC        //在重置eepm时使用。在defaults.h改变想要的名字
7 i- l! p3 }# k- u. U8 K9 r4 j2.#define BAUD_RATE 115200        //配置串口波特率1152004 m# f5 R# d& g
3.#define CPU_MAP_ATMEGA328P         // Arduino Uno CPU: Z) e5 z  J! ^# O! X
4.#define CMD_STATUS_REPORT '?'        //定义实时命令特殊字符" T' [% D9 g( ~5 F
5.#define HOMING_INIT_LOCK         //回原点保护锁) ]7 r# W& \9 r! u; W: q6 ~' }
6.#define HOMING_CYCLE_0 (1<<Z_AXIS)              // 第一步Z清除工作区。
9 {$ R# }6 W$ g# q. w9 d  #define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // 然后X,Y在同一时间。
& h' {9 Z# H7 W8 F  i& P7.#define N_HOMING_LOCATE_CYCLE 1 //回原点循环次数
0 e2 K$ b# u" C% H& t8.#define HOMING_FORCE_SET_ORIGIN //取消这定义迫使Grbl总是在这时候位置设置机器原点尽管开关方向。+ _4 o9 v0 Z7 D- `, l( r2 i3 Y# V
9.#define N_STARTUP_LINE 2 //块Grbl启动时执行的数量。7 @+ E  V! W; I4 r. q! K) Q, H; P, X
10.#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 协调或位置价值英寸. M& @1 f% x' W1 G
   #define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 协调在毫米或位置价值$ J% _. c. N+ F/ o/ z
   #define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分钟的速度值
5 N6 l# r7 B& v; C8 R# |; D0 Z   #define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分钟0 V' Y1 `3 N% g" P( o0 Q& T
   #define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 对浮点小数设置值) c" H0 O* Y0 G( j8 I! `3 _1 p  w+ B
11.#define LIMITS_TWO_SWITCHES_ON_AXES //如果你的机器有两个极限开关连接在平行于一个轴,您需要启用这个特性; S# u1 ^% ]: ?0 p$ b. L) E7 T8 m
12.#define USE_LINE_NUMBERS         //允许GRBL跟踪和报告gcode行号
. {. b3 Z, |/ c- n13.#define REPORT_REALTIME_RATE //允许GRBL报告实时进给速率
$ Z4 o* h: V+ t& B14.#define MESSAGE_PROBE_COORDINATES  //坐标通过Grbl $ #的打印参数?7 [7 D* k1 B7 m! }1 e$ {1 a
15.#define SAFETY_DOOR_SPINDLE_DELAY 4000 //安全门主轴延时
* w" ?- p" P. f! \16.#define SAFETY_DOOR_COOLANT_DELAY 1000 //安全门冷却液延时
# O+ l1 r' s$ h3 ?9 T1 c9 A5 @  s17.#define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS) //启用CoreXY运动学。
2 f6 e; L3 T" Y+ V% N18.#define COREXY // Default disabled. Uncomment to enable.改变X和Y轴的运动原理- ~, M1 `; v, N* P5 j
19.#define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.反转针销逻辑的控制命令
; B* u0 m; x; o/ `/ [$ R& {: u1 ]20.#define INVERT_SPINDLE_ENABLE_PIN // 反转主轴使销从low-disabled5 \- q1 N: j- m
21.#define REPORT_CONTROL_PIN_STATE //启用控制销状态反馈状态报告。
& K, |5 x! j6 p2 |0 q$ X% a22.#define FORCE_INITIALIZATION_ALARM //启用和用户安装限位开关,Grbl将启动报警状态指示. j' h2 w3 e" [( Z7 h5 k
23.#define REPORT_GUI_MODE // gui允许最小的报告反馈模式
" P- u$ L  {% c  i24.#define ACCELERATION_TICKS_PER_SECOND 100 //加速度的时间分辨率管理子系统。
* b) i  ?7 c# v* X" o9 ?" T, K$ K25.#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING //自适应多轴步平滑(积累)是一种先进的功能 . q* T0 o) Q& |# ~6 h
26.#define MAX_STEP_RATE_HZ 30000 //设置最大一步速率可以写成Grbl设置( C$ E  N* Z' Q( c: C
27.#define DISABLE_LIMIT_PIN_PULL_UP //以下选项禁用内部上拉电阻* l& `7 `( v3 y3 A9 _' o! ~
28.#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS //设置哪个轴长度补偿应用的工具。假设轴总是与选择轴工具面向负方向
$ H1 q+ v9 V% D% E& R! D29.#define VARIABLE_SPINDLE //允许变量轴输出电压不同的转速值。) V7 [* N- F$ L/ L
30.#define SPINDLE_MAX_RPM 1000.0  // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.
6 W; w  ^% @6 }0 v9 v) o2 |+ d4 U" C   #define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.
/ w) U: d; x; d. [1 U4 ?. j$ a31.#define MINIMUM_SPINDLE_PWM 5 //使用的变量轴输出。这迫使PWM输出最小占空比时启用。/ s$ |8 {: x! o! U6 P' L
32.#define USE_SPINDLE_DIR_AS_ENABLE_PIN //主轴方向使能M4被删除
* A% t- f; F/ J, g& u33.#define REPORT_ECHO_LINE_RECEIVED //应该对所有正常线路送到Grbl# @' w/ T$ k+ E
34.#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min) //最小规划师结速度。设置默认最小连接速度规划计划
4 T8 ~+ l$ \! Y) d4 @; R35.#define MINIMUM_FEED_RATE 1.0 // (mm/min)//设置计划将允许的最小进给速率5 k* J: F/ ^' ^  y
36.#define N_ARC_CORRECTION 12 //弧生成迭代次数之前小角度近似精确的弧线轨迹5 L7 z, @# B+ g+ e
37.#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)//定义值设置机器ε截止来确定电弧是一个原点了?
9 q6 K2 G' S& v3 v4 X9 J38.#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds) //延时增加表现在住。默认值设置为50毫秒
  Q, d2 F5 A/ m6 @4 M39.#define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.
+ o7 N& F9 B$ F40.#define BLOCK_BUFFER_SIZE 18  //线性运动规划师缓冲区的数量在任何给出时间计划1 ~7 t8 a  k- s/ ~
41.#define SEGMENT_BUFFER_SIZE 6 //控制之间的中间段缓冲大小的步骤执行算法, m) R/ i% J5 q9 E! b
42.#define LINE_BUFFER_SIZE 80 //行执行串行输入流的缓冲区大小。
" b: ~  _! n, X43.define RX_BUFFER_SIZE 128 //串行发送和接收缓冲区大小$ i2 w3 n) e+ Q. J/ f' G" H
44.#define TX_BUFFER_SIZE 648 H, A* b" i2 q, ~& d3 j3 R
45.#define ENABLE_XONXOFF        ////切换为串行通信发送流软件流控制。
' {; L3 F6 R; k6 G6 p1 J46.#define ENABLE_SOFTWARE_DEBOUNCE //一个简单的软件消除抖动特性硬限位开关。* B: d% z7 A: J' k. g9 _! f4 L
47.#define HARD_LIMIT_FORCE_STATE_CHECK        //Grbl检查硬限位开关的状态( z" b7 m6 l$ Q3 B. e
48.// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:编译时错误检查的定义值:
+ Y6 K+ x9 [8 z( j( Y' q% s8 X+ A' }6 f" [
___________________________________________________________________________________________________
5 _7 p9 U7 C/ @1 e0 b. X/*/ n) k: t, E9 g9 D) c  o- S( {
  config.h - compile time configuration* W. X: X. x0 M8 Q! a
  Part of Grbl# Q2 }7 c+ N2 `# E) T7 ^, u- z% X
9 K$ e4 p* A" c  E( Z  s
  Copyright (c) 2012-2015 Sungeun K. Jeon
2 S& k  i$ l$ i. _* Z' n  Copyright (c) 2009-2011 Simen Svale Skogsrud
' R% |' v5 n6 o1 O" P& _# ^3 X3 ]- I5 K% p' _% h
  Grbl is free software: you can redistribute it and/or modify
; Q  o0 r9 c9 z' X/ `  it under the terms of the GNU General Public License as published by
0 O, M# A& h) U6 u' b, S( D  the Free Software Foundation, either version 3 of the License, or( C- X4 R4 @" |8 z8 S
  (at your option) any later version.  z2 f! W1 M' d% H

! W5 ^3 B+ h: [* B1 @# S4 o0 y  Grbl is distributed in the hope that it will be useful,' `& n9 B  Y) F1 T
  but WITHOUT ANY WARRANTY; without even the implied warranty of
) f/ Q9 R6 x( o5 m, g  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1 e8 F4 l& Y' D' d9 e  GNU General Public License for more details.3 l1 X6 s! R. G# Z$ N9 Y

4 |0 A- Y$ w! r3 R  You should have received a copy of the GNU General Public License
0 q& G) T3 W3 \) k# F  along with Grbl.  If not, see <http://www.gnu.org/licenses/>.) ?7 i: C# p3 s
config.h  -编译时配置,Grbl的一部分  U$ m- j, x: F$ O% c3 |

# j, b! c+ ~8 b  h( O* U5 b1 q版权(c)2012 - 2015 Sungeun K. Jeon$ u' v% k# @8 c( w- p7 J5 A; E
版权(c)2009 - 2011 Simen Svale Skogsrud
% O1 p2 x! \) `' a! d+ L: b  ]5 t# h5 l8 O: S* x1 Z
Grbl是免费软件:可以重新分配和/或修改# K, ]4 [' ]  u
GNU通用公共许可证的条款下发布的自由软件基金会,版本3的许可,或(任您选)其后的版本。
6 A2 m* p0 M2 |( }
5 ?3 b/ q' K: ]( oGrbl分布,希望这将是有用的,但是没有任何保证;没有即使的默示保证适销性或健身为特定目的。看到
. e# B/ W$ D. L; f/ }! ]/ |GNU通用公共许可证的更多细节。
7 ]6 h! ~! L) w4 {9 f$ c; m; g& e4 R  w/ O) I0 C& y
你应该收到了GNU通用公共许可证的副本
: I9 L( u: g/ |$ S2 T连同Grbl。如果没有,看< http://www.gnu.org/licenses/ >。
' I7 G* y& B: @8 j  U6 n * l2 h7 s: u- `4 N! e3 `& k- j9 I# {
*/
9 j3 X4 ^4 u1 t& k! R( ?* Q  
4 ?: N. ^! q7 l9 L// This file contains compile-time configurations for Grbl's internal system. For the most part,
3 V1 T6 c/ v  f5 ~// users will not need to directly modify these, but they are here for specific needs, i.e.
3 Z& a( f' T6 J9 D// performance tuning or adjusting to non-typical machines.6 e1 ]' M, `& [% T7 r: x1 o
//这个文件包含编译时配置Grbl的内部系统。在大多数情况下,
+ k' j. O* p# T2 T, ?//用户不需要直接修改这些,但是他们在这里为特定的需求,即。3 x& q. x% }+ [  z) B6 O) w5 K+ e
//性能调优或适应非典型的机器。+ n* q/ ]) Y/ r+ ]& C9 w1 |
: }' u$ C; z$ o4 |
// IMPORTANT: Any changes here requires a full re-compiling of the source code to propagate them.
* P0 G6 v$ a& Z) p% }5 i% w4 l//重要:任何变化需要一个完整的基于源代码的传播。
: A: R/ @* F! i# `- q7 K
- P* U6 x! b3 K) M- |#ifndef config_h  x6 @/ t# t( m' z, j
#define config_h
4 e+ M# T8 A8 A* K! }6 B#include "grbl.h" // For Arduino IDE compatibility.
+ @0 l4 O9 k5 J+ g( i: Q8 d) E
+ K7 e( F6 P) H// Default settings. Used when resetting EEPROM. Change to desired name in defaults.h. G3 v) @( H$ w  }3 r6 E: y) U5 W% s
// 默认设置。在重置eepm时使用。在defaults.h改变想要的名字: I+ J* Y; v" j% G

3 u+ c5 N# J9 c3 P* I+ I& ~( ^; O#define DEFAULTS_GENERIC+ @9 c5 s% F! P9 ~5 G! t9 M# N- G
  H+ w7 {2 K  [" D8 K" [' w8 p
// Serial baud rate
: V  C! I, V) K; U7 F% p, w#define BAUD_RATE 115200                //配置串口波特率115200
$ w6 f/ @! y- r! w* {* `; R
) N- G" Z4 E" f) a; n6 h8 |// Default cpu mappings. Grbl officially supports the Arduino Uno only. Other processor types. }9 }8 K  X3 o  I/ w$ Y
// may exist from user-supplied templates or directly user-defined in cpu_map.h/ V' K! v* v9 e( q) L7 g
//默认cpu映射。Grbl正式支持Arduino Uno。其他类型的处理器可能存在cpu_map.h直接从用户提供的模板或用户定义的( B2 V# ~& y& p) E
/ @' B6 A' ]$ [7 t* B8 F+ J, M
#define CPU_MAP_ATMEGA328P // Arduino Uno CPU' y2 o2 V8 x- }$ O4 d
: y( I$ c8 q/ w0 {' Y$ q
// Define realtime command special characters. These characters are 'picked-off' directly from the; a4 Y7 h- [2 u0 X/ S7 [" l
// serial read data stream and are not passed to the grbl line execution parser. Select characters9 [2 \& w) e9 @! N
// that do not and must not exist in the streamed g-code program. ASCII control characters may be ) c2 m  u4 ?; U  O( w
// used, if they are available per user setup. Also, extended ASCII codes (>127), which are never in
& ~/ P6 ]0 I4 Z& L2 K% h// g-code programs, maybe selected for interface programs.
7 b$ W0 [; P( F) z; X// NOTE: If changed, manually update help message in report.c." X! R1 r3 `, D$ D+ I% [* ]4 T' W7 T

+ l, R% s- u1 @9 b6 g" F7 B//定义实时命令特殊字符。这些字符是直接从“各个击破”串口读取数据流并没有传递到grbl行执行解析器。选择角色
1 I( B0 q+ ^+ H! K( {//不,不能存在于程序流刀位点。ASCII控制字符) C! ~' d* r6 w& a% L# |; ~
//使用,如果他们是可用的每个用户设置。同时,扩展的ASCII码(> 127),从来没有$ I1 V4 e' e9 _: G* }4 h9 b
//刀位点的程序,也许选择界面程序。/ I: Z& V6 u0 G. M
//注意:如果改变,手动更新report.c帮助信息。0 j" i% ]0 ?: f- ^2 K! c

  O' p- u+ ]8 Z# Z% o#define CMD_STATUS_REPORT '?'
' ^, D. S, `: m6 `/ g- y#define CMD_FEED_HOLD '!'; q$ T- E+ ^$ I' w
#define CMD_CYCLE_START '~'$ U. ?$ i5 ]* ^: o$ e3 A; B  u
#define CMD_RESET 0x18 // ctrl-x.6 e2 }6 g8 x8 z$ |' F7 Z0 p
#define CMD_SAFETY_DOOR '@'
+ q+ Y8 t$ f6 L4 |& a7 X
1 U& ?( o4 x+ Y7 M, I// If homing is enabled, homing init lock sets Grbl into an alarm state upon power up. This forces
2 B8 _+ Q) N2 M// the user to perform the homing cycle (or override the locks) before doing anything else. This is
! S' v1 z3 p  {) {1 p8 ]. d/ s// mainly a safety feature to remind the user to home, since position is unknown to Grbl.& V; v. |3 Q4 J* F& w0 c0 n9 u

* @( h+ u8 ?7 q. ~//如果启用了回原点,导航初始化锁集Grbl进入警报状态启动。这就迫使
" R$ M  b9 _7 E: R' x//用户执行归航周期(或覆盖锁)在做任何其他事情之前。这是* b. x( j: p8 G/ B8 T. e
//主要安全功能,提醒用户家里,因为Grbl位置是未知的。" F1 w% G8 r: l5 y" X$ h
, |4 ?. R# x1 A+ \: ?
#define HOMING_INIT_LOCK // Comment to disable
/ \0 e" v2 \2 i, W% Y. q# O1 q  t, R* f6 l. d
// Define the homing cycle patterns with bitmasks. The homing cycle first performs a search mode5 u2 A- H) N8 s  P: y
// to quickly engage the limit switches, followed by a slower locate mode, and finished by a short1 z7 k. R3 C$ Y5 K3 {/ P# T5 L
// pull-off motion to disengage the limit switches. The following HOMING_CYCLE_x defines are executed
; S' r1 \; O% t5 g  A: @$ f// in order starting with suffix 0 and completes the homing routine for the specified-axes only. If+ x# o$ [* ~  Q; u+ H; c3 g# c
// an axis is omitted from the defines, it will not home, nor will the system update its position.! n4 Z1 q, D8 S# m( [, E- R
// Meaning that this allows for users with non-standard cartesian machines, such as a lathe (x then z,: L0 S  d" r; }, o% t4 f+ k
// with no y), to configure the homing cycle behavior to their needs. / }8 F; S; W: j+ K& Z
// NOTE: The homing cycle is designed to allow sharing of limit pins, if the axes are not in the same
- |( w: i: }" M// cycle, but this requires some pin settings changes in cpu_map.h file. For example, the default homing
) P; d/ p. _  i// cycle can share the Z limit pin with either X or Y limit pins, since they are on different cycles.; N$ u+ g7 M& m/ j& K
// By sharing a pin, this frees up a precious IO pin for other purposes. In theory, all axes limit pins. I2 f& j- h6 p
// may be reduced to one pin, if all axes are homed with seperate cycles, or vice versa, all three axes
6 e! e1 ^5 @* z7 U// on separate pin, but homed in one cycle. Also, it should be noted that the function of hard limits
* {2 y$ ~" Y6 |# D9 ~1 M// will not be affected by pin sharing.& `: ]+ L- o% q
//定义导航循环模式的位掩码。归航周期首先执行一个搜索模式
& ]5 ^( Q  M# P//快速进行限位开关,其次是较慢的定位模式,完成了由一个短
5 b; T, X+ h7 {, C2 o//拖出运动脱离限位开关。以下HOMING_CYCLE_x定义执行
( G# C  `) Z2 Z# N% E! A//为了与后缀0开始并完成specified-axes只寻的例程。如果& K4 c4 z0 }7 m. J0 [
//定义省略一个轴,它会不在家,也不会系统更新它的位置。
: ^7 ]8 ^) ]. f& T//意义,这允许用户与非标准笛卡尔的机器,比如车床(x,z,
) Y, G% D% c+ o/ S* F7 |, Y3 n//没有y),配置导航循环行为对他们的需求。+ m$ t# p7 x( Y- f2 {; D
//注意:归航周期允许共享限制针,如果轴不相同
6 b7 q9 p2 K% D6 c4 X0 C//循环,但这需要一些销设置cpu_map的变化。h文件。例如,默认的导航
4 t5 y: R  r! @( h- G//循环可以分享Z限位销X或Y限制针,因为它们是在不同的周期。
" c/ f+ Y, |/ h9 I  r//通过共享一个销,这腾出宝贵的IO销用于其他目的。从理论上讲,所有轴限制别针1 w6 i# p1 [* H6 J! j4 S
//可能会减少到一个销,如果所有轴与分离周期居住的地方,反之亦然,所有三个轴
9 S4 A) J2 Z+ [/ s  M//在不同销,但这时候一个周期。同时,应该注意的是,硬限制的功能
* w8 k& Z- r: `! V" S$ l  N# b//将不会影响销共享。
& S0 g" C* m0 U% a3 j//注意:默认设置为一个传统的硬件数控机器。z轴首次明确,其次是X和Y。
6 ~% z0 x! Q0 t5 N. U( J( J9 F: Z4 r9 O: r: |1 M: H/ j
// NOTE: Defaults are set for a traditional 3-axis CNC machine. Z-axis first to clear, followed by X & Y.4 N9 S) |1 u0 ^/ `, n6 E3 t
#define HOMING_CYCLE_0 (1<<Z_AXIS)                // REQUIRED: First move Z to clear workspace. 第一步Z清除工作区。
. ~# V/ [. Y/ {6 ?( F9 @% l! B#define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // OPTIONAL: Then move X,Y at the same time.然后X,Y在同一时间。' `8 o3 U: m3 e  ~
// #define HOMING_CYCLE_2                         // OPTIONAL: Uncomment and add axes mask to enable
+ j1 {* J& H. \- M/ @8 z7 @! ?% s) a
// Number of homing cycles performed after when the machine initially jogs to limit switches.
1 ?6 Y  z  m9 _0 y9 X' H  H4 X+ w2 }// This help in preventing overshoot and should improve repeatability. This value should be one or 6 q8 g/ \9 e# E. e) Q8 v4 ]
// greater., V* u" F+ C& Y) \, E; b6 h6 L
//执行回原点循环次数后,当机器最初慢跑限位开关。这个帮助防止过度,应该提高重复性。这个值应该是一个或大。
6 C# R* K* |" Y! u1 a& @8 \/ o. e+ ?7 O$ J( Z
#define N_HOMING_LOCATE_CYCLE 1 // Integer (1-128)' V" t8 _$ X9 Z8 i2 o6 h& q  {
- ~; m) J# P/ W5 t" N0 z3 @4 h# y
// After homing, Grbl will set by default the entire machine space into negative space, as is typical
# f' Z: e8 ~4 X+ Q. W* s6 K" _' }3 Y// for professional CNC machines, regardless of where the limit switches are located. Uncomment this
9 k4 c9 j! `0 d6 T// define to force Grbl to always set the machine origin at the homed location despite switch orientation.
8 R7 d& J- _! k+ a) j5 H. k, m5 b$ n" P5 w1 Z6 e% n
//导航后,默认Grbl将整个机器空间留白,是典型的专业数控机器,不管限位开关所在的地方。
6 w8 L, g) w5 L//取消这定义迫使Grbl总是在这时候位置设置机器原点尽管开关方向。. f: H+ H. R* Y- K+ {

$ l* i; Z" s& p4 R9 X9 f8 i5 @// #define HOMING_FORCE_SET_ORIGIN // Uncomment to enable.
/ Z& k9 z+ R+ n: {8 v. z3 F, Y! F0 h4 G
, l. r7 W8 [7 z) h# G1 L
// Number of blocks Grbl executes upon startup. These blocks are stored in EEPROM, where the size0 i5 }( [/ e) H4 z
// and addresses are defined in settings.h. With the current settings, up to 2 startup blocks may
' J( r6 F2 a8 y6 r' X# q// be stored and executed in order. These startup blocks would typically be used to set the g-code
6 m" B% ]2 r' d6 J// parser state depending on user preferences.3 ?) {& v% N  q5 V

* b2 `9 E6 q: Q! W/ }: _) \//块Grbl启动时执行的数量。这些块存储在eepm,大小
/ L  O5 j8 Q' l( Z( I//和地址在settings.h中定义。与当前设置,可能2启动块& l& C& J3 K1 c
//存储和执行。这些启动块通常被用来设置刀位点( P, g  r3 M5 i/ k( i
//解析器的状态取决于用户首选项。
& M1 Q( P8 @) j9 c7 P: I* s: [4 J7 S2 q) N* P
#define N_STARTUP_LINE 2 // Integer (1-2)* e$ R* M- N9 p) i! i; S- R  c

6 v# A' W  M- r! ?, g8 I// Number of floating decimal points printed by Grbl for certain value types. These settings are % X: F3 j! G5 B& f6 [0 W! f. A
// determined by realistic and commonly observed values in CNC machines. For example, position
6 V5 {( q: E9 K9 I- N// values cannot be less than 0.001mm or 0.0001in, because machines can not be physically more- X: a" m1 _6 c: c' @
// precise this. So, there is likely no need to change these, but you can if you need to here." a6 r& j7 g" H* ]
// NOTE: Must be an integer value from 0 to ~4. More than 4 may exhibit round-off errors.* R. x5 J0 a* n$ s+ G

% b6 x, L( y, R5 \// Grbl浮动小数点的数字印刷的特定的值类型。这些设置是# W9 V; f+ S6 d9 K: N1 d
//一般由现实和观测值在数控机器。例如,位置
' H3 k) f; M1 o3 ~) |( |! ?% Z) {//值不能小于0.001毫米或0.0001,因为机器不能身体更多
8 ^: Q" f7 R. d/ X$ t//精确。因此,有可能不需要改变这些,但你可以在这里如果你需要。! `5 C1 _' w5 i- r" h
//注意:必须是一个整数值从0 ~ 4。超过4可能出现舍入错误。
% `. a+ A4 W8 k& }! _  e# o! o
3 r; \8 \' y/ ^. C#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 协调或位置价值英寸
, S4 l5 q2 O5 v: m, m* e#define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 协调在毫米或位置价值2 u% I: H/ _  j* T5 H3 ^
#define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分钟的速度值
- H& s$ Y, ?( C. P8 p) p#define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分钟  F4 y' L& ~8 T
#define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 对浮点小数设置值
! k; `# K* B$ K) }1 e
! w! w. O" _" e) ^9 ?3 W7 V2 A// If your machine has two limits switches wired in parallel to one axis, you will need to enable
+ S7 G5 _5 f# |7 b1 O0 Z" r% T// this feature. Since the two switches are sharing a single pin, there is no way for Grbl to tell
3 }6 L3 u; ^' A; N, U; Q6 @// which one is enabled. This option only effects homing, where if a limit is engaged, Grbl will
; m# ?6 V& o" W: K// alarm out and force the user to manually disengage the limit switch. Otherwise, if you have one
, p. N& X8 e( |& \// limit switch for each axis, don't enable this option. By keeping it disabled, you can perform a
# \! a0 f% J7 ]// homing cycle while on the limit switch and not have to move the machine off of it.1 x6 _. a. H- _' q- X2 |
  L9 v1 X4 E( D+ ?3 H
//如果你的机器有两个极限开关连接在平行于一个轴,您需要启用# q: M' L3 o; d, y' I
//这个特性。自从两个交换机共享一个销,没有办法Grbl告诉9 P4 M# |  t5 f3 E3 G7 F- T. ^6 |& i
//启用哪一个。此选项仅影响归航,如果限制,Grbl意志
+ \" b/ {) `$ H//报警,迫使用户手动松开限位开关。否则,如果你有一个6 I( @  E# N' v- P% ?' z. {; P
//为每个轴限位开关,不启用该选项。通过保持禁用,您可以执行
& r$ o# ]! r+ F, G//导航循环在限位开关并没有将这台机器。. M2 r( g- W7 ]3 B  T/ ]# A

# X* Y: ]0 K- G  i! S// #define LIMITS_TWO_SWITCHES_ON_AXES5 q0 o1 p& B' M# B: p- [. N

' \; f( D& J. {% _! a// Allows GRBL to track and report gcode line numbers.  Enabling this means that the planning buffer
! U' m5 ~( W: b+ T// goes from 18 or 16 to make room for the additional line number data in the plan_block_t struct0 ~( R6 \1 f+ s, G7 Y6 J) I; B4 A$ `5 K

9 i2 ?8 ~7 B% f) B//允许GRBL跟踪和报告gcode行号。使这意味着计划缓冲从18岁或16岁,为额外的行号plan_block_t结构中的数据
, [) r- r  s8 p0 }. P) j/ r) \7 c$ f9 [  d5 j
// #define USE_LINE_NUMBERS // Disabled by default. Uncomment to enable.& H4 {9 ?! L1 z( K
' n7 w4 |* i$ |* e
// Allows GRBL to report the real-time feed rate.  Enabling this means that GRBL will be reporting more
  C5 X$ N0 ~: g0 ]- o9 h3 D// data with each status update.
, ]7 S0 d1 d" e- D1 W// NOTE: This is experimental and doesn't quite work 100%. Maybe fixed or refactored later.
9 r% S9 g  g# H# ^6 m//允许GRBL报告实时进给速率。使这意味着GRBL将报告数据和状态更新。: V7 D% |- }* P' M! S# ?1 C: e: G
//注意:这是实验和100%没有工作。也许以后固定或重构。  G$ Z. E* g* X& Z

4 ^$ ]- p7 s( G9 i' |# \// #define REPORT_REALTIME_RATE // Disabled by default. Uncomment to enable.4 t9 x+ F3 t5 I6 H2 b3 ~

$ ?9 u" J9 \+ B& @, B// Upon a successful probe cycle, this option provides immediately feedback of the probe coordinates
0 _" g% l) [; u$ Z8 L' U8 T& H; X// through an automatically generated message. If disabled, users can still access the last probe/ T4 V2 |% f+ a6 _4 r
// coordinates through Grbl '$#' print parameters.: f1 R4 h( f% j8 b0 |. J, L
//在一个成功的调查周期,这个选项提供立即反馈的探测器坐标: V9 X0 E( n0 q
//通过一个自动生成的消息。如果禁用,用户仍然能够访问调查
' v5 ~3 Y! P, m' M6 A7 C( {//坐标通过Grbl $ #的打印参数。
* }5 _2 ]9 ^, [% o' u$ W1 R# `" h$ O. p; h8 ~3 g
#define MESSAGE_PROBE_COORDINATES // Enabled by default. Comment to disable.
9 j6 [4 F! U) N' ~& V   {, w) s& S7 t0 K9 m
// Enables a second coolant control pin via the mist coolant g-code command M7 on the Arduino Uno
( P5 Q4 H2 A+ }  c! A// analog pin 5. Only use this option if you require a second coolant control pin.4 n* m& C# ]$ f+ L; S- V
// NOTE: The M8 flood coolant control pin on analog pin 4 will still be functional regardless.
" ^' f! {3 \/ q5 ~# ?// #define ENABLE_M7 // Disabled by default. Uncomment to enable.
  C* N* W$ _; ]* y+ u0 O) b; G. A  C) \; r' X5 s  z
// This option causes the feed hold input to act as a safety door switch. A safety door, when triggered,
! p* f  ~6 W& r! G8 r6 \& ~// immediately forces a feed hold and then safely de-energizes the machine. Resuming is blocked until
9 i2 n0 {5 I. L( R2 x$ R/ J// the safety door is re-engaged. When it is, Grbl will re-energize the machine and then resume on the
0 {! w9 m% d) R; ~" b// previous tool path, as if nothing happened.
3 n3 b( D. c4 b( P// #define ENABLE_SAFETY_DOOR_INPUT_PIN // Default disabled. Uncomment to enable.
; i5 [* a! t. X9 B6 W* X4 c  @( l2 c
! `# _% x* q- F, m// After the safety door switch has been toggled and restored, this setting sets the power-up delay# ^4 O( L; g; V8 R
// between restoring the spindle and coolant and resuming the cycle.( {4 [0 r* D* L8 q& v1 }
// NOTE: Delay value is defined in milliseconds from zero to 65,535. * ?* w8 y, f+ q' K
2 d' N1 t, C1 m1 f* w  S
//定义导航循环模式的位掩码。归航周期首先执行一个搜索模式
9 B& p+ r& |6 {7 q- d//快速进行限位开关,其次是较慢的定位模式,完成了由一个短
" {1 v  T# v1 F( n//拖出运动脱离限位开关。以下HOMING_CYCLE_x定义执行
9 ~. A, O& C! X//为了与后缀0开始并完成specified-axes只寻的例程。如果
% h; [+ ]( Z  }1 h' v& Q//定义省略一个轴,它会不在家,也不会系统更新它的位置。
8 z$ X! j0 f# s9 c' g) a& N1 K//意义,这允许用户与非标准笛卡尔的机器,比如车床(x,z,1 a  ~9 c' E& B8 y9 A
//没有y),配置导航循环行为对他们的需求。
$ f) D2 a# m$ i- o8 q//注意:归航周期允许共享限制针,如果轴不相同
/ Z0 F6 A1 k' N) o//循环,但这需要一些销设置cpu_map的变化。h文件。例如,默认的导航
& ^  f- d1 Y" x2 L1 D) ^8 i. p//循环可以分享Z限位销X或Y限制针,因为它们是在不同的周期。; `0 V: q9 E. [+ M
//通过共享一个销,这腾出宝贵的IO销用于其他目的。从理论上讲,所有轴限制别针" I, p) k5 T5 d7 X  Y0 w0 M+ ]
//可能会减少到一个销,如果所有轴与分离周期居住的地方,反之亦然,所有三个轴
1 e2 T6 S' a; `, a3 g//在不同销,但这时候一个周期。同时,应该注意的是,硬限制的功能0 I) |" d7 J. e; E1 ]1 O# r
//将不会影响销共享。, {  ~! I! r, v* X* O4 O% C
//注意:默认设置为一个传统的硬件数控机器。z轴首次明确,其次是X和Y。
, L' B2 t9 `% O& _2 b8 h; ^  B8 J; x0 S# x5 W! i, A' A1 a
, C- i5 U8 w8 p) d7 G
#define SAFETY_DOOR_SPINDLE_DELAY 4000
2 f; z0 ?1 l) @  R' K#define SAFETY_DOOR_COOLANT_DELAY 1000
5 M9 `+ F+ t2 u" N! w3 [
6 O0 \5 k+ L- U1 G// Enable CoreXY kinematics. Use ONLY with CoreXY machines. 7 V0 A! |+ w  U9 \, h1 u
// IMPORTANT: If homing is enabled, you must reconfigure the homing cycle #defines above to $ C+ v4 W8 v0 H; G1 O8 f: I) S: q
//启用CoreXY运动学。只使用与CoreXY机器。
8 m* f$ d6 ~/ W; L) v//重要:如果启用了自动寻的,你必须重新配置导航循环#定义上面
" D9 h/ T* S& V9 J
( ]+ z! c( k7 v) `% G// #define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS)
: m; g3 o2 @" E! [7 w! r: [! r1 V+ {) p* Y0 z# P4 @
// NOTE: This configuration option alters the motion of the X and Y axes to principle of operation
" `4 ^+ G) D% t2 N9 F// defined at (http://corexy.com/theory.html). Motors are assumed to positioned and wired exactly as; h. R2 f- ^3 |% \
// described, if not, motions may move in strange directions. Grbl assumes the CoreXY A and B motors8 o7 |8 l/ y1 d% v
// have the same steps per mm internally.% s# p0 N; \2 S: J, I- d* v1 Y: q2 {& d
//注意:这种配置选项改变X和Y轴的运动原理,操作+ _# _1 D" B  b/ e# m& o
//定义(http://corexy.com/theory.html)。汽车被认为定位和连接一样; @- |$ |! C0 I8 p' m$ j/ `
//描述,如果没有,运动可能会奇怪的方向移动。A和B Grbl假设CoreXY马达
' N& g+ O" W5 U: q. y" c$ v//每毫米内部有相同的步骤。
9 m' d7 X2 V: E( o, Z! @9 ?# o& r2 S' P, Z; z+ Z+ q+ U
// #define COREXY // Default disabled. Uncomment to enable.
" D* ?# m/ y& S1 v! Z& H0 N# l( p+ g" q7 [  h% i
// Inverts pin logic of the control command pins. This essentially means when this option is enabled
0 K8 O0 S1 o. j! a; I. a3 Z0 L7 q- ]// you can use normally-closed switches, rather than the default normally-open switches.
& M3 }5 {! o' M5 g" I// NOTE: Will eventually be added to Grbl settings in v1.0.8 D  j) v' x' U
//反转针销逻辑的控制命令。这实质上意味着当启用这个选项
7 R& |3 b- r: ~# t7 p//可以使用闭合开关,而不是默认的常开开关。4 d8 Q* A+ c0 L3 t$ X' G
//注意:最终将被添加到在v1.0 Grbl设置。0 C  w2 y+ o( O- |& J9 l
' B8 ~) W0 c. E0 i; E9 U4 V
// #define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.+ ~/ W3 M* a# D) Y

# E6 H$ c; |; {5 Q. y5 o// Inverts the spindle enable pin from low-disabled/high-enabled to low-enabled/high-disabled. Useful
! {3 R5 M0 h$ R2 v! P// for some pre-built electronic boards.0 |7 v" B! G, a) o# y/ e" |
// NOTE: If VARIABLE_SPINDLE is enabled(default), this option has no effect as the PWM output and 7 @9 E9 k8 |9 c! k
// spindle enable are combined to one pin. If you need both this option and spindle speed PWM,
( S+ I# b4 F  [// uncomment the config option USE_SPINDLE_DIR_AS_ENABLE_PIN below.; X* m, m7 _% c  {
//反转主轴使销从low-disabled / high-enabled low-enabled / high-disabled。有用的. I4 h* D* ]7 L
//预构建的电子板。
1 _# @0 g! ~$ u; H9 Z//注意:如果启用了VARIABLE_SPINDLE(默认),这个选项作为PWM输出并没有影响
. E$ H& E8 {" s4 _//销轴使结合。如果你需要这个选项和主轴转速PWM,1 f5 _* U( p" `" s7 b3 T
//取消注释以下配置选项USE_SPINDLE_DIR_AS_ENABLE_PIN. q( i# m- V3 \! G
% }4 F( D+ k% r. J4 t
// #define INVERT_SPINDLE_ENABLE_PIN // Default disabled. Uncomment to enable.
/ Y! c3 y' a* t8 g# q7 p  w# _" I% w' `8 S
// Enable control pin states feedback in status reports. The data is presented as simple binary of# T" E) r. t% I9 F/ l/ M& f
// the control pin port (0 (low) or 1(high)), masked to show only the input pins. Non-control pins on the , K6 L8 l  e0 C5 S. Q
// port will always show a 0 value. See cpu_map.h for the pin bitmap. As with the limit pin reporting,
- {/ Y1 D: a1 p5 E// we do not recommend keeping this option enabled. Try to only use this for setting up a new CNC.
4 P( ]7 \& n- `5 Q; F4 x2 {. o//启用控制销状态反馈状态报告。作为简单的二进制数据
# j( ^) i9 N6 n& G8 W$ Q, n- |//控制针端口(0(低)或1(高)),蒙面,只显示输入插脚。非控制性针上* i; B. b$ u& t) r
//端口总是显示0值。看到cpu_map。针位图h。与限制销报告,
/ ~+ T3 Q$ u1 L8 K0 X, q//我们不推荐保持启用这个选项。尽量只使用这个设置一个新的数控。% Y8 B5 L2 M) n: Z, A

8 X0 N. L7 Z0 u4 D// #define REPORT_CONTROL_PIN_STATE // Default disabled. Uncomment to enable.
* {( ]" ^" r: S2 V- W8 w) H1 t* p' |0 `# ~! }9 E6 Q
// When Grbl powers-cycles or is hard reset with the Arduino reset button, Grbl boots up with no ALARM5 ~/ b5 {  [" X# }  _% Q/ a* X" Q9 x+ a
// by default. This is to make it as simple as possible for new users to start using Grbl. When homing: V# ?' ^  h" o/ L* ]5 W
// is enabled and a user has installed limit switches, Grbl will boot up in an ALARM state to indicate 2 m- s: ]9 {! ^* j+ f6 a; J/ W
// Grbl doesn't know its position and to force the user to home before proceeding. This option forces9 k/ r) R0 L( l7 H/ e
// Grbl to always initialize into an ALARM state regardless of homing or not. This option is more for
( o8 b5 T, s3 B! a6 {) x// OEMs and LinuxCNC users that would like this power-cycle behavior.1 }7 d$ m, h* M0 e- E6 h
//当Grbl powers-cycles还是硬重置Arduino复位按钮,Grbl启动没有报警* |8 t. t" k3 w" b+ A
//默认情况下。这是为了让新用户尽可能简单使用Grbl开始。当归航
; ?% V% R, {8 C: d7 ~6 b//启用和用户安装限位开关,Grbl将启动报警状态指示4 y, M$ }; y/ n$ L+ z- v3 \- E) j
// Grbl不知道它的位置,迫使用户在继续之前回家。这个选项部队
' S4 s/ t2 ~9 k6 i( o- J// Grbl总是初始化进入警报状态不管归航。这个选项是更多, J: U8 s8 }+ `5 }$ j
//原始设备制造商和LinuxCNC用户这样的控制行为。
* ^- U7 p; F" H2 u9 L9 }" z2 U6 h8 }) m" B' A( v' |! @
// #define FORCE_INITIALIZATION_ALARM // Default disabled. Uncomment to enable.4 n5 t- ?, @- z- l% O  c( T. z
8 r. b0 k+ Z! A( }
// ---------------------------------------------------------------------------------------
# J+ A$ X0 i/ b6 P2 V( q1 M// ADVANCED CONFIGURATION OPTIONS://高级配置选项:2 Z# N% _* ]- E$ }% ]6 J) K" @

1 ^1 l8 ?% ^8 C. N" _4 I+ w, X9 y// Enables minimal reporting feedback mode for GUIs, where human-readable strings are not as important.( Q- A/ }9 B; G4 x3 b
// This saves nearly 2KB of flash space and may allow enough space to install other/future features.' y8 Y9 e" j8 n
// GUIs will need to install a look-up table for the error-codes that Grbl sends back in their place.
7 }) a# E) c7 T* d6 V% @4 s// NOTE: This feature is new and experimental. Make sure the GUI you are using supports this mode.
* ]3 A2 K4 F0 \! j5 d" T2 j6 L6 U: r$ X! {0 \' A
// gui允许最小的报告反馈模式,人类可读的字符串在哪里不重要。5 u9 u. U( T- c% O/ i0 t
//这个节省近2 kb的闪存空间,允许足够的空间来安装其他/未来的功能。
6 b4 z3 g3 X: d3 @6 n2 Q5 h. b* G// gui需要安装一个查找表的错误代码Grbl发回。  L! R$ e  `* d0 B: E6 Q
//注意:此功能是新的和实验。确保您使用的GUI支持这种模式。
4 t% y! _" ^* t# C9 Y* y) J
0 a0 ^# v5 o2 q// #define REPORT_GUI_MODE // Default disabled. Uncomment to enable.
( U1 H+ B, l& ?6 }# z( h: z! l$ t% A/ M# P5 K, Y/ ]) B8 e% p, v
// The temporal resolution of the acceleration management subsystem. A higher number gives smoother
8 K5 W/ P1 J7 D$ f% _// acceleration, particularly noticeable on machines that run at very high feedrates, but may negatively
- H4 q+ D4 e& o2 O// impact performance. The correct value for this parameter is machine dependent, so it's advised to
6 ~# {, e9 _3 f' d// set this only as high as needed. Approximate successful values can widely range from 50 to 200 or more.. c8 C( K- l; p; o0 Y8 @4 S
// NOTE: Changing this value also changes the execution time of a segment in the step segment buffer.
+ h6 M1 C$ d8 X3 C// When increasing this value, this stores less overall time in the segment buffer and vice versa. Make" v" N" k# M% R* {! Y& I& W1 n9 w
// certain the step segment buffer is increased/decreased to account for these changes.
: e( @  `% U$ e) S. J//加速度的时间分辨率管理子系统。更多更平稳
- W8 [& s. M# x$ }6 d2 [//加速度,特别明显的机器上,运行在非常高的进料速度,但可能负面3 d+ S6 Q+ v8 R& D3 g) ]. c, y
//影响性能。正确的值为这个参数是依赖于机器的,所以建议6 h* g. A6 I' V( b4 q  f) Z( R' ~# \+ M
//这只设置为高。近似成功的价值观可以广泛的范围从50到200或者更多。
7 w; _; u$ {' Q: K0 K//注意:改变这个值也变化的部分步骤的执行时间缓冲。. M2 j$ U) s/ ^2 e
//增加这个值时,这个商店部分缓冲区的总时间减少,反之亦然。使- C1 }# V' m' `3 C& k  I  l2 ^( r5 V# Z
//特定步骤段缓冲是考虑这些变化增加/减少。9 i# `0 l$ Q! O
! n* ^# S6 p9 |
#define ACCELERATION_TICKS_PER_SECOND 100  //加速度的时间分辨率管理子系统。更多更平稳; ^8 N1 R( K8 u4 j! T9 F

7 B7 Q0 T0 N( l// Adaptive Multi-Axis Step Smoothing (AMASS) is an advanced feature that does what its name implies,
% c  X1 a+ d3 o: N% H3 C3 n// smoothing the stepping of multi-axis motions. This feature smooths motion particularly at low step/ z% y/ N: ^0 g* o, c3 n+ G/ C
// frequencies below 10kHz, where the aliasing between axes of multi-axis motions can cause audible
, d9 n* [# l9 m5 H( w: n" `' R// noise and shake your machine. At even lower step frequencies, AMASS adapts and provides even better
/ ~  i, Z) j3 M, z# C  [$ h: s; q3 ?" \// step smoothing. See stepper.c for more details on the AMASS system works.
3 s4 N% z6 F6 ]5 Y, ?7 Y; a//自适应多轴步平滑(积累)是一种先进的功能,它的名字所暗示的那样,
+ e: m' X6 I+ _3 ?//平滑的多轴步进运动。这个特性平滑运动尤其是在低一步. q# c) J9 G: m/ V6 i0 X5 `
//频率低于10 khz,轴之间的混叠的多轴运动可能导致音响
! `* q4 n4 G/ a8 V( [2 K//噪音和震动你的机器。在更低的频率步,积累适应并提供更好4 w2 s! ~5 E+ M$ |' T" Q  }3 Y
//步骤平滑。看到步进。c更多细节的积累系统的工作原理。& W/ ?9 O# T8 a4 h# n

9 M( _1 ?- E* D% j( O! D& ^) V#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING  // Default enabled. Comment to disable.//自适应多轴步平滑; L3 x' _5 E$ g
, u, s1 N2 }/ A, m- I
// Sets the maximum step rate allowed to be written as a Grbl setting. This option enables an error $ S. ]6 o- \* `, }" A
// check in the settings module to prevent settings values that will exceed this limitation. The maximum) w& O1 x" E. R8 X3 v5 P9 F2 F' k# F
// step rate is strictly limited by the CPU speed and will change if something other than an AVR running
' {" w) f5 V5 p/ c& F+ d& d  l// at 16MHz is used.5 _  f3 C2 o9 ~6 c9 m5 ]
// NOTE: For now disabled, will enable if flash space permits.0 F3 |) |" n+ H# o0 a
//设置最大一步速率可以写成Grbl设置。这个选项可以使一个错误, g; l+ Z" M! Y* _! L8 h' r
//设置模块中检查,防止设置值将超过这个限制。的最大) S7 w8 e: U3 k+ T6 F
//步骤严格限制的CPU速度也会改变如果是其他AVR运行) W& ~0 p2 S" V. t
//使用16兆赫。
2 W# B& D7 u9 d1 K//注意:现在残疾,将使如果flash空间许可。
6 s$ X) [# g* G2 D
9 g! {% y7 Z8 q6 H% |9 z// #define MAX_STEP_RATE_HZ 30000 // Hz 设置最大一步速率
9 s) _( }; m% l0 ?3 @- T4 }. P# k
+ C2 G! a7 `7 ]. j" b// By default, Grbl sets all input pins to normal-high operation with their internal pull-up resistors" E! W! O. y+ }# v. q& D5 P
// enabled. This simplifies the wiring for users by requiring only a switch connected to ground,
7 h% P( Q8 p4 Y+ ^. B/ D- Q) z2 B// although its recommended that users take the extra step of wiring in low-pass filter to reduce* _6 F  H( E' ~3 e
// electrical noise detected by the pin. If the user inverts the pin in Grbl settings, this just flips) I' l% B3 Y1 g9 \+ t# S1 G
// which high or low reading indicates an active signal. In normal operation, this means the user 2 p2 x: @3 q4 c$ L
// needs to connect a normal-open switch, but if inverted, this means the user should connect a % `" H1 x; e& y+ p
// normal-closed switch.
+ \6 C7 H; J, E- z9 }3 X: }// The following options disable the internal pull-up resistors, sets the pins to a normal-low ( T' F: _% w( U2 v3 I/ r
// operation, and switches must be now connect to Vcc instead of ground. This also flips the meaning ) d! H" v- S7 w4 q) K- K
// of the invert pin Grbl setting, where an inverted setting now means the user should connect a
$ ]' y, h' f/ m* x' H/ T& M// normal-open switch and vice versa.: o  F5 C5 x! K' C+ V
// NOTE: All pins associated with the feature are disabled, i.e. XYZ limit pins, not individual axes.$ A1 O0 P4 }; o
// WARNING: When the pull-ups are disabled, this requires additional wiring with pull-down resistors!
: v1 i4 T, v+ t. G$ U) T1 l//默认情况下,Grbl所有输入引脚设置为正常高操作的内部上拉电阻/ y+ \4 Q  [. V# g! E" A4 u
//启用。这简化了布线为用户只需要一个开关连接到地面,
0 ^1 G6 x# H+ a; y4 r  e//虽然其建议用户采取额外的步骤,在低通滤波器来减少布线. U) A! ~7 |  v/ N: C
//电噪音检测销。如果用户反转的销Grbl设置,这只是翻转
8 _. n( x" X3 E& d//读高或低表明一个积极的信号。在正常操作中,这意味着用户. `3 o) f$ W$ I- Y4 ?
//需要连接一个常开开关,但如果倒,这意味着用户应该连接5 v$ l0 Q  s7 i- j! B
// normal-closed开关。5 c/ Q, n) N. c# l
//以下选项禁用内部上拉电阻,一般低设置别针
1 W% }, B2 g: o5 O//操作,现在开关必须连接到Vcc代替地面。这也掀的意思- j5 L0 e8 l. J6 v$ b8 A- |# \' q
//反销Grbl设置,一个倒置的设置现在意味着用户应该连接% c; x, J, Z8 L: t- j
//常开开关,反之亦然。4 a, Z6 K; [# K- T% z
//注意:所有针与功能被禁用,例如XYZ限制针,而不是单独的轴。
9 F- K0 h" C+ k# f( j, d: w% G. q//警告:引体向上被禁用时,这需要额外的布线与下拉电阻!, q' q+ }2 f. i- b% H( |3 u% |! q
2 S, Q! R; d2 z7 K* _
//#define DISABLE_LIMIT_PIN_PULL_UP //以下选项禁用内部上拉电阻
0 z+ p! i9 }& R. Y! u$ g//#define DISABLE_PROBE_PIN_PULL_UP% \3 F: Z5 E5 E7 d+ t
//#define DISABLE_CONTROL_PIN_PULL_UP+ ]. f) o" w4 W9 {
8 M4 S9 |* z3 {$ F3 T8 E. Y& u
// Sets which axis the tool length offset is applied. Assumes the spindle is always parallel with $ ^, r8 q. u7 S* x
// the selected axis with the tool oriented toward the negative direction. In other words, a positive3 b: [2 N4 I3 B( i+ t& x
// tool length offset value is subtracted from the current location.* o- i4 z! L" [0 k  ?- ?% O7 ~5 J3 Q
//设置哪个轴长度补偿应用的工具。假设轴总是与
6 n! u/ t$ l% x//选择轴工具面向负方向。换句话说,一个积极的  }- a3 c( H2 s% ?
//工具长度偏移值减去从当前位置。
" C" Y% Z# _6 N7 l# [* n- Z7 A' h/ P0 B  o: v0 z( m4 u, z2 B& `9 s% x
#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS // Default z-axis. Valid values are X_AXIS, Y_AXIS, or Z_AXIS.设置哪个轴长度补偿应用的工具
; p; `$ ~1 L+ U! b$ j/ a* z# y
( t8 |' t+ m7 t. i% T2 C// Enables variable spindle output voltage for different RPM values. On the Arduino Uno, the spindle5 o# e( c3 r1 e
// enable pin will output 5V for maximum RPM with 256 intermediate levels and 0V when disabled.( n; M# M0 \; I7 C! m& Q
// NOTE: IMPORTANT for Arduino Unos! When enabled, the Z-limit pin D11 and spindle enable pin D12 switch!1 X' H5 ~" a, n7 V  f, }
// The hardware PWM output on pin D11 is required for variable spindle output voltages.- |$ ?  _, Z, u8 i- D
//允许变量轴输出电压不同的转速值。Arduino Uno,主轴& v" ~& [2 n$ h$ L- X/ B
//启用销将输出5 v的最高转速256中级水平和0 v时禁用。* d; J8 Z/ l7 f: T1 u8 A  g
//注意:重要Arduino凯泽本人!当启用时,Z-limit销这里和轴销D12开关!0 s& F+ b6 V( q0 ?/ F& ]# B9 @
//硬件PWM输出销这里需要变量轴输出电压。
" |" S) O& V6 l% i! g% A
' T& J7 i  z$ Y* H& [: U$ F#define VARIABLE_SPINDLE // Default enabled. Comment to disable.//允许主轴输出电压不同的转速值4 X2 U2 U5 I! t1 X# `) q/ _
: b" S, l1 H7 _' ]. R7 {
// Used by the variable spindle output only. These parameters set the maximum and minimum spindle speed9 N2 I3 ]5 b9 _" n: z4 q: l
// "S" g-code values to correspond to the maximum and minimum pin voltages. There are 256 discrete and
! x4 {% \' w4 G: Z// equally divided voltage bins between the maximum and minimum spindle speeds. So for a 5V pin, 10006 @7 X0 g3 f! y4 H8 \4 O4 D
// max rpm, and 250 min rpm, the spindle output voltage would be set for the following "S" commands: % A& h0 K, U6 G& J6 M2 J; F, N1 f
// "S1000" @ 5V, "S250" @ 0.02V, and "S625" @ 2.5V (mid-range). The pin outputs 0V when disabled.# V) M& ^' |* Y
//使用的变量轴输出。这些参数设置最大和最小轴转速
+ I' l, D9 E- [! n  D  [9 C& h# G' w//“S”刀位点值对应于销电压的最大值和最小值。有256个离散和% Z0 [: F5 W1 k$ x
//电压平均分配箱主轴速度的最大值和最小值之间。所以对于一个5 v销,1000  p5 \7 e/ ^* v: V0 f) ~! v2 ^
// max rpm,250分钟rpm,主轴输出电压将为以下“S”命令:' I6 {7 e4 N" \" g  m0 Y: z+ M
// @“S1000 5 v,“S250”@ 0.02 v,“S625”@ 2.5 v(中档)。销输出0 v时禁用。
8 w: n2 p3 t- S4 y) _6 j  C2 J' Z# W; G1 \# h7 h$ w2 P# l: F
#define SPINDLE_MAX_RPM 1000.0 // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.5 B( p4 x+ E9 M4 }6 F# Z
#define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.
* Q. c2 w! f# U% c; i
6 |/ z. q3 N) t1 V/ z. R5 G// Used by variable spindle output only. This forces the PWM output to a minimum duty cycle when enabled.1 N- @: y- `& h
// When disabled, the PWM pin will still read 0V. Most users will not need this option, but it may be
( E! u/ j# g% ^* a. P  [+ f" n' L// useful in certain scenarios. This setting does not update the minimum spindle RPM calculations. Any# T/ w9 g# y1 I- j$ {* X
// spindle RPM output lower than this value will be set to this value.
) v/ n' {( }# I+ m& {8 F& R) g//使用的变量轴输出。这迫使PWM输出最小占空比时启用。
" f, l) e. W$ u//当禁用,PWM销仍读0 v。大多数用户不需要这个选项,但是它可能是
) u1 _$ K# S* C" v( n& n5 P//在某些情况下很有用。这个设置不会更新最小主轴转速计算。任何& g, F. \& `% G6 p( y! @2 H
//输出轴转速低于这个值将被设置为这个值。
  B2 e5 h$ f% N1 c3 t" @) a3 X0 v2 C' q* l0 y" @4 v8 S  z
// #define MINIMUM_SPINDLE_PWM 5 // Default disabled. Uncomment to enable. Integer (0-255)
; P1 D4 b: j8 ^2 E0 x
+ B6 b9 a+ i$ g" o6 N// By default on a 328p(Uno), Grbl combines the variable spindle PWM and the enable into one pin to help , k1 c( Q) g3 W5 W: v* m5 T& T* q
// preserve I/O pins. For certain setups, these may need to be separate pins. This configure option uses
) ]$ i& b; Y$ I+ G4 ?, i/ v% F// the spindle direction pin(D13) as a separate spindle enable pin along with spindle speed PWM on pin D11.
  H/ S, [' U6 m  ?1 Q// NOTE: This configure option only works with VARIABLE_SPINDLE enabled and a 328p processor (Uno).
( ^) h6 t+ g) ]( f4 U$ a// NOTE: With no direction pin, the spindle clockwise M4 g-code command will be removed. M3 and M5 still work.. Z" X' n6 U9 g8 r
// NOTE: BEWARE! The Arduino bootloader toggles the D13 pin when it powers up. If you flash Grbl with1 x9 ?3 A% d1 W
// a programmer (you can use a spare Arduino as "Arduino as ISP". Search the web on how to wire this.),
. I; w; o. w) K& i/ _. h: I2 X// this D13 LED toggling should go away. We haven't tested this though. Please report how it goes!% f& k8 m) S, _3 S* T& H; N
//默认ATmega328 p(Uno),Grbl结合变量轴PWM和使到一个销的帮助1 F# P7 A# i, ?7 V* G7 X
//保存I / O管脚。对于某些设置,这些可能需要单独的别针。这个配置选项使用, b7 C& ^5 R3 m3 S* ]
//方向轴销(D13)作为一个单独的轴销上启用销以及主轴转速PWM这里。
* p6 n  D% ^' J0 U: g. {$ J//注意:该配置选项仅适用于VARIABLE_SPINDLE启用和328 p处理器(Uno)。
( V) t7 D" g2 n% U' ]" C- `//注意:没有方向销,主轴顺时针M4刀位点命令将被删除。M3和M5仍然工作。" G( T" a$ |# |4 m' i2 ^
//注意:小心!Arduino引导装载程序切换D13销的权力。如果flash Grbl6 [0 T% \3 L7 n
//程序员(您可以使用一个备用Arduino“Arduino ISP”。搜索网络如何线),
1 `4 g- o' j5 U//这D13导致切换应该消失。我们还没有测试这个。请报告将会怎样!
% y  }' K/ K6 T' @( T
7 [$ z: U& y3 Y! `) a3 F& A1 n, |// #define USE_SPINDLE_DIR_AS_ENABLE_PIN // Default disabled. Uncomment to enable.
4 f  \/ M1 o) d: X* f1 f7 g, c3 E: D8 q! A; ?+ ~7 S4 D
// With this enabled, Grbl sends back an echo of the line it has received, which has been pre-parsed (spaces3 Q- P6 g# H4 T$ n" F4 X( V
// removed, capitalized letters, no comments) and is to be immediately executed by Grbl. Echoes will not be
; K7 Q! x2 q) M! P$ m- P  a/ u6 z// sent upon a line buffer overflow, but should for all normal lines sent to Grbl. For example, if a user - Y- u3 Y0 {3 X0 V! I! q7 T5 t! d
// sendss the line 'g1 x1.032 y2.45 (test comment)', Grbl will echo back in the form '[echo: G1X1.032Y2.45]'.
0 A# k9 e! O. E0 i6 s// NOTE: Only use this for debugging purposes!! When echoing, this takes up valuable resources and can effect4 q: \! a* o4 H( u. u' ]! b
// performance. If absolutely needed for normal operation, the serial write buffer should be greatly increased+ Q$ `7 n. Q- L) u! X! m: W
// to help minimize transmission waiting within the serial write protocol.
9 R' e. O7 F% A! B) a7 L9 A2 S1 Z, D+ k
//启用,Grbl发回的回声线已收到,已预编译(空间
1 \4 b. g# m* @//移除,大写字母,没有评论),由Grbl立即执行。回声将不会
% d8 A6 A* B1 X" L& ]8 n//发送一个线缓冲区溢位,但应该对所有正常线路送到Grbl。例如,如果一个用户0 o" x9 {; A) I
//发送线的g1 x1.032 y2.45(测试评论)形式”,Grbl将回声”(回声:G1X1.032Y2.45]”。+ p4 A( |# q& L) r) D' D
//注意:只使用这个调试! !当呼应,这占用了宝贵的资源,可以影响1 _. y& c+ G- h5 `
//性能。如果正常运行所需的绝对,串行写入缓冲器应该大大增加
2 {* t! e7 E4 \2 R0 {/ p//帮助最小化传输等系列内写协议。$ t8 l7 {% u5 b- B/ b; W
& t  f) J+ e0 r
// #define REPORT_ECHO_LINE_RECEIVED // Default disabled. Uncomment to enable.
! B' i' e% z" |5 R& Y3 W$ ^& s& E8 u* S9 D4 M
// Minimum planner junction speed. Sets the default minimum junction speed the planner plans to at8 h1 O; T, X4 o1 `
// every buffer block junction, except for starting from rest and end of the buffer, which are always
* i* T$ f  I) _7 c// zero. This value controls how fast the machine moves through junctions with no regard for acceleration
% q5 B" w  d# L& E* P. W- _& Q, z// limits or angle between neighboring block line move directions. This is useful for machines that can't8 _4 b+ g4 I) c3 T8 r# T
// tolerate the tool dwelling for a split second, i.e. 3d printers or laser cutters. If used, this value5 k# S6 K# y" x5 `- z6 E
// should not be much greater than zero or to the minimum value necessary for the machine to work.1 i+ c% v/ J* F$ I- B. s2 k" ]

, q2 K) T5 w  [  ~* G//最小规划师结速度。设置默认最小连接速度规划计划4 z5 Q, j) n. v) Y# W) r: s
//每一个缓冲块接头,除了从结束休息和缓冲区,它总是
2 t/ i  j4 K" r% F// 0。这个值控制机器的速度穿过路口,没有考虑加速度$ j( {  z' K7 }- g& V9 j1 U
//限制或相邻块之间的角线方向移动。这是有用的机器,不能
8 F6 \8 V. Z. b, w1 W% ^" l# R1 S- w- e//容忍工具居住某一刹那,即3 d打印机或激光切割机。如果使用这个值
& V3 W/ B7 X/ M+ O! i//不应大于零或机器工作所需的最小值。
9 X" G5 R  w0 o+ M; o* k/ f' t% e- E
#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min)0 S- l: X6 _  X" a4 \
* R; }& {! Z, [. y. _
// Sets the minimum feed rate the planner will allow. Any value below it will be set to this minimum
+ t  S! R& ]' p  i5 h  o! N// value. This also ensures that a planned motion always completes and accounts for any floating-point) b4 P: E* f( h! N' W
// round-off errors. Although not recommended, a lower value than 1.0 mm/min will likely work in smaller
, B# x4 E$ z+ M8 E, b; b// machines, perhaps to 0.1mm/min, but your success may vary based on multiple factors., s9 b# W' k0 f& M
//设置计划将允许的最小进给速率。任何价值低于它将被设置为最低值。这也保证了运动计划总是完成,占任何浮点* C0 Q* W2 Y0 |* w, Q- _
//舍入错误。虽然不推荐,价值低于1.0毫米/分钟可能会在较小的工作) z) a! k8 W  x- |( E0 ^7 H' [
//机器,也许到0.1毫米/分钟,但你的成功基于多种因素可能会有所不同。
, J' Z: [, @) V+ o1 V6 l/ b) p6 P' J  y8 ~) l
#define MINIMUM_FEED_RATE 1.0 // (mm/min)//设置计划将允许的最小进给速率
9 g6 ]" R! V. a9 J, `" j% R, G
! i! l( n5 t6 k// Number of arc generation iterations by small angle approximation before exact arc trajectory
2 C, w- v, Y5 C  `1 [// correction with expensive sin() and cos() calcualtions. This parameter maybe decreased if there ) W" t! |+ ~( a+ \6 @' b% s1 @# I5 U
// are issues with the accuracy of the arc generations, or increased if arc execution is getting1 Y( S& I# r, t
// bogged down by too many trig calculations.
  Q1 D  |5 f: J8 n' @; d0 ^( R' T//弧生成迭代次数之前小角度近似精确的弧线轨迹& @/ |/ k7 n& g
//修正与昂贵的sin()和cos()calcualtions。如果有这个参数可能减少, g3 }& a8 T& u$ }* Q. d' l0 Y
//与弧一代又一代的准确性问题,或如果电弧执行得到增加
4 k. G* K3 Z- R//太多的三角计算的泥潭。
9 w" \: ]7 a5 R% c; A3 w
0 T& B1 r0 S3 t! t8 q) l#define N_ARC_CORRECTION 12 // Integer (1-255)
( P+ M  m" A! N/ n7 n1 U3 w- S5 ]! |, L, E. G3 g0 l
// The arc G2/3 g-code standard is problematic by definition. Radius-based arcs have horrible numerical
0 T" Y6 ?2 t# G6 B" C) E* T// errors when arc at semi-circles(pi) or full-circles(2*pi). Offset-based arcs are much more accurate % l3 a+ t9 t1 h9 f# e: {1 p) B
// but still have a problem when arcs are full-circles (2*pi). This define accounts for the floating 7 U, b1 r9 W1 G/ a! ~# F6 E
// point issues when offset-based arcs are commanded as full circles, but get interpreted as extremely& t7 K4 O! z5 G" g
// small arcs with around machine epsilon (1.2e-7rad) due to numerical round-off and precision issues.
& a" j+ G" ^6 M( l" {1 D// This define value sets the machine epsilon cutoff to determine if the arc is a full-circle or not.# d4 G: Y% g+ @3 h4 k" r* ]/ ~% D
// NOTE: Be very careful when adjusting this value. It should always be greater than 1.2e-7 but not too2 _, C& S  R+ s( C% A
// much greater than this. The default setting should capture most, if not all, full arc error situations.
5 ^2 e7 n, C6 C+ u2 C+ ^* R//弧G2/3刀位点的标准定义是有问题的。Radius-based弧有可怕的数值; @# t: N8 n; M+ r
//错误当电弧在半圆(π)或原点(2 *π)。Offset-based弧更准确/ q5 l) \( }6 Q' a+ \4 \: q7 m
//但仍有一个问题当弧原点(2 *π)。这个定义占浮动% M( L& L9 a8 Z" m) f
//当offset-based弧吩咐点问题完整的圆,但解释为极
, L6 r7 E9 p+ f//小弧机周围ε(1.2 e-7rad)由于数字舍入和精度问题。
' O) x. S) r( b1 w! ]//定义值设置机器ε截止来确定电弧是一个原点了。
! S% b" ?! }- V//注意:调整这个值时非常小心。它应该总是大于1.2 e -但不要太* y3 e( V9 {" Q; a  ?* w) i
//比这大得多。默认设置应该捕获大部分,如果不是全部,全部错误的情况。% U1 U9 q$ ^) u2 c0 o

  {, X' C2 F  O  ], c9 Z$ v9 `, |#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)
& H  g) |, r% H) _7 j, |' U0 s3 ^9 G$ _# l) m
// Time delay increments performed during a dwell. The default value is set at 50ms, which provides
0 w; [+ T- F- ?2 t4 j// a maximum time delay of roughly 55 minutes, more than enough for most any application. Increasing7 x- }' w, K2 n
// this delay will increase the maximum dwell time linearly, but also reduces the responsiveness of # {, U  v+ b7 w6 K7 |
// run-time command executions, like status reports, since these are performed between each dwell / q+ n# P! X+ V, ]( R7 f$ d
// time step. Also, keep in mind that the Arduino delay timer is not very accurate for long delays.: ~; ~) }4 z) f0 F5 ?5 B3 P' s
//延时增加表现在住。默认值设置为50毫秒,它提供了6 n7 Q* T3 U+ H  B
//最大延时约55分钟,足够对大多数任何应用程序。增加0 T% H2 s, ]# G3 G
//这种延迟将增加线性最大停留时间,也减少了响应能力
6 q8 {; j" E+ q+ \# B, Z% y//运行命令执行状态报告一样,因为这些每个住之间执行
$ g' I$ g" X  d7 y" G& {//时间步。还有,记住,Arduino延迟计时器不是很准确的长时间延误。
* b0 s7 g' i" ^9 N
) I3 r3 I6 l/ T& p$ m# n9 C#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds)
' a1 M/ \8 {, R* _
- C/ ?% O5 f# G5 V4 r0 b9 z/ ]// Creates a delay between the direction pin setting and corresponding step pulse by creating$ F4 e, e0 N# j
// another interrupt (Timer2 compare) to manage it. The main Grbl interrupt (Timer1 compare) % A8 v1 }5 ?/ w6 ?3 x( v
// sets the direction pins, and does not immediately set the stepper pins, as it would in
+ H# n" T3 g5 R5 I' y6 u9 u' U// normal operation. The Timer2 compare fires next to set the stepper pins after the step
) A  R, c- ^, o// pulse delay time, and Timer2 overflow will complete the step pulse, except now delayed / `8 {- k& `$ E# ?% y0 s
// by the step pulse time plus the step pulse delay. (Thanks langwadt for the idea!)
* z1 J1 Y/ X/ G. w2 y$ q// NOTE: Uncomment to enable. The recommended delay must be > 3us, and, when added with the
. r: \6 k2 C7 l* T% m6 m// user-supplied step pulse time, the total time must not exceed 127us. Reported successful
5 B2 n1 e- M2 A+ k0 K// values for certain setups have ranged from 5 to 20us.) c: o0 f8 o$ q8 Y2 q) V; m
//创建一个方向销之间的延迟脉冲通过创建设置和相应的步骤
3 b( [, ~) J9 |* P: c# I//另一个中断(Timer2比较)来管理它。主要Grbl中断(Timer1比较)
9 _8 g3 Z$ w6 @/ n//设置方向针,不立即设置步进针,因为它会在
; A+ F2 L% q: O  B) l//正常操作。Timer2比较火旁边设置步进针后一步2 u7 Z9 m  ]: w$ D4 i
//脉冲延迟时间,Timer2溢出脉冲将完成的步骤,现在延迟除外. c. L& `! W) m0 p% j
//脉冲时间加上的一步一步脉冲延迟。(感谢langwadt主意!)' X, \2 T% l9 M
//注意:取消启用。必须> 3,建议延迟,当添加的
; B. ~1 d- y8 P3 V/ @8 a4 T//用户提供的步骤脉冲时间,总时间不得超过127美元。成功的报道
" e+ \+ l; I+ {2 h- d' ?//值对某些设置范围从5到20。. y+ g: \. W# u* A0 ~

: q# x# C  A6 ^8 y0 Z// #define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.
2 u/ o1 t. G; v! Z; ]: |" X
0 g& r8 e9 c+ S/ t9 j// The number of linear motions in the planner buffer to be planned at any give time. The vast$ Q) N$ M% K0 }* R0 G  |
// majority of RAM that Grbl uses is based on this buffer size. Only increase if there is extra ! Q8 G( ?, z1 o5 l, v$ ~
// available RAM, like when re-compiling for a Mega or Sanguino. Or decrease if the Arduino
# e7 s1 M6 p* ]0 i5 v9 `8 a( G5 j// begins to crash due to the lack of available RAM or if the CPU is having trouble keeping0 y  {; o$ c) u, _
// up with planning new incoming motions as they are executed.
0 C7 i9 k/ o5 }; K//线性运动规划师缓冲区的数量在任何给出时间计划。绝大
3 `) I6 t3 C4 [$ D//多数RAM Grbl使用基于这个缓冲区的大小。如果有额外的只会增加9 B3 u" ~( Z! l5 m- R+ n% L
//可用内存,比如当基于大型或Sanguino。如果Arduino或减少
: i. N2 y  j# Z//开始崩溃由于缺乏可用的RAM或者CPU是难以保持! c2 R7 u$ `+ k
//与规划新传入的动作执行。; K- W: k  Y$ x# ]
6 `& o' f. j9 K  d9 X
// #define BLOCK_BUFFER_SIZE 18  // Uncomment to override default in planner.h.
! h, c; C; }' w" Q) j7 f
/ [) N1 ?9 [5 k, z2 H/ U( g' w// Governs the size of the intermediary step segment buffer between the step execution algorithm
: d; m, ]2 \7 Y. H3 C// and the planner blocks. Each segment is set of steps executed at a constant velocity over a
8 t5 q; a4 t0 F7 g& u2 a4 W; o// fixed time defined by ACCELERATION_TICKS_PER_SECOND. They are computed such that the planner/ p$ ^8 W3 {2 T1 N3 Y
// block velocity profile is traced exactly. The size of this buffer governs how much step ! j9 y$ [2 \; e5 S
// execution lead time there is for other Grbl processes have to compute and do their thing
1 a& t$ S( h/ x0 t: K  c: l6 v3 _// before having to come back and refill this buffer, currently at ~50msec of step moves.
! _# `& x( _( O# I+ T& ]//控制之间的中间段缓冲大小的步骤执行算法
+ D3 j- ]  [9 K7 K! G# F$ K1 f0 S" {//和规划师块。每一部分的步骤执行在一个恒定的速度. M2 i' G2 [* q- x; D6 H; b+ y
//固定的时间由ACCELERATION_TICKS_PER_SECOND定义的。他们计算的计划
7 U* j; {$ U/ B//块速度剖面追踪到底。这个缓冲区的大小控制多少步骤
' ~7 Y" [; w) ]- v//执行时间有其他Grbl过程需要计算和做他们的事情
0 A+ @* q* e+ ?) e2 r7 L//之前必须回来重新填充这个缓冲区,目前移动~ 50毫秒的一步。
0 G* |6 h2 N% x: _" E; {
& {! O1 m$ a/ A9 x// #define SEGMENT_BUFFER_SIZE 6 // Uncomment to override default in stepper.h.9 h$ x$ K8 f% g8 J1 s  {' Q

! e+ h( K0 `/ `. W$ ^# k// Line buffer size from the serial input stream to be executed. Also, governs the size of ( [. [2 K5 v! S5 t! Y7 R
// each of the startup blocks, as they are each stored as a string of this size. Make sure' h, p7 @/ b, p& Z+ Y' e# f
// to account for the available EEPROM at the defined memory address in settings.h and for
; W7 ~1 e. b. T( d& w" a* ?4 R( p// the number of desired startup blocks.' f0 d( ?# {7 g9 {- {/ m
// NOTE: 80 characters is not a problem except for extreme cases, but the line buffer size
) j/ H: p/ l5 T' @// can be too small and g-code blocks can get truncated. Officially, the g-code standards
4 K+ }5 y- s% c/ R3 R% ]2 R$ c// support up to 256 characters. In future versions, this default will be increased, when 5 w& L# t0 Q3 n4 }+ {
// we know how much extra memory space we can re-invest into this.
, q9 J3 ^2 h9 B9 c' E6 S//行执行串行输入流的缓冲区大小。同时,大小的控制! S9 W- O  y4 Z; H. z4 ~' |. O
//每个启动模块,它们分别存储为字符串的大小。确保
; p; F% I2 j  S- J. |//占可用eepm定义内存地址的设置。h和  ?; V. N7 l* T% u! K, Y6 H
//需要启动块的数量。! T# i0 D" F6 X$ V1 D( Z
//注意:80个字符不是一个问题,除了极端的情况下,但线缓冲区大小4 g$ a% y$ ~  J! J1 h! y
//可以太小和刀位点块可以截断。正式,刀位点标准
2 d' J3 y$ r8 W  c//支持多达256个字符。在未来的版本中,这个违约将会增加,当) y2 d* E9 P3 ]; K
//我们知道多少额外内存空间的时候我们可以再投资。
- l* W# X, U- g4 D  [- O9 u, V& h! [5 v9 f/ n3 g0 N
// #define LINE_BUFFER_SIZE 80  // Uncomment to override default in protocol.h
/ [: t) R3 P; [' \1 [4 {3 I' P  - V  _5 q+ ]- ?
// Serial send and receive buffer size. The receive buffer is often used as another streaming
& j! N, I% `1 ^- y// buffer to store incoming blocks to be processed by Grbl when its ready. Most streaming
+ q/ {# H' t4 b8 X# B' I4 [0 n& `// interfaces will character count and track each block send to each block response. So, % |: O: E- b$ U4 y; y
// increase the receive buffer if a deeper receive buffer is needed for streaming and avaiable( t' E2 I* X: |! T) ~
// memory allows. The send buffer primarily handles messages in Grbl. Only increase if large
0 K7 h5 t9 y0 @' m& t// messages are sent and Grbl begins to stall, waiting to send the rest of the message.
8 x  c1 [  r6 @: p7 K// NOTE: Buffer size values must be greater than zero and less than 256.$ s4 L1 F- H! \! H0 I! q4 e
// #define RX_BUFFER_SIZE 128 // Uncomment to override defaults in serial.h
$ h! \9 W7 L6 t3 j//串行发送和接收缓冲区大小。接收缓冲区通常用作另一个流  ~& T7 x2 [( q; u' _4 m
//缓冲存储传入的块来处理Grbl当它准备好了。最流
  q( x) P: S, v9 g- I0 P  w) y( N. G4 a//接口将字符计数和跟踪每一块发送给每个块的回应。所以,
  R9 w( L' {" K. L2 L& ~/ ]! x" ^//增加接收缓冲区如果需要更深层次的接收缓冲区为流,、2 z; y# E  g$ S5 o2 ~- O
//内存允许。Grbl发送缓冲主要处理消息。只会增加如果大, E; L2 {, m+ K+ I0 Z+ w5 a) t
//消息发送和Grbl开始停滞,等待发送其余的消息。9 h7 X% `- H6 L" R4 K
//注意:缓冲区大小值必须大于零,小于256。2 x% S' r: ?6 N2 H! w$ ]; h
// # define RX_BUFFER_SIZE 128 / /取消serial.h覆盖默认值
6 j% B6 A7 v3 L, v' `" \- S  g( L: @* q" y
2 K+ y5 T6 m6 X  b2 U5 g3 E
// #define TX_BUFFER_SIZE 64( b2 U  e' Z/ M1 J$ ]2 G
  6 i" K3 G+ d* ^% A
// Toggles XON/XOFF software flow control for serial communications. Not officially supported! n' \/ r" B, ~- \6 a3 t/ F
// due to problems involving the Atmega8U2 USB-to-serial chips on current Arduinos. The firmware
  z5 P8 K) i; f' I. A; G; K// on these chips do not support XON/XOFF flow control characters and the intermediate buffer
+ d: @* `8 p- _7 ]7 g* M9 Y  Z: ?& `// in the chips cause latency and overflow problems with standard terminal programs. However, * O% m8 Q0 L5 D8 [7 j1 g
// using specifically-programmed UI's to manage this latency problem has been confirmed to work.1 x6 g3 t4 \/ ~' P
// As well as, older FTDI FT232RL-based Arduinos(Duemilanove) are known to work with standard
. E$ t. P0 N- |6 C9 T; ^5 i$ x// terminal programs since their firmware correctly manage these XON/XOFF characters. In any
* |0 q) F  n/ A// case, please report any successes to grbl administrators!
) M2 V  }- l+ ^" ~* O* x//切换为串行通信发送朴通/发送葡开软件流控制。不是官方支持
/ e8 U/ w9 F' ~" F$ r* n! s" d//由于问题涉及Atmega8U2 USB-to-serial当前arduino芯片。固件
0 B' v% z1 {3 r9 ]//在这些芯片不支持发送朴通/发送葡开流控制字符和中间缓冲区
# t, T+ Z3 @# Q, Q! Z% U//芯片导致延迟和溢出问题的标准终端程序。然而,
( F+ |" G1 w0 p, @+ H//使用specifically-programmed UI的管理这个延迟问题已经确认工作。: I& B# I: ^; X; \0 m" N! x9 w
//以及老FTDI FT232RL-based arduino(Duemilanove)是已知的标准
0 l) `" o( \$ F//终端程序因为他们正确的固件管理这些发送朴通/发送葡开的角色。在任何6 T$ E8 N* a& d+ f% ]; d1 j, B4 n
//情况,请报告任何成功grbl管理员!% \. W  {  m5 D* T; D& a/ ~' G
& M, W! K& S& ~9 j' l- G
// #define ENABLE_XONXOFF // Default disabled. Uncomment to enable.$ Z+ w! v. v3 x" o) u6 W$ {. H2 G2 t

/ C1 z9 `) u9 s7 g// A simple software debouncing feature for hard limit switches. When enabled, the interrupt
: l. D$ ~7 L& J  C+ k3 Z// monitoring the hard limit switch pins will enable the Arduino's watchdog timer to re-check
3 C3 }# H& P% g$ Z1 E+ c// the limit pin state after a delay of about 32msec. This can help with CNC machines with
" ?# i1 o* X% u( l  Z% V// problematic false triggering of their hard limit switches, but it WILL NOT fix issues with 2 c+ t( O/ W7 Z. U, w
// electrical interference on the signal cables from external sources. It's recommended to first+ y- k4 q2 m: i9 P
// use shielded signal cables with their shielding connected to ground (old USB/computer cables
' A. d7 t2 b4 B$ D/ l* S& J// work well and are cheap to find) and wire in a low-pass circuit into each limit pin.5 v' ~3 c! Q. j; z3 s
//一个简单的软件消除抖动特性硬限位开关。当启用时,中断; m0 W) t7 C' H. \# ]- k. ~
//监控硬限位开关针将使Arduino的看门狗定时器重新审视/ e$ r" A& p3 q  S; e" `
//销的极限状态后约32毫秒的延迟。这可以帮助与数控机器
2 e" |) a) n" E  R3 @//问题错误引发的硬限位开关,但是它不会解决问题+ ]: }3 U- E* d  A5 E6 ~
//电干扰信号电缆从外部来源。首先它的建议
- t% O) A1 d9 T8 L//使用屏蔽信号电缆的屏蔽连接到地面(老USB /计算机电缆5 k. \& F- g: ?! r7 P3 R- {2 {
//工作得很好,很便宜)和线低通电路到每个限位销。+ r, q! `- R) i5 g" w3 k) y
! v9 l$ S) m1 B" L
// #define ENABLE_SOFTWARE_DEBOUNCE // Default disabled. Uncomment to enable.
- d/ K1 r: A3 k: I6 H2 d
0 V+ Q) ~5 h  j! \2 w! q! Q// Force Grbl to check the state of the hard limit switches when the processor detects a pin
; ]9 M# S; a4 K4 Y2 d// change inside the hard limit ISR routine. By default, Grbl will trigger the hard limits
5 g* D) Y$ x  U// alarm upon any pin change, since bouncing switches can cause a state check like this to : }7 B1 V0 u1 ]1 H" ~0 y
// misread the pin. When hard limits are triggered, they should be 100% reliable, which is the% U& L2 ^% y1 B* }5 P( k8 X
// reason that this option is disabled by default. Only if your system/electronics can guarantee% [7 @! k. R8 J% L4 ]  Y/ e0 t
// that the switches don't bounce, we recommend enabling this option. This will help prevent
: Q4 [9 L! D7 |# f) q7 w5 s( g// triggering a hard limit when the machine disengages from the switch.
# ]$ {% V! V: m// NOTE: This option has no effect if SOFTWARE_DEBOUNCE is enabled.3 E5 S1 J0 z+ f
//力Grbl检查硬限位开关的状态,当处理器检测到一个销
0 v; T5 E0 d/ C) z8 C6 n( }3 M/ m//改变内部硬限制ISR例行公事。默认情况下,Grbl将触发硬限制
7 C( x  r6 m- A. _//报警在任何销更改,因为跳开关可以导致这样的状态检查: k# s" I$ m' r2 Q. s
//误读了销。硬限制触发时,他们应该100%可靠,这是$ ~2 L5 i2 p9 c2 e/ R4 B# K
//原因,这个选项默认是禁用的。只有在你的系统/电子产品可以保证1 v6 M% X/ ]/ h7 h9 V% z- r1 U# y" T
//开关不反弹,我们建议启用这个选项。这将有助于防止, V. E% b" W$ d4 k7 f
//触发机退出时硬限制开关。5 o/ M' L; g0 }' i
//注意:这个选项如果启用了SOFTWARE_DEBOUNCE没有影响。
) U2 x& R6 {- L# N# T* Q4 H' u) o) Z- H" j4 S3 {/ N
// #define HARD_LIMIT_FORCE_STATE_CHECK // Default disabled. Uncomment to enable.7 ~! u# H/ }! L: u* b7 k* i
7 w% s) u2 V. t$ F
8 o- K1 ?+ ]! }: R+ K* _
// ---------------------------------------------------------------------------------------. J  a7 E! G5 D& b
// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:编译时错误检查的定义值:2 ?, d/ m5 c. G9 q) [! T

' s5 m) a+ \' D8 H#ifndef HOMING_CYCLE_0
+ r, H- e; O0 s+ f2 Z  #error "Required HOMING_CYCLE_0 not defined."$ h( G- T% `+ Z5 x( a
#endif
% R  i% F: W3 n2 N% \, H& G) f0 P; o$ C/ c  ?0 g5 {
#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(VARIABLE_SPINDLE)
! _- ?) V+ F4 i) d/ ^0 P/ c5 z/ r# u  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with VARIABLE_SPINDLE enabled"' W! u* W! q6 B0 Z  n% \/ F3 F* \
#endif
1 q0 W  L% O. f+ T
) Q0 e2 V! Z2 h#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(CPU_MAP_ATMEGA328P)' Z% D4 y$ \( P7 u+ S4 C, ^
  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with a 328p processor"
! s$ J+ H% X) r1 O, A# s; r#endif
% M8 k( h# t$ T9 T& A9 E5 U3 g' r
- U- c! P8 b4 ?. B: }+ g$ S// ---------------------------------------------------------------------------------------2 q( X* W0 l, \# _' U; i7 m

* d# d7 b& y8 y3 z+ g. [( R& l) U  ?/ J2 A( E
#endif
: f/ Y* J5 Z& ]
& |" _, O! y. Q, h3 T; a9 p& l8 i: v. M2 l& r

. j" \& ~5 w, ~1 ?
5 u8 U4 a7 J" U
( r. h3 L: \. m  p. `. Q! V) }+ F6 g3 G( ~$ n

% I7 \6 ?6 `. h9 b% n9 r& Z* c2 b) s* f0 P$ U, G3 b9 W1 l8 U8 @
4 E! \0 _' U' z# }( N" A

. A  V" d9 ~, L' A% d: D6 x4 |$ d, \- h5 q$ V4 x
' `- ?% `  x4 W* ~- Q
0 b9 |% Q6 z9 S. k. {2 J" W

: P% J% {# L! L; e* `
, K+ s  Y* n) c) A& L5 Q$ a; L( d& d
/ J4 j$ h& x: c5 R& ?/ n' w' I

本帖子中包含更多资源

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

x

评分

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

查看全部评分

回复

使用道具 举报

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

使用道具 举报

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

6 c* E* R! s. v+ o1 B: h" m
回复 支持 反对

使用道具 举报

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 | 只看该作者
补充  b8 s6 L& ^' r
程序运行protocol_execute_realtime(); /运行实时命令。
( i. F  T0 r, K# \, u// Executes run-time commands, when required. This is called from various check points in the main
' ?7 K# ]$ e3 {) G// program, primarily where there may be a while loop waiting for a buffer to clear space or any0 i% G& h6 T0 l- X; ?
// point where the execution time from the last check point may be more than a fraction of a second.) B6 z7 }: R$ R/ h% v
// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code- H8 q7 U6 O, I1 m8 j
// parsing and planning functions. This function also serves as an interface for the interrupts to
1 E$ k  l3 w* s& v" p* \// set the system realtime flags, where only the main program handles them, removing the need to
& C+ D8 F4 G; |$ W! F4 f// define more computationally-expensive volatile variables. This also provides a controlled way to
" D+ v1 M3 T6 z( b7 A7 n// execute certain tasks without having two or more instances of the same task, such as the planner" Y/ U4 y& x1 x$ F: s
// recalculating the buffer upon a feedhold or override.' f$ z, c6 r% ^. M; ]$ E0 X8 \! Y
// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,
0 ~& z1 _1 K+ n7 }& D) ^& }// limit switches, or the main program.
) N% b; W1 W& Z4 e. I: g& `0 e" u. u" ^' O7 p
//执行运行时间命令,在需要时。这就是所谓的从各种主程序要检查站
$ X: j( |% d/ Y6 a8 ?5 G* Y//,主要是那里可能是一个while循环等待缓冲区空间或任何
3 \( L4 g; }$ l9 ^//执行时间从过去的止点可以超过几分之一秒。, ]" z$ P! E9 k7 A
//这是一种异步执行实时命令(又名多任务)grbl的刀位点
' G, F2 x: [: L  z5 x//解析和规划功能。这个函数也可以作为一个接口,用于中断
4 T. ^% C3 K$ b# N' l4 J- `8 F//设置系统实时的旗帜,只有主程序处理,消除的需要
5 V1 Z3 T- i' Z- ^; ^//定义更多的计算昂贵volatile变量。这也提供了一种控制方法
- h# @, D: G- D% P/ T" d//执行某些任务不相同的两个或多个实例的任务,比如计划
! Y2 M/ K# a. U) N//重新计算缓冲feedhold或覆盖。
6 A& B  c3 G! [//注意:sys_rt_exec_state变量标志设置任何过程,步骤或串行中断,插脚引线,
: o& i, u' @" S9 N- D//限位开关或主程序。
3 r& v6 s8 L, V( V5 ?! k, G, Fvoid protocol_execute_realtime()
, x/ w7 V( K& k5 R6 W, w{
1 R" O! V& C2 }: A; L3 ~6 g2 u        // Temp variable to avoid calling volatile multiple times.
2 k8 z1 \* d2 a1 Q        // 临时变量来避免多次调用不稳定。  m- q: m  s% _. \
        uint8_t rt_exec;
4 R7 q7 C5 c" x! a8 e7 ~        do{
5 {7 j0 b1 f! C) i% t9 M          if (rt_exec) {                 // 有标志位置位进入# @0 \  f: g, }* ~, \; L: `' B; X
       
) Y% x4 l5 C7 L            sys.state = STATE_ALARM; // 设置系统为报警状态3 }7 ?  r- z& O4 u% E
      report_alarm_message(ALARM_HARD_LIMIT_ERROR);        //报告报警信息为接近极限值
2 I/ T1 L+ W+ D5 C3 b1 ~0 F( m  `* l    } else if (rt_exec & EXEC_ALARM_SOFT_LIMIT) {                        //报告执行软件限位报警
4 F' B. A; l3 s9 S7 f$ f# ^      report_alarm_message(ALARM_SOFT_LIMIT_ERROR);        //报告出现软件限位报警7 }; t4 b; W; y$ \+ q* E2 T- w7 {0 k
    } else if (rt_exec & EXEC_ALARM_ABORT_CYCLE) {                //执行停止循环报警      
0 t/ Y0 f, c. c& A& x' M, q) K  l      report_alarm_message(ALARM_ABORT_CYCLE);                //出现终止循环报警: s  ~7 q; y4 l9 i7 M' h- V% U
    } else if (rt_exec & EXEC_ALARM_PROBE_FAIL) {                        //执行探查失败报警- r5 l# u3 v" s
      report_alarm_message(ALARM_PROBE_FAIL);                        //出现探查失败报警
# x9 P' n5 t; J3 c    } else if (rt_exec & EXEC_ALARM_HOMING_FAIL) {                //执行返回原点失败报警
2 v) o& T/ I6 @, R& y0 X      report_alarm_message(ALARM_HOMING_FAIL);                //出现返回原点失败报警
* l! |* |) w" T* {6 @    }1 U- [+ c# I2 Y( ?4 l
4 ~8 \* R: Q+ `: s+ n
    // Halt everything upon a critical event flag. Currently hard and soft limits flag this.
7 L- [" y* a* @+ I# Z    // 停止一切在一个关键事件标志。目前硬和软限制标志1 j8 b% Y4 |4 T$ R, e- ~* x
           if (rt_exec & EXEC_CRITICAL_EVENT) {                //如果系统是循环事件进入! k* H' {' L' A/ `& X6 i
             report_feedback_message(MESSAGE_CRITICAL_EVENT);        //报告反馈信息
9 M1 ]0 k2 z2 W3 z              bit_false_atomic(sys_rt_exec_state,EXEC_RESET);                         //清除目前的复位状态
' ^2 N* ~% b4 \
0 \9 z- J$ {) `$ K* s* B        bit_false_atomic(sys_rt_exec_alarm,0xFF);                                 // 清除所有报警标志; o. U( T4 a' h' T* R% Y/ `. S3 z
        }        $ p8 v9 C7 d8 e, K. ^1 d' T) B

' {+ p4 [( A3 T" J2 H5 r6 j上面代码将rt_exec = sys_rt_exec_alarm ,如果rt_exec为真,打印不同报警信息/ H# b4 Z. \5 [+ j- u, Z
和限位保护信息,然后清除报警状态
5 C+ L( j$ f$ B+ d% S5 ^___________________________________________________________________________
% N3 D! W6 w7 _; `) b" }$ o; n没有报警进行执行下面代码,执行了终止命令,串口打印命令
0 v. A  X$ l/ _: {         // Check amd execute realtime commands        校验和执行实时命令$ y4 K; l4 F5 C/ z& \! V
          rt_exec = sys_rt_exec_state; // Copy volatile sys_rt_exec_state" @) u* G" t1 m  c

/ n' p0 W  Y5 q! y# F9 L        if (rt_exec) { // 输入标志是正确的执行
. B, ~% f) J3 M* n
' M& }8 c5 X4 V% s            // Execute system abort. 执行系统终止命令
4 n3 I' Q. A) K* Q4 `            if (rt_exec & EXEC_RESET) {2 v  }# H3 q9 I
              sys.abort = true;  // Only place this is set true.
: c# g: R3 K0 c3 `              return; // Nothing else to do but exit.7 [+ ]# A6 u/ J& E+ d' P; E
        }
& z6 @* K9 o' N  y. g
  a  ~% d, B5 n3 w% j8 r, B            // Execute and serial print status 执行和串口打印状态
8 |8 R* ?( Q4 [. v0 X, J" C            if (rt_exec & EXEC_STATUS_REPORT) { / K3 c: J: t8 D) ^! C7 S' \" X
              report_realtime_status();        //报告实时状态+ b" o' n1 `) b" N
              bit_false_atomic(sys_rt_exec_state,EXEC_STATUS_REPORT);        //清除报告状态清零( ~+ A; x* j( U( \
            }
: b7 j$ G/ e$ O_____________________________________________________________________________
, p# D  q- j2 S8 C. t6 l6 R下面代码4 h/ p  @5 A4 ?- D/ G2 b6 q8 t
//执行状态。6 I* I# m6 G1 f9 E+ {
//注意:所涉及的数学计算持有应该足够低对大多数人来说,即使不是全部,
8 W. a: d/ d1 u! Q( S# @( V//操作场景。一旦启动,系统进入暂停状态
9 K. H# [3 ~! g  p8 M6 ^* `//主程序流程,直到重置或恢复。
9 {% @% v) q, p待办事项:检查模式?如何处理呢?可能没有,因为它只会在空闲,然后重置Grbl。
! g! P1 k0 y" V, g状态检查容许状态的方法。
6 z# u- W. u7 B: {% C* F& j4 v$ s) z5 \* F' _
        //如果全局各自报警标志位其中(执行取消动作) | (执行进给保持) | (执行安全门)任意一位为真进入2 V) I- l8 a$ v
            if (rt_exec & (EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR)) {        8 R0 t% n2 E5 f# ?
- W  A+ P  A4 U  A+ R" s+ y  X9 R  D
        //如果是循环状态执行暂停状态7 `3 a: R" m" e. G% z
        if (sys.state == STATE_CYCLE) {
1 V. W& [! o6 J( L: f8 W( R! a        st_update_plan_block_parameters(); //通知stepper module验算减速。
- U. e; v  O* D4 ?# x0 f        sys.suspend = SUSPEND_ENABLE_HOLD; // 开始暂停标志5 G- }7 Y  z/ u) u$ F' Y
        }9 |2 H/ w; d2 n1 W$ J! L* X3 B

  Q* O- [6 E* K* _% x# N  S        // 如果,Grbl空闲不在运动。简单的指示暂停就绪状态。" ]; R5 K. ^$ ]3 M7 Q
        if (sys.state == STATE_IDLE) { sys.suspend = SUSPEND_ENABLE_READY; }3 t( f' d$ t9 x" L/ }' k- c1 }0 B0 G
9 J  K/ u9 r0 q; [0 b9 Y; q( Q

5 }: I7 ^% w3 \        //执行和标志和减速运动取消并返回空闲。主要由探测使用周期8 ]8 Z9 b" ]; N4 u, ~' H
        //停止和取消剩余的运动。       5 L  P  t+ ^& V( T! d
        if (rt_exec & EXEC_MOTION_CANCEL) {
- B6 Y7 r( m  x$ I          if (sys.state == STATE_CYCLE) { sys.state = STATE_MOTION_CANCEL; }* ^- S1 V8 m$ W3 E8 `; ^0 ?
          sys.suspend |= SUSPEND_MOTION_CANCEL; " M; O+ s+ w( ]$ S1 d! n2 C% L( f
        }% t2 W, T0 h: V. s8 R" A
, E4 I( B. c4 y0 s' k. f* H
        // 只在循环时执行进给保持减速# }: q! k. }4 |) S
         if (rt_exec & EXEC_FEED_HOLD) {
/ d5 f" I' Y" t7 z& j% F        //只有安全门为1才执行保持进给状态赋值* L" C1 N) {- i# K9 I3 k% H
          if (bit_isfalse(sys.state,STATE_SAFETY_DOOR)) { sys.state = STATE_HOLD; }- K; ]" ]/ T9 H' `; D
        }
" {! w% [/ Z9 Q
8 o; f1 P" e5 c4 O9 R2 i        if (rt_exec & EXEC_SAFETY_DOOR) {
1 k1 m! P8 f; O" s+ f" W          report_feedback_message(MESSAGE_SAFETY_DOOR_AJAR);
$ j! M' Z: u* O6 d/ /如果已经活跃,准备好重新开始,CYCLE_STOP标志设置为强制断开。" ?, v, t- D8 {5 X. T  V
/ /注意:只是暂时设置“rt_exec”变量,不是动荡的“rt_exec_state”变量。  J; L& \1 a: {, w, p
          if (sys.suspend & SUSPEND_ENABLE_READY) { bit_true(rt_exec,EXEC_CYCLE_STOP); }2 \6 u. w6 B5 Y
          sys.suspend |= SUSPEND_ENERGIZE;, X5 f) }1 z8 c$ ~
          sys.state = STATE_SAFETY_DOOR;7 z! x& q0 a) {- \. J. Z# f
        }$ U8 @; y: V+ V. L5 n  G; X- E
0 ?, s9 V( o4 P* d  K2 G. ^- _
bit_false_atomic(sys_rt_exec_state,(EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR));   
! F9 P5 G) K: v1 R
& H5 B4 n( U& k( \: t}
- w7 |% i+ ?2 j以上代码执行了; w% }2 s) z; K
1.如果全局各自报警标志位其中(执行取消动作) | (执行进给保持) | (执行安全门)任意一位为真进入9 x0 n7 _8 k% @6 [8 Y, w( o
2.系统为闲着状态, 开始循环状态, 回原点状态, 控制取消状态, 开始保持状态, 开始安全门状态时进入
0 S1 r+ }: X5 _2 I5 A, J3.如果是循环状态执行暂停状态
3 S& ?" w4 N( r' D# X4.如果系统闲置状态执行暂停就绪状态& V& R) r4 D3 X4 o
5.执行动作取消7 z; B3 I  d* e2 W! u1 Z
6.如果是保持进给状态,执行保持进给状态" W4 Q9 ?1 z; i$ ]: F  B
7.执行安全门状态2 N! J) x# V- J7 ^" b8 `
最后执行bit_false_atomic清标志清除(执行取消动作)(执行进给保持)(执行安全门)标志位                  0 e* ^( I' w2 ]* @: A4 S
_____________________________________________________________________________
6 b: P6 K/ i& h7 F4 J( Z/ _* q
7 _3 b3 T; B. M# X% Z& s    // Execute a cycle start by starting the stepper interrupt to begin executing the blocks in queue.6 m) D/ P4 y1 ?% `1 G8 S/ ^8 s
    // 执行一个循环开始启动步进开始执行中断队列的街区! t  L4 p; {+ v' u0 r' M
    if (rt_exec & EXEC_CYCLE_START) {        //循环开始状态进入( |8 F9 s6 k# c
      // Block if called at same time as the hold commands: feed hold, motion cancel, and safety door.
( p1 i4 |9 n$ Z1 ]3 U: l0 K; d7 k! {) u( J      // Ensures auto-cycle-start doesn't resume a hold without an explicit user-input.; p2 l' C$ W. r9 g1 G
          //块如果在同时举行的命令:保持进给,运动取消,和安全的门。 //确保auto-cycle-start没有简历没有显式的用户输入。: k* e/ E8 |3 D' P. x
          
# e8 g0 p, P9 l" f, o: Y      if (!(rt_exec & (EXEC_FEED_HOLD | EXEC_MOTION_CANCEL | EXEC_SAFETY_DOOR))) {   //状态机如果不是保持进给,运动取消,和安全的门。 % \- [6 m/ l" Y6 V' G7 n8 U4 l
        // Cycle start only when IDLE or when a hold is complete and ready to resume.8 B- q2 |4 H2 Q0 y
        // NOTE: SAFETY_DOOR is implicitly blocked. It reverts to HOLD when the door is closed.
6 n9 i$ \0 l. s# H                //循环开始时只有当闲置或持有完成并准备简历。6 J; Y  _$ Q5 G! v6 o. _
                //注意:SAFETY_DOOR是隐式地屏蔽。它返回的时候门是关闭的。    5 g0 i) ^7 A$ G) [3 N3 Z3 V$ q

% @3 z0 W' T! k& M* I# S                // 如果系统状态为闲着状态,系统状态为开始进给或运动取消,暂停标志为位重新开始
$ S- M( n8 Y9 g        if ((sys.state == STATE_IDLE) || ((sys.state & (STATE_HOLD | STATE_MOTION_CANCEL)) && (sys.suspend & SUSPEND_ENABLE_READY))) {$ @$ V) V2 W  E- a0 ?
          // Re-energize powered components, if disabled by SAFETY_DOOR.
% g) c" r( ^' B8 m/ L9 V          //        由SAFETY_DOOR重振组件供电,如果禁用。
* m0 W; r2 C' n. X4 E$ S' M          if (sys.suspend & SUSPEND_ENERGIZE) { 0 e* Y3 D4 Q$ x7 z& R7 K$ N! y2 d6 a
            // Delayed Tasks: Restart spindle and coolant, delay to power-up, then resume cycle.6 x; `+ l! `3 y" V5 O" v0 Z
            //延迟任务:重新启动主轴和冷却剂,延迟升高,然后恢复周期。
* l8 o1 o. D. L. f            if (gc_state.modal.spindle != SPINDLE_DISABLE) {   //主轴模式不是失能进入0 r$ o  x' j6 ^  V9 _& X% l1 m
              spindle_set_state(gc_state.modal.spindle, gc_state.spindle_speed); //设置状态和速度
1 J8 q" O) z  t$ |% u- p              //待办事项:阻塞函数调用。最终需要一个非阻塞。- r, W7 D7 q% |/ p
                delay_ms(SAFETY_DOOR_SPINDLE_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.
  ]+ n% a$ u( |' F/ s$ {            }
, }: j  N/ B2 t& z! H            if (gc_state.modal.coolant != COOLANT_DISABLE) {
9 ~1 P7 a, P" B- n( H' A* X0 f* p              coolant_set_state(gc_state.modal.coolant); ! \0 B1 I  q5 O, m9 B! l% B
              delay_ms(SAFETY_DOOR_COOLANT_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.1 A+ p* n6 Y( x" @) o$ E8 V. j
            }
& e) l# C( x' Z4 @( H% J, m- P            // TODO: Install return to pre-park position.
/ T9 m. p; O* y" L; |0 `          }' K0 b5 f9 |; @- r% n$ r) w8 Z
______________________________________________________________________________________________________________
% U# s, C; h" E          // Start cycle only if queued motions exist in planner buffer and the motion is not canceled.: O  e9 N3 e9 p  c: Q1 L
                  8 @; n7 E2 o5 g% v. W
                  //只有在队列马达存在规定的缓冲,并且动机没有让取消,才会循环, F3 h$ ^5 R* B6 m/ J
                  
8 o3 y) @' h, [' d* U9 D9 S" F9 D          if (plan_get_current_block() && bit_isfalse(sys.suspend,SUSPEND_MOTION_CANCEL)) {
4 M  O! g$ A7 U7 H+ V            sys.state = STATE_CYCLE;8 U5 C# P% r$ k7 a& l2 r
            st_prep_buffer(); // Initialize step segment buffer before beginning cycle.初始化步开始循环之前# [& M+ X8 v# o5 L0 X2 l
            st_wake_up();
1 G7 H7 ]6 j  G4 f# |# h4 i          } else { // Otherwise, do nothing. Set and resume IDLE state.否则,什么也不做,设置和复位空闲模式- ^0 ?2 ~, I$ B% K/ Q
            sys.state = STATE_IDLE;) X$ W6 u* E% g& ~+ }( V4 Y8 ^
          }8 Q0 v( |, g1 L
          sys.suspend = SUSPEND_DISABLE; // Break suspend state.- L/ m' l" _7 J$ E8 |$ U
        }: [4 w' N2 _  M# L' g3 ~
      }   
# M  @# d+ d  N. Q" Y. c/ |* e      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_START);       
* N, ~- W) ?. C5 j    }
" T1 |' _1 @! a; m, ~1 p$ N3 y% B' O
_______________________________________________________________________________________________________
9 O! e, \( T; h    // Reinitializes the cycle plan and stepper system after a feed hold for a resume. Called by ' i& i- k7 D, P% V3 J9 S
    // realtime command execution in the main program, ensuring that the planner re-plans safely.
- y: G" d) y: d. \    // NOTE: Bresenham algorithm variables are still maintained through both the planner and stepper0 ]- P$ j8 s+ d! C6 g( K' ^
    // cycle reinitializations. The stepper path should continue exactly as if nothing has happened.   $ F  g* U5 z6 z, U% F1 o" q
    // NOTE: EXEC_CYCLE_STOP is set by the stepper subsystem when a cycle or feed hold completes.
$ L8 m, ^2 W3 Z. Q# n' V" g  N
( L( Y# I8 G  y  \+ d$ u        //重新启动后循环计划和步进系统的进给保持简历。通过实时命令执行主程序,确保安全计划重新计划。! _2 s: k# a! B5 v6 ~- }
        //注意:画线算法变量仍保持通过规划师和步进
9 Z4 U6 k% a' }+ E- _        //循环仅。步进路径应该继续,好像什么都没发生一样。        & t9 m4 k" m/ P* M
        //注意:EXEC_CYCLE_STOP由步进子系统周期或进给保持时完成。9 P0 Y: M5 R; C5 P( q3 r3 B

* G; E5 W3 C, {    if (rt_exec & EXEC_CYCLE_STOP) {                         //如果是循环停止状态进入) t; ]  Z, F8 U9 f! m; g9 ^
      if (sys.state & (STATE_HOLD | STATE_SAFETY_DOOR)) {: A* v$ D% W2 _& K* c( X
        // Hold complete. Set to indicate ready to resume.  Remain in HOLD or DOOR states until user! ^2 r; U/ K6 q' Y  @4 h
        // has issued a resume command or reset.
9 R2 N; K  U# d& A4 F
; C( }  A$ f! R5 {" m9 i2 I: z                //保存完整。设置为指示准备简历。继续持有或门状态,直到用户
! s+ P! I$ V* P/ n" e                //已发布了一份简历命令或重置。  o+ u8 O2 |+ c5 Q
               
1 ^* W- ?9 u! o        if (sys.suspend & SUSPEND_ENERGIZE) { // De-energize system if safety door has been opened. 如果安全的门已被打开。断开系统
; v1 G) v" }3 v! ?) X4 t) J. j% \          spindle_stop();1 j1 Y0 K0 M8 E' G; Y% `# j
          coolant_stop();
' r3 ]- c# x' U2 Z5 s          // TODO: Install parking motion here. 安装停车动作。7 x8 Y; G! z* h3 {6 x3 C
        }
% m* D9 H0 t+ s4 Q9 q        bit_true(sys.suspend,SUSPEND_ENABLE_READY);, }; o6 u  K& S/ B
      } else { // Motion is complete. Includes CYCLE, HOMING, and MOTION_CANCEL states. 电机完成,循环,回原点,,MOTION_CANCEL
( ~$ L' L6 }, w- i        sys.suspend = SUSPEND_DISABLE;" H: a0 x& C) U% \1 D: N) w
        sys.state = STATE_IDLE;
( h0 u7 l. S8 J- O      }0 B0 |. Y  z0 ?: i( y
      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_STOP);2 [' L! g& V" o7 S7 ^+ p
    }; x; x8 S" ^5 S7 }! W2 o- [% `3 i
   
, V9 @! O& i! w# E: Y  }
1 s) n; e/ [  A0 N. J8 ]/ g___________________________________________________________________________________________________' R- Y% w; \4 E& z  k  m5 ~
5 k- b- S3 I! `! B
  // Overrides flag byte (sys.override) and execution should be installed here, since they
. r, E0 T1 a4 f' p0 W7 y  // are realtime and require a direct and controlled interface to the main stepper program.
' }" W3 V- ?! W5 \1 r. Z6 y* ~  h+ C% z' c5 k  t9 o) c
  //重写标志字节(sys.override)和执行应该安装在这里,因为他们
3 I, ~5 o. E. ]: `: y  //实时和需要直接和控制接口的主要步进程序。! j0 x+ i# K5 c4 U' V" y, M+ F

1 ~0 E0 S; Q& k
( q* o1 R0 U( t- [  // Reload step segment buffer 重新加载步段缓冲9 s5 H9 n& k( _9 }( S7 X8 _
  if (sys.state & (STATE_CYCLE | STATE_HOLD | STATE_MOTION_CANCEL | STATE_SAFETY_DOOR | STATE_HOMING)) { st_prep_buffer(); } 3 |1 c! @4 }$ d6 C! P5 K* e

7 s. q5 ^9 a% J. M  t  // If safety door was opened, actively check when safety door is closed and ready to resume.
: N" j# O) T: u' f  // NOTE: This unlocks the SAFETY_DOOR state to a HOLD state, such that CYCLE_START can activate a resume.       
4 _0 R- X$ S# d4 h$ [  y# N) I. ?
$ C. ^0 Q7 l6 e//如果安全的门被打开,积极检查当安全门关闭,准备简历。
( m  y. q/ |* e9 i9 H: o7 v  //注意:这解锁SAFETY_DOOR状态保持状态,这样CYCLE_START可以激活一个简历。
! R- R& r' P6 Z! v2 ~/ t, V% m% q* J8 l+ S: B% [
  if (sys.state == STATE_SAFETY_DOOR) {                 //安全门状态进入; P: H& J4 }; k1 l) N' Q; n- r+ n0 ]
    if (bit_istrue(sys.suspend,SUSPEND_ENABLE_READY)) { 8 t/ }$ n% h( a
      if (!(system_check_safety_door_ajar())) {
/ M2 x2 o. e  z$ V% J) S        sys.state = STATE_HOLD; // Update to HOLD state to indicate door is closed and ready to resume. 更新保存状态指示门关闭,准备简历。
+ y  p6 i- G( i& ]  T( c      }8 j* X0 X7 G/ F/ B
    }
6 ]6 T5 S; v9 Z& U, C) ^  }6 d- V/ K. v" x3 e

* {+ F7 {# R2 i' U  } while(sys.suspend); // Check for system suspend state before exiting.6 }" d  \5 V( V
  
6 _( I- j( L: ~8 K}  
回复 支持 反对

使用道具 举报

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

点评

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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-2-19 07:11 , Processed in 0.082079 second(s), 20 queries , Gzip On.

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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