机械社区

 找回密码
 注册会员

QQ登录

只需一步,快速开始

搜索
查看: 18521|回复: 15

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

[复制链接]
发表于 2016-8-20 23:56:23 | 显示全部楼层 |阅读模式
本帖最后由 1五湖四海1 于 2016-8-21 00:09 编辑 0 I6 Z$ E4 m# M0 ^( |  v

3 K1 Y# D: D8 F    以前制作过CNC雕刻机,是用MACH3作为上位机控制,硬件是采用PC接并口输出脉冲和方向使能信号经过隔离驱动步进电机驱动器,步进电机驱动是采用TB6560芯片控制。最后就接到步进电机。机械是用铝合金制作,主要部件有三个1605的滚珠丝杠,多个运动滑块等制作。用这台DIY CNC雕刻机可以雕刻木头塑料等东西。当时没有一直玩下去,现在发现网上有用单片机制作的雕刻机挺精巧的现在分享给大家。
- ?+ y) U' g, A: A6 l% B: X  D   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个运动来规划运行速度,以实现平稳的加速和无冲击的转弯。很棒吧!开始玩起。
$ Y5 B3 n! U" W% U2 V+ X    还没有雕刻机的机械部分可以用废旧光驱制作个微型雕刻机运动平台。雕刻机最重要的是主控程序这次用 Arduino/AVR328单片机,价格在15元左右,主控程序是上面提到的目前很火的开源
的GRBL,还有一种基于STM32平台的开源主控程序Dlion也不错可以替代grbl。如果从性能比较这两个方案,显然是stm32平台运行速度更快毕竟他是32单片机呀!
  P+ t6 U( m9 Q- {$ C4 Q! @8 [3 y* x2 f" Z2 H  g

. a3 @& k5 f# n/ Y  \' Z    下面介绍小这个些主控程序主要干的事,通过串口PC和主控板通讯,PC命令给控制板,控制板接收命令做不同的响应,PC可以发G代码给主控板,接收完成后可以自动开始雕刻任务。
0 N9 s* I: k' A! ~          在介绍下G代码因为G代码是雕刻机的核心部分) u- [3 K8 k6 d6 A6 K
G代码是数控程序中的指令。一般都称为G指令。
$ j- A, o, Q. k4 [) [' ?G00------快速定位" t  R% o' V$ _5 [
G01------直线插补
1 ~# ]" x7 A& |7 K: ?- `, s+ K; K2 KG02------顺时针方向圆弧插补
9 R, J; Z# Q% p% }$ ZG03------逆时针方向圆弧插补  s, o1 W  e5 ?% g
G04------定时暂停
$ i! j' M) k- G: X) EG05------通过中间点圆弧插补
% J& P, l1 \( K# m3 d! fG06------抛物线插补
6 L6 z) d0 H7 P: dG07------Z 样条曲线插补
% M( u" U# @( uG08------进给加速" }$ L% t& x7 u' W
G09------进给减速$ P% ?- c7 E! ~( X/ M
G10------数据设置
" a& \' s+ J2 j6 C; m/ y. l$ m. KG16------极坐标编程
/ f/ q- [/ V( ^4 Q4 y7 A) rG17------加工XY平面8 n% X0 W+ |+ k0 I% u5 e! Q
G18------加工XZ平面
! N0 F7 U. a( H& DG19------加工YZ平面
7 D, h# y. D# M8 @  U+ @# L* G
核心就是解析G代码,完成步进电机驱动,和控制主轴开启关闭,还有插补算法,直线插补,圆弧插补,还有一些步进电机的加减速算法。' Z0 |" E8 |' b
下面对grbl主结构做介绍- S( P& C+ ~* B4 [, n7 ~- }$ s
main()主函数首先执行下面初始化函数
) Y8 |6 [) C  {2 X& J, }2 Y, W7 Q5 x        serial_init();                           // 设置串口波特率和中断
3 u  k( M1 a# |        settings_init();                         // 从ROM加载grbl设置
5 Z/ q6 I3 K* G2 }5 i! h        stepper_init();                          // 配置步进方向和中断定时器% C, C( K  y9 D
        system_init();                           // 配置引脚分配别针和pin-change中断$ V+ x+ Y6 b  F
        memset(&sys, 0, sizeof(system_t));          // 清除所有系统变量
1 U  m$ L1 B8 {3 T        sys.abort = true;                           // 中止标识位置位( k1 U2 h+ a; p( ^6 T  s
        sei();                                         // 使能中断
. X+ ^7 V/ S* |- I& [! Y/ T/ C7 K6 m  #ifdef HOMING_INIT_LOCK                        // 宏运算(settings.flags & (1 << 4)) != 0结果flags等于执行sys.state = STATE_ALARM0 Z& j4 T# d  e8 ~
                                                // 系统状态赋值为报警状态
) R7 l; ?2 O& @$ f            if (bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE)) { sys.state = STATE_ALARM; }
# w6 K3 y2 h/ U" e* V: G2 ~  #endif% Q$ n: ?7 v. c% N5 I
_____________________________________________________________________________________________________________________________________/ l4 \$ P1 Q: {; W
接下来是一些主要部分初始化) h) S  V& q' B
for(;;) {, s5 K' |: ~& l' K- \! ^2 V
        serial_reset_read_buffer();         //清除串口读缓冲区
; `* \/ t+ [4 \- h6 I# p% N6 P% F) M2 ^        gc_init();                         //初始化G代码功能函数, N1 O" f( a4 y
        spindle_init();                        //主轴初始化3 n! a" _! c- U$ g$ d' b. H% M
        coolant_init();                        //冷却液初始化
& S# j, a9 u/ p9 n( J+ R$ n        limits_init();                         //极限开关初始化2 h. c) |! [6 N2 r0 ^8 a" i  U
        probe_init();                        //探测部件初始化0 Z. k5 A4 _9 B
        plan_reset();                         //清除块缓冲区和规划师变量4 m/ a: f! Q7 p- S! h! M+ D/ h
        st_reset();                         //清除步进系统变量。
8 E' {$ k4 d6 r+ z
- l) G9 H$ Y7 ~" _" S
& ^2 q: ?& J/ b        //下面两行清除同步gcode和策划师职位当前系统位置。
: k8 B) z% U# E; g% N3 x% s
        plan_sync_position();
9 F7 k6 h# F  R6 z7 G        gc_sync_position();
+ `! {% h0 @; f, E& b9 f1 L; a" O4 ?" @+ @! |

  c5 ?% g5 ^) d+ A        //复位系统变量8 v8 Y1 ], `' f
        sys.abort = false;                //系统中止标志0 r  s% k" K; H, v4 v6 X4 i
        sys_rt_exec_state = 0;                //系统标志位变量状态管理。看到EXEC位掩码。
6 s/ w  a+ L" G$ y        sys_rt_exec_alarm = 0;                //系统标志位变量设置不同的警报。
5 D1 u2 P& [/ A        sys.suspend = false;                //系统暂停标志位变量管理,取消,和安全保护。
! |1 n3 x7 Y( e) B& J        sys.soft_limit = false;                //限位开关限制状态机错误。(布尔)1 j" M$ j2 l" L, L: l( E+ o  e

9 b! m! ?: t  k& r  g& s5 N- ?, o0 S1 Q' k
        protocol_main_loop();                //主协议循环3 ~1 S% Y6 V7 |. C! P' h0 {
}        //% I6 t. ^! D2 _6 Q8 A" L
_____________________________________________________________________________________________________________________________7 z  K% ~  ^9 {" f, q- }
进入void protocol_main_loop()函数
9 X$ ~' Y7 g1 d! O% [{4 S3 d2 Z* W- j& A$ @% _
        report_init_message();                // 打印欢迎信息
: \9 w* |% M8 G% K# d4 I6 I" T; {+ }+ F        //重启后检验和报告报警状态如果错误重启初始化。
6 r1 p/ M- b1 z
        if (sys.state == STATE_ALARM) {  @5 S2 z- V: W4 B* @3 S
            report_feedback_message(MESSAGE_ALARM_LOCK); //打印信息
! f! q. n. a( U7 `, Y
          } else {  D& G1 U0 C2 c
            // 如果没有报警说明一切正常!但还是要检查安全门.
! ^6 t" I3 h) s            if (system_check_safety_door_ajar()) {
. H$ S2 f  V, D2 L$ i4 C* i                     bit_true(sys_rt_exec_state, EXEC_SAFETY_DOOR);
6 Q% H2 t! m9 V                     protocol_execute_realtime(); // 进入安全模式。应该返回空闲状态。7 n5 ]. |3 Y8 j4 R" c5 w
            }         else {
7 {3 l2 Y: R. B6 N              sys.state = STATE_IDLE; // .设置系统做好准备。清除所有国家国旗。. \3 D9 f1 `  l8 G0 y
            } - G9 d3 O# m0 y' o8 W
            system_execute_startup(line);    //开始执行系统脚本
# g7 e0 s7 Y3 v9 g0 r$ X  } , Z# Z7 g# ^$ Z& A

, ~# p0 b) \% H! l+ @0 h& I: L' }; t2 Y6 O
  // 这是主循环!在系统中止时这是出口回到主函数来重置系统。0 u1 h9 t! B$ c5 ~6 w6 F8 `
  // ---------------------------------------------------------------------------------  * v+ c- H' w2 T8 J4 W
  
5 Y5 q% i6 Z0 R& a2 N        uint8_t comment = COMMENT_NONE;. X) c* F$ o+ ~/ H5 `) h7 O
        uint8_t char_counter = 0;
5 f( ~3 K5 r0 G0 I/ i" f        uint8_t c;" W7 M& y$ V3 c8 a3 F" c9 r
_______________________________________________________________________________________________________________________________
! T& j: A; _6 q! w4 j! p& r4 ?接下来进入for(;;)循环                //下面代码是G代码解析核心部分,程序中comment(注释)变量会被赋不同值,代表发符号有‘(’‘)’‘;’
9 C- w+ b6 S' u{/ M+ G" ?* r. Q
//串行数据输入一行的的过程,作为数据。执行一个$ X6 v7 T2 f  |# W# T2 l
//所有数据初始过滤去除空格和注释。 7 K9 D1 I0 b' K4 [
//注意:注释,空格和程序段删除(如果支持的话)处理技术
3 r  n- h& Z! M# }5 X  H( m# T+ d//在G代码解析器,它有助于压缩到Grbl传入的数据$ B) O0 G  J) L7 y$ `
//线缓冲区,这是有限的。刀位点标准实际上州一行不行8 i" A: k. n( G, c$ c5 ]' P
//不能超过256个字符,Arduino Uno没有更多内存空间。% `3 `" R' q) n" I! X2 F
//有更好的处理器,它会很容易把这个初步解析的
. L) Z; i" l; I/ t//分离任务共享的刀位点解析器和Grbl系统命令。                                                               
% e: m- J1 Y" s0 h    while((c = serial_read()) != SERIAL_NO_DATA) {                             //读取串口数据,有数据执行下面代码
2 r7 j+ {+ ?/ P. V% A7 k$ ?      if ((c == '\n') || (c == '\r')) { // End of line reached                //如果数据是/r,/n代表一行结束& m# |! g7 h$ [" ?; d/ w1 c
        line[char_counter] = 0; // Set string termination character.        //设置结束标志& i7 J- p- a$ x0 m* T
        protocol_execute_line(line); // Line is complete. Execute it!        //一行完成执行此函数0 E9 @9 Q5 V  P% P4 Y( U
        comment = COMMENT_NONE;                                                //注释清零
( g$ p# P7 V  M7 z6 l) ^  }        char_counter = 0;                                                    //字符计数清零3 K$ q2 J3 x% z: r, v3 B; _
  
) w; b( U6 C9 t2 `; T. F3 C; E9 ~. c        else {
9 \# r! M3 @/ m) A7 Q- V        if (comment != COMMENT_NONE) {
7 C/ z1 n7 ~; n; B                                                     //扔掉所有注释字符$ t5 }- {/ q# n: O( ?
          if (c == ')') {) b* b$ m; x! S  {# j( y/ r
            //最后注释。重新开始。但是如果有分号类型的注释。
7 j) {0 s6 I0 r. J/ c( v            if (comment == COMMENT_TYPE_PARENTHESES) { comment = COMMENT_NONE; }
- V' M1 g( |9 t4 r  J          }
. L  v- T8 r; s! q      } else {6 r7 A* u: W0 A1 y
          if (c <= ' ') { ' ~# [( V# y+ W9 Z& M5 B9 S
            //扔掉whitepace和控制字符
( `# s% c( g9 v! q8 M) R          } else if (c == '/') {
/ `4 l. n) K, }) b            //块删除不支持将忽略字符。
- q4 H" Z) L( ]2 I4 n, _/ I' a            //注意:如果支持,只需要检查系统是否启用了块删除。
; R0 z) i7 k$ _          } else if (c == '(') {
1 \5 R2 T1 B# q% n& T8 d# U            // Enable comments flag and ignore all characters until ')' or EOL.
1 I3 g# ]; v5 k- G- I' V) @            // NOTE: This doesn't follow the NIST definition exactly, but is good enough for now.
4 b4 ]$ @+ P6 ?6 ^            // In the future, we could simply remove the items within the comments, but retain the6 i) L+ x. Y& E9 G. d  e
            // comment control characters, so that the g-code parser can error-check it.
" Z8 z2 L7 |4 R+ `$ w6 Z1 ]            comment = COMMENT_TYPE_PARENTHESES;
* r( N$ H  N$ q& l8 T4 B* o          } else if (c == ';') {
. J, n4 c# F$ j% T/ O4 z6 j4 S  ^            //注意:','注释EOL LinuxCNC定义。没有国家标准。5 U6 u- }8 }6 `# j/ `
            comment = COMMENT_TYPE_SEMICOLON;
# E2 W: W0 y, Y; S, P, s2 X6 ~+ x# |7 B
  v; X0 W" _. [2 J3 _2 U$ J
_____________________________________________________________________________________________________________________________________/ z& Y5 R/ ^3 S
          } else if (char_counter >= (LINE_BUFFER_SIZE-1)) {                        //串口接收数据大于80字符时) Q- t) ]- x# [) C; Y+ S" \5 J2 Z  l
            // Detect line buffer overflow. Report error and reset line buffer.        检测缓冲区溢出。报告错误和复位线缓冲区。! Q# r% u- i( c" [) K; x7 V
            report_status_message(STATUS_OVERFLOW);                                //打印溢出信息
5 _. @- `' Y+ d; t            comment = COMMENT_NONE;
% g/ O- N9 S% u& z6 f. p            char_counter = 0;( L: T1 Y  ~  H
          } else if (c >= 'a' && c <= 'z') { // Upcase lowercase                        //小写改大写
# O. ^& G; j. y& J5 x9 a            line[char_counter++] = c-'a'+'A';
8 M' w4 C- I; D# Q/ W. a0 j# l          } else {2 e7 N: Q& j; {2 h+ b, C' b( d) D
            line[char_counter++] = c;1 S; @. |: B7 l% k( ~7 Q
          }
# n, V: v" E- U. B8 P        }. Z& `$ _7 B4 k
      }
: y6 ^5 [1 O* v+ s* u2 @    }& }2 h/ g, G& O) B, D: H
____________________________________________________________________________________________________________________________________
7 |! w) C$ G$ b1 j' h* L        //如果没有其他字符在串行处理读取缓冲区和执行,这表明以完成,自动启动,如果启用,任何队列动作。
$ ~8 w' W$ Y3 A6 a6 y        protocol_auto_cycle_start();                //自动开始协议循环
# `& g7 Y) C1 u# q$ P' d        
# p# j" J  d8 Z# L- S4 ^            protocol_execute_realtime();                  //运行实时命令。
: x2 ~  `( M6 n            if (sys.abort) { return; }                 //中止标识置位程序循环重置系统。            
8 E8 N$ l* j6 m2 D7 l. R5 L) ?  }
% P4 T# V" F) o) ]- I2 m! c7 _' T6 `  return;                         //一般程序不会执行到这里
; Q" q  P0 L: A* c1 B}
5 D! R- m; T3 q% L6 G____________________________________________________________________________________________________________________________________
/ w- ^' Y5 M0 T. I! ~5 ?- x正常情况下,读取完G代码程序会进入protocol_auto_cycle_start();//自动开始协议循环 函数下面介绍此函数" {" h  h1 s+ m2 q1 o8 M3 h
// Auto-cycle start has two purposes: 1. Resumes a plan_synchronize() call from a function that6 M' A" v& Y$ O! A1 }
// requires the planner buffer to empty (spindle enable, dwell, etc.) 2. As a user setting that ! a. h7 H' n9 ]
// automatically begins the cycle when a user enters a valid motion command manually. This is
* Y& s& s6 r* b2 U. @9 c// intended as a beginners feature to help new users to understand g-code. It can be disabled
2 o* F/ y0 p" c6 B// as a beginner tool, but (1.) still operates. If disabled, the operation of cycle start is
4 T0 s8 ~* ^; l( C# j( D// manually issuing a cycle start command whenever the user is ready and there is a valid motion
6 Y. k" P1 n6 |1 X, g  C# A/ Z// command in the planner queue.
3 q  V& E: Y% a// NOTE: This function is called from the main loop, buffer sync, and mc_line() only and executes 3 g% {& w$ Z+ @9 G: \
// when one of these conditions exist respectively: There are no more blocks sent (i.e. streaming
/ a; B) z7 S) B( G// is finished, single commands), a command that needs to wait for the motions in the buffer to
6 F8 f+ z8 Z) _! {! r5 t// execute calls a buffer sync, or the planner buffer is full and ready to go./ o/ v5 @% N* Y0 G  b2 E% \, |) w
//自动开始有两个目的:1。回复一个plan_synchronize()调用的函数
- b$ X8 o. w! |, |6 x//需要规划师缓冲区空(主轴启用、住等)2。作为一个用户设置2 f2 k2 u( ]: \
//自动循环开始当一个用户输入一个有效的运动命令手动。这是
* i# n' ~! s& L//作为一个初学者的特性来帮助新用户了解刀位点。它可以被禁用
  k* E# V' L$ A0 o+ E, Q# a//作为一个初学者工具,但(1)仍然运作。如果禁用,运行周期开始
  _/ n% o7 _7 r: G0 B, d4 r! F: V//手动发出一个周期开始命令每当用户准备好,有一个有效的运动+ |5 j4 t: H; D* o3 H6 [/ V
//命令的规划师队列。+ V9 K5 c4 p0 _# Z/ r' S8 Q! y3 d
//注意:这个函数被称为从主循环缓冲区同步,mc_line只()并执行
( r. b$ r  o0 ?7 F, F( w//当其中一个条件分别存在:没有更多的块(即流发送
! w+ E; m1 H% N8 ^//完成后,单一的命令),一个命令,需要等待缓冲的动作
, g' }* s$ {8 [8 @1 E! b8 M//执行调用一个缓冲区同步,或规划师缓冲区满了,准备好了。
% o" ~, i! ]. t# fvoid protocol_auto_cycle_start() { bit_true_atomic(sys_rt_exec_state, EXEC_CYCLE_START); } 5 u: `2 K6 A4 a/ u- A1 k% o* C; {
_______________________________________________________________________________________________% X$ I$ y# b7 D' w' k
接下来程序运行protocol_execute_realtime(); /运行实时命令。
5 `; L) i! R$ S4 c1 j// Executes run-time commands, when required. This is called from various check points in the main
& j. z# ^! h4 f// program, primarily where there may be a while loop waiting for a buffer to clear space or any
8 g* n- j' u6 l// point where the execution time from the last check point may be more than a fraction of a second.
, X! l* Q3 R$ q4 c$ ]1 [1 v// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code& t6 |) Z1 D4 t
// parsing and planning functions. This function also serves as an interface for the interrupts to . Q7 z9 f( P. _7 B$ N" B
// set the system realtime flags, where only the main program handles them, removing the need to9 v, m$ H8 K/ @. I/ N, @
// define more computationally-expensive volatile variables. This also provides a controlled way to 7 M0 Q! R9 U* U  c6 j5 t# n- L
// execute certain tasks without having two or more instances of the same task, such as the planner
1 ~3 q8 y; G  D/ m* o  k) Z8 n// recalculating the buffer upon a feedhold or override." k- x) ]% \6 X5 [$ ~6 R. d
// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,
' S9 V1 l2 m6 t0 Z; _// limit switches, or the main program.
1 X+ y8 k* }' K1 evoid protocol_execute_realtime()& v3 z2 h. c, B* I, ?# `) |
uint8_t rt_exec; // Temp variable to avoid calling volatile multiple times.临时变量来避免多次调用不稳定。' p% s/ ~0 l# u+ w0 u, w$ l# v
就先分享到这吧!
# ^9 S2 C% T- r6 p  _7 [! E" R. F0 u  s
' x( J! ]" \- s, H  f) x
* Z, d3 E3 }( F- x" {7 k
* V. W+ `. x" i7 G6 d9 p
+ j2 @/ w+ f4 q" g0 a
+ C6 O% ^# Z5 u2 n  K. H2 u% W' p% L, J' y% c

: H2 \) \, R4 {2 A: X% N
2 |0 I: `0 g7 s$ @8 W& A* j: Z2 ~- z
2 g; p9 D* O$ n. m1 L+ }
" N4 A- O! [. X) b3 Q. C8 N" Q" L8 j* l8 l2 A% T, ]  a5 f
4 b5 L; H3 U- G2 k( @, r# W, C3 Q

: {( i3 r) S3 |. X" @4 c! d" D) ^6 p) G8 w  r3 S1 n

' @# q6 l* l4 b4 T" ]/ m  [8 S" Z0 p9 `
6 @# @2 ^  ]: i$ w4 E7 \( g

2 `+ G! @, U1 ?3 o. z/ ?- R: `' C# t6 t# }7 ~% m6 ?

( C; D! i2 @" T6 y
) r% n! _- h: e$ s' W  }0 [9 T; W( B6 i

# a' z: k/ ^' ]6 s8 g. ?0 ?8 |$ {补充内容 (2016-8-25 22:40):
9 F# I/ m( T5 |/ X# |配置说明8 V" f" z" ]" h2 S8 O" {" N
//这个文件包含编译时配置Grbl的内部系统。在大多数情况下,( h2 ^, D$ g# j) U  C9 ~
//用户不需要直接修改这些,但是他们在这里为特定的需求,即。/ k+ y1 h0 R) Y; p4 Y
//性能调优或适应非典型的机器。7 h! O5 B3 d; M# L# M. y
主要配置项:: H0 k" I" G8 _( E0 B/ g6 x
1.#define DEFAULTS_GENERIC        //在重置eepm时使用。在defaults.h改变想要的名字7 B- A3 `7 x( P& I" }
2.#define BAUD_RATE 115200        //配置串口波特率115200
7 }% O5 e% w; x$ O) S3.#define CPU_MAP_ATMEGA328P         // Arduino Uno CPU
! Z8 v' `# a, U/ r8 A0 L4.#define CMD_STATUS_REPORT '?'        //定义实时命令特殊字符
5 o0 q9 j- @/ a5 U5.#define HOMING_INIT_LOCK         //回原点保护锁' f1 G0 G+ Z( e* E' V
6.#define HOMING_CYCLE_0 (1<<Z_AXIS)              // 第一步Z清除工作区。8 ~4 m! x: _  c: S5 v- ]
  #define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // 然后X,Y在同一时间。3 w7 t) t$ J4 X0 f# y' Q- o: ]
7.#define N_HOMING_LOCATE_CYCLE 1 //回原点循环次数
/ _7 Q. z0 B8 q$ d5 H1 H; }. l8.#define HOMING_FORCE_SET_ORIGIN //取消这定义迫使Grbl总是在这时候位置设置机器原点尽管开关方向。0 B( q' F$ J1 F. F( c
9.#define N_STARTUP_LINE 2 //块Grbl启动时执行的数量。/ S) D% b( p3 H0 d2 z
10.#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 协调或位置价值英寸# ?  l( f4 S' d2 I0 x$ w
   #define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 协调在毫米或位置价值
) F5 K7 D9 a3 L   #define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分钟的速度值* _, e& [- A/ @1 L+ X
   #define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分钟4 P0 ^; F  a3 e: ]. e
   #define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 对浮点小数设置值& l9 r7 A" I) G( z& P& r6 ?
11.#define LIMITS_TWO_SWITCHES_ON_AXES //如果你的机器有两个极限开关连接在平行于一个轴,您需要启用这个特性
! L* ?* [- x3 p5 }0 _6 f' t/ d. }12.#define USE_LINE_NUMBERS         //允许GRBL跟踪和报告gcode行号* `9 o# l+ q. z5 N1 r( W
13.#define REPORT_REALTIME_RATE //允许GRBL报告实时进给速率
" T* x" [: ^$ T0 U: A14.#define MESSAGE_PROBE_COORDINATES  //坐标通过Grbl $ #的打印参数?4 W1 `, n9 v" g& R
15.#define SAFETY_DOOR_SPINDLE_DELAY 4000 //安全门主轴延时& \) [; G" |" W) C& g
16.#define SAFETY_DOOR_COOLANT_DELAY 1000 //安全门冷却液延时
: Q1 C+ Q+ f* K. X. u) _& N17.#define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS) //启用CoreXY运动学。6 l- J. R6 z7 V7 N
18.#define COREXY // Default disabled. Uncomment to enable.改变X和Y轴的运动原理! E- ?  n4 l% M3 a9 O2 w9 ^
19.#define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.反转针销逻辑的控制命令
' L( b! l3 Q4 L# X" V5 ^20.#define INVERT_SPINDLE_ENABLE_PIN // 反转主轴使销从low-disabled8 s. D; L+ K5 m/ s; Q
21.#define REPORT_CONTROL_PIN_STATE //启用控制销状态反馈状态报告。7 x( |7 u6 P4 U* X- R8 L8 s# d+ {
22.#define FORCE_INITIALIZATION_ALARM //启用和用户安装限位开关,Grbl将启动报警状态指示
7 N; I- X( r( S1 b. o23.#define REPORT_GUI_MODE // gui允许最小的报告反馈模式
8 ]3 u9 m4 u' P- P- [24.#define ACCELERATION_TICKS_PER_SECOND 100 //加速度的时间分辨率管理子系统。$ y4 `! w6 X( Z9 o8 d3 v
25.#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING //自适应多轴步平滑(积累)是一种先进的功能 ' E, |2 }# w; O: [
26.#define MAX_STEP_RATE_HZ 30000 //设置最大一步速率可以写成Grbl设置' N: d: r! V  {: z* ^3 ]% f
27.#define DISABLE_LIMIT_PIN_PULL_UP //以下选项禁用内部上拉电阻
* [' o1 ^" H6 i0 w28.#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS //设置哪个轴长度补偿应用的工具。假设轴总是与选择轴工具面向负方向+ j5 [8 O5 `  p) X! ^7 u
29.#define VARIABLE_SPINDLE //允许变量轴输出电压不同的转速值。3 V: r* o; q8 X* l4 p) H
30.#define SPINDLE_MAX_RPM 1000.0  // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.: a  H* g, o% R* I% X
   #define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.
' I' O' E' }% W! ~  H* J31.#define MINIMUM_SPINDLE_PWM 5 //使用的变量轴输出。这迫使PWM输出最小占空比时启用。
  ^+ J  N* g% i' x" f0 n32.#define USE_SPINDLE_DIR_AS_ENABLE_PIN //主轴方向使能M4被删除8 o; N  ]: {. w" E0 Y% q- y
33.#define REPORT_ECHO_LINE_RECEIVED //应该对所有正常线路送到Grbl
% A3 g% S" p; K. u; i% w34.#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min) //最小规划师结速度。设置默认最小连接速度规划计划0 v6 j- G  G6 {! j
35.#define MINIMUM_FEED_RATE 1.0 // (mm/min)//设置计划将允许的最小进给速率* ?( Q1 Z- U2 E8 }; f: e% a5 |1 i9 H
36.#define N_ARC_CORRECTION 12 //弧生成迭代次数之前小角度近似精确的弧线轨迹9 o5 P/ W- `5 F5 l5 u. q5 v$ ?
37.#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)//定义值设置机器ε截止来确定电弧是一个原点了?
6 n- _# U4 b5 T- j; @" n5 Q8 X/ C0 \! d38.#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds) //延时增加表现在住。默认值设置为50毫秒
4 v* E& E4 u1 A7 h5 m6 F6 t; o% C39.#define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.
4 K2 A' j9 p& x' a- }, t3 ?40.#define BLOCK_BUFFER_SIZE 18  //线性运动规划师缓冲区的数量在任何给出时间计划
- c5 T  {7 A, ]$ Y1 o* u4 C41.#define SEGMENT_BUFFER_SIZE 6 //控制之间的中间段缓冲大小的步骤执行算法
, l* e; d  a, {* H: ?! c' I& `42.#define LINE_BUFFER_SIZE 80 //行执行串行输入流的缓冲区大小。
+ o2 I! j( F8 \% X9 n; y43.define RX_BUFFER_SIZE 128 //串行发送和接收缓冲区大小
# D  _- v3 E, b44.#define TX_BUFFER_SIZE 64
7 H. ]4 \3 h# }3 x45.#define ENABLE_XONXOFF        ////切换为串行通信发送流软件流控制。2 o2 B& g8 T* H; L: p
46.#define ENABLE_SOFTWARE_DEBOUNCE //一个简单的软件消除抖动特性硬限位开关。1 |( A: N6 i% U: R
47.#define HARD_LIMIT_FORCE_STATE_CHECK        //Grbl检查硬限位开关的状态
7 B0 L  C) J4 z) R: M$ Y2 W) y- c48.// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:编译时错误检查的定义值:
4 C& H" e  A- y) w7 j" N
' P2 S! o0 T* u___________________________________________________________________________________________________
( t( F7 n+ q2 _0 [8 }/*
+ [8 @1 U' ?5 ?) }7 H; C5 @$ P  config.h - compile time configuration2 J: L3 V4 y( j" D# u
  Part of Grbl
- K6 s( V  p8 ?3 B
* c5 |/ W/ p9 c: B" Q  N  Copyright (c) 2012-2015 Sungeun K. Jeon* y# _. [4 ^1 r: ^
  Copyright (c) 2009-2011 Simen Svale Skogsrud7 j- m' c6 s; p, @& Y
7 ^" |% O, o; H' Z: t
  Grbl is free software: you can redistribute it and/or modify% {. i/ a  q- @1 u6 z* S
  it under the terms of the GNU General Public License as published by7 n1 U0 U/ s$ x' H3 x- V
  the Free Software Foundation, either version 3 of the License, or) M& ^2 H7 C0 {; C# J5 k
  (at your option) any later version.( G; B* M# f" u% F# Z3 V( B5 z, c
& A/ m+ N4 H$ K5 h
  Grbl is distributed in the hope that it will be useful,
1 m# K1 f8 ]; k# v5 b  but WITHOUT ANY WARRANTY; without even the implied warranty of
* V8 \3 t4 a+ a  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the8 f  m# x3 B( k; q
  GNU General Public License for more details./ |' c, f8 T: W9 X3 K
4 @0 J1 Y* U0 g0 U/ W" d8 C; d' \. ^
  You should have received a copy of the GNU General Public License
) `. z: o) \& @- j( `  along with Grbl.  If not, see <http://www.gnu.org/licenses/>.: w2 I* t% M6 y  \+ ~2 L2 g# P
config.h  -编译时配置,Grbl的一部分: @: f/ @/ y, L! l$ N* h  j4 ^8 @
& c3 b8 P- N  k4 B3 W/ m/ [, F# E
版权(c)2012 - 2015 Sungeun K. Jeon
6 P0 D  T2 M1 j  c# ~版权(c)2009 - 2011 Simen Svale Skogsrud
: ], Y2 }& |9 r4 V. A; l8 U( U5 y0 k. ~1 }# d% b& E8 J7 _
Grbl是免费软件:可以重新分配和/或修改: x' k1 k; z. W& L/ Y
GNU通用公共许可证的条款下发布的自由软件基金会,版本3的许可,或(任您选)其后的版本。
% L4 c; b: h2 C$ S' l( E/ @8 H- W$ ]# P7 o% l
Grbl分布,希望这将是有用的,但是没有任何保证;没有即使的默示保证适销性或健身为特定目的。看到( M* B9 `- r! J- p! A3 z6 ]
GNU通用公共许可证的更多细节。
0 e; R- v+ r: n* ]9 M: z8 v1 G% z  D7 R6 O! Q
你应该收到了GNU通用公共许可证的副本
1 d  t" ~! Q% I7 }, \9 x连同Grbl。如果没有,看< http://www.gnu.org/licenses/ >。
  V" z& R0 H' O. q; q8 E, I
4 P: p( m' e; s8 C/ d  L) ?) m# ~*/
! P) \6 @, G1 \) ~& u% j  7 R6 C" z: }2 e4 }
// This file contains compile-time configurations for Grbl's internal system. For the most part,1 E) j, d6 ~3 ?3 @
// users will not need to directly modify these, but they are here for specific needs, i.e.
& ?: y7 l' y6 z# Q! P: m8 M/ L// performance tuning or adjusting to non-typical machines.5 n# Q( |3 D3 F  n
//这个文件包含编译时配置Grbl的内部系统。在大多数情况下,
9 I5 B- r" k0 ]3 t//用户不需要直接修改这些,但是他们在这里为特定的需求,即。5 b! W- V) i# ?3 E
//性能调优或适应非典型的机器。
) Y# a/ a) N$ l/ E7 {1 f' c2 e
8 ^3 I0 u! R; x+ j* ^# b+ `) V% i// IMPORTANT: Any changes here requires a full re-compiling of the source code to propagate them." B" a5 D$ n; i7 h/ q/ d8 p
//重要:任何变化需要一个完整的基于源代码的传播。
, b8 y% c; t2 R9 h2 F5 l2 r- ?% ?, Y8 b2 E/ J
#ifndef config_h
5 s. Q( M4 w7 W5 Q#define config_h  E: ]; U: n2 t* P# @' w( Q8 s
#include "grbl.h" // For Arduino IDE compatibility.3 ?  j) _& ]$ Z5 X& G" N4 i9 g

0 ^  t; J# F! g! u; y7 O5 @% Z6 M. [' R// Default settings. Used when resetting EEPROM. Change to desired name in defaults.h! w6 Y/ J/ N& p/ W8 P* P0 j  j6 W" w
// 默认设置。在重置eepm时使用。在defaults.h改变想要的名字
( K1 ~; \& I' c1 S4 _* U
- y9 C( t( {& K' n. Z3 _' Z#define DEFAULTS_GENERIC; E9 r, ]- z4 G) ?; I
; Q4 V# H2 Y8 c* a( f8 q- K
// Serial baud rate; n  ]) P" j  d: a5 B7 G
#define BAUD_RATE 115200                //配置串口波特率115200
( Y- o% }; d8 s7 q% o+ T& ^$ Y7 n% Z/ ]
// Default cpu mappings. Grbl officially supports the Arduino Uno only. Other processor types
. H4 @% M4 T/ x; f// may exist from user-supplied templates or directly user-defined in cpu_map.h- Q( M8 h0 n5 m
//默认cpu映射。Grbl正式支持Arduino Uno。其他类型的处理器可能存在cpu_map.h直接从用户提供的模板或用户定义的  U! ^' C! o" V$ }$ g  H6 K$ m5 w
  w) W8 Z# r! z3 N
#define CPU_MAP_ATMEGA328P // Arduino Uno CPU
/ Z: {- W8 C& }1 H( n1 J- a, R2 A& Q! P4 P& e1 b% ~, O- H
// Define realtime command special characters. These characters are 'picked-off' directly from the& H" H6 c$ O1 |; R9 Z9 C. F* T7 D/ C
// serial read data stream and are not passed to the grbl line execution parser. Select characters  B6 i' G( M* Q1 w$ y
// that do not and must not exist in the streamed g-code program. ASCII control characters may be
  D( d( ]) b/ B, @' c% t* I2 H// used, if they are available per user setup. Also, extended ASCII codes (>127), which are never in
) j; P, m; v- T* x// g-code programs, maybe selected for interface programs.% O% B( ?, ^$ @1 c
// NOTE: If changed, manually update help message in report.c.
5 t6 x$ b! t+ L# B' ?: b
: L7 m) Y/ D% h9 V' U//定义实时命令特殊字符。这些字符是直接从“各个击破”串口读取数据流并没有传递到grbl行执行解析器。选择角色5 B( }# ?% c3 {: E" B7 e% L
//不,不能存在于程序流刀位点。ASCII控制字符
8 |9 x. `3 s% l$ C1 p/ R! I2 G//使用,如果他们是可用的每个用户设置。同时,扩展的ASCII码(> 127),从来没有1 P5 x8 @5 d- |* l+ P7 _' w
//刀位点的程序,也许选择界面程序。
% m7 E  w2 ^' L( u7 H9 c//注意:如果改变,手动更新report.c帮助信息。& t! o8 _& S" O0 _& T
. j7 I, s: L3 z' k8 R0 j
#define CMD_STATUS_REPORT '?'
" W/ R7 |7 _. _# f# @#define CMD_FEED_HOLD '!'
" J) w% E* V- c$ G0 p9 V#define CMD_CYCLE_START '~'
/ y* k0 P/ b/ r5 r' @/ R1 U. f' z* ?#define CMD_RESET 0x18 // ctrl-x.. e' v9 ?. S& G' h1 E: Z
#define CMD_SAFETY_DOOR '@'
9 X$ z! G+ R* a' [# _, h3 p& l8 X$ v
// If homing is enabled, homing init lock sets Grbl into an alarm state upon power up. This forces
; j8 t* h# t# ]: Y// the user to perform the homing cycle (or override the locks) before doing anything else. This is! s! S2 F5 Y! E( H0 W
// mainly a safety feature to remind the user to home, since position is unknown to Grbl.
- v6 \) C1 z$ N7 L+ ~( h
. d4 X1 {" y) [/ L//如果启用了回原点,导航初始化锁集Grbl进入警报状态启动。这就迫使+ s0 ?' H' `1 ]' `4 P7 o4 C" j$ _
//用户执行归航周期(或覆盖锁)在做任何其他事情之前。这是) ?! q+ g  U6 }1 G1 u
//主要安全功能,提醒用户家里,因为Grbl位置是未知的。
1 n; v& p0 q3 [0 [2 Y& x( q" }- g9 R+ ^1 t, \( U/ a
#define HOMING_INIT_LOCK // Comment to disable
6 \8 d) r- p) j! R$ U/ k6 w6 h. m, h
// Define the homing cycle patterns with bitmasks. The homing cycle first performs a search mode
( G( ?( `9 e1 [// to quickly engage the limit switches, followed by a slower locate mode, and finished by a short
/ r. y7 S- O( a' {( ]// pull-off motion to disengage the limit switches. The following HOMING_CYCLE_x defines are executed : b% p- A8 g& |% L% u" |  p, n
// in order starting with suffix 0 and completes the homing routine for the specified-axes only. If
, `0 r7 q7 F! ]- `9 d" f// an axis is omitted from the defines, it will not home, nor will the system update its position.
% Z$ }; P  M) `// Meaning that this allows for users with non-standard cartesian machines, such as a lathe (x then z,# x6 O5 C! H. L2 J: |' j( ]
// with no y), to configure the homing cycle behavior to their needs. & o' f. c. h6 B8 X4 N/ W
// NOTE: The homing cycle is designed to allow sharing of limit pins, if the axes are not in the same
- s8 ?5 `& w- m// cycle, but this requires some pin settings changes in cpu_map.h file. For example, the default homing
# s! ~  C0 x; f4 b; Q9 p// cycle can share the Z limit pin with either X or Y limit pins, since they are on different cycles.
1 w, J  G& l6 o# V. p// By sharing a pin, this frees up a precious IO pin for other purposes. In theory, all axes limit pins
- v9 k; @6 i0 a0 ?; t& y) }// may be reduced to one pin, if all axes are homed with seperate cycles, or vice versa, all three axes
! }- ^, E3 D. i5 @6 k3 @// on separate pin, but homed in one cycle. Also, it should be noted that the function of hard limits
3 O/ ~) m# Z2 h// will not be affected by pin sharing.5 d# b( I3 z% a* Z
//定义导航循环模式的位掩码。归航周期首先执行一个搜索模式
  |! [& W4 N6 Z# i0 l//快速进行限位开关,其次是较慢的定位模式,完成了由一个短
: Y  N# `0 e: y2 \; L//拖出运动脱离限位开关。以下HOMING_CYCLE_x定义执行$ ]4 D. ]  Q, w  |+ u& T. n8 `
//为了与后缀0开始并完成specified-axes只寻的例程。如果
# O! X1 T' Y, P3 s//定义省略一个轴,它会不在家,也不会系统更新它的位置。, h9 j1 y* P3 w. N7 q# \3 H
//意义,这允许用户与非标准笛卡尔的机器,比如车床(x,z,& ?" J+ w1 J: D; {
//没有y),配置导航循环行为对他们的需求。
$ y- ?% f) B; |# `4 a$ |//注意:归航周期允许共享限制针,如果轴不相同' b3 _/ r* C. q+ @
//循环,但这需要一些销设置cpu_map的变化。h文件。例如,默认的导航
- j3 k2 X( g  \% ]' D//循环可以分享Z限位销X或Y限制针,因为它们是在不同的周期。' E0 Y" _) L/ |1 }" N7 n9 T  P
//通过共享一个销,这腾出宝贵的IO销用于其他目的。从理论上讲,所有轴限制别针  |) U: L/ z' K  n
//可能会减少到一个销,如果所有轴与分离周期居住的地方,反之亦然,所有三个轴- `6 u& }6 x& ^
//在不同销,但这时候一个周期。同时,应该注意的是,硬限制的功能) A# j: g, r& R" O+ }- s
//将不会影响销共享。( @$ z$ Z1 o# \
//注意:默认设置为一个传统的硬件数控机器。z轴首次明确,其次是X和Y。
+ W7 ^* g5 z+ n2 i1 h: |  r; c/ N1 X; G; z# b* O
// NOTE: Defaults are set for a traditional 3-axis CNC machine. Z-axis first to clear, followed by X & Y.- o- w; {- s5 \5 |* ?# ]
#define HOMING_CYCLE_0 (1<<Z_AXIS)                // REQUIRED: First move Z to clear workspace. 第一步Z清除工作区。
  p% d- H6 |  g; e7 H; _+ G#define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // OPTIONAL: Then move X,Y at the same time.然后X,Y在同一时间。9 a, U5 I9 s* |* P9 B
// #define HOMING_CYCLE_2                         // OPTIONAL: Uncomment and add axes mask to enable* c* |& D2 |3 ?* d
0 S! s1 y' N- V: _( j- U" }
// Number of homing cycles performed after when the machine initially jogs to limit switches.
2 }2 r' n- P8 P- T/ S// This help in preventing overshoot and should improve repeatability. This value should be one or
4 [, y( t9 o; m- \  F// greater.2 `% R) @- g4 H4 |8 T3 u& o9 D
//执行回原点循环次数后,当机器最初慢跑限位开关。这个帮助防止过度,应该提高重复性。这个值应该是一个或大。
* X- w* ]) N' `# _2 d! l7 u9 Q. i( p7 ^! _# `7 {' S
#define N_HOMING_LOCATE_CYCLE 1 // Integer (1-128)
7 D& B* \. ?" R3 J4 n( ~- m  k
) v3 t, c; d) O3 j. W// After homing, Grbl will set by default the entire machine space into negative space, as is typical* S8 H# p. D, N) G. P. v
// for professional CNC machines, regardless of where the limit switches are located. Uncomment this ; E2 c2 u6 g9 l1 U- M
// define to force Grbl to always set the machine origin at the homed location despite switch orientation.
8 k  L4 u& G' S. L' f3 a+ y8 C; l. Q8 \1 o3 P7 i
//导航后,默认Grbl将整个机器空间留白,是典型的专业数控机器,不管限位开关所在的地方。
" H; l' L& X3 A$ l* c//取消这定义迫使Grbl总是在这时候位置设置机器原点尽管开关方向。' D6 }- n5 `2 ?8 _4 C

/ J' w# {" z; r# H7 k// #define HOMING_FORCE_SET_ORIGIN // Uncomment to enable.
# I- v0 J, c5 x, F* h* D3 s9 C5 c" Q9 L) C9 l6 d
$ Q2 c0 Y" z2 F) M% g0 t0 }5 i
// Number of blocks Grbl executes upon startup. These blocks are stored in EEPROM, where the size2 @: ^' R1 s- ?. v% X
// and addresses are defined in settings.h. With the current settings, up to 2 startup blocks may
. _+ B9 S* q% M: z$ F7 Y5 }/ c0 L6 z// be stored and executed in order. These startup blocks would typically be used to set the g-code0 Q# j8 v) y! N1 c
// parser state depending on user preferences.% e7 u# W& w. W* H/ ]/ ?% u

! i) y5 ~: V1 s3 i! o//块Grbl启动时执行的数量。这些块存储在eepm,大小5 }( M, c% T1 C6 e
//和地址在settings.h中定义。与当前设置,可能2启动块
0 R0 H% s/ ?3 \% }& e//存储和执行。这些启动块通常被用来设置刀位点
7 {  O- |! D! ~% k6 z//解析器的状态取决于用户首选项。6 P! w' J. ?0 T7 o

" V: ^6 ?. M; k+ s5 i: g! i& K#define N_STARTUP_LINE 2 // Integer (1-2)
- b8 W/ k+ C* M9 q! b, U2 `! A
# j+ M0 e) r" L! Q1 c* N// Number of floating decimal points printed by Grbl for certain value types. These settings are ( v8 x1 A$ L$ |9 n; o! k: y) i* _
// determined by realistic and commonly observed values in CNC machines. For example, position
) W# ], X1 Q. ^9 x5 P// values cannot be less than 0.001mm or 0.0001in, because machines can not be physically more  S4 O$ v2 _# r1 L2 L
// precise this. So, there is likely no need to change these, but you can if you need to here.
. o/ @# p6 L8 {$ l# S9 O// NOTE: Must be an integer value from 0 to ~4. More than 4 may exhibit round-off errors.  g# a$ w$ R8 U& x' i
6 Q+ C. k, V, n/ ^  r. r& ]! g& m
// Grbl浮动小数点的数字印刷的特定的值类型。这些设置是; ]; o! n8 J0 p/ m+ x
//一般由现实和观测值在数控机器。例如,位置* ^# z  x4 s% @0 `
//值不能小于0.001毫米或0.0001,因为机器不能身体更多
: q, y! b. y2 |4 m//精确。因此,有可能不需要改变这些,但你可以在这里如果你需要。
: Z- F1 l) [8 y5 I# s0 Q7 ~//注意:必须是一个整数值从0 ~ 4。超过4可能出现舍入错误。( ]+ R; T7 y; u- g. W) x* z

2 p- j* H# X. V- W6 u#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 协调或位置价值英寸
1 Z3 `) [6 g: ~8 ?/ h#define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 协调在毫米或位置价值3 {; D6 p* U6 a2 [" q. I
#define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分钟的速度值; C0 d8 m  y9 `) _) k, I, q
#define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分钟/ G" i' g" `% \) m$ P6 b+ H, n
#define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 对浮点小数设置值) v5 ^% ?. G6 e% V0 [  _

$ V3 P: A7 C0 U7 y" |, ]8 ^* Y// If your machine has two limits switches wired in parallel to one axis, you will need to enable5 k+ N+ e2 c' m* ?, p
// this feature. Since the two switches are sharing a single pin, there is no way for Grbl to tell
) ^& k' S6 f5 Y8 c8 i/ w// which one is enabled. This option only effects homing, where if a limit is engaged, Grbl will ; G" j4 [7 @2 Q7 G- O8 q
// alarm out and force the user to manually disengage the limit switch. Otherwise, if you have one9 k- V. G" ~/ p: C5 O
// limit switch for each axis, don't enable this option. By keeping it disabled, you can perform a
# U  B4 g) u  `// homing cycle while on the limit switch and not have to move the machine off of it.
) l# P7 [1 h' o9 n
3 j- o* s( [5 _' S# V5 v3 \: I& m//如果你的机器有两个极限开关连接在平行于一个轴,您需要启用
. G7 x6 Z7 t( P& w//这个特性。自从两个交换机共享一个销,没有办法Grbl告诉3 m  D' O) L8 m6 n# z( b# a- k
//启用哪一个。此选项仅影响归航,如果限制,Grbl意志' }/ z& {6 Z0 @8 Z6 R7 Z! D
//报警,迫使用户手动松开限位开关。否则,如果你有一个$ P9 H2 l9 C) h  U% @
//为每个轴限位开关,不启用该选项。通过保持禁用,您可以执行4 _* |1 D) u3 i4 z
//导航循环在限位开关并没有将这台机器。% D! v$ G8 v# b7 k
5 K* p  |& I% k
// #define LIMITS_TWO_SWITCHES_ON_AXES3 {! S1 b. [2 w; W$ K6 _9 X) n2 t, P

# k9 {8 g5 t1 T! z: ]// Allows GRBL to track and report gcode line numbers.  Enabling this means that the planning buffer, _% l, v. c  O
// goes from 18 or 16 to make room for the additional line number data in the plan_block_t struct
7 i- t; l, {& Q* m* c7 Z
  h: w5 r+ X6 a1 m. v% l& ]' F, ?//允许GRBL跟踪和报告gcode行号。使这意味着计划缓冲从18岁或16岁,为额外的行号plan_block_t结构中的数据+ Z0 _% b$ {0 O6 j9 j& u# ^5 A3 n
; Q1 o# h7 r% ~
// #define USE_LINE_NUMBERS // Disabled by default. Uncomment to enable.
( o$ n# d7 F9 x5 j) e8 v7 L* s) _8 k; i3 j
// Allows GRBL to report the real-time feed rate.  Enabling this means that GRBL will be reporting more . O/ n/ S0 T/ }  k9 R& e! R
// data with each status update.
! s; G* l7 G! Q6 @// NOTE: This is experimental and doesn't quite work 100%. Maybe fixed or refactored later., Z; F/ j" X$ M! V8 |$ Z
//允许GRBL报告实时进给速率。使这意味着GRBL将报告数据和状态更新。
& Z: ?* T$ d4 t//注意:这是实验和100%没有工作。也许以后固定或重构。
  J; G- C, C( \
0 W3 @7 f& W) q& h$ ]. _// #define REPORT_REALTIME_RATE // Disabled by default. Uncomment to enable.$ \& l+ Y" m' }% y9 q, a. G* F

0 d$ z  t" w, `// Upon a successful probe cycle, this option provides immediately feedback of the probe coordinates) u0 l6 D) z" I- |' t
// through an automatically generated message. If disabled, users can still access the last probe
8 I' Q. G! `: s// coordinates through Grbl '$#' print parameters.
" J: R# O" |2 S9 S//在一个成功的调查周期,这个选项提供立即反馈的探测器坐标
* N) a% ~. }* \, q) x/ w4 r3 l9 C//通过一个自动生成的消息。如果禁用,用户仍然能够访问调查/ h$ m( R6 I6 Z+ Z% v; O9 R$ U0 p
//坐标通过Grbl $ #的打印参数。* w7 B& A1 q. N* \. k3 C
: C2 q! B  h7 i/ l$ H9 a1 X
#define MESSAGE_PROBE_COORDINATES // Enabled by default. Comment to disable.+ H7 P6 p$ X4 f' M; Z: [; g

0 B) J7 K4 L+ @( Y& W+ D// Enables a second coolant control pin via the mist coolant g-code command M7 on the Arduino Uno4 l) J! T& `; R
// analog pin 5. Only use this option if you require a second coolant control pin./ H) [9 v. ^- U, \
// NOTE: The M8 flood coolant control pin on analog pin 4 will still be functional regardless.' E  E  Y% O0 x! ~, t* |  G: b
// #define ENABLE_M7 // Disabled by default. Uncomment to enable.! @4 L  K! {' x1 L+ `

+ h) i% B. [. o% j5 b// This option causes the feed hold input to act as a safety door switch. A safety door, when triggered,2 {. f) R: _* P# m( @
// immediately forces a feed hold and then safely de-energizes the machine. Resuming is blocked until! @/ n  H9 @) ~, j+ Z8 J
// the safety door is re-engaged. When it is, Grbl will re-energize the machine and then resume on the! ^3 p* ~. n" H& X! @$ K, l% K
// previous tool path, as if nothing happened.
8 X, Z! [" W+ e, h& M! F// #define ENABLE_SAFETY_DOOR_INPUT_PIN // Default disabled. Uncomment to enable.2 M5 o$ N/ e6 @0 C2 h
1 ^9 k4 k8 o( x2 z; i- V
// After the safety door switch has been toggled and restored, this setting sets the power-up delay
/ Z5 G. i. w* D, u* p  I// between restoring the spindle and coolant and resuming the cycle.
: G$ e" s! o; v5 U* e* n; \0 r1 d// NOTE: Delay value is defined in milliseconds from zero to 65,535.
& q# B& `( q2 U1 B7 S$ M0 p. n. n/ `/ N- s7 o8 u0 H$ g& `) o
//定义导航循环模式的位掩码。归航周期首先执行一个搜索模式- {( f+ Q+ i6 c6 P% n
//快速进行限位开关,其次是较慢的定位模式,完成了由一个短, d- d5 f; y$ _2 ~" ~6 F& ^) R
//拖出运动脱离限位开关。以下HOMING_CYCLE_x定义执行: r' \3 Q1 `  T) Q
//为了与后缀0开始并完成specified-axes只寻的例程。如果6 T* z& d  p, ~1 m* l
//定义省略一个轴,它会不在家,也不会系统更新它的位置。1 `6 Q, ?- Y9 O( T
//意义,这允许用户与非标准笛卡尔的机器,比如车床(x,z,8 h6 W6 h+ a# y, D! q
//没有y),配置导航循环行为对他们的需求。
+ q% F7 r+ s9 g' a8 n; q) M7 ?//注意:归航周期允许共享限制针,如果轴不相同
/ I5 w+ f1 V7 x( |' H//循环,但这需要一些销设置cpu_map的变化。h文件。例如,默认的导航
( G4 l# t/ a( Y2 _7 G//循环可以分享Z限位销X或Y限制针,因为它们是在不同的周期。
; ^( i2 O9 W  t* I& F. p//通过共享一个销,这腾出宝贵的IO销用于其他目的。从理论上讲,所有轴限制别针- U, N. l  p3 H% \9 v
//可能会减少到一个销,如果所有轴与分离周期居住的地方,反之亦然,所有三个轴/ h9 C. [1 {" O% w% V
//在不同销,但这时候一个周期。同时,应该注意的是,硬限制的功能& `5 _" {- z( u  l: j1 [  M
//将不会影响销共享。
9 F  q8 |# X6 q: D" T9 w# [5 p, C//注意:默认设置为一个传统的硬件数控机器。z轴首次明确,其次是X和Y。8 p* M2 J& X' P) v. g
# f/ a, ?' l, ^9 @  L5 N

# e& l. F* O4 k7 }& C. T#define SAFETY_DOOR_SPINDLE_DELAY 4000+ d$ Q+ B( g$ v6 `/ T% {" E
#define SAFETY_DOOR_COOLANT_DELAY 10007 t2 O6 B2 k4 Y8 D9 ~# S

  `$ S8 h8 c  _: j$ |// Enable CoreXY kinematics. Use ONLY with CoreXY machines.
. m% G7 o' {4 \# X- A/ V( g/ ~& s5 J// IMPORTANT: If homing is enabled, you must reconfigure the homing cycle #defines above to
0 `6 D) f4 m0 R: t$ ]6 _3 W//启用CoreXY运动学。只使用与CoreXY机器。
7 M! |. N2 f8 Y* w//重要:如果启用了自动寻的,你必须重新配置导航循环#定义上面# Y+ H6 y# B6 |- S8 ^1 G" W2 Q2 ~. o
. Q) f- f% j! E! j
// #define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS)
5 |/ Q0 c2 q4 g% m4 T# @- O
  L8 |; L/ s* G; M" D7 o- ?, B// NOTE: This configuration option alters the motion of the X and Y axes to principle of operation7 y5 [9 Y- Y/ k; r2 J
// defined at (http://corexy.com/theory.html). Motors are assumed to positioned and wired exactly as
) F2 e; C8 q* w5 ?// described, if not, motions may move in strange directions. Grbl assumes the CoreXY A and B motors
! y# S2 g) `  z% d% ^// have the same steps per mm internally.
5 {* m6 g2 m7 p) s0 l//注意:这种配置选项改变X和Y轴的运动原理,操作
4 l) U7 x- t9 x( m% n* A6 M//定义(http://corexy.com/theory.html)。汽车被认为定位和连接一样9 l0 T% i% E) Q2 I0 Y  K2 q& l+ j
//描述,如果没有,运动可能会奇怪的方向移动。A和B Grbl假设CoreXY马达" C  r" w5 Z# ^& a6 d
//每毫米内部有相同的步骤。4 x) w  T' J3 A6 x8 G
$ @: e6 h  k( @0 j9 q4 u8 D# F3 J( L
// #define COREXY // Default disabled. Uncomment to enable., g! L& m5 `' ]. x# l. T

+ P& y% ^: H: K6 P$ G3 R4 t# z// Inverts pin logic of the control command pins. This essentially means when this option is enabled8 l! |8 h+ j. j+ z$ R
// you can use normally-closed switches, rather than the default normally-open switches.
" S( K7 l/ f# b% C- j. r// NOTE: Will eventually be added to Grbl settings in v1.0.! V' l7 p) d# d5 @  `& a. H
//反转针销逻辑的控制命令。这实质上意味着当启用这个选项1 {% u5 I" M2 C, w) a5 U- D
//可以使用闭合开关,而不是默认的常开开关。
( X3 X- C+ z3 k$ S//注意:最终将被添加到在v1.0 Grbl设置。' x# N. C$ y5 S; y/ H5 G# |
0 @7 j& Y4 R, y+ a
// #define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.
' ^) c- A! y9 T# r4 w* l. ^
% X% m/ k  k4 P// Inverts the spindle enable pin from low-disabled/high-enabled to low-enabled/high-disabled. Useful
% ^& a7 e2 W3 A- _  l# ?// for some pre-built electronic boards.$ s/ i% i: e3 b: ]3 e/ M
// NOTE: If VARIABLE_SPINDLE is enabled(default), this option has no effect as the PWM output and + o. [4 H5 t1 E; c2 y8 w" m1 h9 Y
// spindle enable are combined to one pin. If you need both this option and spindle speed PWM,
( L3 x1 d! N& A, E: f7 s! _// uncomment the config option USE_SPINDLE_DIR_AS_ENABLE_PIN below.
: R" v2 m0 M4 U- X5 f2 d* G//反转主轴使销从low-disabled / high-enabled low-enabled / high-disabled。有用的
/ U+ u, o" e; Q- W# j3 k8 t  Y//预构建的电子板。
& y) E1 l; w2 Z, }. d7 o//注意:如果启用了VARIABLE_SPINDLE(默认),这个选项作为PWM输出并没有影响  {  _4 K! G0 |' m. g/ G
//销轴使结合。如果你需要这个选项和主轴转速PWM,
( ?/ u: o' S. R3 b- Q* G# }" M//取消注释以下配置选项USE_SPINDLE_DIR_AS_ENABLE_PIN0 P5 w- N! K& Z! Y6 b$ H/ d

0 c# B! v) K' s+ O// #define INVERT_SPINDLE_ENABLE_PIN // Default disabled. Uncomment to enable.
" D* i7 z9 u: L% X% P6 s, U
2 n8 R5 j3 \7 M( z// Enable control pin states feedback in status reports. The data is presented as simple binary of
0 i$ j; E- u3 j! p! Z// the control pin port (0 (low) or 1(high)), masked to show only the input pins. Non-control pins on the
6 J+ a1 A- W  `7 h3 X1 e) P// port will always show a 0 value. See cpu_map.h for the pin bitmap. As with the limit pin reporting,% g7 _+ j2 Z4 G3 D
// we do not recommend keeping this option enabled. Try to only use this for setting up a new CNC.# M- ?* w5 B4 E/ D* e1 ?& [
//启用控制销状态反馈状态报告。作为简单的二进制数据
4 m/ t; {+ R  Z6 v! J//控制针端口(0(低)或1(高)),蒙面,只显示输入插脚。非控制性针上
: a# [& X2 S1 P, {; c# i; M//端口总是显示0值。看到cpu_map。针位图h。与限制销报告,
  e1 V* `* V1 F1 H) P: \: o//我们不推荐保持启用这个选项。尽量只使用这个设置一个新的数控。3 p" ?8 [) ^) K8 c% i
; k1 c+ U" {; T
// #define REPORT_CONTROL_PIN_STATE // Default disabled. Uncomment to enable.: E6 y+ @2 t1 _( I0 [/ z# ^2 N
9 A, b: w: d9 a" t2 v
// When Grbl powers-cycles or is hard reset with the Arduino reset button, Grbl boots up with no ALARM9 X  m) j5 @) M1 W5 y7 d
// by default. This is to make it as simple as possible for new users to start using Grbl. When homing  q! F) ]; j  C  l
// is enabled and a user has installed limit switches, Grbl will boot up in an ALARM state to indicate
! ^+ j# h7 o' ~% P+ _// Grbl doesn't know its position and to force the user to home before proceeding. This option forces3 N+ x: Y8 ]& Z0 H8 m9 E- W
// Grbl to always initialize into an ALARM state regardless of homing or not. This option is more for  ]9 @: v& ?$ j$ l1 v
// OEMs and LinuxCNC users that would like this power-cycle behavior.9 P/ L/ {# @8 U8 K9 j- W
//当Grbl powers-cycles还是硬重置Arduino复位按钮,Grbl启动没有报警8 W$ T% m- [. j: R
//默认情况下。这是为了让新用户尽可能简单使用Grbl开始。当归航/ Y  {* R" ]) x1 i% S# }* L
//启用和用户安装限位开关,Grbl将启动报警状态指示& {4 M/ A8 E$ Z: ]
// Grbl不知道它的位置,迫使用户在继续之前回家。这个选项部队
/ U: _9 A2 I( C- J+ i) U7 ^// Grbl总是初始化进入警报状态不管归航。这个选项是更多. V9 e4 A0 l3 p5 F/ w  S
//原始设备制造商和LinuxCNC用户这样的控制行为。" c. I0 z5 y  z

  T8 ?$ w% r9 m" L' z' F// #define FORCE_INITIALIZATION_ALARM // Default disabled. Uncomment to enable.. F( m# O. g# Q+ {3 m6 @; h
! B4 s4 O5 T) ~" I: `
// ---------------------------------------------------------------------------------------% m& H* ?4 T7 f& X9 w- u5 s* |
// ADVANCED CONFIGURATION OPTIONS://高级配置选项:
" q  i( d) [7 \7 @
" ^: x6 k0 Y0 M9 c1 {! J; i* s4 m& A7 r// Enables minimal reporting feedback mode for GUIs, where human-readable strings are not as important.& ~  j5 x! x5 f* ^# h6 Y! @
// This saves nearly 2KB of flash space and may allow enough space to install other/future features., f8 \8 o- `5 f4 J7 \+ E; Z
// GUIs will need to install a look-up table for the error-codes that Grbl sends back in their place.
2 x6 k1 d2 S& h9 `7 p// NOTE: This feature is new and experimental. Make sure the GUI you are using supports this mode.
9 G+ u: |( w, f/ x- M3 W# n* s6 Y
// gui允许最小的报告反馈模式,人类可读的字符串在哪里不重要。
$ l! C- U( ]8 N( ~& s( q//这个节省近2 kb的闪存空间,允许足够的空间来安装其他/未来的功能。: S* W1 i2 Z4 \! Y' |2 s/ J8 U
// gui需要安装一个查找表的错误代码Grbl发回。! I7 k' z5 m* {' s; r
//注意:此功能是新的和实验。确保您使用的GUI支持这种模式。
/ o) G9 U* c5 h) K% s6 w$ X) L+ m) i
# G* p4 L# D0 s# H// #define REPORT_GUI_MODE // Default disabled. Uncomment to enable.
$ }% A& ?0 ?& K! J: h
0 b" f; ]3 U/ a// The temporal resolution of the acceleration management subsystem. A higher number gives smoother5 Q. t1 r2 b3 g8 x( a
// acceleration, particularly noticeable on machines that run at very high feedrates, but may negatively
8 I# F. I$ r: R$ c, `// impact performance. The correct value for this parameter is machine dependent, so it's advised to* r3 ?2 [5 m, Q4 e% z
// set this only as high as needed. Approximate successful values can widely range from 50 to 200 or more.8 t* \+ B( T) n% g) W: V1 R
// NOTE: Changing this value also changes the execution time of a segment in the step segment buffer.
( u' v* I% @/ i& {- Q1 @// When increasing this value, this stores less overall time in the segment buffer and vice versa. Make
! }- y3 Z5 T, V  f; q// certain the step segment buffer is increased/decreased to account for these changes.5 |3 f, ?6 |# `
//加速度的时间分辨率管理子系统。更多更平稳& E, W2 P) J' P: S
//加速度,特别明显的机器上,运行在非常高的进料速度,但可能负面
4 ]2 h. ^/ h8 c- ]$ W+ P8 h# P+ v//影响性能。正确的值为这个参数是依赖于机器的,所以建议$ r( Q8 a# U+ F
//这只设置为高。近似成功的价值观可以广泛的范围从50到200或者更多。
8 d! B& D- O) v# z7 G1 R8 q8 O! b! s" n//注意:改变这个值也变化的部分步骤的执行时间缓冲。
! t% A2 F2 d* n$ I# G//增加这个值时,这个商店部分缓冲区的总时间减少,反之亦然。使
$ I0 `& F# z. Q0 _3 H2 r) Y, b//特定步骤段缓冲是考虑这些变化增加/减少。+ H* X0 H/ R8 x9 L& }$ }5 ~$ `) Z$ M

- Y( }1 q* c1 Z) G8 b#define ACCELERATION_TICKS_PER_SECOND 100  //加速度的时间分辨率管理子系统。更多更平稳
6 e1 _' L# J2 J# Y* V+ x2 p1 T3 }
// Adaptive Multi-Axis Step Smoothing (AMASS) is an advanced feature that does what its name implies,
; L, F) O+ t3 [1 q7 c( }// smoothing the stepping of multi-axis motions. This feature smooths motion particularly at low step! r! i5 Y& l( N2 O0 g0 y- b3 J
// frequencies below 10kHz, where the aliasing between axes of multi-axis motions can cause audible
' S3 y0 t, A8 g// noise and shake your machine. At even lower step frequencies, AMASS adapts and provides even better
# |, P1 D% H1 z; l) U- X% f0 M// step smoothing. See stepper.c for more details on the AMASS system works.
8 q0 \, R8 S9 g0 H# a- ], E//自适应多轴步平滑(积累)是一种先进的功能,它的名字所暗示的那样,
+ y: B% S$ K$ M//平滑的多轴步进运动。这个特性平滑运动尤其是在低一步1 i6 N2 U# a* P
//频率低于10 khz,轴之间的混叠的多轴运动可能导致音响6 |! }' A) N6 |& T
//噪音和震动你的机器。在更低的频率步,积累适应并提供更好/ F+ m, @. b/ \" g
//步骤平滑。看到步进。c更多细节的积累系统的工作原理。; V" Q* y: c# A. _& ]: W# J' o  H' R

$ e* M0 V( Y/ w8 G2 O' S2 z. m#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING  // Default enabled. Comment to disable.//自适应多轴步平滑
0 ]% C  C5 J, }3 Y6 `' S# \4 N3 J2 o; j& n# W5 {4 v+ i
// Sets the maximum step rate allowed to be written as a Grbl setting. This option enables an error : F  I: p3 ~5 B
// check in the settings module to prevent settings values that will exceed this limitation. The maximum" M8 y( @& D  Z  q2 x
// step rate is strictly limited by the CPU speed and will change if something other than an AVR running
/ o6 J8 v) Z, G  _' g7 d3 A// at 16MHz is used.
/ u+ x6 t/ S) O0 c: i+ l, x1 N6 D// NOTE: For now disabled, will enable if flash space permits.$ U4 t4 d$ l* g; D% q
//设置最大一步速率可以写成Grbl设置。这个选项可以使一个错误
1 @  G# ?+ l' K0 X3 p; }2 S/ N( |' m//设置模块中检查,防止设置值将超过这个限制。的最大
0 J% u6 o- x3 S+ k# T- o+ r//步骤严格限制的CPU速度也会改变如果是其他AVR运行" @( R/ e" k" W  `* \
//使用16兆赫。
7 _# o7 O7 I' y. _. g//注意:现在残疾,将使如果flash空间许可。
+ W$ a( ?8 k# a
( B' W) W9 ]7 i# D( w' ?// #define MAX_STEP_RATE_HZ 30000 // Hz 设置最大一步速率$ M" E" q" A' t+ I, b$ l3 N; U

' R) Y( p. T: |7 {" u6 D// By default, Grbl sets all input pins to normal-high operation with their internal pull-up resistors1 U" }& i0 x& H) G
// enabled. This simplifies the wiring for users by requiring only a switch connected to ground, 2 w7 c# _) Z. I7 U6 m2 x
// although its recommended that users take the extra step of wiring in low-pass filter to reduce
) p! j7 R3 V( W4 D/ w// electrical noise detected by the pin. If the user inverts the pin in Grbl settings, this just flips- D$ ~8 E0 i0 Q' J
// which high or low reading indicates an active signal. In normal operation, this means the user
* q1 a& N7 t) W$ O4 V$ T// needs to connect a normal-open switch, but if inverted, this means the user should connect a
. @$ S# x3 i2 H, ^" v// normal-closed switch.
; s* _9 s' N$ Y$ E9 j9 R// The following options disable the internal pull-up resistors, sets the pins to a normal-low ) D6 S0 H+ E7 H! a
// operation, and switches must be now connect to Vcc instead of ground. This also flips the meaning % }4 L! w2 l  C/ o1 b# P5 b
// of the invert pin Grbl setting, where an inverted setting now means the user should connect a
- L6 M- n) S+ \+ Y* Y; W9 k& a// normal-open switch and vice versa.( q9 p! z5 }' N& Q. c- a, Q
// NOTE: All pins associated with the feature are disabled, i.e. XYZ limit pins, not individual axes.
$ q" `+ t* @; T! a  G// WARNING: When the pull-ups are disabled, this requires additional wiring with pull-down resistors!  h, W% r5 b# `
//默认情况下,Grbl所有输入引脚设置为正常高操作的内部上拉电阻
0 F" R( r! K1 f( g3 z  G) R//启用。这简化了布线为用户只需要一个开关连接到地面,# ~' I' R# q2 N" @. P, m
//虽然其建议用户采取额外的步骤,在低通滤波器来减少布线4 ]/ z6 Q. G8 `2 h$ I
//电噪音检测销。如果用户反转的销Grbl设置,这只是翻转
6 B' {6 ]- J8 w+ q  `" }' @//读高或低表明一个积极的信号。在正常操作中,这意味着用户) f' a7 U) z( _0 p
//需要连接一个常开开关,但如果倒,这意味着用户应该连接
/ K$ p; W! g" \) r) G9 Q+ X// normal-closed开关。& g! @" c  w" \5 M) [% V# P% Z
//以下选项禁用内部上拉电阻,一般低设置别针
/ r! e, I0 L3 n//操作,现在开关必须连接到Vcc代替地面。这也掀的意思
) k- ?9 l6 v% D# e# E0 C) |//反销Grbl设置,一个倒置的设置现在意味着用户应该连接2 {' V( s4 P+ N( D9 c
//常开开关,反之亦然。8 C8 e& ^1 r4 M  y$ I# o3 d! W7 o
//注意:所有针与功能被禁用,例如XYZ限制针,而不是单独的轴。8 x7 S8 }& r% ]  I/ _5 A5 I, j
//警告:引体向上被禁用时,这需要额外的布线与下拉电阻!
, E4 v, J! e$ X) W( E* ~4 v- Z2 e* f. p& }  f& o2 o
//#define DISABLE_LIMIT_PIN_PULL_UP //以下选项禁用内部上拉电阻
# K  u# E; }, {5 t& e//#define DISABLE_PROBE_PIN_PULL_UP
' D& J" I5 g& j) L, V* {: }//#define DISABLE_CONTROL_PIN_PULL_UP- A: S" G: M( o( ^3 c, |
  p" t# P* a- c
// Sets which axis the tool length offset is applied. Assumes the spindle is always parallel with , e' E8 X0 z! _6 {% Z; y, b
// the selected axis with the tool oriented toward the negative direction. In other words, a positive. \" f4 ?& n6 G4 z8 o( Z% w
// tool length offset value is subtracted from the current location.
. ^/ X6 X9 a6 |. `6 B; c9 F//设置哪个轴长度补偿应用的工具。假设轴总是与- }5 h' Y3 T3 ^0 b4 \$ ?6 ]1 _
//选择轴工具面向负方向。换句话说,一个积极的, @/ Q: s1 M+ h) o
//工具长度偏移值减去从当前位置。9 z  f, w2 r/ F- D
& B( `! n* d& Q7 u/ f
#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS // Default z-axis. Valid values are X_AXIS, Y_AXIS, or Z_AXIS.设置哪个轴长度补偿应用的工具; J' k% J  E! }* L. F1 q3 y( b, ^' F- }
+ a4 L7 ]& i' V, e4 C3 ^! ^
// Enables variable spindle output voltage for different RPM values. On the Arduino Uno, the spindle6 h& ^$ J; W( V8 W8 M2 v6 @1 e" C
// enable pin will output 5V for maximum RPM with 256 intermediate levels and 0V when disabled.
+ B  e, }: i; F// NOTE: IMPORTANT for Arduino Unos! When enabled, the Z-limit pin D11 and spindle enable pin D12 switch!
2 g7 i# Y" l! X  H7 \8 p5 N: r2 I// The hardware PWM output on pin D11 is required for variable spindle output voltages.6 s  _; }+ D$ ~/ C6 b% O) H
//允许变量轴输出电压不同的转速值。Arduino Uno,主轴
* s$ h( b+ B* r9 O7 c8 j/ B& v//启用销将输出5 v的最高转速256中级水平和0 v时禁用。/ F* X) A/ h# h! E& \2 S
//注意:重要Arduino凯泽本人!当启用时,Z-limit销这里和轴销D12开关!) R! Z: t: V1 g3 T$ S, E
//硬件PWM输出销这里需要变量轴输出电压。# \, f9 v/ G/ I7 Z9 N) x; M- |

- O+ Q4 B# ^$ u0 f1 E! s#define VARIABLE_SPINDLE // Default enabled. Comment to disable.//允许主轴输出电压不同的转速值# B3 L. N2 n1 X' f! f8 x

# s* \) g" I4 M2 P// Used by the variable spindle output only. These parameters set the maximum and minimum spindle speed" R2 g4 a# Y+ A; A1 N
// "S" g-code values to correspond to the maximum and minimum pin voltages. There are 256 discrete and
. \* K8 k0 C6 X4 A// equally divided voltage bins between the maximum and minimum spindle speeds. So for a 5V pin, 1000
' e. H! x; j5 X2 R/ l4 ?// max rpm, and 250 min rpm, the spindle output voltage would be set for the following "S" commands: & D* u5 j, Y& i' X+ Z( y
// "S1000" @ 5V, "S250" @ 0.02V, and "S625" @ 2.5V (mid-range). The pin outputs 0V when disabled.7 @+ u( i0 _' x. s  k
//使用的变量轴输出。这些参数设置最大和最小轴转速
  q' u: D: E3 h//“S”刀位点值对应于销电压的最大值和最小值。有256个离散和4 @5 j6 ?% Q1 j2 h5 [
//电压平均分配箱主轴速度的最大值和最小值之间。所以对于一个5 v销,1000
- w. C( F$ J- }4 [* M* h// max rpm,250分钟rpm,主轴输出电压将为以下“S”命令:
5 M! I1 g4 s5 t, V& ?5 e, I$ N// @“S1000 5 v,“S250”@ 0.02 v,“S625”@ 2.5 v(中档)。销输出0 v时禁用。
3 N* u% e; [& Z2 z7 i2 s( v4 L: c% P& d# |6 i) b7 }2 Q
#define SPINDLE_MAX_RPM 1000.0 // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.
" d8 d' F: @: _: I- }, J) U3 C#define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.
/ K( R' r0 k: q& @0 S9 V( m& |9 c3 r( v, c9 O& h3 x
// Used by variable spindle output only. This forces the PWM output to a minimum duty cycle when enabled.
/ O) T7 D: \1 A& o// When disabled, the PWM pin will still read 0V. Most users will not need this option, but it may be   f) S8 y5 L5 {: h
// useful in certain scenarios. This setting does not update the minimum spindle RPM calculations. Any
6 ?# Z! ^* k+ _: A+ m) E6 }4 F4 }// spindle RPM output lower than this value will be set to this value.3 i! N: e8 }0 J7 G
//使用的变量轴输出。这迫使PWM输出最小占空比时启用。; K/ \2 E2 n, p5 U! `3 z
//当禁用,PWM销仍读0 v。大多数用户不需要这个选项,但是它可能是
% j( A9 B3 q3 M7 u//在某些情况下很有用。这个设置不会更新最小主轴转速计算。任何. U% p, Y( I" d  o
//输出轴转速低于这个值将被设置为这个值。
$ g- W+ s, G, ~& ]
8 v5 K5 v' k  \7 [+ c// #define MINIMUM_SPINDLE_PWM 5 // Default disabled. Uncomment to enable. Integer (0-255)
* m  U( ?- w6 R) r  u: B/ D0 e; D- o$ Q
// By default on a 328p(Uno), Grbl combines the variable spindle PWM and the enable into one pin to help
1 p4 g" l0 u- F2 J# P6 q3 k( E// preserve I/O pins. For certain setups, these may need to be separate pins. This configure option uses
' p# X0 f# w4 N$ ~& P# t+ z// the spindle direction pin(D13) as a separate spindle enable pin along with spindle speed PWM on pin D11.
5 p$ `* P$ c7 g" S  Q" O. U// NOTE: This configure option only works with VARIABLE_SPINDLE enabled and a 328p processor (Uno).
0 f" \' g- D7 j) d0 \// NOTE: With no direction pin, the spindle clockwise M4 g-code command will be removed. M3 and M5 still work.9 q! h5 y- @) r. K' y
// NOTE: BEWARE! The Arduino bootloader toggles the D13 pin when it powers up. If you flash Grbl with+ a( x; M: S1 W
// a programmer (you can use a spare Arduino as "Arduino as ISP". Search the web on how to wire this.), 6 L* o9 d, n6 o
// this D13 LED toggling should go away. We haven't tested this though. Please report how it goes!+ L; _' e) k; k5 v0 c
//默认ATmega328 p(Uno),Grbl结合变量轴PWM和使到一个销的帮助
" g1 o" U7 K( C//保存I / O管脚。对于某些设置,这些可能需要单独的别针。这个配置选项使用
3 A( ~4 g+ z/ T" u0 i( P//方向轴销(D13)作为一个单独的轴销上启用销以及主轴转速PWM这里。
* ~3 w1 U( C; J0 Q5 B//注意:该配置选项仅适用于VARIABLE_SPINDLE启用和328 p处理器(Uno)。+ Z: d0 H! S$ N8 g1 O( O
//注意:没有方向销,主轴顺时针M4刀位点命令将被删除。M3和M5仍然工作。* C) }! b0 e+ G) A8 Z. \& q  {' @
//注意:小心!Arduino引导装载程序切换D13销的权力。如果flash Grbl  B& f  l* R; P& X5 K
//程序员(您可以使用一个备用Arduino“Arduino ISP”。搜索网络如何线),
3 C4 I& |$ _+ f. o. i+ l" i//这D13导致切换应该消失。我们还没有测试这个。请报告将会怎样!
) S. G. C% I; C4 [  K% M3 h' W; Y- v- c
// #define USE_SPINDLE_DIR_AS_ENABLE_PIN // Default disabled. Uncomment to enable.
0 ~2 ~, @! z3 h  v) s7 @% U; i$ w: m" V
// With this enabled, Grbl sends back an echo of the line it has received, which has been pre-parsed (spaces  g" a/ E: r" K! l: y5 n% b
// removed, capitalized letters, no comments) and is to be immediately executed by Grbl. Echoes will not be
0 o6 B, C9 Y# g. P  {' b; p// sent upon a line buffer overflow, but should for all normal lines sent to Grbl. For example, if a user
* U% a2 z* ?1 j, g- ^// sendss the line 'g1 x1.032 y2.45 (test comment)', Grbl will echo back in the form '[echo: G1X1.032Y2.45]'.
0 K! n+ O+ d6 h* c- z# F// NOTE: Only use this for debugging purposes!! When echoing, this takes up valuable resources and can effect0 m4 k1 ~! ^6 l! v# {
// performance. If absolutely needed for normal operation, the serial write buffer should be greatly increased
9 h) {! B2 r1 T5 l% r: m, x- D( t// to help minimize transmission waiting within the serial write protocol.
- {( N* l9 @5 s/ t2 i  c
2 N- _5 |# w- u/ }1 n$ ~//启用,Grbl发回的回声线已收到,已预编译(空间
' t) S6 X$ u8 s/ y$ U1 ]0 `2 ]& Y//移除,大写字母,没有评论),由Grbl立即执行。回声将不会* X) I5 O7 q% R/ J
//发送一个线缓冲区溢位,但应该对所有正常线路送到Grbl。例如,如果一个用户" P* ?2 |4 u8 C3 n; F
//发送线的g1 x1.032 y2.45(测试评论)形式”,Grbl将回声”(回声:G1X1.032Y2.45]”。
% Q* R4 V- e9 [+ y  w//注意:只使用这个调试! !当呼应,这占用了宝贵的资源,可以影响7 v8 N9 V' J* ^8 a. x5 m
//性能。如果正常运行所需的绝对,串行写入缓冲器应该大大增加
- y, \- A/ J  u: f" l; f* x//帮助最小化传输等系列内写协议。
1 n& R! Y. U7 O6 @/ U. N* f3 n
// #define REPORT_ECHO_LINE_RECEIVED // Default disabled. Uncomment to enable.; t8 }; H" ?& t. ~! Z3 S8 o; |
8 G% l" k& w5 ]0 v4 e
// Minimum planner junction speed. Sets the default minimum junction speed the planner plans to at
% {$ j/ n; {$ c) p- w0 d& i# G// every buffer block junction, except for starting from rest and end of the buffer, which are always) M+ }# @2 W( |3 r& q
// zero. This value controls how fast the machine moves through junctions with no regard for acceleration: j, e- {% q1 a4 ?  Q( a
// limits or angle between neighboring block line move directions. This is useful for machines that can't& U2 n3 a7 C) v9 K' k4 q
// tolerate the tool dwelling for a split second, i.e. 3d printers or laser cutters. If used, this value
9 e8 ]& F  ?0 ?) i/ F! j7 W// should not be much greater than zero or to the minimum value necessary for the machine to work.8 S# q6 J  z7 B" \; [

) c& k$ v9 E% y5 D# ?$ r, P8 z//最小规划师结速度。设置默认最小连接速度规划计划) y( J' g/ P+ h; g$ {. P) X6 S
//每一个缓冲块接头,除了从结束休息和缓冲区,它总是
. @4 n8 E2 ]2 N. f3 p* m: }// 0。这个值控制机器的速度穿过路口,没有考虑加速度
  P) @2 A. Q. a2 i8 l! \+ s//限制或相邻块之间的角线方向移动。这是有用的机器,不能  P/ A% ?8 `  `* c  }
//容忍工具居住某一刹那,即3 d打印机或激光切割机。如果使用这个值9 e4 g# |0 B( x) E
//不应大于零或机器工作所需的最小值。
2 u/ M5 x4 \" ?! R2 d+ a
) Y- R1 Q2 s$ Y$ S/ k#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min)6 P9 Q  L0 S8 X# G' R% |
! d3 }( W! q9 v7 d: |
// Sets the minimum feed rate the planner will allow. Any value below it will be set to this minimum9 V  }6 I! b! C8 |
// value. This also ensures that a planned motion always completes and accounts for any floating-point
8 j& M; ^% H4 j- l: u& V' y// round-off errors. Although not recommended, a lower value than 1.0 mm/min will likely work in smaller; [# B, ~: B, E8 Y5 K
// machines, perhaps to 0.1mm/min, but your success may vary based on multiple factors.# F) {. g1 Q% g8 y% A. O
//设置计划将允许的最小进给速率。任何价值低于它将被设置为最低值。这也保证了运动计划总是完成,占任何浮点
- n: z! q% e) N" S/ [/ q//舍入错误。虽然不推荐,价值低于1.0毫米/分钟可能会在较小的工作' M; t  Z% R' N
//机器,也许到0.1毫米/分钟,但你的成功基于多种因素可能会有所不同。
+ y4 v8 d0 ~. @6 ^4 ?, y
9 m9 C4 P7 v" `; ^" D' k#define MINIMUM_FEED_RATE 1.0 // (mm/min)//设置计划将允许的最小进给速率9 N4 c1 V, |" W5 a+ r

( ?, l9 @* n$ h8 a$ d+ p, y1 x// Number of arc generation iterations by small angle approximation before exact arc trajectory
( C9 U6 p- k7 `// correction with expensive sin() and cos() calcualtions. This parameter maybe decreased if there ) f- |' G8 E* Q
// are issues with the accuracy of the arc generations, or increased if arc execution is getting
; @" m: Y- o8 i5 b1 W; h// bogged down by too many trig calculations. - b3 ~# ]  H/ t$ _, J1 q! I. Y
//弧生成迭代次数之前小角度近似精确的弧线轨迹
% m; J- c" r) `7 q; w//修正与昂贵的sin()和cos()calcualtions。如果有这个参数可能减少
5 `) Z# c' f* A. r/ \  j//与弧一代又一代的准确性问题,或如果电弧执行得到增加
/ c- m/ t) a& L0 d* U* d  h//太多的三角计算的泥潭。
9 ?; x7 [9 X9 A$ p
: ^, L( g/ n' R# l  R8 T$ L( F* f#define N_ARC_CORRECTION 12 // Integer (1-255)
/ w: a( K6 c0 H! I) ], L4 n- O
: O0 I8 e2 T- _- s0 z// The arc G2/3 g-code standard is problematic by definition. Radius-based arcs have horrible numerical , ~1 J  Y, L, D2 u7 l% z
// errors when arc at semi-circles(pi) or full-circles(2*pi). Offset-based arcs are much more accurate
! {) V* o. i3 i4 G6 p: {$ l+ G/ b// but still have a problem when arcs are full-circles (2*pi). This define accounts for the floating 8 F# \+ y! }) d! v: i7 Y1 ~2 M4 ]# d
// point issues when offset-based arcs are commanded as full circles, but get interpreted as extremely
7 s) q, I6 e: G% f! T% W# i0 Z& C// small arcs with around machine epsilon (1.2e-7rad) due to numerical round-off and precision issues.
, Z+ S) d4 @/ w  J) ^1 [# i// This define value sets the machine epsilon cutoff to determine if the arc is a full-circle or not.6 z6 z- }2 V$ x/ y; u8 @1 c% Y
// NOTE: Be very careful when adjusting this value. It should always be greater than 1.2e-7 but not too, H  [" F# S1 n. p( d! X5 Y
// much greater than this. The default setting should capture most, if not all, full arc error situations.
: g- k1 n9 z7 |. r' k//弧G2/3刀位点的标准定义是有问题的。Radius-based弧有可怕的数值$ N* _# k. N3 p% X
//错误当电弧在半圆(π)或原点(2 *π)。Offset-based弧更准确/ o8 D& c# Q* I+ @( ?9 z' Q
//但仍有一个问题当弧原点(2 *π)。这个定义占浮动) m4 ]  ?* _$ h; j! I' F, v: i
//当offset-based弧吩咐点问题完整的圆,但解释为极
! ~0 q' l2 q3 l: i- T//小弧机周围ε(1.2 e-7rad)由于数字舍入和精度问题。
. f2 v3 y) L) Q0 T! t0 X//定义值设置机器ε截止来确定电弧是一个原点了。0 a' o5 h2 j1 X6 p8 j: _" i) _
//注意:调整这个值时非常小心。它应该总是大于1.2 e -但不要太' W) K; J' v2 m7 S8 i
//比这大得多。默认设置应该捕获大部分,如果不是全部,全部错误的情况。
9 v0 ^8 R3 P; `6 x6 x- u9 K7 `+ k5 g9 v
#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)
' f- m0 G- c: O! P5 e) Z3 n6 V, J+ c8 p# g
// Time delay increments performed during a dwell. The default value is set at 50ms, which provides
! `+ T) H' ~  B/ j1 @4 Q" a, d// a maximum time delay of roughly 55 minutes, more than enough for most any application. Increasing
6 u, A+ n  O# T5 j3 f// this delay will increase the maximum dwell time linearly, but also reduces the responsiveness of
) A' @% u$ @8 ]! A3 A1 [0 H// run-time command executions, like status reports, since these are performed between each dwell 0 g' K. B1 A! a( X; m3 ^0 b1 P
// time step. Also, keep in mind that the Arduino delay timer is not very accurate for long delays./ H! x5 V3 B7 F( j. r5 r  p
//延时增加表现在住。默认值设置为50毫秒,它提供了
. E1 y3 @; B) g$ C, c- T//最大延时约55分钟,足够对大多数任何应用程序。增加4 ?9 u9 D7 M9 c* m5 U, f3 _
//这种延迟将增加线性最大停留时间,也减少了响应能力
1 h" Y, N2 g3 V3 b4 ^//运行命令执行状态报告一样,因为这些每个住之间执行
: W8 W! w  X7 n/ ?8 u1 u& q2 u- \//时间步。还有,记住,Arduino延迟计时器不是很准确的长时间延误。, o% I; ~- _& R# [
3 h3 P3 Y- {% k' w, ^3 A
#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds)  ~+ q1 j& n9 V

6 w0 A" x; F* l8 B& @% d% G// Creates a delay between the direction pin setting and corresponding step pulse by creating2 Y+ O  k1 y- M: ]; p/ D- ]
// another interrupt (Timer2 compare) to manage it. The main Grbl interrupt (Timer1 compare) 8 {" K$ v5 t* i2 O3 a* C
// sets the direction pins, and does not immediately set the stepper pins, as it would in
/ I1 P+ {# q3 w) j. Q// normal operation. The Timer2 compare fires next to set the stepper pins after the step
" ^5 J5 w: e  E0 b// pulse delay time, and Timer2 overflow will complete the step pulse, except now delayed ; b% j, F4 z3 l3 X( G* e& M- T8 ]+ m
// by the step pulse time plus the step pulse delay. (Thanks langwadt for the idea!)
+ @2 W/ U# \1 p// NOTE: Uncomment to enable. The recommended delay must be > 3us, and, when added with the! i+ a. `7 Q- h) L
// user-supplied step pulse time, the total time must not exceed 127us. Reported successful
" h% b' b7 H3 m// values for certain setups have ranged from 5 to 20us.* N  ^/ o1 g# W
//创建一个方向销之间的延迟脉冲通过创建设置和相应的步骤
8 C; s' q7 n" D1 |4 s, w/ c0 M//另一个中断(Timer2比较)来管理它。主要Grbl中断(Timer1比较)1 b3 y9 M  R8 J1 H9 q1 J8 l( ?
//设置方向针,不立即设置步进针,因为它会在
- x5 I& J; |5 i; e, w' g//正常操作。Timer2比较火旁边设置步进针后一步/ D; t3 O! j4 a% [  x
//脉冲延迟时间,Timer2溢出脉冲将完成的步骤,现在延迟除外
( n4 P4 n( \& J  y6 P0 f" l' `//脉冲时间加上的一步一步脉冲延迟。(感谢langwadt主意!)1 |- I0 g7 o- S! G
//注意:取消启用。必须> 3,建议延迟,当添加的
7 _9 ~# p% ]- Z3 g. M  ]//用户提供的步骤脉冲时间,总时间不得超过127美元。成功的报道
, }: O9 ]  _+ S, q1 Y4 F//值对某些设置范围从5到20。
: s8 ^8 w) K" ]  o. |: m% F3 E# Y: H2 j9 U* b8 T
// #define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.
" b7 w8 w- n, H$ K+ l
8 V6 O! N) d3 v1 i( u// The number of linear motions in the planner buffer to be planned at any give time. The vast
- M6 C1 |; }1 C// majority of RAM that Grbl uses is based on this buffer size. Only increase if there is extra
; V0 W1 l7 b5 x* t+ a8 |; U; Z* S// available RAM, like when re-compiling for a Mega or Sanguino. Or decrease if the Arduino
- _: V, V* j( g// begins to crash due to the lack of available RAM or if the CPU is having trouble keeping
3 p. A4 D$ m! r0 e// up with planning new incoming motions as they are executed. 1 c" I, t; {" }: X" Q
//线性运动规划师缓冲区的数量在任何给出时间计划。绝大7 S( o5 u. \4 K* x/ R/ Z( z6 }+ J  ?
//多数RAM Grbl使用基于这个缓冲区的大小。如果有额外的只会增加
3 }; J9 i/ l2 y7 j//可用内存,比如当基于大型或Sanguino。如果Arduino或减少
% I+ k1 u' j; t# Z//开始崩溃由于缺乏可用的RAM或者CPU是难以保持
, R& e5 x3 e0 R$ }! I3 g//与规划新传入的动作执行。$ `0 q% I  L4 n; o: q
! a# z9 K/ j  J/ W: Y
// #define BLOCK_BUFFER_SIZE 18  // Uncomment to override default in planner.h.) H2 ~: e$ w( O7 P5 c" y) r
+ J% d  }% ]" e
// Governs the size of the intermediary step segment buffer between the step execution algorithm
# n  S' Q) J5 Z2 y% }// and the planner blocks. Each segment is set of steps executed at a constant velocity over a
% U# H: e5 H! P& c- m// fixed time defined by ACCELERATION_TICKS_PER_SECOND. They are computed such that the planner/ y' M/ g! [! T1 ~- S3 V) S$ M- E
// block velocity profile is traced exactly. The size of this buffer governs how much step
9 O; y) U2 I3 r( F. _4 F/ l// execution lead time there is for other Grbl processes have to compute and do their thing
' L9 n) n2 }) G; }. G: l+ X// before having to come back and refill this buffer, currently at ~50msec of step moves.
% {/ r; G  {3 a8 w6 z, }//控制之间的中间段缓冲大小的步骤执行算法! j! }$ |4 `1 d+ U
//和规划师块。每一部分的步骤执行在一个恒定的速度
+ n. Y( R# z; @- m" i9 x; O//固定的时间由ACCELERATION_TICKS_PER_SECOND定义的。他们计算的计划$ Q( ]& g0 Y0 G! r( ^: ?. {
//块速度剖面追踪到底。这个缓冲区的大小控制多少步骤
* t0 W: o1 d3 \  g. v  H; c& y//执行时间有其他Grbl过程需要计算和做他们的事情
$ P- i' P  J. {8 T! I//之前必须回来重新填充这个缓冲区,目前移动~ 50毫秒的一步。: g( u/ ?* w" `, L( L  c5 g( c
2 e, [0 Y5 \% R6 F, T6 z4 a
// #define SEGMENT_BUFFER_SIZE 6 // Uncomment to override default in stepper.h." f2 d7 ~6 D: R9 Q8 k& q

. {. F6 p+ z9 D0 ^# i# t6 P' J// Line buffer size from the serial input stream to be executed. Also, governs the size of
" C" ]4 ]1 j) X+ [/ y0 ~// each of the startup blocks, as they are each stored as a string of this size. Make sure
( ~( f7 Z+ M  A. A' J; y8 l/ ^// to account for the available EEPROM at the defined memory address in settings.h and for8 J$ o# U; z8 |4 O. k
// the number of desired startup blocks.& [& ?. b2 k/ E
// NOTE: 80 characters is not a problem except for extreme cases, but the line buffer size ) W: K! N1 E* p9 n
// can be too small and g-code blocks can get truncated. Officially, the g-code standards 3 _( d# n( H$ Q4 K, c
// support up to 256 characters. In future versions, this default will be increased, when
7 n6 G0 M8 i9 n. X) Z- N( V1 g// we know how much extra memory space we can re-invest into this.
8 J5 ^8 ~. V5 l! S* @/ ]. R//行执行串行输入流的缓冲区大小。同时,大小的控制5 a5 @6 |1 i) j
//每个启动模块,它们分别存储为字符串的大小。确保7 I2 t" M5 I6 l: @
//占可用eepm定义内存地址的设置。h和2 L! K% A* H" T7 q
//需要启动块的数量。2 m9 I3 G/ ^; p7 I* c2 a& L
//注意:80个字符不是一个问题,除了极端的情况下,但线缓冲区大小8 ~) f) F" }0 |
//可以太小和刀位点块可以截断。正式,刀位点标准1 _2 ?& J2 j/ w9 [6 t+ Y
//支持多达256个字符。在未来的版本中,这个违约将会增加,当" }5 ?# p% \- y( L
//我们知道多少额外内存空间的时候我们可以再投资。8 ~, J9 X) l. x7 L( I

/ z: X! [2 D: v9 X$ W4 S// #define LINE_BUFFER_SIZE 80  // Uncomment to override default in protocol.h
/ G3 ~% b% ^/ h. I. O! G; w  
' B- s. O# @' o9 m// Serial send and receive buffer size. The receive buffer is often used as another streaming
+ i. \6 F3 p- c// buffer to store incoming blocks to be processed by Grbl when its ready. Most streaming
# t$ o5 s& K; P' `# s// interfaces will character count and track each block send to each block response. So, , T$ i% a. E, ]8 _& }$ H6 g
// increase the receive buffer if a deeper receive buffer is needed for streaming and avaiable5 X4 ^; p" o2 C6 c6 \# }
// memory allows. The send buffer primarily handles messages in Grbl. Only increase if large6 ]* P+ D, @/ D; ^2 n( S) [+ K
// messages are sent and Grbl begins to stall, waiting to send the rest of the message." C: V: O5 ]# K% g9 P8 G' U1 j
// NOTE: Buffer size values must be greater than zero and less than 256.
; D$ p: ^+ x9 b- x/ P// #define RX_BUFFER_SIZE 128 // Uncomment to override defaults in serial.h8 U: Y. p  L+ S
//串行发送和接收缓冲区大小。接收缓冲区通常用作另一个流3 I1 |- @1 S+ k  |
//缓冲存储传入的块来处理Grbl当它准备好了。最流
- }: Z7 w. V% P3 w* `  a% N. Q//接口将字符计数和跟踪每一块发送给每个块的回应。所以,5 w4 E+ n1 K7 P
//增加接收缓冲区如果需要更深层次的接收缓冲区为流,、
* {! a; Q7 L2 O5 f# {1 Y//内存允许。Grbl发送缓冲主要处理消息。只会增加如果大1 q2 l  g# `! g& h$ S/ w
//消息发送和Grbl开始停滞,等待发送其余的消息。" x: _' Z* n- i# S( R2 y
//注意:缓冲区大小值必须大于零,小于256。& Q% E2 s' N2 h3 N% ~& m  v/ w
// # define RX_BUFFER_SIZE 128 / /取消serial.h覆盖默认值
3 e) L$ l# C+ y% r) `5 g0 f; o, F- M$ l- }+ _: L+ D+ x

2 B1 ]' o2 Q, k3 d" U7 d: q// #define TX_BUFFER_SIZE 64
0 ]8 U: n* @) V2 {6 \. a: |2 d& o  
: `$ I: d4 V! i# I// Toggles XON/XOFF software flow control for serial communications. Not officially supported
& B/ d, `4 p6 w6 _// due to problems involving the Atmega8U2 USB-to-serial chips on current Arduinos. The firmware9 O  ^  c0 f, N+ e8 H9 l  ^* n
// on these chips do not support XON/XOFF flow control characters and the intermediate buffer . |9 q" Y" s3 M; `
// in the chips cause latency and overflow problems with standard terminal programs. However, 0 w$ |7 H$ g  F$ G; L5 L
// using specifically-programmed UI's to manage this latency problem has been confirmed to work.
& _0 }# t" Y4 H& f( N/ `$ X// As well as, older FTDI FT232RL-based Arduinos(Duemilanove) are known to work with standard
+ t( L+ ]) I0 Q) v5 T3 f// terminal programs since their firmware correctly manage these XON/XOFF characters. In any7 q% ~, x0 s% k  m
// case, please report any successes to grbl administrators!
1 A7 ^3 A- b% |//切换为串行通信发送朴通/发送葡开软件流控制。不是官方支持$ W# T3 g( s/ _) M4 P
//由于问题涉及Atmega8U2 USB-to-serial当前arduino芯片。固件
, x, x2 w6 `# X. l3 E5 E4 P6 q//在这些芯片不支持发送朴通/发送葡开流控制字符和中间缓冲区5 a& ?) i; J& n5 j9 w5 T
//芯片导致延迟和溢出问题的标准终端程序。然而,
/ r  ?) D" u- A! k5 a//使用specifically-programmed UI的管理这个延迟问题已经确认工作。
4 b- b" S$ f7 r) C7 \* q6 o# X# U//以及老FTDI FT232RL-based arduino(Duemilanove)是已知的标准. X. `4 a3 d, a
//终端程序因为他们正确的固件管理这些发送朴通/发送葡开的角色。在任何
! w5 v1 k. i) e9 ^//情况,请报告任何成功grbl管理员!
8 t* w: b2 g% k$ x0 r3 |
6 l' K/ G) X9 x6 x6 H  e// #define ENABLE_XONXOFF // Default disabled. Uncomment to enable.2 D* Q9 h* t8 ?7 K

% j& j/ S; R8 s% v+ Y$ }; o// A simple software debouncing feature for hard limit switches. When enabled, the interrupt " j% n4 E) v( {/ y) N0 h4 Q, V
// monitoring the hard limit switch pins will enable the Arduino's watchdog timer to re-check ( J" ^- @$ [. ?0 D: f4 L; o# J
// the limit pin state after a delay of about 32msec. This can help with CNC machines with
* R5 ~5 T8 j: Q' I// problematic false triggering of their hard limit switches, but it WILL NOT fix issues with 0 Q6 B: \4 V" b) S( S4 s
// electrical interference on the signal cables from external sources. It's recommended to first
4 H6 ^5 f( p' o// use shielded signal cables with their shielding connected to ground (old USB/computer cables   e. T+ J& J9 R: ~; s3 X
// work well and are cheap to find) and wire in a low-pass circuit into each limit pin.
' x8 Q) j7 N3 j9 v+ U/ l3 M//一个简单的软件消除抖动特性硬限位开关。当启用时,中断
" `/ {; {% U. n' h! ]+ B; m) M3 \//监控硬限位开关针将使Arduino的看门狗定时器重新审视( l+ Z3 w7 \$ O4 A
//销的极限状态后约32毫秒的延迟。这可以帮助与数控机器" v' j4 M  w( Y$ t0 N) [2 j
//问题错误引发的硬限位开关,但是它不会解决问题
( @& [4 r; i- d# @0 L5 g, E: i# W//电干扰信号电缆从外部来源。首先它的建议
# n& G# o6 g! z$ x//使用屏蔽信号电缆的屏蔽连接到地面(老USB /计算机电缆
1 ]+ b4 P! [1 g9 R- I//工作得很好,很便宜)和线低通电路到每个限位销。+ }' @! p; l$ ]( {1 l

3 n, G0 {  J+ Q+ I6 Z2 B// #define ENABLE_SOFTWARE_DEBOUNCE // Default disabled. Uncomment to enable.1 V3 p' B3 F, a0 z0 b
6 H; c/ K% K. N  q; u
// Force Grbl to check the state of the hard limit switches when the processor detects a pin
- W  u* v( r$ y9 `6 }, h6 C3 Y// change inside the hard limit ISR routine. By default, Grbl will trigger the hard limits/ G% v( H! o. m- c& P/ _
// alarm upon any pin change, since bouncing switches can cause a state check like this to   i; N' m4 w! y4 E1 q3 u# @
// misread the pin. When hard limits are triggered, they should be 100% reliable, which is the6 j/ ~& a# P. p6 [  H" c
// reason that this option is disabled by default. Only if your system/electronics can guarantee
8 |3 A. [# o6 Z2 d// that the switches don't bounce, we recommend enabling this option. This will help prevent6 N) v( v/ `2 f! n
// triggering a hard limit when the machine disengages from the switch.  r7 C3 r/ ]% U. C+ l; V6 M. V
// NOTE: This option has no effect if SOFTWARE_DEBOUNCE is enabled.5 A6 u+ O$ w3 T1 ]% G. X4 i1 t1 b
//力Grbl检查硬限位开关的状态,当处理器检测到一个销2 b) z5 o1 L5 B' t$ n
//改变内部硬限制ISR例行公事。默认情况下,Grbl将触发硬限制
% N+ Q# v0 ?* W- J* H" F//报警在任何销更改,因为跳开关可以导致这样的状态检查
8 A- }6 S; h; f# o# b$ d! L; O//误读了销。硬限制触发时,他们应该100%可靠,这是
5 w; q5 E, B! W+ h- X//原因,这个选项默认是禁用的。只有在你的系统/电子产品可以保证& z# O; {# n3 w( p8 M! p$ X+ N8 |, K, W* b
//开关不反弹,我们建议启用这个选项。这将有助于防止4 F( ~9 o4 F0 ?! [1 s
//触发机退出时硬限制开关。
- H; ?8 I! k2 I+ y' Z4 q, y1 _! s//注意:这个选项如果启用了SOFTWARE_DEBOUNCE没有影响。
1 w! I+ S$ o4 I5 [1 h$ U
$ d4 c- z) g) j/ q% ?: @; Q// #define HARD_LIMIT_FORCE_STATE_CHECK // Default disabled. Uncomment to enable.
3 d; |' `( ^$ m6 i1 [& R
% a  Z' C* M5 c5 v* s6 N3 A/ J0 f) z5 ^" w
// ---------------------------------------------------------------------------------------
9 H7 j* y8 ^1 ]3 i// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:编译时错误检查的定义值:$ {& I& _4 A8 C/ [  z

# I: z& x$ }/ E. x! C0 d8 x3 _' t#ifndef HOMING_CYCLE_01 Q( g1 P+ B4 c7 r4 x1 F. ], T1 ]
  #error "Required HOMING_CYCLE_0 not defined."
# w7 B  V( L- x: u/ k#endif
( Z) P4 p# Y& H/ h& e" c0 n& z; e& k# N
#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(VARIABLE_SPINDLE)* H- X; g- c3 L! ]( [/ p8 l# x# t
  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with VARIABLE_SPINDLE enabled"+ j/ |9 R5 g9 ]2 ^4 o4 ?3 P4 W
#endif
& Z$ T- f- E$ C: A* V/ a- w/ f1 P( s
#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(CPU_MAP_ATMEGA328P)4 K3 d" j5 W* [
  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with a 328p processor"
' ~8 b3 [0 _3 L1 k+ a#endif
7 w, D2 r+ U5 v, r
3 k: ]/ D: L2 `) X5 A// ---------------------------------------------------------------------------------------8 H& W* x' U5 ]( m% m
  d6 h& \' f3 w8 ?

2 W  l; t+ P4 Q/ h#endif$ N! ]0 ~: R$ S+ t

" L  A' W" |5 A8 |6 x0 Z% U: E/ Q8 t- d8 l/ A

6 b) B$ Y' w; I6 J
6 l' o/ l% X. X% P2 G. v
, E  M$ d3 F7 A) s" H1 }4 O, Q0 w: W7 h3 i, K1 t. I

, N6 r! V; X$ E+ L0 k2 o2 P
6 v: n. e9 Q5 N! p- o2 V; `% `9 A7 D1 K6 ?0 \
6 M8 \  D# Q/ q  O8 I: ~% f
7 |) V9 T8 X$ G$ f9 ?# K8 Q

2 S$ H% m4 S2 t1 w5 e: K; L: I  T7 v7 V. X
' d4 ~" o2 C$ g: D" P  v6 K
9 {& I9 V# Q6 R) `

# X  Q6 g; @2 o

本帖子中包含更多资源

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

x

评分

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

查看全部评分

回复

使用道具 举报

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

使用道具 举报

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

! ]' _# o6 c9 c, ^' L3 G
回复 支持 反对

使用道具 举报

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

使用道具 举报

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

使用道具 举报

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

使用道具 举报

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

使用道具 举报

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

使用道具 举报

 楼主| 发表于 2016-8-23 23:03:17 | 显示全部楼层
补充. D: P* y9 g% J) [* c5 r  H
程序运行protocol_execute_realtime(); /运行实时命令。
$ [% q% C# f; y* R// Executes run-time commands, when required. This is called from various check points in the main; e9 |) D, ~& `* }2 \3 v1 k
// program, primarily where there may be a while loop waiting for a buffer to clear space or any3 Y/ f8 }+ n) U! i5 w# P
// point where the execution time from the last check point may be more than a fraction of a second.
# t9 X  {+ p: t/ s# F// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code9 t* h7 [6 o( d) h9 @
// parsing and planning functions. This function also serves as an interface for the interrupts to # W3 L0 M. O' [( V- D& k! E4 U9 Y
// set the system realtime flags, where only the main program handles them, removing the need to' V# p% R; v) A4 K* G
// define more computationally-expensive volatile variables. This also provides a controlled way to
) O: z; U2 S& Q9 `( q// execute certain tasks without having two or more instances of the same task, such as the planner$ R( l- x/ q( S% K+ {3 `% w
// recalculating the buffer upon a feedhold or override.: L- q/ K' z1 K  N% [
// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,% h: T8 S1 {7 G) w& c# W
// limit switches, or the main program.
$ E4 U, I" o; Q5 L9 k" A& }/ {# Q* F& X% S6 `( m
//执行运行时间命令,在需要时。这就是所谓的从各种主程序要检查站
. j) y8 d* L3 z3 G$ z//,主要是那里可能是一个while循环等待缓冲区空间或任何8 R' f* d7 Q4 c* u
//执行时间从过去的止点可以超过几分之一秒。+ V# \# b. @- _6 t/ l
//这是一种异步执行实时命令(又名多任务)grbl的刀位点
5 S& E" |- X1 Y! F/ n0 y1 F//解析和规划功能。这个函数也可以作为一个接口,用于中断0 p; X+ W& U" R* ], |
//设置系统实时的旗帜,只有主程序处理,消除的需要; b# u& P% R" ~& k9 ~
//定义更多的计算昂贵volatile变量。这也提供了一种控制方法- {: ]  T% ~' R: ^  f% k/ E& t
//执行某些任务不相同的两个或多个实例的任务,比如计划
/ @7 I+ t; l& ?+ g$ T//重新计算缓冲feedhold或覆盖。
5 P7 I. J: |3 w- G//注意:sys_rt_exec_state变量标志设置任何过程,步骤或串行中断,插脚引线,' U& ?( }& V) E8 C
//限位开关或主程序。: Y, {, V( M% C) q
void protocol_execute_realtime()3 b9 l, w8 ~# x2 R+ p: @( k0 x( d
{: X, Y) R+ V0 Y9 q  O
        // Temp variable to avoid calling volatile multiple times.# d" W( E5 |) h6 X+ p7 q& `9 h1 \
        // 临时变量来避免多次调用不稳定。
' Q0 C! `/ Q" \1 j        uint8_t rt_exec; * ?4 P' J: K6 w, Q1 g0 a: S9 z" e# I
        do{( o4 p7 _( r/ w9 S
          if (rt_exec) {                 // 有标志位置位进入# i9 ?) a. u1 s: ?/ o0 A
        8 F1 V% I+ t1 _
            sys.state = STATE_ALARM; // 设置系统为报警状态
2 X$ e  e) O: ?( ^! w5 R      report_alarm_message(ALARM_HARD_LIMIT_ERROR);        //报告报警信息为接近极限值# e9 D: h# P2 v% \0 k+ E, v
    } else if (rt_exec & EXEC_ALARM_SOFT_LIMIT) {                        //报告执行软件限位报警% p$ G: J! g, ?8 p! _
      report_alarm_message(ALARM_SOFT_LIMIT_ERROR);        //报告出现软件限位报警
$ _  [7 P: T& t& B. ^8 E    } else if (rt_exec & EXEC_ALARM_ABORT_CYCLE) {                //执行停止循环报警      ( h1 u, L: C: K
      report_alarm_message(ALARM_ABORT_CYCLE);                //出现终止循环报警/ ?( A% Z$ C" S  I  L; M1 b* G
    } else if (rt_exec & EXEC_ALARM_PROBE_FAIL) {                        //执行探查失败报警  L* r! `* C8 [8 t
      report_alarm_message(ALARM_PROBE_FAIL);                        //出现探查失败报警0 X4 S( ?2 e: f' f5 x4 ~
    } else if (rt_exec & EXEC_ALARM_HOMING_FAIL) {                //执行返回原点失败报警) f" q! |' w5 m( _) w5 c: x) }* z
      report_alarm_message(ALARM_HOMING_FAIL);                //出现返回原点失败报警
$ I6 E2 S7 U) p8 O3 f, P    }
  U; L5 W$ b6 C, f9 y& i( Z! V2 d
0 d# X5 T+ t6 I1 S    // Halt everything upon a critical event flag. Currently hard and soft limits flag this.' ], S( Q4 Z& y# _& `; ]
    // 停止一切在一个关键事件标志。目前硬和软限制标志# |" R% ~0 F* u& T
           if (rt_exec & EXEC_CRITICAL_EVENT) {                //如果系统是循环事件进入( ~+ P0 }: f1 T2 L  o7 @
             report_feedback_message(MESSAGE_CRITICAL_EVENT);        //报告反馈信息. }- k4 Y2 X3 G5 ^) |% ?3 i1 K
              bit_false_atomic(sys_rt_exec_state,EXEC_RESET);                         //清除目前的复位状态6 U, X0 i( t) x' ]4 ?0 U

3 N" g, V; P2 O6 M' L9 U        bit_false_atomic(sys_rt_exec_alarm,0xFF);                                 // 清除所有报警标志
. E0 t9 U# ?! ~$ p5 W        }       
+ w. {8 \4 |/ g( n+ q" E- x  c5 v
: S9 D6 ^- P) z8 B2 H- J上面代码将rt_exec = sys_rt_exec_alarm ,如果rt_exec为真,打印不同报警信息
  |: L3 c# }- Q: K6 e% P* K和限位保护信息,然后清除报警状态2 z1 X' _- v3 c7 ]& d" _7 F0 |
___________________________________________________________________________
3 \) Z, v* x" o7 n' V没有报警进行执行下面代码,执行了终止命令,串口打印命令
# k$ C- b" k' j; x1 b# o( V$ ^         // Check amd execute realtime commands        校验和执行实时命令% g0 j8 Q) X2 N8 |! g1 e
          rt_exec = sys_rt_exec_state; // Copy volatile sys_rt_exec_state4 M( Q1 l* N4 \% f5 `

# w& m5 {( j5 z1 h5 i/ y. F        if (rt_exec) { // 输入标志是正确的执行9 e$ K/ j: u+ ^

$ H+ X5 E( M  V% c            // Execute system abort. 执行系统终止命令5 G0 x9 X; a% I/ O/ q; B6 R: U
            if (rt_exec & EXEC_RESET) {7 U0 L- j! D0 Z6 H
              sys.abort = true;  // Only place this is set true.
( A7 C: D* j. t0 {; ]              return; // Nothing else to do but exit.
+ ^5 B; _: l8 j- y  x' F, x/ c        }
% u  |! Y; \8 x+ j, Q; C4 `' q
% u1 ?! c  ~. q2 b. g/ ^$ G4 G            // Execute and serial print status 执行和串口打印状态
& ?/ l( m6 M$ o8 w5 l            if (rt_exec & EXEC_STATUS_REPORT) {
: G0 w6 f9 T, a" O              report_realtime_status();        //报告实时状态; x+ ?( v, u( A) J/ v
              bit_false_atomic(sys_rt_exec_state,EXEC_STATUS_REPORT);        //清除报告状态清零! f6 d/ W6 R. a3 d/ X$ d
            }9 O. P+ V1 e# G+ v2 ?0 l4 m
_____________________________________________________________________________, K. T* U8 X) a1 j: e0 H& x, Q
下面代码
( u) l, h& U  \, c7 }//执行状态。1 j) e' d  A; t! b$ Y
//注意:所涉及的数学计算持有应该足够低对大多数人来说,即使不是全部,
- W% k" L  l( z5 b//操作场景。一旦启动,系统进入暂停状态
. y% T* I6 ^) q, U//主程序流程,直到重置或恢复。
3 T1 y# Z& d3 w待办事项:检查模式?如何处理呢?可能没有,因为它只会在空闲,然后重置Grbl。# |5 s- n; m! ]' o$ t9 j
状态检查容许状态的方法。
2 ~- z4 ^) ~# a) _1 D% G$ S& I# n( e0 X* D# w& {
        //如果全局各自报警标志位其中(执行取消动作) | (执行进给保持) | (执行安全门)任意一位为真进入$ D$ i, C6 b3 j6 w. o
            if (rt_exec & (EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR)) {        ! d6 y2 z$ t. R4 q- a

/ ^( w" X* F% j2 \6 r% C        //如果是循环状态执行暂停状态$ z! X* L2 N& j9 Z
        if (sys.state == STATE_CYCLE) {
9 y( F, k& z) B        st_update_plan_block_parameters(); //通知stepper module验算减速。
5 l$ R) u2 z" @* u) _        sys.suspend = SUSPEND_ENABLE_HOLD; // 开始暂停标志
( X+ G% t4 \5 B8 c- x: C$ h* `/ d        }) `- S* Q: U# _( [* D
1 R* [4 L; w( c
        // 如果,Grbl空闲不在运动。简单的指示暂停就绪状态。/ P# g& D$ D4 \3 r  o3 K$ v
        if (sys.state == STATE_IDLE) { sys.suspend = SUSPEND_ENABLE_READY; }! ?4 o# m' N" B2 ?; M, J

2 X" m- c5 ^% a8 U. \) B( B& O4 g$ Q& z2 m3 h7 _
        //执行和标志和减速运动取消并返回空闲。主要由探测使用周期
- U7 O) `' B& h        //停止和取消剩余的运动。       % ?4 {' W: l5 @# K1 c/ ]
        if (rt_exec & EXEC_MOTION_CANCEL) {
) h( O, |: g- a* n7 [) x. Z          if (sys.state == STATE_CYCLE) { sys.state = STATE_MOTION_CANCEL; }8 r( ]1 S5 O1 a% K# F
          sys.suspend |= SUSPEND_MOTION_CANCEL; 5 X7 |0 p+ |8 S( k
        }5 b+ [- O- I+ g! Q3 l+ z, Q

4 k0 r# l& P+ x# Z9 S4 W. l& R        // 只在循环时执行进给保持减速+ n' \5 l: [) \. o
         if (rt_exec & EXEC_FEED_HOLD) {9 |) @9 ]! k/ L
        //只有安全门为1才执行保持进给状态赋值  _: [* d& E2 g( _: c" |# L
          if (bit_isfalse(sys.state,STATE_SAFETY_DOOR)) { sys.state = STATE_HOLD; }
  _. u) Y- J' |) d; v        }
+ o1 R$ @1 B  S$ k: b. O4 |: T4 K5 c* s% W' B& S$ S( a
        if (rt_exec & EXEC_SAFETY_DOOR) {
2 f5 T  [$ F, A+ D  R; v! H, y, \          report_feedback_message(MESSAGE_SAFETY_DOOR_AJAR);
0 q. Q* X3 W5 p  q) H2 e/ /如果已经活跃,准备好重新开始,CYCLE_STOP标志设置为强制断开。2 M% |" N" u9 i9 C- J$ h5 L
/ /注意:只是暂时设置“rt_exec”变量,不是动荡的“rt_exec_state”变量。8 w4 m" D) ]$ b1 l3 B/ L8 ]" V
          if (sys.suspend & SUSPEND_ENABLE_READY) { bit_true(rt_exec,EXEC_CYCLE_STOP); }) r5 T! G9 ]" N2 S; C" [+ j* }
          sys.suspend |= SUSPEND_ENERGIZE;1 s3 A, s7 o, W7 T  A
          sys.state = STATE_SAFETY_DOOR;7 y# N2 ^2 {5 A2 w; W% q; K- h
        }
2 l4 ?9 S- t7 C- e$ U
1 I. S9 n9 X5 A. c' z. L1 ^9 u) g+ n$ kbit_false_atomic(sys_rt_exec_state,(EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR));   
/ e* E( D- w* ~" c: K# I6 B7 W: |. k1 [* ?! r% u* D' ^
}
+ Q9 u  \% I" O/ K3 W3 a0 A0 [" _以上代码执行了) E1 ]% O5 Q# a( R! J3 ^
1.如果全局各自报警标志位其中(执行取消动作) | (执行进给保持) | (执行安全门)任意一位为真进入
. [, a6 ^8 w! B, K8 [3 B! H8 R7 a. {, _2.系统为闲着状态, 开始循环状态, 回原点状态, 控制取消状态, 开始保持状态, 开始安全门状态时进入
5 p2 z4 `- f4 I9 Z3.如果是循环状态执行暂停状态
9 Z6 y+ r  l5 i! M  v2 d8 [4.如果系统闲置状态执行暂停就绪状态
' q5 `$ @1 V8 [' A* D9 q7 F5.执行动作取消0 }) a1 U8 F* _
6.如果是保持进给状态,执行保持进给状态( |/ }3 E& O) R0 t. ^' w+ `
7.执行安全门状态
. j% m$ U0 U' @7 F$ I最后执行bit_false_atomic清标志清除(执行取消动作)(执行进给保持)(执行安全门)标志位                 
; ^% m- W: n& {' L5 ]! l_____________________________________________________________________________
" T. `: n2 E# ?- Z  X6 O
  T* A  f% A4 H1 x    // Execute a cycle start by starting the stepper interrupt to begin executing the blocks in queue.- T; H+ L) O& d7 H1 G& V
    // 执行一个循环开始启动步进开始执行中断队列的街区& B  d" O2 [1 p# C
    if (rt_exec & EXEC_CYCLE_START) {        //循环开始状态进入
' x( y4 _. @) Q, w9 z/ H) {      // Block if called at same time as the hold commands: feed hold, motion cancel, and safety door.
$ G+ U! w7 p0 W4 ]$ T7 }      // Ensures auto-cycle-start doesn't resume a hold without an explicit user-input.
  {6 A/ T) J4 B6 f, y7 N  f7 }7 S' n          //块如果在同时举行的命令:保持进给,运动取消,和安全的门。 //确保auto-cycle-start没有简历没有显式的用户输入。
% r; q7 ?- g' j- h+ K, u           : Z: I- a* [% F* w9 H3 J
      if (!(rt_exec & (EXEC_FEED_HOLD | EXEC_MOTION_CANCEL | EXEC_SAFETY_DOOR))) {   //状态机如果不是保持进给,运动取消,和安全的门。
3 Z" C7 P, ~0 g1 x5 m) D        // Cycle start only when IDLE or when a hold is complete and ready to resume.
# `; }7 `9 _- }1 G        // NOTE: SAFETY_DOOR is implicitly blocked. It reverts to HOLD when the door is closed.
* U; k/ d  m7 ~4 E7 N2 Y                //循环开始时只有当闲置或持有完成并准备简历。& p* ^4 e/ Z% N5 Y1 X8 U  X
                //注意:SAFETY_DOOR是隐式地屏蔽。它返回的时候门是关闭的。   
5 g0 T( v& C: H! ?, ]8 Y5 I, s. J# r
                // 如果系统状态为闲着状态,系统状态为开始进给或运动取消,暂停标志为位重新开始5 i* f( B, B9 O2 F9 C& O
        if ((sys.state == STATE_IDLE) || ((sys.state & (STATE_HOLD | STATE_MOTION_CANCEL)) && (sys.suspend & SUSPEND_ENABLE_READY))) {# N* H. ?1 P4 }! `' k0 @
          // Re-energize powered components, if disabled by SAFETY_DOOR.4 K& I. G, }5 H9 c
          //        由SAFETY_DOOR重振组件供电,如果禁用。
7 _- K7 b  ?. N! S  S, c5 ?8 n6 S          if (sys.suspend & SUSPEND_ENERGIZE) { * d: H$ H& \: W8 E1 X7 f& W" o
            // Delayed Tasks: Restart spindle and coolant, delay to power-up, then resume cycle.
5 o/ ?7 X( `: p) S5 k            //延迟任务:重新启动主轴和冷却剂,延迟升高,然后恢复周期。
" |& W$ X) j+ r& }2 G            if (gc_state.modal.spindle != SPINDLE_DISABLE) {   //主轴模式不是失能进入
1 X; k* c& v' g# Q+ P              spindle_set_state(gc_state.modal.spindle, gc_state.spindle_speed); //设置状态和速度6 U; r) q( f0 j9 X
              //待办事项:阻塞函数调用。最终需要一个非阻塞。4 \7 T: ]. A$ i1 w1 {
                delay_ms(SAFETY_DOOR_SPINDLE_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.
7 r6 n2 d" y, f7 r( |3 p: _            }9 W( Q- Z. F: V2 Y& _! R: M9 q
            if (gc_state.modal.coolant != COOLANT_DISABLE) {
  t2 `1 z- S% h6 q              coolant_set_state(gc_state.modal.coolant); 4 x7 t7 U. _9 U0 I! _/ Z: x
              delay_ms(SAFETY_DOOR_COOLANT_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.
1 f, X( d+ U0 R) X            }
7 _$ i6 X' c& o% y. c            // TODO: Install return to pre-park position.$ \$ g- D* ?8 _. |" G
          }! ?, M% e& c/ ]- e. S
______________________________________________________________________________________________________________4 `  x. P4 x+ z( V, E1 k
          // Start cycle only if queued motions exist in planner buffer and the motion is not canceled.
6 E4 d* L1 J6 F7 g0 A* h. u                  / C9 @! X4 z) X
                  //只有在队列马达存在规定的缓冲,并且动机没有让取消,才会循环) Q* [8 _* o7 a/ _, x
                  / e& J9 k5 \- O! ^
          if (plan_get_current_block() && bit_isfalse(sys.suspend,SUSPEND_MOTION_CANCEL)) {) K' X$ X# N" l5 \) e
            sys.state = STATE_CYCLE;! R, k$ T: v& X6 A
            st_prep_buffer(); // Initialize step segment buffer before beginning cycle.初始化步开始循环之前+ u7 b" N0 D2 g% _
            st_wake_up();
0 D4 a0 h: o. p0 J6 T          } else { // Otherwise, do nothing. Set and resume IDLE state.否则,什么也不做,设置和复位空闲模式
1 {' `9 E* ?' F6 q0 _            sys.state = STATE_IDLE;$ H! K0 i# z: k
          }
* c( d; T  d+ N! Z) i) i          sys.suspend = SUSPEND_DISABLE; // Break suspend state.
' \& P9 ~8 i& W& v        }! I, N  _- f1 h3 c! g
      }   
9 b. b% k6 ^$ {      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_START);       
* c7 D: I. g: _9 V4 [/ f& e2 ]* t    }
! T" Y) X5 l# i& h8 b* c
' X7 L2 `; @; e_______________________________________________________________________________________________________; b1 R4 h) s1 Q' P# T
    // Reinitializes the cycle plan and stepper system after a feed hold for a resume. Called by
7 a4 I6 A8 K; n$ D    // realtime command execution in the main program, ensuring that the planner re-plans safely.
4 Y! a" v4 s  e7 r    // NOTE: Bresenham algorithm variables are still maintained through both the planner and stepper5 p2 s( |/ Q8 O; \$ d4 m
    // cycle reinitializations. The stepper path should continue exactly as if nothing has happened.   7 c. M) b3 p$ K/ o( ~# y" ~
    // NOTE: EXEC_CYCLE_STOP is set by the stepper subsystem when a cycle or feed hold completes.5 r! e% a5 g4 y* V
4 X* n" i8 ~+ C( o
        //重新启动后循环计划和步进系统的进给保持简历。通过实时命令执行主程序,确保安全计划重新计划。- l, ]4 [; d$ _0 l% Z/ @
        //注意:画线算法变量仍保持通过规划师和步进
3 |9 F6 N. |: Z  P4 [- y. Q        //循环仅。步进路径应该继续,好像什么都没发生一样。       
% U- D  ~5 O' I        //注意:EXEC_CYCLE_STOP由步进子系统周期或进给保持时完成。
9 b* y# V2 s2 _% [9 p1 ?# k
3 g0 C9 x* v! x" F% G    if (rt_exec & EXEC_CYCLE_STOP) {                         //如果是循环停止状态进入$ Y  g5 G1 L3 t/ }% J# Q. P; n) M
      if (sys.state & (STATE_HOLD | STATE_SAFETY_DOOR)) {! T3 c' z$ {! R6 K* E" g7 Y
        // Hold complete. Set to indicate ready to resume.  Remain in HOLD or DOOR states until user+ I* E! a+ j: J9 l
        // has issued a resume command or reset.2 z, o0 M1 S' p" U, x  L- \
+ I+ d. y3 e1 ?/ X  `  U6 i0 E
                //保存完整。设置为指示准备简历。继续持有或门状态,直到用户
4 S% |) ]+ H7 V2 T6 c                //已发布了一份简历命令或重置。( J1 t$ d) y: W% }3 Z- l, z# e7 d
                ( G; y$ `' H. h- i: Q5 |+ s7 \9 B
        if (sys.suspend & SUSPEND_ENERGIZE) { // De-energize system if safety door has been opened. 如果安全的门已被打开。断开系统) H. l- v# T. ^+ P% |& ?- f* S9 y
          spindle_stop();
, A6 P5 D0 c' Y4 _          coolant_stop();3 ]" \2 W5 h4 S
          // TODO: Install parking motion here. 安装停车动作。
( z1 a4 R- t! B# Y8 k  E        }
4 x+ D6 ^- b7 f$ R        bit_true(sys.suspend,SUSPEND_ENABLE_READY);8 q/ F4 I  s, A" l' \% v
      } else { // Motion is complete. Includes CYCLE, HOMING, and MOTION_CANCEL states. 电机完成,循环,回原点,,MOTION_CANCEL
* }7 ^8 X9 M0 ^; G4 o        sys.suspend = SUSPEND_DISABLE;
: P; o$ V' A$ C5 U        sys.state = STATE_IDLE;
! Y$ e3 D" E( O6 u( l2 r3 v2 F$ J      }5 d, @* ~. C5 i& j  A
      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_STOP);# a3 e4 D: |. m% ]5 k
    }
, ]4 x: D2 j+ Q+ M* X! C    6 j3 l  t( g1 @) s$ ?( b
  }
4 v9 B: L+ P+ g, R% U1 f2 c___________________________________________________________________________________________________
" X, d+ ^( j; q: m" [
& [8 U$ v. s3 ~$ g; a, Y  // Overrides flag byte (sys.override) and execution should be installed here, since they
- b  w/ {1 D1 y, r: U; @8 o7 ?  // are realtime and require a direct and controlled interface to the main stepper program.
5 z& W0 x$ {6 S& E8 x' k: i+ C
" x+ L! g* _! b+ a  //重写标志字节(sys.override)和执行应该安装在这里,因为他们
# s, `, r4 V! _1 h/ P* K  //实时和需要直接和控制接口的主要步进程序。, w: g( r- a! q, T) ?8 z7 \
9 P$ k. ]  u! j! I

8 R: V$ K; H- g$ N1 Q' u% j  // Reload step segment buffer 重新加载步段缓冲
6 ^$ Z( [# ?) S& f  if (sys.state & (STATE_CYCLE | STATE_HOLD | STATE_MOTION_CANCEL | STATE_SAFETY_DOOR | STATE_HOMING)) { st_prep_buffer(); }
& V0 _% R4 `/ u5 r, Q$ x
/ N0 N- q2 k. b, K+ |" S; S  // If safety door was opened, actively check when safety door is closed and ready to resume.
6 K8 M3 R3 ~2 D# A) m; o7 D  // NOTE: This unlocks the SAFETY_DOOR state to a HOLD state, such that CYCLE_START can activate a resume.       
2 D4 Z4 u+ N0 z1 P! D( o/ @* z# A* B  s2 L
//如果安全的门被打开,积极检查当安全门关闭,准备简历。1 Z7 }9 n- f* W
  //注意:这解锁SAFETY_DOOR状态保持状态,这样CYCLE_START可以激活一个简历。
7 ~' ~  v& p  [$ y( x, s1 \: F
+ \% _/ I) y7 u, o1 H  if (sys.state == STATE_SAFETY_DOOR) {                 //安全门状态进入
6 q7 i1 u# l) u- H/ f    if (bit_istrue(sys.suspend,SUSPEND_ENABLE_READY)) { / N  v/ }& i, O' Q# C% b
      if (!(system_check_safety_door_ajar())) {. T, v+ O# @/ u+ A0 w
        sys.state = STATE_HOLD; // Update to HOLD state to indicate door is closed and ready to resume. 更新保存状态指示门关闭,准备简历。
. c/ O, L8 k) i) Y      }* S4 x$ A' H" q0 S# i
    }
! d" J6 }0 ^1 y" e3 X0 l  }& H. a9 [# @" S; c
% R4 s$ i) i- [2 b
  } while(sys.suspend); // Check for system suspend state before exiting.
; A/ S4 }+ [8 F# [3 K1 p' s. V+ X  
1 `4 B6 I2 ^- g% ?6 {  S}  
回复 支持 反对

使用道具 举报

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

点评

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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-2-19 06:05 , Processed in 0.086216 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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