找回密码
 注册会员

QQ登录

只需一步,快速开始

搜索
查看: 19100|回复: 15

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

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

5 j" K( A+ e3 E' y    下面介绍小这个些主控程序主要干的事,通过串口PC和主控板通讯,PC命令给控制板,控制板接收命令做不同的响应,PC可以发G代码给主控板,接收完成后可以自动开始雕刻任务。  N6 Y" c# j8 J& O  e+ ^
          在介绍下G代码因为G代码是雕刻机的核心部分  c# u+ Z, T. g; z! e8 u
G代码是数控程序中的指令。一般都称为G指令。0 S: M' \' q  q6 }
G00------快速定位
4 Q- v* h( z4 H* uG01------直线插补& Y: ]% m! \. H* V1 b( ]
G02------顺时针方向圆弧插补! t' g  V4 \3 x, q6 s
G03------逆时针方向圆弧插补
7 E) d( t; l$ i, |) X+ x  c7 BG04------定时暂停
9 R4 f, A4 N7 yG05------通过中间点圆弧插补( Y) m/ Q$ z8 w
G06------抛物线插补
1 t  z6 |* ]' u* {; z* r) UG07------Z 样条曲线插补
1 _/ m) M+ d2 K: jG08------进给加速
5 n9 D" s0 W8 ]2 KG09------进给减速: f* B9 o9 C1 g! T
G10------数据设置7 ]$ ^% U% {( x
G16------极坐标编程
' z) J/ A8 {6 P* {G17------加工XY平面
& q7 g9 l. p, L* Y2 U2 vG18------加工XZ平面( B5 z( p/ d" {1 R
G19------加工YZ平面
& s" x1 o6 ]$ d
核心就是解析G代码,完成步进电机驱动,和控制主轴开启关闭,还有插补算法,直线插补,圆弧插补,还有一些步进电机的加减速算法。
1 q& n: F1 Y- t% h) |3 h9 ?9 m% S下面对grbl主结构做介绍
( m! [( Q9 A# c  Z* s( jmain()主函数首先执行下面初始化函数% n) a. d: {7 a9 v# w' R
        serial_init();                           // 设置串口波特率和中断& d/ z9 K: k# t
        settings_init();                         // 从ROM加载grbl设置& W1 U0 E+ @; c+ j+ K
        stepper_init();                          // 配置步进方向和中断定时器$ B3 D' l2 W  o6 C7 ^8 Z: v% {
        system_init();                           // 配置引脚分配别针和pin-change中断  \* q; `, C1 L* L! x+ f+ [4 q
        memset(&sys, 0, sizeof(system_t));          // 清除所有系统变量0 I( C* z5 u( j
        sys.abort = true;                           // 中止标识位置位
8 _8 j) U. m1 D1 B; Y        sei();                                         // 使能中断0 x; G; L; Y* p
  #ifdef HOMING_INIT_LOCK                        // 宏运算(settings.flags & (1 << 4)) != 0结果flags等于执行sys.state = STATE_ALARM
' ^- N' Z, ]3 w& X* a                                                // 系统状态赋值为报警状态9 Y! B- Z+ Y. X
            if (bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE)) { sys.state = STATE_ALARM; }
* n7 |3 _9 s1 _4 A8 y% M- ~* G8 `8 ?* b  #endif6 [7 v2 v( `; _
_____________________________________________________________________________________________________________________________________
# i- h8 G5 B; P. A$ }* t接下来是一些主要部分初始化
1 g. ?5 O+ `+ b9 M* C" H# S  y# ?for(;;) {
* |/ @9 b; ?! H. H1 i" v        serial_reset_read_buffer();         //清除串口读缓冲区  _. j5 D1 F3 {2 i, ^
        gc_init();                         //初始化G代码功能函数
' v2 P% P, h  y  ]2 A6 h: Z        spindle_init();                        //主轴初始化$ a+ p, `. a) A/ c1 c7 o# j2 `
        coolant_init();                        //冷却液初始化
3 E2 H2 b$ f. t& K        limits_init();                         //极限开关初始化" m0 }, Y' ~7 H3 H, Q
        probe_init();                        //探测部件初始化
/ T+ U, z, G( q9 V: `* t        plan_reset();                         //清除块缓冲区和规划师变量/ L! g$ @7 ~/ `" V$ ^
        st_reset();                         //清除步进系统变量。
8 H, T" U$ k$ X8 Q+ q! |. F* v; V; X5 V. l$ N% ]
1 ]+ ~8 w$ r% b: {2 }$ a% t( ]0 `
        //下面两行清除同步gcode和策划师职位当前系统位置。6 F" ?' |6 d2 j% M* x  |0 b. B
        plan_sync_position();# h8 X2 V0 y1 O: v
        gc_sync_position();
  ~# t0 _4 T+ ]8 {" Y7 w) ^8 ]6 {
. l8 U; P1 j  m
- X7 d$ G5 [5 f3 P        //复位系统变量
% H% R8 Q3 B' `& m2 ~        sys.abort = false;                //系统中止标志
1 L8 q0 n. s* h        sys_rt_exec_state = 0;                //系统标志位变量状态管理。看到EXEC位掩码。7 f$ F& s& c4 n; E
        sys_rt_exec_alarm = 0;                //系统标志位变量设置不同的警报。
; j: d2 p" O0 m$ ]* e5 M        sys.suspend = false;                //系统暂停标志位变量管理,取消,和安全保护。
7 N- w9 M" _5 \" J# k        sys.soft_limit = false;                //限位开关限制状态机错误。(布尔)0 R+ `( f7 `' p* M' C# E3 j% s) N* ]
- m$ ~) d" I5 k# m( e8 S: D. \7 ^

2 B' e3 q% n4 P2 g        protocol_main_loop();                //主协议循环# D, c/ }9 J2 ^5 n6 X& l
}        //0 R. R% J; h  T7 b
_____________________________________________________________________________________________________________________________/ ?' l5 Z0 q$ K* E9 f' X
进入void protocol_main_loop()函数
) X+ _8 t( U" D9 v{! l" A( [7 j5 D9 l# s6 q* F
        report_init_message();                // 打印欢迎信息
) f% ]0 t; U6 N; |2 {        //重启后检验和报告报警状态如果错误重启初始化。
8 P/ O( o* S* r; Y+ M# F1 a
        if (sys.state == STATE_ALARM) {7 @# U* w, q* B8 S" i0 [6 o- c
            report_feedback_message(MESSAGE_ALARM_LOCK); //打印信息* C6 V! R3 D8 |5 ]
          } else {
% p9 [& X7 S2 g) R$ x' i            // 如果没有报警说明一切正常!但还是要检查安全门. + n9 J; J1 E; B4 u
            if (system_check_safety_door_ajar()) {
6 \6 G6 i. E* D9 Q+ O                     bit_true(sys_rt_exec_state, EXEC_SAFETY_DOOR);1 W( B  T9 m4 h5 y' L% ]
                     protocol_execute_realtime(); // 进入安全模式。应该返回空闲状态。9 L6 ~. u7 W5 t" Y1 Q1 Z% r7 Q
            }         else {
7 e' {! l1 @2 R/ y0 K8 c' c              sys.state = STATE_IDLE; // .设置系统做好准备。清除所有国家国旗。; I9 V) o* ]9 W* F! w/ \5 G+ w
            } 2 L- C4 ^6 I2 w- E: ^2 v7 u
            system_execute_startup(line);    //开始执行系统脚本
' @9 X( @  X0 b) @* }8 n7 R  }
, L7 c  L; n; T) Y
, Y8 y% _* ?* ?( g1 v0 x. c1 z
) O; A  V' k2 N$ U  // 这是主循环!在系统中止时这是出口回到主函数来重置系统。; x! Y. Y$ V1 C: o
  // ---------------------------------------------------------------------------------  0 I+ n) ?* h& A/ G  ^/ ]
  
6 I) ]. ~5 Y  s+ ]" {: o% W, j% p$ v        uint8_t comment = COMMENT_NONE;' [) V4 Q9 T( @
        uint8_t char_counter = 0;4 W' Y) {' G& \! E; M6 H
        uint8_t c;
7 E0 x* A; ~2 m( X0 `, D! d_______________________________________________________________________________________________________________________________
4 ?: V. Z  R- _! c! ~接下来进入for(;;)循环                //下面代码是G代码解析核心部分,程序中comment(注释)变量会被赋不同值,代表发符号有‘(’‘)’‘;’
, l  H" t- x: r# K) ?4 j) ?{' O: t9 {* v& n  @& w! e. N+ G
//串行数据输入一行的的过程,作为数据。执行一个2 X. y# k3 A6 P; K! A
//所有数据初始过滤去除空格和注释。
1 g! s) X3 c+ w' H& X. G//注意:注释,空格和程序段删除(如果支持的话)处理技术
1 ]/ ?5 W' G" I; I. D; W//在G代码解析器,它有助于压缩到Grbl传入的数据5 u1 w& h/ V  V* _! Z. c  d$ V* C
//线缓冲区,这是有限的。刀位点标准实际上州一行不行3 [* m5 y' _: Z1 b! h; a
//不能超过256个字符,Arduino Uno没有更多内存空间。: c' T+ ^: L: v; p5 f* ?
//有更好的处理器,它会很容易把这个初步解析的. A* Q% s: }2 w9 k. O3 b2 R
//分离任务共享的刀位点解析器和Grbl系统命令。                                                                - O' O9 M1 l  [- Y6 T
    while((c = serial_read()) != SERIAL_NO_DATA) {                             //读取串口数据,有数据执行下面代码1 o2 v: n- M/ V+ f
      if ((c == '\n') || (c == '\r')) { // End of line reached                //如果数据是/r,/n代表一行结束
( h# H7 w4 w1 b9 @/ c$ ?        line[char_counter] = 0; // Set string termination character.        //设置结束标志
& D% e$ c1 r; h* M# ~7 U        protocol_execute_line(line); // Line is complete. Execute it!        //一行完成执行此函数* i8 J5 b: Z  z+ V+ t
        comment = COMMENT_NONE;                                                //注释清零
, m( R* l' j7 ?4 L% W  ?& |& ~0 q1 z        char_counter = 0;                                                    //字符计数清零" G# G; {" v+ g2 E0 j" r
  
+ a% h0 @* a8 X+ {        else {
, K. ~% j+ c' |- A" G7 C3 r8 E        if (comment != COMMENT_NONE) {% M# y2 Y2 L! p2 @* P+ [
                                                     //扔掉所有注释字符
" M$ N, I8 A9 _* ~7 T          if (c == ')') {- ]% b$ S0 _1 ?. A& @' e# u* f
            //最后注释。重新开始。但是如果有分号类型的注释。0 k2 x! C& D, I
            if (comment == COMMENT_TYPE_PARENTHESES) { comment = COMMENT_NONE; }5 q) Z& g0 @; u: P, Z) S
          }
3 j# Q' r( K7 b; Y% H, ?" V9 N      } else {
$ t9 G! O+ u: C2 N! N7 r          if (c <= ' ') {
: D* N9 E5 k4 [  P1 m3 T* R9 e            //扔掉whitepace和控制字符
1 g/ L+ `, F/ I. r4 P          } else if (c == '/') {
4 ?- |- Q  v& h; r9 @; i            //块删除不支持将忽略字符。
2 ^# o  p/ f( _- u            //注意:如果支持,只需要检查系统是否启用了块删除。/ h% Y! {; @) U8 y4 d0 A
          } else if (c == '(') {1 Q6 w% c. S9 h* O, i
            // Enable comments flag and ignore all characters until ')' or EOL.! z/ @: b0 G1 d4 S1 c* X: h
            // NOTE: This doesn't follow the NIST definition exactly, but is good enough for now.3 a+ K2 `* |- f( Q0 q' o
            // In the future, we could simply remove the items within the comments, but retain the6 Z3 C7 K* ?# u) y9 F" H
            // comment control characters, so that the g-code parser can error-check it.: m: s8 }. t/ L
            comment = COMMENT_TYPE_PARENTHESES;
( K% f' Z& Y. O          } else if (c == ';') {4 z  A  o. i) V/ |! P
            //注意:','注释EOL LinuxCNC定义。没有国家标准。
' a6 b/ c' `5 c0 e% z# r3 a            comment = COMMENT_TYPE_SEMICOLON;
6 [) j4 ^+ x- {4 ]7 Y5 j9 }% q
: O: p9 C; w! ~- L; {
, [- B) @7 k* {# N_____________________________________________________________________________________________________________________________________
, b! _! Z( M( W( ~' C& @          } else if (char_counter >= (LINE_BUFFER_SIZE-1)) {                        //串口接收数据大于80字符时
! l9 M8 D6 ]# j; l/ s7 R0 _            // Detect line buffer overflow. Report error and reset line buffer.        检测缓冲区溢出。报告错误和复位线缓冲区。
8 E' |& ]/ a/ |% M            report_status_message(STATUS_OVERFLOW);                                //打印溢出信息; R8 N2 o3 y. b
            comment = COMMENT_NONE;
, Q& H; G2 C- o* y            char_counter = 0;. ~+ Z- X; E9 V: L, k# X
          } else if (c >= 'a' && c <= 'z') { // Upcase lowercase                        //小写改大写
1 E3 ]! l2 s3 B) [2 G6 I$ i8 M) S# J            line[char_counter++] = c-'a'+'A';4 z' Q( ^5 s  X7 c; o
          } else {' L! {& y7 ^* j  L4 _
            line[char_counter++] = c;& Z  [# u6 |. K! n# j! o
          }) i# ]) j' ~, K3 K& p" c7 q9 Y" _
        }
" a/ \0 V0 J& y& ]1 P5 m7 D5 Q      }
( ~: |2 w* `0 {  G    }
4 }" ], U9 L/ @: M____________________________________________________________________________________________________________________________________2 \* U" E. Q# L+ m$ ?
        //如果没有其他字符在串行处理读取缓冲区和执行,这表明以完成,自动启动,如果启用,任何队列动作。5 E& i) L1 v/ q7 i
        protocol_auto_cycle_start();                //自动开始协议循环
5 i4 ^2 u7 y9 {1 [1 J4 d$ u4 {        % R* q. e& |" c: [5 ?4 G
            protocol_execute_realtime();                  //运行实时命令。
7 ~& d( \1 `" @- g3 O# r- `) \            if (sys.abort) { return; }                 //中止标识置位程序循环重置系统。            . n: C2 }5 v( J- ?' {) x
  }
' M: U! `! M4 S" N# Q& h& n. x  return;                         //一般程序不会执行到这里0 V5 y: G' Z: e# ]( C- K0 [
}. u9 \9 _- @5 v8 X4 j  d& Y
____________________________________________________________________________________________________________________________________# J- Q. a! i" V6 }* l2 r0 F5 B
正常情况下,读取完G代码程序会进入protocol_auto_cycle_start();//自动开始协议循环 函数下面介绍此函数1 P* ]+ k5 _- S; V
// Auto-cycle start has two purposes: 1. Resumes a plan_synchronize() call from a function that9 L9 [) D* D! m
// requires the planner buffer to empty (spindle enable, dwell, etc.) 2. As a user setting that & C3 z; i7 ~8 A1 l& Q8 |
// automatically begins the cycle when a user enters a valid motion command manually. This is * E/ G! @+ C6 A/ n4 a( s
// intended as a beginners feature to help new users to understand g-code. It can be disabled
/ u0 w2 z/ ]/ d/ Y9 V, \6 u// as a beginner tool, but (1.) still operates. If disabled, the operation of cycle start is
: m% x" g. `0 w% a: o6 @3 ?// manually issuing a cycle start command whenever the user is ready and there is a valid motion
" w3 N) X& ^4 Q' R// command in the planner queue.4 t  J; ^$ Y$ O8 T( J& q
// NOTE: This function is called from the main loop, buffer sync, and mc_line() only and executes " L& V, E9 u4 Y2 Y( J9 t" p
// when one of these conditions exist respectively: There are no more blocks sent (i.e. streaming
5 S0 x# C  I: U5 G. Y1 D// is finished, single commands), a command that needs to wait for the motions in the buffer to $ w% a* o% _& B4 e# \0 ?
// execute calls a buffer sync, or the planner buffer is full and ready to go.
/ a) {% u- W* ~. X" y6 t: [( Q4 F' Y//自动开始有两个目的:1。回复一个plan_synchronize()调用的函数
; |& h; I9 `% X' l$ H" m& t//需要规划师缓冲区空(主轴启用、住等)2。作为一个用户设置
- q9 P* i, ?9 q7 O( e* Z' A. K//自动循环开始当一个用户输入一个有效的运动命令手动。这是
/ y& o+ S) Q$ p/ _6 B3 V//作为一个初学者的特性来帮助新用户了解刀位点。它可以被禁用
% D" {) W4 x) O8 V//作为一个初学者工具,但(1)仍然运作。如果禁用,运行周期开始9 a& b, p0 ~5 ]; f$ ]3 `9 C
//手动发出一个周期开始命令每当用户准备好,有一个有效的运动  A- k( A# A' f* |0 O4 ?0 P' R
//命令的规划师队列。: f" \$ f5 U2 Y/ P7 ^& a# Y; H
//注意:这个函数被称为从主循环缓冲区同步,mc_line只()并执行- e9 K) C# }6 K+ |( z
//当其中一个条件分别存在:没有更多的块(即流发送
1 W7 c  `( W3 F( \0 J5 J; F9 }//完成后,单一的命令),一个命令,需要等待缓冲的动作7 e$ \; d. j9 l) `4 l
//执行调用一个缓冲区同步,或规划师缓冲区满了,准备好了。
# D" u& B+ u7 Cvoid protocol_auto_cycle_start() { bit_true_atomic(sys_rt_exec_state, EXEC_CYCLE_START); }
1 i+ n3 p$ [6 @& l& C! r7 J8 H_______________________________________________________________________________________________
5 f- Y1 S7 a6 l: y) S接下来程序运行protocol_execute_realtime(); /运行实时命令。6 Y" B8 v9 j, O0 m4 k0 W
// Executes run-time commands, when required. This is called from various check points in the main
/ Q* G! ~5 \$ q// program, primarily where there may be a while loop waiting for a buffer to clear space or any
9 V& m: K# J! ?5 y2 s' e// point where the execution time from the last check point may be more than a fraction of a second.
$ B, e: o5 ^; f& r// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code
1 M& m, U7 K( r# c# g$ v6 l7 B! w# o// parsing and planning functions. This function also serves as an interface for the interrupts to
  l9 t# a8 n. S! W" ^* {// set the system realtime flags, where only the main program handles them, removing the need to
9 A6 m1 @* L. K8 t& }// define more computationally-expensive volatile variables. This also provides a controlled way to
& ?! C2 B# q% Q. B" q, l9 H4 _// execute certain tasks without having two or more instances of the same task, such as the planner4 a5 h# H. z( H' n% p( Q5 S
// recalculating the buffer upon a feedhold or override.  D$ v6 ]) H5 o$ h& S. v: J
// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,* [1 y! N% |! L, |
// limit switches, or the main program.- S# ?7 w: E2 t
void protocol_execute_realtime()7 M. N$ h# ~( r4 i
uint8_t rt_exec; // Temp variable to avoid calling volatile multiple times.临时变量来避免多次调用不稳定。
% g6 `$ P2 C8 r! l8 }就先分享到这吧!- v( n. G8 a3 E+ r+ y6 G

% s* I3 k1 b& I# n
" c! o& W7 O3 A" H* w# [1 i0 w& Y! ]9 f# Y% |3 F* u9 ]  c
+ V  `( n0 Y+ y/ B+ C' G1 o

1 c1 \4 v; ^; H# V! |2 F
$ Z; G, e3 ^4 Y- k6 I: g: T( I/ ]- @9 f5 d- U7 C1 h

6 ~" e, m1 }* G/ A9 l  Y  ]2 a& b; s; ~: `& B
% M. x  @( B5 Y; J$ x9 i$ f

) A9 ?/ B8 ~6 f) P5 l: I" N9 G+ O* F2 v0 M  J7 b6 w; H; _

7 b$ F9 Z' ^' I9 k- g7 g9 h
1 x5 x0 \2 F" P. v- H! u9 v% L+ q4 G) W+ S! B

" p  l* j0 @3 s) G4 d
: ], t5 Y" S, n3 S2 l; {4 q; C
( T/ _/ q9 Q6 v. V# t$ N3 B1 b! t. M* ^; N+ u' F8 G4 ]
, B' K# Z* K1 X0 _
& ?! ^  P: D3 o% @  S

8 ~: U5 Z' n5 q+ Q
! h+ q* `4 [) E( T. w补充内容 (2016-8-25 22:40):5 K- U0 f: U: X2 h% X
配置说明
' f7 H$ g1 h$ p9 g7 T//这个文件包含编译时配置Grbl的内部系统。在大多数情况下,
) {7 ^$ }5 e& f8 L//用户不需要直接修改这些,但是他们在这里为特定的需求,即。
0 A6 g+ g9 ]' I& |//性能调优或适应非典型的机器。/ \  }7 a" Y! S2 O& S
主要配置项:* O; {. b/ r1 F0 g# }
1.#define DEFAULTS_GENERIC        //在重置eepm时使用。在defaults.h改变想要的名字
( t. x! j$ k. Q# P5 ]8 q2.#define BAUD_RATE 115200        //配置串口波特率115200/ z- v; ~) ?5 A2 e
3.#define CPU_MAP_ATMEGA328P         // Arduino Uno CPU% I0 g9 J$ x! v* s
4.#define CMD_STATUS_REPORT '?'        //定义实时命令特殊字符
9 {5 f3 z& n* s$ y" F8 n5.#define HOMING_INIT_LOCK         //回原点保护锁! D$ U6 `2 S. T- s! A- c* s
6.#define HOMING_CYCLE_0 (1<<Z_AXIS)              // 第一步Z清除工作区。* _, a% F+ E# @" y9 S( ]
  #define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // 然后X,Y在同一时间。; R5 j: |! J6 B6 p* D' y
7.#define N_HOMING_LOCATE_CYCLE 1 //回原点循环次数
' z/ i; G% n4 R- ?" Q9 {) I8.#define HOMING_FORCE_SET_ORIGIN //取消这定义迫使Grbl总是在这时候位置设置机器原点尽管开关方向。
( f: a7 ?1 H3 ^: P& G9.#define N_STARTUP_LINE 2 //块Grbl启动时执行的数量。
5 C% F2 m4 X. w' }6 @10.#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 协调或位置价值英寸* ~1 V. W( C$ a3 b6 `' ^. x7 U3 c8 j
   #define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 协调在毫米或位置价值
3 B/ T! s+ D. M( x$ q6 M   #define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分钟的速度值
' |( Q% W" d: h, |) r- t% i; c   #define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分钟0 B4 K; U% q5 @6 V
   #define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 对浮点小数设置值
7 V! ^7 g% ]. V' l8 K2 `11.#define LIMITS_TWO_SWITCHES_ON_AXES //如果你的机器有两个极限开关连接在平行于一个轴,您需要启用这个特性
, F# A! {' o- d: z2 H2 Z4 m12.#define USE_LINE_NUMBERS         //允许GRBL跟踪和报告gcode行号2 ^# e8 z% k: ?0 H4 p7 }
13.#define REPORT_REALTIME_RATE //允许GRBL报告实时进给速率/ `' M+ m1 J; I/ C5 L+ f  r
14.#define MESSAGE_PROBE_COORDINATES  //坐标通过Grbl $ #的打印参数?* i! g) r- u6 K
15.#define SAFETY_DOOR_SPINDLE_DELAY 4000 //安全门主轴延时
; C# O6 J4 U, T/ |; n. _% Q16.#define SAFETY_DOOR_COOLANT_DELAY 1000 //安全门冷却液延时! ^; f4 L, z, |$ }- f; f8 k
17.#define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS) //启用CoreXY运动学。
; ?4 t! `" B3 v' K- l18.#define COREXY // Default disabled. Uncomment to enable.改变X和Y轴的运动原理5 I6 l. I4 T, b0 E" B
19.#define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.反转针销逻辑的控制命令
6 X+ z) v% |- \$ ^5 C20.#define INVERT_SPINDLE_ENABLE_PIN // 反转主轴使销从low-disabled
6 b, A  t* j+ b8 ?8 i0 Y6 i# }9 f21.#define REPORT_CONTROL_PIN_STATE //启用控制销状态反馈状态报告。/ V( A) }- g, @5 W! L
22.#define FORCE_INITIALIZATION_ALARM //启用和用户安装限位开关,Grbl将启动报警状态指示  s/ g% B' J( ^; O9 i# P2 S
23.#define REPORT_GUI_MODE // gui允许最小的报告反馈模式  F. }2 Y" Y4 k( K! t3 J& ?2 C  D
24.#define ACCELERATION_TICKS_PER_SECOND 100 //加速度的时间分辨率管理子系统。
1 F* u  T/ Y) x$ \8 |25.#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING //自适应多轴步平滑(积累)是一种先进的功能
! {% g1 d9 V0 g3 x. r26.#define MAX_STEP_RATE_HZ 30000 //设置最大一步速率可以写成Grbl设置
4 S0 n5 a& W+ S/ s& P27.#define DISABLE_LIMIT_PIN_PULL_UP //以下选项禁用内部上拉电阻0 U3 R+ d  [. V0 d8 S4 B
28.#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS //设置哪个轴长度补偿应用的工具。假设轴总是与选择轴工具面向负方向
6 T' N( {3 C! G+ m29.#define VARIABLE_SPINDLE //允许变量轴输出电压不同的转速值。
4 ~/ V# Z) b( Y; A7 V+ S+ }4 Q% P30.#define SPINDLE_MAX_RPM 1000.0  // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.
$ x2 L$ \+ c  x! h7 `   #define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.8 T, L, q+ [* x& \  _* X+ k
31.#define MINIMUM_SPINDLE_PWM 5 //使用的变量轴输出。这迫使PWM输出最小占空比时启用。
* W0 m* Z4 L1 D% P7 [& A* ~' L32.#define USE_SPINDLE_DIR_AS_ENABLE_PIN //主轴方向使能M4被删除
) U. J* f# u2 s+ l33.#define REPORT_ECHO_LINE_RECEIVED //应该对所有正常线路送到Grbl( [% ^- A. V& h. R. h1 q0 _
34.#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min) //最小规划师结速度。设置默认最小连接速度规划计划
: R# ?' h$ Q  b35.#define MINIMUM_FEED_RATE 1.0 // (mm/min)//设置计划将允许的最小进给速率
! d3 }" ~5 v7 f- Z36.#define N_ARC_CORRECTION 12 //弧生成迭代次数之前小角度近似精确的弧线轨迹
- r1 f7 t# ~# O37.#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)//定义值设置机器ε截止来确定电弧是一个原点了?6 }% L0 _: |; N5 s% W$ n. G" |  T
38.#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds) //延时增加表现在住。默认值设置为50毫秒
7 P4 Q, J; p+ v; D& u! p39.#define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.6 @9 Z- i9 j# G! i- @' }7 f' V
40.#define BLOCK_BUFFER_SIZE 18  //线性运动规划师缓冲区的数量在任何给出时间计划
' W: I  l6 J& y/ |6 f41.#define SEGMENT_BUFFER_SIZE 6 //控制之间的中间段缓冲大小的步骤执行算法
: z7 T6 S: E9 J42.#define LINE_BUFFER_SIZE 80 //行执行串行输入流的缓冲区大小。2 z/ v  ~6 Y* `" ~/ _  X; h
43.define RX_BUFFER_SIZE 128 //串行发送和接收缓冲区大小
0 t% e6 |/ y( W# j" v44.#define TX_BUFFER_SIZE 64
' N: U! j) E) z- p  b45.#define ENABLE_XONXOFF        ////切换为串行通信发送流软件流控制。
' @5 D1 ^8 Y# ^/ I/ p; P% Q46.#define ENABLE_SOFTWARE_DEBOUNCE //一个简单的软件消除抖动特性硬限位开关。
% |. B3 X: ^% P2 x47.#define HARD_LIMIT_FORCE_STATE_CHECK        //Grbl检查硬限位开关的状态
- f: {* ]* ^# }4 y0 m, k48.// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:编译时错误检查的定义值:
, q5 x1 c1 e- F2 ]% [
% F/ f  i0 c! X  `* \___________________________________________________________________________________________________
# W# u  H8 L' E8 ]$ A/*
2 ~, s* T) X7 N  config.h - compile time configuration. Q# x* ^- R$ Y' m' G* A0 E0 w0 r
  Part of Grbl
3 S6 Q2 L9 [8 o1 N3 [; c' _5 O; _, u9 Z/ J& [3 D7 L. Q2 q/ |8 n
  Copyright (c) 2012-2015 Sungeun K. Jeon
* ~5 z+ L$ S) ^$ B; O  Copyright (c) 2009-2011 Simen Svale Skogsrud6 t( d' B8 e2 P$ w: s& j2 @1 X

& E% f1 ?! ^, {! F0 X2 m: Q  Grbl is free software: you can redistribute it and/or modify0 E; x5 Y6 \+ F! S% N& r" r
  it under the terms of the GNU General Public License as published by: h8 X/ u" B* e& ~5 x
  the Free Software Foundation, either version 3 of the License, or
& t5 [9 o" c6 @/ [9 f  (at your option) any later version.- m% C: X8 m+ O7 |4 @+ P6 X

4 h& M3 b- l$ h2 W( D# ]$ ]+ G  Grbl is distributed in the hope that it will be useful,$ e) X7 [8 l- `3 S/ Y
  but WITHOUT ANY WARRANTY; without even the implied warranty of
7 R. R1 p  x) ~* G6 e$ u+ {3 P  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0 \# ^+ ?4 x* ~, z  GNU General Public License for more details.% j5 l# [% {, C

5 n9 {) l* j' ~# _1 P  You should have received a copy of the GNU General Public License0 d3 {5 ~$ d1 S* |% t$ G
  along with Grbl.  If not, see <http://www.gnu.org/licenses/>.0 M8 Q9 h1 ^' d" }6 c' E
config.h  -编译时配置,Grbl的一部分+ \. N, H- M( B) G7 ?* b" _* }9 T9 r
: P. ^0 N" W. @
版权(c)2012 - 2015 Sungeun K. Jeon* \" T+ p% c7 K( g) r  \
版权(c)2009 - 2011 Simen Svale Skogsrud8 o0 \; v0 s$ @2 e/ Z

* n; x0 _! I" S: ?4 E( sGrbl是免费软件:可以重新分配和/或修改
. t: U: m, W  X8 AGNU通用公共许可证的条款下发布的自由软件基金会,版本3的许可,或(任您选)其后的版本。; ~8 v& A0 {8 T: S( A" U3 n7 ]
; u+ u: c1 P: I; g
Grbl分布,希望这将是有用的,但是没有任何保证;没有即使的默示保证适销性或健身为特定目的。看到
, t1 r8 H5 Z4 Z3 y  T- LGNU通用公共许可证的更多细节。# q% k4 Y% E7 q6 K. k

1 G6 O" N! A0 c) k. O你应该收到了GNU通用公共许可证的副本$ n. _1 o. A; O, D
连同Grbl。如果没有,看< http://www.gnu.org/licenses/ >。
1 A8 z! y! q3 |/ }' ]; r : }& o4 N: E: r' S& {2 D& T
*/
$ x: P" [5 s5 ~3 u, Y  " U8 J# R% H; \# e" W# ~
// This file contains compile-time configurations for Grbl's internal system. For the most part,( g) `2 r2 e5 `! K" v6 u9 [, r
// users will not need to directly modify these, but they are here for specific needs, i.e.* [/ L4 ]8 b: Z5 f6 q$ l
// performance tuning or adjusting to non-typical machines.$ `4 l" _7 x; k( ^' o2 ]2 _: h4 E1 w" U
//这个文件包含编译时配置Grbl的内部系统。在大多数情况下,
, h4 ^. T  V3 d//用户不需要直接修改这些,但是他们在这里为特定的需求,即。
5 R4 @' D% j. v2 [+ [: c//性能调优或适应非典型的机器。2 m. q8 \! ]& J

/ b0 ?+ O- q. r- t// IMPORTANT: Any changes here requires a full re-compiling of the source code to propagate them.9 D1 U4 i7 m; e, i$ Z
//重要:任何变化需要一个完整的基于源代码的传播。
% F5 g6 O: L# q+ j$ ~3 ~. c* s0 \8 h, w6 |8 y! P. r: W! m
#ifndef config_h
" R/ A, U, ]' W: r" E1 u#define config_h
1 V- B6 Y0 x, o4 F#include "grbl.h" // For Arduino IDE compatibility.) Q* u, O2 i8 a$ ^" Y
5 Q4 }' o1 _; S0 n
// Default settings. Used when resetting EEPROM. Change to desired name in defaults.h+ [  V/ G1 L. |3 r4 d
// 默认设置。在重置eepm时使用。在defaults.h改变想要的名字6 @/ w! L' a# H  T6 F2 a3 b" Q

1 T& N% T' n( i+ _: o#define DEFAULTS_GENERIC' G' O0 }+ k& `) l1 I9 ]" @
6 d9 g' ^( F  t  d5 p/ _
// Serial baud rate
5 j2 P1 v; n7 A  A  |- M$ y#define BAUD_RATE 115200                //配置串口波特率115200: a" h8 T/ A5 O" D. `1 {

/ I# M* D  I# b! X. n7 A7 D2 g7 W// Default cpu mappings. Grbl officially supports the Arduino Uno only. Other processor types
# m0 P. {9 @9 s2 w$ m2 C// may exist from user-supplied templates or directly user-defined in cpu_map.h: T2 W  L* {5 Y; q
//默认cpu映射。Grbl正式支持Arduino Uno。其他类型的处理器可能存在cpu_map.h直接从用户提供的模板或用户定义的
! {' h* Q& Y) ^- t8 o; z$ _8 T0 l) I& @# O% m% U1 Z9 {
#define CPU_MAP_ATMEGA328P // Arduino Uno CPU
9 w7 h) p  e/ [% |4 @) e2 p- ?+ [5 U4 o
// Define realtime command special characters. These characters are 'picked-off' directly from the
+ s7 Y# N* w: e' O+ i  K3 ]% g// serial read data stream and are not passed to the grbl line execution parser. Select characters% P: Y7 x  w/ e: g) t# b
// that do not and must not exist in the streamed g-code program. ASCII control characters may be , G  J' C  A/ A
// used, if they are available per user setup. Also, extended ASCII codes (>127), which are never in
) q/ N4 _( W% Y' [5 L// g-code programs, maybe selected for interface programs.- k- k1 }) [% B2 r: e
// NOTE: If changed, manually update help message in report.c.) h9 @! d* g% }4 C! _3 i" x
9 m' p  c- k# ?( f8 [( E
//定义实时命令特殊字符。这些字符是直接从“各个击破”串口读取数据流并没有传递到grbl行执行解析器。选择角色
" D2 l2 S1 r0 k( H  ?) O//不,不能存在于程序流刀位点。ASCII控制字符
* d, m3 b) l7 v- H$ h//使用,如果他们是可用的每个用户设置。同时,扩展的ASCII码(> 127),从来没有  @  V# B; Y+ B( P2 A
//刀位点的程序,也许选择界面程序。
( S% v& G" q( g4 |" Q//注意:如果改变,手动更新report.c帮助信息。
, Z' r4 e% h; ^
6 q+ Z- {% _# ]0 y) i+ D: E#define CMD_STATUS_REPORT '?'8 Y1 X1 f. c# q5 r7 x" r
#define CMD_FEED_HOLD '!'" x8 U2 Z  c  n. R; u6 N
#define CMD_CYCLE_START '~'
. V8 m; c. j$ A/ e/ S7 b5 l4 C. J#define CMD_RESET 0x18 // ctrl-x.$ O) B. `# c6 r- p
#define CMD_SAFETY_DOOR '@'* K) n+ z, _( [7 Y, U! H. m* P  b

/ p0 g. w- v. e- {5 P& V' Z' Z// If homing is enabled, homing init lock sets Grbl into an alarm state upon power up. This forces" H/ v+ R' z' ]" J3 e% Y
// the user to perform the homing cycle (or override the locks) before doing anything else. This is$ p- _2 K# _; x4 L' ?& h
// mainly a safety feature to remind the user to home, since position is unknown to Grbl.
, w* Z+ n( V% y! J: }& V. }' b! r3 R
//如果启用了回原点,导航初始化锁集Grbl进入警报状态启动。这就迫使
* G4 g' z  D" z//用户执行归航周期(或覆盖锁)在做任何其他事情之前。这是
$ F8 ?: ^! a/ B//主要安全功能,提醒用户家里,因为Grbl位置是未知的。; h( |0 |3 n* |
' ^" L9 g0 g+ M2 L: q: E5 \" N& _
#define HOMING_INIT_LOCK // Comment to disable
8 V' j: _" w, u/ C) S$ Y
1 g: I  r9 W% |8 F  t6 t$ r// Define the homing cycle patterns with bitmasks. The homing cycle first performs a search mode6 p+ g+ Q8 x  w
// to quickly engage the limit switches, followed by a slower locate mode, and finished by a short
! S6 M( l1 t9 C6 c+ P9 }! a// pull-off motion to disengage the limit switches. The following HOMING_CYCLE_x defines are executed / S! v; @; f" t5 D0 P
// in order starting with suffix 0 and completes the homing routine for the specified-axes only. If
' p3 D1 k" E1 J; A+ o2 b# S// an axis is omitted from the defines, it will not home, nor will the system update its position.) N% X2 q5 e: h) r* m
// Meaning that this allows for users with non-standard cartesian machines, such as a lathe (x then z,
. E. w, ^" i$ G' k- S$ x% D3 i  p) z// with no y), to configure the homing cycle behavior to their needs. : P$ R* t7 v' `% a
// NOTE: The homing cycle is designed to allow sharing of limit pins, if the axes are not in the same
( N" ?$ Z" F' D0 M7 z# Q// cycle, but this requires some pin settings changes in cpu_map.h file. For example, the default homing: s- X6 |0 Q# R7 d
// cycle can share the Z limit pin with either X or Y limit pins, since they are on different cycles.
! @" C. d6 y; z// By sharing a pin, this frees up a precious IO pin for other purposes. In theory, all axes limit pins, W. V% D  x; V% }
// may be reduced to one pin, if all axes are homed with seperate cycles, or vice versa, all three axes
; b4 A; i5 H# i! B// on separate pin, but homed in one cycle. Also, it should be noted that the function of hard limits
- M; R- C, @( i// will not be affected by pin sharing.: \: j' K1 X0 ^2 U) Q  y0 H
//定义导航循环模式的位掩码。归航周期首先执行一个搜索模式
" J7 n1 C# D5 u& w4 {$ ]- s( ~# W//快速进行限位开关,其次是较慢的定位模式,完成了由一个短+ o, t1 @' s* G" O- _$ g
//拖出运动脱离限位开关。以下HOMING_CYCLE_x定义执行, h2 Z/ U7 }+ z9 M
//为了与后缀0开始并完成specified-axes只寻的例程。如果4 L. ^2 j/ b: D  C
//定义省略一个轴,它会不在家,也不会系统更新它的位置。
0 W8 l, @5 a5 _$ h9 D0 S) ~//意义,这允许用户与非标准笛卡尔的机器,比如车床(x,z,
- ?) p3 E2 ^/ J6 R" R//没有y),配置导航循环行为对他们的需求。
% E# E+ b! F3 j) s- `; O//注意:归航周期允许共享限制针,如果轴不相同2 @# I8 {2 P; r5 w9 L8 @9 P( m
//循环,但这需要一些销设置cpu_map的变化。h文件。例如,默认的导航1 n, a* }6 k; A4 ^( f; |! V) p
//循环可以分享Z限位销X或Y限制针,因为它们是在不同的周期。* s6 }1 g. J, H/ Y. |
//通过共享一个销,这腾出宝贵的IO销用于其他目的。从理论上讲,所有轴限制别针! W( _0 u) T( B. Y0 T% [0 G
//可能会减少到一个销,如果所有轴与分离周期居住的地方,反之亦然,所有三个轴
& h. ~$ i  G3 ~  R//在不同销,但这时候一个周期。同时,应该注意的是,硬限制的功能* Y* }7 v5 o/ X) T/ C
//将不会影响销共享。
& x% g: K$ S# g) C& t4 d//注意:默认设置为一个传统的硬件数控机器。z轴首次明确,其次是X和Y。
' W2 r' B& a* `+ R1 D9 V# ?# p8 ^7 S' m, r
// NOTE: Defaults are set for a traditional 3-axis CNC machine. Z-axis first to clear, followed by X & Y.
8 E* T* G0 k) ]  d  R$ ]#define HOMING_CYCLE_0 (1<<Z_AXIS)                // REQUIRED: First move Z to clear workspace. 第一步Z清除工作区。
+ m& L. N; K$ l( J. _* |; D9 J#define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // OPTIONAL: Then move X,Y at the same time.然后X,Y在同一时间。% y* M$ x8 X: i
// #define HOMING_CYCLE_2                         // OPTIONAL: Uncomment and add axes mask to enable/ X; q1 h9 V; H: E

4 x% |9 y0 C7 e/ ^, Z1 a  W9 P// Number of homing cycles performed after when the machine initially jogs to limit switches.4 z0 A* ^) n6 L, [# w
// This help in preventing overshoot and should improve repeatability. This value should be one or
  g2 ^( j7 Z0 ?4 w: P3 c) J// greater.
% U3 t7 p0 C! ]! D+ O( V//执行回原点循环次数后,当机器最初慢跑限位开关。这个帮助防止过度,应该提高重复性。这个值应该是一个或大。
' l3 S+ b) {3 w7 F8 m$ f+ y2 V$ n! f5 F; k
#define N_HOMING_LOCATE_CYCLE 1 // Integer (1-128)
5 P7 Y: x7 j: P: H: m
3 ?' J5 I& \  Y& e& i) F6 F// After homing, Grbl will set by default the entire machine space into negative space, as is typical
7 B4 _. f2 x! ^6 R1 {// for professional CNC machines, regardless of where the limit switches are located. Uncomment this 6 V: f% V5 u, |6 B
// define to force Grbl to always set the machine origin at the homed location despite switch orientation.
7 e, t( @/ A: u& @2 u4 v0 n: J9 D) w+ L
//导航后,默认Grbl将整个机器空间留白,是典型的专业数控机器,不管限位开关所在的地方。6 o" X' Q" a! z5 G
//取消这定义迫使Grbl总是在这时候位置设置机器原点尽管开关方向。
/ o2 l9 m* C7 G: i5 [  C0 W3 l! E6 v. `
7 l" `+ U2 d9 j4 Y* X// #define HOMING_FORCE_SET_ORIGIN // Uncomment to enable., w5 z6 N5 d4 j& c

+ C/ k* X3 D; z) L3 A" t
8 r3 r3 H3 }9 @$ ?* I: \: t% D// Number of blocks Grbl executes upon startup. These blocks are stored in EEPROM, where the size5 k- Y6 v3 F9 ]2 E& F, s
// and addresses are defined in settings.h. With the current settings, up to 2 startup blocks may% Q$ A9 [2 |* c1 C1 }7 y
// be stored and executed in order. These startup blocks would typically be used to set the g-code- W8 h4 d' x# S2 J4 J, |
// parser state depending on user preferences.
& E  j9 ?2 M% A& |* G8 ?
2 e1 W3 I1 Y. G+ ~//块Grbl启动时执行的数量。这些块存储在eepm,大小
( R2 G0 f1 a5 D( D# A//和地址在settings.h中定义。与当前设置,可能2启动块2 A7 g$ _& k8 w9 h' V/ u: @: F" G
//存储和执行。这些启动块通常被用来设置刀位点
3 ?" v! L! K' X# B$ `2 ^//解析器的状态取决于用户首选项。
% M% p+ b) K6 H
2 C, X/ @0 D3 s, t4 n2 H7 K#define N_STARTUP_LINE 2 // Integer (1-2)
0 \0 S& u  |7 D
& s9 B. W+ Z! L+ @& v* X// Number of floating decimal points printed by Grbl for certain value types. These settings are
0 J6 ~( U# d, A! g0 D# H// determined by realistic and commonly observed values in CNC machines. For example, position2 e! s/ m9 }6 Z8 ^6 `1 B, v: M
// values cannot be less than 0.001mm or 0.0001in, because machines can not be physically more
) g  k2 H6 U+ E" F8 Z7 p5 P( u// precise this. So, there is likely no need to change these, but you can if you need to here.% l8 L7 L& ?7 Y
// NOTE: Must be an integer value from 0 to ~4. More than 4 may exhibit round-off errors.
: f7 |2 W8 ?/ a' g
, K( c1 m: D2 s// Grbl浮动小数点的数字印刷的特定的值类型。这些设置是# q+ O9 e' \2 W8 s. n, |, Q
//一般由现实和观测值在数控机器。例如,位置
' J, a8 ^( P$ z; G. b0 d. T3 H//值不能小于0.001毫米或0.0001,因为机器不能身体更多8 V1 h* ^8 n- B3 {5 ^# c/ @; p
//精确。因此,有可能不需要改变这些,但你可以在这里如果你需要。% n9 K+ [% d8 s, E9 w& J1 k
//注意:必须是一个整数值从0 ~ 4。超过4可能出现舍入错误。! s$ D, i! I6 m( F

2 z" w0 }$ W6 F8 [6 f, f1 K, S7 ]- M6 N#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 协调或位置价值英寸
, M9 J; K& A4 l#define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 协调在毫米或位置价值
. h7 A6 E5 X# Y2 ]3 K#define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分钟的速度值
; Q' A, ^- [% ~- B/ y0 m#define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分钟
* y: l( C3 e/ h" ^#define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 对浮点小数设置值" H3 |+ G4 J2 s
) D* h/ @3 O+ G5 q
// If your machine has two limits switches wired in parallel to one axis, you will need to enable
& ^  D+ n) P% ], w" F: G1 W! I" ?// this feature. Since the two switches are sharing a single pin, there is no way for Grbl to tell
* H/ o$ c$ k  @( R+ Y// which one is enabled. This option only effects homing, where if a limit is engaged, Grbl will
$ {4 p) S/ W8 F0 @+ x; \// alarm out and force the user to manually disengage the limit switch. Otherwise, if you have one
" O: k$ `) B" ~; k4 M// limit switch for each axis, don't enable this option. By keeping it disabled, you can perform a
' _0 G0 H2 N+ Q7 x' U// homing cycle while on the limit switch and not have to move the machine off of it.
+ N5 q9 ]% y2 N2 y: y1 H- k
  Y2 M( u* o" f$ A) G8 t+ C# s! K//如果你的机器有两个极限开关连接在平行于一个轴,您需要启用8 I( `5 i! |+ L# E. u5 k+ a& w- y
//这个特性。自从两个交换机共享一个销,没有办法Grbl告诉
! X6 b, K( I  F5 \# m% ^0 P1 |//启用哪一个。此选项仅影响归航,如果限制,Grbl意志
# E) z7 d+ h( c3 E1 D! }- i//报警,迫使用户手动松开限位开关。否则,如果你有一个0 i9 t" |) g* e' i: `
//为每个轴限位开关,不启用该选项。通过保持禁用,您可以执行
1 o% K2 y  [9 J8 K' b9 C. P/ _- x! m6 C//导航循环在限位开关并没有将这台机器。8 q5 F4 N" d" a4 L# h

' _/ i# m( T& k: \" k/ M0 ~// #define LIMITS_TWO_SWITCHES_ON_AXES
% V" L% C7 e  R. q' j: K2 N# |2 L+ ~) {4 r5 f0 j; S) c/ A
// Allows GRBL to track and report gcode line numbers.  Enabling this means that the planning buffer5 U+ S- I! K, f6 v$ D# ?
// goes from 18 or 16 to make room for the additional line number data in the plan_block_t struct
, o2 R# ~4 p" }9 W. e" [" Q( g
( \( E# E, a: `# h//允许GRBL跟踪和报告gcode行号。使这意味着计划缓冲从18岁或16岁,为额外的行号plan_block_t结构中的数据1 o* ?! C, g! ]+ f& ^
( o  n  s( g4 k6 q( w- H: `! L
// #define USE_LINE_NUMBERS // Disabled by default. Uncomment to enable.- f* i  L/ s$ t5 m) C/ G

& g0 W1 ^1 F1 U/ Y// Allows GRBL to report the real-time feed rate.  Enabling this means that GRBL will be reporting more
( M; h9 _5 f; m// data with each status update.5 [& P' T! C+ _" M
// NOTE: This is experimental and doesn't quite work 100%. Maybe fixed or refactored later.
3 `8 ]: u+ w% {  g# e( w//允许GRBL报告实时进给速率。使这意味着GRBL将报告数据和状态更新。$ t/ U: t/ I" `
//注意:这是实验和100%没有工作。也许以后固定或重构。
$ Y  M; x* B* w! z6 I  K# p7 r
# m; }* x  B& S% ~8 r// #define REPORT_REALTIME_RATE // Disabled by default. Uncomment to enable.
5 L+ f" C0 |) }4 e
" y1 v9 h5 G7 m6 T5 {  k2 g: e/ e9 T// Upon a successful probe cycle, this option provides immediately feedback of the probe coordinates
, `: C3 s; x4 U, y3 V  v/ D// through an automatically generated message. If disabled, users can still access the last probe
5 P6 _: ?8 ?/ D; v// coordinates through Grbl '$#' print parameters.
0 A! t7 t1 j6 u( K- \' }+ t5 v' ^//在一个成功的调查周期,这个选项提供立即反馈的探测器坐标
1 }4 ?8 t2 M, F1 N9 k//通过一个自动生成的消息。如果禁用,用户仍然能够访问调查
# c8 X1 q; c% U$ E6 E4 A% F//坐标通过Grbl $ #的打印参数。' Z, X* N2 j( g, B% r& q+ V
8 N# y  a1 k" j/ K( F+ J# M
#define MESSAGE_PROBE_COORDINATES // Enabled by default. Comment to disable.1 G0 g- N' ?$ o& T
. ]7 v/ n- e$ g. }% ]3 y+ U& T5 b
// Enables a second coolant control pin via the mist coolant g-code command M7 on the Arduino Uno
5 T8 o. N% m$ Y* f: k- ~/ C// analog pin 5. Only use this option if you require a second coolant control pin." l7 {6 [2 b2 g2 {
// NOTE: The M8 flood coolant control pin on analog pin 4 will still be functional regardless.5 a: F1 [9 A% e# ^  M; q
// #define ENABLE_M7 // Disabled by default. Uncomment to enable.9 ?2 Q% X6 v( @8 t2 Z1 i3 S
/ X$ w8 |6 t2 _, n, k2 J
// This option causes the feed hold input to act as a safety door switch. A safety door, when triggered,
7 X4 z* T3 k% Q4 m( s! g// immediately forces a feed hold and then safely de-energizes the machine. Resuming is blocked until1 ]: q9 X5 T. K8 u5 _1 \5 k6 @
// the safety door is re-engaged. When it is, Grbl will re-energize the machine and then resume on the
2 p5 Z9 ^  j! H& N// previous tool path, as if nothing happened.& X% k$ B5 I  b0 I$ s( \
// #define ENABLE_SAFETY_DOOR_INPUT_PIN // Default disabled. Uncomment to enable.3 B, N: p8 I* Y3 ?" a

6 b  K/ o) k* i& I5 h; e6 ~// After the safety door switch has been toggled and restored, this setting sets the power-up delay
& P# N4 J5 ]4 }$ Y1 a5 y, r$ P8 i// between restoring the spindle and coolant and resuming the cycle.
, I$ w8 Y* i- S) Q- x7 b, L// NOTE: Delay value is defined in milliseconds from zero to 65,535.
; c# \; A/ r' \% u& l; O. e, p! l# k" b' y8 E4 h% J
//定义导航循环模式的位掩码。归航周期首先执行一个搜索模式
. a- o3 r) X$ w5 S: w) f5 Y//快速进行限位开关,其次是较慢的定位模式,完成了由一个短
7 V/ b  g8 R  u+ K- y8 W" V//拖出运动脱离限位开关。以下HOMING_CYCLE_x定义执行( b' x: k! w  t  R8 @2 o2 ^# s
//为了与后缀0开始并完成specified-axes只寻的例程。如果) W; j' d+ u/ B* A1 z% M: O/ p
//定义省略一个轴,它会不在家,也不会系统更新它的位置。
3 Y& ~" B2 @, \. u//意义,这允许用户与非标准笛卡尔的机器,比如车床(x,z,
1 Z2 @: l5 h* G4 ?+ Y) l7 H//没有y),配置导航循环行为对他们的需求。# I# Y  q4 \$ Y0 d, g, ?
//注意:归航周期允许共享限制针,如果轴不相同
; a: n+ r4 H) g1 z/ _//循环,但这需要一些销设置cpu_map的变化。h文件。例如,默认的导航
% R/ m+ e2 U. q; e- b6 S0 H//循环可以分享Z限位销X或Y限制针,因为它们是在不同的周期。
9 K8 N  @0 d8 u/ I' \. A( M//通过共享一个销,这腾出宝贵的IO销用于其他目的。从理论上讲,所有轴限制别针
; Y% @% t+ x0 x# ?" i  f//可能会减少到一个销,如果所有轴与分离周期居住的地方,反之亦然,所有三个轴
; W' q7 v. Z' o1 H/ m0 [//在不同销,但这时候一个周期。同时,应该注意的是,硬限制的功能
2 ~& E7 j# v' ^- X  _//将不会影响销共享。6 O) y+ p1 q' ~" c
//注意:默认设置为一个传统的硬件数控机器。z轴首次明确,其次是X和Y。* q7 g" M, b2 [; z1 ^* I: K# n

$ `0 C; q0 T0 k/ p. M/ E' O& p1 A8 b/ k
#define SAFETY_DOOR_SPINDLE_DELAY 4000
+ L+ a6 o8 z5 }- B3 s( \#define SAFETY_DOOR_COOLANT_DELAY 1000
. O% o" W' {  A
" ^# R% Q) K" N% \6 f5 e$ f$ J// Enable CoreXY kinematics. Use ONLY with CoreXY machines. 8 I8 B  R3 p. j: _0 K+ L$ u3 n
// IMPORTANT: If homing is enabled, you must reconfigure the homing cycle #defines above to " w( B" a+ h& L& l
//启用CoreXY运动学。只使用与CoreXY机器。
) K3 _" M) ]# r% H3 W//重要:如果启用了自动寻的,你必须重新配置导航循环#定义上面: y  i$ a) O4 S1 H
2 D* u5 v" b! A: G; K& s
// #define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS)
9 V( g* ]5 O# [0 l! y6 N9 Y$ i( x' r8 S2 q5 h4 ?- o4 A
// NOTE: This configuration option alters the motion of the X and Y axes to principle of operation
& i1 |/ B, k0 ~// defined at (http://corexy.com/theory.html). Motors are assumed to positioned and wired exactly as
+ s" G& ~) S; T3 F- L// described, if not, motions may move in strange directions. Grbl assumes the CoreXY A and B motors. r% y2 Q8 `/ r, T- H* k
// have the same steps per mm internally.! K- Y$ w% C; U. Y2 t- y2 s
//注意:这种配置选项改变X和Y轴的运动原理,操作  N( |9 `' T7 j$ O, d( y0 ]+ R
//定义(http://corexy.com/theory.html)。汽车被认为定位和连接一样
+ K0 ]! Y7 n  a% j7 i* X# D//描述,如果没有,运动可能会奇怪的方向移动。A和B Grbl假设CoreXY马达, j  Y* K; w  ?' q6 X7 J" b# r
//每毫米内部有相同的步骤。7 @2 n/ a2 O. _1 t
. b, d2 B: K  T  \. Y
// #define COREXY // Default disabled. Uncomment to enable.+ M: M1 [4 z; r
5 T( B. `- L3 `8 m( [( x% g; p' |5 Y! Y
// Inverts pin logic of the control command pins. This essentially means when this option is enabled
$ a3 c+ J" b' [7 O- g// you can use normally-closed switches, rather than the default normally-open switches.
, u! X7 @1 ]# M: Q// NOTE: Will eventually be added to Grbl settings in v1.0.1 f' T" W& \, V
//反转针销逻辑的控制命令。这实质上意味着当启用这个选项; J$ e, y0 U8 X1 c, h9 c0 ^
//可以使用闭合开关,而不是默认的常开开关。
# f6 k( b- H# C8 z" |7 O0 ?- k//注意:最终将被添加到在v1.0 Grbl设置。
- ^1 S, D: z  F5 ^
$ m6 o) ?1 U; x: w3 Y. l// #define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.
. o" C" `: f& B9 d4 b. y% p
7 w9 J7 J' s- P0 V( j- K, h; j5 n// Inverts the spindle enable pin from low-disabled/high-enabled to low-enabled/high-disabled. Useful
* w0 G$ b: Y- a6 q  q$ b: e! f// for some pre-built electronic boards.
4 U0 S% H( W$ Q// NOTE: If VARIABLE_SPINDLE is enabled(default), this option has no effect as the PWM output and 1 e" ]& c. f" i! g
// spindle enable are combined to one pin. If you need both this option and spindle speed PWM, : Z# g/ n% R) R
// uncomment the config option USE_SPINDLE_DIR_AS_ENABLE_PIN below.
2 S+ C+ m$ K: @: a//反转主轴使销从low-disabled / high-enabled low-enabled / high-disabled。有用的- G+ Z6 r2 f% a; j1 u
//预构建的电子板。- K% a% [$ ^# D% e7 z8 r- D6 }0 G9 q
//注意:如果启用了VARIABLE_SPINDLE(默认),这个选项作为PWM输出并没有影响
( i: V  c% L7 t6 C" C//销轴使结合。如果你需要这个选项和主轴转速PWM,- Q: W; [% H! b9 g) H0 r/ v: Y4 m' q
//取消注释以下配置选项USE_SPINDLE_DIR_AS_ENABLE_PIN+ }' `- S5 f5 N" D; e7 K

  G% V8 t' p: T7 R7 q; A. C2 U6 O// #define INVERT_SPINDLE_ENABLE_PIN // Default disabled. Uncomment to enable.
  d/ {5 N- |5 A  ]
4 a* m& @/ r: {% y/ w+ Y" G// Enable control pin states feedback in status reports. The data is presented as simple binary of
' A: X% D! n; \// the control pin port (0 (low) or 1(high)), masked to show only the input pins. Non-control pins on the
$ `7 U+ }* W' I9 u# U// port will always show a 0 value. See cpu_map.h for the pin bitmap. As with the limit pin reporting,
+ k( c# e! t  ]) G( E// we do not recommend keeping this option enabled. Try to only use this for setting up a new CNC.) ^, M' ~/ h/ ~) ~9 m( c
//启用控制销状态反馈状态报告。作为简单的二进制数据
8 O5 a3 f% }- v+ Z# k! A& }//控制针端口(0(低)或1(高)),蒙面,只显示输入插脚。非控制性针上
$ x+ m6 |4 R8 g//端口总是显示0值。看到cpu_map。针位图h。与限制销报告,
; K# p+ v) b* m& \! D/ V% L4 @//我们不推荐保持启用这个选项。尽量只使用这个设置一个新的数控。# b, ~+ @& F% W0 R0 o4 w+ Q
6 E+ [: c0 M  [" g" L2 M
// #define REPORT_CONTROL_PIN_STATE // Default disabled. Uncomment to enable.
* `5 l8 L6 X7 ]1 o+ S, y" J$ f5 ^( N
// When Grbl powers-cycles or is hard reset with the Arduino reset button, Grbl boots up with no ALARM% E- ]; Y- K- S' Y/ e+ P
// by default. This is to make it as simple as possible for new users to start using Grbl. When homing
) u1 C. c; ^6 r) o// is enabled and a user has installed limit switches, Grbl will boot up in an ALARM state to indicate ! R5 {% `% |) }9 y
// Grbl doesn't know its position and to force the user to home before proceeding. This option forces  I+ Q- h: e' b  l4 A4 r
// Grbl to always initialize into an ALARM state regardless of homing or not. This option is more for" N. j0 A  `, Z4 m7 ?  w# T. G* a
// OEMs and LinuxCNC users that would like this power-cycle behavior.* ^. ~5 j$ Y! d' ?4 \' a( {- g
//当Grbl powers-cycles还是硬重置Arduino复位按钮,Grbl启动没有报警
% i) }5 [% y, ~  o, Z//默认情况下。这是为了让新用户尽可能简单使用Grbl开始。当归航( S' t) w4 e: ]. j
//启用和用户安装限位开关,Grbl将启动报警状态指示
, Z- q' S( \! l% ?# p0 g3 p// Grbl不知道它的位置,迫使用户在继续之前回家。这个选项部队
0 e5 H! q# n3 [, ]! f// Grbl总是初始化进入警报状态不管归航。这个选项是更多
3 f) {" `* I% r# ~  \//原始设备制造商和LinuxCNC用户这样的控制行为。
$ s) h! k& U2 @- _5 `4 y4 s1 E2 D+ i+ {' @
// #define FORCE_INITIALIZATION_ALARM // Default disabled. Uncomment to enable.
6 U# G7 k- c  V2 z5 P+ C& n6 J- y  I  i8 z9 R6 M
// ---------------------------------------------------------------------------------------
# D) c! |, h# t  v' @) v// ADVANCED CONFIGURATION OPTIONS://高级配置选项:
6 ?) J8 ?: _5 P( u9 E. E. _
( W* t- @: v  W5 I- I1 ^// Enables minimal reporting feedback mode for GUIs, where human-readable strings are not as important.
6 |2 ^, J" k  n3 x! X7 b// This saves nearly 2KB of flash space and may allow enough space to install other/future features.
$ B$ Y/ c( r0 g" q! L// GUIs will need to install a look-up table for the error-codes that Grbl sends back in their place., i; F  ^" I2 Z
// NOTE: This feature is new and experimental. Make sure the GUI you are using supports this mode.
) ]: j- ~% g% t7 E0 d5 H% |
# Y% _3 b2 g; g1 C5 M$ D- u// gui允许最小的报告反馈模式,人类可读的字符串在哪里不重要。
5 J( M& _% Z( ~( B; H3 Z//这个节省近2 kb的闪存空间,允许足够的空间来安装其他/未来的功能。3 y, {9 M6 }7 W: i3 N1 B1 ~
// gui需要安装一个查找表的错误代码Grbl发回。
3 o7 @3 M. ^3 Z& t! J  g- r: a) a//注意:此功能是新的和实验。确保您使用的GUI支持这种模式。
$ ~! j3 P. i& s0 [7 v3 ^+ c8 w9 W2 U
// #define REPORT_GUI_MODE // Default disabled. Uncomment to enable.
; s9 E  N/ h- p: I% W0 q6 }
8 t. m- r( q; x% J% y' y; s// The temporal resolution of the acceleration management subsystem. A higher number gives smoother8 a& K% X" S# `, ?6 H9 _
// acceleration, particularly noticeable on machines that run at very high feedrates, but may negatively
0 w; H$ U  s5 Q, _6 X// impact performance. The correct value for this parameter is machine dependent, so it's advised to
# q) L3 K3 K1 r// set this only as high as needed. Approximate successful values can widely range from 50 to 200 or more.+ r1 t" c) m+ g) F+ Z2 {: H
// NOTE: Changing this value also changes the execution time of a segment in the step segment buffer. % @0 C+ f  O  |! b7 V6 x
// When increasing this value, this stores less overall time in the segment buffer and vice versa. Make
/ e( Z+ j$ m. o* ?// certain the step segment buffer is increased/decreased to account for these changes.1 ~9 h. a2 V! j8 C9 @# l
//加速度的时间分辨率管理子系统。更多更平稳! h3 f5 B0 N% v
//加速度,特别明显的机器上,运行在非常高的进料速度,但可能负面
9 r3 _0 D4 W( h3 x/ m. u' S//影响性能。正确的值为这个参数是依赖于机器的,所以建议
) M, r' k, `$ u; V//这只设置为高。近似成功的价值观可以广泛的范围从50到200或者更多。
+ |' E( Y. [- S. b. L" u. K//注意:改变这个值也变化的部分步骤的执行时间缓冲。' u* v) d: }! P- \' Q! Q
//增加这个值时,这个商店部分缓冲区的总时间减少,反之亦然。使6 a' K: b& a# n9 V8 Z& V
//特定步骤段缓冲是考虑这些变化增加/减少。
& d# Q) t) E! O1 @# U+ W8 [2 K: u: x1 ?
#define ACCELERATION_TICKS_PER_SECOND 100  //加速度的时间分辨率管理子系统。更多更平稳& q+ P. p0 K  p
6 R" o! G% G; k5 y2 z4 o
// Adaptive Multi-Axis Step Smoothing (AMASS) is an advanced feature that does what its name implies, 2 v( _8 {% Z9 M' E$ C1 e6 v
// smoothing the stepping of multi-axis motions. This feature smooths motion particularly at low step
* M" E; m, c; }0 w: X7 F6 V// frequencies below 10kHz, where the aliasing between axes of multi-axis motions can cause audible
8 t1 C, W# N# w! c, }5 a% p// noise and shake your machine. At even lower step frequencies, AMASS adapts and provides even better8 e7 m5 ]2 T7 n8 E+ \8 U; |! r+ h+ Q
// step smoothing. See stepper.c for more details on the AMASS system works.
- \$ H0 f1 e& x8 p//自适应多轴步平滑(积累)是一种先进的功能,它的名字所暗示的那样,
9 N% Q* f% @+ c* @  `2 L//平滑的多轴步进运动。这个特性平滑运动尤其是在低一步0 Y) S; m) M/ K$ A0 p6 H. K- m
//频率低于10 khz,轴之间的混叠的多轴运动可能导致音响$ I. g2 i6 I  Y3 {! j
//噪音和震动你的机器。在更低的频率步,积累适应并提供更好
6 }3 N+ ?- y% c4 A2 M//步骤平滑。看到步进。c更多细节的积累系统的工作原理。3 o8 l# I! S& H9 \* l# N

6 T* p2 Q6 {; S, y2 R#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING  // Default enabled. Comment to disable.//自适应多轴步平滑8 A. P( {% k; s( u2 b3 S

. M  ~$ l# C$ \) ]5 [  \2 W/ i5 H8 S// Sets the maximum step rate allowed to be written as a Grbl setting. This option enables an error
; Z+ \0 ?2 `  e  f8 H. k6 k// check in the settings module to prevent settings values that will exceed this limitation. The maximum
4 ]! }7 f* K9 H  x/ f# z// step rate is strictly limited by the CPU speed and will change if something other than an AVR running
% e& f% u# ~( }0 ~) B( J6 V" t7 c: l// at 16MHz is used.: ?, l5 p8 B1 {+ k6 z' D
// NOTE: For now disabled, will enable if flash space permits." F, C8 A" H& ~4 I
//设置最大一步速率可以写成Grbl设置。这个选项可以使一个错误; R  q9 o: I/ W/ {4 o, h
//设置模块中检查,防止设置值将超过这个限制。的最大1 n5 d: W+ T3 v! |1 N0 P
//步骤严格限制的CPU速度也会改变如果是其他AVR运行+ O& x/ z+ w( {% U5 y1 D7 E
//使用16兆赫。9 A" U+ x: w) r& c+ w
//注意:现在残疾,将使如果flash空间许可。9 X* e+ i5 i/ w- @( u

4 P1 ^0 j3 \* K( @% h1 o. l6 T// #define MAX_STEP_RATE_HZ 30000 // Hz 设置最大一步速率
/ q2 N- {8 I6 [; T% r! R' c3 ^* d. s: J5 l3 P
// By default, Grbl sets all input pins to normal-high operation with their internal pull-up resistors5 W, O( M# ^1 j, e' p
// enabled. This simplifies the wiring for users by requiring only a switch connected to ground,
# T3 u0 g( L. n1 E# L) l// although its recommended that users take the extra step of wiring in low-pass filter to reduce4 w1 L3 X& u# ?% Q
// electrical noise detected by the pin. If the user inverts the pin in Grbl settings, this just flips& W, H  A% D* ?* W) c8 Y& O
// which high or low reading indicates an active signal. In normal operation, this means the user / h: x3 d5 Y$ O+ C
// needs to connect a normal-open switch, but if inverted, this means the user should connect a
8 _! P3 Q" b' b0 A) w, b8 }// normal-closed switch. $ Q0 I# x, Q& r3 {/ k; h+ \
// The following options disable the internal pull-up resistors, sets the pins to a normal-low & P! c6 Z. X: s0 F0 O
// operation, and switches must be now connect to Vcc instead of ground. This also flips the meaning , ?# Q& \6 o0 M+ ~
// of the invert pin Grbl setting, where an inverted setting now means the user should connect a
, R4 \- s# e5 c) H- I/ v5 H// normal-open switch and vice versa.' q, W4 }" a. u4 H7 Z6 @3 r3 l
// NOTE: All pins associated with the feature are disabled, i.e. XYZ limit pins, not individual axes.
1 F$ O# x0 ~9 \) g( O% H. m* ], G// WARNING: When the pull-ups are disabled, this requires additional wiring with pull-down resistors!
, m" T$ n' }# f& @//默认情况下,Grbl所有输入引脚设置为正常高操作的内部上拉电阻
: f0 b; E/ G4 r; R& ^  D//启用。这简化了布线为用户只需要一个开关连接到地面,
: \% m5 ^5 s( v' M  W//虽然其建议用户采取额外的步骤,在低通滤波器来减少布线/ O$ e2 F) a2 h2 M. ^0 I/ S
//电噪音检测销。如果用户反转的销Grbl设置,这只是翻转; R2 ^7 z, ?! o: B
//读高或低表明一个积极的信号。在正常操作中,这意味着用户$ T9 |/ O2 X0 f1 G
//需要连接一个常开开关,但如果倒,这意味着用户应该连接
3 h) J7 o4 e/ |6 @; q7 Q; h$ i// normal-closed开关。
2 b) Z9 A. S$ `1 V7 Y: W* h  Z6 R, d//以下选项禁用内部上拉电阻,一般低设置别针
+ _* H( H- U7 P# x* s//操作,现在开关必须连接到Vcc代替地面。这也掀的意思: T1 J" ^8 b, ^9 k2 B8 q' {
//反销Grbl设置,一个倒置的设置现在意味着用户应该连接
* q, D4 r, m% P//常开开关,反之亦然。% U% p& l6 x# T, |5 E" c
//注意:所有针与功能被禁用,例如XYZ限制针,而不是单独的轴。% O5 ~6 e2 k- F9 ^
//警告:引体向上被禁用时,这需要额外的布线与下拉电阻!# r+ A, N3 z4 V9 a) O, w7 Z

8 k" G7 P/ [8 U7 _5 O//#define DISABLE_LIMIT_PIN_PULL_UP //以下选项禁用内部上拉电阻$ h% w) _# U5 ?6 \! ?
//#define DISABLE_PROBE_PIN_PULL_UP. o3 e8 S5 e7 [+ T+ p; J6 a! r
//#define DISABLE_CONTROL_PIN_PULL_UP0 J  @- T1 N* j4 O+ m; [5 M
6 m" i/ d# C4 U0 j' P- c7 U/ L
// Sets which axis the tool length offset is applied. Assumes the spindle is always parallel with
; e; ]+ F9 k2 A2 r& w" I// the selected axis with the tool oriented toward the negative direction. In other words, a positive
/ S6 i0 p% o! l( f// tool length offset value is subtracted from the current location.
- s4 W' H1 y7 t: F" i7 I" J( |1 B//设置哪个轴长度补偿应用的工具。假设轴总是与- t( _0 e! A8 t. n
//选择轴工具面向负方向。换句话说,一个积极的9 D* x5 E6 A, a: m1 ?/ c2 X
//工具长度偏移值减去从当前位置。
7 b0 H+ l' M4 g; i( u
6 i/ S- P# I& [+ i' D" Y#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS // Default z-axis. Valid values are X_AXIS, Y_AXIS, or Z_AXIS.设置哪个轴长度补偿应用的工具
7 \" d* d! I6 h* j
& j* K$ |8 _: O* w// Enables variable spindle output voltage for different RPM values. On the Arduino Uno, the spindle9 B9 d5 L) x) Y* \- c) r6 p, `
// enable pin will output 5V for maximum RPM with 256 intermediate levels and 0V when disabled.
# f+ x+ o2 n' D! L4 Q# \// NOTE: IMPORTANT for Arduino Unos! When enabled, the Z-limit pin D11 and spindle enable pin D12 switch!
* `6 [: R0 y7 S; s' p7 b// The hardware PWM output on pin D11 is required for variable spindle output voltages.
$ R5 Y! P, b# Q( O- C2 U) D  X: C//允许变量轴输出电压不同的转速值。Arduino Uno,主轴
9 {6 b7 O7 E9 I& e, \//启用销将输出5 v的最高转速256中级水平和0 v时禁用。
1 Y' R! J% M* U% ^//注意:重要Arduino凯泽本人!当启用时,Z-limit销这里和轴销D12开关!
+ S( o4 `* o! |0 j! e//硬件PWM输出销这里需要变量轴输出电压。! `. q1 m6 A" X- x3 ^4 Q
  Z5 V7 ]$ f1 R, F/ ^) Y7 y1 U
#define VARIABLE_SPINDLE // Default enabled. Comment to disable.//允许主轴输出电压不同的转速值
7 v( N) P4 R: i& C4 i, c) i  ^9 Q: [8 d. u  p2 K
// Used by the variable spindle output only. These parameters set the maximum and minimum spindle speed2 M' q/ Y/ i# _. Z0 [- k3 H
// "S" g-code values to correspond to the maximum and minimum pin voltages. There are 256 discrete and
) t" F! b/ b, h4 z) p/ q9 o' e// equally divided voltage bins between the maximum and minimum spindle speeds. So for a 5V pin, 1000& ^& F' r9 n7 M8 U+ L2 x8 o
// max rpm, and 250 min rpm, the spindle output voltage would be set for the following "S" commands: ( |/ m# d; I9 Z6 U
// "S1000" @ 5V, "S250" @ 0.02V, and "S625" @ 2.5V (mid-range). The pin outputs 0V when disabled.- p0 Z; G" E% K8 P: q. s  r
//使用的变量轴输出。这些参数设置最大和最小轴转速' l/ x1 `" {$ y$ ]
//“S”刀位点值对应于销电压的最大值和最小值。有256个离散和
$ ~/ Q$ a: O) N4 Q( o//电压平均分配箱主轴速度的最大值和最小值之间。所以对于一个5 v销,10009 e) V+ I+ }5 m7 f
// max rpm,250分钟rpm,主轴输出电压将为以下“S”命令:
! P. s# a7 R$ i1 |// @“S1000 5 v,“S250”@ 0.02 v,“S625”@ 2.5 v(中档)。销输出0 v时禁用。2 s5 `: c# Q! i2 c! c% F
# a( J% v6 |3 q5 f( t+ E
#define SPINDLE_MAX_RPM 1000.0 // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.5 }6 I) \/ x+ D- e3 d* O
#define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.) @/ _7 N1 }/ S- D! I: Q$ E* t

7 r/ _, a- R) K  n// Used by variable spindle output only. This forces the PWM output to a minimum duty cycle when enabled.! G# }( l6 k* x4 L4 W* W
// When disabled, the PWM pin will still read 0V. Most users will not need this option, but it may be
2 T% i9 e2 p8 h// useful in certain scenarios. This setting does not update the minimum spindle RPM calculations. Any
6 U6 E$ C% N' _' D# c7 W// spindle RPM output lower than this value will be set to this value.# M) ^' K" |* q0 \- k" e$ n! F
//使用的变量轴输出。这迫使PWM输出最小占空比时启用。5 k  U! a' p* ?+ `
//当禁用,PWM销仍读0 v。大多数用户不需要这个选项,但是它可能是2 i' [! [) V5 d8 Z) X2 k: q
//在某些情况下很有用。这个设置不会更新最小主轴转速计算。任何! x! m# O- t* _
//输出轴转速低于这个值将被设置为这个值。# N5 a6 T/ B9 R

6 |  I& P+ T# Y' _5 s: t1 w// #define MINIMUM_SPINDLE_PWM 5 // Default disabled. Uncomment to enable. Integer (0-255)* I, L3 y% ]5 q3 E

7 I9 n( M& G( m, B2 K// By default on a 328p(Uno), Grbl combines the variable spindle PWM and the enable into one pin to help % b% p5 O+ j; Z! N% I/ H) t3 M
// preserve I/O pins. For certain setups, these may need to be separate pins. This configure option uses* d8 e" o: D5 ?" C5 u
// the spindle direction pin(D13) as a separate spindle enable pin along with spindle speed PWM on pin D11. 5 j8 O: Z1 Y6 T
// NOTE: This configure option only works with VARIABLE_SPINDLE enabled and a 328p processor (Uno). 2 x0 K  q) F2 D
// NOTE: With no direction pin, the spindle clockwise M4 g-code command will be removed. M3 and M5 still work.5 E; _  A9 p+ n
// NOTE: BEWARE! The Arduino bootloader toggles the D13 pin when it powers up. If you flash Grbl with
7 O. C8 O: r5 m4 ]& f2 |; ?// a programmer (you can use a spare Arduino as "Arduino as ISP". Search the web on how to wire this.),   u& X- ?. m/ b( ?( e' |4 V
// this D13 LED toggling should go away. We haven't tested this though. Please report how it goes!' P3 E% D' [; t7 k
//默认ATmega328 p(Uno),Grbl结合变量轴PWM和使到一个销的帮助
/ _: b/ i! Z8 e. S$ b& E$ E! C//保存I / O管脚。对于某些设置,这些可能需要单独的别针。这个配置选项使用3 ?1 h& f2 O8 ?8 L% I, S7 r
//方向轴销(D13)作为一个单独的轴销上启用销以及主轴转速PWM这里。
( L! n7 G3 ?! ^" m9 O//注意:该配置选项仅适用于VARIABLE_SPINDLE启用和328 p处理器(Uno)。
7 V! J$ P! m2 z) b' {! e//注意:没有方向销,主轴顺时针M4刀位点命令将被删除。M3和M5仍然工作。: B6 q- ?1 j* T* \, N. _- k
//注意:小心!Arduino引导装载程序切换D13销的权力。如果flash Grbl- W4 U6 {. z( L+ q6 \- I
//程序员(您可以使用一个备用Arduino“Arduino ISP”。搜索网络如何线),
, h  l) @, V+ w, Q% ^: N5 G//这D13导致切换应该消失。我们还没有测试这个。请报告将会怎样!
! Q, S+ ~6 k1 B2 q3 I7 r: f' r+ n" o6 r" F8 c9 c5 C
// #define USE_SPINDLE_DIR_AS_ENABLE_PIN // Default disabled. Uncomment to enable.4 k, f" |) S+ |* d" m( N
8 f* C9 Q% [4 y. n2 g
// With this enabled, Grbl sends back an echo of the line it has received, which has been pre-parsed (spaces
. E) H! J9 V& l' j* v# C5 \// removed, capitalized letters, no comments) and is to be immediately executed by Grbl. Echoes will not be 5 b1 B! p$ h: V- K- T
// sent upon a line buffer overflow, but should for all normal lines sent to Grbl. For example, if a user
% O" l# F; B" }0 m, X3 ?5 g+ ?// sendss the line 'g1 x1.032 y2.45 (test comment)', Grbl will echo back in the form '[echo: G1X1.032Y2.45]'.+ O) L: X* {$ ]
// NOTE: Only use this for debugging purposes!! When echoing, this takes up valuable resources and can effect2 G  v9 X2 x& K$ e* M! t6 d9 x" ]
// performance. If absolutely needed for normal operation, the serial write buffer should be greatly increased7 v6 O; r8 t# D/ y$ j0 F
// to help minimize transmission waiting within the serial write protocol.
$ P  F+ U7 e3 }3 z: x
) b6 ~* C6 S$ Q; i& |//启用,Grbl发回的回声线已收到,已预编译(空间
( O8 y/ }. E& x//移除,大写字母,没有评论),由Grbl立即执行。回声将不会
, A: ~* N6 |4 D9 B! G//发送一个线缓冲区溢位,但应该对所有正常线路送到Grbl。例如,如果一个用户- x, l* ?9 ^2 ]$ Y4 H
//发送线的g1 x1.032 y2.45(测试评论)形式”,Grbl将回声”(回声:G1X1.032Y2.45]”。" h' Q8 o  g6 X3 w
//注意:只使用这个调试! !当呼应,这占用了宝贵的资源,可以影响4 Q  A7 Y9 R6 z% C
//性能。如果正常运行所需的绝对,串行写入缓冲器应该大大增加
6 c  M- _0 U+ r" ~; ?3 m9 L//帮助最小化传输等系列内写协议。
( y0 ?! W& d2 m; a  n, j! k. _0 y" y5 b% h  p6 S% q
// #define REPORT_ECHO_LINE_RECEIVED // Default disabled. Uncomment to enable.
) T4 b  ~/ J6 \5 A3 g
  T& x' ?: O! p1 M% y// Minimum planner junction speed. Sets the default minimum junction speed the planner plans to at
4 A  j+ R) d6 i' u& {// every buffer block junction, except for starting from rest and end of the buffer, which are always
4 O8 `- B! I: i2 m3 O  s/ d+ X5 B- Z4 ?// zero. This value controls how fast the machine moves through junctions with no regard for acceleration6 T/ L& l* L& }: G! j, ^# O0 r& w" o
// limits or angle between neighboring block line move directions. This is useful for machines that can't
4 _# O% p9 v5 `; [// tolerate the tool dwelling for a split second, i.e. 3d printers or laser cutters. If used, this value! \( y8 p1 E- [. m6 z
// should not be much greater than zero or to the minimum value necessary for the machine to work.
% N9 B% ]; v+ V* x0 q! D/ T8 y9 Z9 x, h! [& J7 P- t4 C$ f* W
//最小规划师结速度。设置默认最小连接速度规划计划' G# N6 Y# w2 E3 u
//每一个缓冲块接头,除了从结束休息和缓冲区,它总是; b$ m  J; W4 \$ m5 d: V  |
// 0。这个值控制机器的速度穿过路口,没有考虑加速度
6 b0 s& [: l4 W/ b) I$ Y6 M//限制或相邻块之间的角线方向移动。这是有用的机器,不能, \1 o: `1 ~- F, N6 E2 |$ G
//容忍工具居住某一刹那,即3 d打印机或激光切割机。如果使用这个值
9 ?; z0 }; b0 U" C! }//不应大于零或机器工作所需的最小值。; W" Q6 L9 V* y
; k& p: ^1 S! K' J; @- T9 G
#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min)9 @/ C. E# O. ^

" w4 ~% H9 O1 M" P// Sets the minimum feed rate the planner will allow. Any value below it will be set to this minimum
% ?) u" @7 t1 e* p; C" |// value. This also ensures that a planned motion always completes and accounts for any floating-point" X$ v3 `" @- |
// round-off errors. Although not recommended, a lower value than 1.0 mm/min will likely work in smaller$ Z7 N" L' y5 q+ f* P4 i' }
// machines, perhaps to 0.1mm/min, but your success may vary based on multiple factors.. E: A/ ~, m  l1 I( J
//设置计划将允许的最小进给速率。任何价值低于它将被设置为最低值。这也保证了运动计划总是完成,占任何浮点
3 {2 e& a8 I5 U: ]$ M6 |  Q//舍入错误。虽然不推荐,价值低于1.0毫米/分钟可能会在较小的工作  r4 G* f9 A; c+ q, S0 A' A; W  d
//机器,也许到0.1毫米/分钟,但你的成功基于多种因素可能会有所不同。4 S& x+ v8 ^5 ]' @" l- H; B3 n

, m0 j- i" F" `/ _#define MINIMUM_FEED_RATE 1.0 // (mm/min)//设置计划将允许的最小进给速率
! @/ p6 ~' z9 R' `% O0 [' x- g% d6 A
// Number of arc generation iterations by small angle approximation before exact arc trajectory 6 z4 o1 B/ q% n! R6 b
// correction with expensive sin() and cos() calcualtions. This parameter maybe decreased if there : n1 Y; A, p8 L* n* J2 K5 c3 C
// are issues with the accuracy of the arc generations, or increased if arc execution is getting
0 b  A( T7 L' U3 a" [& f/ ?// bogged down by too many trig calculations. " D. y& O( c. q) L4 o9 C
//弧生成迭代次数之前小角度近似精确的弧线轨迹
5 i% _7 `! j5 m$ s//修正与昂贵的sin()和cos()calcualtions。如果有这个参数可能减少
0 n! E4 u, o+ P1 _) I. f# y* u//与弧一代又一代的准确性问题,或如果电弧执行得到增加
& E  F- {+ ]/ L/ W) {/ U//太多的三角计算的泥潭。
8 e' c  e3 D1 p+ ~( k0 ^0 T6 u' T2 j, \2 ?
#define N_ARC_CORRECTION 12 // Integer (1-255)
, r8 J) Y2 `0 P# q% x, ?0 }- M
9 f9 ?, ^5 R+ r- H// The arc G2/3 g-code standard is problematic by definition. Radius-based arcs have horrible numerical
8 d- y  k; J" o4 M# ^% \// errors when arc at semi-circles(pi) or full-circles(2*pi). Offset-based arcs are much more accurate 5 d7 V$ f1 |3 s1 [: ?
// but still have a problem when arcs are full-circles (2*pi). This define accounts for the floating
3 u& Q! L6 l" H0 N- ~$ K// point issues when offset-based arcs are commanded as full circles, but get interpreted as extremely
$ Q( f/ Z# D& e. L  T2 C// small arcs with around machine epsilon (1.2e-7rad) due to numerical round-off and precision issues.
, t1 a: a% u( r( \. |+ u// This define value sets the machine epsilon cutoff to determine if the arc is a full-circle or not.! L# _* }' W2 u6 @8 t' z: _
// NOTE: Be very careful when adjusting this value. It should always be greater than 1.2e-7 but not too
, J+ t$ G# i  w% m8 l+ m) O& J& e// much greater than this. The default setting should capture most, if not all, full arc error situations.
: i/ u6 W* b( [3 {! b//弧G2/3刀位点的标准定义是有问题的。Radius-based弧有可怕的数值
' D: s, O2 M- ]/ X//错误当电弧在半圆(π)或原点(2 *π)。Offset-based弧更准确' X  S) i) k3 F# a
//但仍有一个问题当弧原点(2 *π)。这个定义占浮动$ i1 f  I3 E( L. \
//当offset-based弧吩咐点问题完整的圆,但解释为极6 Q* l. `( i# |; ~$ F1 {
//小弧机周围ε(1.2 e-7rad)由于数字舍入和精度问题。6 R/ s2 K# n7 d  S8 o- K! i
//定义值设置机器ε截止来确定电弧是一个原点了。
* U" N9 J) A" O+ x3 A* ~//注意:调整这个值时非常小心。它应该总是大于1.2 e -但不要太+ v* w! X& D8 G/ }
//比这大得多。默认设置应该捕获大部分,如果不是全部,全部错误的情况。
: W% ^" Y) f' I. u: ^& I' U$ E. p, |* M% J. F, P
#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians); \- c7 _, [  R, j, `6 Z, i4 S" D
0 S, |# W; C( i4 g: q
// Time delay increments performed during a dwell. The default value is set at 50ms, which provides* I# Q; C/ o6 _8 t' p* |+ p; W
// a maximum time delay of roughly 55 minutes, more than enough for most any application. Increasing
9 O' h; l! d% H, P. N// this delay will increase the maximum dwell time linearly, but also reduces the responsiveness of
3 ]! s8 c- v, v// run-time command executions, like status reports, since these are performed between each dwell
; ^, v7 v6 w/ v1 h: l1 H, N  J// time step. Also, keep in mind that the Arduino delay timer is not very accurate for long delays.6 Q  x6 b, T- B; I& J- z
//延时增加表现在住。默认值设置为50毫秒,它提供了7 y6 Z5 t: S2 a. W% D, X- c
//最大延时约55分钟,足够对大多数任何应用程序。增加* V( f8 e/ `' y$ W& k8 M
//这种延迟将增加线性最大停留时间,也减少了响应能力
9 u( F9 D$ \  d/ H3 }5 _" x7 D//运行命令执行状态报告一样,因为这些每个住之间执行
# |# [! c4 [  A, u% a! R  y% |//时间步。还有,记住,Arduino延迟计时器不是很准确的长时间延误。
/ K1 o# F1 p* R9 @5 \' a
$ @8 F5 n( H1 r7 N8 p  L& \: _#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds)
1 I0 h: B# m- U6 N/ |
' q& z( g/ r6 d0 h// Creates a delay between the direction pin setting and corresponding step pulse by creating/ B  D' `1 h2 R( D# g* X1 U
// another interrupt (Timer2 compare) to manage it. The main Grbl interrupt (Timer1 compare) 8 K! j# Z4 @6 G8 L# R
// sets the direction pins, and does not immediately set the stepper pins, as it would in
1 \% ]% E  h& S// normal operation. The Timer2 compare fires next to set the stepper pins after the step 2 q1 C( g& J' F! E& s
// pulse delay time, and Timer2 overflow will complete the step pulse, except now delayed
$ W" b2 @7 H' @+ t( K// by the step pulse time plus the step pulse delay. (Thanks langwadt for the idea!)% g: n  G) ^& W# J3 q
// NOTE: Uncomment to enable. The recommended delay must be > 3us, and, when added with the! h; ~. t: N! I/ Q
// user-supplied step pulse time, the total time must not exceed 127us. Reported successful
% C4 D* o9 f: T6 v// values for certain setups have ranged from 5 to 20us.
$ E2 Z1 D# i; m  a6 p' V//创建一个方向销之间的延迟脉冲通过创建设置和相应的步骤
: Y7 ^% H; O& o* H$ t9 b, p//另一个中断(Timer2比较)来管理它。主要Grbl中断(Timer1比较)
6 b! k1 |! B1 {1 M7 S//设置方向针,不立即设置步进针,因为它会在' r  f, j8 J5 j! P, I. o
//正常操作。Timer2比较火旁边设置步进针后一步. ?# |( F& m+ j+ m& f, x
//脉冲延迟时间,Timer2溢出脉冲将完成的步骤,现在延迟除外
% t* \7 u4 `+ W! Z) V//脉冲时间加上的一步一步脉冲延迟。(感谢langwadt主意!)
8 R, [2 ^' Z8 I& C//注意:取消启用。必须> 3,建议延迟,当添加的" s5 F8 F0 K, h3 M( y# ]
//用户提供的步骤脉冲时间,总时间不得超过127美元。成功的报道
" \( ]: M. W2 J5 U, V& k4 M//值对某些设置范围从5到20。
9 \% G0 y# Y9 ]2 F% f7 `* ?! l# S3 H8 G3 u
// #define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled./ I! a: o2 K8 }9 {. \. p4 B

( n4 \4 ]8 v1 q  e) `/ {// The number of linear motions in the planner buffer to be planned at any give time. The vast
) q3 l8 O6 D, r. Q, b; l, R// majority of RAM that Grbl uses is based on this buffer size. Only increase if there is extra
" m! O" t' z; ~( c/ f* C- H// available RAM, like when re-compiling for a Mega or Sanguino. Or decrease if the Arduino* L+ J1 I& a, z1 |) O9 v" \3 b+ ^
// begins to crash due to the lack of available RAM or if the CPU is having trouble keeping, T& D$ r( F3 s0 {" ]0 o
// up with planning new incoming motions as they are executed. ' j2 X. p4 {7 N& U& N9 T$ ]
//线性运动规划师缓冲区的数量在任何给出时间计划。绝大
5 I3 H6 x% F! k. E% S( J; }# T+ u//多数RAM Grbl使用基于这个缓冲区的大小。如果有额外的只会增加& a+ f' ]; E. g5 C0 Y5 q, D$ h
//可用内存,比如当基于大型或Sanguino。如果Arduino或减少
' T7 b+ S! t+ P5 b//开始崩溃由于缺乏可用的RAM或者CPU是难以保持
. y4 I1 m/ f- j' q& H# \//与规划新传入的动作执行。& m1 v4 b5 Q: c
% ?. _( R5 z$ c( o7 F
// #define BLOCK_BUFFER_SIZE 18  // Uncomment to override default in planner.h.9 j; a; j  D( I6 m) [
' P5 o5 @& l& z6 r' V
// Governs the size of the intermediary step segment buffer between the step execution algorithm
4 ?0 X6 w- y& p: o" k- h// and the planner blocks. Each segment is set of steps executed at a constant velocity over a  P( t' C3 W9 w2 k/ G' o
// fixed time defined by ACCELERATION_TICKS_PER_SECOND. They are computed such that the planner, s. p4 T) v; E4 m
// block velocity profile is traced exactly. The size of this buffer governs how much step & I3 u3 e1 ]5 h& ]3 L% ^
// execution lead time there is for other Grbl processes have to compute and do their thing
! q* h: k8 L' o+ L; n// before having to come back and refill this buffer, currently at ~50msec of step moves." r4 H8 K- V3 y  S$ [% Z
//控制之间的中间段缓冲大小的步骤执行算法6 T6 G! @' N7 e8 q4 q0 F
//和规划师块。每一部分的步骤执行在一个恒定的速度
$ ?8 E2 U5 y! d, y9 [6 Y+ b//固定的时间由ACCELERATION_TICKS_PER_SECOND定义的。他们计算的计划
2 q* i9 C) n# m//块速度剖面追踪到底。这个缓冲区的大小控制多少步骤# c3 P! J; W1 B- X4 e5 g+ d% |
//执行时间有其他Grbl过程需要计算和做他们的事情5 W' x0 y1 x, g6 U4 T4 @
//之前必须回来重新填充这个缓冲区,目前移动~ 50毫秒的一步。
* b! R. E" s. S! f9 G! h
$ z. ^" \. R2 t// #define SEGMENT_BUFFER_SIZE 6 // Uncomment to override default in stepper.h.
$ Q: `9 G) I7 G- d4 \+ X! N5 u$ F1 [  y7 E# k
// Line buffer size from the serial input stream to be executed. Also, governs the size of ) p3 }3 x7 p9 o
// each of the startup blocks, as they are each stored as a string of this size. Make sure- r. [  u7 @* N
// to account for the available EEPROM at the defined memory address in settings.h and for
6 R3 v2 T9 f! a  t+ e// the number of desired startup blocks.
$ S: N( ~: R4 n4 K% G7 v2 u1 ~// NOTE: 80 characters is not a problem except for extreme cases, but the line buffer size " Z+ o! j7 A; X) j
// can be too small and g-code blocks can get truncated. Officially, the g-code standards 1 J& b+ w  a4 ^: x" C2 G( N
// support up to 256 characters. In future versions, this default will be increased, when
0 |. v& P3 D$ n' G( \( I// we know how much extra memory space we can re-invest into this.
% M# Q7 L; }3 ^9 a! k9 g/ k4 I; `8 z//行执行串行输入流的缓冲区大小。同时,大小的控制
) E( y' \% ~4 T% u//每个启动模块,它们分别存储为字符串的大小。确保
" {3 q1 o" `- y4 ?, ?//占可用eepm定义内存地址的设置。h和1 U. i& U& a: u, L. }5 l0 G3 X# k$ D; w
//需要启动块的数量。+ X* }& a+ F1 V' [
//注意:80个字符不是一个问题,除了极端的情况下,但线缓冲区大小
, {. Y& V3 @  ]  m) f8 R//可以太小和刀位点块可以截断。正式,刀位点标准
; A5 f; _) Y! U+ v( m% X! Q- q//支持多达256个字符。在未来的版本中,这个违约将会增加,当6 c( i8 s9 I' v" f% O
//我们知道多少额外内存空间的时候我们可以再投资。# ^$ N" F( [9 ]$ {! n. D
4 S# E8 W$ x6 `7 _8 e. r" m9 u0 n
// #define LINE_BUFFER_SIZE 80  // Uncomment to override default in protocol.h
- F' T+ Z( i) @. P8 S- f  |' [( N( L  
6 M5 M4 s* O; m" Y" v// Serial send and receive buffer size. The receive buffer is often used as another streaming& V# a- t2 I3 v4 X
// buffer to store incoming blocks to be processed by Grbl when its ready. Most streaming( |$ [, d- B& d% @1 \& v+ \
// interfaces will character count and track each block send to each block response. So,
: `8 Y1 K: b+ y% m& I// increase the receive buffer if a deeper receive buffer is needed for streaming and avaiable
+ ]8 F9 k" V5 \( c2 Z// memory allows. The send buffer primarily handles messages in Grbl. Only increase if large  g) T+ h. ]6 h8 q; p
// messages are sent and Grbl begins to stall, waiting to send the rest of the message.: V; ^* ]- B' p4 y
// NOTE: Buffer size values must be greater than zero and less than 256.: t: [' O( m& U5 n' x- @  j
// #define RX_BUFFER_SIZE 128 // Uncomment to override defaults in serial.h
3 R) e4 _' K% C$ c9 k' l$ R& s//串行发送和接收缓冲区大小。接收缓冲区通常用作另一个流  y- M0 c+ z% z! ?/ ?
//缓冲存储传入的块来处理Grbl当它准备好了。最流" ?  A6 y' x+ ]/ X. u8 x
//接口将字符计数和跟踪每一块发送给每个块的回应。所以,
4 F5 q7 Z# ~: M  X. J- B9 R//增加接收缓冲区如果需要更深层次的接收缓冲区为流,、: P+ W  M; ^0 i* k2 K) X
//内存允许。Grbl发送缓冲主要处理消息。只会增加如果大
- W! D5 v4 \; c8 ?  L: B//消息发送和Grbl开始停滞,等待发送其余的消息。. h* _  m( Q6 X( d6 A) f4 w# J
//注意:缓冲区大小值必须大于零,小于256。, K& d9 _2 O' S7 h& U/ \9 J" x$ j
// # define RX_BUFFER_SIZE 128 / /取消serial.h覆盖默认值5 s3 D. Y& ^) h- t, p% K* M
$ h8 |( Y# u1 J8 J, n
' `+ w2 S% p3 v# K6 V+ C- J
// #define TX_BUFFER_SIZE 64
: y" u* d' J/ r% r' h' a7 c% W  
, Q; F% l* }0 O& [, f// Toggles XON/XOFF software flow control for serial communications. Not officially supported" q) G  M0 T. l; k! r* A
// due to problems involving the Atmega8U2 USB-to-serial chips on current Arduinos. The firmware8 B) M+ _6 @9 P* _3 K; R
// on these chips do not support XON/XOFF flow control characters and the intermediate buffer
; j* e! V3 {0 l" R0 v$ N- v) [// in the chips cause latency and overflow problems with standard terminal programs. However,
1 g5 z' t& ]+ t7 v% G" R+ s// using specifically-programmed UI's to manage this latency problem has been confirmed to work.& y9 ^5 B( S9 g, }* x: Q
// As well as, older FTDI FT232RL-based Arduinos(Duemilanove) are known to work with standard- ^1 N6 o2 Q4 K
// terminal programs since their firmware correctly manage these XON/XOFF characters. In any1 p. W6 g: X4 n, t
// case, please report any successes to grbl administrators!# Z$ Q( m& a/ p& W8 {- N& c
//切换为串行通信发送朴通/发送葡开软件流控制。不是官方支持0 ~6 p: M* j6 Z) Y+ ^* x2 G
//由于问题涉及Atmega8U2 USB-to-serial当前arduino芯片。固件" f7 i$ o0 v7 q: o# q
//在这些芯片不支持发送朴通/发送葡开流控制字符和中间缓冲区
/ A& F3 q% x* n( U9 f3 J//芯片导致延迟和溢出问题的标准终端程序。然而,
: P. i1 g- r% x( l9 k" h" ^( v//使用specifically-programmed UI的管理这个延迟问题已经确认工作。# F- ~8 k7 l/ ~1 P' q* S* U' s! n$ @" w
//以及老FTDI FT232RL-based arduino(Duemilanove)是已知的标准
) x5 y: i3 M. g( R$ J' e7 b//终端程序因为他们正确的固件管理这些发送朴通/发送葡开的角色。在任何
/ `8 g% P% b8 o. D7 T//情况,请报告任何成功grbl管理员!' w( e: ^) j  Q, A: @$ G
8 ~  A/ o/ u% L6 s! o
// #define ENABLE_XONXOFF // Default disabled. Uncomment to enable.  b) f- a6 P. N" ^/ c
* F: V4 p5 E) g6 W& a. z) Z
// A simple software debouncing feature for hard limit switches. When enabled, the interrupt
* w& Q( S( @5 E; i3 R6 ^// monitoring the hard limit switch pins will enable the Arduino's watchdog timer to re-check & F7 A! Q; `$ L1 L
// the limit pin state after a delay of about 32msec. This can help with CNC machines with % Z) d0 `5 S) G/ O8 a
// problematic false triggering of their hard limit switches, but it WILL NOT fix issues with 2 q4 E5 H, w: K8 p
// electrical interference on the signal cables from external sources. It's recommended to first- C' k1 r% }; v) e% ]' F
// use shielded signal cables with their shielding connected to ground (old USB/computer cables 9 J( g) ^1 e4 Q1 a$ A
// work well and are cheap to find) and wire in a low-pass circuit into each limit pin." G7 l9 ^; e/ k0 Y  H/ {" Y4 k* I. g
//一个简单的软件消除抖动特性硬限位开关。当启用时,中断$ R6 D; l# }, `% H# f
//监控硬限位开关针将使Arduino的看门狗定时器重新审视$ m& v9 t/ \, |( Y. L
//销的极限状态后约32毫秒的延迟。这可以帮助与数控机器
& M, T4 @/ @6 t8 o: t0 k//问题错误引发的硬限位开关,但是它不会解决问题3 B& d. G" ^+ N4 `! o* g# O
//电干扰信号电缆从外部来源。首先它的建议$ {7 p" |: X9 G( R
//使用屏蔽信号电缆的屏蔽连接到地面(老USB /计算机电缆0 t& e1 o1 L  _: b7 C* f2 |3 J' K
//工作得很好,很便宜)和线低通电路到每个限位销。
, E2 @' l, C% v3 H: a; h& j8 s6 b* g3 \6 k6 E
// #define ENABLE_SOFTWARE_DEBOUNCE // Default disabled. Uncomment to enable.
7 p( M+ B- s2 Z; p8 s
  \2 |9 d+ a/ ^5 K, R  g, p// Force Grbl to check the state of the hard limit switches when the processor detects a pin4 Q! \7 P1 |, l& l
// change inside the hard limit ISR routine. By default, Grbl will trigger the hard limits9 S: ]' x6 n$ E. w. ]! G
// alarm upon any pin change, since bouncing switches can cause a state check like this to 4 ~. ^8 a0 Y2 N* i7 Q* `
// misread the pin. When hard limits are triggered, they should be 100% reliable, which is the
" u* F8 Z- s1 o1 O// reason that this option is disabled by default. Only if your system/electronics can guarantee
8 I9 T2 Z4 [  Q5 f9 {// that the switches don't bounce, we recommend enabling this option. This will help prevent
* X9 \; {) C5 J6 Y// triggering a hard limit when the machine disengages from the switch.9 ~$ x! ~/ p$ }- e' i6 d
// NOTE: This option has no effect if SOFTWARE_DEBOUNCE is enabled.- Q: g% N$ H' {
//力Grbl检查硬限位开关的状态,当处理器检测到一个销
% W* |0 p+ a' f' c# V; f1 g//改变内部硬限制ISR例行公事。默认情况下,Grbl将触发硬限制1 b3 f5 O; o! N
//报警在任何销更改,因为跳开关可以导致这样的状态检查
8 M4 Q' v( G+ i/ F5 Y//误读了销。硬限制触发时,他们应该100%可靠,这是/ r' \) T2 T7 j0 x2 h9 c
//原因,这个选项默认是禁用的。只有在你的系统/电子产品可以保证6 Q' p2 Q0 Y( C7 W- r' Z5 D" j. ~
//开关不反弹,我们建议启用这个选项。这将有助于防止9 n# g4 h, L$ ^
//触发机退出时硬限制开关。# s4 T( a+ u+ ?# V- J* J
//注意:这个选项如果启用了SOFTWARE_DEBOUNCE没有影响。
; I) J, l# x6 X: a; f. O) e$ a/ H+ c- j
// #define HARD_LIMIT_FORCE_STATE_CHECK // Default disabled. Uncomment to enable.- o( O6 x: K4 I: {5 J+ ~

/ j2 U4 h* Q; g& \4 Y# y8 \
: H3 g& J9 g% {& u6 _' u// ---------------------------------------------------------------------------------------
6 J; W$ i6 U+ d, i// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:编译时错误检查的定义值:6 F; E/ t4 N! H8 P; T( a. F* _0 z! F
1 K1 u4 {/ G$ Z$ @0 g. U! H
#ifndef HOMING_CYCLE_0: e/ C0 h" N* f" j) }
  #error "Required HOMING_CYCLE_0 not defined."
$ E8 u; I! M2 K6 a#endif) N0 ^2 m1 Y; w

* T  e. N+ Y- a- S#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(VARIABLE_SPINDLE)1 D# E0 ?5 g: K7 g
  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with VARIABLE_SPINDLE enabled"9 O7 x$ W# o1 r& H* m% k
#endif  t. |: p6 r% q5 Y' Q9 j; I5 E

  t3 F% j; s% e" w( V, y#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(CPU_MAP_ATMEGA328P)9 v: g! L% \! f7 ]; }
  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with a 328p processor"- ^# q. f# Y8 i* M) }- S0 Q
#endif  K% k4 M4 ?" H/ W# u$ S9 G

2 ]/ u5 r9 h! w5 d& s  H* F4 M: u( W% @// ---------------------------------------------------------------------------------------
, W' `6 X* R9 R/ }5 n. T
- k! G) k" m( E! g3 g
% ]3 X9 C# j& I) V( H4 G# J( ~9 h#endif# U! Z8 \5 P3 a/ b% Z
; T. L  X4 [5 I! l: \4 F

  X8 M2 `: _0 m3 M! J/ P% L5 D. q* w' G# {* B
8 d' F% |+ M, ~' W& Z' O% l' ?

- n$ J- j. H+ |4 [3 t6 A! r6 ]' B, n# a; d" ^7 G+ ~8 s. ]

4 l; H  M5 n. G9 j4 c- _  M, j7 [: e5 f9 y& q- h
* k) I4 J$ c6 g$ B

5 e* x; j+ f$ o2 ~9 a. N% i) l2 M3 x& q) ]  b, S8 I# ^/ p/ M. J# K; a
7 ^0 t4 r1 X6 ~* `: V

1 @+ r( k" e5 I* K. ?( a0 G; q* n

4 B2 h+ V" i$ b$ N8 b& }* }( J. ?! j4 t- Z& f% Q" o# T

本帖子中包含更多资源

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

×

评分

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

查看全部评分

回复

使用道具 举报

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

2 j7 {- @# _  l  P' X
发表于 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 | 显示全部楼层
补充* U; _6 N5 y9 y) H
程序运行protocol_execute_realtime(); /运行实时命令。% \2 S4 y8 Z# Y5 ~: n" ]! v4 n
// Executes run-time commands, when required. This is called from various check points in the main
; J& H4 u& a1 O) f: L* O( e// program, primarily where there may be a while loop waiting for a buffer to clear space or any
  p' v2 T* }, [// point where the execution time from the last check point may be more than a fraction of a second.
0 f0 a: Z# I6 P3 R// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code
& ?- C. b8 C, w6 A( L// parsing and planning functions. This function also serves as an interface for the interrupts to
2 w! t1 B, V$ \; E( r# }: ^// set the system realtime flags, where only the main program handles them, removing the need to
3 |5 x: y) H% O! k: V// define more computationally-expensive volatile variables. This also provides a controlled way to : k+ z3 J2 {" n4 l
// execute certain tasks without having two or more instances of the same task, such as the planner8 D* d( C/ M2 ]/ c$ X
// recalculating the buffer upon a feedhold or override.
/ f/ Z9 e5 y) x) ~5 j5 Z// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,0 V5 [) M' F! B) H( z" a
// limit switches, or the main program.# I9 c) ?0 M, I* K  N' u6 N

5 C! u* E9 f" H; d. Y- G//执行运行时间命令,在需要时。这就是所谓的从各种主程序要检查站: r( P, b. @" }9 K% X$ F
//,主要是那里可能是一个while循环等待缓冲区空间或任何
9 U# i% x5 |. Q- p, q//执行时间从过去的止点可以超过几分之一秒。
7 `5 g' M+ c8 C9 z//这是一种异步执行实时命令(又名多任务)grbl的刀位点
+ I& [1 r6 ^; V3 G5 i, g//解析和规划功能。这个函数也可以作为一个接口,用于中断
2 _! f+ M( g, T0 S. y//设置系统实时的旗帜,只有主程序处理,消除的需要
( U) k( c. U6 c//定义更多的计算昂贵volatile变量。这也提供了一种控制方法% e! w" M' _# r: T' W
//执行某些任务不相同的两个或多个实例的任务,比如计划
) \8 a' x; l! r5 H# w//重新计算缓冲feedhold或覆盖。
4 n: v4 w( }9 `//注意:sys_rt_exec_state变量标志设置任何过程,步骤或串行中断,插脚引线,4 I. s. M# n7 r% r$ e6 E2 Z
//限位开关或主程序。
" \: z" x1 t2 c& G, cvoid protocol_execute_realtime()& n- [- R& `8 M9 u, s' X
{3 h3 g2 i+ W; T2 E
        // Temp variable to avoid calling volatile multiple times.5 l" U$ ?) V0 Z% N& `" b  Y  r% S
        // 临时变量来避免多次调用不稳定。
5 J+ q5 R$ v" o  H0 H% P  @) T: F5 S        uint8_t rt_exec;
& U! l+ A: F0 B3 E$ G0 M" k! V        do{0 q5 N9 l5 |6 m$ M$ F3 \
          if (rt_exec) {                 // 有标志位置位进入
4 I/ ^8 g* V/ Y8 t0 s2 O5 v       
4 A6 h" ?8 E3 b, _- L3 N            sys.state = STATE_ALARM; // 设置系统为报警状态# x/ N9 g2 x. N7 ^7 Y( r
      report_alarm_message(ALARM_HARD_LIMIT_ERROR);        //报告报警信息为接近极限值, d  U0 U( R7 y& a' r: _$ N
    } else if (rt_exec & EXEC_ALARM_SOFT_LIMIT) {                        //报告执行软件限位报警
1 g# s7 k& q8 m# r1 c+ e: m( T6 f  H      report_alarm_message(ALARM_SOFT_LIMIT_ERROR);        //报告出现软件限位报警; d, C7 a2 x& @- f
    } else if (rt_exec & EXEC_ALARM_ABORT_CYCLE) {                //执行停止循环报警      
0 l9 X$ s, d: ]2 r  ~, j      report_alarm_message(ALARM_ABORT_CYCLE);                //出现终止循环报警" ?9 }( d. _! G
    } else if (rt_exec & EXEC_ALARM_PROBE_FAIL) {                        //执行探查失败报警. A' ]: F; ]1 C' f. [" O
      report_alarm_message(ALARM_PROBE_FAIL);                        //出现探查失败报警
: z- R, F5 e! T$ o( E3 n    } else if (rt_exec & EXEC_ALARM_HOMING_FAIL) {                //执行返回原点失败报警
4 ]3 M+ ^, m+ r( d7 o      report_alarm_message(ALARM_HOMING_FAIL);                //出现返回原点失败报警1 `5 G5 Z. I7 A
    }) g( g" |8 y- \* F- p
6 }7 ?9 C7 U$ m7 @9 _9 P
    // Halt everything upon a critical event flag. Currently hard and soft limits flag this.
' E% a6 c/ u$ K: U# p. f9 }    // 停止一切在一个关键事件标志。目前硬和软限制标志
& L' x9 H( [/ N# r% u2 H* d6 R           if (rt_exec & EXEC_CRITICAL_EVENT) {                //如果系统是循环事件进入( b; Y5 E8 K; K, P: q0 h6 w
             report_feedback_message(MESSAGE_CRITICAL_EVENT);        //报告反馈信息; l# Z2 Z! `9 N
              bit_false_atomic(sys_rt_exec_state,EXEC_RESET);                         //清除目前的复位状态# `+ S6 p: \) X- C
+ J* _3 B  U1 o) Z$ g0 T
        bit_false_atomic(sys_rt_exec_alarm,0xFF);                                 // 清除所有报警标志
5 Y) x0 @8 ^5 [, ^# f: A; I        }       
8 C2 M( V1 z- m$ S' \1 `
" h* I$ `& j1 }& g1 Y上面代码将rt_exec = sys_rt_exec_alarm ,如果rt_exec为真,打印不同报警信息% P5 h! x- v- }. M/ y
和限位保护信息,然后清除报警状态
+ ~- M$ ?+ N1 Y' l" p1 u2 g" c$ R___________________________________________________________________________
  s3 _+ d: z. i& Q没有报警进行执行下面代码,执行了终止命令,串口打印命令
. L/ t/ ?$ |. ]9 ?/ Z* D, H         // Check amd execute realtime commands        校验和执行实时命令
8 Z% K; w' X. O+ z2 X7 o5 f          rt_exec = sys_rt_exec_state; // Copy volatile sys_rt_exec_state
( ^  |( w* \% M1 d0 |2 D6 m1 g* J; o3 e
        if (rt_exec) { // 输入标志是正确的执行% E+ n' N2 P3 y. b2 e% I& S
& R& u1 u; o, L4 X
            // Execute system abort. 执行系统终止命令
4 d( N3 j) r% g' }            if (rt_exec & EXEC_RESET) {
( j+ B( Q! m! A' X              sys.abort = true;  // Only place this is set true.- Z7 ]4 C7 W1 d$ m
              return; // Nothing else to do but exit.& ?: F5 a" N& E' p
        }
% s/ T2 c+ l2 I# |1 X
5 O0 t" k' O7 Z0 ?9 T/ O            // Execute and serial print status 执行和串口打印状态
% L$ v; u, e0 F* Y. I6 s. o            if (rt_exec & EXEC_STATUS_REPORT) { 8 f8 t3 N- d- V! S3 s
              report_realtime_status();        //报告实时状态  F. _! H6 h% U0 z* y" G% T
              bit_false_atomic(sys_rt_exec_state,EXEC_STATUS_REPORT);        //清除报告状态清零! @$ y  b/ `3 J( \4 q" k0 m; u
            }. H/ u/ }( S; [% |( _+ d
_____________________________________________________________________________
- ~" X& l' P! M; D, t下面代码
8 a1 a$ r6 |  ~( H% Z' e//执行状态。+ n9 B% a0 z! y& {. I
//注意:所涉及的数学计算持有应该足够低对大多数人来说,即使不是全部,  e$ I1 ~+ k- G
//操作场景。一旦启动,系统进入暂停状态# U& \4 K& W8 ^: h: `/ P3 I5 {
//主程序流程,直到重置或恢复。0 N& H: {- z, l/ o! \" l5 t
待办事项:检查模式?如何处理呢?可能没有,因为它只会在空闲,然后重置Grbl。/ K: |* _( {) i) p  Z" |9 w
状态检查容许状态的方法。, Y3 J$ y6 _8 R7 e( r
* Y5 ^8 \8 p  H4 D& V
        //如果全局各自报警标志位其中(执行取消动作) | (执行进给保持) | (执行安全门)任意一位为真进入- x1 d6 N- m9 b) v
            if (rt_exec & (EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR)) {       
9 ?9 K/ Q  Q5 J" L3 Y/ l
- W, L7 T) U- k7 {) T7 e        //如果是循环状态执行暂停状态9 u" b4 W8 L2 u. G  D5 F
        if (sys.state == STATE_CYCLE) {
, \1 B# {6 @; p1 Y! x1 i: h% o        st_update_plan_block_parameters(); //通知stepper module验算减速。! @' O9 [) o: ]; z
        sys.suspend = SUSPEND_ENABLE_HOLD; // 开始暂停标志. t' K7 E. [2 H" h' i
        }
8 ?4 [% T) o7 P' Y" Z+ k. {  C# g" |
        // 如果,Grbl空闲不在运动。简单的指示暂停就绪状态。
* f; M( S6 E+ d4 ?3 l        if (sys.state == STATE_IDLE) { sys.suspend = SUSPEND_ENABLE_READY; }7 v8 J. c9 Q, w' k
- V- G* ]  D( E4 R  h0 |
: [! m* g& U1 a
        //执行和标志和减速运动取消并返回空闲。主要由探测使用周期
3 Y' t0 l: ~" T        //停止和取消剩余的运动。       , V* d" {6 p! H) \
        if (rt_exec & EXEC_MOTION_CANCEL) {
' x% U  \6 ?, ^3 e          if (sys.state == STATE_CYCLE) { sys.state = STATE_MOTION_CANCEL; }
' w4 ]! ~( r& _( D8 U          sys.suspend |= SUSPEND_MOTION_CANCEL;
- f( I: E5 T/ _6 |# K7 o8 N        }
  a- ~! p+ u  C
% g& |6 i/ s9 F, L& w        // 只在循环时执行进给保持减速  e# ^- j0 d8 e. r# d
         if (rt_exec & EXEC_FEED_HOLD) {
: V2 Y. I$ H/ t" H        //只有安全门为1才执行保持进给状态赋值8 ?" v, O3 E3 {6 i  N7 p+ P
          if (bit_isfalse(sys.state,STATE_SAFETY_DOOR)) { sys.state = STATE_HOLD; }- o  \  ?* s* [- ^
        }
0 H' U8 T' i- C+ R. {
. B3 V/ j8 c' u* Z5 V: T        if (rt_exec & EXEC_SAFETY_DOOR) {2 K  y6 L6 Q7 u; Y3 H
          report_feedback_message(MESSAGE_SAFETY_DOOR_AJAR); + a" P5 E' x, r1 G3 [5 G# C
/ /如果已经活跃,准备好重新开始,CYCLE_STOP标志设置为强制断开。7 V. b6 q5 n, z% x
/ /注意:只是暂时设置“rt_exec”变量,不是动荡的“rt_exec_state”变量。
" ]$ n& c* f& p" E          if (sys.suspend & SUSPEND_ENABLE_READY) { bit_true(rt_exec,EXEC_CYCLE_STOP); }
0 r* T. F+ v  A1 ~5 [          sys.suspend |= SUSPEND_ENERGIZE;
4 \) F' b- s2 n# a8 V4 {6 [          sys.state = STATE_SAFETY_DOOR;
3 y1 N: J! x# w; P9 p7 G        }+ e% X' O" e/ Y) G1 h

/ [0 E  f+ O8 I( S6 @  Bbit_false_atomic(sys_rt_exec_state,(EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR));    % z  ]) z% g; X% ^" e

3 E& q7 i( j- E# [! r}
5 t9 h7 R3 \$ g: j3 j0 R1 w5 J: n以上代码执行了
) `5 E) P3 q7 B1.如果全局各自报警标志位其中(执行取消动作) | (执行进给保持) | (执行安全门)任意一位为真进入
: q9 m4 v0 e' c( B5 m, \1 Y4 S2.系统为闲着状态, 开始循环状态, 回原点状态, 控制取消状态, 开始保持状态, 开始安全门状态时进入0 `# b2 i- F. u% w: V6 [
3.如果是循环状态执行暂停状态* D- P' b% r6 N5 B/ `) r* Y
4.如果系统闲置状态执行暂停就绪状态
4 J" J1 X. w" L6 t1 W5.执行动作取消
. V- U7 U2 m% D; E6.如果是保持进给状态,执行保持进给状态. i( Q4 K0 p$ Z
7.执行安全门状态
! ?4 J7 y2 B! u% D5 p% D  V* O最后执行bit_false_atomic清标志清除(执行取消动作)(执行进给保持)(执行安全门)标志位                 
5 h& w0 f. y, @. Y# K; P_____________________________________________________________________________
" J" T% ~5 u* o9 d$ {  g! u  |' C0 w  n& u* w# o) F' w; ~
    // Execute a cycle start by starting the stepper interrupt to begin executing the blocks in queue.( O0 g! @& z! t
    // 执行一个循环开始启动步进开始执行中断队列的街区
9 f8 d; K, j8 l" }    if (rt_exec & EXEC_CYCLE_START) {        //循环开始状态进入
7 s- E2 ^8 ^5 f: u; c      // Block if called at same time as the hold commands: feed hold, motion cancel, and safety door.7 K) s8 n4 J  F  b3 x
      // Ensures auto-cycle-start doesn't resume a hold without an explicit user-input.
5 ]; D5 p2 \% {- z. o" \          //块如果在同时举行的命令:保持进给,运动取消,和安全的门。 //确保auto-cycle-start没有简历没有显式的用户输入。# p3 C; z% i: [) |
           - w& S: t5 i. n! s
      if (!(rt_exec & (EXEC_FEED_HOLD | EXEC_MOTION_CANCEL | EXEC_SAFETY_DOOR))) {   //状态机如果不是保持进给,运动取消,和安全的门。
6 o6 a6 T: g) j        // Cycle start only when IDLE or when a hold is complete and ready to resume.
' M5 C4 I( u; s( M! |        // NOTE: SAFETY_DOOR is implicitly blocked. It reverts to HOLD when the door is closed.& h, k1 R( n1 H
                //循环开始时只有当闲置或持有完成并准备简历。
# j; }1 J+ Q# B9 }5 O                //注意:SAFETY_DOOR是隐式地屏蔽。它返回的时候门是关闭的。   
' @1 |8 M- B! Y9 |' O8 O& ^/ i6 R; G' w  k: X) _7 ]1 w0 Y' G
                // 如果系统状态为闲着状态,系统状态为开始进给或运动取消,暂停标志为位重新开始  A" u' D) g% a) Q5 ?- F
        if ((sys.state == STATE_IDLE) || ((sys.state & (STATE_HOLD | STATE_MOTION_CANCEL)) && (sys.suspend & SUSPEND_ENABLE_READY))) {
* ~7 x" X1 J$ ?1 W9 [* E; n          // Re-energize powered components, if disabled by SAFETY_DOOR.$ y% S& R9 y3 L3 \. Z- u. Q( W
          //        由SAFETY_DOOR重振组件供电,如果禁用。# R& w; C0 q0 H
          if (sys.suspend & SUSPEND_ENERGIZE) { : \) P" d# c; b/ ~& h
            // Delayed Tasks: Restart spindle and coolant, delay to power-up, then resume cycle.
: [0 K2 C( I$ q$ o. _* M0 j            //延迟任务:重新启动主轴和冷却剂,延迟升高,然后恢复周期。
1 m  }3 x# B* f! [            if (gc_state.modal.spindle != SPINDLE_DISABLE) {   //主轴模式不是失能进入% i" J! U: b- U- w; Q& G
              spindle_set_state(gc_state.modal.spindle, gc_state.spindle_speed); //设置状态和速度- p" z: y: M7 I8 v
              //待办事项:阻塞函数调用。最终需要一个非阻塞。
( B. y5 ?% A* x* b: j                delay_ms(SAFETY_DOOR_SPINDLE_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.  a8 Y: x" \2 y" P! S
            }
+ s" h1 _/ _' b            if (gc_state.modal.coolant != COOLANT_DISABLE) { - l$ A7 e6 `! ~7 w/ s
              coolant_set_state(gc_state.modal.coolant);
' `1 }2 I2 F% s4 B0 b              delay_ms(SAFETY_DOOR_COOLANT_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.
1 c) g6 X$ k6 _2 A5 e1 F. O            }
' A8 w' j$ w7 g2 m0 J1 C            // TODO: Install return to pre-park position./ V* V2 m& }6 [8 w
          }
5 K! K$ K  h8 I" |. @6 ?* E______________________________________________________________________________________________________________) J2 o9 P! r* W2 J$ y, I6 h3 X
          // Start cycle only if queued motions exist in planner buffer and the motion is not canceled.
' k6 i0 r; ]( U% h                  
3 _, @, j6 I3 T5 L7 Y                  //只有在队列马达存在规定的缓冲,并且动机没有让取消,才会循环
' A. m4 f' A: R9 {. H+ Z. e                  
. x! q$ a0 q2 j          if (plan_get_current_block() && bit_isfalse(sys.suspend,SUSPEND_MOTION_CANCEL)) {
. v+ D5 w% a/ ~. O$ g            sys.state = STATE_CYCLE;
9 f% n  H2 v' V" T, a' p  t            st_prep_buffer(); // Initialize step segment buffer before beginning cycle.初始化步开始循环之前2 L( s: E' V& r' W
            st_wake_up();+ d( M2 |$ n5 X3 f7 }4 ]* G
          } else { // Otherwise, do nothing. Set and resume IDLE state.否则,什么也不做,设置和复位空闲模式7 K( r6 T! ~& f' h3 u; r' N: D$ T
            sys.state = STATE_IDLE;( K% M& B# z7 E
          }% S+ S/ n; I; J. ^
          sys.suspend = SUSPEND_DISABLE; // Break suspend state.
# Q* i, ]/ T2 M2 ]        }
4 s$ z( \! D9 N/ F; K  P      }   
  S( X- @+ p8 k6 d      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_START);       
+ Z! P. Z: V. y    }  b& Z; M* u5 S, u5 C
0 ?5 F" U+ L0 @
_______________________________________________________________________________________________________$ O# ~/ s6 d& k, a! b
    // Reinitializes the cycle plan and stepper system after a feed hold for a resume. Called by * W' c: Y+ t. ?2 N, G' c
    // realtime command execution in the main program, ensuring that the planner re-plans safely.
5 y! N) [* P8 @9 }0 T7 H    // NOTE: Bresenham algorithm variables are still maintained through both the planner and stepper
1 ?" u/ r3 I5 K    // cycle reinitializations. The stepper path should continue exactly as if nothing has happened.   : H- l/ i+ G  @0 Z! U5 @
    // NOTE: EXEC_CYCLE_STOP is set by the stepper subsystem when a cycle or feed hold completes.- I/ M# ^/ S4 P( @

3 o4 A6 M/ r1 d+ Y        //重新启动后循环计划和步进系统的进给保持简历。通过实时命令执行主程序,确保安全计划重新计划。) c* t1 z5 t3 |6 v
        //注意:画线算法变量仍保持通过规划师和步进
. A8 w' t9 r& f+ L        //循环仅。步进路径应该继续,好像什么都没发生一样。       
$ u, P. L/ h/ B3 z  ~7 }        //注意:EXEC_CYCLE_STOP由步进子系统周期或进给保持时完成。
/ \; j% H& q/ n) n2 I6 `7 Z! N: s; m- F$ y+ y
    if (rt_exec & EXEC_CYCLE_STOP) {                         //如果是循环停止状态进入* _: N3 R! U. y7 N$ R
      if (sys.state & (STATE_HOLD | STATE_SAFETY_DOOR)) {
' ?5 W$ Z& x1 m% M: ]4 }& ~* y        // Hold complete. Set to indicate ready to resume.  Remain in HOLD or DOOR states until user" f1 F6 w) ~; a/ u' N" A0 W
        // has issued a resume command or reset.
0 d$ b/ g9 l& ]) K1 C/ c
- r2 ~4 [2 K( I3 X2 U, E( n2 m                //保存完整。设置为指示准备简历。继续持有或门状态,直到用户
1 M$ W: _  g' U; D                //已发布了一份简历命令或重置。9 c: J- M. P+ k1 A
               
, a9 s0 f5 S8 y: c$ ~        if (sys.suspend & SUSPEND_ENERGIZE) { // De-energize system if safety door has been opened. 如果安全的门已被打开。断开系统" w4 O0 k5 y! d! s
          spindle_stop();( y4 n- c2 {! ?1 v7 q3 p$ g- d
          coolant_stop();# U# p( R/ y) G
          // TODO: Install parking motion here. 安装停车动作。! o) e: f% `# ~
        }
( C* c  S; ~+ e) s% `. o        bit_true(sys.suspend,SUSPEND_ENABLE_READY);, g) \" y, K; n& D; a& P
      } else { // Motion is complete. Includes CYCLE, HOMING, and MOTION_CANCEL states. 电机完成,循环,回原点,,MOTION_CANCEL
& s4 P9 }( C3 N: f        sys.suspend = SUSPEND_DISABLE;
8 j$ U9 V6 G5 M2 Z! I9 |        sys.state = STATE_IDLE;
+ `8 B% r( I' d3 Z/ n3 Z2 I' v8 O3 a      }
5 O9 ?& O6 H' Q; e; w, ~, B: Y      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_STOP);3 ]2 A2 U- ^: x, Z8 H
    }
$ R, y. q% y4 {' ?7 j   
& s! c0 R( x5 F5 t3 S  }
0 i! u3 a4 a4 r$ H___________________________________________________________________________________________________" H8 s  ]( l% P, i8 h0 O
7 Q2 u, u6 v+ E
  // Overrides flag byte (sys.override) and execution should be installed here, since they
3 K% Z/ J- i+ m( {6 _" ?  // are realtime and require a direct and controlled interface to the main stepper program.
5 v% t" m: O0 ~& t" y- Z9 e, @, j) R' ]
  //重写标志字节(sys.override)和执行应该安装在这里,因为他们
( U! o/ T3 V/ @  //实时和需要直接和控制接口的主要步进程序。
, }% d$ n* ~0 ]/ m* H: C
! s* A6 }& c( K! c: V5 e* w; `* J5 c. @2 K
  // Reload step segment buffer 重新加载步段缓冲! i5 w9 }2 u! U: w) k" f
  if (sys.state & (STATE_CYCLE | STATE_HOLD | STATE_MOTION_CANCEL | STATE_SAFETY_DOOR | STATE_HOMING)) { st_prep_buffer(); }
( [7 C4 h( R. T0 J. d' s' `% `/ D5 n% c9 l; y
  // If safety door was opened, actively check when safety door is closed and ready to resume.
1 K# c# j8 l' S: `" E1 ?% ]  // NOTE: This unlocks the SAFETY_DOOR state to a HOLD state, such that CYCLE_START can activate a resume.        " V$ P) {  D! F: I1 Y8 a
3 ~$ M/ B4 j# S8 x) _7 `' o& N2 U/ _
//如果安全的门被打开,积极检查当安全门关闭,准备简历。+ @" W# n* U+ M/ J" X/ K
  //注意:这解锁SAFETY_DOOR状态保持状态,这样CYCLE_START可以激活一个简历。, ]; r0 ~  b8 B" e  L$ y3 `0 n

- u! q1 l  j: x1 C. m  if (sys.state == STATE_SAFETY_DOOR) {                 //安全门状态进入6 l3 h; {2 J9 n- m) {
    if (bit_istrue(sys.suspend,SUSPEND_ENABLE_READY)) { : A* x. H$ S; ?  f
      if (!(system_check_safety_door_ajar())) {
5 I! x. e" W9 y; Y# \7 T        sys.state = STATE_HOLD; // Update to HOLD state to indicate door is closed and ready to resume. 更新保存状态指示门关闭,准备简历。8 s. B" z% V9 P/ [. ^
      }5 s: E6 s  V, o6 w0 ^
    }% T* w7 E' F7 V' \' w0 s7 F& g$ S  q
  }
, a/ i. G  s1 Q3 M4 J
, d. @& _# Z+ I, v+ o; l+ b. S7 J  } while(sys.suspend); // Check for system suspend state before exiting./ @6 K7 c) r- |: F
  ) y$ I! w6 b& ?+ O
}  
发表于 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-7-12 15:08 , Processed in 0.111263 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.5 Licensed

© 2001-2025 Discuz! Team.

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