找回密码
 注册会员

QQ登录

只需一步,快速开始

搜索
查看: 19357|回复: 15

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

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

( s0 k, a! D" A/ Q9 [( Z! |" i    下面介绍小这个些主控程序主要干的事,通过串口PC和主控板通讯,PC命令给控制板,控制板接收命令做不同的响应,PC可以发G代码给主控板,接收完成后可以自动开始雕刻任务。
: {% P* b1 ]# D6 T7 I          在介绍下G代码因为G代码是雕刻机的核心部分
) O: R" p& S( D6 WG代码是数控程序中的指令。一般都称为G指令。
5 @, S4 e9 j2 A, b  g: M6 TG00------快速定位* V# i$ R, |1 ]8 s. Y; {5 r+ U& u
G01------直线插补9 }- p, e! o5 z' n; K# F
G02------顺时针方向圆弧插补; E0 T/ C* s% @$ m
G03------逆时针方向圆弧插补
; t3 w7 Y4 T+ t) t& UG04------定时暂停
7 U5 T' }  A  }2 X& t( b* R' bG05------通过中间点圆弧插补& w& e. n! P# B4 l0 y0 P
G06------抛物线插补
& Q  U/ p$ K$ i% v$ V4 A2 k5 b* UG07------Z 样条曲线插补+ R5 N( Z# E5 c/ m7 S% u4 [8 h
G08------进给加速" {2 e( I7 U) z; E' R
G09------进给减速6 r" C* i% F* I5 @& x$ \- e
G10------数据设置0 P& ]" f$ A( u6 }) S
G16------极坐标编程
2 u. E% l' J: J% @G17------加工XY平面
7 \; ^$ j: d+ P6 \G18------加工XZ平面
3 x4 z# ?6 c, ?& VG19------加工YZ平面
& X, w& j2 h" l5 g5 A+ S1 O' G7 J
核心就是解析G代码,完成步进电机驱动,和控制主轴开启关闭,还有插补算法,直线插补,圆弧插补,还有一些步进电机的加减速算法。
. @3 K5 ~! _5 x# z下面对grbl主结构做介绍5 r( a& E2 r. o0 T2 R* }5 U
main()主函数首先执行下面初始化函数
5 w+ y4 X9 z' E) c# _; O" A  r        serial_init();                           // 设置串口波特率和中断
7 H, z' D2 ?% T4 a& z        settings_init();                         // 从ROM加载grbl设置, E5 R% S( n) f
        stepper_init();                          // 配置步进方向和中断定时器
: O& x5 u, N  @        system_init();                           // 配置引脚分配别针和pin-change中断
9 L/ R. i9 a( H+ K        memset(&sys, 0, sizeof(system_t));          // 清除所有系统变量6 x2 i1 u" B8 \6 m6 d
        sys.abort = true;                           // 中止标识位置位' Q. ~3 K& o: T$ ^  w
        sei();                                         // 使能中断& `+ r- s" @. N9 ~- O; Q% T
  #ifdef HOMING_INIT_LOCK                        // 宏运算(settings.flags & (1 << 4)) != 0结果flags等于执行sys.state = STATE_ALARM
% Q) E/ \5 ]; u& ]" T                                                // 系统状态赋值为报警状态
2 ?  |8 D0 ]0 u7 x            if (bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE)) { sys.state = STATE_ALARM; }
, `% \( _, z$ S  #endif
; F* A+ u# B' {" R4 }_____________________________________________________________________________________________________________________________________
* b* l% @) K0 D- U& I7 u接下来是一些主要部分初始化
2 `5 l  p5 C1 N: U: N5 z) T3 efor(;;) {3 _( q; Z! Z4 p; \5 S9 t
        serial_reset_read_buffer();         //清除串口读缓冲区* c6 ?9 {- J: E& C
        gc_init();                         //初始化G代码功能函数
/ _( L( ~3 S) ~- o        spindle_init();                        //主轴初始化$ N+ ]8 x. k- z% N% i4 b  h* Q
        coolant_init();                        //冷却液初始化5 c, p/ H; a, E, }# C
        limits_init();                         //极限开关初始化
3 ^2 m# P' _: S" k& ]. }% q# j, X        probe_init();                        //探测部件初始化; A( P0 g; R; D: X
        plan_reset();                         //清除块缓冲区和规划师变量- L+ D& |/ @' H
        st_reset();                         //清除步进系统变量。
$ ]/ x5 M1 w" b1 k8 b& F2 B( U2 ]" W% r, ~) J8 _

: _% {0 w, S6 F! d$ B8 d5 c. N        //下面两行清除同步gcode和策划师职位当前系统位置。
0 n9 n0 o3 J' @1 X+ R9 q
        plan_sync_position();
$ X5 K# O  q# L. r$ t0 ?/ p        gc_sync_position();* W9 q9 M4 |) Z% a) g* m
: F5 ]% V0 K6 x* `4 d' ]9 Z
/ }: E0 o* s  x$ p3 X3 ~
        //复位系统变量
: S. G/ }, x. q7 E7 N% T. u6 q& {/ K        sys.abort = false;                //系统中止标志
) a6 t$ @! _1 d" Z- _2 Z; I3 B+ U        sys_rt_exec_state = 0;                //系统标志位变量状态管理。看到EXEC位掩码。
# e3 e) u% s8 b1 _1 i        sys_rt_exec_alarm = 0;                //系统标志位变量设置不同的警报。1 |; N+ P, O/ X+ }: J
        sys.suspend = false;                //系统暂停标志位变量管理,取消,和安全保护。
7 P. @3 I4 D* f+ h        sys.soft_limit = false;                //限位开关限制状态机错误。(布尔)6 P) g; t. Y: Y
& _# w0 j9 a5 S! l! m) J3 W
7 c" p. r* l. v# s+ l! E
        protocol_main_loop();                //主协议循环. B1 I9 o# q8 i% v. k# z4 m
}        //
9 D" D- q" y1 I; x8 X_____________________________________________________________________________________________________________________________
6 `! j! L- ?( S' G( A进入void protocol_main_loop()函数
5 [4 b2 h" X6 G{  c! _( E* Y, ~* L* ]: U# A" V) w
        report_init_message();                // 打印欢迎信息
3 D9 f7 E& X8 B" h        //重启后检验和报告报警状态如果错误重启初始化。1 P2 m* y3 _$ l/ U' N0 x
        if (sys.state == STATE_ALARM) {
) |# C, t* R3 l            report_feedback_message(MESSAGE_ALARM_LOCK); //打印信息- _/ X) I+ G. f4 F0 m& [
          } else {
' T2 K. t9 R- d" O            // 如果没有报警说明一切正常!但还是要检查安全门.
; K: a8 w4 \+ _9 b  ]4 ?! h            if (system_check_safety_door_ajar()) {
- O+ P5 p" H/ s( W4 O9 A2 c                     bit_true(sys_rt_exec_state, EXEC_SAFETY_DOOR);8 _3 f4 k/ w1 _' Z) h$ p
                     protocol_execute_realtime(); // 进入安全模式。应该返回空闲状态。
2 [( F0 F* w. h. u$ r6 \: c6 z            }         else {
' J. U  l( i1 a9 x9 I% i3 M, v              sys.state = STATE_IDLE; // .设置系统做好准备。清除所有国家国旗。
6 R+ d5 E6 w. @/ M- O' _# N) P            } ! W: e3 `' ~( c! E
            system_execute_startup(line);    //开始执行系统脚本
7 W% {; T! n% B# [  } & \- t% H6 j9 _1 W2 _
7 v( j* x" F# u
! Y& R: P, m! p5 h" |) K$ O
  // 这是主循环!在系统中止时这是出口回到主函数来重置系统。& i- G2 b/ a, {" M5 E# k8 A- s
  // ---------------------------------------------------------------------------------  
7 v1 P& L3 ?( y. h& \  & M( L, {, c. z- N! w0 Z- m9 ~
        uint8_t comment = COMMENT_NONE;
7 _% e6 v9 J+ f( }7 c        uint8_t char_counter = 0;
0 C( @0 t9 c1 M5 T, E$ x3 N& G        uint8_t c;
- c) d2 y' i2 U1 H: o$ L/ h_______________________________________________________________________________________________________________________________
, _/ p  c0 O- }6 T8 ]接下来进入for(;;)循环                //下面代码是G代码解析核心部分,程序中comment(注释)变量会被赋不同值,代表发符号有‘(’‘)’‘;’
7 ^1 u; N0 H9 f% P{; ^( Y, N# L/ x/ v8 q6 ?$ T
//串行数据输入一行的的过程,作为数据。执行一个2 W% A* i  R/ I
//所有数据初始过滤去除空格和注释。
0 K6 k) u( @0 m$ y4 C; p//注意:注释,空格和程序段删除(如果支持的话)处理技术% E, A7 H, y1 `
//在G代码解析器,它有助于压缩到Grbl传入的数据
$ s: v- Q- S' ^& T" H( ]//线缓冲区,这是有限的。刀位点标准实际上州一行不行% B2 O% K. z% ]6 q* ?' a  `# ~
//不能超过256个字符,Arduino Uno没有更多内存空间。$ @- B; w8 I9 F7 P6 y
//有更好的处理器,它会很容易把这个初步解析的5 K: r. X; y; \6 l# k, m! f! z& |
//分离任务共享的刀位点解析器和Grbl系统命令。                                                                - y$ \4 T% H) W: n6 P
    while((c = serial_read()) != SERIAL_NO_DATA) {                             //读取串口数据,有数据执行下面代码
! T% m) p. g+ q9 h( l. t2 _$ e      if ((c == '\n') || (c == '\r')) { // End of line reached                //如果数据是/r,/n代表一行结束
' U- k8 \/ P, Y+ h        line[char_counter] = 0; // Set string termination character.        //设置结束标志4 a$ C: ^# E4 i, C& A8 t! d- C
        protocol_execute_line(line); // Line is complete. Execute it!        //一行完成执行此函数
) f, [) s- t( k9 c7 J3 }5 l# S        comment = COMMENT_NONE;                                                //注释清零' j3 ~# D2 A. R3 f, R* V& N
        char_counter = 0;                                                    //字符计数清零& D- @8 a: ?$ y. M4 F& ]' U
  
: ~! G( L, ]7 G! y        else {( e0 U$ e' o6 r( E
        if (comment != COMMENT_NONE) {% T1 [9 d0 A  T8 s( E
                                                     //扔掉所有注释字符
2 \4 C, S0 r# ], ?3 k3 k: }# }. M          if (c == ')') {) M8 q6 H1 \5 ?: V# G
            //最后注释。重新开始。但是如果有分号类型的注释。9 {6 ?7 y9 O6 H0 o* y
            if (comment == COMMENT_TYPE_PARENTHESES) { comment = COMMENT_NONE; }
# @  o4 B4 S/ m6 {0 K; \9 _          }
$ A; f) J: Y8 U! R% X      } else {
1 ]8 g, X1 ^; A/ D6 Q( G/ g& R          if (c <= ' ') { 8 r9 b5 J7 k* z: F. g/ S5 t
            //扔掉whitepace和控制字符7 _' _* T3 N( H1 m
          } else if (c == '/') {
, u5 K% l  R- I7 ]' Q# U: ~            //块删除不支持将忽略字符。$ N7 k9 Y! v2 E9 Y* g$ p
            //注意:如果支持,只需要检查系统是否启用了块删除。  g( k2 O) x7 ]+ u
          } else if (c == '(') {
( w0 I* ^! o* Y% h7 J* d            // Enable comments flag and ignore all characters until ')' or EOL.- {; r* z# ~/ X1 ?: S
            // NOTE: This doesn't follow the NIST definition exactly, but is good enough for now.( }5 A. B! o0 Z! w# a
            // In the future, we could simply remove the items within the comments, but retain the
6 j& r- w2 H, [4 @            // comment control characters, so that the g-code parser can error-check it.
* P6 G  P9 X, [" S# [6 ?            comment = COMMENT_TYPE_PARENTHESES;
9 b& O+ t# F& @: L% F6 N          } else if (c == ';') {
* b  h. e( m# v            //注意:','注释EOL LinuxCNC定义。没有国家标准。$ y5 ]; _+ U3 R. S
            comment = COMMENT_TYPE_SEMICOLON;8 \* K; l) t8 o" _. }; d6 h$ x
3 P7 [7 e8 j/ }* ]9 m9 B
6 r' L! Y6 P2 C2 Y& e/ G/ m
_____________________________________________________________________________________________________________________________________9 {  [3 z+ @* [- h: v3 j2 O( @
          } else if (char_counter >= (LINE_BUFFER_SIZE-1)) {                        //串口接收数据大于80字符时
, c9 _0 P) M/ A6 H) P* {            // Detect line buffer overflow. Report error and reset line buffer.        检测缓冲区溢出。报告错误和复位线缓冲区。
4 ]' D1 o) x7 _* m, f- j6 y            report_status_message(STATUS_OVERFLOW);                                //打印溢出信息
' z* `  \+ V6 C$ q6 F            comment = COMMENT_NONE;
+ r- O3 N5 @0 ]/ v$ }+ @            char_counter = 0;+ D0 Q7 L: y% K. f9 U! S, b
          } else if (c >= 'a' && c <= 'z') { // Upcase lowercase                        //小写改大写& d& I1 a5 R5 C
            line[char_counter++] = c-'a'+'A';, o! Y  z: O, g6 z) L- V
          } else {8 j3 [- g) ~+ d! c$ P0 k  C
            line[char_counter++] = c;
# H# V% o4 o9 H% r2 m& Q          }( E( w# G. k% A$ F+ T
        }
! _0 b7 ?! e. e( h  a      }
) z$ M* n/ h: G5 [: m    }
* ?# [7 l- \! y6 ?! _____________________________________________________________________________________________________________________________________
2 h! Z& O3 M. j7 J        //如果没有其他字符在串行处理读取缓冲区和执行,这表明以完成,自动启动,如果启用,任何队列动作。
) @# ^7 \2 k  W2 r5 r        protocol_auto_cycle_start();                //自动开始协议循环
, }4 T  ]3 k3 i& G7 {6 |        
2 B/ O5 ~4 L7 J/ L/ Q: M            protocol_execute_realtime();                  //运行实时命令。
0 \( I$ ^& O. F/ |, U            if (sys.abort) { return; }                 //中止标识置位程序循环重置系统。            
- _1 X! e7 r# z8 ?- h" k  }
2 i) E% D* i" l8 s8 L  return;                         //一般程序不会执行到这里3 X5 `$ g: H4 `: X) C" I
}
" l- }, s* a% w4 `) U____________________________________________________________________________________________________________________________________
2 m0 x+ u+ U3 v正常情况下,读取完G代码程序会进入protocol_auto_cycle_start();//自动开始协议循环 函数下面介绍此函数0 v" f0 G5 u' l  [
// Auto-cycle start has two purposes: 1. Resumes a plan_synchronize() call from a function that9 `! D2 P! l/ H8 W6 q" s* ?
// requires the planner buffer to empty (spindle enable, dwell, etc.) 2. As a user setting that . E; L+ {# j3 K$ Z2 Z3 ~1 E
// automatically begins the cycle when a user enters a valid motion command manually. This is
! }1 J7 ^* F: i0 P// intended as a beginners feature to help new users to understand g-code. It can be disabled) Q3 |5 {" Y* O2 D5 n. @
// as a beginner tool, but (1.) still operates. If disabled, the operation of cycle start is
$ H- |& W/ }# v3 y/ }5 v// manually issuing a cycle start command whenever the user is ready and there is a valid motion
) e4 B" E7 Z: N( e) \  m/ E, n, K// command in the planner queue.
: u- Z9 @% H# b4 q* D8 U3 B// NOTE: This function is called from the main loop, buffer sync, and mc_line() only and executes 5 c7 h9 @' J1 N! }  f$ r2 i' _
// when one of these conditions exist respectively: There are no more blocks sent (i.e. streaming
/ w# E7 x1 y* P% }8 V( L' O. I% _// is finished, single commands), a command that needs to wait for the motions in the buffer to ( V5 K$ T/ ^  F$ h7 }2 ]" E
// execute calls a buffer sync, or the planner buffer is full and ready to go.+ v/ P9 s) M" S% V7 o: e
//自动开始有两个目的:1。回复一个plan_synchronize()调用的函数; E3 Q$ o8 u6 U/ a$ z3 h5 }; _7 ]
//需要规划师缓冲区空(主轴启用、住等)2。作为一个用户设置6 O- {) [" E; B% ^9 s6 o
//自动循环开始当一个用户输入一个有效的运动命令手动。这是
; v; W/ o0 r' V//作为一个初学者的特性来帮助新用户了解刀位点。它可以被禁用6 J! b3 s: C" g" w6 d: y
//作为一个初学者工具,但(1)仍然运作。如果禁用,运行周期开始
) m; N8 H5 P% y( k6 t6 I//手动发出一个周期开始命令每当用户准备好,有一个有效的运动2 _; M* a2 L" ]3 i4 @
//命令的规划师队列。/ }5 x6 u5 _! e3 y5 R0 b
//注意:这个函数被称为从主循环缓冲区同步,mc_line只()并执行
+ G' s2 i$ Z& l% ^5 M//当其中一个条件分别存在:没有更多的块(即流发送
6 c4 G* Q) T' w- x, W! L( H//完成后,单一的命令),一个命令,需要等待缓冲的动作
% E5 C! \5 X* k1 E3 |//执行调用一个缓冲区同步,或规划师缓冲区满了,准备好了。4 U$ y6 z$ M% {0 n. C
void protocol_auto_cycle_start() { bit_true_atomic(sys_rt_exec_state, EXEC_CYCLE_START); } 0 q, E* {  i9 Y
_______________________________________________________________________________________________
7 U- R: I( e! L3 Z' n. C9 [接下来程序运行protocol_execute_realtime(); /运行实时命令。+ @5 t0 v; ?  l; {
// Executes run-time commands, when required. This is called from various check points in the main* H" h4 X3 G7 m2 [- d, J
// program, primarily where there may be a while loop waiting for a buffer to clear space or any6 \4 g) P2 B( N4 E
// point where the execution time from the last check point may be more than a fraction of a second.1 y4 d" i/ I  E: D9 |) p
// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code
: p! T% c4 D  b7 W8 i// parsing and planning functions. This function also serves as an interface for the interrupts to
' g6 a, P+ [0 q- A% M! o0 P7 m// set the system realtime flags, where only the main program handles them, removing the need to  r- ?9 K. g: v$ @( n) |; |' a
// define more computationally-expensive volatile variables. This also provides a controlled way to
3 K! ]$ a9 A6 Z$ v// execute certain tasks without having two or more instances of the same task, such as the planner, V9 f  h# W# B  C3 \5 O5 D: O1 `
// recalculating the buffer upon a feedhold or override.7 t: _" W7 ]1 ~$ [+ W: a  w3 x% k
// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,/ J* a; A/ D4 L( e; `. I" ^
// limit switches, or the main program.+ W6 [# M' J0 P: Q- h! w& G8 r7 Z
void protocol_execute_realtime()
2 R7 {/ y+ Y, ~1 _0 C uint8_t rt_exec; // Temp variable to avoid calling volatile multiple times.临时变量来避免多次调用不稳定。& P1 k# s8 T! E$ l8 e1 z% E* m! E
就先分享到这吧!
- e" R4 O& k1 B% i2 i7 F1 S* ]" e  L- f8 W( r2 @: c

* b4 _4 Y! `+ M$ E
- f; V/ y/ J+ ^" S0 W- |  u& ?, X% j. j' @8 j; X. D
: D! C$ f8 ^  f7 h" u! X2 u

  e$ ^, {# L$ G" O: ]' Z- j6 R5 Y; p' B. E  J5 _5 O$ _
5 `2 X& K5 N8 j: h

  ^! X( V( b/ Q3 C  H
5 b. x8 W0 l+ f
  l. J* P- G5 C: |
4 D6 P3 Z) m! c
# R/ `( C" _7 A6 `' ~5 ?% |; I, L6 ?: v) c0 \: l3 P

) @* G' y3 F  K' X7 v
2 K+ H0 w. A8 m) O0 V. p: x  B8 S1 N* f/ J; ]4 `
$ p! ]1 Y" p4 F; C8 V
& [- l" F+ _" ~% p) a3 e2 K8 b
3 Z, F3 O4 \1 b" @; j+ M

) w! d) u! ~- n0 B' l8 I7 G- r5 B0 r, Y- P! P. h
% E" _; T2 o6 h& G
补充内容 (2016-8-25 22:40):# r4 _/ |: F9 Z" S5 z6 I
配置说明
( o7 }$ X- m! U& l! |. k; a//这个文件包含编译时配置Grbl的内部系统。在大多数情况下,
, J. Q0 v7 Z: }$ [2 l! X6 j//用户不需要直接修改这些,但是他们在这里为特定的需求,即。
1 w! I* \& f6 p//性能调优或适应非典型的机器。6 I9 h. O. I) x% H
主要配置项:) ]2 z. S! i# p; e) i7 G0 }
1.#define DEFAULTS_GENERIC        //在重置eepm时使用。在defaults.h改变想要的名字
) j9 ?6 \, T$ c2.#define BAUD_RATE 115200        //配置串口波特率115200
9 g# \& G3 n+ I0 V3.#define CPU_MAP_ATMEGA328P         // Arduino Uno CPU
. X, {: @9 z5 \- r% U: Y" W, h4.#define CMD_STATUS_REPORT '?'        //定义实时命令特殊字符
2 x# I1 F' f& g- B; {- Z5.#define HOMING_INIT_LOCK         //回原点保护锁
9 x! h2 A8 k. Y4 I6.#define HOMING_CYCLE_0 (1<<Z_AXIS)              // 第一步Z清除工作区。
" w+ w& e6 g) E  #define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // 然后X,Y在同一时间。
7 C0 _. F% {) h6 n7.#define N_HOMING_LOCATE_CYCLE 1 //回原点循环次数
& W$ G, m& E9 M9 X( H0 g4 W5 f8.#define HOMING_FORCE_SET_ORIGIN //取消这定义迫使Grbl总是在这时候位置设置机器原点尽管开关方向。
2 g2 ]& U* `. G/ f/ B$ g0 {9.#define N_STARTUP_LINE 2 //块Grbl启动时执行的数量。$ p3 U3 o  h8 p* I* d* _; R  L: V7 e- @
10.#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 协调或位置价值英寸
( `; K; w" }+ A, Z2 S( f   #define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 协调在毫米或位置价值2 ~- D2 y5 t- U7 [
   #define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分钟的速度值! L9 y" m: ]5 J
   #define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分钟" w/ h/ x# L$ z0 c. s
   #define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 对浮点小数设置值, u4 W7 h7 z  c1 t( Q
11.#define LIMITS_TWO_SWITCHES_ON_AXES //如果你的机器有两个极限开关连接在平行于一个轴,您需要启用这个特性
# {" _0 O/ N* I, R5 \! G( U0 q9 A12.#define USE_LINE_NUMBERS         //允许GRBL跟踪和报告gcode行号
5 M" }5 d0 I* B6 ?- N: \13.#define REPORT_REALTIME_RATE //允许GRBL报告实时进给速率
1 F/ a1 f7 i+ K1 [14.#define MESSAGE_PROBE_COORDINATES  //坐标通过Grbl $ #的打印参数?! ^% V  {) y  a% s' F' Q
15.#define SAFETY_DOOR_SPINDLE_DELAY 4000 //安全门主轴延时( a2 ?( I0 S: l/ [
16.#define SAFETY_DOOR_COOLANT_DELAY 1000 //安全门冷却液延时+ k4 b: s4 j" h% J- }! a' ]
17.#define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS) //启用CoreXY运动学。0 G& H4 t6 z( N# n6 C+ {" G
18.#define COREXY // Default disabled. Uncomment to enable.改变X和Y轴的运动原理# I9 s5 x% j1 `) {
19.#define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.反转针销逻辑的控制命令& e8 d/ Q% \3 j* {
20.#define INVERT_SPINDLE_ENABLE_PIN // 反转主轴使销从low-disabled( c6 t! j1 z/ s! p
21.#define REPORT_CONTROL_PIN_STATE //启用控制销状态反馈状态报告。  P1 @& n* p8 Y% S
22.#define FORCE_INITIALIZATION_ALARM //启用和用户安装限位开关,Grbl将启动报警状态指示" d+ m( ?. U% c8 N
23.#define REPORT_GUI_MODE // gui允许最小的报告反馈模式
8 e, X% i4 u) V24.#define ACCELERATION_TICKS_PER_SECOND 100 //加速度的时间分辨率管理子系统。. ?, j" c6 T. \. g4 T6 M1 y) s
25.#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING //自适应多轴步平滑(积累)是一种先进的功能
( c* ^# u) r! B; s26.#define MAX_STEP_RATE_HZ 30000 //设置最大一步速率可以写成Grbl设置6 Q4 T( C4 d8 c8 B/ z+ L9 T9 Q* [
27.#define DISABLE_LIMIT_PIN_PULL_UP //以下选项禁用内部上拉电阻+ j) T. s' R7 ^) a" x, e
28.#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS //设置哪个轴长度补偿应用的工具。假设轴总是与选择轴工具面向负方向/ M% ^0 t+ ^% l4 [
29.#define VARIABLE_SPINDLE //允许变量轴输出电压不同的转速值。
  m2 n8 z. m; Z/ l- m7 Y: l30.#define SPINDLE_MAX_RPM 1000.0  // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.
: z5 M% j' B0 S   #define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.7 K# v3 \; g! ^! R+ n
31.#define MINIMUM_SPINDLE_PWM 5 //使用的变量轴输出。这迫使PWM输出最小占空比时启用。
3 F0 F; i1 G0 M2 K/ m( g& q32.#define USE_SPINDLE_DIR_AS_ENABLE_PIN //主轴方向使能M4被删除
( q2 T  w  }; A33.#define REPORT_ECHO_LINE_RECEIVED //应该对所有正常线路送到Grbl
4 |9 S( U5 t* S& ]5 q34.#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min) //最小规划师结速度。设置默认最小连接速度规划计划' d. i) J9 I3 U% N- U5 z
35.#define MINIMUM_FEED_RATE 1.0 // (mm/min)//设置计划将允许的最小进给速率" Q8 C8 [; a3 D* X# A
36.#define N_ARC_CORRECTION 12 //弧生成迭代次数之前小角度近似精确的弧线轨迹0 K* g1 k; j3 n- z* [- J
37.#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)//定义值设置机器ε截止来确定电弧是一个原点了?* @( B3 P  u7 u
38.#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds) //延时增加表现在住。默认值设置为50毫秒
3 J3 _7 N8 M; R5 }- Q, T39.#define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.
# m* j5 s, d$ y. C( }  e  {  h40.#define BLOCK_BUFFER_SIZE 18  //线性运动规划师缓冲区的数量在任何给出时间计划
9 s0 F7 S' R1 y: ^7 Y41.#define SEGMENT_BUFFER_SIZE 6 //控制之间的中间段缓冲大小的步骤执行算法* c6 [9 D- \$ M( L
42.#define LINE_BUFFER_SIZE 80 //行执行串行输入流的缓冲区大小。
* X" d* D8 V) D. [1 L& q43.define RX_BUFFER_SIZE 128 //串行发送和接收缓冲区大小
. Q- Z: v" I) R2 s  F- p8 z7 D( Y44.#define TX_BUFFER_SIZE 642 Q( T  f* N5 C% {6 i( |* K
45.#define ENABLE_XONXOFF        ////切换为串行通信发送流软件流控制。
" g( \% v: q( w( i46.#define ENABLE_SOFTWARE_DEBOUNCE //一个简单的软件消除抖动特性硬限位开关。
. q! D' j7 G- [( }6 J47.#define HARD_LIMIT_FORCE_STATE_CHECK        //Grbl检查硬限位开关的状态2 Y8 G+ |$ ~6 n+ W# F
48.// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:编译时错误检查的定义值:$ l' w6 y# W( C- p8 [

, A0 e# u" s6 u6 B. _6 Q___________________________________________________________________________________________________! q$ c1 G- `* N( h2 |
/*. b5 Z1 d8 t- I" y( I
  config.h - compile time configuration! r  ~# d5 z! b( W3 A
  Part of Grbl
9 o0 B, G* v% n& w9 t. {& P- N" D5 S# [2 j
  Copyright (c) 2012-2015 Sungeun K. Jeon
' F$ v$ l3 a, e  Copyright (c) 2009-2011 Simen Svale Skogsrud- j: t6 ^4 J3 K2 E" U

. x8 D& Q( C7 z- q: P  Grbl is free software: you can redistribute it and/or modify) ^  B0 b! V4 _' @# g9 o, R7 t( Q) Y
  it under the terms of the GNU General Public License as published by
, s/ I; {8 C8 U  the Free Software Foundation, either version 3 of the License, or2 t# a5 Q5 F. d6 i2 s6 p
  (at your option) any later version./ U  C1 G! [0 H
8 x3 |9 n. S% w  z+ H% K8 ?
  Grbl is distributed in the hope that it will be useful,+ t9 {/ I# h  }/ x- O4 {
  but WITHOUT ANY WARRANTY; without even the implied warranty of4 ]1 I, ]- W$ E0 ?
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
( R+ F, o# U  R. O  GNU General Public License for more details.
3 l8 Q3 S) a# S+ [/ i7 T  h# \8 Y5 r% d( l# L
  You should have received a copy of the GNU General Public License/ ]- b+ N* l$ u" i; m/ l: U
  along with Grbl.  If not, see <http://www.gnu.org/licenses/>.
, Q  s% |/ ?* x; J& a' R4 Gconfig.h  -编译时配置,Grbl的一部分; U2 M3 \4 B- l: h2 |0 U3 i

3 k" g0 b5 N; E7 G# C版权(c)2012 - 2015 Sungeun K. Jeon
# n$ L8 A' R+ e$ ~" X) D, O6 a版权(c)2009 - 2011 Simen Svale Skogsrud
; Z2 W+ d  J+ d0 L0 h3 h+ ^
+ o- v' v4 E# i0 b8 FGrbl是免费软件:可以重新分配和/或修改
1 J2 b0 m! ^* HGNU通用公共许可证的条款下发布的自由软件基金会,版本3的许可,或(任您选)其后的版本。
0 X& H$ \1 l4 j, C# K- k
' J* i' r/ o1 f7 ]% S2 |* e! I0 K6 ]  jGrbl分布,希望这将是有用的,但是没有任何保证;没有即使的默示保证适销性或健身为特定目的。看到' j! T7 Q8 N/ E1 Q% s
GNU通用公共许可证的更多细节。
& }) {7 P- ]: J4 ]& g2 m) p6 f; j$ b2 s' H( G
你应该收到了GNU通用公共许可证的副本3 P' g2 C- S) i7 Z$ q2 c. J
连同Grbl。如果没有,看< http://www.gnu.org/licenses/ >。
5 e  j- [' V2 ?! {% D 5 b2 c: X) ]; g$ D. h# O# b
*/
6 m- {- U" A/ `  
) e% M1 F7 L4 z& }// This file contains compile-time configurations for Grbl's internal system. For the most part,0 e, `& V" v  p7 A
// users will not need to directly modify these, but they are here for specific needs, i.e.
0 p0 O0 x  @3 O6 n7 H- r# j// performance tuning or adjusting to non-typical machines.$ c: W" Z2 A7 I4 `" \$ j$ B( y/ J% M
//这个文件包含编译时配置Grbl的内部系统。在大多数情况下,
& W$ x7 B! S4 B+ Q2 C* Q//用户不需要直接修改这些,但是他们在这里为特定的需求,即。6 p* h+ W* x; t/ _2 L3 p/ ~
//性能调优或适应非典型的机器。) S7 R& J  _: N

" O) E6 C; \( K2 m; B! y// IMPORTANT: Any changes here requires a full re-compiling of the source code to propagate them.
/ y9 R, Z9 s+ E) ^* z( A! {. q//重要:任何变化需要一个完整的基于源代码的传播。
2 g6 p2 k9 O1 I7 @$ u* c3 H3 C! K
  Z& ~# |9 d& j" I. u#ifndef config_h3 e  p( Q4 s  ~$ S! n+ N# |
#define config_h8 k5 u8 ^4 Q3 L# [' H7 u6 ~- c5 C& \/ J# V
#include "grbl.h" // For Arduino IDE compatibility.
" S8 t$ U7 C- @: U1 q! E/ O# D) e- C* k0 l" f6 ^$ G& s% A* l
// Default settings. Used when resetting EEPROM. Change to desired name in defaults.h
- @& w% B/ Z0 Q+ P* p: v// 默认设置。在重置eepm时使用。在defaults.h改变想要的名字# i2 f1 w6 z2 Q
+ Z+ l  c" H; Z' w3 n
#define DEFAULTS_GENERIC/ K$ p8 B- r( {5 b8 G. {$ [' ~6 O

; D2 h0 H' P' G( w6 g// Serial baud rate
) \# `' o. e  W# o8 |6 c( X#define BAUD_RATE 115200                //配置串口波特率115200( E' C" c: F# }& O1 Z- k
, q( k/ ?5 g; ^8 n/ O6 C
// Default cpu mappings. Grbl officially supports the Arduino Uno only. Other processor types
; n7 R7 L3 W4 W8 Q; G, C// may exist from user-supplied templates or directly user-defined in cpu_map.h% M1 f8 k8 o9 V2 X% U
//默认cpu映射。Grbl正式支持Arduino Uno。其他类型的处理器可能存在cpu_map.h直接从用户提供的模板或用户定义的
1 A: ?2 B; H3 B1 C) `
2 P: b3 Q5 k' W- v#define CPU_MAP_ATMEGA328P // Arduino Uno CPU9 u! E+ F- U8 S2 U; D

/ P$ K$ m3 O/ d/ p// Define realtime command special characters. These characters are 'picked-off' directly from the4 |; T! S5 W. B- q
// serial read data stream and are not passed to the grbl line execution parser. Select characters/ k2 j) q; ~: ?& j, {# B# G
// that do not and must not exist in the streamed g-code program. ASCII control characters may be $ E0 ?* W6 b5 r+ b6 h7 I" r
// used, if they are available per user setup. Also, extended ASCII codes (>127), which are never in
- N* N2 Y! u) N  L1 n// g-code programs, maybe selected for interface programs.7 g* D& b' N9 w; J* P6 q2 U. ]9 d2 c
// NOTE: If changed, manually update help message in report.c.( \# T. E; L: L  Z2 g! c
3 B7 M8 F  k/ {$ R. p5 w0 t. |7 s" ~: v3 x
//定义实时命令特殊字符。这些字符是直接从“各个击破”串口读取数据流并没有传递到grbl行执行解析器。选择角色
- s- C$ n/ d' r, W) B* ^$ ^//不,不能存在于程序流刀位点。ASCII控制字符9 E, q! _3 O: k
//使用,如果他们是可用的每个用户设置。同时,扩展的ASCII码(> 127),从来没有5 F6 c, I4 S5 z: O1 e
//刀位点的程序,也许选择界面程序。
2 W3 y$ o' ~7 c* `, j* m//注意:如果改变,手动更新report.c帮助信息。% }8 n' T8 m9 z6 m

/ U1 }( q" ?1 [' K5 b5 D! k; [#define CMD_STATUS_REPORT '?'+ S4 \% z- K- O2 I1 m  J* y
#define CMD_FEED_HOLD '!'
+ a' q+ l: Q, t" u5 @& k#define CMD_CYCLE_START '~'" d; G8 A6 V! m/ R
#define CMD_RESET 0x18 // ctrl-x.
: N* K0 Z- u# ^- ^#define CMD_SAFETY_DOOR '@'
$ ]/ K- |0 c; _
) x6 `. V; B- f1 ]; N4 z& d; c// If homing is enabled, homing init lock sets Grbl into an alarm state upon power up. This forces
) g2 W7 n, ?) u4 R// the user to perform the homing cycle (or override the locks) before doing anything else. This is
/ s& ~8 }7 o; ~# u$ l1 c6 F// mainly a safety feature to remind the user to home, since position is unknown to Grbl.
5 C" N' N" V+ _4 T) l& k
) l4 e7 Z  x) K' k' S3 F7 n+ o//如果启用了回原点,导航初始化锁集Grbl进入警报状态启动。这就迫使
8 W' ?- h! x# [$ A0 m//用户执行归航周期(或覆盖锁)在做任何其他事情之前。这是
2 y: o! g+ o3 J0 i; \& ^) P6 h$ C//主要安全功能,提醒用户家里,因为Grbl位置是未知的。" o, C8 U0 ^( z7 K% [4 Q

; Y% ?5 R( S  ~. ?#define HOMING_INIT_LOCK // Comment to disable- ^- y( O+ Y0 ?' W6 M9 z" j& D
) D2 S6 B. Z. N  }  s
// Define the homing cycle patterns with bitmasks. The homing cycle first performs a search mode, J7 b0 ?+ S5 ~5 T3 p1 [: j& |' X
// to quickly engage the limit switches, followed by a slower locate mode, and finished by a short1 M4 D3 d% ?( [3 {; ~4 g  k6 v
// pull-off motion to disengage the limit switches. The following HOMING_CYCLE_x defines are executed ( k0 q! B. E) v. w' \4 ^
// in order starting with suffix 0 and completes the homing routine for the specified-axes only. If7 M, u- V; u! o
// an axis is omitted from the defines, it will not home, nor will the system update its position.
' a4 q% O; Z. D, x' b! S// Meaning that this allows for users with non-standard cartesian machines, such as a lathe (x then z,7 j3 ?3 j1 E* _, p4 m; K; m
// with no y), to configure the homing cycle behavior to their needs. & e2 e! y4 {9 H
// NOTE: The homing cycle is designed to allow sharing of limit pins, if the axes are not in the same8 ?5 P0 c4 Z4 f5 Z8 r+ l
// cycle, but this requires some pin settings changes in cpu_map.h file. For example, the default homing
- i  {; v, C5 J- k// cycle can share the Z limit pin with either X or Y limit pins, since they are on different cycles.
) Z& C3 O( A1 W3 b// By sharing a pin, this frees up a precious IO pin for other purposes. In theory, all axes limit pins; J( }1 U& ]4 T( }, _
// may be reduced to one pin, if all axes are homed with seperate cycles, or vice versa, all three axes
2 E* z; k& v1 f9 [) C) z% D// on separate pin, but homed in one cycle. Also, it should be noted that the function of hard limits
! i( E+ E+ l- A3 F2 J# l// will not be affected by pin sharing.( \) Q) x( e& O  R, Y& U# `2 x- e5 B: u
//定义导航循环模式的位掩码。归航周期首先执行一个搜索模式
9 @# k6 r1 A- Y% l1 i//快速进行限位开关,其次是较慢的定位模式,完成了由一个短
5 X' f5 L$ F; x//拖出运动脱离限位开关。以下HOMING_CYCLE_x定义执行
/ W* G' O' l2 U( C//为了与后缀0开始并完成specified-axes只寻的例程。如果
) h" h* ]+ S4 o$ p8 V) n  F! t//定义省略一个轴,它会不在家,也不会系统更新它的位置。
; R2 ^" R8 O+ `1 P) {//意义,这允许用户与非标准笛卡尔的机器,比如车床(x,z,
; P# D4 M! N; l. Y2 X; s//没有y),配置导航循环行为对他们的需求。
/ @' l( Z5 ~: Z. ^//注意:归航周期允许共享限制针,如果轴不相同
; B" p& W# D% m+ J& C3 |) p//循环,但这需要一些销设置cpu_map的变化。h文件。例如,默认的导航
& f* v4 G" C+ c! j5 w//循环可以分享Z限位销X或Y限制针,因为它们是在不同的周期。
- ~, v$ p+ _5 {3 |  c3 W//通过共享一个销,这腾出宝贵的IO销用于其他目的。从理论上讲,所有轴限制别针3 J7 P. E4 y8 h  E: K
//可能会减少到一个销,如果所有轴与分离周期居住的地方,反之亦然,所有三个轴4 F/ P! [% [: W: @+ B' u
//在不同销,但这时候一个周期。同时,应该注意的是,硬限制的功能
# Y+ c/ {% x/ Y1 {//将不会影响销共享。
- O+ F; e0 q8 @2 [+ C- l3 I  m$ [& }//注意:默认设置为一个传统的硬件数控机器。z轴首次明确,其次是X和Y。8 x9 t  L! F( q4 j/ D) P: R* T- L3 R- F
( A- C7 O5 y% |/ A) f  f
// NOTE: Defaults are set for a traditional 3-axis CNC machine. Z-axis first to clear, followed by X & Y.
) i* b: P& {' L8 k#define HOMING_CYCLE_0 (1<<Z_AXIS)                // REQUIRED: First move Z to clear workspace. 第一步Z清除工作区。
2 \0 V* \8 }% G2 R8 d; {#define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // OPTIONAL: Then move X,Y at the same time.然后X,Y在同一时间。
" J7 L& w) ?7 A* i4 q// #define HOMING_CYCLE_2                         // OPTIONAL: Uncomment and add axes mask to enable
2 `  n) R1 O7 I' G2 n
; L- g( F; W. ^4 D// Number of homing cycles performed after when the machine initially jogs to limit switches.
, B7 F6 r, Z2 G1 V* J0 g* N. o3 |// This help in preventing overshoot and should improve repeatability. This value should be one or 8 N) u0 f/ b5 v7 C
// greater.
$ X4 C. _4 K& _6 R3 Q//执行回原点循环次数后,当机器最初慢跑限位开关。这个帮助防止过度,应该提高重复性。这个值应该是一个或大。- O' ]) n6 o7 P2 Y7 C+ W2 J) m- U

$ N4 h. I+ E+ A+ q/ x  b#define N_HOMING_LOCATE_CYCLE 1 // Integer (1-128)
) k) J  u5 ]* E1 M% x& G+ ]7 _+ L. }1 X0 i5 X5 t
// After homing, Grbl will set by default the entire machine space into negative space, as is typical! v$ C' h1 {0 [3 w0 i/ V
// for professional CNC machines, regardless of where the limit switches are located. Uncomment this
' Z" X; X: m( f2 L' R// define to force Grbl to always set the machine origin at the homed location despite switch orientation.% k9 Z# r+ `/ C$ t8 z! `

9 Z9 P  u* P* [2 N  ~//导航后,默认Grbl将整个机器空间留白,是典型的专业数控机器,不管限位开关所在的地方。
( n' S- f" R  N8 @2 n//取消这定义迫使Grbl总是在这时候位置设置机器原点尽管开关方向。
! R9 R6 Q. Z6 E2 J1 s+ n% o/ G$ Y- n, \' V: s& O
// #define HOMING_FORCE_SET_ORIGIN // Uncomment to enable.' f) H# w* E1 l
! |. o; I  S+ B1 z/ {% F! Q

7 R3 F( ^8 [5 l9 X# k8 f- P" f: |// Number of blocks Grbl executes upon startup. These blocks are stored in EEPROM, where the size/ p) l; V% z( _8 j1 }3 s
// and addresses are defined in settings.h. With the current settings, up to 2 startup blocks may6 t6 I+ G' M' x
// be stored and executed in order. These startup blocks would typically be used to set the g-code
- t4 G4 H2 y  ~' D( U// parser state depending on user preferences.
+ m; L# r6 F4 G3 s+ l/ q
0 i# a( ~9 H3 `8 j% G; m//块Grbl启动时执行的数量。这些块存储在eepm,大小+ D8 x6 ]- L3 u5 `1 W( K8 k- o3 w
//和地址在settings.h中定义。与当前设置,可能2启动块
% Y) p" S& ?% q' g" f: m9 \//存储和执行。这些启动块通常被用来设置刀位点# R' r6 P4 ~9 D2 u* a4 ]+ p7 v
//解析器的状态取决于用户首选项。
& T; y' }# l& ~- v: H
6 a0 ^& f4 \! V$ k( s#define N_STARTUP_LINE 2 // Integer (1-2). Z/ D$ W" ?) G( d& z1 r* a* j

+ k) R3 x$ n, `3 u' O( [// Number of floating decimal points printed by Grbl for certain value types. These settings are
! Y+ d9 h1 k$ V) z# [+ ?// determined by realistic and commonly observed values in CNC machines. For example, position0 K7 m7 T! p& O6 t
// values cannot be less than 0.001mm or 0.0001in, because machines can not be physically more( J! y. Y# Z% }( a
// precise this. So, there is likely no need to change these, but you can if you need to here.9 ~6 Y1 m" o. i' j" L- O
// NOTE: Must be an integer value from 0 to ~4. More than 4 may exhibit round-off errors.5 L* ^: u- K/ J9 {* e) U, ?* z

/ s9 Y6 b0 S/ J( N// Grbl浮动小数点的数字印刷的特定的值类型。这些设置是0 h, S1 H; a# j* g, q/ u
//一般由现实和观测值在数控机器。例如,位置8 e3 N# H# z; l0 t$ g
//值不能小于0.001毫米或0.0001,因为机器不能身体更多6 f- r" G% Q8 ~. v/ `
//精确。因此,有可能不需要改变这些,但你可以在这里如果你需要。
$ a* [  u- r4 q8 H+ S# ]% ]" a. ?4 y* B1 D" b//注意:必须是一个整数值从0 ~ 4。超过4可能出现舍入错误。5 z, g# c3 r5 m4 Q5 |
; H, L- ~& @2 {4 `* L
#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 协调或位置价值英寸
1 Q0 q" z$ D( g5 h& F4 K" a#define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 协调在毫米或位置价值7 C0 ~5 U+ V$ b- h+ H9 w9 u
#define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分钟的速度值1 d" Q3 Z5 R8 y) A! o5 }
#define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分钟
. N; m  G# D; n0 A' F8 r0 S#define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 对浮点小数设置值1 V& x0 `# p& }: g8 n' ^. z6 G7 x

! r+ V- C) \) g9 `" C$ y// If your machine has two limits switches wired in parallel to one axis, you will need to enable
" N+ b4 q; S! z( ]- E// this feature. Since the two switches are sharing a single pin, there is no way for Grbl to tell
. k/ n9 X- J9 Q  J// which one is enabled. This option only effects homing, where if a limit is engaged, Grbl will ! k$ r. U& r, y  [' Y
// alarm out and force the user to manually disengage the limit switch. Otherwise, if you have one6 d2 }% U" f. L, U7 V
// limit switch for each axis, don't enable this option. By keeping it disabled, you can perform a
1 P* p0 g/ e, H& y) d! |, s// homing cycle while on the limit switch and not have to move the machine off of it.3 X4 `- i! U9 ]" e2 \

0 e0 V( G4 n# J//如果你的机器有两个极限开关连接在平行于一个轴,您需要启用7 o. C1 N- t9 q3 n0 a
//这个特性。自从两个交换机共享一个销,没有办法Grbl告诉7 I! E# o' y( r, G' b- d
//启用哪一个。此选项仅影响归航,如果限制,Grbl意志1 P: Q2 Z4 D/ R) R5 Z
//报警,迫使用户手动松开限位开关。否则,如果你有一个$ w$ A5 a  ]) \0 }* L4 }  i
//为每个轴限位开关,不启用该选项。通过保持禁用,您可以执行" d( V. z( m8 h$ I) `
//导航循环在限位开关并没有将这台机器。
/ h5 b8 m6 x0 W  ]! ]2 |0 O) V( z$ t
// #define LIMITS_TWO_SWITCHES_ON_AXES
  Z" v. \! Q/ Y* h
. t& u) y+ `% N* ?3 ?3 e5 W// Allows GRBL to track and report gcode line numbers.  Enabling this means that the planning buffer
1 m6 `$ `0 u/ V- D// goes from 18 or 16 to make room for the additional line number data in the plan_block_t struct
, N3 j  S: `& c  d+ C" w7 I: ^3 `+ [7 c3 C! Y0 d
//允许GRBL跟踪和报告gcode行号。使这意味着计划缓冲从18岁或16岁,为额外的行号plan_block_t结构中的数据+ {# d1 b, \3 E; Q

3 T, @8 l6 G* w. k* n: d5 {" J% g// #define USE_LINE_NUMBERS // Disabled by default. Uncomment to enable.
6 ^) o8 @1 z# F; `, d% \$ a5 A* `8 b" h/ _" z2 R
// Allows GRBL to report the real-time feed rate.  Enabling this means that GRBL will be reporting more
; ]/ ~8 ]! a4 _/ Z+ k$ N* }// data with each status update.
7 |! P2 i! o8 \( w// NOTE: This is experimental and doesn't quite work 100%. Maybe fixed or refactored later.
* U3 b+ k8 q9 n+ Y+ |" O0 `0 ]  D//允许GRBL报告实时进给速率。使这意味着GRBL将报告数据和状态更新。
; U- X7 g" \! R! \. g$ G7 B+ F8 \//注意:这是实验和100%没有工作。也许以后固定或重构。
7 U* Y' I" u' y3 X7 D) P! _' o
& N. s' X( `& V" v. {6 z// #define REPORT_REALTIME_RATE // Disabled by default. Uncomment to enable.
1 C% P# O3 L  O; b% Y* W
) T' {6 \2 H* B2 n6 Q' E( t, C// Upon a successful probe cycle, this option provides immediately feedback of the probe coordinates
, ~6 H6 @6 u9 t* e$ j# Y// through an automatically generated message. If disabled, users can still access the last probe4 d, W) |7 ]! J" ~- l4 S
// coordinates through Grbl '$#' print parameters." Q; @: m- u! ~3 R# ?
//在一个成功的调查周期,这个选项提供立即反馈的探测器坐标9 C7 y% O4 `5 C
//通过一个自动生成的消息。如果禁用,用户仍然能够访问调查6 G9 H) h8 d6 s" |7 D
//坐标通过Grbl $ #的打印参数。' i1 I/ Q$ d. F. K- [' G4 @

) |2 ?9 d2 H5 Y#define MESSAGE_PROBE_COORDINATES // Enabled by default. Comment to disable.
+ C4 l' q4 S  L$ \; O! j! X5 b ; u7 N: y: f) k! \* A0 ^; t& h
// Enables a second coolant control pin via the mist coolant g-code command M7 on the Arduino Uno
( M& f' W2 `! b2 @( k; z// analog pin 5. Only use this option if you require a second coolant control pin.
6 m5 G, @) U+ M0 ]4 K2 T/ ~9 C// NOTE: The M8 flood coolant control pin on analog pin 4 will still be functional regardless.
9 O4 N! g6 A7 q6 u$ P% [. a// #define ENABLE_M7 // Disabled by default. Uncomment to enable.4 h, |9 }/ o/ n% j4 p! ]: T

- h4 Y9 _0 a8 Z, D// This option causes the feed hold input to act as a safety door switch. A safety door, when triggered,
, d) v' F2 L+ V5 J; a# {// immediately forces a feed hold and then safely de-energizes the machine. Resuming is blocked until
3 k1 a1 J  G; @% k// the safety door is re-engaged. When it is, Grbl will re-energize the machine and then resume on the
+ p- G% L% ]# y& I// previous tool path, as if nothing happened.
+ B) a/ V" m5 \+ }  O4 r9 J" \// #define ENABLE_SAFETY_DOOR_INPUT_PIN // Default disabled. Uncomment to enable.
8 g2 g3 l" a5 F2 n
& I/ h: C' S1 X// After the safety door switch has been toggled and restored, this setting sets the power-up delay8 T2 `; w3 n$ l4 G0 _5 ]
// between restoring the spindle and coolant and resuming the cycle.4 V+ i! e4 m' w9 H2 E- ]
// NOTE: Delay value is defined in milliseconds from zero to 65,535.
3 f" G4 G( P9 V0 U, X. C+ g4 Z; O; N, e, w' d% a
//定义导航循环模式的位掩码。归航周期首先执行一个搜索模式4 [$ n% y5 j# U+ I$ M. u- _2 R% Y4 j* W
//快速进行限位开关,其次是较慢的定位模式,完成了由一个短
. P. _( {; n, t& g! O/ @* Z2 D$ [- [//拖出运动脱离限位开关。以下HOMING_CYCLE_x定义执行2 A+ L4 e- t( `  D) x' \$ l2 B1 I
//为了与后缀0开始并完成specified-axes只寻的例程。如果/ N) x4 _0 k& j/ _0 M! b
//定义省略一个轴,它会不在家,也不会系统更新它的位置。3 n3 [6 |: |$ _% B; c, Q& }
//意义,这允许用户与非标准笛卡尔的机器,比如车床(x,z,
/ x. a0 F& G# m( E* h//没有y),配置导航循环行为对他们的需求。7 w* v. v, x# ^
//注意:归航周期允许共享限制针,如果轴不相同3 S- h% U' P: v$ |
//循环,但这需要一些销设置cpu_map的变化。h文件。例如,默认的导航
& U. L6 p: ~- P  q//循环可以分享Z限位销X或Y限制针,因为它们是在不同的周期。  E" \" t* M2 C0 [8 R
//通过共享一个销,这腾出宝贵的IO销用于其他目的。从理论上讲,所有轴限制别针
9 S7 e! R( ~$ T: U//可能会减少到一个销,如果所有轴与分离周期居住的地方,反之亦然,所有三个轴
# ~$ i! c. h- g: g2 F/ I//在不同销,但这时候一个周期。同时,应该注意的是,硬限制的功能
3 m, E' W- T# q7 b% S7 e. B( J//将不会影响销共享。
+ [% K% _6 ~$ \0 w$ N; w+ ~8 g" w( \//注意:默认设置为一个传统的硬件数控机器。z轴首次明确,其次是X和Y。
6 w6 c7 S7 c9 j0 B& L6 L
* Q! T: g2 P# A- ^0 f8 D& \' f7 R, s0 q1 M+ p/ I
#define SAFETY_DOOR_SPINDLE_DELAY 4000
) Q& ~6 M- h$ m6 Q4 n#define SAFETY_DOOR_COOLANT_DELAY 1000
9 ?* L# F0 X# j/ |; O/ s6 a% M3 g5 j' H! r9 v# l( L
// Enable CoreXY kinematics. Use ONLY with CoreXY machines. ; C3 u0 A' ~0 Q- X) ^/ E
// IMPORTANT: If homing is enabled, you must reconfigure the homing cycle #defines above to
5 x: p0 a, h/ a9 c% Y9 M//启用CoreXY运动学。只使用与CoreXY机器。
( [3 w  n7 T/ d0 B+ r; `//重要:如果启用了自动寻的,你必须重新配置导航循环#定义上面
7 s) h6 z! k4 {. n) P9 `! a! X
6 P$ p1 d8 H9 f. V// #define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS)
8 b# Y( Q. z% H! X0 ?  U' [6 T& E. E
// NOTE: This configuration option alters the motion of the X and Y axes to principle of operation. Q, O3 Q( A/ C
// defined at (http://corexy.com/theory.html). Motors are assumed to positioned and wired exactly as& ?4 H3 O  n2 [; D! X6 m2 v
// described, if not, motions may move in strange directions. Grbl assumes the CoreXY A and B motors
1 ]+ S+ s1 A6 T/ ?// have the same steps per mm internally.
5 a2 y# Q0 @: U) o//注意:这种配置选项改变X和Y轴的运动原理,操作
, d/ h9 H( H( Z* s* O//定义(http://corexy.com/theory.html)。汽车被认为定位和连接一样
  _8 n/ M$ ?/ \) B9 B" `//描述,如果没有,运动可能会奇怪的方向移动。A和B Grbl假设CoreXY马达
8 @4 Q5 M1 f" q0 ?; E$ G' S//每毫米内部有相同的步骤。. X+ P2 H- g7 N, f) E% v! s; g

7 y; i( u# y+ K6 G# P// #define COREXY // Default disabled. Uncomment to enable.
4 P! q  [7 d9 }9 `4 g
- b/ K! p# |. W& y5 ^// Inverts pin logic of the control command pins. This essentially means when this option is enabled% ~2 P0 Y: o: F5 X- H( v. Q
// you can use normally-closed switches, rather than the default normally-open switches.
& O" F0 W3 D& m1 T: {& a& H// NOTE: Will eventually be added to Grbl settings in v1.0.
# h) i3 ]+ f% A3 a6 d//反转针销逻辑的控制命令。这实质上意味着当启用这个选项+ F6 P" N0 T' x" P( l. A1 x3 g
//可以使用闭合开关,而不是默认的常开开关。3 ?# E9 H* d  r+ i
//注意:最终将被添加到在v1.0 Grbl设置。
( o/ V" z, S" y& M) {+ s5 ^" @9 l% _! p2 S8 G
// #define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.( L% [6 \3 m! F
5 J% G1 c( j( w, ~2 d3 K$ e7 ?
// Inverts the spindle enable pin from low-disabled/high-enabled to low-enabled/high-disabled. Useful
2 e5 L; q+ g8 W5 t6 c0 s// for some pre-built electronic boards.# }# i" {2 t) E* r% u
// NOTE: If VARIABLE_SPINDLE is enabled(default), this option has no effect as the PWM output and
1 ^4 n, P6 z7 r( O0 h1 i0 ~: T// spindle enable are combined to one pin. If you need both this option and spindle speed PWM,
1 z$ j! K- j( P) `9 j1 C// uncomment the config option USE_SPINDLE_DIR_AS_ENABLE_PIN below.
0 m0 [9 g) A3 h. ]//反转主轴使销从low-disabled / high-enabled low-enabled / high-disabled。有用的) h; O. Y9 D) E" j5 R
//预构建的电子板。8 ]' |$ A& \, F
//注意:如果启用了VARIABLE_SPINDLE(默认),这个选项作为PWM输出并没有影响5 K+ K$ q1 s; I7 h# B# A
//销轴使结合。如果你需要这个选项和主轴转速PWM,( `* i3 `( n! h" G
//取消注释以下配置选项USE_SPINDLE_DIR_AS_ENABLE_PIN
5 O  E- e5 q0 r4 j$ h( \( ~1 P7 K! Z$ Z
! D# v+ b% E! \1 [* z: G7 b// #define INVERT_SPINDLE_ENABLE_PIN // Default disabled. Uncomment to enable.' v8 L* [" P/ S& h( X
9 ?6 A, I0 ?2 t! @, i3 ~8 Z
// Enable control pin states feedback in status reports. The data is presented as simple binary of  u0 O4 e( j6 r
// the control pin port (0 (low) or 1(high)), masked to show only the input pins. Non-control pins on the % `6 ]4 X6 o& B+ ~
// port will always show a 0 value. See cpu_map.h for the pin bitmap. As with the limit pin reporting,8 ~3 H2 g  q. [* V
// we do not recommend keeping this option enabled. Try to only use this for setting up a new CNC.7 n8 S- O4 o: B5 ~% k
//启用控制销状态反馈状态报告。作为简单的二进制数据+ r$ R7 w- n1 H8 d! h+ b! {
//控制针端口(0(低)或1(高)),蒙面,只显示输入插脚。非控制性针上
0 \2 ]4 Z0 c. t% S, @5 b* u' R//端口总是显示0值。看到cpu_map。针位图h。与限制销报告,& a+ R8 C9 h1 w9 z8 C" ]) i7 n
//我们不推荐保持启用这个选项。尽量只使用这个设置一个新的数控。  j: M1 I  E- f' Q

; C) w8 l8 k: _* T9 l// #define REPORT_CONTROL_PIN_STATE // Default disabled. Uncomment to enable.
0 D: G8 G6 N7 P3 \
0 V# y9 }) K9 C8 y// When Grbl powers-cycles or is hard reset with the Arduino reset button, Grbl boots up with no ALARM
2 @3 W; c! m7 h9 x& |  I. V// by default. This is to make it as simple as possible for new users to start using Grbl. When homing
1 p% U  T' G( |. F- u- {// is enabled and a user has installed limit switches, Grbl will boot up in an ALARM state to indicate
+ y1 f' t& Y* @. H// Grbl doesn't know its position and to force the user to home before proceeding. This option forces! N; E. i6 @3 ^; ]
// Grbl to always initialize into an ALARM state regardless of homing or not. This option is more for; x8 f8 j4 I0 `
// OEMs and LinuxCNC users that would like this power-cycle behavior.% `! R& K1 X; L; ^- V/ a! J8 y* j
//当Grbl powers-cycles还是硬重置Arduino复位按钮,Grbl启动没有报警
6 W* w5 z+ s- \//默认情况下。这是为了让新用户尽可能简单使用Grbl开始。当归航: E) m0 W. m0 X% K7 U
//启用和用户安装限位开关,Grbl将启动报警状态指示
6 g& P) Y3 o+ |/ d1 I0 i! T// Grbl不知道它的位置,迫使用户在继续之前回家。这个选项部队. S& I6 d7 i) K# R5 V4 M
// Grbl总是初始化进入警报状态不管归航。这个选项是更多
  |/ F2 b  W( k$ _2 O, K//原始设备制造商和LinuxCNC用户这样的控制行为。
, b0 U* Q: J, ^5 X+ a
4 z0 F% o# z8 z  ?' q( V2 Y" g// #define FORCE_INITIALIZATION_ALARM // Default disabled. Uncomment to enable.. j6 b9 J/ j- ^0 P6 y3 \

, {3 j6 v% E2 W5 W1 p) Y# ^  M// ---------------------------------------------------------------------------------------
# {+ s! f9 y9 P6 w// ADVANCED CONFIGURATION OPTIONS://高级配置选项:
+ i* \0 ~$ d; S- U! D, F0 x+ W( w( D$ |  j- F; X) D# ]9 A! {
// Enables minimal reporting feedback mode for GUIs, where human-readable strings are not as important.- ^# H2 t- w# W4 d0 m
// This saves nearly 2KB of flash space and may allow enough space to install other/future features.: Y* p; j8 P! s3 O  i' D9 l
// GUIs will need to install a look-up table for the error-codes that Grbl sends back in their place.
1 S9 M' y2 G: N+ Z4 ]/ v8 B8 A( D// NOTE: This feature is new and experimental. Make sure the GUI you are using supports this mode.
& f) v, L0 f8 j$ p& }& w
- E9 K5 {5 z  e* Z) u) I8 s// gui允许最小的报告反馈模式,人类可读的字符串在哪里不重要。# \/ ~4 Y- f/ s, H  g( t
//这个节省近2 kb的闪存空间,允许足够的空间来安装其他/未来的功能。  {- N% N) {# o5 `6 y7 @
// gui需要安装一个查找表的错误代码Grbl发回。
. ^( G+ c! @# @" Y//注意:此功能是新的和实验。确保您使用的GUI支持这种模式。
& R2 V9 q  N4 W# p5 }
$ U! S: i+ N0 Z/ y5 P// #define REPORT_GUI_MODE // Default disabled. Uncomment to enable.; @* T0 S9 t3 q% `
# N1 W) w7 |! w5 f1 d
// The temporal resolution of the acceleration management subsystem. A higher number gives smoother- A5 ]  t8 b" Y6 Q( d9 z
// acceleration, particularly noticeable on machines that run at very high feedrates, but may negatively
* j; @. w/ E  t$ o, \# ~// impact performance. The correct value for this parameter is machine dependent, so it's advised to
/ ~8 H. F# H9 ?+ z) {$ |% r// set this only as high as needed. Approximate successful values can widely range from 50 to 200 or more.: y' \6 a6 l/ P0 m
// NOTE: Changing this value also changes the execution time of a segment in the step segment buffer.
, i5 @9 L* o' L8 c, R7 \// When increasing this value, this stores less overall time in the segment buffer and vice versa. Make$ q: h  G1 S) K: }( b1 |% D
// certain the step segment buffer is increased/decreased to account for these changes.
) u; v, C* l; D1 E//加速度的时间分辨率管理子系统。更多更平稳
9 h+ m! W/ C, X5 N. }1 R; b" D0 y//加速度,特别明显的机器上,运行在非常高的进料速度,但可能负面* o( c- a& v2 N6 B/ n% D0 }
//影响性能。正确的值为这个参数是依赖于机器的,所以建议
( [, Y" n% K* z7 ^/ g3 Z$ z//这只设置为高。近似成功的价值观可以广泛的范围从50到200或者更多。, P0 e3 v. {% O/ _, |; k) r
//注意:改变这个值也变化的部分步骤的执行时间缓冲。
: X0 G0 K) i5 U3 a6 S: ^//增加这个值时,这个商店部分缓冲区的总时间减少,反之亦然。使
, E0 ], u& k" t8 [3 `+ s//特定步骤段缓冲是考虑这些变化增加/减少。. ~4 E8 B5 S1 l! c( ]7 Z5 _# ~0 O
% v" x" N4 k2 \; q0 p. ^  b6 ]
#define ACCELERATION_TICKS_PER_SECOND 100  //加速度的时间分辨率管理子系统。更多更平稳
* @: v8 I7 B: M+ ]% |# T5 k$ E1 X7 K
// Adaptive Multi-Axis Step Smoothing (AMASS) is an advanced feature that does what its name implies, " y  i: f* Q7 O
// smoothing the stepping of multi-axis motions. This feature smooths motion particularly at low step
0 `$ H4 {0 @9 y, x+ u. |4 ~// frequencies below 10kHz, where the aliasing between axes of multi-axis motions can cause audible
3 @/ e: Z  L" t# O$ M// noise and shake your machine. At even lower step frequencies, AMASS adapts and provides even better
* w3 s  f  l7 O4 b8 b% D- L// step smoothing. See stepper.c for more details on the AMASS system works.. t6 [  x2 D5 b8 ?) G7 a0 O
//自适应多轴步平滑(积累)是一种先进的功能,它的名字所暗示的那样,
5 t3 j9 L( Q; c1 y* V6 e; o//平滑的多轴步进运动。这个特性平滑运动尤其是在低一步, p3 [" v  K; ~
//频率低于10 khz,轴之间的混叠的多轴运动可能导致音响
; f! z1 b5 n/ |, E; X3 _1 h) i//噪音和震动你的机器。在更低的频率步,积累适应并提供更好
# D! d1 t- E: y//步骤平滑。看到步进。c更多细节的积累系统的工作原理。) c8 Z+ R3 P7 f2 M7 q0 I5 `
5 p' V$ a* I- z0 A9 n# m
#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING  // Default enabled. Comment to disable.//自适应多轴步平滑
1 Z# t& H# N3 R5 b$ O% q/ `3 i9 O- }! |* a6 A  I' _3 f
// Sets the maximum step rate allowed to be written as a Grbl setting. This option enables an error
! A( M* v$ |+ N; Y3 j// check in the settings module to prevent settings values that will exceed this limitation. The maximum1 }. f  l9 }  Z
// step rate is strictly limited by the CPU speed and will change if something other than an AVR running
& q3 a$ d, C6 R& B  M7 D: Z. n// at 16MHz is used.
: v5 ~& J6 |. S- Z, y( k// NOTE: For now disabled, will enable if flash space permits.
9 \2 R: n8 X1 m, K$ X1 m//设置最大一步速率可以写成Grbl设置。这个选项可以使一个错误! ?5 e6 R1 F. s+ F* v8 p+ I
//设置模块中检查,防止设置值将超过这个限制。的最大, d/ p9 j0 F% |5 h$ v
//步骤严格限制的CPU速度也会改变如果是其他AVR运行
9 T1 j! U& E" w7 s6 v//使用16兆赫。8 _6 `% N) l3 u3 Q3 c7 Y" Y: }
//注意:现在残疾,将使如果flash空间许可。/ [! I# ~0 F& m. F3 t- C4 q' m0 w
% j; X  c+ n7 `1 V9 U+ q: e
// #define MAX_STEP_RATE_HZ 30000 // Hz 设置最大一步速率
* f2 a: k* h+ W) U# S5 ?7 B4 v% [: D3 ?
// By default, Grbl sets all input pins to normal-high operation with their internal pull-up resistors
) {! s/ a3 C2 p0 y6 r// enabled. This simplifies the wiring for users by requiring only a switch connected to ground, 7 f8 P- G/ @( M7 _( a* m% Q  N
// although its recommended that users take the extra step of wiring in low-pass filter to reduce; G3 W; C' I! J2 s
// electrical noise detected by the pin. If the user inverts the pin in Grbl settings, this just flips
% z: ~+ Q* _3 a9 p6 N% x/ r// which high or low reading indicates an active signal. In normal operation, this means the user ; g' a' w" e* `5 ?; K4 u
// needs to connect a normal-open switch, but if inverted, this means the user should connect a
0 K# n) w6 d2 G  g: Z// normal-closed switch. . j# b: i; Y( q8 f
// The following options disable the internal pull-up resistors, sets the pins to a normal-low 9 Q; a4 O2 n/ @# G8 \. {7 R# @( a  t
// operation, and switches must be now connect to Vcc instead of ground. This also flips the meaning , s) \' V; L3 g, P, v! ]- F' ^
// of the invert pin Grbl setting, where an inverted setting now means the user should connect a
6 e) ?) j. c' B; F" N+ M// normal-open switch and vice versa.3 p" u- n; T& ?
// NOTE: All pins associated with the feature are disabled, i.e. XYZ limit pins, not individual axes., @2 M  ^1 [6 u0 t8 o( X9 k
// WARNING: When the pull-ups are disabled, this requires additional wiring with pull-down resistors!
1 M: W3 v" M3 }. p//默认情况下,Grbl所有输入引脚设置为正常高操作的内部上拉电阻
8 a. R4 n: L, ^' [//启用。这简化了布线为用户只需要一个开关连接到地面,
7 u% a- a' M6 |5 h' T! e//虽然其建议用户采取额外的步骤,在低通滤波器来减少布线
2 N. n# `/ L% `2 |0 Q1 I) y//电噪音检测销。如果用户反转的销Grbl设置,这只是翻转
+ ^! ]# X0 T, F7 q% e/ I7 n' e//读高或低表明一个积极的信号。在正常操作中,这意味着用户* Z& _( f1 M! y
//需要连接一个常开开关,但如果倒,这意味着用户应该连接( ^4 _2 U9 n6 d' B
// normal-closed开关。
4 {$ p9 e' a  j! S) s! v# \4 k//以下选项禁用内部上拉电阻,一般低设置别针: m' c& u7 Z5 ]4 R
//操作,现在开关必须连接到Vcc代替地面。这也掀的意思) ^" l/ p% h" e- _: D0 X- o9 q
//反销Grbl设置,一个倒置的设置现在意味着用户应该连接2 @: }6 I' O  R
//常开开关,反之亦然。$ {5 B5 A6 m4 b5 [; {
//注意:所有针与功能被禁用,例如XYZ限制针,而不是单独的轴。! r, {+ H' a9 A- E4 x
//警告:引体向上被禁用时,这需要额外的布线与下拉电阻!
$ j4 i0 k0 q# `' \  E/ [7 e5 y8 t( U
//#define DISABLE_LIMIT_PIN_PULL_UP //以下选项禁用内部上拉电阻
0 \( w& Q5 D) j//#define DISABLE_PROBE_PIN_PULL_UP
; ?$ F* v( @( V: _0 x//#define DISABLE_CONTROL_PIN_PULL_UP* a3 T/ _- Z* C$ c

; c4 d! [8 [" i7 K* M* Y// Sets which axis the tool length offset is applied. Assumes the spindle is always parallel with ! k7 R: H1 f3 v4 v) q
// the selected axis with the tool oriented toward the negative direction. In other words, a positive. y  r. I( D9 \' B
// tool length offset value is subtracted from the current location.2 d! Y: b8 i& D8 N2 \
//设置哪个轴长度补偿应用的工具。假设轴总是与* b6 N( r& u" m) j: |$ f# y
//选择轴工具面向负方向。换句话说,一个积极的
& L& u3 w' m% k" W* T//工具长度偏移值减去从当前位置。
; e& {. i4 t1 f9 o% O9 O0 [4 r5 L! C1 K# M0 B  Y: _% ~1 B9 a
#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS // Default z-axis. Valid values are X_AXIS, Y_AXIS, or Z_AXIS.设置哪个轴长度补偿应用的工具
% j) Z3 ]# U# h  a/ u0 B; D' C6 R! H+ w+ y  o5 @9 ]
// Enables variable spindle output voltage for different RPM values. On the Arduino Uno, the spindle, j9 `) k8 {8 G* z3 t: i! L
// enable pin will output 5V for maximum RPM with 256 intermediate levels and 0V when disabled.5 d% [: }4 ^# |" I* }9 J; }' u
// NOTE: IMPORTANT for Arduino Unos! When enabled, the Z-limit pin D11 and spindle enable pin D12 switch!
$ n8 l- V) B. ?  x/ q// The hardware PWM output on pin D11 is required for variable spindle output voltages.9 S6 B( J/ i: _
//允许变量轴输出电压不同的转速值。Arduino Uno,主轴+ O, S1 y* N7 r4 X; @' P5 b2 \
//启用销将输出5 v的最高转速256中级水平和0 v时禁用。9 f" m3 m, Y8 b6 @- ]; G
//注意:重要Arduino凯泽本人!当启用时,Z-limit销这里和轴销D12开关!
3 D! r7 j5 A! k. n//硬件PWM输出销这里需要变量轴输出电压。
2 P" I3 ]! P7 U4 i
7 B$ |* \9 Z3 m. S. w#define VARIABLE_SPINDLE // Default enabled. Comment to disable.//允许主轴输出电压不同的转速值
3 M, E9 p3 f  g! j) ?3 n. j
" i) B' q. T3 U% O* q5 v3 k9 C// Used by the variable spindle output only. These parameters set the maximum and minimum spindle speed. Z( |0 F, Q! D2 t0 s) |) p) c; b
// "S" g-code values to correspond to the maximum and minimum pin voltages. There are 256 discrete and " q1 u$ ^# y% }. o+ r
// equally divided voltage bins between the maximum and minimum spindle speeds. So for a 5V pin, 1000
' o4 `! z/ n" S// max rpm, and 250 min rpm, the spindle output voltage would be set for the following "S" commands:
. k. u2 U5 S  ^8 L$ B( a# ~( C// "S1000" @ 5V, "S250" @ 0.02V, and "S625" @ 2.5V (mid-range). The pin outputs 0V when disabled.; E# j& ]$ Z4 |0 k& w+ M) A
//使用的变量轴输出。这些参数设置最大和最小轴转速- I2 E; {% n" O$ O) k2 }7 |
//“S”刀位点值对应于销电压的最大值和最小值。有256个离散和
0 o9 `: ^7 z1 x5 Q3 I4 V9 [" ?//电压平均分配箱主轴速度的最大值和最小值之间。所以对于一个5 v销,1000
' l# M5 a9 ^# r7 B// max rpm,250分钟rpm,主轴输出电压将为以下“S”命令:) r# i0 D4 E) j& Q- h; o
// @“S1000 5 v,“S250”@ 0.02 v,“S625”@ 2.5 v(中档)。销输出0 v时禁用。
+ H8 t8 c5 V. V8 _+ J+ u
0 q: w/ \0 a6 f- \! X) K#define SPINDLE_MAX_RPM 1000.0 // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.0 z* O# `% A$ K+ b0 C
#define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.
% v9 ?$ ]8 ~: G9 {
( r( v- x: w; N// Used by variable spindle output only. This forces the PWM output to a minimum duty cycle when enabled.
7 `4 j! {( Y) @0 }: Z" P7 T0 t5 b// When disabled, the PWM pin will still read 0V. Most users will not need this option, but it may be
1 y# K% _! l3 D: i// useful in certain scenarios. This setting does not update the minimum spindle RPM calculations. Any
+ v' {! u, v! C// spindle RPM output lower than this value will be set to this value.
: c7 f# K8 _1 V! H& P5 D% f, u//使用的变量轴输出。这迫使PWM输出最小占空比时启用。
$ ~4 v. D) I2 X//当禁用,PWM销仍读0 v。大多数用户不需要这个选项,但是它可能是
. L" Y' L& j! N& ?% w4 m7 p; w8 {//在某些情况下很有用。这个设置不会更新最小主轴转速计算。任何$ g- [1 l0 e  S1 G& ~
//输出轴转速低于这个值将被设置为这个值。
, Z" C: r+ [- p
' y% h4 V( N7 [9 I  o7 T. |// #define MINIMUM_SPINDLE_PWM 5 // Default disabled. Uncomment to enable. Integer (0-255)
9 i: c1 W6 ~( `1 E4 ?! ]' M  p# D  j% J3 r, u% U9 B
// By default on a 328p(Uno), Grbl combines the variable spindle PWM and the enable into one pin to help ( C* h4 D: X, B. n+ k$ s! Q. G2 v
// preserve I/O pins. For certain setups, these may need to be separate pins. This configure option uses8 h, ~- c8 V; [& V4 w5 ^" V
// the spindle direction pin(D13) as a separate spindle enable pin along with spindle speed PWM on pin D11.   u% m8 c" A6 |2 V9 p
// NOTE: This configure option only works with VARIABLE_SPINDLE enabled and a 328p processor (Uno).
4 P9 s( T6 J5 F  ^/ [// NOTE: With no direction pin, the spindle clockwise M4 g-code command will be removed. M3 and M5 still work.
2 W5 _  L" w& k" m// NOTE: BEWARE! The Arduino bootloader toggles the D13 pin when it powers up. If you flash Grbl with7 I: Q# T# A% \' g/ g6 t
// a programmer (you can use a spare Arduino as "Arduino as ISP". Search the web on how to wire this.),
4 w7 c. s" l. `  j" p' K' G  q// this D13 LED toggling should go away. We haven't tested this though. Please report how it goes!
! \7 f! e! N! e  O5 n8 n0 e//默认ATmega328 p(Uno),Grbl结合变量轴PWM和使到一个销的帮助
8 ^8 X% Q6 `0 B( a: Y0 \//保存I / O管脚。对于某些设置,这些可能需要单独的别针。这个配置选项使用+ G/ O2 Q. s( d, I* Z- ]7 f
//方向轴销(D13)作为一个单独的轴销上启用销以及主轴转速PWM这里。
% \: e% V& ]7 q& O( _/ c) K+ n//注意:该配置选项仅适用于VARIABLE_SPINDLE启用和328 p处理器(Uno)。
! j5 D* T# ?. D! m' x) o2 s' C//注意:没有方向销,主轴顺时针M4刀位点命令将被删除。M3和M5仍然工作。
1 F# X" b/ @. @  t+ P//注意:小心!Arduino引导装载程序切换D13销的权力。如果flash Grbl" [7 Y8 f; c# x5 y# A) P2 r  {0 L" u
//程序员(您可以使用一个备用Arduino“Arduino ISP”。搜索网络如何线),
1 B2 P' z& F1 k0 C//这D13导致切换应该消失。我们还没有测试这个。请报告将会怎样!
: C' I: }3 Q, \6 ^. l8 F8 W2 g
8 G& [4 |# J+ M// #define USE_SPINDLE_DIR_AS_ENABLE_PIN // Default disabled. Uncomment to enable.1 D2 M; Q3 r9 Y0 G2 p
% x+ Z1 Q2 e' T0 ~
// With this enabled, Grbl sends back an echo of the line it has received, which has been pre-parsed (spaces
" l0 C/ f1 |. W+ N, D, \// removed, capitalized letters, no comments) and is to be immediately executed by Grbl. Echoes will not be
' U6 p0 C* i7 |& H% E// sent upon a line buffer overflow, but should for all normal lines sent to Grbl. For example, if a user ! \: Q+ ~/ S; O) d  h
// sendss the line 'g1 x1.032 y2.45 (test comment)', Grbl will echo back in the form '[echo: G1X1.032Y2.45]'.
# O7 P$ z/ M% M# n$ t! W// NOTE: Only use this for debugging purposes!! When echoing, this takes up valuable resources and can effect
6 \$ O3 r2 \4 M- ], |- h// performance. If absolutely needed for normal operation, the serial write buffer should be greatly increased1 w- N" K( Y9 O; }3 r
// to help minimize transmission waiting within the serial write protocol.
; Q" t) f) A6 r: w! P$ t
- a5 }" d1 N( H3 Z- H//启用,Grbl发回的回声线已收到,已预编译(空间
+ d1 d0 l2 G( f, a4 H5 K//移除,大写字母,没有评论),由Grbl立即执行。回声将不会
, I2 R* K1 Q' l( D+ o' R0 v//发送一个线缓冲区溢位,但应该对所有正常线路送到Grbl。例如,如果一个用户
) e5 T" J* R& v- `! C- j* q1 m) c7 i//发送线的g1 x1.032 y2.45(测试评论)形式”,Grbl将回声”(回声:G1X1.032Y2.45]”。
: r' d6 J' C6 F! N0 P9 ~8 O/ s& u//注意:只使用这个调试! !当呼应,这占用了宝贵的资源,可以影响
6 i7 D2 }" T) X* M, z9 l//性能。如果正常运行所需的绝对,串行写入缓冲器应该大大增加1 C  ]' o& |' V- j2 L
//帮助最小化传输等系列内写协议。3 _; K- x( |1 O

! h1 s& {$ N  m4 r/ O" e// #define REPORT_ECHO_LINE_RECEIVED // Default disabled. Uncomment to enable.
4 y- U4 E& A. X! @- _7 o- {" q. ^9 o! b! R: q
// Minimum planner junction speed. Sets the default minimum junction speed the planner plans to at) p1 r! V: x' d' S7 o
// every buffer block junction, except for starting from rest and end of the buffer, which are always
7 @! X* [- y8 f0 u// zero. This value controls how fast the machine moves through junctions with no regard for acceleration
- P+ U( w2 D! }+ n( R) D0 H// limits or angle between neighboring block line move directions. This is useful for machines that can't
# T3 ^, u/ \9 t2 p, v& j/ L" l  y// tolerate the tool dwelling for a split second, i.e. 3d printers or laser cutters. If used, this value
2 p8 ]" R1 l1 ^9 F0 J$ j// should not be much greater than zero or to the minimum value necessary for the machine to work.
' F3 V% y$ f& {1 U
4 w; K! \6 x" R, R7 y* y//最小规划师结速度。设置默认最小连接速度规划计划
' X/ }, I* T; X8 F% J" p//每一个缓冲块接头,除了从结束休息和缓冲区,它总是1 O: P  i% B. X; M
// 0。这个值控制机器的速度穿过路口,没有考虑加速度9 L* O! |+ q8 m' e$ s
//限制或相邻块之间的角线方向移动。这是有用的机器,不能
. s7 {$ G- b, \, U//容忍工具居住某一刹那,即3 d打印机或激光切割机。如果使用这个值6 k. p( f4 G8 F5 a1 S/ T9 Z
//不应大于零或机器工作所需的最小值。
; u6 z- l" I- a1 x
, a& N3 M+ d5 ^7 C#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min)) _8 K) |2 I0 {

" N8 t4 [* e( ]2 r) M& B: S3 h// Sets the minimum feed rate the planner will allow. Any value below it will be set to this minimum" i; c. [" m, m) r: U& \* O1 x
// value. This also ensures that a planned motion always completes and accounts for any floating-point
; u0 z6 A# s1 P. `* v: E// round-off errors. Although not recommended, a lower value than 1.0 mm/min will likely work in smaller" _4 i& G! L8 F; H
// machines, perhaps to 0.1mm/min, but your success may vary based on multiple factors.* |$ e$ ~& w0 ~4 V
//设置计划将允许的最小进给速率。任何价值低于它将被设置为最低值。这也保证了运动计划总是完成,占任何浮点$ h7 h1 |; d* d1 n2 U& m
//舍入错误。虽然不推荐,价值低于1.0毫米/分钟可能会在较小的工作
" ?' U: r) H9 B* j* u5 J& K  F5 p% _//机器,也许到0.1毫米/分钟,但你的成功基于多种因素可能会有所不同。
! w+ X! K$ D3 ]0 S
6 k/ j& x) m' d( l4 k8 Y#define MINIMUM_FEED_RATE 1.0 // (mm/min)//设置计划将允许的最小进给速率. G- `& j4 h0 |; r# ~8 @

7 k" Z! O+ I& H+ W( L) X9 h// Number of arc generation iterations by small angle approximation before exact arc trajectory ' e7 _& s9 F( a
// correction with expensive sin() and cos() calcualtions. This parameter maybe decreased if there / f5 R  ^( T: t# K. \& m
// are issues with the accuracy of the arc generations, or increased if arc execution is getting
# C% f! \& T& r! n8 a" O7 g3 [// bogged down by too many trig calculations.
& e, H: `7 O( m  f. s! ?//弧生成迭代次数之前小角度近似精确的弧线轨迹
, Y$ G" ?+ ~/ j. O( J, m: `//修正与昂贵的sin()和cos()calcualtions。如果有这个参数可能减少- N! X, m1 Y7 o1 W, z
//与弧一代又一代的准确性问题,或如果电弧执行得到增加: h) s+ W3 \0 r% S' r7 P4 y7 R
//太多的三角计算的泥潭。
0 w8 V& a: u) b! W. ]. }1 _9 B9 _4 J9 N9 w
#define N_ARC_CORRECTION 12 // Integer (1-255)
7 P8 f) U1 `' A7 ?
, w% e( ?6 l+ x! M2 i+ C- V. U" `// The arc G2/3 g-code standard is problematic by definition. Radius-based arcs have horrible numerical 4 b+ N1 A1 }4 ~# g4 E) |
// errors when arc at semi-circles(pi) or full-circles(2*pi). Offset-based arcs are much more accurate 0 M& j1 d% U2 j2 W% y2 ~3 F4 K  N
// but still have a problem when arcs are full-circles (2*pi). This define accounts for the floating ( W9 Z3 ?1 d( Z% _9 }! f5 k
// point issues when offset-based arcs are commanded as full circles, but get interpreted as extremely
% l; y- F& `2 p3 V8 z// small arcs with around machine epsilon (1.2e-7rad) due to numerical round-off and precision issues.
) b6 i. Y% c1 U/ s$ e7 K3 k// This define value sets the machine epsilon cutoff to determine if the arc is a full-circle or not.
+ @' v3 h* I/ s  G0 U6 _4 C# l// NOTE: Be very careful when adjusting this value. It should always be greater than 1.2e-7 but not too, j3 A4 p0 p2 Z2 f$ c  o2 o8 g( @
// much greater than this. The default setting should capture most, if not all, full arc error situations.
7 Z" I  J" H* S$ o& A( A//弧G2/3刀位点的标准定义是有问题的。Radius-based弧有可怕的数值
+ \8 I6 \# U# M& X. Z//错误当电弧在半圆(π)或原点(2 *π)。Offset-based弧更准确* T) W9 C' i3 ?1 t6 ?
//但仍有一个问题当弧原点(2 *π)。这个定义占浮动# {! P' r- \" f) H! n# e
//当offset-based弧吩咐点问题完整的圆,但解释为极& g9 h2 @- J6 a- K
//小弧机周围ε(1.2 e-7rad)由于数字舍入和精度问题。
5 m) q: O4 ?9 S6 C; S//定义值设置机器ε截止来确定电弧是一个原点了。
4 S( Z0 D; V7 X: L& c//注意:调整这个值时非常小心。它应该总是大于1.2 e -但不要太2 |4 V( Z2 l( z3 p7 Q" d; Z( x
//比这大得多。默认设置应该捕获大部分,如果不是全部,全部错误的情况。) H( y" S  o3 U( f( A  g; V3 ~

( S% F0 ?, d- ~4 G( O#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)
  L1 n2 _9 f0 U. b, ^0 x7 M. w6 x& t, N9 _5 A$ ?
// Time delay increments performed during a dwell. The default value is set at 50ms, which provides( i5 A8 P5 P& M1 R  k" M5 k* E$ Y
// a maximum time delay of roughly 55 minutes, more than enough for most any application. Increasing5 A# U& J: G. r) m1 ^8 N# p* x
// this delay will increase the maximum dwell time linearly, but also reduces the responsiveness of
1 h! m5 V8 b3 e1 p: y8 O6 M  S2 }// run-time command executions, like status reports, since these are performed between each dwell
9 x: n# \: f' ~# W7 Y// time step. Also, keep in mind that the Arduino delay timer is not very accurate for long delays.9 l3 Z6 }6 F% x7 m( `, z+ K
//延时增加表现在住。默认值设置为50毫秒,它提供了
+ t+ C& F7 L; H6 d//最大延时约55分钟,足够对大多数任何应用程序。增加
0 U* ]7 T( [. R; p//这种延迟将增加线性最大停留时间,也减少了响应能力0 A$ C) \- p: ]" }4 K# L3 n! d
//运行命令执行状态报告一样,因为这些每个住之间执行
9 v6 \5 r! a8 T/ I. }//时间步。还有,记住,Arduino延迟计时器不是很准确的长时间延误。
  m# Z4 f" S6 O: f- M! ^0 L* A% S5 V/ A" ]( o5 Z  P- I1 e2 F7 o
#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds)
. r7 Y9 s' ^5 \  `3 M" H: i+ [$ v% t/ s6 s# S' g
// Creates a delay between the direction pin setting and corresponding step pulse by creating! k/ y  S" F" f5 v, W! J7 u  Q
// another interrupt (Timer2 compare) to manage it. The main Grbl interrupt (Timer1 compare)
5 R7 r" \- h  r. u8 R% V// sets the direction pins, and does not immediately set the stepper pins, as it would in
. p2 z$ K8 C( |/ [$ n: r+ u" p6 j// normal operation. The Timer2 compare fires next to set the stepper pins after the step " ]( }; s4 f4 p" Q: d( O
// pulse delay time, and Timer2 overflow will complete the step pulse, except now delayed ! l1 T) X# J3 A
// by the step pulse time plus the step pulse delay. (Thanks langwadt for the idea!)
" H1 c8 z, h3 v# w0 S! W// NOTE: Uncomment to enable. The recommended delay must be > 3us, and, when added with the
! w: C$ A0 v( d! g8 E2 X// user-supplied step pulse time, the total time must not exceed 127us. Reported successful% `% l0 I# b" n* s
// values for certain setups have ranged from 5 to 20us.
1 h& b1 {5 a/ c//创建一个方向销之间的延迟脉冲通过创建设置和相应的步骤
4 r& I0 Z( R& w5 s//另一个中断(Timer2比较)来管理它。主要Grbl中断(Timer1比较)
, t' v; V# K7 G0 G, \! |- g: Q//设置方向针,不立即设置步进针,因为它会在+ b7 m1 z. e- {2 s0 o3 @
//正常操作。Timer2比较火旁边设置步进针后一步. z0 W7 C1 U; F: ]3 f0 W! h; R
//脉冲延迟时间,Timer2溢出脉冲将完成的步骤,现在延迟除外
" z9 R) V; k" P5 s, M! X# C//脉冲时间加上的一步一步脉冲延迟。(感谢langwadt主意!)
1 j# v2 [" a5 |. R//注意:取消启用。必须> 3,建议延迟,当添加的
1 }) @# I* L* n% A4 |//用户提供的步骤脉冲时间,总时间不得超过127美元。成功的报道9 B0 C$ p" X! |2 f0 }6 K, E0 g" M6 O  g
//值对某些设置范围从5到20。
% t2 S/ _$ p& P. X9 J# N; w0 `& `$ \4 u" }$ D- v
// #define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled./ e6 f* Q/ w; `- h; `

1 E$ P( {' J7 F# B5 i// The number of linear motions in the planner buffer to be planned at any give time. The vast* R8 t' W1 t/ T& _
// majority of RAM that Grbl uses is based on this buffer size. Only increase if there is extra
/ I  d7 I" u! [: ~+ R// available RAM, like when re-compiling for a Mega or Sanguino. Or decrease if the Arduino
( p$ v: m* d9 `, E* Z// begins to crash due to the lack of available RAM or if the CPU is having trouble keeping6 F' m6 {; e' Z3 K/ T
// up with planning new incoming motions as they are executed.
6 D8 r. W. O% T! p//线性运动规划师缓冲区的数量在任何给出时间计划。绝大
; z3 ~) D1 N9 K- T! v4 c//多数RAM Grbl使用基于这个缓冲区的大小。如果有额外的只会增加: B. @( y/ p" i2 l
//可用内存,比如当基于大型或Sanguino。如果Arduino或减少
$ c4 B( M- G% ~% y# F1 z1 V//开始崩溃由于缺乏可用的RAM或者CPU是难以保持
, `/ e6 |5 w5 ^% d% R( J//与规划新传入的动作执行。. P) p% j# ?2 q' ?; r

+ P5 W- `' W  b  ?& m% }// #define BLOCK_BUFFER_SIZE 18  // Uncomment to override default in planner.h.- G9 {8 ]3 @; G8 m( A% K

2 o: N3 c# g0 [5 W) k1 N// Governs the size of the intermediary step segment buffer between the step execution algorithm; \- H, X. Q( A7 i4 r; x' t/ K
// and the planner blocks. Each segment is set of steps executed at a constant velocity over a' w! `2 e8 ]8 q6 [9 W
// fixed time defined by ACCELERATION_TICKS_PER_SECOND. They are computed such that the planner
, Y; {' K9 Z9 f1 D9 K// block velocity profile is traced exactly. The size of this buffer governs how much step * F! x. _( m; s$ m
// execution lead time there is for other Grbl processes have to compute and do their thing ' x1 S0 ~( A1 c- {- e
// before having to come back and refill this buffer, currently at ~50msec of step moves.6 j4 J, M( g4 j: \+ O
//控制之间的中间段缓冲大小的步骤执行算法
' M" _' D! H$ l. g. q  N//和规划师块。每一部分的步骤执行在一个恒定的速度
" ?; {* J+ _7 h7 R//固定的时间由ACCELERATION_TICKS_PER_SECOND定义的。他们计算的计划
) j: ^: m* j' \+ }//块速度剖面追踪到底。这个缓冲区的大小控制多少步骤
7 z1 }" Z( D$ e2 T6 N7 t//执行时间有其他Grbl过程需要计算和做他们的事情/ {! s9 g5 O  ?. G  R
//之前必须回来重新填充这个缓冲区,目前移动~ 50毫秒的一步。" m. c6 u8 I* I  k2 b" t' k
! l1 P- h) ~% i5 J3 @
// #define SEGMENT_BUFFER_SIZE 6 // Uncomment to override default in stepper.h.
4 |  o) [* ~& f% w1 }" q1 x; [# t' l6 S* [
// Line buffer size from the serial input stream to be executed. Also, governs the size of
7 e& Q' F2 b! e- l// each of the startup blocks, as they are each stored as a string of this size. Make sure
2 Z( S- r" F5 x0 w9 J4 m& L// to account for the available EEPROM at the defined memory address in settings.h and for* q- s; W; w4 T5 g, P% a* N
// the number of desired startup blocks.
# l# R1 j/ Q: _  {7 [// NOTE: 80 characters is not a problem except for extreme cases, but the line buffer size
7 q' z- h% \2 Z1 r: J- u// can be too small and g-code blocks can get truncated. Officially, the g-code standards
: t1 C+ C2 D& ]3 U, U. v; R9 D// support up to 256 characters. In future versions, this default will be increased, when
+ o0 K8 h( S# j* F# C( J// we know how much extra memory space we can re-invest into this.5 w9 J( W9 ]) J* u  p* K* m' d* U4 T
//行执行串行输入流的缓冲区大小。同时,大小的控制4 S# F. W. g$ J$ d" k3 o+ P6 J
//每个启动模块,它们分别存储为字符串的大小。确保# [- Y4 P9 T  i, s4 N. G* w
//占可用eepm定义内存地址的设置。h和
9 g) J) Y. ?8 b, \1 y# h//需要启动块的数量。
1 L3 V4 k+ r2 P0 Y//注意:80个字符不是一个问题,除了极端的情况下,但线缓冲区大小; u0 \" K2 T7 u' Y3 }" h8 C; @; [
//可以太小和刀位点块可以截断。正式,刀位点标准
4 V! ^" v' v( M$ u$ @5 v, B1 d//支持多达256个字符。在未来的版本中,这个违约将会增加,当
1 M! P! ?* e1 k+ D5 B: x2 R//我们知道多少额外内存空间的时候我们可以再投资。
2 f# [0 d2 s6 |. |# U- X& N
$ y! {# N7 J  ~( L4 [- d// #define LINE_BUFFER_SIZE 80  // Uncomment to override default in protocol.h% u) M8 D( j6 v4 B: H  S. K
  % R2 W4 `5 B  I6 t% X; J, ?
// Serial send and receive buffer size. The receive buffer is often used as another streaming
/ ], x, J3 ^8 r* v: r// buffer to store incoming blocks to be processed by Grbl when its ready. Most streaming+ e2 f  ^- F9 A# D
// interfaces will character count and track each block send to each block response. So,
- l% ?4 r/ \/ z  \) W: R// increase the receive buffer if a deeper receive buffer is needed for streaming and avaiable
! B+ C* z" G; x, O// memory allows. The send buffer primarily handles messages in Grbl. Only increase if large
# S, `4 o, h, g- B8 h; C- {// messages are sent and Grbl begins to stall, waiting to send the rest of the message.
' T' \3 L" E. }) k// NOTE: Buffer size values must be greater than zero and less than 256.
7 b" x' |% d) d// #define RX_BUFFER_SIZE 128 // Uncomment to override defaults in serial.h
+ d% p6 q+ T4 p7 j9 ?( D: A( P//串行发送和接收缓冲区大小。接收缓冲区通常用作另一个流
- N/ _* J5 N$ t  U+ Z& Y//缓冲存储传入的块来处理Grbl当它准备好了。最流# H2 i9 N3 B+ Z2 K( i8 {
//接口将字符计数和跟踪每一块发送给每个块的回应。所以,
3 T# v3 s3 {+ S3 K  r//增加接收缓冲区如果需要更深层次的接收缓冲区为流,、
) ^% o9 w$ A$ G# h- u1 o; e//内存允许。Grbl发送缓冲主要处理消息。只会增加如果大/ l5 s# r' J: A3 [
//消息发送和Grbl开始停滞,等待发送其余的消息。
9 p, d- s7 M/ f7 S//注意:缓冲区大小值必须大于零,小于256。6 l- S$ R6 _: p$ Y- h+ p+ n1 r
// # define RX_BUFFER_SIZE 128 / /取消serial.h覆盖默认值! J9 t# t$ |! A
6 |% [5 \0 v9 ~; z: {

# v7 y# X  r: j/ S' J0 y! C1 s// #define TX_BUFFER_SIZE 64
$ x. [) X) q( q5 \9 f7 Y* }' ?! i9 z# V  # {7 T/ t$ C/ }) }
// Toggles XON/XOFF software flow control for serial communications. Not officially supported
( P. v+ f& c1 ^; m// due to problems involving the Atmega8U2 USB-to-serial chips on current Arduinos. The firmware( _" }# h6 ?1 n, k/ W! {# d
// on these chips do not support XON/XOFF flow control characters and the intermediate buffer
5 I; H/ t1 g3 x* J+ k: j; {9 {8 O// in the chips cause latency and overflow problems with standard terminal programs. However, # J% p3 p' }/ W3 K; R5 j- w2 c, z- _
// using specifically-programmed UI's to manage this latency problem has been confirmed to work.6 N( K4 H+ N* L- t+ Q  S
// As well as, older FTDI FT232RL-based Arduinos(Duemilanove) are known to work with standard
5 e. L3 X9 h8 d, I$ H// terminal programs since their firmware correctly manage these XON/XOFF characters. In any
$ s9 ~4 Y+ T8 Q, m, u// case, please report any successes to grbl administrators!
& @  b" i/ m" G' r; V//切换为串行通信发送朴通/发送葡开软件流控制。不是官方支持
  R+ ?& U7 ?2 l, S& f# m//由于问题涉及Atmega8U2 USB-to-serial当前arduino芯片。固件
, l9 Z& _* ~2 o1 T3 r0 u) b3 _( _5 f//在这些芯片不支持发送朴通/发送葡开流控制字符和中间缓冲区
" o' {+ k; `- Z/ o+ A' `7 `. M' F//芯片导致延迟和溢出问题的标准终端程序。然而,$ {. l) O* v* t. ?) I5 `* b
//使用specifically-programmed UI的管理这个延迟问题已经确认工作。
( V7 m' K6 J" K2 I, z//以及老FTDI FT232RL-based arduino(Duemilanove)是已知的标准
/ `* L! k; w: y//终端程序因为他们正确的固件管理这些发送朴通/发送葡开的角色。在任何
1 m# ~, j  K! x2 S: Z//情况,请报告任何成功grbl管理员!
" t2 `1 B  e, Y) P, w; H- h) |# Y, S) g5 t: I
// #define ENABLE_XONXOFF // Default disabled. Uncomment to enable.4 w5 P" Y0 i: ^2 k! L" f% V
8 L! A5 m% |! X# @
// A simple software debouncing feature for hard limit switches. When enabled, the interrupt
. C) `" t  X: N! t: a- J// monitoring the hard limit switch pins will enable the Arduino's watchdog timer to re-check
3 Q% j; b8 r- y5 p% p+ |# c// the limit pin state after a delay of about 32msec. This can help with CNC machines with 8 c& Z. y/ o8 B6 l
// problematic false triggering of their hard limit switches, but it WILL NOT fix issues with ' t% X+ h" u1 Z
// electrical interference on the signal cables from external sources. It's recommended to first- A' M4 e: O" V. A- H
// use shielded signal cables with their shielding connected to ground (old USB/computer cables ' ?6 H* q: B3 D% i5 l; t
// work well and are cheap to find) and wire in a low-pass circuit into each limit pin.: m; z/ Y, X# U% r8 D
//一个简单的软件消除抖动特性硬限位开关。当启用时,中断) B4 X/ M; a& @, ~+ i. i
//监控硬限位开关针将使Arduino的看门狗定时器重新审视
! W8 y0 ~0 h7 o$ q//销的极限状态后约32毫秒的延迟。这可以帮助与数控机器/ _$ m9 |7 i* G6 ~2 `
//问题错误引发的硬限位开关,但是它不会解决问题# D+ T( a9 {$ |: g  l+ t4 E
//电干扰信号电缆从外部来源。首先它的建议" ^7 t2 i9 Z( `
//使用屏蔽信号电缆的屏蔽连接到地面(老USB /计算机电缆; a5 _8 H4 h8 C0 u2 x
//工作得很好,很便宜)和线低通电路到每个限位销。# q3 y" c# {8 V% W  t( u. [1 M7 t

( k( N. e2 [1 p! }// #define ENABLE_SOFTWARE_DEBOUNCE // Default disabled. Uncomment to enable.
+ z7 C' Q) ?; x& Y0 e9 i* R% u; `) I0 @  _# ?+ S
// Force Grbl to check the state of the hard limit switches when the processor detects a pin4 ]  [  K( i1 f9 G
// change inside the hard limit ISR routine. By default, Grbl will trigger the hard limits8 e. Q8 R3 F& [/ r! }4 |
// alarm upon any pin change, since bouncing switches can cause a state check like this to
! F: C! B! w& _3 P// misread the pin. When hard limits are triggered, they should be 100% reliable, which is the
8 h; l! s" k$ d/ X! B/ s// reason that this option is disabled by default. Only if your system/electronics can guarantee
, @2 M" k/ `: G  A) r) g// that the switches don't bounce, we recommend enabling this option. This will help prevent
  Y; M8 W: K8 j// triggering a hard limit when the machine disengages from the switch.; u- T- z+ m- y; {& k
// NOTE: This option has no effect if SOFTWARE_DEBOUNCE is enabled.
" r1 {9 ?. n/ Z- |5 G//力Grbl检查硬限位开关的状态,当处理器检测到一个销  q. S- S& R! W0 n1 @2 f
//改变内部硬限制ISR例行公事。默认情况下,Grbl将触发硬限制
# u6 D+ `5 C- C//报警在任何销更改,因为跳开关可以导致这样的状态检查  s; H: `# X* ?6 P9 }
//误读了销。硬限制触发时,他们应该100%可靠,这是! z. S7 S8 A; Z6 Z
//原因,这个选项默认是禁用的。只有在你的系统/电子产品可以保证2 g$ I2 e% w- A! E, k5 e6 ]
//开关不反弹,我们建议启用这个选项。这将有助于防止
, N, G! ?  C: l& g% ^7 o0 r//触发机退出时硬限制开关。" z9 g% K3 p7 `; B
//注意:这个选项如果启用了SOFTWARE_DEBOUNCE没有影响。
* ?; J% a  {9 f; x+ K3 H) l. T* S% {
# Z: l$ O  A- b( y. u// #define HARD_LIMIT_FORCE_STATE_CHECK // Default disabled. Uncomment to enable.
$ t5 @4 {1 d( G  M, W. m: p* G/ w3 C" _1 C; L2 A
. e# b! G6 O* h3 c6 F
// ---------------------------------------------------------------------------------------
% E( F4 |/ F0 w- W3 u// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:编译时错误检查的定义值:  e- B% d# V  m

, n9 Z. s* k2 D; B#ifndef HOMING_CYCLE_05 n7 [6 ~& C% C: f( O
  #error "Required HOMING_CYCLE_0 not defined."
7 p* |7 g  {7 i+ [#endif9 F3 ^/ b- ?- z7 z- Z  o- P/ h2 L9 b

+ g: z1 Y; O& {) J#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(VARIABLE_SPINDLE)3 k6 B- ~2 D6 E  u! y; ?
  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with VARIABLE_SPINDLE enabled"! [6 l) v0 L. _# w' b
#endif* G& x, J, R6 q" f. b+ ?) I! h

: z9 B4 C3 x; v8 }# }. C#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(CPU_MAP_ATMEGA328P)/ s7 X' O" G) w
  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with a 328p processor"* Z2 {0 W9 t( P, g; Q
#endif
7 o: s2 Q/ W3 g2 e! ~+ P/ k7 a& Y$ ^  ~$ b/ l
// ---------------------------------------------------------------------------------------
# ]( k" L. A7 B1 u+ T0 p, B! x' ]0 W; |) D! _1 e
& y/ F" h2 e! w
#endif- S4 ]- y0 {6 i9 P0 G2 _/ I

& o/ ]( {  O% b$ P# I# r6 X: x# e! o% _* V+ X9 M( B
- s- }& d3 s! d& K( T
+ `8 G# d$ f! t8 N# b/ ^- m: `

" {. c% {6 [3 m
' {4 a! ~6 X5 M! g. i& `" C/ w( ?4 M* t
6 |) L" j$ l% ]1 Z

* M* d0 Z  ?9 m" H8 s( ~  R$ T- h, o7 V) [! v

9 O" h( L% @: K# |! ?* e, Z  N9 K9 B8 \  Y( n& q( W

% ^: a* |# j) D2 E# D* f7 G" |( L2 M* `
0 }' H7 [1 T' M9 ]- A' N2 _
0 H+ E( L( Q$ _/ r4 X* ^) F7 O# c) K, U8 @

本帖子中包含更多资源

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

×

评分

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

查看全部评分

回复

使用道具 举报

 楼主| 发表于 2016-8-21 00:11:42 | 显示全部楼层
那些没有用的照片不知道怎么就上去了好讨厌。
 楼主| 发表于 2016-8-21 00:14:16 | 显示全部楼层
$ B5 H) H6 \* b3 i. |( f
发表于 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 | 显示全部楼层
补充7 R2 b9 V+ g) ?2 l( D' Y
程序运行protocol_execute_realtime(); /运行实时命令。# \) E0 |7 @. M7 \
// Executes run-time commands, when required. This is called from various check points in the main
4 o$ l8 F1 e8 M' V  w( Y" N# K// program, primarily where there may be a while loop waiting for a buffer to clear space or any
/ v+ G3 H) A# j. E// point where the execution time from the last check point may be more than a fraction of a second.
% E1 Q# V$ U. ^4 A5 p8 q// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code
* O$ `0 f* p! F, ]// parsing and planning functions. This function also serves as an interface for the interrupts to
- a  b9 _0 p6 W8 k// set the system realtime flags, where only the main program handles them, removing the need to
' d5 i6 R0 v4 _6 w6 a& e1 Y# J7 y// define more computationally-expensive volatile variables. This also provides a controlled way to
9 ]$ m: D" f$ s: y& E+ `// execute certain tasks without having two or more instances of the same task, such as the planner
' u, B5 b+ E& @6 B2 `// recalculating the buffer upon a feedhold or override., \3 v% p  F" H
// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,8 a; r  }& O9 C; ~: y
// limit switches, or the main program.
, `1 ^% G$ [, @8 X( C2 X0 j5 ?
//执行运行时间命令,在需要时。这就是所谓的从各种主程序要检查站
( n9 ^. c5 r" ]$ `" o* |//,主要是那里可能是一个while循环等待缓冲区空间或任何
/ d1 m& B# R% R/ |//执行时间从过去的止点可以超过几分之一秒。& K% W' P" A" B  r2 Q; x
//这是一种异步执行实时命令(又名多任务)grbl的刀位点
  d7 a+ c1 m, L. m% Z9 _( r//解析和规划功能。这个函数也可以作为一个接口,用于中断
: n( f$ v5 W' I- x) H( ~4 I2 e//设置系统实时的旗帜,只有主程序处理,消除的需要
0 _5 j7 l" u( C& B- ~8 W//定义更多的计算昂贵volatile变量。这也提供了一种控制方法+ ~% q) ~7 i. D2 N: E
//执行某些任务不相同的两个或多个实例的任务,比如计划
! e# h) |( q3 z: V  q//重新计算缓冲feedhold或覆盖。
3 @6 r5 [, o- {4 \. i( J7 c//注意:sys_rt_exec_state变量标志设置任何过程,步骤或串行中断,插脚引线,
* D0 v) G& E5 t# ^9 S9 K4 O//限位开关或主程序。
0 m8 a, |1 a$ p: Dvoid protocol_execute_realtime()
& U. c# o- H4 x; C% e{
+ r( x! J9 o) }" c; Z0 Y! x/ F$ h        // Temp variable to avoid calling volatile multiple times.
4 P8 c- k6 K3 X+ Y        // 临时变量来避免多次调用不稳定。6 y; ?1 Y. _! Q
        uint8_t rt_exec; ' r; G8 ^; F8 \& s+ [
        do{+ Q3 v" P2 |1 D6 e" z' v
          if (rt_exec) {                 // 有标志位置位进入9 f, {# t  C8 m  ~2 h5 G
        8 G5 n& Y1 w% u
            sys.state = STATE_ALARM; // 设置系统为报警状态- F3 a0 k  ^& H5 p" M- Y, {/ c4 e
      report_alarm_message(ALARM_HARD_LIMIT_ERROR);        //报告报警信息为接近极限值
: L- D' \' C0 ?/ ^  C2 y9 d    } else if (rt_exec & EXEC_ALARM_SOFT_LIMIT) {                        //报告执行软件限位报警! Q/ x5 d' {6 t* K) O
      report_alarm_message(ALARM_SOFT_LIMIT_ERROR);        //报告出现软件限位报警
5 M+ \9 z3 l, o. `    } else if (rt_exec & EXEC_ALARM_ABORT_CYCLE) {                //执行停止循环报警      8 g, h* s% O7 \( P
      report_alarm_message(ALARM_ABORT_CYCLE);                //出现终止循环报警2 R8 O& x! o+ T% `; L$ Z
    } else if (rt_exec & EXEC_ALARM_PROBE_FAIL) {                        //执行探查失败报警
4 t* P  h6 m9 W) i" |1 c      report_alarm_message(ALARM_PROBE_FAIL);                        //出现探查失败报警
  U# D) T0 b( v' l+ O0 x    } else if (rt_exec & EXEC_ALARM_HOMING_FAIL) {                //执行返回原点失败报警
* |* Y4 h# x& B) @$ ?2 p+ o9 R" X: F- f      report_alarm_message(ALARM_HOMING_FAIL);                //出现返回原点失败报警
& V( ^4 L8 L) {. T1 m: C+ D4 @    }
7 M9 x( [# r1 N4 S% V1 h9 H0 b- y8 v+ a' ^0 r
    // Halt everything upon a critical event flag. Currently hard and soft limits flag this.
( S0 Z! P6 c- _- d- v$ e    // 停止一切在一个关键事件标志。目前硬和软限制标志
5 ?2 h! O3 I( h4 s           if (rt_exec & EXEC_CRITICAL_EVENT) {                //如果系统是循环事件进入
0 O& w' i' D) M             report_feedback_message(MESSAGE_CRITICAL_EVENT);        //报告反馈信息
/ m1 Z- {4 K5 m4 x' V/ b6 v              bit_false_atomic(sys_rt_exec_state,EXEC_RESET);                         //清除目前的复位状态
$ X; s7 j9 ?/ |& r/ G
( c+ n7 e4 _& E" X        bit_false_atomic(sys_rt_exec_alarm,0xFF);                                 // 清除所有报警标志
+ Q- B+ o! ^+ T- Z3 c/ b* ^7 v5 Q        }       
! ?( L* f, K% d6 V" V" }. x8 \6 T6 C( w9 _7 X) ~# u& _  U0 R5 a' X1 k$ a; U
上面代码将rt_exec = sys_rt_exec_alarm ,如果rt_exec为真,打印不同报警信息7 X! ^) [) D* Z. E; a
和限位保护信息,然后清除报警状态
& k( c2 ^6 \* P0 h) ?___________________________________________________________________________
" }' F$ h+ d# P- e! S* b- C; T没有报警进行执行下面代码,执行了终止命令,串口打印命令
) e& i- j( {) k+ b: x4 [7 d  X  s' V# y         // Check amd execute realtime commands        校验和执行实时命令9 W6 L- }5 F( O- P' c& U
          rt_exec = sys_rt_exec_state; // Copy volatile sys_rt_exec_state
1 W& K" e$ c1 F0 o( c# b5 v7 m
/ Z" m: [! c2 f: _/ a        if (rt_exec) { // 输入标志是正确的执行  d+ `, n8 l& [' e6 r& p6 D# O

4 F" ]6 K! F! s/ [            // Execute system abort. 执行系统终止命令
/ O% G' z2 k( u9 x0 w            if (rt_exec & EXEC_RESET) {2 q9 X4 z: [) j3 B
              sys.abort = true;  // Only place this is set true.
& |( C( T# C/ l              return; // Nothing else to do but exit.
" V, Y0 A- x4 M6 r4 Y( p6 Y! M  y  J        }
! I# `2 Z9 L2 k% ~+ \/ m/ D7 r2 I  ?" g" D0 o) X
            // Execute and serial print status 执行和串口打印状态
: _$ A; s# s. }, e            if (rt_exec & EXEC_STATUS_REPORT) {
5 A. M* O$ N; V! E              report_realtime_status();        //报告实时状态
6 H; }$ D- c/ D3 w              bit_false_atomic(sys_rt_exec_state,EXEC_STATUS_REPORT);        //清除报告状态清零' y8 H5 h& i/ O: A+ G9 U2 Z* j
            }( O% k4 q2 d. Y  r: C9 s0 O
_____________________________________________________________________________
8 Z3 l- I/ c0 H. E1 u下面代码
, T0 @/ z, a2 P/ t; U5 R4 U, u, o9 H0 \//执行状态。/ `* C. u+ h9 v+ Y& F' A
//注意:所涉及的数学计算持有应该足够低对大多数人来说,即使不是全部,6 Z! N6 L  h* e/ ?
//操作场景。一旦启动,系统进入暂停状态
& Y/ h" u( J% b. |2 {3 Q" z//主程序流程,直到重置或恢复。  q) w# |& m1 Q' T
待办事项:检查模式?如何处理呢?可能没有,因为它只会在空闲,然后重置Grbl。
: e& B8 {) h! L& [6 Q2 n# K状态检查容许状态的方法。
. H( g: g* l6 s, w# b& T' f5 `. C. @) S( T9 }  f7 W# I% u
        //如果全局各自报警标志位其中(执行取消动作) | (执行进给保持) | (执行安全门)任意一位为真进入/ @2 \. b, b& D
            if (rt_exec & (EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR)) {       
0 V, g  Y9 Y, A( c6 q) T! t, R7 o5 D/ Y2 I  U0 t6 p
        //如果是循环状态执行暂停状态
1 [) Q3 y. G  Z: g8 C) s6 e6 H        if (sys.state == STATE_CYCLE) {# v; Z/ h( Z/ P
        st_update_plan_block_parameters(); //通知stepper module验算减速。
4 y! c2 V2 }6 i5 M% F9 b* _        sys.suspend = SUSPEND_ENABLE_HOLD; // 开始暂停标志* R# V) Y: I$ \
        }
& n4 @- w4 Z9 a! h. M( x7 s& e6 I# F' B/ R3 ?' P/ `
        // 如果,Grbl空闲不在运动。简单的指示暂停就绪状态。
, o) `. \* t0 _  T        if (sys.state == STATE_IDLE) { sys.suspend = SUSPEND_ENABLE_READY; }# _& K: N( B2 s

$ q, k' X6 w0 X5 _7 P1 C" ^
# K2 @! T) M5 }7 {& J1 J; M4 U0 b        //执行和标志和减速运动取消并返回空闲。主要由探测使用周期
2 C* m% p/ X$ D! B        //停止和取消剩余的运动。      
" U" Q8 C- p4 [- g        if (rt_exec & EXEC_MOTION_CANCEL) {
5 _: l/ w- _8 X% |          if (sys.state == STATE_CYCLE) { sys.state = STATE_MOTION_CANCEL; }
. c* ?. Y. T( [" l1 i! m          sys.suspend |= SUSPEND_MOTION_CANCEL;
$ B& y9 V' ~+ a! s6 z        }# t' C5 Y% F5 M
. @& i* u2 G$ d+ ]3 q" ~
        // 只在循环时执行进给保持减速/ N- O9 V) O1 ~3 y/ [
         if (rt_exec & EXEC_FEED_HOLD) {2 i& F, P1 ?2 b+ _/ a
        //只有安全门为1才执行保持进给状态赋值
: _$ V3 r5 ]. Q3 }1 E: v: P          if (bit_isfalse(sys.state,STATE_SAFETY_DOOR)) { sys.state = STATE_HOLD; }
" `/ V; ^) T1 \5 J8 k        }. _) i2 K/ c6 _; x- f8 D

& v/ g; P* N  J2 s: I9 a' e3 n        if (rt_exec & EXEC_SAFETY_DOOR) {, U8 s6 O: Q5 R
          report_feedback_message(MESSAGE_SAFETY_DOOR_AJAR);
$ k; M. h: h! H" R5 I0 k- A/ /如果已经活跃,准备好重新开始,CYCLE_STOP标志设置为强制断开。/ b' f8 h; t( s2 N& W
/ /注意:只是暂时设置“rt_exec”变量,不是动荡的“rt_exec_state”变量。
/ E" n1 ?# |6 L          if (sys.suspend & SUSPEND_ENABLE_READY) { bit_true(rt_exec,EXEC_CYCLE_STOP); }
+ x% E# D) F: K5 T- H9 P- G          sys.suspend |= SUSPEND_ENERGIZE;, e9 s3 t. A3 j: e) n. p1 G
          sys.state = STATE_SAFETY_DOOR;
2 E: S; S- s/ T7 N        }, J+ h" W# ?5 h, I

( o  Y* a0 h  c* |bit_false_atomic(sys_rt_exec_state,(EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR));   
5 f, Y# b/ g: m% \
" `7 z9 z/ E$ D" Z% p0 J, q$ {}2 a" q* {; M& H* o+ W
以上代码执行了- I2 }( `: n9 V0 P' j5 C
1.如果全局各自报警标志位其中(执行取消动作) | (执行进给保持) | (执行安全门)任意一位为真进入: a7 f) c/ p) n# h
2.系统为闲着状态, 开始循环状态, 回原点状态, 控制取消状态, 开始保持状态, 开始安全门状态时进入- p' G& r) Z) R3 d: q( v
3.如果是循环状态执行暂停状态' {' o3 p  I- \9 R- q$ ?
4.如果系统闲置状态执行暂停就绪状态% ^* W1 k! G( L$ Y: D
5.执行动作取消+ ?' R7 h, x3 P$ I5 o- O' o
6.如果是保持进给状态,执行保持进给状态
/ ?( I5 K5 |( X. Q; _7 @3 x7.执行安全门状态
* G& Z% U4 G' t/ ]8 Z  A, k最后执行bit_false_atomic清标志清除(执行取消动作)(执行进给保持)(执行安全门)标志位                 
- ]' U, }6 ]4 t* F$ u_____________________________________________________________________________
. U# ~, `0 @; I  ?; g- O/ A' o. N' A8 b* l( y6 n, d1 X
    // Execute a cycle start by starting the stepper interrupt to begin executing the blocks in queue./ ]. h6 G  X7 ]' {! x
    // 执行一个循环开始启动步进开始执行中断队列的街区
7 P! `1 h4 [  V( k0 N3 b' [% N, u    if (rt_exec & EXEC_CYCLE_START) {        //循环开始状态进入) L7 Z( S6 t7 y5 {
      // Block if called at same time as the hold commands: feed hold, motion cancel, and safety door.
+ @$ v* I" Q. P' R' x8 Z; M% d8 j      // Ensures auto-cycle-start doesn't resume a hold without an explicit user-input.# k9 a+ o. Z& n, g5 x8 ]+ d
          //块如果在同时举行的命令:保持进给,运动取消,和安全的门。 //确保auto-cycle-start没有简历没有显式的用户输入。6 M8 v/ W) H  M. _
          
9 Y( M. K; s& [, ~7 j, H! H      if (!(rt_exec & (EXEC_FEED_HOLD | EXEC_MOTION_CANCEL | EXEC_SAFETY_DOOR))) {   //状态机如果不是保持进给,运动取消,和安全的门。 2 ]5 h! ?+ U" q* S$ `# D
        // Cycle start only when IDLE or when a hold is complete and ready to resume.0 w7 J  D! U' n/ A
        // NOTE: SAFETY_DOOR is implicitly blocked. It reverts to HOLD when the door is closed.
, N' u5 V! X, p3 ^                //循环开始时只有当闲置或持有完成并准备简历。
+ F2 V' b4 L4 W                //注意:SAFETY_DOOR是隐式地屏蔽。它返回的时候门是关闭的。   
: s" F- \+ M: R# Q9 X( U6 `+ S* Q- W" {
                // 如果系统状态为闲着状态,系统状态为开始进给或运动取消,暂停标志为位重新开始' g" A! V8 L* W& z8 n
        if ((sys.state == STATE_IDLE) || ((sys.state & (STATE_HOLD | STATE_MOTION_CANCEL)) && (sys.suspend & SUSPEND_ENABLE_READY))) {
* z1 `* x9 R$ i) J( {/ T          // Re-energize powered components, if disabled by SAFETY_DOOR.& m! x1 L% a" E8 D- _- v4 |
          //        由SAFETY_DOOR重振组件供电,如果禁用。% {; v  j, s5 [5 b' A, Y
          if (sys.suspend & SUSPEND_ENERGIZE) { , [: r' M- ]) n) F
            // Delayed Tasks: Restart spindle and coolant, delay to power-up, then resume cycle.
  x- z: J2 E# u! P* w3 P            //延迟任务:重新启动主轴和冷却剂,延迟升高,然后恢复周期。% I3 S& n9 k! k8 k  e" H! h5 x& u
            if (gc_state.modal.spindle != SPINDLE_DISABLE) {   //主轴模式不是失能进入
3 W- m; H2 ~9 O/ |( c' T. }* I              spindle_set_state(gc_state.modal.spindle, gc_state.spindle_speed); //设置状态和速度6 c# ~+ n. l, e" r: p8 ^
              //待办事项:阻塞函数调用。最终需要一个非阻塞。
9 m1 f" F5 M1 h  g. T- f2 C                delay_ms(SAFETY_DOOR_SPINDLE_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.5 s% i( }( i+ M: G/ f1 `- Y% J" e
            }/ L4 t8 Z, C5 p9 z, v/ i! {
            if (gc_state.modal.coolant != COOLANT_DISABLE) {
" f$ u5 v0 b9 |# Z1 W7 D( z              coolant_set_state(gc_state.modal.coolant);
2 c- G; L: `: ]0 F4 d( d              delay_ms(SAFETY_DOOR_COOLANT_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.2 s, S) f6 \" I: Z3 w5 g. e
            }( i% A2 F% a% S8 g
            // TODO: Install return to pre-park position.! s# P' c" g/ m% n; E/ n: T
          }
% F6 C; R6 e' T6 j8 S8 @______________________________________________________________________________________________________________* F3 o9 ^2 P' ^" Z4 r
          // Start cycle only if queued motions exist in planner buffer and the motion is not canceled.
9 U5 f7 Q2 n( ?# t% b+ w                  4 L# V7 b* q# R5 A
                  //只有在队列马达存在规定的缓冲,并且动机没有让取消,才会循环- _0 l. M7 R- B
                  $ H7 V5 l; J/ ^& j. h5 R! ?
          if (plan_get_current_block() && bit_isfalse(sys.suspend,SUSPEND_MOTION_CANCEL)) {
- M( L* r3 e8 E4 v( v& ]2 k$ y$ ]& f            sys.state = STATE_CYCLE;) a/ Q3 n! e1 L; Q- e' l7 V
            st_prep_buffer(); // Initialize step segment buffer before beginning cycle.初始化步开始循环之前
- R5 X* p; {; y+ I            st_wake_up();
2 b6 o5 K; n* A$ i; _          } else { // Otherwise, do nothing. Set and resume IDLE state.否则,什么也不做,设置和复位空闲模式
& e" T4 Z  H2 Z$ s            sys.state = STATE_IDLE;; G) q7 w" z8 R6 H3 z! y, o
          }
% N; M7 G+ [7 k: i5 c. x4 r          sys.suspend = SUSPEND_DISABLE; // Break suspend state.. a. Q" Q' o1 J" y
        }
" R' P" U1 R8 u9 C, J$ L+ T  q      }   
. l4 g) s, i* e5 ]' }      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_START);        & B( a/ G7 {. v
    }1 u! F8 l6 c* t0 f( f' O$ N+ `

( M- b$ M4 D& W$ Y; r" U0 t1 x% |9 @_______________________________________________________________________________________________________+ R) Y2 x# n/ o# Y
    // Reinitializes the cycle plan and stepper system after a feed hold for a resume. Called by + |3 P8 I+ ?  b* L# e" I
    // realtime command execution in the main program, ensuring that the planner re-plans safely.
2 d# ?' V' J- x  }5 `5 S    // NOTE: Bresenham algorithm variables are still maintained through both the planner and stepper2 o3 W" v- Z4 m4 m
    // cycle reinitializations. The stepper path should continue exactly as if nothing has happened.   
( r# c% T9 A5 X; V$ |4 o    // NOTE: EXEC_CYCLE_STOP is set by the stepper subsystem when a cycle or feed hold completes.
8 Y; ~/ I6 h+ i6 \, q
+ C2 d- c! M; A+ c$ V5 Y        //重新启动后循环计划和步进系统的进给保持简历。通过实时命令执行主程序,确保安全计划重新计划。
; Z: D: J* B5 r5 ~# @4 O        //注意:画线算法变量仍保持通过规划师和步进
5 x7 p. _" l( E0 A        //循环仅。步进路径应该继续,好像什么都没发生一样。        4 j9 [5 H" U# E9 [3 Z+ V) F
        //注意:EXEC_CYCLE_STOP由步进子系统周期或进给保持时完成。. m/ a4 z+ ~$ j; r* [: P& w

7 x. W% k  z2 h/ V    if (rt_exec & EXEC_CYCLE_STOP) {                         //如果是循环停止状态进入, i9 a, Z1 }- _; ~4 o. g6 W
      if (sys.state & (STATE_HOLD | STATE_SAFETY_DOOR)) {; v$ ?" U9 A2 Y( G
        // Hold complete. Set to indicate ready to resume.  Remain in HOLD or DOOR states until user
" o9 e! c) X! ~/ @$ u$ r! \* J1 }) ?        // has issued a resume command or reset.) Q# h2 J2 \" I% W: c

/ g5 w% S. I. `- X                //保存完整。设置为指示准备简历。继续持有或门状态,直到用户
1 U  u) ]+ m' p0 J* j$ {                //已发布了一份简历命令或重置。
% [+ a9 V' F  z0 d. q4 t; ~               
, L' ~% Y4 g+ F+ \% V5 J        if (sys.suspend & SUSPEND_ENERGIZE) { // De-energize system if safety door has been opened. 如果安全的门已被打开。断开系统8 f8 A$ I! A3 q/ V: e5 H, B7 m
          spindle_stop();7 O1 f( p  Y0 G) d* O$ o; W
          coolant_stop();
# ]. D$ f$ P6 e( k  c          // TODO: Install parking motion here. 安装停车动作。/ x2 G) `" @$ T# n" ^: _1 b& O
        }0 X% w* q' j! X$ P, {: a% _) l
        bit_true(sys.suspend,SUSPEND_ENABLE_READY);
& L& e! u# Z# w8 E      } else { // Motion is complete. Includes CYCLE, HOMING, and MOTION_CANCEL states. 电机完成,循环,回原点,,MOTION_CANCEL% m% Y& }5 v# R8 q0 _
        sys.suspend = SUSPEND_DISABLE;) n, U6 C8 e! x! r' p/ Y; i( N
        sys.state = STATE_IDLE;
  Y0 D9 Z2 |6 Y1 m! E0 F; p      }
' O* L' b8 R& r7 \      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_STOP);
. t. h, S) L1 O' d# h0 s% E/ u    }
" q$ J2 O  s! h6 ^4 u" L    ) M9 R7 t9 C, g! v. ^% F
  }
1 ^7 W" a3 w% }7 k- h: ?___________________________________________________________________________________________________
: g/ B5 @8 v1 J% B( k9 v. M# B4 O
+ l4 o0 r! V2 o2 b! a% N  // Overrides flag byte (sys.override) and execution should be installed here, since they 6 H$ v7 q( |2 k: N( e6 t
  // are realtime and require a direct and controlled interface to the main stepper program.
) z* n2 |( [9 Q% C. `% ]2 |8 D" c1 V* P. o$ N0 T, n5 m( t& m5 }
  //重写标志字节(sys.override)和执行应该安装在这里,因为他们6 \8 M! F  q( S" [4 }) C
  //实时和需要直接和控制接口的主要步进程序。
, V2 p# V: ^) E( A0 ?! S( X
) |* a) D* R* ~7 O" h9 J8 F2 \% L. n. U9 e
  // Reload step segment buffer 重新加载步段缓冲* y7 f* _. p- c+ P& S$ @  ^
  if (sys.state & (STATE_CYCLE | STATE_HOLD | STATE_MOTION_CANCEL | STATE_SAFETY_DOOR | STATE_HOMING)) { st_prep_buffer(); }
' ~0 l2 ~3 c$ q
3 w4 y$ g3 \+ c( Q, C% c( L, P  // If safety door was opened, actively check when safety door is closed and ready to resume.$ e. S5 d7 m/ Y2 I. j! Y5 r
  // NOTE: This unlocks the SAFETY_DOOR state to a HOLD state, such that CYCLE_START can activate a resume.        3 A& X' L0 C& r
! E: v8 I* c3 O4 M) @; @, s
//如果安全的门被打开,积极检查当安全门关闭,准备简历。
/ H3 b! _/ y! ~  m# I9 Y  //注意:这解锁SAFETY_DOOR状态保持状态,这样CYCLE_START可以激活一个简历。0 L; I7 ^4 N$ x" q

$ {, p$ K# _  w+ R9 n* w  if (sys.state == STATE_SAFETY_DOOR) {                 //安全门状态进入
$ d# t" \+ ^: p+ I. L% X4 I4 `! E7 r    if (bit_istrue(sys.suspend,SUSPEND_ENABLE_READY)) { 7 R" {( Z# `3 g
      if (!(system_check_safety_door_ajar())) {
. N# e2 q1 A* w4 T% ^7 z        sys.state = STATE_HOLD; // Update to HOLD state to indicate door is closed and ready to resume. 更新保存状态指示门关闭,准备简历。
% Y$ z9 i+ Y- Z4 S. X      }9 O* a% f+ U( P. k/ @2 Y1 G
    }; @/ Z: a; W* m1 q9 w: D
  }
' T5 G7 `9 c3 _3 M! ?9 i
" @& |3 n! ~/ i- r  Z. q+ ?5 T  } while(sys.suspend); // Check for system suspend state before exiting.. D: ?, T" _1 t0 H2 A. I
  
- W) f, ^. S$ c! t& r( c}  
发表于 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-9-18 11:18 , Processed in 0.120700 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.5 Licensed

© 2001-2025 Discuz! Team.

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