机械必威体育网址

 找回密码
 注册会员

QQ登录

只需一步,快速开始

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

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

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

% c+ A# t- H: a/ y4 j    下面介绍小这个些主控程序主要干的事,通过串口PC和主控板通讯,PC命令给控制板,控制板接收命令做不同的响应,PC可以发G代码给主控板,接收完成后可以自动开始雕刻任务。
6 Z, u. r9 R6 k3 ]          在介绍下G代码因为G代码是雕刻机的核心部分
7 {* T. v- q, y# k% aG代码是数控程序中的指令。一般都称为G指令。
- `% ^9 \! \3 \; B4 [/ G) H6 E; ]G00------快速定位
8 K7 ^3 C, O) ]* S. e4 y) }G01------直线插补
4 q& ~5 g  W, m8 v: g& [G02------顺时针方向圆弧插补
8 f, |- f. U' F6 ]. d6 Q2 d1 nG03------逆时针方向圆弧插补: B8 d# V* {* q: z
G04------定时暂停/ y# e. p+ \  b6 }
G05------通过中间点圆弧插补& v: a& o: Z& R: q9 z6 p% m
G06------抛物线插补
( R- o5 F# o" P( H. {3 sG07------Z 样条曲线插补
: p4 k0 a& A& J/ @+ RG08------进给加速
9 A/ i) f5 C4 ~3 z) n# L1 EG09------进给减速
! a. \  j) n) _. f2 ^G10------数据设置' `. {% O$ S% E) I
G16------极坐标编程
1 z* u, c) v7 R3 N, s; c  kG17------加工XY平面" A' }, H/ p3 ~6 u
G18------加工XZ平面
* H$ s! T: j9 q7 @* |4 Q) t3 _G19------加工YZ平面
, o; S) J5 u! Y5 b5 s+ F8 `3 u
核心就是解析G代码,完成步进电机驱动,和控制主轴开启关闭,还有插补算法,直线插补,圆弧插补,还有一些步进电机的加减速算法。5 i9 d# b  n5 l0 ^
下面对grbl主结构做介绍. S, c% X( z% v
main()主函数首先执行下面初始化函数& f8 O" D9 `. M$ C8 y
        serial_init();                           // 设置串口波特率和中断& y& n2 M: c( v+ d- [8 F
        settings_init();                         // 从ROM加载grbl设置, l  e) G& u) U6 w
        stepper_init();                          // 配置步进方向和中断定时器" {. f9 [" c+ g. |7 e7 s
        system_init();                           // 配置引脚分配别针和pin-change中断3 i8 N) b6 L. M, }0 P) ?! E
        memset(&sys, 0, sizeof(system_t));          // 清除所有系统变量5 e1 o7 G: R+ p" ?
        sys.abort = true;                           // 中止标识位置位  n; h' F1 H- j5 J
        sei();                                         // 使能中断
2 U9 g; n6 h! i( e" d7 k. z  #ifdef HOMING_INIT_LOCK                        // 宏运算(settings.flags & (1 << 4)) != 0结果flags等于执行sys.state = STATE_ALARM
+ i+ l4 k& f# M7 O                                                // 系统状态赋值为报警状态3 u: ?# S: r- ]# u7 w
            if (bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE)) { sys.state = STATE_ALARM; }  k: l* q5 R* x' a& R, F
  #endif
8 Q* }: K5 i4 F9 G0 B7 Z% m) N_____________________________________________________________________________________________________________________________________) B; Y9 ]2 y7 I1 G" `
接下来是一些主要部分初始化
1 h5 z  E( F, V) M3 q5 h, R" A( a. Ofor(;;) {
9 z" f: Q' m( _" N! ?6 z% c; c        serial_reset_read_buffer();         //清除串口读缓冲区% }$ y2 p5 d* D0 h, ]6 k) ~# b
        gc_init();                         //初始化G代码功能函数% x( [' F* _9 c6 Z" s
        spindle_init();                        //主轴初始化
6 ~: i/ |! m/ c! g/ h  o- ]. ?        coolant_init();                        //冷却液初始化9 {4 ~0 j" j( v0 x
        limits_init();                         //极限开关初始化; i6 l! V0 G6 ], g  @
        probe_init();                        //探测部件初始化
: e$ \3 [, g9 Q3 }" v- _& \        plan_reset();                         //清除块缓冲区和规划师变量* X! W: y* i4 o' D- h
        st_reset();                         //清除步进系统变量。# C+ l& a* P6 u3 V2 A3 D
4 T) l4 ]& \5 z  M2 y5 K

/ t. b6 a; D* @        //下面两行清除同步gcode和策划师职位当前系统位置。
* k1 C' n2 z8 L: M& F6 }4 M+ J
        plan_sync_position();
  J8 c. P6 b) v# ^        gc_sync_position();
0 T; |8 K0 `) n* f5 K9 G8 a. Y. F5 x6 D

6 n3 Q# W/ W5 H" W+ V        //复位系统变量' B; m' }! b6 u. V! k
        sys.abort = false;                //系统中止标志
! l0 z! N, e1 D; {        sys_rt_exec_state = 0;                //系统标志位变量状态管理。看到EXEC位掩码。
- \5 H& H) h' M% v; h& D0 M: f        sys_rt_exec_alarm = 0;                //系统标志位变量设置不同的警报。
! L7 x) I, {3 w7 W        sys.suspend = false;                //系统暂停标志位变量管理,取消,和安全保护。
! G2 M. ]1 V2 d3 b! Y& N* _        sys.soft_limit = false;                //限位开关限制状态机错误。(布尔)' X" x, O/ N4 k9 h+ y

. ~) l& l9 M* ]; v' h  v! D9 O; i+ Z1 X7 A% a: J) ]2 h: N7 _6 F
        protocol_main_loop();                //主协议循环4 g! _- g$ y4 E! R* w7 k0 d% @
}        //
7 S' h9 f. T/ Z! o7 j_____________________________________________________________________________________________________________________________& @3 W: F0 G/ |1 U5 g5 w( L" b* t. F
进入void protocol_main_loop()函数
' _* ?4 }' F( o( Q# W{- A$ ~4 t: c; o$ ]2 u, u3 O
        report_init_message();                // 打印欢迎信息
# X, |  |+ l6 c; T" r        //重启后检验和报告报警状态如果错误重启初始化。
3 g& Y1 j, i6 J8 P
        if (sys.state == STATE_ALARM) {$ t  q) u) N" b1 W' d) C" \
            report_feedback_message(MESSAGE_ALARM_LOCK); //打印信息
$ ?+ h$ k; u5 r* k; g" L
          } else {* T' @: L2 T" T# V) S; X9 Z3 W0 R) T- ^
            // 如果没有报警说明一切正常!但还是要检查安全门. , D4 `2 E  c4 }8 s
            if (system_check_safety_door_ajar()) {: P8 t1 R( t. F
                     bit_true(sys_rt_exec_state, EXEC_SAFETY_DOOR);6 @+ r9 q5 ?. i  w. k$ A: T; [7 S0 f
                     protocol_execute_realtime(); // 进入安全模式。应该返回空闲状态。
% X4 L6 t2 F3 h  b2 @$ W            }         else {+ H4 T9 l; y; P' h. `8 L( X7 B
              sys.state = STATE_IDLE; // .设置系统做好准备。清除所有国家国旗。& Y# Z( _2 D2 J& D3 F/ A
            } / j( b% S5 m: m3 ^! G9 q5 ~
            system_execute_startup(line);    //开始执行系统脚本
! r: K9 {9 n# s) p! B  I+ B/ X  } 9 B$ y$ G2 B7 j$ B: N: ^5 b7 y. ?1 ]

5 v  @: ]. j* i2 K, e! z
/ @! R9 i: d1 ~  g. b. M6 Q, w  // 这是主循环!在系统中止时这是出口回到主函数来重置系统。
' i: G& s, @5 n9 r8 m& R$ d7 o  b  // ---------------------------------------------------------------------------------  
$ B3 u# O, R* i  e( X  $ C( x$ ?5 Y4 d, `" o/ @
        uint8_t comment = COMMENT_NONE;
- M* A0 a0 Q# l  j8 C        uint8_t char_counter = 0;9 h2 d! r9 i$ c. T( u! i  \3 _
        uint8_t c;
. t2 V3 |- |1 d) F! L& T; i_______________________________________________________________________________________________________________________________
% T8 j( m" t; e% o9 d接下来进入for(;;)循环                //下面代码是G代码解析核心部分,程序中comment(注释)变量会被赋不同值,代表发符号有‘(’‘)’‘;’
: U" h+ d7 M' i/ i# s& D{! o  x# g( L8 o. j! ~+ X  X
//串行数据输入一行的的过程,作为数据。执行一个
, `' B; m: F" o2 c//所有数据初始过滤去除空格和注释。
0 r  e1 c6 d7 J/ }. P//注意:注释,空格和程序段删除(如果支持的话)处理技术
9 @9 ]! P/ i: ~: X/ |3 `5 R//在G代码解析器,它有助于压缩到Grbl传入的数据
1 H! ]4 ]8 h/ y! }//线缓冲区,这是有限的。刀位点标准实际上州一行不行
6 I5 a" i- N& u7 E- z//不能超过256个字符,Arduino Uno没有更多内存空间。  L- R1 P  }# z) Y( h5 F( b1 ]
//有更好的处理器,它会很容易把这个初步解析的
: T2 J9 p5 v# R//分离任务共享的刀位点解析器和Grbl系统命令。                                                               
5 e2 ?) e3 i6 w# j    while((c = serial_read()) != SERIAL_NO_DATA) {                             //读取串口数据,有数据执行下面代码
" N7 Z% f% e9 D9 \7 Y, b3 b3 I9 W      if ((c == '\n') || (c == '\r')) { // End of line reached                //如果数据是/r,/n代表一行结束5 T5 l4 @, u. S, f5 k/ |
        line[char_counter] = 0; // Set string termination character.        //设置结束标志
' x7 \& z' [% C  T/ m  f        protocol_execute_line(line); // Line is complete. Execute it!        //一行完成执行此函数4 v% A+ v# s  t- R; G
        comment = COMMENT_NONE;                                                //注释清零
2 l- i3 R/ l6 m        char_counter = 0;                                                    //字符计数清零
" o1 Q$ r; O1 z$ i! s* `1 f  9 }5 z6 u7 y, I1 T2 G, `
        else {
4 [+ i5 K4 w# q) O- q  f6 e        if (comment != COMMENT_NONE) {
+ Y9 Q* k# w3 o) E# h                                                     //扔掉所有注释字符: X* P5 m/ j  K# Z* {  G5 N& k
          if (c == ')') {8 Q' B$ V9 D: C4 c! A( ?
            //最后注释。重新开始。但是如果有分号类型的注释。
0 d4 {* M' l& `  G$ q            if (comment == COMMENT_TYPE_PARENTHESES) { comment = COMMENT_NONE; }; G9 n! a+ \4 N# ?  W1 N6 r% a
          }& X* k: c1 X& F( V+ l( J
      } else {
- ^# B( G5 X2 [, i          if (c <= ' ') { 9 K& B; I3 |6 d# C8 T2 C$ x
            //扔掉whitepace和控制字符4 c# t+ l! }1 x- }$ u& c- P
          } else if (c == '/') {
( k3 T+ K6 I0 A. F% A, y) p            //块删除不支持将忽略字符。
$ C, X% G* W; Q$ c& K9 T( V3 x5 h            //注意:如果支持,只需要检查系统是否启用了块删除。
  Z/ C. W5 l+ K: {* Y6 O          } else if (c == '(') {
1 I' `3 R7 }% ?; n0 d. |            // Enable comments flag and ignore all characters until ')' or EOL.
' U( ]4 M( E/ ~  b7 I# A1 ~            // NOTE: This doesn't follow the NIST definition exactly, but is good enough for now.
: v2 |8 Z6 ]* M9 a) _9 K            // In the future, we could simply remove the items within the comments, but retain the7 e( c- W; U  k8 H3 A& V6 m
            // comment control characters, so that the g-code parser can error-check it.# y. i* V( z5 E/ s
            comment = COMMENT_TYPE_PARENTHESES;; W7 d1 ~2 B$ u1 W% X  j$ M
          } else if (c == ';') {
( @/ i3 W- A' A; E; S2 ^- b8 h: X2 s            //注意:','注释EOL LinuxCNC定义。没有国家标准。0 }  N  R1 e# J' |. x5 P
            comment = COMMENT_TYPE_SEMICOLON;
& A  X+ Z8 h+ G# Q. M, Q$ N9 {9 X: q5 l: A' H% `4 \# K

' p9 ~7 f- ~3 G9 M3 h) F_____________________________________________________________________________________________________________________________________3 p3 `4 G( ^( b* q% V) R! }
          } else if (char_counter >= (LINE_BUFFER_SIZE-1)) {                        //串口接收数据大于80字符时9 z+ c+ ^+ P  ]9 P, V
            // Detect line buffer overflow. Report error and reset line buffer.        检测缓冲区溢出。报告错误和复位线缓冲区。8 W4 i- h% ^; r- v
            report_status_message(STATUS_OVERFLOW);                                //打印溢出信息) z" j/ L6 E/ `3 s& C, ?/ z2 F
            comment = COMMENT_NONE;6 k9 A% i1 d0 _  C2 V
            char_counter = 0;
; m$ b6 \: g& h$ z3 n: _          } else if (c >= 'a' && c <= 'z') { // Upcase lowercase                        //小写改大写
/ z8 J6 O$ C- ^6 y            line[char_counter++] = c-'a'+'A';4 [- _! |" {- y2 V6 n& D$ O
          } else {) Q" o( f, H) {0 B. l
            line[char_counter++] = c;% z0 I" L+ ^! ~$ P; O
          }, p" E1 P! P! I2 m
        }
9 k: J# i: |0 P8 H0 ~* a      }
. S- y3 y; H. J( r+ ]& g) L; ]    }! S' q1 E* F' c% y! j. y
____________________________________________________________________________________________________________________________________! n% U7 b1 @3 }! t) M7 Q
        //如果没有其他字符在串行处理读取缓冲区和执行,这表明以完成,自动启动,如果启用,任何队列动作。
. n7 N  T! d- k- R# d7 b; {) H' |3 G        protocol_auto_cycle_start();                //自动开始协议循环
3 V& {, }# X" r$ P        / r, p6 o& a- m" f) Q( q2 n+ i! }
            protocol_execute_realtime();                  //运行实时命令。1 Y- g2 C7 e/ E- [2 c0 a( i/ Y  R
            if (sys.abort) { return; }                 //中止标识置位程序循环重置系统。            
' g3 w4 Y7 ~8 w! A$ ]: ~- {  }
, S! O2 H& {  S0 d7 D) e6 G  return;                         //一般程序不会执行到这里
" x- e6 Z7 u) h6 e  N' \}
8 @/ w" w, n! B____________________________________________________________________________________________________________________________________; }$ A  _) ~5 F3 V6 j6 p! C
正常情况下,读取完G代码程序会进入protocol_auto_cycle_start();//自动开始协议循环 函数下面介绍此函数3 U8 v0 Y& y$ Q
// Auto-cycle start has two purposes: 1. Resumes a plan_synchronize() call from a function that
2 t! m* B; i" o2 B0 _- v// requires the planner buffer to empty (spindle enable, dwell, etc.) 2. As a user setting that 7 ~2 F! [$ Y' p3 C4 t
// automatically begins the cycle when a user enters a valid motion command manually. This is
/ ]6 v  ~: r6 S4 F  q% e3 B) @// intended as a beginners feature to help new users to understand g-code. It can be disabled" j: l3 P! P. L4 C6 Q
// as a beginner tool, but (1.) still operates. If disabled, the operation of cycle start is" J, H6 l! W' D* I0 B
// manually issuing a cycle start command whenever the user is ready and there is a valid motion : E8 P( w5 \: G3 ^( x7 V0 G
// command in the planner queue.
' l3 C+ Y2 S: ?* q' B/ g% n( V// NOTE: This function is called from the main loop, buffer sync, and mc_line() only and executes 8 \2 D5 T& `: \
// when one of these conditions exist respectively: There are no more blocks sent (i.e. streaming
- G. a' |" p% o" C( r8 l// is finished, single commands), a command that needs to wait for the motions in the buffer to / [8 B: G4 K- ^6 X- W, |+ C
// execute calls a buffer sync, or the planner buffer is full and ready to go.$ v: Q4 D) u& h
//自动开始有两个目的:1。回复一个plan_synchronize()调用的函数9 T6 H' x) b; C2 {! L# n! W
//需要规划师缓冲区空(主轴启用、住等)2。作为一个用户设置! b, C: D3 w% R. Q2 @; {0 A! B4 K
//自动循环开始当一个用户输入一个有效的运动命令手动。这是" K9 C2 z6 n! [2 ?4 H
//作为一个初学者的特性来帮助新用户了解刀位点。它可以被禁用
2 Y8 q& X- ?- M, z//作为一个初学者工具,但(1)仍然运作。如果禁用,运行周期开始
% j! g5 }8 Q: s3 J//手动发出一个周期开始命令每当用户准备好,有一个有效的运动
6 g3 P2 z! @. Y2 \" h! r4 H/ p9 L//命令的规划师队列。  d+ R4 j9 h8 y3 x# \0 \
//注意:这个函数被称为从主循环缓冲区同步,mc_line只()并执行1 g" k8 ?1 L3 b% [2 @
//当其中一个条件分别存在:没有更多的块(即流发送, v! D; x5 |( t7 g3 b1 ]( L& K
//完成后,单一的命令),一个命令,需要等待缓冲的动作
# n( R; V; C7 @4 z0 y//执行调用一个缓冲区同步,或规划师缓冲区满了,准备好了。4 K! g  B$ t' J3 t) V
void protocol_auto_cycle_start() { bit_true_atomic(sys_rt_exec_state, EXEC_CYCLE_START); }
, P: u7 `8 f0 |9 m, L_______________________________________________________________________________________________
; Y7 h3 s3 T, w# h接下来程序运行protocol_execute_realtime(); /运行实时命令。* m# }7 P) w3 f' N
// Executes run-time commands, when required. This is called from various check points in the main
! b8 h! Z$ l9 Y/ N5 A// program, primarily where there may be a while loop waiting for a buffer to clear space or any4 p+ \6 C. ?3 y1 s! m2 y  ?7 N5 O
// point where the execution time from the last check point may be more than a fraction of a second.
! W! Y# U& |% V# z// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code
. w" e5 m6 ]9 d( n6 \5 ?0 f. ~// parsing and planning functions. This function also serves as an interface for the interrupts to
2 M  s$ R  J( [# A0 c+ _! x// set the system realtime flags, where only the main program handles them, removing the need to
# g& O. k1 U; j5 e& \// define more computationally-expensive volatile variables. This also provides a controlled way to   |" K% d) f2 H
// execute certain tasks without having two or more instances of the same task, such as the planner
: Y2 y* @- d3 X! |4 r5 a9 h// recalculating the buffer upon a feedhold or override.6 Q) x7 s: S1 I* F3 Q$ H
// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,* Z4 z0 w& b1 B8 @3 t" W" F' [# ~
// limit switches, or the main program.
* m8 j- \& h) U3 s! N4 Lvoid protocol_execute_realtime()
. p# v2 K+ E0 J! C# _, I uint8_t rt_exec; // Temp variable to avoid calling volatile multiple times.临时变量来避免多次调用不稳定。5 w  _0 l3 `0 Q) y0 c$ z/ N
就先分享到这吧!
* ~, k1 n+ z" I9 ^0 T4 h
  n  V8 H6 q9 i5 A, V* @; G$ k3 T- ^6 {

/ n! h& t% ?" t* B+ L. H4 O: b. {4 f# l9 H

& J( |1 q, d" R6 Q( R5 L. Z( t6 q- \
6 M' c+ a; s) m8 `! `
  ^# K- L" }* S- X, S- R1 y0 K, j

# @1 a7 b% j' q- o9 E) ~: E8 R: i( {+ ~3 S1 I
( A4 ~8 l! X$ g3 |- I. }

4 z) |" C6 a' B+ L5 {
5 m# ~6 ^5 U9 i" p6 x+ U" ]
% F, }) L; d4 u) ?/ f( W9 `6 [
# F& C; w& F) C8 G& O% @
: b8 M; U) T# V9 W9 k- N
0 H0 G# R; x" F
. ]) p# m( d' U' p% F) O- p3 Y' ?! d/ l: K7 o7 P
  U. k9 Q* X! z7 G0 c

5 b, z; k) k) f, f* `9 l
# n2 v4 M$ M/ a7 h. q
, ]) X9 ]9 ^7 c2 k补充内容 (2016-8-25 22:40):- [, Q: I$ Q' b* n( f7 W- M
配置说明
7 V5 t; A. I% T. e//这个文件包含编译时配置Grbl的内部系统。在大多数情况下,* L1 \: g4 m* ]6 [4 m
//用户不需要直接修改这些,但是他们在这里为特定的需求,即。  E9 q/ @+ |: b+ _/ Q! {
//性能调优或适应非典型的机器。0 V1 x; k8 D9 c6 y: j+ d9 j- U
主要配置项:" V* N# a5 q7 F2 a) }4 X
1.#define DEFAULTS_GENERIC        //在重置eepm时使用。在defaults.h改变想要的名字
/ Z- E8 m" k. z9 o9 N6 j2.#define BAUD_RATE 115200        //配置串口波特率115200
! Z; H7 j+ Q. ?; W; O3.#define CPU_MAP_ATMEGA328P         // Arduino Uno CPU
9 F6 _# \( m+ q5 ^3 V0 |8 G4.#define CMD_STATUS_REPORT '?'        //定义实时命令特殊字符7 C, ]& X1 s$ C
5.#define HOMING_INIT_LOCK         //回原点保护锁
, ~- S, J4 T; |, Q6.#define HOMING_CYCLE_0 (1<<Z_AXIS)              // 第一步Z清除工作区。
7 [; r" p" h$ [4 K- g  #define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // 然后X,Y在同一时间。& X0 F. c, P7 G1 H, d0 S& b
7.#define N_HOMING_LOCATE_CYCLE 1 //回原点循环次数- e' d# z& }5 y/ O! G% C) o* y; [
8.#define HOMING_FORCE_SET_ORIGIN //取消这定义迫使Grbl总是在这时候位置设置机器原点尽管开关方向。
+ L( c. M- |9 i) C9.#define N_STARTUP_LINE 2 //块Grbl启动时执行的数量。
( V7 ]# u) L+ q8 @% f$ j10.#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 协调或位置价值英寸0 S$ P. [! e: ?: d! `% }. x
   #define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 协调在毫米或位置价值
+ v5 w+ K" N0 }" ?% k   #define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分钟的速度值3 z& k* r# y2 H$ d
   #define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分钟2 {# f9 l( k# H8 M. Z
   #define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 对浮点小数设置值9 _. S; H* g, s$ X- s8 }. F$ h
11.#define LIMITS_TWO_SWITCHES_ON_AXES //如果你的机器有两个极限开关连接在平行于一个轴,您需要启用这个特性
& \0 o5 L5 {- ]2 e7 Z! v" C% {12.#define USE_LINE_NUMBERS         //允许GRBL跟踪和报告gcode行号
' M0 V5 {7 w. [13.#define REPORT_REALTIME_RATE //允许GRBL报告实时进给速率
, [- w3 X9 _5 a; _# ]14.#define MESSAGE_PROBE_COORDINATES  //坐标通过Grbl $ #的打印参数?" G1 a3 Y% D# c0 v; @9 D
15.#define SAFETY_DOOR_SPINDLE_DELAY 4000 //安全门主轴延时
# a' E3 p2 O; o. G6 n16.#define SAFETY_DOOR_COOLANT_DELAY 1000 //安全门冷却液延时- i( j, Z4 g$ g" Y
17.#define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS) //启用CoreXY运动学。
" ^8 {& E4 [+ `7 a# Q18.#define COREXY // Default disabled. Uncomment to enable.改变X和Y轴的运动原理- O: z5 D7 Z8 z  i
19.#define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.反转针销逻辑的控制命令
  G; x( L" K" r4 f  ^7 X2 k" n+ A* [20.#define INVERT_SPINDLE_ENABLE_PIN // 反转主轴使销从low-disabled" Z) ~6 X. H4 M/ W$ G
21.#define REPORT_CONTROL_PIN_STATE //启用控制销状态反馈状态报告。
1 d6 H9 _+ O- `3 k, |% ~! ]0 r22.#define FORCE_INITIALIZATION_ALARM //启用和用户安装限位开关,Grbl将启动报警状态指示* g" y& l% G0 d2 J+ I/ O
23.#define REPORT_GUI_MODE // gui允许最小的报告反馈模式
6 W2 c6 E7 r3 v( P8 G24.#define ACCELERATION_TICKS_PER_SECOND 100 //加速度的时间分辨率管理子系统。, w* m* C: g9 c
25.#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING //自适应多轴步平滑(积累)是一种先进的功能
' K* |* O9 \) U. t5 n26.#define MAX_STEP_RATE_HZ 30000 //设置最大一步速率可以写成Grbl设置0 q9 \1 Y' w; K
27.#define DISABLE_LIMIT_PIN_PULL_UP //以下选项禁用内部上拉电阻
: t& q. j: N0 m1 P  t' w5 H28.#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS //设置哪个轴长度补偿应用的工具。假设轴总是与选择轴工具面向负方向
- m0 S2 a- L/ ~7 [29.#define VARIABLE_SPINDLE //允许变量轴输出电压不同的转速值。2 t) F( O# d! Z$ q# _" n# a
30.#define SPINDLE_MAX_RPM 1000.0  // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.7 c+ \% N% X) {# `
   #define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.  l) o  [" M0 e) ~  }1 N! m
31.#define MINIMUM_SPINDLE_PWM 5 //使用的变量轴输出。这迫使PWM输出最小占空比时启用。
9 Z$ ^. H, s9 Y5 A4 q7 ~: J. N' T32.#define USE_SPINDLE_DIR_AS_ENABLE_PIN //主轴方向使能M4被删除
$ ^" s% ]" g7 E# n( N* ]9 A33.#define REPORT_ECHO_LINE_RECEIVED //应该对所有正常线路送到Grbl7 z: m$ L, U& p; N7 w0 q
34.#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min) //最小规划师结速度。设置默认最小连接速度规划计划
3 Z( g' G+ E% `- \  X3 n# T35.#define MINIMUM_FEED_RATE 1.0 // (mm/min)//设置计划将允许的最小进给速率
0 d! ]9 Y9 M4 V* \5 g3 g36.#define N_ARC_CORRECTION 12 //弧生成迭代次数之前小角度近似精确的弧线轨迹
: G8 U: J2 [; g- V4 v1 A* W37.#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)//定义值设置机器ε截止来确定电弧是一个原点了?
3 k: z. k' g# C' T$ B( Y/ x38.#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds) //延时增加表现在住。默认值设置为50毫秒
5 c" T5 w- w, o& X5 \, d: R39.#define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.! }0 ^: I- @) T; D+ l0 D  [( {
40.#define BLOCK_BUFFER_SIZE 18  //线性运动规划师缓冲区的数量在任何给出时间计划% x& t- u( q0 w- G5 `
41.#define SEGMENT_BUFFER_SIZE 6 //控制之间的中间段缓冲大小的步骤执行算法
6 f1 S  U6 I: v4 \6 Z42.#define LINE_BUFFER_SIZE 80 //行执行串行输入流的缓冲区大小。) A1 d& [0 a; p: @8 V4 k
43.define RX_BUFFER_SIZE 128 //串行发送和接收缓冲区大小
6 e' O* c, p% l44.#define TX_BUFFER_SIZE 64
) I+ t; l# D9 j; L' H! }* m7 I4 X45.#define ENABLE_XONXOFF        ////切换为串行通信发送流软件流控制。9 s2 I; I& }" n! n: p7 Q
46.#define ENABLE_SOFTWARE_DEBOUNCE //一个简单的软件消除抖动特性硬限位开关。
. ~" i4 r: R) L) p9 E47.#define HARD_LIMIT_FORCE_STATE_CHECK        //Grbl检查硬限位开关的状态
) ^! W: z8 z) K. q! L, G  y48.// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:编译时错误检查的定义值:" V' b4 s" |6 W" I- v% G0 k
- }1 U5 g9 s, i* s6 m5 H
___________________________________________________________________________________________________
% z) I( O8 Q2 r! X3 g- o! r/*
! R  k- _3 G& Z% w7 |; E  config.h - compile time configuration- `- z0 L2 N: j# {2 e4 e2 p
  Part of Grbl5 z1 ~. n* k4 f) k0 v+ ~8 N

+ [3 D6 p( r$ V4 Z0 p  s  Copyright (c) 2012-2015 Sungeun K. Jeon8 |! W( `; I, C0 g
  Copyright (c) 2009-2011 Simen Svale Skogsrud
3 M9 }% e9 v. u
* o/ D4 P" ^7 \  q  Grbl is free software: you can redistribute it and/or modify
+ q7 r3 m  Z' Y, B% w/ z! A  it under the terms of the GNU General Public License as published by
$ v& o+ n( G% T! E. I  the Free Software Foundation, either version 3 of the License, or
, v! {0 ^2 d2 D3 j3 O  (at your option) any later version.! c; `& N& B2 ~

. _+ r, ]) i, ?$ C+ r0 C  Grbl is distributed in the hope that it will be useful,9 l; |0 B7 l% r
  but WITHOUT ANY WARRANTY; without even the implied warranty of* h( I- V1 Z6 g" E, q
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the+ ]: E& q! T& G) o3 s7 H
  GNU General Public License for more details.
+ z: L8 @/ o( b! ^/ p& D( |* v& f9 d' q$ q
  You should have received a copy of the GNU General Public License
4 _; Z* J% T& M; e, D  along with Grbl.  If not, see <http://www.gnu.org/licenses/>.
+ Z4 }/ F8 R- W# ]' A- aconfig.h  -编译时配置,Grbl的一部分
$ A7 b( k; e% I0 [! o2 z- U# F
7 p2 N& {  @: t6 ~9 `" Z+ \& i# m# G版权(c)2012 - 2015 Sungeun K. Jeon8 |# t+ Q; T5 q; G4 Q
版权(c)2009 - 2011 Simen Svale Skogsrud1 q( b) A; ?+ Z7 f

- ?9 _% ]& ]+ ~7 v+ X  C5 c7 gGrbl是免费软件:可以重新分配和/或修改
6 M$ @0 j, ]' i$ M2 z0 fGNU通用公共许可证的条款下发布的自由软件基金会,版本3的许可,或(任您选)其后的版本。6 M/ J$ s! l% @- a+ C4 c: d

- _! y" m0 X' f+ ?/ n) iGrbl分布,希望这将是有用的,但是没有任何保证;没有即使的默示保证适销性或健身为特定目的。看到
  c! A+ P. B, {# r( i' UGNU通用公共许可证的更多细节。; l. g3 ^/ i% [# u; w8 c, a, W0 t
$ R/ p2 E1 ^# R
你应该收到了GNU通用公共许可证的副本3 R0 m; ]: o: _0 K; s
连同Grbl。如果没有,看< http://www.gnu.org/licenses/ >。2 ]9 T' T6 n# U' C% r
( y& U3 \$ J) x; g2 Q/ O5 s0 h7 Q
*/
( ^" e) H' X  o1 v% ^: V+ C# S  8 E  O5 _) x: O( V
// This file contains compile-time configurations for Grbl's internal system. For the most part,
* s/ z6 y* n0 A) l% y// users will not need to directly modify these, but they are here for specific needs, i.e.
1 ~5 ~( M) s. m& I5 j( A6 `// performance tuning or adjusting to non-typical machines.
! O- [9 w* J  h8 Z//这个文件包含编译时配置Grbl的内部系统。在大多数情况下,1 H3 @7 f/ f8 j! d5 f. y- [" ?
//用户不需要直接修改这些,但是他们在这里为特定的需求,即。
- k+ M% Y: }5 s: k: k. F//性能调优或适应非典型的机器。; |8 c- ^: U# I: I$ R5 P1 o  c

, [5 g: x) x  q7 [. s// IMPORTANT: Any changes here requires a full re-compiling of the source code to propagate them.
) {5 o0 ?# s) O; v) ]//重要:任何变化需要一个完整的基于源代码的传播。+ f8 W& y+ g4 y: L
( T2 h. m0 Q1 O! g: M5 L# F8 V
#ifndef config_h7 v- W& x2 u6 N& Y: g
#define config_h
% ^9 ]4 `0 K" K0 [" Y#include "grbl.h" // For Arduino IDE compatibility., \6 S1 N+ x0 W8 P7 b8 c- ?
$ Q0 z  e/ h9 z& ]
// Default settings. Used when resetting EEPROM. Change to desired name in defaults.h
% p7 }' M& j7 d7 _* Y// 默认设置。在重置eepm时使用。在defaults.h改变想要的名字
7 C" o% u  p5 e7 A/ n9 \
7 S7 V4 D* ]; s3 N; A- X#define DEFAULTS_GENERIC
& U5 R% j' H. C7 q9 C/ D& R5 ]2 M0 o: \! d' W& L# p8 [: _
// Serial baud rate% }5 X1 Q. V. H
#define BAUD_RATE 115200                //配置串口波特率115200! Y* X# u: z4 k# |) R0 @* ^
$ z) h' Z  ~7 `
// Default cpu mappings. Grbl officially supports the Arduino Uno only. Other processor types
, d" ]; m7 G/ r: Q% \2 ^// may exist from user-supplied templates or directly user-defined in cpu_map.h9 }) l" Y6 g" K7 ^" h- L* o
//默认cpu映射。Grbl正式支持Arduino Uno。其他类型的处理器可能存在cpu_map.h直接从用户提供的模板或用户定义的
" U% C, d& c& e* F+ U2 B1 b# q; ]% m& G9 o& |& x
#define CPU_MAP_ATMEGA328P // Arduino Uno CPU9 L4 y2 ?8 Z& ^" m/ K

; \- E% z6 s' K7 H// Define realtime command special characters. These characters are 'picked-off' directly from the1 @- t9 v  q: E) ?* ^
// serial read data stream and are not passed to the grbl line execution parser. Select characters; d# ~9 t) B( J  q
// that do not and must not exist in the streamed g-code program. ASCII control characters may be
  a: N' K+ `4 E) D// used, if they are available per user setup. Also, extended ASCII codes (>127), which are never in 7 g& W1 H$ a: D) r; D8 }
// g-code programs, maybe selected for interface programs.4 h& g( \/ f4 t; P
// NOTE: If changed, manually update help message in report.c.
4 U1 v7 _% E3 j8 m3 Q# c( ^8 Q1 ^/ W1 U. W. U. Y
//定义实时命令特殊字符。这些字符是直接从“各个击破”串口读取数据流并没有传递到grbl行执行解析器。选择角色% @5 y/ x: l. G9 b" @3 G* E. d
//不,不能存在于程序流刀位点。ASCII控制字符
$ {7 `6 S) t' Y  D//使用,如果他们是可用的每个用户设置。同时,扩展的ASCII码(> 127),从来没有. E. [2 r) F% B4 I+ P! N
//刀位点的程序,也许选择界面程序。% }7 P* G/ N( k& V4 D2 r& A
//注意:如果改变,手动更新report.c帮助信息。! W% `  X6 p. y$ D2 h( I

, Y* r' t2 Q- U" F" U. G#define CMD_STATUS_REPORT '?'
0 x) K  a% ^- k" I  y) d#define CMD_FEED_HOLD '!'7 ~9 }1 Y5 x. b6 c
#define CMD_CYCLE_START '~'/ Z( M+ w% `9 J
#define CMD_RESET 0x18 // ctrl-x.$ k) U  ]1 t1 c5 e4 v
#define CMD_SAFETY_DOOR '@'
* U8 \* ^: S7 H! e8 j* |+ w; q
8 p- o. u* ^7 Z+ o$ R4 [// If homing is enabled, homing init lock sets Grbl into an alarm state upon power up. This forces
* w8 Z2 ^% q- Y3 V( L* R( w// the user to perform the homing cycle (or override the locks) before doing anything else. This is2 g4 W# I' j' Y0 {
// mainly a safety feature to remind the user to home, since position is unknown to Grbl." _( h4 U  _. t4 r4 L9 w' e; F% `5 g. \
, u0 _: \, s" T5 P, h% G; c
//如果启用了回原点,导航初始化锁集Grbl进入警报状态启动。这就迫使
7 U1 l9 o9 E/ X0 _. G, n//用户执行归航周期(或覆盖锁)在做任何其他事情之前。这是
2 v2 a1 D7 f5 v0 C) P- |% c//主要安全功能,提醒用户家里,因为Grbl位置是未知的。, d  Z: _( i" d" e" h0 X5 Q- K

7 p' s8 E$ D" n7 _/ |. U  j#define HOMING_INIT_LOCK // Comment to disable
* n7 p: h9 y, o0 d2 x, i( `+ T, f7 Y0 {' p" m2 k# I
// Define the homing cycle patterns with bitmasks. The homing cycle first performs a search mode" Y5 q/ F# l; H1 V( a0 |- e: b4 ]1 ~
// to quickly engage the limit switches, followed by a slower locate mode, and finished by a short& M3 e2 E* @8 _; H9 p
// pull-off motion to disengage the limit switches. The following HOMING_CYCLE_x defines are executed * Z& I) p* ^. {
// in order starting with suffix 0 and completes the homing routine for the specified-axes only. If
0 b# x5 f. `. |9 {/ Y// an axis is omitted from the defines, it will not home, nor will the system update its position.
' Y$ H5 x8 R7 t// Meaning that this allows for users with non-standard cartesian machines, such as a lathe (x then z,1 {. p( O$ S5 y' y8 X  E1 E: |
// with no y), to configure the homing cycle behavior to their needs.
! i2 ~+ k! Z( W! _8 D" y// NOTE: The homing cycle is designed to allow sharing of limit pins, if the axes are not in the same3 ?  f! {8 m' x2 l' d8 a: l. e
// cycle, but this requires some pin settings changes in cpu_map.h file. For example, the default homing1 y( _# Q0 k8 A; H4 m
// cycle can share the Z limit pin with either X or Y limit pins, since they are on different cycles.8 Y0 M  b  |1 u# q4 V4 }/ f0 W6 {4 W
// By sharing a pin, this frees up a precious IO pin for other purposes. In theory, all axes limit pins
- P9 _# Y* l7 t6 p3 a// may be reduced to one pin, if all axes are homed with seperate cycles, or vice versa, all three axes, r# \, q- m2 `' g  W+ D. f0 L8 J
// on separate pin, but homed in one cycle. Also, it should be noted that the function of hard limits
' A2 K% G! R- j0 z( K. P9 R- i# q// will not be affected by pin sharing., |% ~1 o8 S2 B+ G7 x/ u. W+ \
//定义导航循环模式的位掩码。归航周期首先执行一个搜索模式
9 A# H7 `1 r/ z7 W9 ^& O//快速进行限位开关,其次是较慢的定位模式,完成了由一个短6 {7 w7 w8 t: s
//拖出运动脱离限位开关。以下HOMING_CYCLE_x定义执行7 s4 k7 Y2 H2 T9 P
//为了与后缀0开始并完成specified-axes只寻的例程。如果
' T/ L9 v8 p3 m8 O2 u  _/ t//定义省略一个轴,它会不在家,也不会系统更新它的位置。" S1 g' @+ n3 ]1 j! A! c* s: W* Y
//意义,这允许用户与非标准笛卡尔的机器,比如车床(x,z,
, s& y6 g9 h! K' W$ l) t" P; o- l) I+ Z//没有y),配置导航循环行为对他们的需求。# P  |8 w, Z/ c- Z/ `
//注意:归航周期允许共享限制针,如果轴不相同1 b! |  M, \1 d, U( I
//循环,但这需要一些销设置cpu_map的变化。h文件。例如,默认的导航
# [8 U/ \  X6 |9 x: q//循环可以分享Z限位销X或Y限制针,因为它们是在不同的周期。
+ u: V9 T' f  B/ U3 u( c* k//通过共享一个销,这腾出宝贵的IO销用于其他目的。从理论上讲,所有轴限制别针& X, n& s' @  v5 p) x  X
//可能会减少到一个销,如果所有轴与分离周期居住的地方,反之亦然,所有三个轴
7 D/ L7 b% q( L1 N9 Z% s//在不同销,但这时候一个周期。同时,应该注意的是,硬限制的功能
4 N( s# @0 G4 C) p  J//将不会影响销共享。% T/ w; ~0 {4 u/ x: G+ D
//注意:默认设置为一个传统的硬件数控机器。z轴首次明确,其次是X和Y。8 C' l$ v8 k' a  W, w

3 ?& b2 v$ }; l9 _' ?* r// NOTE: Defaults are set for a traditional 3-axis CNC machine. Z-axis first to clear, followed by X & Y.5 Q; w3 [% i' u
#define HOMING_CYCLE_0 (1<<Z_AXIS)                // REQUIRED: First move Z to clear workspace. 第一步Z清除工作区。
9 ^% k, T8 G8 X#define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // OPTIONAL: Then move X,Y at the same time.然后X,Y在同一时间。
! w! ?2 g' j0 }9 N# n9 s// #define HOMING_CYCLE_2                         // OPTIONAL: Uncomment and add axes mask to enable
6 C5 H9 D* `4 ^: t- @% n1 j! |: }
% T8 u) M/ w' w/ b, `$ w// Number of homing cycles performed after when the machine initially jogs to limit switches.* y8 O1 d9 p1 B, o- W3 H  E; f1 S
// This help in preventing overshoot and should improve repeatability. This value should be one or
$ h/ x! Y- @" D( z! G// greater.
3 W" d: s+ Y4 b! J$ {//执行回原点循环次数后,当机器最初慢跑限位开关。这个帮助防止过度,应该提高重复性。这个值应该是一个或大。
. f# b$ L6 q* m. |) \, o
3 @! W+ y( @3 q( `3 j# j#define N_HOMING_LOCATE_CYCLE 1 // Integer (1-128)
; u* ]8 O$ z* }' R9 J; i7 w% `$ P: W& d/ A6 y, A
// After homing, Grbl will set by default the entire machine space into negative space, as is typical0 ~8 q+ b, _' o, d3 k
// for professional CNC machines, regardless of where the limit switches are located. Uncomment this
/ i7 D% _  [$ i" G4 b! K! e2 M// define to force Grbl to always set the machine origin at the homed location despite switch orientation.
! Z* H- x; L2 S! A- n6 d! C( i7 z2 k) `& e4 r+ h
//导航后,默认Grbl将整个机器空间留白,是典型的专业数控机器,不管限位开关所在的地方。" \) s8 X- c( z* @
//取消这定义迫使Grbl总是在这时候位置设置机器原点尽管开关方向。
. O! j& z% I1 Y; ?" H& ?# `' |' u# C( _' q
// #define HOMING_FORCE_SET_ORIGIN // Uncomment to enable.$ w! g* P/ T/ E2 V) W9 }5 C% r' X

3 D- `, r3 B! D
- ^& E1 Q; ]9 n// Number of blocks Grbl executes upon startup. These blocks are stored in EEPROM, where the size
$ L) ]9 O# o& a- s" @// and addresses are defined in settings.h. With the current settings, up to 2 startup blocks may
  Q0 ^# A6 G% R' G8 T. t8 {! ^3 `// be stored and executed in order. These startup blocks would typically be used to set the g-code
+ c1 v( i& j7 n. R# K// parser state depending on user preferences.
2 B. \3 k- U: F& R! r7 s0 T
, Z4 |- q' d+ j0 l3 r- p7 o! ]//块Grbl启动时执行的数量。这些块存储在eepm,大小
' o& }  b( W1 N$ {2 g0 o$ _//和地址在settings.h中定义。与当前设置,可能2启动块
9 X. C$ k4 ?9 Q3 V$ [. T6 n- n//存储和执行。这些启动块通常被用来设置刀位点
4 @4 g6 a4 d9 V7 S//解析器的状态取决于用户首选项。
$ x" l3 F8 C0 O. @# M6 u7 }5 B! ?, X$ X2 I5 R
#define N_STARTUP_LINE 2 // Integer (1-2)
; \: v. @% o1 I- u0 g
) U. K2 H3 u$ _6 D7 K: Y// Number of floating decimal points printed by Grbl for certain value types. These settings are & D/ T1 d; K1 r9 j5 ?) z  {; ~* o
// determined by realistic and commonly observed values in CNC machines. For example, position
  J# i: _/ n& D/ B2 N1 P4 P4 c// values cannot be less than 0.001mm or 0.0001in, because machines can not be physically more
; q" f/ O* b! c+ Z4 I4 R5 K// precise this. So, there is likely no need to change these, but you can if you need to here.* [6 S( w; F& K. T2 w3 V- m
// NOTE: Must be an integer value from 0 to ~4. More than 4 may exhibit round-off errors.7 ]& n+ I5 O% Z) s+ M* w
  W1 _; L! J0 X0 X3 c% T
// Grbl浮动小数点的数字印刷的特定的值类型。这些设置是- ]+ H! b9 d) p
//一般由现实和观测值在数控机器。例如,位置
( h( t8 x6 E7 z. G! K//值不能小于0.001毫米或0.0001,因为机器不能身体更多
8 o7 E8 F* ^0 l4 }0 E. N5 J//精确。因此,有可能不需要改变这些,但你可以在这里如果你需要。9 s$ T8 N* b6 q4 U! B# a
//注意:必须是一个整数值从0 ~ 4。超过4可能出现舍入错误。. o* s8 e$ L! w& E
' @1 M* M% e: }+ F, B
#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 协调或位置价值英寸
. ]0 F5 G$ U2 w#define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 协调在毫米或位置价值" L) E0 B  A. w/ m
#define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分钟的速度值
7 ^2 j) j' B8 W* [5 k# `% s( Z# P#define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分钟/ {( {2 Z! k1 W' V2 H0 ]! U" {# }
#define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 对浮点小数设置值3 H  b6 s+ E. V' D) j) A0 f

' a/ c8 b( K9 X; H* H0 J6 o7 p// If your machine has two limits switches wired in parallel to one axis, you will need to enable
, H6 `, Q& {3 v3 I& R0 @// this feature. Since the two switches are sharing a single pin, there is no way for Grbl to tell  c' o$ S1 S9 o6 U/ L
// which one is enabled. This option only effects homing, where if a limit is engaged, Grbl will
# N4 A" K0 H0 t% }! K8 T// alarm out and force the user to manually disengage the limit switch. Otherwise, if you have one. U& D3 W4 c, r' Y
// limit switch for each axis, don't enable this option. By keeping it disabled, you can perform a8 ?' `5 S, I4 j2 p6 O6 m( Q0 M
// homing cycle while on the limit switch and not have to move the machine off of it.7 c9 o& \& w8 m! O; W
4 K, J8 r4 `4 Q( a9 Z: s; W$ K
//如果你的机器有两个极限开关连接在平行于一个轴,您需要启用
( Q. k2 F- B4 A) N: z6 B//这个特性。自从两个交换机共享一个销,没有办法Grbl告诉
) \" y: [% h8 c0 q//启用哪一个。此选项仅影响归航,如果限制,Grbl意志3 g- l2 k7 G0 {( p6 U9 m+ }
//报警,迫使用户手动松开限位开关。否则,如果你有一个5 q; Y6 p& S; L' x8 N* J
//为每个轴限位开关,不启用该选项。通过保持禁用,您可以执行
) Z. G+ v* g/ c0 w  }% A/ X//导航循环在限位开关并没有将这台机器。7 G, I0 Y% V. {9 U$ m6 H

1 z- F' S9 `, S0 ^# ^" v// #define LIMITS_TWO_SWITCHES_ON_AXES! q$ ]* w+ ]2 d7 H  d& X+ s+ u

' F2 Z! ]; @; ?( {// Allows GRBL to track and report gcode line numbers.  Enabling this means that the planning buffer
, D2 e0 j- U% o! H/ q// goes from 18 or 16 to make room for the additional line number data in the plan_block_t struct% E. j" h6 C; h$ `2 `9 n5 n

7 o* ^% N; f+ P8 p//允许GRBL跟踪和报告gcode行号。使这意味着计划缓冲从18岁或16岁,为额外的行号plan_block_t结构中的数据
& H$ x: ?0 s+ e9 S! U8 V5 {
  n0 L- C& L  X9 N  d// #define USE_LINE_NUMBERS // Disabled by default. Uncomment to enable.
! l( H+ B. V# h' g' i8 v7 O9 R
, v8 F, V4 _* F' S5 P// Allows GRBL to report the real-time feed rate.  Enabling this means that GRBL will be reporting more
0 @! [  v: M' u" _; @// data with each status update.5 v4 I  U8 R; ^% m
// NOTE: This is experimental and doesn't quite work 100%. Maybe fixed or refactored later.
$ D/ L% g1 L* O% a3 N- }//允许GRBL报告实时进给速率。使这意味着GRBL将报告数据和状态更新。) E) {0 H/ z2 ]' q* d9 t
//注意:这是实验和100%没有工作。也许以后固定或重构。# }$ ?+ A) L% A: ]/ D- ^& y
* i) F. s1 T1 w% k+ @
// #define REPORT_REALTIME_RATE // Disabled by default. Uncomment to enable.  ?) g) `+ m4 @6 O" Z# e, X) O
! M& z3 I4 ?& \, a9 E) r
// Upon a successful probe cycle, this option provides immediately feedback of the probe coordinates
. ?& v8 I# k7 G3 j# t! Y// through an automatically generated message. If disabled, users can still access the last probe8 G/ J# R. a  R  K% Z, J0 E
// coordinates through Grbl '$#' print parameters.9 ^/ a$ q/ f  v; j
//在一个成功的调查周期,这个选项提供立即反馈的探测器坐标
9 E0 \5 w" D8 ^. O6 U! g//通过一个自动生成的消息。如果禁用,用户仍然能够访问调查+ X4 G4 O; z2 d2 [
//坐标通过Grbl $ #的打印参数。
4 `" F/ \  m8 z) ?7 y. u
$ F) m; @! {8 G#define MESSAGE_PROBE_COORDINATES // Enabled by default. Comment to disable.
3 R- I3 A: L3 Y
5 p9 I5 w, h2 C& O- P4 x// Enables a second coolant control pin via the mist coolant g-code command M7 on the Arduino Uno
  w0 b3 v- I' c# D7 B9 V// analog pin 5. Only use this option if you require a second coolant control pin.& _0 g4 \) {! z) V
// NOTE: The M8 flood coolant control pin on analog pin 4 will still be functional regardless.# v" q4 r9 o6 i9 d4 n2 N& B
// #define ENABLE_M7 // Disabled by default. Uncomment to enable.
  k0 V" s: |# ]/ |5 A3 S3 b+ U$ e0 X+ K, U
// This option causes the feed hold input to act as a safety door switch. A safety door, when triggered,
. y6 v# w* G6 b! j8 U1 ]// immediately forces a feed hold and then safely de-energizes the machine. Resuming is blocked until8 h: x8 F" N( R8 a. r
// the safety door is re-engaged. When it is, Grbl will re-energize the machine and then resume on the
0 a' q7 B: j" ]+ ]// previous tool path, as if nothing happened.& k! ]* g+ o+ s, P* y
// #define ENABLE_SAFETY_DOOR_INPUT_PIN // Default disabled. Uncomment to enable.: ^# }8 z/ s, a- R; V- H/ G- p

- q3 r6 a  t, `) z// After the safety door switch has been toggled and restored, this setting sets the power-up delay$ }" |/ Z- C) b, k
// between restoring the spindle and coolant and resuming the cycle.
, V* L! c  T+ A; f2 y# \% q; h// NOTE: Delay value is defined in milliseconds from zero to 65,535. $ a  ^: o% u) J- l3 [& ~

7 F1 v4 m, |" d. g5 o//定义导航循环模式的位掩码。归航周期首先执行一个搜索模式
% _' {( w' ^0 q  |% V: ]//快速进行限位开关,其次是较慢的定位模式,完成了由一个短3 ?3 @- _/ c5 z* @1 H3 C, l- N3 ^
//拖出运动脱离限位开关。以下HOMING_CYCLE_x定义执行7 U0 k/ a7 i* N1 y# D/ O% Z
//为了与后缀0开始并完成specified-axes只寻的例程。如果
: Q$ m8 }: @) G. W8 b/ E4 |: _5 J. h//定义省略一个轴,它会不在家,也不会系统更新它的位置。
8 n' n6 w5 b/ o9 M9 m//意义,这允许用户与非标准笛卡尔的机器,比如车床(x,z,5 ^. h' g3 t& s1 T
//没有y),配置导航循环行为对他们的需求。
2 `* @' u( r9 W: U$ s4 m* b- o//注意:归航周期允许共享限制针,如果轴不相同
6 |- O& i2 Z: Z5 D8 W# D9 C//循环,但这需要一些销设置cpu_map的变化。h文件。例如,默认的导航
- d7 V- j% k: s& c% P//循环可以分享Z限位销X或Y限制针,因为它们是在不同的周期。! m. @. [, S- o% \8 h9 E* X
//通过共享一个销,这腾出宝贵的IO销用于其他目的。从理论上讲,所有轴限制别针
/ v) h: ^% T* `* O) ~( ^  X//可能会减少到一个销,如果所有轴与分离周期居住的地方,反之亦然,所有三个轴
  ^0 u# ^" n3 F2 z//在不同销,但这时候一个周期。同时,应该注意的是,硬限制的功能
; Q6 {+ Y* M1 Y; M//将不会影响销共享。
8 K2 w7 @! ]# K1 _5 v//注意:默认设置为一个传统的硬件数控机器。z轴首次明确,其次是X和Y。
+ i) r4 O' `9 D7 ~4 q
' c. ~; J- e( ?0 Y' L  e: Y! A! N5 q+ l% D* \5 d5 k
#define SAFETY_DOOR_SPINDLE_DELAY 4000* e+ b1 N. f& F6 q
#define SAFETY_DOOR_COOLANT_DELAY 1000
: ?$ C: ?2 _' G' z/ d, Q5 R* r9 ?0 s% z7 ]3 F+ o
// Enable CoreXY kinematics. Use ONLY with CoreXY machines.
' i* V( L# p; h9 m) J: e// IMPORTANT: If homing is enabled, you must reconfigure the homing cycle #defines above to   e! t  G0 [" j9 G3 U5 U" R# ^
//启用CoreXY运动学。只使用与CoreXY机器。8 x( Z: _  a4 i% @1 `' o3 H3 G* B
//重要:如果启用了自动寻的,你必须重新配置导航循环#定义上面9 l- u2 m  W  S
7 O, o+ B& f* y% n
// #define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS)9 v3 c: |5 V& O; G

6 U% [  o; c4 u8 o1 S// NOTE: This configuration option alters the motion of the X and Y axes to principle of operation
7 I1 X! H* r4 I& J9 `9 p// defined at (http://corexy.com/theory.html). Motors are assumed to positioned and wired exactly as
2 \0 \* w2 i. [- k( e// described, if not, motions may move in strange directions. Grbl assumes the CoreXY A and B motors
8 K0 @+ t* a* z& d, C  k# @/ Y// have the same steps per mm internally.5 j, f$ B  \( @/ H! R9 @; F
//注意:这种配置选项改变X和Y轴的运动原理,操作
/ e- x4 o1 i9 u1 O/ w" G//定义(http://corexy.com/theory.html)。汽车被认为定位和连接一样
: y) @$ |3 v+ m4 \* j5 v3 n1 T" e//描述,如果没有,运动可能会奇怪的方向移动。A和B Grbl假设CoreXY马达
" s2 b, p5 h/ g# Z0 V$ n! ~//每毫米内部有相同的步骤。) a- m' Z8 F2 B+ ~! j

1 u, `4 D/ F9 S// #define COREXY // Default disabled. Uncomment to enable.
; a9 n$ u" q& ]6 L# j' S& }4 d/ a
// Inverts pin logic of the control command pins. This essentially means when this option is enabled
6 P; h" \6 f+ _0 e2 w// you can use normally-closed switches, rather than the default normally-open switches.
& B# P; o2 y; J. i// NOTE: Will eventually be added to Grbl settings in v1.0.
! M+ @: a. j% e" U0 c: b//反转针销逻辑的控制命令。这实质上意味着当启用这个选项! b0 D7 J6 j- M1 h4 x) j7 E
//可以使用闭合开关,而不是默认的常开开关。: \* M# X4 I1 k- I4 U! z+ u4 B
//注意:最终将被添加到在v1.0 Grbl设置。  Z* @" S2 V" g! B6 p" `6 t4 X
& w/ ~; r2 p1 E1 o! J0 l
// #define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.
) r( s" i3 f$ h  D; \
  l1 c3 f3 V* N; V// Inverts the spindle enable pin from low-disabled/high-enabled to low-enabled/high-disabled. Useful
. a4 T1 Z  z# N: e- w7 E// for some pre-built electronic boards.! U) j, \& D, s# a& G# G! P
// NOTE: If VARIABLE_SPINDLE is enabled(default), this option has no effect as the PWM output and
6 H+ z) R, B! A+ q// spindle enable are combined to one pin. If you need both this option and spindle speed PWM, 9 Q& ]" l1 o# s8 I0 {
// uncomment the config option USE_SPINDLE_DIR_AS_ENABLE_PIN below.$ o3 }% g) p$ }" D: |9 i* C$ ?6 l
//反转主轴使销从low-disabled / high-enabled low-enabled / high-disabled。有用的
3 l: N- i  w" e) H3 b7 F) \//预构建的电子板。4 m) t: r  N0 c) K# o+ u4 k7 S
//注意:如果启用了VARIABLE_SPINDLE(默认),这个选项作为PWM输出并没有影响5 @$ f9 r. s$ e. ^7 E5 t/ J
//销轴使结合。如果你需要这个选项和主轴转速PWM,
# D& D; E* n0 b9 ^+ j; C//取消注释以下配置选项USE_SPINDLE_DIR_AS_ENABLE_PIN& A; T0 ]6 q$ U; c8 Z3 {

+ H, i1 G* C7 k! S; T* }( N6 J// #define INVERT_SPINDLE_ENABLE_PIN // Default disabled. Uncomment to enable.- ~; O/ l5 n- ]. ?( h. |1 J8 X
! T2 h7 w* m9 ]( x" }' u
// Enable control pin states feedback in status reports. The data is presented as simple binary of
. x/ I4 m1 Y6 U* T. v8 f3 E# O- w// the control pin port (0 (low) or 1(high)), masked to show only the input pins. Non-control pins on the % c: f5 @+ S8 w9 C
// port will always show a 0 value. See cpu_map.h for the pin bitmap. As with the limit pin reporting,' D- Y" B( R  M: l1 G) ~
// we do not recommend keeping this option enabled. Try to only use this for setting up a new CNC.
& F4 b( ^1 _! _! J" P% o//启用控制销状态反馈状态报告。作为简单的二进制数据1 I. E  ]; t+ h0 K
//控制针端口(0(低)或1(高)),蒙面,只显示输入插脚。非控制性针上
, R+ p7 N1 y! Q+ f0 D* q//端口总是显示0值。看到cpu_map。针位图h。与限制销报告,
& m, {; m/ ]/ \% P4 N! f; d//我们不推荐保持启用这个选项。尽量只使用这个设置一个新的数控。
  V6 p3 m1 Y& S+ V4 J% S, D3 ^$ J& |1 }5 j
// #define REPORT_CONTROL_PIN_STATE // Default disabled. Uncomment to enable.
8 n. G( f0 T) l" J
" J8 x1 y  F: h/ ~: `3 V// When Grbl powers-cycles or is hard reset with the Arduino reset button, Grbl boots up with no ALARM
3 ]+ a" p7 J) ?+ \9 g3 W// by default. This is to make it as simple as possible for new users to start using Grbl. When homing' J/ C; A5 W; I6 q$ m/ U: u
// is enabled and a user has installed limit switches, Grbl will boot up in an ALARM state to indicate
+ o5 j% K/ j9 h3 x// Grbl doesn't know its position and to force the user to home before proceeding. This option forces) _# _, G, d! s  o3 o
// Grbl to always initialize into an ALARM state regardless of homing or not. This option is more for) ]' f, n) x  W, Y' q2 `
// OEMs and LinuxCNC users that would like this power-cycle behavior.5 K1 y, h% B3 j) k* y
//当Grbl powers-cycles还是硬重置Arduino复位按钮,Grbl启动没有报警/ M2 f3 O+ h. _6 _" i) W
//默认情况下。这是为了让新用户尽可能简单使用Grbl开始。当归航; g' b5 E  t! n0 d
//启用和用户安装限位开关,Grbl将启动报警状态指示
2 v9 A- L* l$ S5 X  E+ P// Grbl不知道它的位置,迫使用户在继续之前回家。这个选项部队
$ r) V% f$ o9 h6 H4 K& d+ |4 _// Grbl总是初始化进入警报状态不管归航。这个选项是更多; b$ ^1 \5 r# @' p
//原始设备制造商和LinuxCNC用户这样的控制行为。2 j' ~. S1 _- G& ]

. A. S, \% g1 u# j. n& z// #define FORCE_INITIALIZATION_ALARM // Default disabled. Uncomment to enable.+ c& m1 a. _; n2 t2 t" O
8 V+ O  k5 }" j/ D
// ---------------------------------------------------------------------------------------0 v0 E1 M3 z+ U  S; s
// ADVANCED CONFIGURATION OPTIONS://高级配置选项:& I5 p' O4 p' K# ~

- ^, B  I4 s9 f// Enables minimal reporting feedback mode for GUIs, where human-readable strings are not as important.$ P: C" g( e* m0 P/ K
// This saves nearly 2KB of flash space and may allow enough space to install other/future features.) S+ B6 p+ T+ z8 r
// GUIs will need to install a look-up table for the error-codes that Grbl sends back in their place.0 m" w1 G7 ^4 ~- N7 Y, m  S
// NOTE: This feature is new and experimental. Make sure the GUI you are using supports this mode.2 p, g8 O# ^$ I
3 p7 G1 Q1 @1 z% @% h
// gui允许最小的报告反馈模式,人类可读的字符串在哪里不重要。
5 e8 r4 `7 A# q//这个节省近2 kb的闪存空间,允许足够的空间来安装其他/未来的功能。
  V" N) V1 @; C" n- Q. l; K, v0 X// gui需要安装一个查找表的错误代码Grbl发回。
! }" G" A* |) O* p+ m//注意:此功能是新的和实验。确保您使用的GUI支持这种模式。" `& j8 c7 ~* F9 H+ d7 P# J0 o
6 x! a% {& @- {- J( c2 O+ C* ~
// #define REPORT_GUI_MODE // Default disabled. Uncomment to enable.
/ v0 E& E; q) X# d- I, t. J! C1 d
6 q  z  {/ ?/ \% \" q2 h/ }// The temporal resolution of the acceleration management subsystem. A higher number gives smoother* R; D. y. Q/ S3 n& `8 p' D  M
// acceleration, particularly noticeable on machines that run at very high feedrates, but may negatively5 `8 q4 i& A7 e1 Z" b
// impact performance. The correct value for this parameter is machine dependent, so it's advised to
9 }" f8 O$ j: X% l6 ]5 D! [// set this only as high as needed. Approximate successful values can widely range from 50 to 200 or more.6 i/ V" B" U/ N! H- t, T+ v% ?
// NOTE: Changing this value also changes the execution time of a segment in the step segment buffer.
1 ^( A5 a" {: k/ O* W9 O// When increasing this value, this stores less overall time in the segment buffer and vice versa. Make" |! R4 F4 m* s# X" _
// certain the step segment buffer is increased/decreased to account for these changes.
1 G( P4 }+ _+ S4 G//加速度的时间分辨率管理子系统。更多更平稳
8 L9 j* _  @$ c2 ]) P6 [. z//加速度,特别明显的机器上,运行在非常高的进料速度,但可能负面
4 r( {/ ~9 D" f5 k/ T6 Z//影响性能。正确的值为这个参数是依赖于机器的,所以建议
; T& P" \: Q. F. y//这只设置为高。近似成功的价值观可以广泛的范围从50到200或者更多。
3 N9 l! k. J" O  C, E: X//注意:改变这个值也变化的部分步骤的执行时间缓冲。
! _$ X4 \" C% C+ P) z, O//增加这个值时,这个商店部分缓冲区的总时间减少,反之亦然。使
; ?4 l; l* V. z+ m4 E0 b/ a  M//特定步骤段缓冲是考虑这些变化增加/减少。
; i4 {" G& ^4 U# u/ F6 n6 `0 R; x% R  k. }8 _  n
#define ACCELERATION_TICKS_PER_SECOND 100  //加速度的时间分辨率管理子系统。更多更平稳* e; z! K7 B) w8 P/ Z
0 a" b& p  q/ S) v1 p+ J
// Adaptive Multi-Axis Step Smoothing (AMASS) is an advanced feature that does what its name implies,
5 E8 ]# N4 _. _! l$ [// smoothing the stepping of multi-axis motions. This feature smooths motion particularly at low step: L1 d- A1 ~* d" q9 R% n
// frequencies below 10kHz, where the aliasing between axes of multi-axis motions can cause audible
. j2 a1 P& e- o! Q// noise and shake your machine. At even lower step frequencies, AMASS adapts and provides even better
8 u( a' @8 V% M' I: w# m// step smoothing. See stepper.c for more details on the AMASS system works.
6 b6 h7 D# H' x! N6 h( ]& K/ j, t//自适应多轴步平滑(积累)是一种先进的功能,它的名字所暗示的那样," v  V$ ]4 y# X  ]
//平滑的多轴步进运动。这个特性平滑运动尤其是在低一步7 u( V. j& |- v5 h$ c5 @! f0 p
//频率低于10 khz,轴之间的混叠的多轴运动可能导致音响# Z( K: J, f! B6 j
//噪音和震动你的机器。在更低的频率步,积累适应并提供更好
/ ~2 p9 b- r9 @1 Q//步骤平滑。看到步进。c更多细节的积累系统的工作原理。
" {, ^: \2 {/ C" O1 y& e
5 t+ C5 x* h. u, }! }/ P#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING  // Default enabled. Comment to disable.//自适应多轴步平滑& |! T' A* l' M- {- _$ c

6 u: G9 B$ y+ l3 b3 ~7 J// Sets the maximum step rate allowed to be written as a Grbl setting. This option enables an error 4 }4 W6 _+ I, J# K$ A6 R9 Z$ M+ S
// check in the settings module to prevent settings values that will exceed this limitation. The maximum
0 f. ?4 ]) `: Z- }4 v// step rate is strictly limited by the CPU speed and will change if something other than an AVR running$ E$ F% k3 A' B1 b, j
// at 16MHz is used.
( k2 h  H( r/ F8 D# h// NOTE: For now disabled, will enable if flash space permits.
& }0 M8 f3 {4 C* c4 T0 f7 v) q/ |//设置最大一步速率可以写成Grbl设置。这个选项可以使一个错误
+ p8 n! l: C  x, @/ }, l/ m//设置模块中检查,防止设置值将超过这个限制。的最大
3 s' n. u- }1 x$ b3 {$ B; |2 n//步骤严格限制的CPU速度也会改变如果是其他AVR运行" q8 t  i# `6 l/ d: P7 f  x  S: K: W
//使用16兆赫。% i3 p' c) j( B& Z. g6 X
//注意:现在残疾,将使如果flash空间许可。, X1 Y+ K1 H( f# `/ B
( z" K- _/ \# R$ r  m4 A& c+ J
// #define MAX_STEP_RATE_HZ 30000 // Hz 设置最大一步速率
! ?' [, M8 M0 m2 G
9 X8 y: A+ z+ n( [4 I// By default, Grbl sets all input pins to normal-high operation with their internal pull-up resistors" _$ ]- h. k0 {4 E8 r1 Q1 r) ^
// enabled. This simplifies the wiring for users by requiring only a switch connected to ground,
, u; u. O7 ^' E9 `// although its recommended that users take the extra step of wiring in low-pass filter to reduce
$ [. m( ?$ c# |' d// electrical noise detected by the pin. If the user inverts the pin in Grbl settings, this just flips
( C# u* r1 @1 x+ D" o1 v// which high or low reading indicates an active signal. In normal operation, this means the user ) ^. y4 i- s1 s+ Z1 z; O5 ]
// needs to connect a normal-open switch, but if inverted, this means the user should connect a
, O6 `' \% e& c4 n- _% {& ^" J! ^6 e// normal-closed switch.
7 e$ p, z& R2 ~& O( Z3 J// The following options disable the internal pull-up resistors, sets the pins to a normal-low 4 L7 y; J+ B( `3 b
// operation, and switches must be now connect to Vcc instead of ground. This also flips the meaning - x. }: P3 M( U5 l+ i
// of the invert pin Grbl setting, where an inverted setting now means the user should connect a * _$ A& D5 V. d  a& \# f6 z5 r
// normal-open switch and vice versa.3 A7 d8 @4 n& g7 `9 v
// NOTE: All pins associated with the feature are disabled, i.e. XYZ limit pins, not individual axes.
: r+ K5 k9 {* }8 ?" K% k// WARNING: When the pull-ups are disabled, this requires additional wiring with pull-down resistors!' N2 H% W8 r7 T
//默认情况下,Grbl所有输入引脚设置为正常高操作的内部上拉电阻  g0 P2 m5 M7 B& A2 m
//启用。这简化了布线为用户只需要一个开关连接到地面,+ F5 c% u' {0 J7 B
//虽然其建议用户采取额外的步骤,在低通滤波器来减少布线# R# O' b$ X" T2 r9 |% L5 p4 G
//电噪音检测销。如果用户反转的销Grbl设置,这只是翻转
- T$ Z' t/ V$ d) {/ l//读高或低表明一个积极的信号。在正常操作中,这意味着用户7 F8 t% q" I. \" i
//需要连接一个常开开关,但如果倒,这意味着用户应该连接
9 G, d; V8 H) N* Z8 ]0 a% M( w! a. J// normal-closed开关。, i0 N  L9 `& a; [8 b) K" `
//以下选项禁用内部上拉电阻,一般低设置别针" z% m: d  [; s* M0 [* A
//操作,现在开关必须连接到Vcc代替地面。这也掀的意思
' i% M' x1 \: T1 @  ]2 l/ U) y% D- M//反销Grbl设置,一个倒置的设置现在意味着用户应该连接
& e$ F, Y2 V2 G; R4 N: [//常开开关,反之亦然。
- y2 C6 o7 J4 q//注意:所有针与功能被禁用,例如XYZ限制针,而不是单独的轴。1 }7 _2 z, g' S  H6 `% N; ]
//警告:引体向上被禁用时,这需要额外的布线与下拉电阻!* I, K9 R) ^0 H" ?' [8 t
3 Z, ~, j4 R3 E) B; u
//#define DISABLE_LIMIT_PIN_PULL_UP //以下选项禁用内部上拉电阻
1 M, Y" n/ ^3 ?- Z  \//#define DISABLE_PROBE_PIN_PULL_UP
: m3 J  t, I% W) o& ~" j9 B1 t8 a//#define DISABLE_CONTROL_PIN_PULL_UP
) ^7 j% Z- A. {! i4 F# q  u1 D, x8 R/ c9 ]0 f7 f. |  r# x+ R
// Sets which axis the tool length offset is applied. Assumes the spindle is always parallel with
& F/ ?7 w8 G8 V: g& v// the selected axis with the tool oriented toward the negative direction. In other words, a positive
/ K$ f; G5 |+ e7 i// tool length offset value is subtracted from the current location./ A9 ^8 p4 ?/ X. J* c9 O
//设置哪个轴长度补偿应用的工具。假设轴总是与
; p$ m8 W& r7 _//选择轴工具面向负方向。换句话说,一个积极的' y4 p" C5 ~: s
//工具长度偏移值减去从当前位置。5 V+ m/ h; g5 Z: ^

7 Z# I" O* |7 ]! R6 M% y+ H#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS // Default z-axis. Valid values are X_AXIS, Y_AXIS, or Z_AXIS.设置哪个轴长度补偿应用的工具, I6 g9 e) ?6 P
: D0 }" e/ ]9 m
// Enables variable spindle output voltage for different RPM values. On the Arduino Uno, the spindle
* v+ `9 k9 U3 }6 t3 w4 `# ^5 h! B% P// enable pin will output 5V for maximum RPM with 256 intermediate levels and 0V when disabled.
* S5 K2 q" r9 b% j% H// NOTE: IMPORTANT for Arduino Unos! When enabled, the Z-limit pin D11 and spindle enable pin D12 switch!+ e% H9 o$ ?" s4 ^/ @
// The hardware PWM output on pin D11 is required for variable spindle output voltages.
; z; U6 R0 X0 G# J//允许变量轴输出电压不同的转速值。Arduino Uno,主轴
- q7 w0 J' q& J9 D, Z! A//启用销将输出5 v的最高转速256中级水平和0 v时禁用。
) a8 m' E# c* O//注意:重要Arduino凯泽本人!当启用时,Z-limit销这里和轴销D12开关!
+ H' S2 M1 ^- G: E' B0 ?//硬件PWM输出销这里需要变量轴输出电压。
/ p/ W1 B1 A/ M: S7 J, p- S+ N8 K4 L) E
! p  N! q+ a& i" z+ T  k#define VARIABLE_SPINDLE // Default enabled. Comment to disable.//允许主轴输出电压不同的转速值. n' |: v$ Y1 N9 N
& @8 N0 h" z5 ]: w1 v
// Used by the variable spindle output only. These parameters set the maximum and minimum spindle speed% q% d! }% q& g/ l6 _
// "S" g-code values to correspond to the maximum and minimum pin voltages. There are 256 discrete and & k  S' i" @# T- B% t& t
// equally divided voltage bins between the maximum and minimum spindle speeds. So for a 5V pin, 10008 q6 c/ h% B9 h- S
// max rpm, and 250 min rpm, the spindle output voltage would be set for the following "S" commands: , P8 L6 \3 v& E
// "S1000" @ 5V, "S250" @ 0.02V, and "S625" @ 2.5V (mid-range). The pin outputs 0V when disabled.
2 e; A( o+ I/ d/ p1 F1 D//使用的变量轴输出。这些参数设置最大和最小轴转速' _" v$ E5 s/ u1 v7 x
//“S”刀位点值对应于销电压的最大值和最小值。有256个离散和
& a  V6 P5 o4 J9 ]' P//电压平均分配箱主轴速度的最大值和最小值之间。所以对于一个5 v销,1000
3 A4 M+ D: I% n// max rpm,250分钟rpm,主轴输出电压将为以下“S”命令:+ I  j' ^9 R0 ?2 \! W
// @“S1000 5 v,“S250”@ 0.02 v,“S625”@ 2.5 v(中档)。销输出0 v时禁用。4 s& E, P5 `& {) Q. }9 F

, _7 `5 a- Z( z# \. f" n#define SPINDLE_MAX_RPM 1000.0 // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.
* a5 O* ?$ \; u( |3 s* x0 S8 ?" F#define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.
+ M5 Q; I* ~2 a
* X" p! w& J6 e# h// Used by variable spindle output only. This forces the PWM output to a minimum duty cycle when enabled.# B* r+ n1 {% S+ g3 H4 x3 W# p
// When disabled, the PWM pin will still read 0V. Most users will not need this option, but it may be / M) i$ E, t2 |% ^3 w
// useful in certain scenarios. This setting does not update the minimum spindle RPM calculations. Any
4 Z: I% o1 R- h1 E% h/ A7 L# i  Z// spindle RPM output lower than this value will be set to this value.1 L  v8 `2 p+ }2 B  b
//使用的变量轴输出。这迫使PWM输出最小占空比时启用。
4 G% z* {% W( G* C8 B# p//当禁用,PWM销仍读0 v。大多数用户不需要这个选项,但是它可能是/ |8 f" {/ \' t2 m4 }# ~
//在某些情况下很有用。这个设置不会更新最小主轴转速计算。任何
  G& L. ?" C$ J9 Q. o1 }//输出轴转速低于这个值将被设置为这个值。
/ F. L: u; s; u$ C' l4 q3 O% w3 T) O( O
// #define MINIMUM_SPINDLE_PWM 5 // Default disabled. Uncomment to enable. Integer (0-255)) q% X  r1 U+ ~8 L2 r
! K) C; p: A; {/ F
// By default on a 328p(Uno), Grbl combines the variable spindle PWM and the enable into one pin to help 7 m. Q/ }* D& z( i* r/ k
// preserve I/O pins. For certain setups, these may need to be separate pins. This configure option uses
2 n7 @1 G+ u2 X% e// the spindle direction pin(D13) as a separate spindle enable pin along with spindle speed PWM on pin D11.
# w0 b7 E  K, G+ W) u6 @// NOTE: This configure option only works with VARIABLE_SPINDLE enabled and a 328p processor (Uno). # P% d+ l2 }! d' o( X
// NOTE: With no direction pin, the spindle clockwise M4 g-code command will be removed. M3 and M5 still work.
  V4 ~; p+ [" s3 {4 |7 N* M// NOTE: BEWARE! The Arduino bootloader toggles the D13 pin when it powers up. If you flash Grbl with
! u* j8 d8 D0 R; {: S// a programmer (you can use a spare Arduino as "Arduino as ISP". Search the web on how to wire this.),
" T4 l  U/ Q0 D// this D13 LED toggling should go away. We haven't tested this though. Please report how it goes!4 d$ K# }  U1 _! {1 i0 w
//默认ATmega328 p(Uno),Grbl结合变量轴PWM和使到一个销的帮助
7 p+ z1 A: V, m6 N+ B  o//保存I / O管脚。对于某些设置,这些可能需要单独的别针。这个配置选项使用
2 [8 m% \4 p! G: i//方向轴销(D13)作为一个单独的轴销上启用销以及主轴转速PWM这里。3 a7 e) ~, r# `. s; e8 {1 i# _
//注意:该配置选项仅适用于VARIABLE_SPINDLE启用和328 p处理器(Uno)。
' T; p- A5 \' p' X+ x//注意:没有方向销,主轴顺时针M4刀位点命令将被删除。M3和M5仍然工作。
% ~7 a* r/ w) p//注意:小心!Arduino引导装载程序切换D13销的权力。如果flash Grbl
5 O" S: Q+ y7 U3 \# F- M' |//程序员(您可以使用一个备用Arduino“Arduino ISP”。搜索网络如何线),
; i( V, j* X9 j' ^5 m//这D13导致切换应该消失。我们还没有测试这个。请报告将会怎样!5 T0 w9 P" y$ ^2 _0 ?
3 ?. z! q7 T+ T
// #define USE_SPINDLE_DIR_AS_ENABLE_PIN // Default disabled. Uncomment to enable.
, J* W; ~( L% e/ g1 X  {. M2 L$ n0 z$ G& s' ~
// With this enabled, Grbl sends back an echo of the line it has received, which has been pre-parsed (spaces4 W1 V5 m* ~  T# y5 b
// removed, capitalized letters, no comments) and is to be immediately executed by Grbl. Echoes will not be / j* s- t0 H6 [7 l# }
// sent upon a line buffer overflow, but should for all normal lines sent to Grbl. For example, if a user
' |3 n6 W+ @; {( Z// sendss the line 'g1 x1.032 y2.45 (test comment)', Grbl will echo back in the form '[echo: G1X1.032Y2.45]'.
, w5 M  z" v) E; L// NOTE: Only use this for debugging purposes!! When echoing, this takes up valuable resources and can effect0 ^. H, A( q. P  V5 {$ K* C) [& H
// performance. If absolutely needed for normal operation, the serial write buffer should be greatly increased  z/ }( S1 C: T$ @
// to help minimize transmission waiting within the serial write protocol.
) B0 \' ?- e* K4 |+ D8 X  J6 D# |+ X3 ?7 f- X: j
//启用,Grbl发回的回声线已收到,已预编译(空间
- z" w& e' j) c  ?//移除,大写字母,没有评论),由Grbl立即执行。回声将不会
" ]* u( N6 H! k" @+ P- @5 [//发送一个线缓冲区溢位,但应该对所有正常线路送到Grbl。例如,如果一个用户
7 b% ~7 P5 z2 w4 S0 z//发送线的g1 x1.032 y2.45(测试评论)形式”,Grbl将回声”(回声:G1X1.032Y2.45]”。' S" H. Y  @) u. E
//注意:只使用这个调试! !当呼应,这占用了宝贵的资源,可以影响
, l  s+ a: X5 \, L9 A& t//性能。如果正常运行所需的绝对,串行写入缓冲器应该大大增加
3 _/ r/ m+ J0 _- d' a) P//帮助最小化传输等系列内写协议。
6 F0 J- J: `( Q
$ t8 Y3 q- ?4 Z1 m; j  Z// #define REPORT_ECHO_LINE_RECEIVED // Default disabled. Uncomment to enable.% C  C# ~2 {; S! x  F5 t

, ^& d4 O) L6 z, @% }7 Q. S// Minimum planner junction speed. Sets the default minimum junction speed the planner plans to at1 i. w" S, _& [( @( g" n7 t" q
// every buffer block junction, except for starting from rest and end of the buffer, which are always' I# h& Q; P7 f* c3 ]  ?+ x6 |
// zero. This value controls how fast the machine moves through junctions with no regard for acceleration" A' y6 X5 i0 i
// limits or angle between neighboring block line move directions. This is useful for machines that can't' G$ r& _& c8 S3 B; P( y
// tolerate the tool dwelling for a split second, i.e. 3d printers or laser cutters. If used, this value7 H2 ^4 M, U, L6 b
// should not be much greater than zero or to the minimum value necessary for the machine to work.
; u+ v/ n6 h* i7 {8 L7 g' C* J: |2 {4 x/ O' ^/ w
//最小规划师结速度。设置默认最小连接速度规划计划
( p7 |4 P; j/ h0 W2 D8 ~% m6 o  M//每一个缓冲块接头,除了从结束休息和缓冲区,它总是
  P- ~9 \# K- R! s  ]// 0。这个值控制机器的速度穿过路口,没有考虑加速度- X0 W* D. `3 ~1 T- B8 V" [  u
//限制或相邻块之间的角线方向移动。这是有用的机器,不能
- N# o! W+ u  j& h$ k//容忍工具居住某一刹那,即3 d打印机或激光切割机。如果使用这个值% _. ?9 d, T& j# |# Y* q, A
//不应大于零或机器工作所需的最小值。
1 b4 {8 ?/ J2 M; _. ^5 o2 t5 _, w% R3 n# b1 ]) k$ M' \* s
#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min)
( {: e* N2 H4 s# L
9 A, c0 c& n- _( F# q// Sets the minimum feed rate the planner will allow. Any value below it will be set to this minimum% A! F' W$ B- ]- ^
// value. This also ensures that a planned motion always completes and accounts for any floating-point- Q& s* m8 y# ~9 @
// round-off errors. Although not recommended, a lower value than 1.0 mm/min will likely work in smaller
) y$ r4 U& L! |$ O// machines, perhaps to 0.1mm/min, but your success may vary based on multiple factors.
& [' p, l- Y( l3 B5 S8 f# z//设置计划将允许的最小进给速率。任何价值低于它将被设置为最低值。这也保证了运动计划总是完成,占任何浮点
3 i( K6 n: b; G+ R7 D  F6 w//舍入错误。虽然不推荐,价值低于1.0毫米/分钟可能会在较小的工作6 w0 e7 b7 [5 V3 N1 R
//机器,也许到0.1毫米/分钟,但你的成功基于多种因素可能会有所不同。* P5 n  M6 q) }$ w
9 c& X4 h$ F* l8 T. }0 a3 q
#define MINIMUM_FEED_RATE 1.0 // (mm/min)//设置计划将允许的最小进给速率+ L7 X% }' E' G/ [. Q: ^; Q

( N4 N2 Z, p# c; U9 c/ k) r) [; C// Number of arc generation iterations by small angle approximation before exact arc trajectory # K( J6 E/ W( s4 K' z$ E6 ~( W3 ?: m
// correction with expensive sin() and cos() calcualtions. This parameter maybe decreased if there
, z/ q. M1 Y( r# b: |// are issues with the accuracy of the arc generations, or increased if arc execution is getting; N, E; c5 w2 I! e
// bogged down by too many trig calculations. % Y8 R5 F  B# P! G! L1 D7 Y
//弧生成迭代次数之前小角度近似精确的弧线轨迹
3 ]& t$ A! x& ~  ]: @' C//修正与昂贵的sin()和cos()calcualtions。如果有这个参数可能减少
  a0 V3 j1 r  E# S. d& t4 Z7 [$ G0 x//与弧一代又一代的准确性问题,或如果电弧执行得到增加
2 A. k) J+ s9 r2 p, @//太多的三角计算的泥潭。/ s! L5 d6 B1 C9 \1 V# {& {

2 z% q$ j" a+ q; l- C#define N_ARC_CORRECTION 12 // Integer (1-255)4 `9 f" J$ g- g( z- E

3 `& F0 B& j. f# c) W- ]// The arc G2/3 g-code standard is problematic by definition. Radius-based arcs have horrible numerical 9 `# \, W- w# h* r
// errors when arc at semi-circles(pi) or full-circles(2*pi). Offset-based arcs are much more accurate
# T2 e, U8 C* p3 @1 x; |) w# y// but still have a problem when arcs are full-circles (2*pi). This define accounts for the floating
# `- B! d4 Y  x% Z, I" [// point issues when offset-based arcs are commanded as full circles, but get interpreted as extremely7 L$ [) e: _1 {1 }& ]
// small arcs with around machine epsilon (1.2e-7rad) due to numerical round-off and precision issues.
  q) _  ?4 |- ^, u! B9 L% t// This define value sets the machine epsilon cutoff to determine if the arc is a full-circle or not.
9 w7 j% n3 V5 _7 z* G// NOTE: Be very careful when adjusting this value. It should always be greater than 1.2e-7 but not too1 m5 J: L0 Y( R
// much greater than this. The default setting should capture most, if not all, full arc error situations./ K, C5 Q1 |2 K# [: f$ k
//弧G2/3刀位点的标准定义是有问题的。Radius-based弧有可怕的数值+ a6 P% o1 c- V8 u6 v
//错误当电弧在半圆(π)或原点(2 *π)。Offset-based弧更准确
  V. a: ~5 o+ g8 x$ s//但仍有一个问题当弧原点(2 *π)。这个定义占浮动2 C* T- a) j% U7 W8 h
//当offset-based弧吩咐点问题完整的圆,但解释为极
% s5 F+ v$ A* v/ v, Z. N//小弧机周围ε(1.2 e-7rad)由于数字舍入和精度问题。
% B+ U0 O& J$ d1 M8 y! h//定义值设置机器ε截止来确定电弧是一个原点了。
) X) j% U5 y7 ^4 g//注意:调整这个值时非常小心。它应该总是大于1.2 e -但不要太
) i3 o; g) A+ d1 l  k' \//比这大得多。默认设置应该捕获大部分,如果不是全部,全部错误的情况。/ ^! J, C7 S2 H5 x

8 k# z( e! I6 v) s2 y. U#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)
7 H0 g, x& G  U0 O  v
# @4 n' u1 |0 }! T# o// Time delay increments performed during a dwell. The default value is set at 50ms, which provides4 I+ H. W$ R6 f6 s7 }! {; H3 i7 D+ A
// a maximum time delay of roughly 55 minutes, more than enough for most any application. Increasing) ~  r+ }3 r4 O/ u
// this delay will increase the maximum dwell time linearly, but also reduces the responsiveness of
! S& I. D* w" M7 z3 H, |// run-time command executions, like status reports, since these are performed between each dwell ( o5 w0 \1 a! v5 D2 I: F9 T' w
// time step. Also, keep in mind that the Arduino delay timer is not very accurate for long delays.
2 V" k7 ~9 R# e" P* B% V//延时增加表现在住。默认值设置为50毫秒,它提供了
4 N1 P5 Y% M8 ^- u8 q4 _//最大延时约55分钟,足够对大多数任何应用程序。增加$ t- L& I$ w" p% A/ [8 [1 Q
//这种延迟将增加线性最大停留时间,也减少了响应能力
- w8 Y8 x+ W6 B0 e//运行命令执行状态报告一样,因为这些每个住之间执行4 A! n) y0 h$ p- ]4 h, v9 B4 I
//时间步。还有,记住,Arduino延迟计时器不是很准确的长时间延误。: z/ r- r% m1 J0 y# B; Z- n# \

+ z% g$ V4 I( k#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds)/ B& b2 h  \: \* D! Y
. ^  ?$ I, V" e! j4 E
// Creates a delay between the direction pin setting and corresponding step pulse by creating
: i& H2 _6 X# e  R9 b, U// another interrupt (Timer2 compare) to manage it. The main Grbl interrupt (Timer1 compare) * G$ b5 n9 ?* Z  t
// sets the direction pins, and does not immediately set the stepper pins, as it would in
  N8 R# Z5 w) W% J  I: \4 F// normal operation. The Timer2 compare fires next to set the stepper pins after the step 2 K* }: W. y4 ?: O% i
// pulse delay time, and Timer2 overflow will complete the step pulse, except now delayed
# P" L. t6 _: W1 n* [7 N; G. [// by the step pulse time plus the step pulse delay. (Thanks langwadt for the idea!)
2 T% m' m; Y" p1 c6 Z1 E// NOTE: Uncomment to enable. The recommended delay must be > 3us, and, when added with the
- x- D+ J$ v# Y; l// user-supplied step pulse time, the total time must not exceed 127us. Reported successful
4 S- ?. p  o; S% A2 C// values for certain setups have ranged from 5 to 20us.
" l/ q+ c2 m* S/ M- k, h8 D//创建一个方向销之间的延迟脉冲通过创建设置和相应的步骤: R% l' w" ]0 O' a
//另一个中断(Timer2比较)来管理它。主要Grbl中断(Timer1比较)3 ~8 |& `4 t4 \" X+ I6 V! }
//设置方向针,不立即设置步进针,因为它会在
  }6 }. C3 H! J% [. C; K2 T//正常操作。Timer2比较火旁边设置步进针后一步
0 {- z# @, A3 B, w0 b" O//脉冲延迟时间,Timer2溢出脉冲将完成的步骤,现在延迟除外1 A; w4 a  p9 U" }, A3 W
//脉冲时间加上的一步一步脉冲延迟。(感谢langwadt主意!)* J: c. a9 i( N3 q4 x+ M# t
//注意:取消启用。必须> 3,建议延迟,当添加的8 J  U$ }6 `/ h3 a* ~9 M# |
//用户提供的步骤脉冲时间,总时间不得超过127美元。成功的报道
7 e) J7 z  c  X  r% w  Z; M//值对某些设置范围从5到20。$ X. h* J& @0 M- s# s
0 c+ i! J. f* u4 i
// #define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled." T" h% |4 d( Y$ [/ c5 e6 `; O
9 n6 ~+ q' }% ]9 j3 O% ~' [
// The number of linear motions in the planner buffer to be planned at any give time. The vast
$ @) r$ d' d1 d// majority of RAM that Grbl uses is based on this buffer size. Only increase if there is extra ( [& C  U- G# y, ^! u6 K
// available RAM, like when re-compiling for a Mega or Sanguino. Or decrease if the Arduino
" C9 N2 ~/ K% c: c3 O4 Z2 k// begins to crash due to the lack of available RAM or if the CPU is having trouble keeping! L9 E. C( f. L5 T/ X2 P
// up with planning new incoming motions as they are executed.
9 f+ i4 v' c) d1 j  u//线性运动规划师缓冲区的数量在任何给出时间计划。绝大
, c9 m; _( u0 K//多数RAM Grbl使用基于这个缓冲区的大小。如果有额外的只会增加8 J& e  f0 l! D; E
//可用内存,比如当基于大型或Sanguino。如果Arduino或减少
. z: [9 f  n, r& F//开始崩溃由于缺乏可用的RAM或者CPU是难以保持5 o& _% N5 N. A$ h. h- K8 J
//与规划新传入的动作执行。
7 e8 K! F; \$ z. h: x8 r( c) g, I. A+ t. N) a# A
// #define BLOCK_BUFFER_SIZE 18  // Uncomment to override default in planner.h.8 I: s6 Q3 |* Q6 v
! O$ @( a; _0 J$ D
// Governs the size of the intermediary step segment buffer between the step execution algorithm
$ K1 p& Z% q3 e) K7 N// and the planner blocks. Each segment is set of steps executed at a constant velocity over a
5 w1 [- ?. x# {. u$ q// fixed time defined by ACCELERATION_TICKS_PER_SECOND. They are computed such that the planner
7 D. z1 [* l) m, w6 c' ?* l// block velocity profile is traced exactly. The size of this buffer governs how much step : @8 Q+ O6 s* n- D
// execution lead time there is for other Grbl processes have to compute and do their thing 9 l/ p. ~2 E4 S. q
// before having to come back and refill this buffer, currently at ~50msec of step moves.
1 ~! C3 U3 s5 @//控制之间的中间段缓冲大小的步骤执行算法
, [# r: O7 m5 @5 h" ]//和规划师块。每一部分的步骤执行在一个恒定的速度4 C" V6 G, g8 \4 F
//固定的时间由ACCELERATION_TICKS_PER_SECOND定义的。他们计算的计划$ T; i4 E4 N' O8 g* ]1 L* w6 H6 t
//块速度剖面追踪到底。这个缓冲区的大小控制多少步骤7 `: B1 X" G; i1 o
//执行时间有其他Grbl过程需要计算和做他们的事情
. E6 n/ \7 R; l& g7 i- E1 x; l//之前必须回来重新填充这个缓冲区,目前移动~ 50毫秒的一步。- M0 S/ C7 r  T: z- t

8 v6 H/ q. e" n# S( Z) N$ D// #define SEGMENT_BUFFER_SIZE 6 // Uncomment to override default in stepper.h.& X0 M6 M! y5 f" M( ?0 n+ Y

. V  {; z( j7 z* p; t// Line buffer size from the serial input stream to be executed. Also, governs the size of ! s- {' X3 y+ X# c# r( E
// each of the startup blocks, as they are each stored as a string of this size. Make sure* q4 S; E0 k1 f" ]
// to account for the available EEPROM at the defined memory address in settings.h and for9 o) W( @& o7 h* }& F) F
// the number of desired startup blocks.
# m7 y: ^3 k3 ^* n' @6 e// NOTE: 80 characters is not a problem except for extreme cases, but the line buffer size 4 n, V  v3 k) _; v
// can be too small and g-code blocks can get truncated. Officially, the g-code standards
1 x& C5 S$ Z/ P" \7 l2 B// support up to 256 characters. In future versions, this default will be increased, when 8 N  I" S$ y* ~9 X1 k+ j! A
// we know how much extra memory space we can re-invest into this.2 h/ E) i3 L# b; l
//行执行串行输入流的缓冲区大小。同时,大小的控制; r  F1 o2 j  Z
//每个启动模块,它们分别存储为字符串的大小。确保
$ @# p' W& h9 Q. ^/ \//占可用eepm定义内存地址的设置。h和
: z. C( f" X$ x* Y//需要启动块的数量。
9 E1 v' I9 `3 a! H8 C//注意:80个字符不是一个问题,除了极端的情况下,但线缓冲区大小! g; _- @' B8 n% h5 \, V
//可以太小和刀位点块可以截断。正式,刀位点标准4 _+ @5 i. f9 C' \1 r1 O- W
//支持多达256个字符。在未来的版本中,这个违约将会增加,当! z2 k- s& [- K9 Y
//我们知道多少额外内存空间的时候我们可以再投资。; p  w2 X+ u0 z! B/ x) g( Q
: N& T3 W1 B4 _7 X; ]4 {
// #define LINE_BUFFER_SIZE 80  // Uncomment to override default in protocol.h# j+ [5 g3 D# b
  
# z9 _5 R1 A  ]+ l8 j+ }3 P// Serial send and receive buffer size. The receive buffer is often used as another streaming: H+ e' g. Y1 [+ W- y3 ?
// buffer to store incoming blocks to be processed by Grbl when its ready. Most streaming
0 k7 W' a/ Z: q" E// interfaces will character count and track each block send to each block response. So, ; y+ b; t/ T; y
// increase the receive buffer if a deeper receive buffer is needed for streaming and avaiable
. A0 O3 [0 D$ w3 g) q' a// memory allows. The send buffer primarily handles messages in Grbl. Only increase if large& j: K: m; s3 x( H: w
// messages are sent and Grbl begins to stall, waiting to send the rest of the message.
" J, M; [) a  \# |( H2 O% h// NOTE: Buffer size values must be greater than zero and less than 256./ o2 Z, X% P1 i& h
// #define RX_BUFFER_SIZE 128 // Uncomment to override defaults in serial.h
1 V2 G$ [, F4 F4 @: e/ B* n' [- l1 P% c//串行发送和接收缓冲区大小。接收缓冲区通常用作另一个流
# i7 X/ M' c! @9 D//缓冲存储传入的块来处理Grbl当它准备好了。最流
- l2 |/ C7 m! r* m- F3 a+ T1 S9 ]//接口将字符计数和跟踪每一块发送给每个块的回应。所以,5 U; V# ]8 B. R5 _9 i0 Y
//增加接收缓冲区如果需要更深层次的接收缓冲区为流,、& X0 [0 e" a+ ^* W0 j1 `! W
//内存允许。Grbl发送缓冲主要处理消息。只会增加如果大
& z- O; c5 x) K. L$ w# r/ I//消息发送和Grbl开始停滞,等待发送其余的消息。
1 E; \! s# k" V% T; k//注意:缓冲区大小值必须大于零,小于256。, g8 f1 n# a1 w% M) o" e
// # define RX_BUFFER_SIZE 128 / /取消serial.h覆盖默认值9 ^- b9 C- Y0 }  n& u( `
  D% I, O3 _& [7 x* s7 J: Q
/ ?4 b1 u- x9 O+ V# L
// #define TX_BUFFER_SIZE 647 U; T. N* t4 a
  - h4 w5 G1 V  m
// Toggles XON/XOFF software flow control for serial communications. Not officially supported
+ ]$ J, Y) x0 \// due to problems involving the Atmega8U2 USB-to-serial chips on current Arduinos. The firmware3 p( `# u& x1 ~) c
// on these chips do not support XON/XOFF flow control characters and the intermediate buffer - D0 W- G6 d" s( n: a0 g5 o# M2 i4 F
// in the chips cause latency and overflow problems with standard terminal programs. However,
9 k. T  c0 ^* \, M// using specifically-programmed UI's to manage this latency problem has been confirmed to work.* N/ K* p7 V: w9 h! i
// As well as, older FTDI FT232RL-based Arduinos(Duemilanove) are known to work with standard  a) v3 t- a; x; h3 V
// terminal programs since their firmware correctly manage these XON/XOFF characters. In any* ?) _: t1 t; ^4 T2 ]& J, |
// case, please report any successes to grbl administrators!) D2 a1 X. `- m: T
//切换为串行通信发送朴通/发送葡开软件流控制。不是官方支持% d, }4 v& g% o5 ~( o* `. _$ q
//由于问题涉及Atmega8U2 USB-to-serial当前arduino芯片。固件
+ f7 j+ b6 w, H0 E//在这些芯片不支持发送朴通/发送葡开流控制字符和中间缓冲区- y$ C4 \, t4 j8 s
//芯片导致延迟和溢出问题的标准终端程序。然而,
; T3 \7 Y8 p# B7 R//使用specifically-programmed UI的管理这个延迟问题已经确认工作。3 U; G) J7 x) d5 k7 l; X: X
//以及老FTDI FT232RL-based arduino(Duemilanove)是已知的标准- ]" |* [5 [1 \& K, j
//终端程序因为他们正确的固件管理这些发送朴通/发送葡开的角色。在任何- L6 \- F. L/ I) c
//情况,请报告任何成功grbl管理员!
) v* w/ S) B5 X% u4 B; r% _8 R3 U% J/ l
// #define ENABLE_XONXOFF // Default disabled. Uncomment to enable.5 z$ \( n6 j* t1 \+ z4 l9 }4 u
9 y9 |4 Q9 u2 V  Z3 H
// A simple software debouncing feature for hard limit switches. When enabled, the interrupt
3 ~7 l9 M1 ~0 k, K% r" Z/ z4 v// monitoring the hard limit switch pins will enable the Arduino's watchdog timer to re-check
; W) b; a  {: b( O9 @+ r; q// the limit pin state after a delay of about 32msec. This can help with CNC machines with
' [8 ~6 j4 `' `9 }. d/ `# s// problematic false triggering of their hard limit switches, but it WILL NOT fix issues with . m+ Z7 D  f6 ?4 T1 }2 t
// electrical interference on the signal cables from external sources. It's recommended to first
: @# E  `% {$ W) G; V; H$ b// use shielded signal cables with their shielding connected to ground (old USB/computer cables
( R0 ~4 C4 }2 }  d4 `// work well and are cheap to find) and wire in a low-pass circuit into each limit pin.
1 P* H% |" d% U6 p* S6 @4 o//一个简单的软件消除抖动特性硬限位开关。当启用时,中断
4 G; p# Z9 A3 H' o//监控硬限位开关针将使Arduino的看门狗定时器重新审视
$ o( c- v$ T# J$ C//销的极限状态后约32毫秒的延迟。这可以帮助与数控机器
+ D4 `- u. O2 F  u# {, H. u//问题错误引发的硬限位开关,但是它不会解决问题
; h* C, R! |: [9 U//电干扰信号电缆从外部来源。首先它的建议
0 B* N; I* h) X4 _* y//使用屏蔽信号电缆的屏蔽连接到地面(老USB /计算机电缆
) q7 k$ f  H, E8 F& p. G//工作得很好,很便宜)和线低通电路到每个限位销。, h8 z% K3 T2 p$ Q" U4 Z
  ?8 x7 q6 R+ ?7 V1 {. Z
// #define ENABLE_SOFTWARE_DEBOUNCE // Default disabled. Uncomment to enable.8 u' i2 {4 b, l: E( m
4 B2 U6 ?$ i  x! T5 D5 G8 R  [
// Force Grbl to check the state of the hard limit switches when the processor detects a pin
  {" b; V8 E# ?/ V// change inside the hard limit ISR routine. By default, Grbl will trigger the hard limits* ]: Y1 m2 B& q& c/ `* G7 M
// alarm upon any pin change, since bouncing switches can cause a state check like this to 3 G: Q" q6 d& R7 w# s% j
// misread the pin. When hard limits are triggered, they should be 100% reliable, which is the3 n6 q( f) J( _) K9 a/ t3 O
// reason that this option is disabled by default. Only if your system/electronics can guarantee
9 D3 I& O: K; Y( R+ `8 S, T// that the switches don't bounce, we recommend enabling this option. This will help prevent
+ o  H  c, P2 o- f! k3 _" A// triggering a hard limit when the machine disengages from the switch.
, p' g! `, a2 v  X5 }// NOTE: This option has no effect if SOFTWARE_DEBOUNCE is enabled.) F0 y4 U# u! f, e
//力Grbl检查硬限位开关的状态,当处理器检测到一个销
. f& E+ r6 ?4 x0 q; c1 ~, C//改变内部硬限制ISR例行公事。默认情况下,Grbl将触发硬限制3 b  _( Y: @+ r: {
//报警在任何销更改,因为跳开关可以导致这样的状态检查' z+ Y$ U% ~8 ?/ z) u5 W0 P, R9 X
//误读了销。硬限制触发时,他们应该100%可靠,这是& n' F; v2 P2 t- V( B
//原因,这个选项默认是禁用的。只有在你的系统/电子产品可以保证
# P6 d! n* A" B( v' N//开关不反弹,我们建议启用这个选项。这将有助于防止
; E! h- }/ B" B1 i% ^$ W, z//触发机退出时硬限制开关。/ X% M$ J$ d$ H0 `( T& B; z
//注意:这个选项如果启用了SOFTWARE_DEBOUNCE没有影响。
* L1 T/ ?* q6 c6 J- O
; g. s3 V) N5 M0 T4 }! ^: _1 }/ ]// #define HARD_LIMIT_FORCE_STATE_CHECK // Default disabled. Uncomment to enable.0 t1 {' y" d; _0 @

3 ~& l9 x* B2 |4 K% ~: \/ S/ ~& t1 f. |/ A
// ---------------------------------------------------------------------------------------
+ }1 [% l% u- B- T9 V* u+ o// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:编译时错误检查的定义值:6 M! z* Y1 j; K0 B  N
0 D) o5 ?# R  Y: X* W2 L
#ifndef HOMING_CYCLE_0
; K& ~5 }, c) q3 R* v5 Y) i) ~! D  #error "Required HOMING_CYCLE_0 not defined."
8 m3 r+ n* U5 M$ W1 e5 a  o6 D#endif8 e; p' @& {8 m

% O, z# X0 E7 b" \4 d1 }8 J* u$ {, A#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(VARIABLE_SPINDLE)
( C( w% o) F6 n$ i$ L5 S' v- t  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with VARIABLE_SPINDLE enabled"
% ?2 P& r$ U; w! K6 [) o, c  c#endif
- H7 ?. d, |& A+ m0 H' B0 L7 w
& E# _5 H3 A, @) P5 x#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(CPU_MAP_ATMEGA328P)% M2 H9 c1 }+ y/ H% s; n- d" q4 u
  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with a 328p processor"
& Z3 a; v; E/ B+ S4 F#endif# [% r1 Y$ Q8 a6 n3 J  i+ B( Z0 i

, u! I+ t+ a! ~' }; J/ _  t3 m// ---------------------------------------------------------------------------------------( p/ i4 P2 L& Y$ ~& i7 l
% i" l) D( }$ v- M/ p. v5 ^
& h. ?( e! ^% _, j9 p  t% C
#endif  t# v! A/ f$ p" K' C' m. N
* [1 s  I0 x* w

  n6 ^/ n7 f& ?" u  F3 s% a9 t& Q9 R, l* G! e' ]
, }  T7 l+ }9 ]9 A% M8 d, C! W
8 e- \! V9 F& J! E$ o# ]# l
, _* ~5 ]6 x& a

' p5 Z# \- N  I" \" j, e1 Z/ ~( {8 g; W3 W' p

2 K* s& i: x$ I  f
4 Z' j9 s* T) Z- `( p9 W; v
; b% o$ Z4 Y: y* [/ `4 g- u( C5 t5 p& e/ R; T& e! d, }
9 \" l7 p) [# W. w# v, n
1 Z* f+ Q' W0 W2 J, v
. N+ t' X% G/ T: f4 S* y" F* T

8 N, ^7 Z$ Y* L+ I1 C4 l

本帖子中包含更多资源

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

x

评分

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

查看全部评分

回复

使用道具 举报

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

使用道具 举报

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

* Q) s, |# T' V' ?9 E; x
回复 支持 反对

使用道具 举报

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 | 只看该作者
补充
' J8 l% V3 B/ I/ U- _( f$ \程序运行protocol_execute_realtime(); /运行实时命令。6 Z7 K1 {3 b% Q0 i
// Executes run-time commands, when required. This is called from various check points in the main) p" ]  m, A' F
// program, primarily where there may be a while loop waiting for a buffer to clear space or any, n$ F, J# o5 |
// point where the execution time from the last check point may be more than a fraction of a second.
- R& X+ N9 W- \- P! i! t// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code
; {& V/ \9 j5 E3 y4 J  r// parsing and planning functions. This function also serves as an interface for the interrupts to
% V0 U0 b% O  K/ L// set the system realtime flags, where only the main program handles them, removing the need to
: s9 U, }8 v5 o8 Q) a  i6 |3 K// define more computationally-expensive volatile variables. This also provides a controlled way to - m% s1 y# z+ U7 T1 y. J
// execute certain tasks without having two or more instances of the same task, such as the planner
0 i2 j/ Q& T8 x" q9 y; [- @3 c// recalculating the buffer upon a feedhold or override.
+ ]6 G) S- _$ @7 s4 H// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,
: ~5 \# R5 ?3 ?4 V6 Y( |- g// limit switches, or the main program." g& b" K/ x) c) `+ F! Q
3 F9 v3 ]- r) z7 r; ]
//执行运行时间命令,在需要时。这就是所谓的从各种主程序要检查站
& u+ G# B6 x- Y6 ~//,主要是那里可能是一个while循环等待缓冲区空间或任何7 R3 |: B9 z. b
//执行时间从过去的止点可以超过几分之一秒。
5 M5 P! C' L( `//这是一种异步执行实时命令(又名多任务)grbl的刀位点+ I, e3 U$ _+ c+ x4 ]6 @
//解析和规划功能。这个函数也可以作为一个接口,用于中断) ]/ D; u: m( ^2 E( m
//设置系统实时的旗帜,只有主程序处理,消除的需要
7 q* k, G# [: j" c' v4 M//定义更多的计算昂贵volatile变量。这也提供了一种控制方法
( A1 n8 [2 w7 i//执行某些任务不相同的两个或多个实例的任务,比如计划
5 J! i& x- k, ^3 R//重新计算缓冲feedhold或覆盖。4 ?* p0 E8 }2 @5 T
//注意:sys_rt_exec_state变量标志设置任何过程,步骤或串行中断,插脚引线,* [% a) U0 W/ t9 Y5 v
//限位开关或主程序。5 T5 D) k& q7 s2 o. z; i6 n$ @& S9 g% @
void protocol_execute_realtime()+ A) |  a  F+ M8 l6 k: T$ D7 l
{# t' G) f) Q$ \9 }: C( H- E
        // Temp variable to avoid calling volatile multiple times.
& p  W6 T1 Y& g* y        // 临时变量来避免多次调用不稳定。
+ _$ \* P  i- I- T% q5 A7 K. R        uint8_t rt_exec; ' z$ D; P1 Z& @$ e
        do{
2 m+ j7 A6 L6 E0 M          if (rt_exec) {                 // 有标志位置位进入* p7 f, s! W4 f& d# _) w; V/ M
        5 Z8 E- [6 w$ {' \( t% }$ ~. ?
            sys.state = STATE_ALARM; // 设置系统为报警状态) y4 }+ a. j, f9 w6 g5 z; i( k* n
      report_alarm_message(ALARM_HARD_LIMIT_ERROR);        //报告报警信息为接近极限值5 R: z, P; f$ ?( c6 b
    } else if (rt_exec & EXEC_ALARM_SOFT_LIMIT) {                        //报告执行软件限位报警
: L$ d0 Q: [" N      report_alarm_message(ALARM_SOFT_LIMIT_ERROR);        //报告出现软件限位报警, Z% n4 P+ _) P/ O* {
    } else if (rt_exec & EXEC_ALARM_ABORT_CYCLE) {                //执行停止循环报警      
1 Q9 x, t9 W+ I: E( s      report_alarm_message(ALARM_ABORT_CYCLE);                //出现终止循环报警
- z8 s6 w0 e+ ~* z8 r    } else if (rt_exec & EXEC_ALARM_PROBE_FAIL) {                        //执行探查失败报警
" W. G$ t. O. _; E/ f" N" v      report_alarm_message(ALARM_PROBE_FAIL);                        //出现探查失败报警( k' _% x2 W, p( |! T. @. l
    } else if (rt_exec & EXEC_ALARM_HOMING_FAIL) {                //执行返回原点失败报警5 m! ]5 V1 c; ^  O0 e' {
      report_alarm_message(ALARM_HOMING_FAIL);                //出现返回原点失败报警! e% d/ u: \: ^& q. t
    }9 H  g( z* ^, R6 k% L
6 ?; \0 u6 R3 K# y! f4 G, g
    // Halt everything upon a critical event flag. Currently hard and soft limits flag this.
; {( l3 L6 V# h, W7 {3 {, o    // 停止一切在一个关键事件标志。目前硬和软限制标志
) R7 n4 z! g& I' _. [           if (rt_exec & EXEC_CRITICAL_EVENT) {                //如果系统是循环事件进入5 }" K  {6 ~  e, v
             report_feedback_message(MESSAGE_CRITICAL_EVENT);        //报告反馈信息
) Z$ Z3 ?- j, e0 c              bit_false_atomic(sys_rt_exec_state,EXEC_RESET);                         //清除目前的复位状态
2 p9 p2 p* f- A+ I. Z3 y' e! W8 D$ I* C8 s9 O# b
        bit_false_atomic(sys_rt_exec_alarm,0xFF);                                 // 清除所有报警标志
) N8 K1 ^  f9 O! o        }       
) H# s3 k: J9 W( h  _# K* B. T' `, p4 E( j
上面代码将rt_exec = sys_rt_exec_alarm ,如果rt_exec为真,打印不同报警信息& N. q& r" O* _
和限位保护信息,然后清除报警状态
: D; N. R4 G! `___________________________________________________________________________
  s- T/ R3 d) U. d" X* M/ n6 M1 T没有报警进行执行下面代码,执行了终止命令,串口打印命令
) x, T8 E( ^6 a         // Check amd execute realtime commands        校验和执行实时命令2 I1 b) M% \8 l* T' a- u. y
          rt_exec = sys_rt_exec_state; // Copy volatile sys_rt_exec_state
4 I9 E. N8 N: _" c' Q  C% p' n( ?
        if (rt_exec) { // 输入标志是正确的执行1 T+ n( V0 `; s6 C9 z% h
( e: C5 x7 g& \) Q
            // Execute system abort. 执行系统终止命令
7 Q9 u7 t+ V1 A( r6 F  K            if (rt_exec & EXEC_RESET) {1 _1 u% I: I3 U9 }
              sys.abort = true;  // Only place this is set true.! G/ P1 A% n- [( q$ `8 T7 a: d
              return; // Nothing else to do but exit.7 T8 ^& v* {# L2 {+ K& g: a3 ^
        }1 L. [5 c! I# b+ a3 e4 ^
6 N! d8 |' }/ F- `# ?
            // Execute and serial print status 执行和串口打印状态# M7 P0 b9 M- m5 i; x, Y
            if (rt_exec & EXEC_STATUS_REPORT) { / m! n9 g9 D8 ~
              report_realtime_status();        //报告实时状态
1 ]. S! a' g' V9 v( r7 h              bit_false_atomic(sys_rt_exec_state,EXEC_STATUS_REPORT);        //清除报告状态清零8 c' i& `; ?0 ^4 _4 c# H5 _% Z& X3 o
            }( ]- R6 O" P. \
_____________________________________________________________________________* E& S0 I0 I0 }% E. O- s
下面代码" Z$ s4 h$ A7 ]3 t2 E, R5 m6 p
//执行状态。0 A0 I3 K9 d6 @) U$ {8 z
//注意:所涉及的数学计算持有应该足够低对大多数人来说,即使不是全部,/ X5 A8 f4 \$ A( Y. @) g
//操作场景。一旦启动,系统进入暂停状态
( r) ]3 k% u& ?; E$ R+ h//主程序流程,直到重置或恢复。: W# u6 t5 k& ]- q( H8 ^* g, ^& Q
待办事项:检查模式?如何处理呢?可能没有,因为它只会在空闲,然后重置Grbl。
' h1 P( G+ a" r" j9 o状态检查容许状态的方法。& i! S8 S: R! [! G, o5 Y

# F% P) I8 V. F9 }/ Y! p        //如果全局各自报警标志位其中(执行取消动作) | (执行进给保持) | (执行安全门)任意一位为真进入/ @6 r0 [. d4 [/ z
            if (rt_exec & (EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR)) {        3 R  @; Q1 k/ v' N
0 J; T$ F8 ^: O3 U2 W" o4 S
        //如果是循环状态执行暂停状态
. Q2 G5 l/ y5 F* Z        if (sys.state == STATE_CYCLE) {$ w1 t% u( i5 x+ ~% y, N; x% N8 Z
        st_update_plan_block_parameters(); //通知stepper module验算减速。
) V4 Q+ a$ n6 o/ |/ p        sys.suspend = SUSPEND_ENABLE_HOLD; // 开始暂停标志
- o' \2 r# H6 a7 o; c/ @: G# I1 K! l        }
# @( N: y8 c; p4 V& w. f9 `7 G$ _7 ]8 f, p  I
        // 如果,Grbl空闲不在运动。简单的指示暂停就绪状态。+ j4 o& o& S8 V+ R9 S
        if (sys.state == STATE_IDLE) { sys.suspend = SUSPEND_ENABLE_READY; }
3 F8 b2 A4 K7 o6 R: G
( l! B# }$ O7 x6 }& ?- M, g! |
: [6 Z* x# \$ `! s/ D. y        //执行和标志和减速运动取消并返回空闲。主要由探测使用周期6 u; g7 y. ~0 E  h* g6 g
        //停止和取消剩余的运动。       ' s3 ~& f" b: K) _: H% Z- J) M+ @
        if (rt_exec & EXEC_MOTION_CANCEL) {
* m. a" }, M# d          if (sys.state == STATE_CYCLE) { sys.state = STATE_MOTION_CANCEL; }
# ^; O( _) k0 O& I* H          sys.suspend |= SUSPEND_MOTION_CANCEL; ) r( S5 M- n0 _3 x& q0 k9 Q
        }1 }! x$ O& q, K& O1 G0 M. Q

0 b. h9 N' P0 L1 t; W        // 只在循环时执行进给保持减速! G& Z  P) Q7 }/ W
         if (rt_exec & EXEC_FEED_HOLD) {
+ ]% T8 i7 T4 W$ m, |8 O9 ^/ c        //只有安全门为1才执行保持进给状态赋值
6 G4 ]! c+ F& M& [$ G          if (bit_isfalse(sys.state,STATE_SAFETY_DOOR)) { sys.state = STATE_HOLD; }; T! M% {1 u! t8 K3 K5 N
        }& u6 F0 o1 w$ n+ ~  a

9 x2 b2 z6 ]6 m1 l/ s& E$ N+ ~        if (rt_exec & EXEC_SAFETY_DOOR) {
; W6 d2 k3 M( {! b4 P8 S# n          report_feedback_message(MESSAGE_SAFETY_DOOR_AJAR);
/ V2 V* \6 ^0 b/ /如果已经活跃,准备好重新开始,CYCLE_STOP标志设置为强制断开。
) I4 ~5 r9 x6 x! Z6 o/ /注意:只是暂时设置“rt_exec”变量,不是动荡的“rt_exec_state”变量。
, C+ L. O- r# ~4 u/ J          if (sys.suspend & SUSPEND_ENABLE_READY) { bit_true(rt_exec,EXEC_CYCLE_STOP); }0 N( ]+ t8 Z: G, M1 c" l$ q/ ]
          sys.suspend |= SUSPEND_ENERGIZE;
% Y4 |3 p; \; R4 X          sys.state = STATE_SAFETY_DOOR;6 o1 `3 r/ M* t! J( S" A
        }6 m# Q+ o" j/ L% [, O, f; y3 R/ W

: G: `: d6 o' ^; Lbit_false_atomic(sys_rt_exec_state,(EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR));    ( k1 S  o: t  {

# u: l% W- z) m8 G8 R}
5 b& ^0 L/ T! {  l. D: {7 _6 W# T以上代码执行了
+ u% h6 S4 g! @" {, B6 p1.如果全局各自报警标志位其中(执行取消动作) | (执行进给保持) | (执行安全门)任意一位为真进入
) P3 O: ]2 Z7 u& f2.系统为闲着状态, 开始循环状态, 回原点状态, 控制取消状态, 开始保持状态, 开始安全门状态时进入3 Z# F6 s% u6 M5 q
3.如果是循环状态执行暂停状态7 v& e( M4 E; x5 l5 @/ F; |
4.如果系统闲置状态执行暂停就绪状态
0 Y+ D, `' S) j: t% a$ f' l5.执行动作取消- r2 h% H( p! ^( t
6.如果是保持进给状态,执行保持进给状态; _, X; s  ]7 C' U! j" [: ]+ X* g
7.执行安全门状态
, @* c! L6 U9 d* [最后执行bit_false_atomic清标志清除(执行取消动作)(执行进给保持)(执行安全门)标志位                 
2 `' j4 G$ ?' z' z4 B* j2 d, [_____________________________________________________________________________
3 P1 a4 j- k) _& s: Y1 t% ]  y5 j1 n3 h, x& M- q: ~: B$ S9 |
    // Execute a cycle start by starting the stepper interrupt to begin executing the blocks in queue.- U/ ^- I7 n/ e2 w% T3 H
    // 执行一个循环开始启动步进开始执行中断队列的街区
# ^2 Y5 `5 I! L; X. a7 o    if (rt_exec & EXEC_CYCLE_START) {        //循环开始状态进入  h/ p. U9 I/ Z; q
      // Block if called at same time as the hold commands: feed hold, motion cancel, and safety door.9 m7 a% D( g2 S0 B7 e
      // Ensures auto-cycle-start doesn't resume a hold without an explicit user-input.
6 @, I" F' j( O& E1 a! m          //块如果在同时举行的命令:保持进给,运动取消,和安全的门。 //确保auto-cycle-start没有简历没有显式的用户输入。
, g9 i* |; I# C, [% |7 i6 ]          
9 m" j. U2 T7 ^& G+ j      if (!(rt_exec & (EXEC_FEED_HOLD | EXEC_MOTION_CANCEL | EXEC_SAFETY_DOOR))) {   //状态机如果不是保持进给,运动取消,和安全的门。 1 U( @; u! D# u& p$ V+ f+ z
        // Cycle start only when IDLE or when a hold is complete and ready to resume.
5 Y9 P! j4 {$ Y6 [" D! b1 c5 p        // NOTE: SAFETY_DOOR is implicitly blocked. It reverts to HOLD when the door is closed.
( S# F6 U; o9 n: L0 j9 u2 Q+ Z                //循环开始时只有当闲置或持有完成并准备简历。1 {( E& x! Z4 W6 G: l+ S- R
                //注意:SAFETY_DOOR是隐式地屏蔽。它返回的时候门是关闭的。   
1 }4 g- |. J* L  H" y, n; C* {- B; t# n0 [9 x: Z8 Q, S
                // 如果系统状态为闲着状态,系统状态为开始进给或运动取消,暂停标志为位重新开始
8 O$ D5 I& X/ K        if ((sys.state == STATE_IDLE) || ((sys.state & (STATE_HOLD | STATE_MOTION_CANCEL)) && (sys.suspend & SUSPEND_ENABLE_READY))) {: y. x& _( b: t' s+ y4 f6 t- d
          // Re-energize powered components, if disabled by SAFETY_DOOR.
3 J" k" Q; H% ^$ W          //        由SAFETY_DOOR重振组件供电,如果禁用。: ]- a2 R0 T, b  U  L
          if (sys.suspend & SUSPEND_ENERGIZE) {
8 \) e" A; b/ }' y. h( }            // Delayed Tasks: Restart spindle and coolant, delay to power-up, then resume cycle.4 l! k2 ^. T1 g" N
            //延迟任务:重新启动主轴和冷却剂,延迟升高,然后恢复周期。
) |( p! j5 N8 b+ o            if (gc_state.modal.spindle != SPINDLE_DISABLE) {   //主轴模式不是失能进入
, M2 J, }) a, r/ x              spindle_set_state(gc_state.modal.spindle, gc_state.spindle_speed); //设置状态和速度/ S/ k& x: K- R* m% t
              //待办事项:阻塞函数调用。最终需要一个非阻塞。
$ g6 g2 E3 N4 @1 e! ?$ U& ~6 V                delay_ms(SAFETY_DOOR_SPINDLE_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.& |4 h& b+ u7 a4 `' _
            }
9 r. G; n0 H. E# P7 b6 p! T            if (gc_state.modal.coolant != COOLANT_DISABLE) {
, j% k; z+ `; o' m              coolant_set_state(gc_state.modal.coolant);
/ c! q, B! a8 s2 H4 m" b) j7 V" q, R              delay_ms(SAFETY_DOOR_COOLANT_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.6 K7 d0 s. T" T4 J" G' u+ |
            }. M0 E8 ~+ B! F9 d' H) o$ p0 V' p. }
            // TODO: Install return to pre-park position.
( D6 }5 J1 n/ Q0 Y! ?# T          }
( r1 d0 }) |6 ]* f& ^______________________________________________________________________________________________________________3 E( o9 ^5 l( e# w
          // Start cycle only if queued motions exist in planner buffer and the motion is not canceled.
( c- w+ _4 \: L5 b                  $ L; u! u: J1 P, H- v
                  //只有在队列马达存在规定的缓冲,并且动机没有让取消,才会循环4 K0 G+ [( Y" l) T* B( V
                  0 [0 Y- c( G" `% }) L/ {! a
          if (plan_get_current_block() && bit_isfalse(sys.suspend,SUSPEND_MOTION_CANCEL)) {
% h- m) s; a$ e1 G) {# T% A            sys.state = STATE_CYCLE;% b' S; W/ ^, E; l2 C
            st_prep_buffer(); // Initialize step segment buffer before beginning cycle.初始化步开始循环之前6 H8 A# t6 D: J
            st_wake_up();0 b' y3 X: j3 p* l
          } else { // Otherwise, do nothing. Set and resume IDLE state.否则,什么也不做,设置和复位空闲模式- S/ x+ y" D  q; h5 [/ A
            sys.state = STATE_IDLE;
5 x; r3 F- ]6 e: e# a( w          }
+ l: q/ g7 L3 k# b  Z          sys.suspend = SUSPEND_DISABLE; // Break suspend state." o6 s$ |" O# ^; Q6 C
        }
* p! S) j' Y  t, m# k, o3 L      }    % ?7 O9 R) q! c
      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_START);        / p4 z( e" N; g. S! m  ^
    }% L" c9 E8 d8 A  U$ y9 B( G
4 |& e# y) N$ f) q9 i5 F$ m
_______________________________________________________________________________________________________
! u. z0 L$ z& K3 y/ L    // Reinitializes the cycle plan and stepper system after a feed hold for a resume. Called by
0 T  Y  `3 J( `# ^4 q    // realtime command execution in the main program, ensuring that the planner re-plans safely.
* K, P$ s9 K4 u# z6 r    // NOTE: Bresenham algorithm variables are still maintained through both the planner and stepper
0 F' V8 D! R& y    // cycle reinitializations. The stepper path should continue exactly as if nothing has happened.   7 H0 e! m9 o: C' u! _- w
    // NOTE: EXEC_CYCLE_STOP is set by the stepper subsystem when a cycle or feed hold completes.
4 }; f/ [' O9 Y0 Z2 n6 T% m3 B, `8 X
; v: l3 x9 F5 G  H7 l" }        //重新启动后循环计划和步进系统的进给保持简历。通过实时命令执行主程序,确保安全计划重新计划。
/ I* m" F% E3 q- }        //注意:画线算法变量仍保持通过规划师和步进- F# z+ N- d/ B* M' k. t
        //循环仅。步进路径应该继续,好像什么都没发生一样。        ) p* x2 [, b1 c4 J) B
        //注意:EXEC_CYCLE_STOP由步进子系统周期或进给保持时完成。
0 V- D' H, w. Z0 x- ^
; R" q0 z( |. E$ D" s    if (rt_exec & EXEC_CYCLE_STOP) {                         //如果是循环停止状态进入8 M& V* ?) z. t4 @/ \
      if (sys.state & (STATE_HOLD | STATE_SAFETY_DOOR)) {
. H1 }. r6 y+ \$ D: F( ~! `        // Hold complete. Set to indicate ready to resume.  Remain in HOLD or DOOR states until user
% u' e! m: O$ h        // has issued a resume command or reset.2 b* y: M, H5 G" v: s7 O4 K

: V+ `. k( ?3 ^8 A  D3 R                //保存完整。设置为指示准备简历。继续持有或门状态,直到用户
* Y2 h2 W; j; u% W7 {/ N                //已发布了一份简历命令或重置。
. s  U/ l( w- I; f2 {: T                2 Q( }# N( E' @" O7 |
        if (sys.suspend & SUSPEND_ENERGIZE) { // De-energize system if safety door has been opened. 如果安全的门已被打开。断开系统3 j0 g6 I/ }+ t9 n9 B% W
          spindle_stop();- D+ z6 U" f; G" T" ~
          coolant_stop();% O+ P8 h3 ^( v- B
          // TODO: Install parking motion here. 安装停车动作。
; c- {* U) W, T- N! n        }+ U; A& M4 a  j8 M! R
        bit_true(sys.suspend,SUSPEND_ENABLE_READY);" O6 q0 x& K- D3 I; h
      } else { // Motion is complete. Includes CYCLE, HOMING, and MOTION_CANCEL states. 电机完成,循环,回原点,,MOTION_CANCEL
5 ~  U7 U9 U5 s0 D8 e        sys.suspend = SUSPEND_DISABLE;9 Q+ {6 W) }. A; T
        sys.state = STATE_IDLE;: r; ~/ E! h; b/ c2 M5 W- }0 @
      }
$ Y! N4 Z* e* e7 e+ y      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_STOP);
; O8 @4 c. R* N- ]6 z# ~    }
, y! F6 d6 @6 ]3 L  ?1 h6 m    ( S  N8 G  y) w+ [. w- N5 ]
  }0 E. c: ], |  h; i
___________________________________________________________________________________________________
5 k! X8 R. o7 k1 \, f/ J) S; I% o1 l: o# L
  // Overrides flag byte (sys.override) and execution should be installed here, since they
' B$ ~+ b7 P3 ~) c) F  // are realtime and require a direct and controlled interface to the main stepper program.
. I3 h  R. @0 s+ l5 \6 t0 B- }2 P: L) d; R# b* A& k+ x9 R; e
  //重写标志字节(sys.override)和执行应该安装在这里,因为他们
& P- y" W8 b# e( H' M  //实时和需要直接和控制接口的主要步进程序。4 A: K; m; @( [

* X0 B, G( {" a% c+ G! K4 w4 W
2 q) z& P+ z+ \# L# N! ]! x! U7 d/ _  // Reload step segment buffer 重新加载步段缓冲
- X7 L0 T5 H6 w) r4 y  if (sys.state & (STATE_CYCLE | STATE_HOLD | STATE_MOTION_CANCEL | STATE_SAFETY_DOOR | STATE_HOMING)) { st_prep_buffer(); } $ v) t/ }  R+ L
  ]  E: o+ e4 j
  // If safety door was opened, actively check when safety door is closed and ready to resume.3 p; l+ V2 ~6 V* f0 M/ R1 r: U- Z
  // NOTE: This unlocks the SAFETY_DOOR state to a HOLD state, such that CYCLE_START can activate a resume.       
/ M9 ~, G% B% G: z/ Y' K+ k) D8 k# h  ^" K( e2 F) c4 [: A
//如果安全的门被打开,积极检查当安全门关闭,准备简历。
! a* M- Z9 Z$ D$ C' l/ W% V- ?  //注意:这解锁SAFETY_DOOR状态保持状态,这样CYCLE_START可以激活一个简历。- M9 F; q5 a" I4 C3 y; F5 R

* s( r6 x2 r& n/ \: C% i  if (sys.state == STATE_SAFETY_DOOR) {                 //安全门状态进入+ u, W' p7 P: Y' z3 a/ ^' }
    if (bit_istrue(sys.suspend,SUSPEND_ENABLE_READY)) {
6 O2 U2 p6 x% d( k  ^8 w8 Z+ h      if (!(system_check_safety_door_ajar())) {
4 s+ @5 i% v" H6 j% @; X        sys.state = STATE_HOLD; // Update to HOLD state to indicate door is closed and ready to resume. 更新保存状态指示门关闭,准备简历。
, E$ }# D5 u4 W      }
, @) F1 [) E' _( ^& Q8 U: S" o, b    }: W; h# M6 o8 _
  }: e7 i5 i' q4 L; r0 f& I0 C" C" s
' O0 n$ _" I, p/ i* n: m9 p4 @
  } while(sys.suspend); // Check for system suspend state before exiting.9 G, R- U& X/ o! t8 ~/ [
  ) c# k/ S2 P! V* u  L
}  
回复 支持 反对

使用道具 举报

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

点评

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

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-16 08:29 , Processed in 0.081913 second(s), 19 queries , Gzip On.

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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