机械必威体育网址

 找回密码
 注册会员

QQ登录

只需一步,快速开始

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

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

[复制链接]
跳转到指定楼层
1#
发表于 2016-8-20 23:56:23 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 1五湖四海1 于 2016-8-21 00:09 编辑 ) ^$ i; h/ V1 n! o0 P
- G7 R2 k+ b8 b/ ^" ^
    以前制作过CNC雕刻机,是用MACH3作为上位机控制,硬件是采用PC接并口输出脉冲和方向使能信号经过隔离驱动步进电机驱动器,步进电机驱动是采用TB6560芯片控制。最后就接到步进电机。机械是用铝合金制作,主要部件有三个1605的滚珠丝杠,多个运动滑块等制作。用这台DIY CNC雕刻机可以雕刻木头塑料等东西。当时没有一直玩下去,现在发现网上有用单片机制作的雕刻机挺精巧的现在分享给大家。
) J" [) u' U1 R! l- y0 ~% r2 q, @   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个运动来规划运行速度,以实现平稳的加速和无冲击的转弯。很棒吧!开始玩起。2 c8 ^. d# h9 B# C1 V% y! \0 Y
    还没有雕刻机的机械部分可以用废旧光驱制作个微型雕刻机运动平台。雕刻机最重要的是主控程序这次用 Arduino/AVR328单片机,价格在15元左右,主控程序是上面提到的目前很火的开源
的GRBL,还有一种基于STM32平台的开源主控程序Dlion也不错可以替代grbl。如果从性能比较这两个方案,显然是stm32平台运行速度更快毕竟他是32单片机呀!
0 ~$ T$ i2 c) K! T$ L8 V7 c8 s# U! [
  k# L& H. I! S- @- D
    下面介绍小这个些主控程序主要干的事,通过串口PC和主控板通讯,PC命令给控制板,控制板接收命令做不同的响应,PC可以发G代码给主控板,接收完成后可以自动开始雕刻任务。
+ n+ y$ S( L! z: C2 g  u; i% {          在介绍下G代码因为G代码是雕刻机的核心部分, O; ]2 [2 _$ h3 s
G代码是数控程序中的指令。一般都称为G指令。
3 d4 |( \: v4 l+ B# oG00------快速定位) R0 ]6 B6 ?3 T* d0 B
G01------直线插补
6 m  r' d1 E  w0 G" wG02------顺时针方向圆弧插补
9 c/ b! Q( d1 i  HG03------逆时针方向圆弧插补$ y9 s& [3 U% a; Z0 o
G04------定时暂停3 b6 ^9 F( [* C3 V1 A* t0 l0 N
G05------通过中间点圆弧插补
4 `& G9 _7 ~9 tG06------抛物线插补, K6 s* v% j5 F* F
G07------Z 样条曲线插补
, H" N1 M) p$ X/ v; DG08------进给加速
1 t1 Y; x4 i" n9 q6 L8 j/ pG09------进给减速' d+ D/ b) j! j3 A6 p
G10------数据设置/ ^3 y/ z0 b1 o6 |3 N/ P
G16------极坐标编程
2 d; Y8 w/ b5 n: U. ?) PG17------加工XY平面, W! k( \( W7 ~
G18------加工XZ平面+ w1 V' T# C/ P
G19------加工YZ平面

" V! Y1 K6 O  x) l0 X1 h核心就是解析G代码,完成步进电机驱动,和控制主轴开启关闭,还有插补算法,直线插补,圆弧插补,还有一些步进电机的加减速算法。
0 A* g7 S* [. b下面对grbl主结构做介绍, t+ W' U$ t0 B* b
main()主函数首先执行下面初始化函数
5 a6 a. [; a9 j$ \* @        serial_init();                           // 设置串口波特率和中断
" z' Q+ d" F; b2 B        settings_init();                         // 从ROM加载grbl设置
1 O5 K  F* r& V& Z4 o% T. n        stepper_init();                          // 配置步进方向和中断定时器
% O' i  {- ~2 |0 B" x9 S2 x3 r, n        system_init();                           // 配置引脚分配别针和pin-change中断5 K0 n' D9 N9 E1 u# O
        memset(&sys, 0, sizeof(system_t));          // 清除所有系统变量* o3 n& I, T3 X/ D
        sys.abort = true;                           // 中止标识位置位
. X, w3 {: a4 |        sei();                                         // 使能中断
9 `% a8 ~& X5 o0 ]7 _2 \0 ?  #ifdef HOMING_INIT_LOCK                        // 宏运算(settings.flags & (1 << 4)) != 0结果flags等于执行sys.state = STATE_ALARM- g0 B% M( z- D8 V) N  Q3 m/ J
                                                // 系统状态赋值为报警状态% k' |1 \2 V8 w. u
            if (bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE)) { sys.state = STATE_ALARM; }& C6 o) {% B; p1 ^! {6 q9 D
  #endif
( R3 _. k4 q" O4 z& e_____________________________________________________________________________________________________________________________________
* |; E' y8 }7 Z) Y. \$ z, v接下来是一些主要部分初始化
" m; T* h% Z- d3 ifor(;;) {
* k# v/ b% ?& ^        serial_reset_read_buffer();         //清除串口读缓冲区; ^( _5 Y/ e$ {% q9 b
        gc_init();                         //初始化G代码功能函数9 K4 l& T4 N0 D$ c+ v
        spindle_init();                        //主轴初始化
' V9 v$ V- g8 v# y        coolant_init();                        //冷却液初始化1 m' p' l3 ]4 I* c2 P
        limits_init();                         //极限开关初始化, ]# L9 `0 z6 G6 E1 B/ X
        probe_init();                        //探测部件初始化
) p0 I% U$ V: d, B0 m& d        plan_reset();                         //清除块缓冲区和规划师变量
$ D. D+ P* H/ ]% M        st_reset();                         //清除步进系统变量。
5 J" P% s1 x" F% H  i, d* @) k) B) Y) Z+ r! \* r) @0 P
2 k. N( A- _' a! G
        //下面两行清除同步gcode和策划师职位当前系统位置。: Q$ ]6 l1 n7 C; |& H
        plan_sync_position();
' [, o+ U8 R* w  i        gc_sync_position();
6 t0 r4 N9 @0 z; u( j' F
" [0 H3 v& Y  Y1 n2 L2 b9 x. O5 @% D& m7 ^. c7 s
        //复位系统变量. w/ Z  R% ?4 Z' \' ~
        sys.abort = false;                //系统中止标志
+ v6 r% G: _, Z% q        sys_rt_exec_state = 0;                //系统标志位变量状态管理。看到EXEC位掩码。' A, T% _" ]9 N& w1 N* A7 ^
        sys_rt_exec_alarm = 0;                //系统标志位变量设置不同的警报。) m. b; b/ ~, r6 x/ G
        sys.suspend = false;                //系统暂停标志位变量管理,取消,和安全保护。
6 E7 S2 l0 o% e        sys.soft_limit = false;                //限位开关限制状态机错误。(布尔)
9 u4 [7 N6 M1 F7 n+ V; R% _$ T  |8 G7 k) \3 T

) w* ~# u# n; m        protocol_main_loop();                //主协议循环$ v; i; e; a& l9 N* [, I4 M& Q
}        //5 y9 X: t% S* g  d9 w/ h  Z
_____________________________________________________________________________________________________________________________
6 G4 a8 ^1 W6 \1 {* f1 t进入void protocol_main_loop()函数% b  @5 ~# N0 ]% h8 [5 f8 O
{& w, i, a, l, \- R  B2 \, ?7 G. r
        report_init_message();                // 打印欢迎信息 ; u* L0 }. R  z' y! X4 }2 J
        //重启后检验和报告报警状态如果错误重启初始化。
/ A, t8 y4 m0 ?3 q& H3 P' d
        if (sys.state == STATE_ALARM) {: w0 e9 F0 w) U; v4 f
            report_feedback_message(MESSAGE_ALARM_LOCK); //打印信息
  B+ H$ d. Y6 z
          } else {" i, h# X) _/ f0 A# U
            // 如果没有报警说明一切正常!但还是要检查安全门. 0 P% H% M: ]! G. g& W1 V" q
            if (system_check_safety_door_ajar()) {  j, q: ?% a) n
                     bit_true(sys_rt_exec_state, EXEC_SAFETY_DOOR);
, T  G/ W2 A+ `, |1 \2 c                     protocol_execute_realtime(); // 进入安全模式。应该返回空闲状态。3 k. c3 d  C2 Z7 G+ p* d
            }         else {
% e3 ?1 \4 x  }* r% O: {" k              sys.state = STATE_IDLE; // .设置系统做好准备。清除所有国家国旗。
" W, V5 Q: i. [2 j+ N            }
, @6 I- u5 r. e8 o# U: \' S6 a7 }            system_execute_startup(line);    //开始执行系统脚本
+ M- W' ?2 ~. R9 H( k; N  } & h5 y' v6 E$ I3 V' V  r
# `& n' y% ~+ ?4 R7 M* |
; t5 f5 r8 }9 G4 l! _( V! J$ a- u8 `; t
  // 这是主循环!在系统中止时这是出口回到主函数来重置系统。6 z5 c' n0 _: u5 P$ ], \
  // ---------------------------------------------------------------------------------  4 j; I' d9 P- D% j% S
  
9 I! d& j3 U7 V7 s) S4 ^        uint8_t comment = COMMENT_NONE;: s6 g+ C. D3 z6 h6 z2 `
        uint8_t char_counter = 0;/ u+ @4 Y9 _: X: b  m
        uint8_t c;6 g: I& P) l5 i+ ~8 h1 i. M
_______________________________________________________________________________________________________________________________6 m8 B* b; }8 O1 h
接下来进入for(;;)循环                //下面代码是G代码解析核心部分,程序中comment(注释)变量会被赋不同值,代表发符号有‘(’‘)’‘;’
: p- I) z% w; j" M{
/ C# |7 U0 H8 B/ O//串行数据输入一行的的过程,作为数据。执行一个
: T8 m0 a: Z2 q# h! Q//所有数据初始过滤去除空格和注释。
& Z- l% V6 p5 I6 h//注意:注释,空格和程序段删除(如果支持的话)处理技术
) L# v: q$ u" r) }2 o//在G代码解析器,它有助于压缩到Grbl传入的数据
8 B6 k/ n' p3 k//线缓冲区,这是有限的。刀位点标准实际上州一行不行+ I9 N$ H. P- N) o  ]' E" w
//不能超过256个字符,Arduino Uno没有更多内存空间。
% R: g1 b2 T. B( F" l7 P! _//有更好的处理器,它会很容易把这个初步解析的
  v8 ]" K* T* z//分离任务共享的刀位点解析器和Grbl系统命令。                                                                # S; \- f; Y7 h5 p) j- G7 H0 x* l# W
    while((c = serial_read()) != SERIAL_NO_DATA) {                             //读取串口数据,有数据执行下面代码8 B6 j6 i* f8 u7 V. n2 n1 D
      if ((c == '\n') || (c == '\r')) { // End of line reached                //如果数据是/r,/n代表一行结束6 l# U2 a& }$ @+ m. g1 v8 E4 r
        line[char_counter] = 0; // Set string termination character.        //设置结束标志
* ~9 h" E, n& W6 ?( H! g        protocol_execute_line(line); // Line is complete. Execute it!        //一行完成执行此函数+ `6 n( a& U" c8 _
        comment = COMMENT_NONE;                                                //注释清零
% q9 t8 E* M; R+ i1 A        char_counter = 0;                                                    //字符计数清零
( Z) J6 d- ~* I! Q2 l  1 e9 {+ S: @7 |7 t8 Q
        else {+ d- U2 g1 x: o: S$ Y0 a
        if (comment != COMMENT_NONE) {
) y8 m3 t. Y& K4 l* G( ?                                                     //扔掉所有注释字符
  `1 q( M8 b% U9 I) j3 ?& `          if (c == ')') {
: O9 f3 {8 ]4 [8 d' [* Z# @- d' {            //最后注释。重新开始。但是如果有分号类型的注释。/ U9 T$ y1 C, H1 d
            if (comment == COMMENT_TYPE_PARENTHESES) { comment = COMMENT_NONE; }
' r* m1 F" v- n5 {8 Y          }
$ A$ n  K+ t+ J      } else {
5 ?2 K$ K1 F/ i+ z4 C- R          if (c <= ' ') { , |. Y, @2 [" a
            //扔掉whitepace和控制字符
2 u$ d9 X- c( r: n( M* n- G6 v! a7 ]          } else if (c == '/') {
" Y6 r3 y  z( G. C# H9 H            //块删除不支持将忽略字符。
& K0 h9 M1 q1 \- j; \$ ?" P            //注意:如果支持,只需要检查系统是否启用了块删除。
3 U6 C" H+ H1 h          } else if (c == '(') {
6 z+ q5 `# P" W% Y            // Enable comments flag and ignore all characters until ')' or EOL.
$ B/ f7 d& z4 p* I1 N: S            // NOTE: This doesn't follow the NIST definition exactly, but is good enough for now.
3 L$ I, ]- ^# N' f2 Z            // In the future, we could simply remove the items within the comments, but retain the
! e+ [; q; \+ _. I            // comment control characters, so that the g-code parser can error-check it.5 [7 q. I7 Q7 s2 i/ Y5 [! J
            comment = COMMENT_TYPE_PARENTHESES;0 ], |/ A4 L8 S; W7 F
          } else if (c == ';') {3 Q+ a: Z' T* a+ a; E. m. h
            //注意:','注释EOL LinuxCNC定义。没有国家标准。
% E6 Q7 o, R8 k2 w            comment = COMMENT_TYPE_SEMICOLON;  }- h/ A  U+ }  b

' W/ m+ b5 }$ d; N# O' {) y$ x' p
! n: y* b/ b& b8 |_____________________________________________________________________________________________________________________________________5 R$ ]- _1 ~& L# v
          } else if (char_counter >= (LINE_BUFFER_SIZE-1)) {                        //串口接收数据大于80字符时
4 P0 W4 T& L, T8 [3 [            // Detect line buffer overflow. Report error and reset line buffer.        检测缓冲区溢出。报告错误和复位线缓冲区。5 B6 [- Z5 r  l
            report_status_message(STATUS_OVERFLOW);                                //打印溢出信息
6 x5 ]1 i* u4 u5 z; u' w            comment = COMMENT_NONE;* R- n: c! j0 p# Z# k% j( s" f
            char_counter = 0;
2 k1 N1 ]3 v' `8 P$ k          } else if (c >= 'a' && c <= 'z') { // Upcase lowercase                        //小写改大写+ _0 x1 h" _. n# v2 n6 w9 V
            line[char_counter++] = c-'a'+'A';
. Z: d' u4 U/ A& X$ y, G8 `: a. ^! ]          } else {( m$ p9 m1 Y1 Z
            line[char_counter++] = c;# u% n/ j4 X' c9 ?: r
          }
. ^/ r# x) a/ `' K6 m: D        }
& ~, }' R# B7 F/ \# j$ n      }
9 n/ C: \! F# R. c1 l: n6 S    }% `/ e0 f& i! D
____________________________________________________________________________________________________________________________________1 x' C7 w- l+ X1 p0 _5 T4 t4 V
        //如果没有其他字符在串行处理读取缓冲区和执行,这表明以完成,自动启动,如果启用,任何队列动作。
5 X  {& u, q3 k5 X) ]) c        protocol_auto_cycle_start();                //自动开始协议循环
) T. c) o; I9 B, r1 m+ b        ; Z, Z. c0 N/ r7 T' [
            protocol_execute_realtime();                  //运行实时命令。0 V# R7 ?% U$ t/ A! p
            if (sys.abort) { return; }                 //中止标识置位程序循环重置系统。            
" H; k' w$ m9 K/ h$ J+ k  }
0 Y2 O, U: f1 [2 l3 l  return;                         //一般程序不会执行到这里
5 I8 \# u" o9 t$ x}! [. Z7 @0 w$ G5 O1 [% T, a# [/ w
____________________________________________________________________________________________________________________________________
! r1 Z- h6 O9 I- i9 I- @正常情况下,读取完G代码程序会进入protocol_auto_cycle_start();//自动开始协议循环 函数下面介绍此函数) v6 l. ^- [9 ^5 Q4 K. M+ C5 j
// Auto-cycle start has two purposes: 1. Resumes a plan_synchronize() call from a function that8 F3 ]) K7 t& K
// requires the planner buffer to empty (spindle enable, dwell, etc.) 2. As a user setting that
9 M" j  \/ g/ b' }) {. R// automatically begins the cycle when a user enters a valid motion command manually. This is 9 T% ?! c5 C3 c" h% Q& d; ?
// intended as a beginners feature to help new users to understand g-code. It can be disabled
1 r) m: B1 h" g$ C! z5 J% z// as a beginner tool, but (1.) still operates. If disabled, the operation of cycle start is; w( x# c* q  s0 L
// manually issuing a cycle start command whenever the user is ready and there is a valid motion 7 a# }9 ?  Y3 q/ n
// command in the planner queue.' o) s8 g5 e$ g- D
// NOTE: This function is called from the main loop, buffer sync, and mc_line() only and executes
& a0 u. E* A9 A// when one of these conditions exist respectively: There are no more blocks sent (i.e. streaming / D* t2 e5 i  I6 O( U7 @" ?
// is finished, single commands), a command that needs to wait for the motions in the buffer to
( k6 Q$ `2 B7 W+ t7 E// execute calls a buffer sync, or the planner buffer is full and ready to go.8 I$ D* D8 _# S8 j4 e& }: Z+ U
//自动开始有两个目的:1。回复一个plan_synchronize()调用的函数
8 g# M# ^' ?# L0 @/ }, `//需要规划师缓冲区空(主轴启用、住等)2。作为一个用户设置
# R1 S5 K5 U' H& H! O//自动循环开始当一个用户输入一个有效的运动命令手动。这是( o7 C; [( t* W
//作为一个初学者的特性来帮助新用户了解刀位点。它可以被禁用) ^. D1 t6 M* ]. f  G  a
//作为一个初学者工具,但(1)仍然运作。如果禁用,运行周期开始, T' s. f) A5 J& \' l9 u* `/ O6 H
//手动发出一个周期开始命令每当用户准备好,有一个有效的运动
: Z  v; ?+ L/ O4 H* x0 H$ L  M//命令的规划师队列。
& o3 t* b3 a$ H% ^# R% ~% _/ g//注意:这个函数被称为从主循环缓冲区同步,mc_line只()并执行! v( @* X. f% ^( `4 n) E5 F
//当其中一个条件分别存在:没有更多的块(即流发送
' ?5 F- g$ B' f9 n5 L7 \* y) G//完成后,单一的命令),一个命令,需要等待缓冲的动作, ~3 z$ s9 e) @
//执行调用一个缓冲区同步,或规划师缓冲区满了,准备好了。+ R) D% I& \* Z  i7 h0 L
void protocol_auto_cycle_start() { bit_true_atomic(sys_rt_exec_state, EXEC_CYCLE_START); }
* W1 o4 u( z! |: ]; U_______________________________________________________________________________________________# i5 u- R  K7 g6 z
接下来程序运行protocol_execute_realtime(); /运行实时命令。: k; P/ d/ ]% U% G$ c! `3 G- M
// Executes run-time commands, when required. This is called from various check points in the main$ Z$ K9 g- V0 w5 l8 G# d0 @
// program, primarily where there may be a while loop waiting for a buffer to clear space or any2 k4 Z$ |- O. \$ x) M" S. b, r( p! O9 a
// point where the execution time from the last check point may be more than a fraction of a second.
5 V4 j. W1 ^# W2 ]8 a0 u// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code# [; B# R8 Y7 X/ K5 f
// parsing and planning functions. This function also serves as an interface for the interrupts to ) c% l; E. f5 X' o
// set the system realtime flags, where only the main program handles them, removing the need to
6 H0 R: `! q+ z" Y+ w// define more computationally-expensive volatile variables. This also provides a controlled way to + j. q- P4 n4 v( O
// execute certain tasks without having two or more instances of the same task, such as the planner
% [; p% U& m0 L. E5 R) e- S$ {// recalculating the buffer upon a feedhold or override.2 Z- x4 W3 ^) C1 c+ @* r( |
// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,
8 W6 a# h2 ?8 V- e0 s+ ]  L3 ^// limit switches, or the main program.
  ?& }/ r) O0 G. _void protocol_execute_realtime()1 B; p+ x' b0 T5 s! [
uint8_t rt_exec; // Temp variable to avoid calling volatile multiple times.临时变量来避免多次调用不稳定。1 K$ U- g% }4 t/ X8 S3 v& O
就先分享到这吧!! {- {- [  X- M

1 h1 w0 J5 R- {: y8 k
2 u9 W' ?7 \6 L" B  s& C, q' z
* O5 _! {. G+ {! B7 e7 y! L; N4 c3 U2 G; |3 |7 @: L1 w2 b
; k, q2 O( |- x
! q0 C8 \  P, ]
! s7 j2 l' y) s7 ]% K

" |! p9 Z' @8 q7 i8 H
0 C( F8 h3 W- Z  ~" i* y% k$ b
' t5 q  M3 w/ s7 T2 |: K9 a# f: y: f- e2 c& f% N8 j, E
: B- y# j/ \. `! c  Z/ Z: Z% G) p

7 K" K' D8 h; u% U
  K" ]: Q' f( Z7 S+ h6 Q" z* u# `$ @' `9 `  l2 h; h2 t4 A

/ G5 f$ K: Y6 R2 Q4 ^6 s) P: q* J+ A; Y$ H! Q* u

; w8 r) D* ?0 ~" b/ F- U- C, N' [2 G' H2 @

- p& m2 \# Y8 F" B! k5 G
' b+ @% x/ }1 B, w
1 @/ C7 Z4 U" e5 s# D7 Q
+ c6 R# F3 N/ s6 Z: A7 c5 M补充内容 (2016-8-25 22:40):4 B' G8 N" i0 M
配置说明0 W3 b$ j" t0 {1 ^
//这个文件包含编译时配置Grbl的内部系统。在大多数情况下,# R* `% ]  e8 y$ P" d
//用户不需要直接修改这些,但是他们在这里为特定的需求,即。# _, }. y9 C$ I' A8 }' M& b
//性能调优或适应非典型的机器。2 o1 \- a- O4 _0 B# Z+ S! ]  [
主要配置项:
: z( C, j2 u# a" I. M7 J6 ]1.#define DEFAULTS_GENERIC        //在重置eepm时使用。在defaults.h改变想要的名字
0 b( G* q1 [. u& [0 {0 O2.#define BAUD_RATE 115200        //配置串口波特率115200
5 m, m* v  g" \* {4 i+ d3.#define CPU_MAP_ATMEGA328P         // Arduino Uno CPU
$ |  U% R) y5 D4.#define CMD_STATUS_REPORT '?'        //定义实时命令特殊字符
( o; f3 p6 i( n5.#define HOMING_INIT_LOCK         //回原点保护锁
$ C" l$ c9 O% u$ O  P) T6.#define HOMING_CYCLE_0 (1<<Z_AXIS)              // 第一步Z清除工作区。+ v# L3 f' I" n
  #define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // 然后X,Y在同一时间。* a6 `: n+ Z5 U
7.#define N_HOMING_LOCATE_CYCLE 1 //回原点循环次数
* \3 I* l7 o5 m3 y8.#define HOMING_FORCE_SET_ORIGIN //取消这定义迫使Grbl总是在这时候位置设置机器原点尽管开关方向。/ Y& G( j6 U: G' ?
9.#define N_STARTUP_LINE 2 //块Grbl启动时执行的数量。' |  d' d7 p$ e% v' s" t* k( o* I& [
10.#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 协调或位置价值英寸
; s* j2 V2 Q1 n" z2 }% f0 S   #define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 协调在毫米或位置价值
. g7 w6 d: E! q" t   #define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分钟的速度值+ ?% c+ |: S, n+ W- |
   #define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分钟7 S$ Z7 u* S! v& [0 K: R
   #define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 对浮点小数设置值2 j" [7 H$ ^/ u8 b; t& @
11.#define LIMITS_TWO_SWITCHES_ON_AXES //如果你的机器有两个极限开关连接在平行于一个轴,您需要启用这个特性
% @$ J' g( ~5 c$ W! d12.#define USE_LINE_NUMBERS         //允许GRBL跟踪和报告gcode行号
6 {* t3 E# o2 _13.#define REPORT_REALTIME_RATE //允许GRBL报告实时进给速率& M# k6 u5 W3 E- y3 C8 R
14.#define MESSAGE_PROBE_COORDINATES  //坐标通过Grbl $ #的打印参数?
. C* X1 V' }; T) L15.#define SAFETY_DOOR_SPINDLE_DELAY 4000 //安全门主轴延时
: }) j' f) I4 B0 x16.#define SAFETY_DOOR_COOLANT_DELAY 1000 //安全门冷却液延时
' j# o6 y) N5 Z: z- V17.#define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS) //启用CoreXY运动学。
/ T) b- T! ]  Z( u" Y9 H' ~; s18.#define COREXY // Default disabled. Uncomment to enable.改变X和Y轴的运动原理
8 S8 D; h1 k/ Q1 }/ t- W19.#define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.反转针销逻辑的控制命令8 K% d, P4 u% O5 e* r
20.#define INVERT_SPINDLE_ENABLE_PIN // 反转主轴使销从low-disabled
8 _+ S: w3 X7 ]: ?21.#define REPORT_CONTROL_PIN_STATE //启用控制销状态反馈状态报告。
6 B% i. K3 g- o  n22.#define FORCE_INITIALIZATION_ALARM //启用和用户安装限位开关,Grbl将启动报警状态指示
8 r' p" n7 m0 u$ G, _23.#define REPORT_GUI_MODE // gui允许最小的报告反馈模式
& m) Q# a" N  @( g24.#define ACCELERATION_TICKS_PER_SECOND 100 //加速度的时间分辨率管理子系统。
9 V: L" G: y) F# ^6 q25.#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING //自适应多轴步平滑(积累)是一种先进的功能
' m) g% k% r, k3 X7 i0 K( \26.#define MAX_STEP_RATE_HZ 30000 //设置最大一步速率可以写成Grbl设置4 r5 [/ A' W: Q: T6 l
27.#define DISABLE_LIMIT_PIN_PULL_UP //以下选项禁用内部上拉电阻2 ^4 \# o) v! {+ \: Q5 t; k
28.#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS //设置哪个轴长度补偿应用的工具。假设轴总是与选择轴工具面向负方向
4 |- l; L" m9 O( g+ [! E29.#define VARIABLE_SPINDLE //允许变量轴输出电压不同的转速值。% S4 O/ [% _3 `3 A4 Y! L* Q* Y
30.#define SPINDLE_MAX_RPM 1000.0  // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.
% r) C, G& f9 B# ]   #define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM., Z7 m4 Q; O3 h3 b5 ~" d! v
31.#define MINIMUM_SPINDLE_PWM 5 //使用的变量轴输出。这迫使PWM输出最小占空比时启用。6 l6 O$ z0 Z% e# \* a6 Z
32.#define USE_SPINDLE_DIR_AS_ENABLE_PIN //主轴方向使能M4被删除( ^" u" F2 U- C0 `* d
33.#define REPORT_ECHO_LINE_RECEIVED //应该对所有正常线路送到Grbl' s2 G  k+ @+ V0 {) {/ D
34.#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min) //最小规划师结速度。设置默认最小连接速度规划计划
# C' Q) }1 S7 ]# h" S2 o35.#define MINIMUM_FEED_RATE 1.0 // (mm/min)//设置计划将允许的最小进给速率
  ~8 i+ g- c: s2 U. h36.#define N_ARC_CORRECTION 12 //弧生成迭代次数之前小角度近似精确的弧线轨迹
1 p' v4 ]$ [( X& `/ e37.#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)//定义值设置机器ε截止来确定电弧是一个原点了?* B& E3 j( j! t$ n* A8 ]
38.#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds) //延时增加表现在住。默认值设置为50毫秒. c6 E1 \, A6 o0 Q2 f1 D/ p- C
39.#define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.3 h! _4 M1 k" @+ Y  ^) ^" Q
40.#define BLOCK_BUFFER_SIZE 18  //线性运动规划师缓冲区的数量在任何给出时间计划
1 o! p0 B# B: d! F8 k41.#define SEGMENT_BUFFER_SIZE 6 //控制之间的中间段缓冲大小的步骤执行算法
, r% u2 m7 L1 }% T) v$ v! F42.#define LINE_BUFFER_SIZE 80 //行执行串行输入流的缓冲区大小。! k2 S6 k, x# O% L
43.define RX_BUFFER_SIZE 128 //串行发送和接收缓冲区大小
" ~8 S$ s3 E8 {- t/ [0 n! e44.#define TX_BUFFER_SIZE 64
+ f, r- s9 M) {5 {4 }" f45.#define ENABLE_XONXOFF        ////切换为串行通信发送流软件流控制。6 T- R  b9 ]1 W
46.#define ENABLE_SOFTWARE_DEBOUNCE //一个简单的软件消除抖动特性硬限位开关。
- j# f5 J& F4 [) k* u! y  `47.#define HARD_LIMIT_FORCE_STATE_CHECK        //Grbl检查硬限位开关的状态5 c" o! `) N  v2 M' p& W! N1 |
48.// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:编译时错误检查的定义值:
) R. J! I% t/ L; B/ `' q' L1 ]0 Q$ a
$ V6 W+ E8 u+ D___________________________________________________________________________________________________
# \0 c6 X8 ]( _/*. I2 q+ U1 B3 B. {( f
  config.h - compile time configuration6 G+ z9 g" b* i" J# j! v
  Part of Grbl$ f( {$ y+ e8 A9 D4 S% Y" H. D) @
1 q5 x  [* N6 W$ z+ |7 L' B
  Copyright (c) 2012-2015 Sungeun K. Jeon
7 N# _8 B  V+ E& x+ I  Copyright (c) 2009-2011 Simen Svale Skogsrud
" X! N  L' ]( P2 m: _! r$ \
2 ~6 `, l) b7 ^; b6 g2 \2 ~! Z' w3 j  Grbl is free software: you can redistribute it and/or modify
& X' J4 n6 u! \7 g6 l6 [  it under the terms of the GNU General Public License as published by* ?7 R: O; w5 D) B
  the Free Software Foundation, either version 3 of the License, or
/ a2 N& d5 G: O, H5 Q* q9 _  (at your option) any later version.
0 _  S) E- r* Q, e1 s6 d: t  U" v
! D' j8 o9 w$ \4 j  Grbl is distributed in the hope that it will be useful,9 B: k1 z; Z% v- H6 U9 u) e2 ?
  but WITHOUT ANY WARRANTY; without even the implied warranty of. ]& ^6 O2 O3 ^9 I. T
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the& Q) |* Y; T5 n0 h, c
  GNU General Public License for more details.
% [6 j9 L. p4 H0 Q- T  f" D! a% p' B$ L. O/ W) z% B0 x3 U
  You should have received a copy of the GNU General Public License" J1 P, u, r) ^3 y# I1 s
  along with Grbl.  If not, see <http://www.gnu.org/licenses/>.; X) \9 [  p+ w  c2 R9 [: a7 g
config.h  -编译时配置,Grbl的一部分
& n6 G: Q7 z3 h$ E( o& j0 ^2 p7 e: G$ K% k; J& N5 o
版权(c)2012 - 2015 Sungeun K. Jeon
* v9 ^6 o& H+ \9 f: @版权(c)2009 - 2011 Simen Svale Skogsrud5 T- c6 p1 h+ j- X
/ g! `/ z( T6 i) W% h; X, d
Grbl是免费软件:可以重新分配和/或修改
: {6 K; y0 K: N$ j  O/ }* }GNU通用公共许可证的条款下发布的自由软件基金会,版本3的许可,或(任您选)其后的版本。; R8 G" V4 Y' Q4 d4 Z
1 V2 R( ~; _8 ?7 ?; z3 f
Grbl分布,希望这将是有用的,但是没有任何保证;没有即使的默示保证适销性或健身为特定目的。看到
% ~# z% @, W4 Q* yGNU通用公共许可证的更多细节。
% n! F/ e- H" o' @5 I8 t5 \/ L- H
% `) w3 T  W4 a, @  W你应该收到了GNU通用公共许可证的副本
3 E' [' Y5 v% V, A/ U2 K连同Grbl。如果没有,看< http://www.gnu.org/licenses/ >。
3 x$ s, F! f- J9 s3 S! A. u , j# s; {* N/ z! |# ~3 o7 @
*/, T& R' \8 O! q+ X- M) I0 n& }; C
  , s% d3 L" y- y3 l
// This file contains compile-time configurations for Grbl's internal system. For the most part,
+ j7 @4 o, `( m6 W( m7 G6 E5 {// users will not need to directly modify these, but they are here for specific needs, i.e.
, I8 F) V+ U; f$ O/ r% Z9 m// performance tuning or adjusting to non-typical machines.; i9 N, {! j% A; W. p, p
//这个文件包含编译时配置Grbl的内部系统。在大多数情况下,$ q, o7 _( P$ W" R; p" G
//用户不需要直接修改这些,但是他们在这里为特定的需求,即。
% U5 d6 C; n1 D6 ~& @1 S; O//性能调优或适应非典型的机器。
. X* ~6 L' o4 Q8 ?
$ D- S5 K' l: p* I/ m6 q- T// IMPORTANT: Any changes here requires a full re-compiling of the source code to propagate them.
! I2 D% J" d' ^  p//重要:任何变化需要一个完整的基于源代码的传播。
: J, ?: ?; P  @, v/ u0 J
  u. l- ?" f$ Y- G#ifndef config_h: w( X/ v# h8 I+ N% i2 C7 @
#define config_h- Z, N5 \5 K2 J
#include "grbl.h" // For Arduino IDE compatibility.4 i/ F- b  B) y) ~8 j' C
, A4 E. v+ g6 c' j9 r, d, t) S: c
// Default settings. Used when resetting EEPROM. Change to desired name in defaults.h
) ]  Q- K# ^# y/ l// 默认设置。在重置eepm时使用。在defaults.h改变想要的名字
/ ^( s: Q' b. u$ u- P: e  Z$ T7 X! S; w
#define DEFAULTS_GENERIC
1 l+ C/ S0 {' w
; s( g" u1 A7 a* Z% ~// Serial baud rate
* p" D8 ^- E2 J' X, L& z#define BAUD_RATE 115200                //配置串口波特率115200; K: e" O# a3 a+ ~
$ g& }, u6 j8 i
// Default cpu mappings. Grbl officially supports the Arduino Uno only. Other processor types, z; Y. L% Z/ @6 y: E; X9 Z- I
// may exist from user-supplied templates or directly user-defined in cpu_map.h& H' ^4 k& Z2 V$ U
//默认cpu映射。Grbl正式支持Arduino Uno。其他类型的处理器可能存在cpu_map.h直接从用户提供的模板或用户定义的3 D# j( S" o( j  s3 Q

/ S; X! [% I# e0 ?7 O#define CPU_MAP_ATMEGA328P // Arduino Uno CPU9 d, f7 K3 e8 K$ R- S9 f8 G

" {) w; O: o- G1 K. ~- U// Define realtime command special characters. These characters are 'picked-off' directly from the
0 Q1 T: u9 y7 O  c: e// serial read data stream and are not passed to the grbl line execution parser. Select characters8 b* Q' {1 _5 O! ]. U
// that do not and must not exist in the streamed g-code program. ASCII control characters may be % C1 o. u" t# p- ?
// used, if they are available per user setup. Also, extended ASCII codes (>127), which are never in   M" T3 @0 Y+ y. v; E) ^
// g-code programs, maybe selected for interface programs.
/ U' d& e# M1 F9 K3 _// NOTE: If changed, manually update help message in report.c., E2 Y. w. i2 O3 }" L
/ J$ B  m4 k2 G% \) B% L! T
//定义实时命令特殊字符。这些字符是直接从“各个击破”串口读取数据流并没有传递到grbl行执行解析器。选择角色; s8 \( [' V9 q% G, S# {
//不,不能存在于程序流刀位点。ASCII控制字符( k& C0 {& w5 D  t' ]1 x
//使用,如果他们是可用的每个用户设置。同时,扩展的ASCII码(> 127),从来没有
$ c* E% U7 v5 g6 |//刀位点的程序,也许选择界面程序。
& ?6 B0 y- q6 g. j+ {3 l//注意:如果改变,手动更新report.c帮助信息。2 F0 `& x% Z1 w" Y2 i: I6 I3 V3 [

6 B/ N2 |4 y0 k" w6 j; E% J#define CMD_STATUS_REPORT '?'
! G; {0 x: S; h8 \# M& _% |#define CMD_FEED_HOLD '!'9 U2 Y5 g0 i' e6 q8 X! s6 w
#define CMD_CYCLE_START '~'
" `  N6 f9 h% K6 s+ N#define CMD_RESET 0x18 // ctrl-x.
) ^6 J4 w8 S: b& f' ?% U#define CMD_SAFETY_DOOR '@'
& e5 [/ l1 Q& Y9 e# {" x+ K' v9 L: U, t) Y( r8 X! T- [1 l8 U+ @
// If homing is enabled, homing init lock sets Grbl into an alarm state upon power up. This forces0 V. s7 z$ V9 E  Y# V$ L+ p! R9 Y
// the user to perform the homing cycle (or override the locks) before doing anything else. This is
- J& B$ v  y$ {, l+ ~( q7 G; Q0 M1 s8 _// mainly a safety feature to remind the user to home, since position is unknown to Grbl.9 @3 R& l" O% n, b4 M, ]1 c

  u1 |2 e) B+ C0 w. v//如果启用了回原点,导航初始化锁集Grbl进入警报状态启动。这就迫使9 C5 k5 \9 ~; I2 B
//用户执行归航周期(或覆盖锁)在做任何其他事情之前。这是
. B, s* T( j, |* d% N4 |+ r$ c//主要安全功能,提醒用户家里,因为Grbl位置是未知的。; F1 d* x" ]( u4 r
; T% o% O# K1 N8 _. i+ D* U% t! C/ T
#define HOMING_INIT_LOCK // Comment to disable0 i+ M' t* c* l
3 |% m  p; M/ U7 T6 b0 v
// Define the homing cycle patterns with bitmasks. The homing cycle first performs a search mode
! q1 q2 L6 q- G3 p// to quickly engage the limit switches, followed by a slower locate mode, and finished by a short& G6 I7 S  Y. [+ E: `
// pull-off motion to disengage the limit switches. The following HOMING_CYCLE_x defines are executed
5 y4 D/ D3 F. W- m// in order starting with suffix 0 and completes the homing routine for the specified-axes only. If4 N7 {' n4 E3 F" V
// an axis is omitted from the defines, it will not home, nor will the system update its position./ b: M1 L. I) k5 _9 i
// Meaning that this allows for users with non-standard cartesian machines, such as a lathe (x then z,
8 \/ G6 X9 C% p, m// with no y), to configure the homing cycle behavior to their needs.
2 H( {/ p' q6 q8 Z* i// NOTE: The homing cycle is designed to allow sharing of limit pins, if the axes are not in the same
' a# s3 u) h5 L, U2 r4 R6 i// cycle, but this requires some pin settings changes in cpu_map.h file. For example, the default homing7 @6 a7 {* e- d2 j) J+ {& {
// cycle can share the Z limit pin with either X or Y limit pins, since they are on different cycles.
, i; E! G! c3 o5 I# W. }/ r/ K// By sharing a pin, this frees up a precious IO pin for other purposes. In theory, all axes limit pins0 O: B6 N) ^9 a, y0 j0 ~$ Y
// may be reduced to one pin, if all axes are homed with seperate cycles, or vice versa, all three axes' ~/ C7 ?& ~1 ^6 j7 f8 |1 q7 s
// on separate pin, but homed in one cycle. Also, it should be noted that the function of hard limits ! w5 Z- E3 b+ V! s! E  \% k9 H0 ~
// will not be affected by pin sharing.6 N8 w$ o% {! Q$ c0 z* i
//定义导航循环模式的位掩码。归航周期首先执行一个搜索模式% Y  ]. m" L! F
//快速进行限位开关,其次是较慢的定位模式,完成了由一个短
: o2 C5 j6 E# N$ Y2 e//拖出运动脱离限位开关。以下HOMING_CYCLE_x定义执行" ~" y$ w. p9 S: n2 w" o
//为了与后缀0开始并完成specified-axes只寻的例程。如果
# ^1 {: y5 c1 ], k( D& x' y//定义省略一个轴,它会不在家,也不会系统更新它的位置。: s) Q! ~2 j0 U9 c: ]% I
//意义,这允许用户与非标准笛卡尔的机器,比如车床(x,z,, G4 }+ Y9 s$ X% O
//没有y),配置导航循环行为对他们的需求。
2 X' E- u$ ]' t/ ^2 o( p//注意:归航周期允许共享限制针,如果轴不相同/ S3 {, X% a  q# i% k: }
//循环,但这需要一些销设置cpu_map的变化。h文件。例如,默认的导航
& [8 X5 T. D- X' Z. ?% f4 g+ {//循环可以分享Z限位销X或Y限制针,因为它们是在不同的周期。
/ I) J' V* q) I2 X# j//通过共享一个销,这腾出宝贵的IO销用于其他目的。从理论上讲,所有轴限制别针0 |* P, |3 @, C
//可能会减少到一个销,如果所有轴与分离周期居住的地方,反之亦然,所有三个轴
/ S# O; o1 ?  ~% c( Q//在不同销,但这时候一个周期。同时,应该注意的是,硬限制的功能
/ O0 O' U  p7 P3 E8 p//将不会影响销共享。
, O0 P/ h0 v8 i! m' L. v//注意:默认设置为一个传统的硬件数控机器。z轴首次明确,其次是X和Y。
) _$ n! ?7 Z/ |$ u. a- d( D
+ k" `/ e( F0 _8 U: ~- Q# i9 Q// NOTE: Defaults are set for a traditional 3-axis CNC machine. Z-axis first to clear, followed by X & Y.
$ k  i5 N: E/ {5 [#define HOMING_CYCLE_0 (1<<Z_AXIS)                // REQUIRED: First move Z to clear workspace. 第一步Z清除工作区。
' F. b% p, f7 M) L$ I/ g% Q! {#define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // OPTIONAL: Then move X,Y at the same time.然后X,Y在同一时间。' C5 ]: x# X, m! {
// #define HOMING_CYCLE_2                         // OPTIONAL: Uncomment and add axes mask to enable" F7 _+ n% l8 I/ g$ B/ e/ H

; w+ Q# W9 g: l( y" O// Number of homing cycles performed after when the machine initially jogs to limit switches.( s# ?% e$ j- ]/ L( d/ E" O# n
// This help in preventing overshoot and should improve repeatability. This value should be one or
& B+ v$ I) q7 W  [$ c/ x& x  ^// greater.
7 S) E$ V: z  |" Z$ b& s//执行回原点循环次数后,当机器最初慢跑限位开关。这个帮助防止过度,应该提高重复性。这个值应该是一个或大。) \0 {' Y# K. m
% C; _& S! Y! @# `2 I8 [
#define N_HOMING_LOCATE_CYCLE 1 // Integer (1-128)
3 T- o: v  V/ f3 w2 ~
. o+ N' ]( g/ j3 I/ d. Z0 R6 f9 b: x// After homing, Grbl will set by default the entire machine space into negative space, as is typical8 w0 d& E8 p4 L8 v# s
// for professional CNC machines, regardless of where the limit switches are located. Uncomment this 5 A& [5 Z! C, O1 K2 U, h% Q
// define to force Grbl to always set the machine origin at the homed location despite switch orientation.$ |* h, I( g4 |  ]/ x9 U. q" W

8 @/ y, C* g: i6 `//导航后,默认Grbl将整个机器空间留白,是典型的专业数控机器,不管限位开关所在的地方。
0 c' {) g8 L: s7 U9 l6 G3 H//取消这定义迫使Grbl总是在这时候位置设置机器原点尽管开关方向。
/ o/ Y% C' y$ B' J7 f! R0 ]" \8 H! U: x- c7 f2 }
// #define HOMING_FORCE_SET_ORIGIN // Uncomment to enable.
; k( r8 h9 M0 q! g) c5 f
! n" {7 V4 B8 g1 I* ~  E) K6 a5 a. j3 x
// Number of blocks Grbl executes upon startup. These blocks are stored in EEPROM, where the size. H. |4 @6 j$ P
// and addresses are defined in settings.h. With the current settings, up to 2 startup blocks may' }3 J/ F; i5 ^
// be stored and executed in order. These startup blocks would typically be used to set the g-code
. C2 W8 L5 J, P% [' F+ K// parser state depending on user preferences.- s8 p0 q+ z, p8 s

5 z; X3 d* R. D  r9 P$ o//块Grbl启动时执行的数量。这些块存储在eepm,大小
! t/ l* X- m$ y; H2 H//和地址在settings.h中定义。与当前设置,可能2启动块
  e9 d) [& H2 s//存储和执行。这些启动块通常被用来设置刀位点
7 S9 i9 L7 D- ?8 ~//解析器的状态取决于用户首选项。% K, j# l3 w  V& B$ n/ Y! v* b, t

& m# Y: M5 v  y! e4 x0 M, C& T% Z#define N_STARTUP_LINE 2 // Integer (1-2)$ H* ]/ f' L% c4 F4 F  R& o
: C0 P& J& J, P1 _0 N
// Number of floating decimal points printed by Grbl for certain value types. These settings are , j( Q# K, F" K0 c( ?
// determined by realistic and commonly observed values in CNC machines. For example, position# I& s4 N6 ~8 H% x! G$ |0 i8 j
// values cannot be less than 0.001mm or 0.0001in, because machines can not be physically more4 [, z1 A8 C& r5 E% ]
// precise this. So, there is likely no need to change these, but you can if you need to here.
% w$ i. E7 o5 g& A. {  r$ u// NOTE: Must be an integer value from 0 to ~4. More than 4 may exhibit round-off errors.7 D! b5 m4 J6 M$ [% l
% z& X, o2 R; ]
// Grbl浮动小数点的数字印刷的特定的值类型。这些设置是
3 p; r" V, I# ^0 j$ D  S* }//一般由现实和观测值在数控机器。例如,位置& i1 G% }6 n5 I9 U1 @+ x; o" X
//值不能小于0.001毫米或0.0001,因为机器不能身体更多& Y5 @  [7 n* d' e/ T, ?
//精确。因此,有可能不需要改变这些,但你可以在这里如果你需要。$ w% T! r/ u0 b2 p3 }' w$ J% h
//注意:必须是一个整数值从0 ~ 4。超过4可能出现舍入错误。
/ k" o8 F# _7 k2 @8 K2 Y9 |& e8 \$ o5 h8 t: O* Z7 |
#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 协调或位置价值英寸- ?: ~; T) [$ v6 c6 t: Y2 f9 T$ v
#define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 协调在毫米或位置价值
' q# ~, W; j1 C4 n: k#define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分钟的速度值
9 {0 \1 J" I0 k7 O#define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分钟. E/ E3 ~( K' W3 n$ g% P
#define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 对浮点小数设置值
. {" u, V+ U; u' T) ^
+ O; {3 ^8 ]& V. A// If your machine has two limits switches wired in parallel to one axis, you will need to enable
" S1 W* _( |  f6 ?// this feature. Since the two switches are sharing a single pin, there is no way for Grbl to tell
4 d  l# v" a/ _// which one is enabled. This option only effects homing, where if a limit is engaged, Grbl will
0 W2 V- M' h, P// alarm out and force the user to manually disengage the limit switch. Otherwise, if you have one, R4 t  e' N2 }3 S8 N; A' Q
// limit switch for each axis, don't enable this option. By keeping it disabled, you can perform a/ f. o% @& B" a0 v8 ^$ A/ A
// homing cycle while on the limit switch and not have to move the machine off of it.
" ]7 t1 F$ i/ }2 X3 h
; n" }1 K* E! S2 R% E) k* [//如果你的机器有两个极限开关连接在平行于一个轴,您需要启用" t5 f2 c2 Z' o8 ]# B5 c  X: |. M  G
//这个特性。自从两个交换机共享一个销,没有办法Grbl告诉! A; g9 Q0 q) I, C. k9 x: \
//启用哪一个。此选项仅影响归航,如果限制,Grbl意志
2 F8 ^4 i. N5 c- b  F1 I//报警,迫使用户手动松开限位开关。否则,如果你有一个
5 }- _. T1 T2 y' u//为每个轴限位开关,不启用该选项。通过保持禁用,您可以执行0 O( l/ `) X7 _, z
//导航循环在限位开关并没有将这台机器。. |9 c; G2 l. N1 n9 N! X7 K) y- T
# g! o+ p1 N& m
// #define LIMITS_TWO_SWITCHES_ON_AXES1 y0 w) o, b) [6 P: v0 ^5 w
" N1 C4 T) \. G2 F7 d  o
// Allows GRBL to track and report gcode line numbers.  Enabling this means that the planning buffer
0 b9 y9 y" s2 C, j' t// goes from 18 or 16 to make room for the additional line number data in the plan_block_t struct* Q. D( }+ l8 c! t# w# `" k: O
" `$ q' P% u6 m/ v) z/ n
//允许GRBL跟踪和报告gcode行号。使这意味着计划缓冲从18岁或16岁,为额外的行号plan_block_t结构中的数据
: f+ c3 Q8 L7 T. N( z/ G+ v( E9 |( l) c- ~! q" X
// #define USE_LINE_NUMBERS // Disabled by default. Uncomment to enable.1 j) d& ^/ S: h+ a% Y! l

0 w) u+ \( @" ^, E0 G) Y// Allows GRBL to report the real-time feed rate.  Enabling this means that GRBL will be reporting more
7 Y8 m' ~: o5 e* g// data with each status update.
% q* M- [) S" y3 f+ D// NOTE: This is experimental and doesn't quite work 100%. Maybe fixed or refactored later.$ w# c: H3 d! w( Q9 H, W
//允许GRBL报告实时进给速率。使这意味着GRBL将报告数据和状态更新。+ ?5 W& H7 V% z6 D( I6 t
//注意:这是实验和100%没有工作。也许以后固定或重构。
# }7 g" R8 c% O  n7 E" g; h3 y5 R' p8 Z' a6 b$ f8 p* D
// #define REPORT_REALTIME_RATE // Disabled by default. Uncomment to enable.+ E2 o. k  J9 k$ ^9 A! h1 ?9 }

5 d3 p) e" S1 V2 W// Upon a successful probe cycle, this option provides immediately feedback of the probe coordinates
) m. L2 F' G( n; F$ U" H// through an automatically generated message. If disabled, users can still access the last probe
5 g  B1 l( k; b+ Q) q& Y6 s1 O+ D// coordinates through Grbl '$#' print parameters.( U3 n- e6 c* h/ F
//在一个成功的调查周期,这个选项提供立即反馈的探测器坐标
3 r2 j& i1 n6 g, o- {5 A* E//通过一个自动生成的消息。如果禁用,用户仍然能够访问调查  F. I- O, E+ ]9 Y
//坐标通过Grbl $ #的打印参数。
/ [1 G; p9 m. ^" \0 m; @, X$ c
, n. }9 U' g' H0 u& f8 O#define MESSAGE_PROBE_COORDINATES // Enabled by default. Comment to disable.0 v6 B* |6 y# y7 R6 U
& E5 o6 H, M& U5 _
// Enables a second coolant control pin via the mist coolant g-code command M7 on the Arduino Uno. \% @' y6 g1 S. N1 T$ O- v+ O
// analog pin 5. Only use this option if you require a second coolant control pin.. \/ O& e4 i; l+ V
// NOTE: The M8 flood coolant control pin on analog pin 4 will still be functional regardless.
8 C0 v' X) r! t$ X// #define ENABLE_M7 // Disabled by default. Uncomment to enable.3 A4 s9 A0 R5 Z1 j+ U

- d0 t" S7 W- I4 X1 i// This option causes the feed hold input to act as a safety door switch. A safety door, when triggered,
$ r5 y- [, z% L8 k// immediately forces a feed hold and then safely de-energizes the machine. Resuming is blocked until
. a9 N9 K% p% A; i. ~& Q% g& n// the safety door is re-engaged. When it is, Grbl will re-energize the machine and then resume on the8 m" v$ Z# G$ p5 a/ d* r
// previous tool path, as if nothing happened.
2 c+ R+ Z0 x) K6 @// #define ENABLE_SAFETY_DOOR_INPUT_PIN // Default disabled. Uncomment to enable.
( n$ r8 h6 E( B- y& {& _% I4 m' A4 ~
" U  k& ~# |, C: ^( G+ h// After the safety door switch has been toggled and restored, this setting sets the power-up delay' T: r: j$ d9 G! _
// between restoring the spindle and coolant and resuming the cycle.. Q8 _+ p3 v( \* ]5 w
// NOTE: Delay value is defined in milliseconds from zero to 65,535. : o9 t. P6 R, ?

+ f. l- }- o; l" G- ~+ u3 [//定义导航循环模式的位掩码。归航周期首先执行一个搜索模式6 A1 F% o& G5 P: B& s/ E/ M
//快速进行限位开关,其次是较慢的定位模式,完成了由一个短
0 A. h( D7 R- v( f. H  t( w% ]//拖出运动脱离限位开关。以下HOMING_CYCLE_x定义执行
" t% z; q7 Z0 P, S3 ~8 p2 W- b//为了与后缀0开始并完成specified-axes只寻的例程。如果
; F6 D5 Y4 x+ e6 ~$ D) O/ u//定义省略一个轴,它会不在家,也不会系统更新它的位置。
! B3 n, M" n( z9 D. A% g//意义,这允许用户与非标准笛卡尔的机器,比如车床(x,z,
  s9 d1 v7 q- N) n- q0 j' D. D8 J; w//没有y),配置导航循环行为对他们的需求。
5 E5 M* ^: @  I+ ^//注意:归航周期允许共享限制针,如果轴不相同
- u- x& ^; |  R) `1 p! S//循环,但这需要一些销设置cpu_map的变化。h文件。例如,默认的导航
8 W6 w# I- W# |  ~7 _( r//循环可以分享Z限位销X或Y限制针,因为它们是在不同的周期。. B) ^5 u0 G# U+ P6 ^8 H, o
//通过共享一个销,这腾出宝贵的IO销用于其他目的。从理论上讲,所有轴限制别针
6 Z6 t  |8 O! M2 `//可能会减少到一个销,如果所有轴与分离周期居住的地方,反之亦然,所有三个轴8 [7 j! `0 ]# [' ]' Z5 C; G) b( ]
//在不同销,但这时候一个周期。同时,应该注意的是,硬限制的功能2 [3 c/ l# c% Y3 {
//将不会影响销共享。
) H* j9 v* U2 y, M( W//注意:默认设置为一个传统的硬件数控机器。z轴首次明确,其次是X和Y。
: U) d4 F# D( M6 g/ L8 @8 _* X
; Z# j5 r9 e8 {( Y* o5 w8 w
1 F0 ?8 @. K; x& {+ [8 K2 {/ b6 i#define SAFETY_DOOR_SPINDLE_DELAY 4000
" [( R! _& N4 e& r# F  e! v) O#define SAFETY_DOOR_COOLANT_DELAY 1000
5 F8 c8 p# A5 B4 n6 ?! O4 B3 }! p4 \/ o; H
// Enable CoreXY kinematics. Use ONLY with CoreXY machines.
2 Y2 @4 N: H: a// IMPORTANT: If homing is enabled, you must reconfigure the homing cycle #defines above to : A0 ?- c; E( t3 S6 U
//启用CoreXY运动学。只使用与CoreXY机器。' ~) p7 i0 x9 i: q! q
//重要:如果启用了自动寻的,你必须重新配置导航循环#定义上面
$ W8 h. f# v' J* d/ U
7 ~% g; J6 @! G  S// #define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS). D% G/ R! Y, h* U. E
8 n7 p* A, s& V8 ]' s  n0 e+ v1 B* q
// NOTE: This configuration option alters the motion of the X and Y axes to principle of operation
: H" [+ S5 E( N$ h// defined at (http://corexy.com/theory.html). Motors are assumed to positioned and wired exactly as
7 d$ O; i) E4 W4 H$ M. V// described, if not, motions may move in strange directions. Grbl assumes the CoreXY A and B motors) C- O9 T1 H/ d! E- Y2 j6 u
// have the same steps per mm internally.# p3 h4 h. m+ L
//注意:这种配置选项改变X和Y轴的运动原理,操作
' G! r9 C9 q2 J. H. P/ M! G9 `1 F/ e//定义(http://corexy.com/theory.html)。汽车被认为定位和连接一样
- V0 [7 y& {2 q//描述,如果没有,运动可能会奇怪的方向移动。A和B Grbl假设CoreXY马达, \% @4 r; E) r2 N+ B+ d
//每毫米内部有相同的步骤。
  h* i8 r. U# \! ]$ ^9 A
3 h$ g  a" a6 {! k: Z' Z// #define COREXY // Default disabled. Uncomment to enable.8 Z9 r' }8 g0 i  p
, M( b; o, W9 q$ S
// Inverts pin logic of the control command pins. This essentially means when this option is enabled# F3 T+ x1 z/ C( ^% ^3 {  w
// you can use normally-closed switches, rather than the default normally-open switches.
' Z" ]( K$ W4 N' P; @0 f// NOTE: Will eventually be added to Grbl settings in v1.0.
7 I/ [3 {( j) Z2 g//反转针销逻辑的控制命令。这实质上意味着当启用这个选项* H5 b1 O& W, K$ \* C
//可以使用闭合开关,而不是默认的常开开关。
7 A1 M, i3 t9 F6 r//注意:最终将被添加到在v1.0 Grbl设置。
! H# z/ D% i* ^. Y9 v6 v
3 M, I% ]. E. G! |* [% o* s// #define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.! x9 b/ ^1 v# \1 h7 N, n/ l
5 h! F! g0 A7 b2 W
// Inverts the spindle enable pin from low-disabled/high-enabled to low-enabled/high-disabled. Useful
/ @' h9 b3 ~4 T# g- k: g* {// for some pre-built electronic boards.; w; _* H; \0 @$ [% C
// NOTE: If VARIABLE_SPINDLE is enabled(default), this option has no effect as the PWM output and ! J- |- ~7 O) n+ d* ?# U+ Q
// spindle enable are combined to one pin. If you need both this option and spindle speed PWM, 2 E* Z4 a! s: t) ?6 J
// uncomment the config option USE_SPINDLE_DIR_AS_ENABLE_PIN below.
. C7 s5 t+ h5 \# ~' ~4 {' i4 K) E//反转主轴使销从low-disabled / high-enabled low-enabled / high-disabled。有用的: N$ s2 B6 {9 D( v# o$ {6 P$ K
//预构建的电子板。
+ c: q: ^$ M, c* L$ i8 ]//注意:如果启用了VARIABLE_SPINDLE(默认),这个选项作为PWM输出并没有影响/ ]1 N2 Z  [  y& Z1 t6 K
//销轴使结合。如果你需要这个选项和主轴转速PWM,5 Z: ?! R& Q- f0 q+ W- j( v' K
//取消注释以下配置选项USE_SPINDLE_DIR_AS_ENABLE_PIN# P( |) M* _+ o' P& ^8 |2 Z" f
# R. a4 M1 \$ w0 r
// #define INVERT_SPINDLE_ENABLE_PIN // Default disabled. Uncomment to enable.
- q, o- M* t! _$ C7 A$ q0 n4 v$ X1 J' `% _) L! z
// Enable control pin states feedback in status reports. The data is presented as simple binary of
- e9 z( B, v+ R3 Y# G// the control pin port (0 (low) or 1(high)), masked to show only the input pins. Non-control pins on the 1 O# F$ T3 o1 T* F$ o* g
// port will always show a 0 value. See cpu_map.h for the pin bitmap. As with the limit pin reporting,9 Y4 U7 o9 X2 u( f  x
// we do not recommend keeping this option enabled. Try to only use this for setting up a new CNC.$ C3 _+ @7 ]& X" j2 P% j
//启用控制销状态反馈状态报告。作为简单的二进制数据
( b: G( _6 M! }; n$ O& n//控制针端口(0(低)或1(高)),蒙面,只显示输入插脚。非控制性针上/ O: Y7 L- Z: \
//端口总是显示0值。看到cpu_map。针位图h。与限制销报告,) d4 h  Y4 `2 N' y) W
//我们不推荐保持启用这个选项。尽量只使用这个设置一个新的数控。9 t4 }' o: m" \; _$ @

8 _6 M* L# h6 J& R) z0 Q// #define REPORT_CONTROL_PIN_STATE // Default disabled. Uncomment to enable.2 a4 }( v5 Z% R, r1 E  c0 \

4 }2 |* \1 J* d9 \// When Grbl powers-cycles or is hard reset with the Arduino reset button, Grbl boots up with no ALARM
# o- M; m, d& w4 d9 J// by default. This is to make it as simple as possible for new users to start using Grbl. When homing9 N5 D  i& P# h8 x4 E7 j
// is enabled and a user has installed limit switches, Grbl will boot up in an ALARM state to indicate
$ w5 v. I# f4 I  ^// Grbl doesn't know its position and to force the user to home before proceeding. This option forces; @# e9 s+ i6 o+ f
// Grbl to always initialize into an ALARM state regardless of homing or not. This option is more for/ N& t; A" K; ^) p$ D# I
// OEMs and LinuxCNC users that would like this power-cycle behavior.; x) M- ~; C' o- z) _4 D! \6 L6 q
//当Grbl powers-cycles还是硬重置Arduino复位按钮,Grbl启动没有报警
4 B; [; a. }$ v9 R& \9 d//默认情况下。这是为了让新用户尽可能简单使用Grbl开始。当归航
  c9 n" Q4 O) y//启用和用户安装限位开关,Grbl将启动报警状态指示
/ F6 ^; B# k4 J; @" F" K// Grbl不知道它的位置,迫使用户在继续之前回家。这个选项部队, z7 D0 N8 W& }9 ]$ L. M8 ]
// Grbl总是初始化进入警报状态不管归航。这个选项是更多* I+ m1 [. x4 R( t* G: d% `" q
//原始设备制造商和LinuxCNC用户这样的控制行为。. @2 E7 ]* f* V/ U7 L3 _- k9 o, R
% s7 \" f# Q8 L/ ?$ x
// #define FORCE_INITIALIZATION_ALARM // Default disabled. Uncomment to enable.* M/ Z) q, E+ [: w, u. i
" L4 q5 `4 R) J4 }6 h+ n/ G9 O4 ~; \7 s
// ---------------------------------------------------------------------------------------6 A, c  B% X' }4 [  D
// ADVANCED CONFIGURATION OPTIONS://高级配置选项:
( o; S- r6 p. x: @( f- b- j( |: v  p
: f8 v/ Q5 d1 q! z// Enables minimal reporting feedback mode for GUIs, where human-readable strings are not as important.
9 ~8 v  |. j3 H// This saves nearly 2KB of flash space and may allow enough space to install other/future features.) Q& }, P0 p# K) [6 X
// GUIs will need to install a look-up table for the error-codes that Grbl sends back in their place.* K- t/ K/ B" l4 h9 ~$ K, \( ~; Z
// NOTE: This feature is new and experimental. Make sure the GUI you are using supports this mode.
; u9 ?/ g1 C( v! L$ _, J  S& E5 ?, V
// gui允许最小的报告反馈模式,人类可读的字符串在哪里不重要。& A6 O, B' b9 t
//这个节省近2 kb的闪存空间,允许足够的空间来安装其他/未来的功能。- X% ^: C( j2 i' A% @
// gui需要安装一个查找表的错误代码Grbl发回。
6 b: ~# _, k7 x/ A; f% V- r5 j//注意:此功能是新的和实验。确保您使用的GUI支持这种模式。
1 h3 @' Q6 K5 E9 ?  r) D
" i0 C+ |& L: Q( e- l7 g// #define REPORT_GUI_MODE // Default disabled. Uncomment to enable.) O) x! H+ P, j4 K! n$ Y& l- h+ i1 S0 X

: H- V& G2 d* Q// The temporal resolution of the acceleration management subsystem. A higher number gives smoother
/ k1 I; ?2 r' x3 F$ z// acceleration, particularly noticeable on machines that run at very high feedrates, but may negatively
. K9 U) Y0 Z1 u% J// impact performance. The correct value for this parameter is machine dependent, so it's advised to1 S! j  {* x, ?% `" h0 I0 W; |
// set this only as high as needed. Approximate successful values can widely range from 50 to 200 or more.
& o% M: E: r4 d& U9 }5 T% e// NOTE: Changing this value also changes the execution time of a segment in the step segment buffer.
+ G3 T$ [+ o* B; A( H// When increasing this value, this stores less overall time in the segment buffer and vice versa. Make
/ @* _& c3 S. t// certain the step segment buffer is increased/decreased to account for these changes.
- s" L0 P& J5 I+ C. I& f//加速度的时间分辨率管理子系统。更多更平稳* {3 E) l/ \8 \& J, T
//加速度,特别明显的机器上,运行在非常高的进料速度,但可能负面
, @$ p1 f7 W9 \//影响性能。正确的值为这个参数是依赖于机器的,所以建议0 S+ H9 L9 N+ y# I9 [8 e# v3 F5 m0 L
//这只设置为高。近似成功的价值观可以广泛的范围从50到200或者更多。% D/ u1 {3 J. I8 Q. p4 d* v5 e
//注意:改变这个值也变化的部分步骤的执行时间缓冲。
3 M$ F: E- r& J; S  _$ w1 Y7 t# p//增加这个值时,这个商店部分缓冲区的总时间减少,反之亦然。使
! S- t& S# ~' U& W//特定步骤段缓冲是考虑这些变化增加/减少。
) f, u* q- V) F1 F& Z% _* w( h! q5 b7 ~( T/ n
#define ACCELERATION_TICKS_PER_SECOND 100  //加速度的时间分辨率管理子系统。更多更平稳) u0 j. x) s' d

! S/ B0 Q& n, J) W+ y: H6 x2 b// Adaptive Multi-Axis Step Smoothing (AMASS) is an advanced feature that does what its name implies,
) {) d( N2 A- V* ^// smoothing the stepping of multi-axis motions. This feature smooths motion particularly at low step
# _' N. t/ d  T// frequencies below 10kHz, where the aliasing between axes of multi-axis motions can cause audible # M/ r1 A+ i. W* x8 _5 k. ~: t) l
// noise and shake your machine. At even lower step frequencies, AMASS adapts and provides even better
! O* ^' V: v% _( E/ C2 O// step smoothing. See stepper.c for more details on the AMASS system works.# d) E7 H; b6 N# Q9 u2 k1 l0 S
//自适应多轴步平滑(积累)是一种先进的功能,它的名字所暗示的那样,- @6 f. H# g% P4 f( F2 V! l6 N4 N
//平滑的多轴步进运动。这个特性平滑运动尤其是在低一步
) [, R% V/ T. x: |# l1 s//频率低于10 khz,轴之间的混叠的多轴运动可能导致音响
: F/ N* D4 C/ O//噪音和震动你的机器。在更低的频率步,积累适应并提供更好0 T% E% J, r: b: d- N0 m1 e
//步骤平滑。看到步进。c更多细节的积累系统的工作原理。
: I' k8 n' {. c5 |' `4 M7 D9 G  \( B) ~: N+ c$ ?  d; ~% ]. _
#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING  // Default enabled. Comment to disable.//自适应多轴步平滑0 \$ v: m! ^" {2 E. @# y
, u& b5 s) Y( R6 W# g
// Sets the maximum step rate allowed to be written as a Grbl setting. This option enables an error 0 t- u( S) y7 r
// check in the settings module to prevent settings values that will exceed this limitation. The maximum; S6 f' h% v; Y' h8 B. o$ d' C$ U
// step rate is strictly limited by the CPU speed and will change if something other than an AVR running
5 h' p  F' }5 `, H2 p// at 16MHz is used.
8 j# c1 a* _4 X// NOTE: For now disabled, will enable if flash space permits.
6 i6 ]1 J7 `# q0 s  D; A0 }//设置最大一步速率可以写成Grbl设置。这个选项可以使一个错误
/ P0 y* U, ?5 U# y# E1 M+ M, m//设置模块中检查,防止设置值将超过这个限制。的最大
% ~" Y3 {. M  v& L//步骤严格限制的CPU速度也会改变如果是其他AVR运行
% m+ [( o3 L6 S; m//使用16兆赫。
  h4 S! y5 P2 X. _. e+ c//注意:现在残疾,将使如果flash空间许可。
1 n1 s( K3 A: {' [0 V) ?$ l2 {# _; B9 o3 s  X
// #define MAX_STEP_RATE_HZ 30000 // Hz 设置最大一步速率
3 U/ m+ z$ o+ @* ~9 @9 K: h" B# @0 M3 ?6 b7 M! h) b
// By default, Grbl sets all input pins to normal-high operation with their internal pull-up resistors: q: H2 l7 e  n$ p$ p4 z
// enabled. This simplifies the wiring for users by requiring only a switch connected to ground,
% w: M+ A) J% n' q' m$ H; Q// although its recommended that users take the extra step of wiring in low-pass filter to reduce& D1 {: Y4 ~/ B- m, Q) Y$ n% _0 B
// electrical noise detected by the pin. If the user inverts the pin in Grbl settings, this just flips
% _: F4 ?1 [. a" j* G// which high or low reading indicates an active signal. In normal operation, this means the user ! Y5 f$ ]& t9 i5 g  M; D3 ?3 g4 {
// needs to connect a normal-open switch, but if inverted, this means the user should connect a ( h4 S' U8 S; i' b  T
// normal-closed switch. " u1 k- H: q7 K
// The following options disable the internal pull-up resistors, sets the pins to a normal-low
7 A3 F: E: S. ?1 X  G0 Q3 a// operation, and switches must be now connect to Vcc instead of ground. This also flips the meaning 7 {4 S+ N' m6 H6 Y
// of the invert pin Grbl setting, where an inverted setting now means the user should connect a
+ O: ]: D3 v: M) ~2 o' |& a1 C// normal-open switch and vice versa.* j- e7 B# d( Z8 z3 W; ]  i$ x
// NOTE: All pins associated with the feature are disabled, i.e. XYZ limit pins, not individual axes.  t" H, V" T1 ?4 Z3 G! H# U2 u
// WARNING: When the pull-ups are disabled, this requires additional wiring with pull-down resistors!
0 ]0 c+ d$ _& s//默认情况下,Grbl所有输入引脚设置为正常高操作的内部上拉电阻7 g; X2 |; D) Z
//启用。这简化了布线为用户只需要一个开关连接到地面,* V& D* |2 H$ P7 ~$ r
//虽然其建议用户采取额外的步骤,在低通滤波器来减少布线5 Z2 v4 b6 m9 Z% _: Z
//电噪音检测销。如果用户反转的销Grbl设置,这只是翻转
) s# G& u6 l3 m//读高或低表明一个积极的信号。在正常操作中,这意味着用户7 z$ B  F6 l( J# N. B* s& R
//需要连接一个常开开关,但如果倒,这意味着用户应该连接
+ {3 S, }0 X! b' t) X; {: a' u// normal-closed开关。
% P$ e, V/ r: I6 t9 v1 d//以下选项禁用内部上拉电阻,一般低设置别针
; ]% u1 d; v) i& q//操作,现在开关必须连接到Vcc代替地面。这也掀的意思
: b2 F6 Z* a6 r% t//反销Grbl设置,一个倒置的设置现在意味着用户应该连接/ Y) h* B* L7 K& H/ A
//常开开关,反之亦然。. q+ Z3 B1 m6 u- l
//注意:所有针与功能被禁用,例如XYZ限制针,而不是单独的轴。' ^" S3 `( ~0 ^) ^
//警告:引体向上被禁用时,这需要额外的布线与下拉电阻!/ |3 Y4 D' k1 @8 L. c" s9 I
- Y& f6 G$ O* }: n, T% }" p& h# _
//#define DISABLE_LIMIT_PIN_PULL_UP //以下选项禁用内部上拉电阻
$ u, o  w) g. ~  u' ]4 [( j//#define DISABLE_PROBE_PIN_PULL_UP% L3 ?% j8 }+ r9 W/ h$ L
//#define DISABLE_CONTROL_PIN_PULL_UP6 ^5 w8 n4 ]8 A+ K* }% k3 E
4 Y, o. A" n  q/ q( T/ ~& P5 V
// Sets which axis the tool length offset is applied. Assumes the spindle is always parallel with 4 U9 Y! H; l# t9 J& N
// the selected axis with the tool oriented toward the negative direction. In other words, a positive
- P% s; t4 w$ R3 G* b2 ?0 |// tool length offset value is subtracted from the current location.9 E. K) J4 H: n, U$ G& {5 x
//设置哪个轴长度补偿应用的工具。假设轴总是与
1 h' z) V% u7 h  u* J2 w3 R//选择轴工具面向负方向。换句话说,一个积极的
8 n  W7 ]" A/ O" t; Q//工具长度偏移值减去从当前位置。1 ^! `& K1 w. r" Y1 e

0 E( }* u" s2 v& D#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS // Default z-axis. Valid values are X_AXIS, Y_AXIS, or Z_AXIS.设置哪个轴长度补偿应用的工具
* B) o* ?- |: M! i8 f5 S  f
8 V2 q3 S, r1 y( V// Enables variable spindle output voltage for different RPM values. On the Arduino Uno, the spindle
, t% Y! Q" J- [) _: w( d, g1 v// enable pin will output 5V for maximum RPM with 256 intermediate levels and 0V when disabled.* v4 X) a! b2 l" Q2 K+ }
// NOTE: IMPORTANT for Arduino Unos! When enabled, the Z-limit pin D11 and spindle enable pin D12 switch!. y5 ?) ^; k" }2 S0 L' L6 p
// The hardware PWM output on pin D11 is required for variable spindle output voltages.+ m1 |; m) {4 u: o
//允许变量轴输出电压不同的转速值。Arduino Uno,主轴
- B7 R9 r( k% k5 Z$ S- ^, ]- r//启用销将输出5 v的最高转速256中级水平和0 v时禁用。" m; _8 l* D) ~1 l4 t" x
//注意:重要Arduino凯泽本人!当启用时,Z-limit销这里和轴销D12开关!  r# t: K5 r! q; T# [( i1 p
//硬件PWM输出销这里需要变量轴输出电压。: C8 p+ y0 B- T6 H+ b$ e! _

8 h# R7 W+ Z* \#define VARIABLE_SPINDLE // Default enabled. Comment to disable.//允许主轴输出电压不同的转速值+ q- Y* B" V/ t" R6 F7 S; \3 ^

% z$ V0 Y& F( e  u6 S// Used by the variable spindle output only. These parameters set the maximum and minimum spindle speed7 [. [1 g. d, h! a6 U' B; i" f
// "S" g-code values to correspond to the maximum and minimum pin voltages. There are 256 discrete and
3 N' m: S/ Q5 u/ b, l0 p* g8 }0 S// equally divided voltage bins between the maximum and minimum spindle speeds. So for a 5V pin, 1000
7 i, g1 h1 p2 x6 d* ~// max rpm, and 250 min rpm, the spindle output voltage would be set for the following "S" commands: , [$ c5 F$ z3 D. k1 ^
// "S1000" @ 5V, "S250" @ 0.02V, and "S625" @ 2.5V (mid-range). The pin outputs 0V when disabled.
% t3 m1 L1 o3 [1 \//使用的变量轴输出。这些参数设置最大和最小轴转速/ d  Z' n3 E- u, ?4 n- j! ~
//“S”刀位点值对应于销电压的最大值和最小值。有256个离散和
# ]( t+ H9 D( F0 e4 h* V//电压平均分配箱主轴速度的最大值和最小值之间。所以对于一个5 v销,1000! r8 w; b# j' h5 W
// max rpm,250分钟rpm,主轴输出电压将为以下“S”命令:
6 W% Z4 @( @' l// @“S1000 5 v,“S250”@ 0.02 v,“S625”@ 2.5 v(中档)。销输出0 v时禁用。6 a6 E, u! u* }: ?+ J
3 u" p: C6 Y' ?1 `# ^
#define SPINDLE_MAX_RPM 1000.0 // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.+ s" J6 O3 N7 h+ b$ l' K- }8 n
#define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.6 C( p* ^" |* U. [, I
6 s! F- }8 ?$ i. t
// Used by variable spindle output only. This forces the PWM output to a minimum duty cycle when enabled.
9 ?5 R3 v  |$ g// When disabled, the PWM pin will still read 0V. Most users will not need this option, but it may be 2 Q7 p6 e- [3 ^4 Y
// useful in certain scenarios. This setting does not update the minimum spindle RPM calculations. Any
8 w, E% Y$ o! F/ u3 Y// spindle RPM output lower than this value will be set to this value.# P- e! g3 C/ N6 h8 `  y3 F
//使用的变量轴输出。这迫使PWM输出最小占空比时启用。4 [% c( {3 W5 U* K9 F# I& R
//当禁用,PWM销仍读0 v。大多数用户不需要这个选项,但是它可能是
* c1 o' G' b1 n" ]9 R//在某些情况下很有用。这个设置不会更新最小主轴转速计算。任何
# m( R- d' \$ x" ^! b5 h//输出轴转速低于这个值将被设置为这个值。
4 b0 V. G( R  _/ |5 `2 h. r$ g! a$ S/ Q5 H# J$ E9 o+ ^5 N) p
// #define MINIMUM_SPINDLE_PWM 5 // Default disabled. Uncomment to enable. Integer (0-255)! \: T9 |( v+ y) A& P. g! O

5 W, \+ J) E" |  n& L// By default on a 328p(Uno), Grbl combines the variable spindle PWM and the enable into one pin to help % j5 E) o0 x: Y) Y0 v
// preserve I/O pins. For certain setups, these may need to be separate pins. This configure option uses
7 A' G; c" H# X5 V2 N7 ?3 S$ {# C5 b* `// the spindle direction pin(D13) as a separate spindle enable pin along with spindle speed PWM on pin D11. 1 B7 G. A6 v- O- G) G
// NOTE: This configure option only works with VARIABLE_SPINDLE enabled and a 328p processor (Uno).
* f. N' L  G% I9 M! b// NOTE: With no direction pin, the spindle clockwise M4 g-code command will be removed. M3 and M5 still work.7 O/ O3 ]. {* ]: J5 _) z
// NOTE: BEWARE! The Arduino bootloader toggles the D13 pin when it powers up. If you flash Grbl with  L/ p' ?9 I. c9 u5 z
// a programmer (you can use a spare Arduino as "Arduino as ISP". Search the web on how to wire this.),
; u: g( }$ T  q$ J; b2 i, i, g// this D13 LED toggling should go away. We haven't tested this though. Please report how it goes!* h0 m  G3 J. r  m
//默认ATmega328 p(Uno),Grbl结合变量轴PWM和使到一个销的帮助
; b. P( g; _: Z! s- p5 D% r& k//保存I / O管脚。对于某些设置,这些可能需要单独的别针。这个配置选项使用
( {8 ?% j. U3 o; L" O: h2 i" E; v//方向轴销(D13)作为一个单独的轴销上启用销以及主轴转速PWM这里。
0 u4 y3 [& ^/ u& D3 m( I//注意:该配置选项仅适用于VARIABLE_SPINDLE启用和328 p处理器(Uno)。. b# D: n- C% ]1 R2 w7 I+ E" H! I
//注意:没有方向销,主轴顺时针M4刀位点命令将被删除。M3和M5仍然工作。! D, n' v. I7 A4 b+ c# O6 V3 J1 i: Y: C
//注意:小心!Arduino引导装载程序切换D13销的权力。如果flash Grbl
$ P4 I/ [: g5 i' o7 J1 e" f5 w//程序员(您可以使用一个备用Arduino“Arduino ISP”。搜索网络如何线),
4 f, X8 q9 h, p' [( D0 s0 W//这D13导致切换应该消失。我们还没有测试这个。请报告将会怎样!
5 p; a: N0 h: ]% E! N. E: w, ~; d, m1 I1 V- n' I( |  E8 |
// #define USE_SPINDLE_DIR_AS_ENABLE_PIN // Default disabled. Uncomment to enable.
- j4 \8 n" d" B8 \
/ F( b  M0 Y3 m# z& z% N; r// With this enabled, Grbl sends back an echo of the line it has received, which has been pre-parsed (spaces' y1 h1 P0 g; h9 |
// removed, capitalized letters, no comments) and is to be immediately executed by Grbl. Echoes will not be ; }/ @: q, Z; ?
// sent upon a line buffer overflow, but should for all normal lines sent to Grbl. For example, if a user
  B- u; t6 x- m1 S// sendss the line 'g1 x1.032 y2.45 (test comment)', Grbl will echo back in the form '[echo: G1X1.032Y2.45]'.
5 j/ n0 _' p+ N6 D4 b9 I// NOTE: Only use this for debugging purposes!! When echoing, this takes up valuable resources and can effect/ A* d* F' Z: I# W: u% m
// performance. If absolutely needed for normal operation, the serial write buffer should be greatly increased
) ^: @/ y  u5 E4 M7 U' a) ~+ \// to help minimize transmission waiting within the serial write protocol.
. E- T( u# u0 R& J3 Q8 g5 I+ g
//启用,Grbl发回的回声线已收到,已预编译(空间
( y  Z; d% u1 Z/ V. ~//移除,大写字母,没有评论),由Grbl立即执行。回声将不会9 `( @+ @8 m7 P7 P6 {( o7 Y3 X
//发送一个线缓冲区溢位,但应该对所有正常线路送到Grbl。例如,如果一个用户* L8 f- s% y: I% i% B1 w
//发送线的g1 x1.032 y2.45(测试评论)形式”,Grbl将回声”(回声:G1X1.032Y2.45]”。
! z7 F8 d* Y' ~1 R//注意:只使用这个调试! !当呼应,这占用了宝贵的资源,可以影响* \( i: x& o; E) Y8 q/ d
//性能。如果正常运行所需的绝对,串行写入缓冲器应该大大增加
$ Z6 X' s! P! N# p//帮助最小化传输等系列内写协议。0 ^1 a& K- o- B! p; T

# E( ]( c  f4 S) r. J, O// #define REPORT_ECHO_LINE_RECEIVED // Default disabled. Uncomment to enable.
5 Q4 c5 S8 W+ Q3 x
6 w" o3 n6 h: h8 w$ Y// Minimum planner junction speed. Sets the default minimum junction speed the planner plans to at8 R; d7 `% w( \
// every buffer block junction, except for starting from rest and end of the buffer, which are always
( ?1 I5 `8 g$ K* t$ x# s// zero. This value controls how fast the machine moves through junctions with no regard for acceleration
3 b4 d. y% b$ r// limits or angle between neighboring block line move directions. This is useful for machines that can't
+ |: t( Q- b; R: E// tolerate the tool dwelling for a split second, i.e. 3d printers or laser cutters. If used, this value
) \  b  ^8 j6 _* D* S& Z0 u6 G// should not be much greater than zero or to the minimum value necessary for the machine to work.  B' P* }0 o+ V5 E
- D, j! C3 }5 X- |( [
//最小规划师结速度。设置默认最小连接速度规划计划
! I0 ]/ O) P* D. b8 I//每一个缓冲块接头,除了从结束休息和缓冲区,它总是
" z) w+ w( Y+ j// 0。这个值控制机器的速度穿过路口,没有考虑加速度. ~/ a  X' {5 u
//限制或相邻块之间的角线方向移动。这是有用的机器,不能, N# J6 \3 L& ~8 A$ ]7 d
//容忍工具居住某一刹那,即3 d打印机或激光切割机。如果使用这个值
- K- i+ t" u7 D6 |$ j//不应大于零或机器工作所需的最小值。
2 Y# r6 B0 Y* C0 V: V  m8 j7 e: O9 L) K  i. G6 N
#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min)/ @# D* g3 ?# u8 a4 [3 q
  ?- b/ [* `9 ?( Q5 q) Y0 k1 n7 b1 S
// Sets the minimum feed rate the planner will allow. Any value below it will be set to this minimum
+ l7 G: U% E* \9 D// value. This also ensures that a planned motion always completes and accounts for any floating-point
1 _/ Q3 |9 E. ~1 Q$ h// round-off errors. Although not recommended, a lower value than 1.0 mm/min will likely work in smaller* _. x  n2 z6 i+ E. `
// machines, perhaps to 0.1mm/min, but your success may vary based on multiple factors.% K9 e/ w  b, h
//设置计划将允许的最小进给速率。任何价值低于它将被设置为最低值。这也保证了运动计划总是完成,占任何浮点
* V# V# O, r3 u//舍入错误。虽然不推荐,价值低于1.0毫米/分钟可能会在较小的工作
* v" o' O7 v" P: @7 n6 A1 n//机器,也许到0.1毫米/分钟,但你的成功基于多种因素可能会有所不同。
/ k, w2 b5 F$ w5 g( ?  h# \$ C: y; n" w0 x: C# v* A& a# W  M+ ?
#define MINIMUM_FEED_RATE 1.0 // (mm/min)//设置计划将允许的最小进给速率
1 `+ X$ e- y2 O: Y7 A0 I- P
8 |+ \5 p" G% S5 d& L  w  h// Number of arc generation iterations by small angle approximation before exact arc trajectory
  q7 F; v! B8 O& J6 ~, A7 a) H8 M- g. x5 b// correction with expensive sin() and cos() calcualtions. This parameter maybe decreased if there
  Z" G8 A  h* \" h* R// are issues with the accuracy of the arc generations, or increased if arc execution is getting
: S- j4 g; d2 O// bogged down by too many trig calculations.
9 h' y' P: P" W# f+ S//弧生成迭代次数之前小角度近似精确的弧线轨迹( q$ U, N2 B* w& _
//修正与昂贵的sin()和cos()calcualtions。如果有这个参数可能减少
8 d+ N) S7 m# H; N; S+ d//与弧一代又一代的准确性问题,或如果电弧执行得到增加
# L# z& k4 W4 g  d. \//太多的三角计算的泥潭。  ^0 e( |$ V1 D! t0 O# |( z2 |+ N  e

; ]* K1 w. ~4 W, R& Z) O# U#define N_ARC_CORRECTION 12 // Integer (1-255)
. A; j* I& s+ \" f
% o4 p4 b6 [* B3 w4 H+ s// The arc G2/3 g-code standard is problematic by definition. Radius-based arcs have horrible numerical
/ Z; F2 A- k9 B& b. R' z0 X5 v// errors when arc at semi-circles(pi) or full-circles(2*pi). Offset-based arcs are much more accurate $ w+ l9 b: e9 M/ F2 d6 ^$ D
// but still have a problem when arcs are full-circles (2*pi). This define accounts for the floating
" Y7 j+ v2 s. ]; p+ J// point issues when offset-based arcs are commanded as full circles, but get interpreted as extremely
" |1 d+ G- r& A1 \* y% T// small arcs with around machine epsilon (1.2e-7rad) due to numerical round-off and precision issues.9 u+ m8 v1 F1 U! Q" @# v
// This define value sets the machine epsilon cutoff to determine if the arc is a full-circle or not." ~4 W9 X7 I. T3 V6 W
// NOTE: Be very careful when adjusting this value. It should always be greater than 1.2e-7 but not too6 q) G! J. Y2 j+ n2 Z2 Q" w
// much greater than this. The default setting should capture most, if not all, full arc error situations.; |5 M' n! x* @. k# M0 S# h" v! S
//弧G2/3刀位点的标准定义是有问题的。Radius-based弧有可怕的数值6 Y4 s5 x% |' h
//错误当电弧在半圆(π)或原点(2 *π)。Offset-based弧更准确
2 s5 G9 A' C& S* U5 O5 j5 B//但仍有一个问题当弧原点(2 *π)。这个定义占浮动4 Q- X3 W! f" O4 D( x9 S+ A
//当offset-based弧吩咐点问题完整的圆,但解释为极
& r2 m: B+ {; ^& H4 q5 v0 Z//小弧机周围ε(1.2 e-7rad)由于数字舍入和精度问题。
6 ^6 `& G) v1 X! ~/ g//定义值设置机器ε截止来确定电弧是一个原点了。$ L) l* V8 h% k8 ~2 i6 h+ u
//注意:调整这个值时非常小心。它应该总是大于1.2 e -但不要太7 _* m8 j' T. ]+ [" j
//比这大得多。默认设置应该捕获大部分,如果不是全部,全部错误的情况。% H% q7 B1 E) N% @3 O3 f
/ M% K( F" L0 D; H* W+ W8 X
#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians). Y+ o# x( C* ]$ H4 `! w; O

. ?/ Y. A$ ~! F// Time delay increments performed during a dwell. The default value is set at 50ms, which provides
! [% ^  h: A. w6 R& m+ X+ n4 ], n// a maximum time delay of roughly 55 minutes, more than enough for most any application. Increasing
1 v9 R0 }' `& p! [// this delay will increase the maximum dwell time linearly, but also reduces the responsiveness of ! |' ^! {) T  _  [! c7 z. D; v
// run-time command executions, like status reports, since these are performed between each dwell # t) a4 L! A& `% e; \2 W! Q7 \
// time step. Also, keep in mind that the Arduino delay timer is not very accurate for long delays.! _/ \2 x- E9 c" @6 a) o
//延时增加表现在住。默认值设置为50毫秒,它提供了5 }" b$ R. r% _. ]# u( X
//最大延时约55分钟,足够对大多数任何应用程序。增加
7 A( j- l; V! \2 i//这种延迟将增加线性最大停留时间,也减少了响应能力
0 H  A( L+ p% J! }4 I2 B9 [  o//运行命令执行状态报告一样,因为这些每个住之间执行
) W% I7 k5 t  w//时间步。还有,记住,Arduino延迟计时器不是很准确的长时间延误。! g8 z' e7 f% n) x2 n# B, I

, u  Z. y& \- E# }8 A#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds)
4 z* Q4 p0 d1 f" j& s* O
0 r& X' [( {# Z9 J% o& [  e// Creates a delay between the direction pin setting and corresponding step pulse by creating
$ P" s( J- E: P# X: u/ S// another interrupt (Timer2 compare) to manage it. The main Grbl interrupt (Timer1 compare) $ L, g; x  ^8 H
// sets the direction pins, and does not immediately set the stepper pins, as it would in 1 G" {; a6 h; r: i. F7 f
// normal operation. The Timer2 compare fires next to set the stepper pins after the step ' {% `- y% y7 T3 m/ Q* @3 ]
// pulse delay time, and Timer2 overflow will complete the step pulse, except now delayed
7 ^1 D- r6 ?5 Y) N: b# j// by the step pulse time plus the step pulse delay. (Thanks langwadt for the idea!)
( \) r! |- H6 M// NOTE: Uncomment to enable. The recommended delay must be > 3us, and, when added with the
9 B$ v. _' x3 U% ]; A2 I& m// user-supplied step pulse time, the total time must not exceed 127us. Reported successful1 N* j& V. v! o5 w* n( F8 C* c: M7 J
// values for certain setups have ranged from 5 to 20us.3 M! }5 s- f  V
//创建一个方向销之间的延迟脉冲通过创建设置和相应的步骤
! K  ]7 n6 t, d% S6 R* Q//另一个中断(Timer2比较)来管理它。主要Grbl中断(Timer1比较); y8 P5 v! t, ^- o' |+ z
//设置方向针,不立即设置步进针,因为它会在, k' L" N" |; L* ]+ O8 v1 x  d+ ]3 I
//正常操作。Timer2比较火旁边设置步进针后一步
! ^2 D+ A) h: F) M//脉冲延迟时间,Timer2溢出脉冲将完成的步骤,现在延迟除外1 a" ?6 X' V, I  e" y  F
//脉冲时间加上的一步一步脉冲延迟。(感谢langwadt主意!)' n3 P9 m1 `0 w3 s4 E* G! l
//注意:取消启用。必须> 3,建议延迟,当添加的" Y4 ?+ i( Z; B
//用户提供的步骤脉冲时间,总时间不得超过127美元。成功的报道- P* U( i8 }+ k6 f$ g3 L
//值对某些设置范围从5到20。
+ U0 h$ e4 J" V3 V" `: A  e! k5 G- o! U/ P6 D+ V5 h! I
// #define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.) m/ _' K& A5 E5 Y) G

- q& \$ T4 y) \// The number of linear motions in the planner buffer to be planned at any give time. The vast$ B8 `: Q8 q2 o( {1 H2 h9 G
// majority of RAM that Grbl uses is based on this buffer size. Only increase if there is extra
  z7 v1 w  h6 k( }/ H// available RAM, like when re-compiling for a Mega or Sanguino. Or decrease if the Arduino+ y2 q! \# \5 r9 I8 k/ B
// begins to crash due to the lack of available RAM or if the CPU is having trouble keeping. x1 c% b0 H8 \& z, ]
// up with planning new incoming motions as they are executed.
( I/ @% @4 ~7 C5 Y) `# T$ o4 M, I//线性运动规划师缓冲区的数量在任何给出时间计划。绝大
1 _$ r3 ~$ t( L) r- A) n0 T9 i' w//多数RAM Grbl使用基于这个缓冲区的大小。如果有额外的只会增加
5 \4 @8 d- f( ~//可用内存,比如当基于大型或Sanguino。如果Arduino或减少
3 U9 x& d" r4 M+ E/ ^: ?1 B' f//开始崩溃由于缺乏可用的RAM或者CPU是难以保持! I! Y" u3 s0 J7 j! i) w* R4 u/ m( l8 |
//与规划新传入的动作执行。
0 m  E+ S3 b, O+ B6 \/ ]0 B
4 w7 K4 u, [7 c! w0 r// #define BLOCK_BUFFER_SIZE 18  // Uncomment to override default in planner.h.
: u) v5 W  o! N0 X6 i
* d- W; G/ V1 ]9 s7 D// Governs the size of the intermediary step segment buffer between the step execution algorithm
, L" x  q$ O7 U+ w4 {7 F0 Y) _2 |// and the planner blocks. Each segment is set of steps executed at a constant velocity over a5 w4 y' k8 d. ^) U
// fixed time defined by ACCELERATION_TICKS_PER_SECOND. They are computed such that the planner
6 h# r: m/ |8 V2 n) [4 Q// block velocity profile is traced exactly. The size of this buffer governs how much step , C9 r) v- i7 m( ^5 ], `. r9 D- [
// execution lead time there is for other Grbl processes have to compute and do their thing
3 H% o' T  I9 O: H; E$ J// before having to come back and refill this buffer, currently at ~50msec of step moves.
1 h" Y& _; I/ w" _& H  R//控制之间的中间段缓冲大小的步骤执行算法3 O- M' V. j5 {% `6 E, I
//和规划师块。每一部分的步骤执行在一个恒定的速度: b: P% y) y+ I" |5 S0 h2 s
//固定的时间由ACCELERATION_TICKS_PER_SECOND定义的。他们计算的计划; S  c3 x: y& E2 Q1 ^/ K6 z8 s
//块速度剖面追踪到底。这个缓冲区的大小控制多少步骤0 M! N6 a8 H3 V! X& E; P
//执行时间有其他Grbl过程需要计算和做他们的事情
3 E) p6 U' ~' o3 R4 B//之前必须回来重新填充这个缓冲区,目前移动~ 50毫秒的一步。
8 v0 y: `% [, Y, Y6 M/ t
& `7 y! f6 V) d: n/ q7 |// #define SEGMENT_BUFFER_SIZE 6 // Uncomment to override default in stepper.h.
; Q( [9 Q) j/ G. W. ?
9 Z( ^5 }5 C8 f) b: W8 o// Line buffer size from the serial input stream to be executed. Also, governs the size of . r" g( ]2 H7 t, g& G
// each of the startup blocks, as they are each stored as a string of this size. Make sure
" B) t( h9 k$ h) ?% M# h  I- `  f// to account for the available EEPROM at the defined memory address in settings.h and for
5 J. y1 C1 [0 x: A; v" H0 A// the number of desired startup blocks.; D( @/ }8 t4 z* v4 j
// NOTE: 80 characters is not a problem except for extreme cases, but the line buffer size + _/ m( `! i- T. v
// can be too small and g-code blocks can get truncated. Officially, the g-code standards ; `8 `  ?8 b7 Z/ u1 l5 W
// support up to 256 characters. In future versions, this default will be increased, when # [: I5 p$ b) z: B% a  ^" M/ e
// we know how much extra memory space we can re-invest into this.
" B  a: j+ z9 M( L) Q, f3 b( e//行执行串行输入流的缓冲区大小。同时,大小的控制  j9 H3 Z* M4 k. V% S
//每个启动模块,它们分别存储为字符串的大小。确保
6 s: K  ]$ Q4 i% H//占可用eepm定义内存地址的设置。h和
. w8 P, I3 u( W& t! R6 f( C5 p4 X//需要启动块的数量。2 e: n8 `. Z$ P
//注意:80个字符不是一个问题,除了极端的情况下,但线缓冲区大小% N; Y3 }: Y" U. f5 u; _
//可以太小和刀位点块可以截断。正式,刀位点标准
' k# J! i6 ~! ]5 F. ]9 |//支持多达256个字符。在未来的版本中,这个违约将会增加,当, B  u/ u% Z# X; U
//我们知道多少额外内存空间的时候我们可以再投资。
+ ^4 Q/ d: V% B( j( H3 }2 K& q# Q
, ]  [& z. h( e! ~' V! [0 u3 R// #define LINE_BUFFER_SIZE 80  // Uncomment to override default in protocol.h, l0 q1 X$ o" f; O
  
9 C; u8 T* r  a% K/ x. A+ B// Serial send and receive buffer size. The receive buffer is often used as another streaming) C* @. Q+ D' B& R$ }
// buffer to store incoming blocks to be processed by Grbl when its ready. Most streaming
; c: }' x; a" W5 F# D4 `// interfaces will character count and track each block send to each block response. So,
& S* |7 W& s0 X4 t// increase the receive buffer if a deeper receive buffer is needed for streaming and avaiable; D8 {1 G- |- e" I  _
// memory allows. The send buffer primarily handles messages in Grbl. Only increase if large& B! H' K5 j# l
// messages are sent and Grbl begins to stall, waiting to send the rest of the message.& R5 [+ J" |' w  X% k
// NOTE: Buffer size values must be greater than zero and less than 256.0 X5 m9 F% s( X5 s
// #define RX_BUFFER_SIZE 128 // Uncomment to override defaults in serial.h
% S5 ?4 ~* G3 s+ Z//串行发送和接收缓冲区大小。接收缓冲区通常用作另一个流
% e2 I/ w# z* x# k1 y- _//缓冲存储传入的块来处理Grbl当它准备好了。最流+ J' Q0 [6 m) e* U: U- ?$ H
//接口将字符计数和跟踪每一块发送给每个块的回应。所以,# W: Z1 \' {- a* z2 r1 b3 Z
//增加接收缓冲区如果需要更深层次的接收缓冲区为流,、
: H% P- \% W1 |: j) U' A3 D//内存允许。Grbl发送缓冲主要处理消息。只会增加如果大' P5 t! h" w3 P7 ^) O
//消息发送和Grbl开始停滞,等待发送其余的消息。
; N$ b6 m* S+ ]- I; W//注意:缓冲区大小值必须大于零,小于256。
8 ?  Z/ b# b- a$ Y, a) I5 r// # define RX_BUFFER_SIZE 128 / /取消serial.h覆盖默认值9 y1 c- O. s- ^7 z) ~. U

8 N" m8 ?/ X% P, x; ~: S6 z  h! ~- `8 |& \
// #define TX_BUFFER_SIZE 64
# f! l% M* H. }; a  1 W* `- E/ [$ e* c( z( \9 c+ `
// Toggles XON/XOFF software flow control for serial communications. Not officially supported3 {" K7 x9 ~9 R& _, c% G1 ?
// due to problems involving the Atmega8U2 USB-to-serial chips on current Arduinos. The firmware
, d- I1 K# _4 s9 E8 t; H$ h9 X% G2 V8 }// on these chips do not support XON/XOFF flow control characters and the intermediate buffer 7 {4 M4 _3 p3 O2 k, E; g
// in the chips cause latency and overflow problems with standard terminal programs. However, . j! O- e: Q1 t1 r# l$ [; q
// using specifically-programmed UI's to manage this latency problem has been confirmed to work.
, \* n' x2 v, |7 |2 ~3 T* U// As well as, older FTDI FT232RL-based Arduinos(Duemilanove) are known to work with standard" \; Q4 M8 t9 P$ w/ h
// terminal programs since their firmware correctly manage these XON/XOFF characters. In any" D1 w- Q+ F# ~; O/ u' }
// case, please report any successes to grbl administrators!
6 d7 C( x) [8 R/ M6 G: t% p1 a4 ?* @//切换为串行通信发送朴通/发送葡开软件流控制。不是官方支持; t+ o3 @4 N( D) b
//由于问题涉及Atmega8U2 USB-to-serial当前arduino芯片。固件+ z, Z9 e+ I+ o
//在这些芯片不支持发送朴通/发送葡开流控制字符和中间缓冲区
: g7 A6 U/ Q' S: g//芯片导致延迟和溢出问题的标准终端程序。然而,7 g7 g1 o! S5 Z0 z: s
//使用specifically-programmed UI的管理这个延迟问题已经确认工作。
+ i6 u) k* v; N+ b//以及老FTDI FT232RL-based arduino(Duemilanove)是已知的标准8 A6 x! q: E; S% E
//终端程序因为他们正确的固件管理这些发送朴通/发送葡开的角色。在任何7 ]- {0 X0 }% T* [$ L4 a
//情况,请报告任何成功grbl管理员!- Y" B- j9 i6 W1 R+ o6 G) m
  j) I" V9 `; j* l; M
// #define ENABLE_XONXOFF // Default disabled. Uncomment to enable.! P7 g+ K5 h/ v: L' }$ }3 U
4 P- I5 S9 t  h( H3 l0 m
// A simple software debouncing feature for hard limit switches. When enabled, the interrupt
7 }, U7 r( I* X// monitoring the hard limit switch pins will enable the Arduino's watchdog timer to re-check ' C8 A8 e  A  a8 m3 B  d
// the limit pin state after a delay of about 32msec. This can help with CNC machines with
' e( W8 Y. U" w) s// problematic false triggering of their hard limit switches, but it WILL NOT fix issues with
! P. V% X, {  W3 e// electrical interference on the signal cables from external sources. It's recommended to first6 _. s0 R4 Z) i) E. N7 Q
// use shielded signal cables with their shielding connected to ground (old USB/computer cables
- Y* y8 Z; J" F1 K5 l; k; ?5 R// work well and are cheap to find) and wire in a low-pass circuit into each limit pin.
  \% V3 [. }. L+ |" M; `//一个简单的软件消除抖动特性硬限位开关。当启用时,中断
" [, Y( R4 h5 H9 `6 Y! P) o//监控硬限位开关针将使Arduino的看门狗定时器重新审视
& l% d/ p1 W+ K. b//销的极限状态后约32毫秒的延迟。这可以帮助与数控机器4 z3 }8 V' D, @9 y$ o4 I( _
//问题错误引发的硬限位开关,但是它不会解决问题7 B6 b, e4 K) N  @3 X8 \
//电干扰信号电缆从外部来源。首先它的建议. v( u9 n9 `9 C/ a. u" E1 {
//使用屏蔽信号电缆的屏蔽连接到地面(老USB /计算机电缆7 ~7 E7 v, A" S7 @+ M- ~' b
//工作得很好,很便宜)和线低通电路到每个限位销。
1 F* \( D# n1 J! |4 D3 P5 q! j3 `1 o" n* l& `  C5 z
// #define ENABLE_SOFTWARE_DEBOUNCE // Default disabled. Uncomment to enable.  w( ?# S3 u4 a3 P1 e  Z
$ i7 C6 ^$ }% f. V5 t
// Force Grbl to check the state of the hard limit switches when the processor detects a pin& `% z/ S/ Z5 h" [3 M/ I+ i
// change inside the hard limit ISR routine. By default, Grbl will trigger the hard limits
; d3 f1 y. h7 V/ C2 i( \// alarm upon any pin change, since bouncing switches can cause a state check like this to : `6 g* n1 `! R; ]$ e, Q
// misread the pin. When hard limits are triggered, they should be 100% reliable, which is the
/ g. Q8 O" {( l: b5 v/ I/ `4 m// reason that this option is disabled by default. Only if your system/electronics can guarantee+ S$ I  S* t: U+ [
// that the switches don't bounce, we recommend enabling this option. This will help prevent/ I& t2 D0 C. v. R$ C+ ?
// triggering a hard limit when the machine disengages from the switch.8 U, s- }' L# J: O; U
// NOTE: This option has no effect if SOFTWARE_DEBOUNCE is enabled./ r7 Q+ ~6 q8 Q
//力Grbl检查硬限位开关的状态,当处理器检测到一个销
/ B3 q- d6 c0 H4 ?1 ?$ C//改变内部硬限制ISR例行公事。默认情况下,Grbl将触发硬限制7 U3 W& w2 t( Q+ t' f# o
//报警在任何销更改,因为跳开关可以导致这样的状态检查
- ~6 h4 J6 q0 g5 n& E9 u//误读了销。硬限制触发时,他们应该100%可靠,这是
+ @& }6 o1 ]5 R- A5 F//原因,这个选项默认是禁用的。只有在你的系统/电子产品可以保证4 V7 m; J3 t4 q9 b( i7 f
//开关不反弹,我们建议启用这个选项。这将有助于防止
& h& n1 y8 d! G& u) t//触发机退出时硬限制开关。* h: F# E% d3 l6 w
//注意:这个选项如果启用了SOFTWARE_DEBOUNCE没有影响。5 q- R: [  D' `
" M8 N) \/ c# l% G2 ^; ^# C% P0 w
// #define HARD_LIMIT_FORCE_STATE_CHECK // Default disabled. Uncomment to enable.8 j& i( k1 a2 R& U. L# w
! G/ }5 h0 E- n- ]" h/ b

& u$ X; F5 M* X2 L  d  X6 C# p// ---------------------------------------------------------------------------------------
- ~8 X, A! Y/ `1 b3 r* X// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:编译时错误检查的定义值:2 N2 L. ^. ~6 f) q; Y, x

& ^. \! ^/ C$ x! x. O0 d% S#ifndef HOMING_CYCLE_02 B- Y% ~$ q" p
  #error "Required HOMING_CYCLE_0 not defined."
+ |) s2 e: G1 k+ A) c7 \#endif
0 q( l* E- X$ X, W) l2 H; {; G
% U; X4 d- X" M3 H" ~#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(VARIABLE_SPINDLE)
/ |$ r( {. v5 v2 r( a' a# h' j  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with VARIABLE_SPINDLE enabled") [  U' G: [0 M, S0 V4 Q
#endif
# W* m* ^6 N( ^+ ]' _' I# z9 q' O$ {* J9 B4 I$ Y3 r; k$ G- j$ b3 Y
#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(CPU_MAP_ATMEGA328P)2 @4 F5 R4 N, L. b
  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with a 328p processor": _; l9 m5 A6 c' H
#endif" T/ Z, H$ a$ p' J+ y  _
. t" r6 K" M0 x0 _' N
// ---------------------------------------------------------------------------------------# m/ q9 J" Y. S0 y/ R  m
' @6 r$ P$ f9 q! O8 d
. X2 Y# f! g3 O) S2 D/ u# B
#endif
0 ~" [( K5 c; [6 _+ g4 t
, u4 N: R+ K% T  C
5 M+ N% I/ [6 n# r5 x9 C) |
: _6 p8 i$ @; i8 @/ {% p/ V! X: i& R5 j5 a) I+ r. A

& G) @+ d9 _" O, y+ }) H0 d* I1 L1 A+ g4 f
5 b! k% n' [2 X: e& J4 J

+ N6 x$ V% V# Q
1 T% c+ @; I( Q* k* o! m: b3 @% K/ _% R3 C

8 p/ A+ F- j, L- p6 w3 f
% f0 }2 n, q9 b0 ]8 h7 x( {: q/ n4 _# w3 K+ b
( d8 s# q2 H4 }5 j
' _# D- R. L; V5 f' i# G; M# A

+ ?5 k/ r/ Y& y5 W

本帖子中包含更多资源

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

x

评分

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

查看全部评分

回复

使用道具 举报

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

使用道具 举报

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

; V5 \+ ~/ s& Z3 {, l! q- y8 ~2 d
回复 支持 反对

使用道具 举报

4#
发表于 2016-8-21 05:50:22 | 只看该作者
      楼主厉害!
回复 支持 反对

使用道具 举报

5#
发表于 2016-8-21 08:22:05 | 只看该作者
谢谢楼主,先收藏一下,慢慢学习
回复 支持 反对

使用道具 举报

6#
发表于 2016-8-23 15:11:25 | 只看该作者
这是什么宝贝?
回复 支持 反对

使用道具 举报

7#
发表于 2016-8-23 15:11:47 | 只看该作者
换了个浏览器Chrome,试试能否发言了。
回复 支持 反对

使用道具 举报

8#
发表于 2016-8-23 20:12:33 | 只看该作者
楼主厉害
回复

使用道具 举报

9#
 楼主| 发表于 2016-8-23 23:03:17 | 只看该作者
补充
; P0 ?( X: N& T8 i6 K3 i程序运行protocol_execute_realtime(); /运行实时命令。
' Q6 m. }5 w5 X7 ?// Executes run-time commands, when required. This is called from various check points in the main& u+ ~% Q4 w* U/ S  J6 d4 G% }
// program, primarily where there may be a while loop waiting for a buffer to clear space or any
2 k9 J& z6 N! o// point where the execution time from the last check point may be more than a fraction of a second.
, ]( R& M- o: Q# c  O" j% W& u// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code/ i. Z6 e; z' Q( ^
// parsing and planning functions. This function also serves as an interface for the interrupts to
- s% a# d$ z7 c! U7 K) ?// set the system realtime flags, where only the main program handles them, removing the need to# K! k! L" U0 l3 H! j  o
// define more computationally-expensive volatile variables. This also provides a controlled way to * A- d7 Y% z( W3 V4 {
// execute certain tasks without having two or more instances of the same task, such as the planner
1 `' X+ Y$ Y" P- Q4 @" y3 F6 H& A// recalculating the buffer upon a feedhold or override., t* h0 l6 e- l% s3 A( [& R, n: W) c
// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,' j* a' j$ b4 {- ~) u, S
// limit switches, or the main program.& M' m1 D4 h' Y! t2 E! g
! {% g' ]) y& R  M1 `5 d+ c
//执行运行时间命令,在需要时。这就是所谓的从各种主程序要检查站0 `' i8 o) C7 A+ a( I1 @6 W
//,主要是那里可能是一个while循环等待缓冲区空间或任何+ ^8 R4 m, D& I6 k
//执行时间从过去的止点可以超过几分之一秒。9 D- M, a- X8 D
//这是一种异步执行实时命令(又名多任务)grbl的刀位点' {4 ^& O! e5 l, P1 D0 b+ {) K1 W
//解析和规划功能。这个函数也可以作为一个接口,用于中断
. K1 r( v9 P* b9 d, I5 g//设置系统实时的旗帜,只有主程序处理,消除的需要" b1 Z  e4 h4 i
//定义更多的计算昂贵volatile变量。这也提供了一种控制方法
' g' F: a$ z4 x: A& m//执行某些任务不相同的两个或多个实例的任务,比如计划
* z' t' q* Q& y) U9 I//重新计算缓冲feedhold或覆盖。
! u6 v, s( |& Q6 h. [# [6 w//注意:sys_rt_exec_state变量标志设置任何过程,步骤或串行中断,插脚引线,. X) h0 _! ?+ |. ~# ^) E( `
//限位开关或主程序。
3 b6 k9 k% d) d; A" Zvoid protocol_execute_realtime()
- U( e+ B8 Y. Q{* j8 i8 a9 Y& T. T; q( {
        // Temp variable to avoid calling volatile multiple times.- }2 ?6 q9 [0 ^( b- L8 T
        // 临时变量来避免多次调用不稳定。
  }" d" t! K" q; |, u' O4 I3 q        uint8_t rt_exec; * u5 ~3 p! {4 \3 {
        do{
$ y; A; u" |0 v' m0 |4 |          if (rt_exec) {                 // 有标志位置位进入
0 b3 Q, h" r) q' F  Z; @       
% @5 v( Q: D% G% \; ^& d0 j            sys.state = STATE_ALARM; // 设置系统为报警状态
3 h0 }/ e( K. m0 N( J4 R      report_alarm_message(ALARM_HARD_LIMIT_ERROR);        //报告报警信息为接近极限值, \/ c. O! _& _7 X/ o; D5 l. f, [
    } else if (rt_exec & EXEC_ALARM_SOFT_LIMIT) {                        //报告执行软件限位报警
$ J% o( s% N  X& d1 y8 M( w& b6 ?0 n- K      report_alarm_message(ALARM_SOFT_LIMIT_ERROR);        //报告出现软件限位报警2 `/ P- ~3 n/ e* E, ?# O
    } else if (rt_exec & EXEC_ALARM_ABORT_CYCLE) {                //执行停止循环报警      
  \1 u) d' L# [( {  V6 {* n0 I      report_alarm_message(ALARM_ABORT_CYCLE);                //出现终止循环报警
9 s8 R% K7 V2 l* m3 A1 f6 U; W    } else if (rt_exec & EXEC_ALARM_PROBE_FAIL) {                        //执行探查失败报警
9 A" e# J+ {; J' I9 M3 B3 N5 d( F      report_alarm_message(ALARM_PROBE_FAIL);                        //出现探查失败报警
0 Q/ \, z% X, g8 O# P* O    } else if (rt_exec & EXEC_ALARM_HOMING_FAIL) {                //执行返回原点失败报警  e& Q. i7 P6 O5 y$ ^6 f
      report_alarm_message(ALARM_HOMING_FAIL);                //出现返回原点失败报警
4 e+ O, [" Y: c1 Y+ c/ b1 k# m( q    }
+ u7 H5 X/ h1 x* e. z. u2 ?
" C% o+ I, Y) _2 i/ {# j0 u    // Halt everything upon a critical event flag. Currently hard and soft limits flag this.2 u) e% I" N9 U" A" v6 _; _1 o/ l
    // 停止一切在一个关键事件标志。目前硬和软限制标志; O4 M& M* G' j: }& z/ u. y
           if (rt_exec & EXEC_CRITICAL_EVENT) {                //如果系统是循环事件进入
/ W$ m0 A2 J+ x: ?( ?             report_feedback_message(MESSAGE_CRITICAL_EVENT);        //报告反馈信息9 \% u' a3 @  z  C% Q$ g
              bit_false_atomic(sys_rt_exec_state,EXEC_RESET);                         //清除目前的复位状态( Q& P2 L7 G4 A% v4 w
! ]& i% A. g6 i  `
        bit_false_atomic(sys_rt_exec_alarm,0xFF);                                 // 清除所有报警标志* [. l& L) _+ |+ ^# y/ Z6 \
        }        & ^6 S5 K0 R7 @+ L) k
/ @3 W) \1 x; n" ~1 I# d
上面代码将rt_exec = sys_rt_exec_alarm ,如果rt_exec为真,打印不同报警信息8 A$ V; {6 d( l
和限位保护信息,然后清除报警状态
/ G8 v1 h3 e  p' M9 P___________________________________________________________________________+ Q0 b+ W; |2 M8 A- W: K1 ?
没有报警进行执行下面代码,执行了终止命令,串口打印命令
: H8 }( _$ Q+ V, }' [         // Check amd execute realtime commands        校验和执行实时命令* N, ?% K8 f+ i0 n$ e" t" M% j
          rt_exec = sys_rt_exec_state; // Copy volatile sys_rt_exec_state3 [4 W/ n* h, T1 S- I) L. Z* n

6 s$ m2 u! ~9 |/ Q  ?        if (rt_exec) { // 输入标志是正确的执行; Q' p4 o) _9 a3 q' }' }

4 [. H& x" G3 C+ b' r! F" x7 d            // Execute system abort. 执行系统终止命令$ q& H  D4 \' R
            if (rt_exec & EXEC_RESET) {
# H' f% ^! E% B6 I% u. }              sys.abort = true;  // Only place this is set true.; y1 k( v% h4 r9 W
              return; // Nothing else to do but exit.
! g! J. w1 _* H( Q' B        }% O1 P' ]6 y* `2 e
6 l. g+ e; O3 j/ e
            // Execute and serial print status 执行和串口打印状态' v$ e! f  D" E' D* }: f' i' E
            if (rt_exec & EXEC_STATUS_REPORT) {
' ?: n% _% m+ M4 C5 n              report_realtime_status();        //报告实时状态
5 x0 u* L( U" n- v! a+ u, E              bit_false_atomic(sys_rt_exec_state,EXEC_STATUS_REPORT);        //清除报告状态清零- h( {8 h  c4 Q6 z3 T. e% l
            }, J3 A4 Y6 o& t& H2 E& w$ _9 |4 f4 [
_____________________________________________________________________________
' |( b. X3 j5 C' V3 ?. z& E) @# y  o下面代码3 `# w& K  `' f; D8 N
//执行状态。
7 ?6 L. X  }/ F2 _8 e. N$ X//注意:所涉及的数学计算持有应该足够低对大多数人来说,即使不是全部,: m6 `) L# W0 K# Z/ C- ?
//操作场景。一旦启动,系统进入暂停状态
5 Q( [! P1 Q: B+ u//主程序流程,直到重置或恢复。4 o% S, Y: r+ z7 D: P9 D4 C
待办事项:检查模式?如何处理呢?可能没有,因为它只会在空闲,然后重置Grbl。. \5 `$ q2 U5 d( D
状态检查容许状态的方法。
& s: h; _5 U! q
* d  B* A6 y6 C* E; [        //如果全局各自报警标志位其中(执行取消动作) | (执行进给保持) | (执行安全门)任意一位为真进入
0 n; e! R; D: ^$ t1 d& r            if (rt_exec & (EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR)) {        - `/ \( p  \" j- E# n! ^/ D
  N) _5 t7 k; ^! x$ m! t
        //如果是循环状态执行暂停状态4 Z+ L# `% ?0 P, c8 t  Q! p4 J
        if (sys.state == STATE_CYCLE) {
6 @: }+ E' t) I; q- V" m& s        st_update_plan_block_parameters(); //通知stepper module验算减速。: e/ Q; N! b9 C2 j& V
        sys.suspend = SUSPEND_ENABLE_HOLD; // 开始暂停标志
3 G$ W( \  c1 v% ~        }
1 y0 o  `. X' O2 m* g2 e. h! z& a% |/ A7 U8 n
        // 如果,Grbl空闲不在运动。简单的指示暂停就绪状态。/ O+ a0 i& L, ~! H, J
        if (sys.state == STATE_IDLE) { sys.suspend = SUSPEND_ENABLE_READY; }
, l+ Q( E3 g$ Z5 \; {+ p* a9 {8 m, b" d
/ I" ]3 E6 w( R+ W8 R
        //执行和标志和减速运动取消并返回空闲。主要由探测使用周期
; z' f$ l7 @/ }6 E( a& T- }7 E        //停止和取消剩余的运动。      
7 `! z( a; {/ a. ^6 j0 v$ E        if (rt_exec & EXEC_MOTION_CANCEL) {
% v) z5 E6 m- k& n          if (sys.state == STATE_CYCLE) { sys.state = STATE_MOTION_CANCEL; }
8 F6 b5 S2 G4 Y/ a( D          sys.suspend |= SUSPEND_MOTION_CANCEL;
3 |' n7 |# _6 k4 D) k        }" Y2 v% e' p1 a& s( }
) g+ S+ f6 H2 a9 S
        // 只在循环时执行进给保持减速. L, c8 c9 d* X! L3 a
         if (rt_exec & EXEC_FEED_HOLD) {
" X' t, {6 \" g0 ~( j3 N        //只有安全门为1才执行保持进给状态赋值
$ b* q5 j& V% |) m- Q  e' A# ]9 d* T" S          if (bit_isfalse(sys.state,STATE_SAFETY_DOOR)) { sys.state = STATE_HOLD; }$ o. T' h$ Z. \$ k2 p0 @! [
        }
! a/ m/ Y: }7 r8 N3 N. a4 J% v% M5 X7 K/ p5 A- |0 @9 Y6 Y
        if (rt_exec & EXEC_SAFETY_DOOR) {
: Z5 v. R4 @( F. w1 e: H2 \& ~& }* ?          report_feedback_message(MESSAGE_SAFETY_DOOR_AJAR); ! [1 u" ?; }3 v& J  K
/ /如果已经活跃,准备好重新开始,CYCLE_STOP标志设置为强制断开。
  T& n& h- u" K) J9 Y$ y" v/ /注意:只是暂时设置“rt_exec”变量,不是动荡的“rt_exec_state”变量。
+ E. x/ I! {& A. D7 E, [  h! M4 }          if (sys.suspend & SUSPEND_ENABLE_READY) { bit_true(rt_exec,EXEC_CYCLE_STOP); }9 o# ~/ O0 ]. V; B( q; q$ f
          sys.suspend |= SUSPEND_ENERGIZE;
4 @3 _. @. d9 _# M          sys.state = STATE_SAFETY_DOOR;
* @1 h5 X! m7 N/ u6 Q        }) i& w4 c' X, R& B* k3 `) G3 D- Y
* l& t& B  ?: t# }/ c
bit_false_atomic(sys_rt_exec_state,(EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR));   
, W1 B& S4 ~' {6 `' @. F
9 s; U3 C( z8 u0 K# t}
% l5 w4 w4 r$ H9 l# H3 |# F. d0 k! a以上代码执行了
! I' S( Y  V2 ^2 J( Q9 r) v1.如果全局各自报警标志位其中(执行取消动作) | (执行进给保持) | (执行安全门)任意一位为真进入- V' p' T$ a& _6 E1 Z
2.系统为闲着状态, 开始循环状态, 回原点状态, 控制取消状态, 开始保持状态, 开始安全门状态时进入6 j8 Q& g- k. x, J  R$ W- b
3.如果是循环状态执行暂停状态
+ m' j- k! M7 i4.如果系统闲置状态执行暂停就绪状态* ^' J0 L" n# t. |5 `% W) @' s4 I- ]
5.执行动作取消
7 R5 T, G5 C5 z) {; X4 _6.如果是保持进给状态,执行保持进给状态
* Q- _! t' |6 e& ~7.执行安全门状态) ~3 I+ {  A4 t5 k& J2 Y3 @; j
最后执行bit_false_atomic清标志清除(执行取消动作)(执行进给保持)(执行安全门)标志位                 
* h4 s) [$ F. x1 u8 m8 v_____________________________________________________________________________5 L2 t& x( T5 y% K% F  }
1 K6 o4 C- W  Y$ d9 D
    // Execute a cycle start by starting the stepper interrupt to begin executing the blocks in queue.
* ]8 M+ g- A' H% j) g6 k; d    // 执行一个循环开始启动步进开始执行中断队列的街区
. t2 Z1 c1 }3 R2 C+ _2 R. n    if (rt_exec & EXEC_CYCLE_START) {        //循环开始状态进入
2 q4 e$ Y5 G6 o' U4 {& ^      // Block if called at same time as the hold commands: feed hold, motion cancel, and safety door.
2 F4 W: L& K: D# Y      // Ensures auto-cycle-start doesn't resume a hold without an explicit user-input.' W/ k( I( Z/ u$ s
          //块如果在同时举行的命令:保持进给,运动取消,和安全的门。 //确保auto-cycle-start没有简历没有显式的用户输入。
$ U( ?3 r1 E3 U4 F- K# ^8 D          
, X* u# @/ P+ @: e1 A3 j% R, V      if (!(rt_exec & (EXEC_FEED_HOLD | EXEC_MOTION_CANCEL | EXEC_SAFETY_DOOR))) {   //状态机如果不是保持进给,运动取消,和安全的门。 7 Q* K! h0 D7 H; Z- J3 E
        // Cycle start only when IDLE or when a hold is complete and ready to resume.
+ @( d1 l7 L1 o9 s8 [- h        // NOTE: SAFETY_DOOR is implicitly blocked. It reverts to HOLD when the door is closed.
" n9 k8 l2 \' Q: K8 f# E, j                //循环开始时只有当闲置或持有完成并准备简历。# S* a; `9 n" g0 N; [( I- {
                //注意:SAFETY_DOOR是隐式地屏蔽。它返回的时候门是关闭的。    1 v4 h! c/ a6 r$ _; B
1 X! M  T# I3 w0 I9 r* R
                // 如果系统状态为闲着状态,系统状态为开始进给或运动取消,暂停标志为位重新开始7 h, W) E% O  Y+ V7 [
        if ((sys.state == STATE_IDLE) || ((sys.state & (STATE_HOLD | STATE_MOTION_CANCEL)) && (sys.suspend & SUSPEND_ENABLE_READY))) {9 z5 j1 ?* c/ ?) a8 }, d! r% j
          // Re-energize powered components, if disabled by SAFETY_DOOR.8 O" p/ P5 F0 ~; S$ ~: }
          //        由SAFETY_DOOR重振组件供电,如果禁用。& u' |# `. S- C2 R8 A, s
          if (sys.suspend & SUSPEND_ENERGIZE) {
% o! W# x! W- T$ f: J2 q            // Delayed Tasks: Restart spindle and coolant, delay to power-up, then resume cycle.
( ~9 z2 `: Z: F" B+ {# h" I            //延迟任务:重新启动主轴和冷却剂,延迟升高,然后恢复周期。% `, f/ O2 a) F! `# ~3 C" w
            if (gc_state.modal.spindle != SPINDLE_DISABLE) {   //主轴模式不是失能进入  f: i. x& }5 R* V0 e
              spindle_set_state(gc_state.modal.spindle, gc_state.spindle_speed); //设置状态和速度
4 {6 r% G3 H( f: o2 `3 ^9 o              //待办事项:阻塞函数调用。最终需要一个非阻塞。
# v0 v1 H7 \- Y5 O: t/ f/ U" d6 W                delay_ms(SAFETY_DOOR_SPINDLE_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.
9 g# a# {- `3 t" @8 M            }3 U+ {/ x6 j4 t* ]
            if (gc_state.modal.coolant != COOLANT_DISABLE) { 0 n/ n) b8 s5 }
              coolant_set_state(gc_state.modal.coolant);
  L6 c* s3 U; E1 N* c. w! _# l2 c. y              delay_ms(SAFETY_DOOR_COOLANT_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually./ R' x) O3 g9 G2 z
            }6 G/ P  e" X7 `; N3 c
            // TODO: Install return to pre-park position.
; ?; a, P  c$ p6 b* N* q# ?1 E          }1 M0 H0 L* A& j; q, X4 L9 h- M
______________________________________________________________________________________________________________; G" N, Q, A8 S" c3 B
          // Start cycle only if queued motions exist in planner buffer and the motion is not canceled.
. O! T* P6 o! l! ~/ F: Z# l2 ~7 ]                  3 K  T4 W) h, W1 J3 D
                  //只有在队列马达存在规定的缓冲,并且动机没有让取消,才会循环! Q3 `/ h# t' m/ W* @! Z
                  4 T; y8 }7 ^5 V. {: [8 C$ s9 s
          if (plan_get_current_block() && bit_isfalse(sys.suspend,SUSPEND_MOTION_CANCEL)) {
) ~" \% a9 U1 N$ w8 R5 ?            sys.state = STATE_CYCLE;
+ G3 J: ]2 _( F" w4 z- e            st_prep_buffer(); // Initialize step segment buffer before beginning cycle.初始化步开始循环之前
5 O3 Y% k( m+ Y5 j/ {5 I" [* M% G            st_wake_up();
# v# d. ?0 L, x& O7 d9 X1 `, \          } else { // Otherwise, do nothing. Set and resume IDLE state.否则,什么也不做,设置和复位空闲模式
* w+ p1 c& {( m& g6 i, K            sys.state = STATE_IDLE;
" p& I/ }% O8 o5 m          }
5 }" P8 F- \, }! W          sys.suspend = SUSPEND_DISABLE; // Break suspend state.
2 f. w8 Q- \2 z+ m        }
9 M( M7 L1 Z' h6 n% K: w0 W. \      }    2 R  b/ e, a4 D
      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_START);        - Z4 ~3 C9 [. r4 }% d  j6 F
    }
! k* w6 O9 y7 ^$ r: x; @; A; v7 O8 w0 a
_______________________________________________________________________________________________________1 F, j) }6 B0 h  [/ b5 Y0 S% k
    // Reinitializes the cycle plan and stepper system after a feed hold for a resume. Called by * h6 ]0 Y/ w% `
    // realtime command execution in the main program, ensuring that the planner re-plans safely.
5 `* d% m3 z8 ~, L& _    // NOTE: Bresenham algorithm variables are still maintained through both the planner and stepper
- O6 I6 H1 u. f0 c! O    // cycle reinitializations. The stepper path should continue exactly as if nothing has happened.   # P" t$ c" z9 l: f5 O6 u
    // NOTE: EXEC_CYCLE_STOP is set by the stepper subsystem when a cycle or feed hold completes.
. a" Z/ Z+ s7 J1 C& h4 w% E
* p+ Y8 l# E3 Q& C8 t+ b, o- S        //重新启动后循环计划和步进系统的进给保持简历。通过实时命令执行主程序,确保安全计划重新计划。
+ S2 S$ l& [+ |: ~) u2 N0 s4 I) q- u1 u8 b        //注意:画线算法变量仍保持通过规划师和步进9 ]  [( A$ w5 c% C9 U
        //循环仅。步进路径应该继续,好像什么都没发生一样。       
$ P8 X$ W$ D& D/ g2 v. j. E; Z+ o        //注意:EXEC_CYCLE_STOP由步进子系统周期或进给保持时完成。, b5 b  |8 G$ F# w  E  i. T3 H
; b5 F- n9 O4 j& J/ L+ P* k# P' M
    if (rt_exec & EXEC_CYCLE_STOP) {                         //如果是循环停止状态进入
' ^- J3 d8 T3 K  s) ]2 s      if (sys.state & (STATE_HOLD | STATE_SAFETY_DOOR)) {
5 c4 T2 I( A1 ]. y( e        // Hold complete. Set to indicate ready to resume.  Remain in HOLD or DOOR states until user
5 [7 M) ]" s( G" r7 Q' W        // has issued a resume command or reset.( U9 R! R( N$ p' n3 k1 I

, ^- o7 v5 T+ V8 W& ?$ M' ~) l                //保存完整。设置为指示准备简历。继续持有或门状态,直到用户0 G1 t5 J# Z7 G& U- K. Y  M# f
                //已发布了一份简历命令或重置。) e- m$ S) x; Q' \# g2 v: w2 P9 w
                ) j. g# r$ C; V3 j! a
        if (sys.suspend & SUSPEND_ENERGIZE) { // De-energize system if safety door has been opened. 如果安全的门已被打开。断开系统1 N2 K( c& s; f4 i) T+ o' C/ i
          spindle_stop();
3 L; P/ y, ~$ K7 p) k8 e* z          coolant_stop();0 _* u; [/ r. p  D4 F: t
          // TODO: Install parking motion here. 安装停车动作。
: O4 ?3 i9 X7 C7 }+ C& O  o9 c        }3 i9 G* p! q" c3 s$ j6 m
        bit_true(sys.suspend,SUSPEND_ENABLE_READY);
7 D, z. o/ |! \* J/ i7 }/ q      } else { // Motion is complete. Includes CYCLE, HOMING, and MOTION_CANCEL states. 电机完成,循环,回原点,,MOTION_CANCEL8 ?; e7 U: I3 I" |1 |
        sys.suspend = SUSPEND_DISABLE;
; {) x9 Y7 f( i) F! a5 l3 D        sys.state = STATE_IDLE;. B2 z. {+ _7 N! I
      }
# E" d5 R; `5 U0 O5 Y      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_STOP);
+ k& E/ J2 z3 f! }" _    }$ V+ q! J% L* G* b* W( `% J+ x
   
5 F% T! h1 h$ t- c- n  }, g6 g0 P# m# {% W
___________________________________________________________________________________________________
) K* o: ]7 Z; Y7 M( p% ~9 ~/ K7 ~$ l
  // Overrides flag byte (sys.override) and execution should be installed here, since they 5 n( v; q3 z+ k* q# Z
  // are realtime and require a direct and controlled interface to the main stepper program.$ ?+ N8 x( D% y4 \
7 g, \# @+ P5 G, ^$ H. f
  //重写标志字节(sys.override)和执行应该安装在这里,因为他们
! P0 r+ E1 {: b4 s3 {: q  //实时和需要直接和控制接口的主要步进程序。
# w* ]) i' p0 i* c/ W' Z7 O- h
; R# C; I" L* C. z% r- Y
6 O# Y) M9 f! F. K" h( b9 J+ ]  // Reload step segment buffer 重新加载步段缓冲8 t* f/ A/ m, W
  if (sys.state & (STATE_CYCLE | STATE_HOLD | STATE_MOTION_CANCEL | STATE_SAFETY_DOOR | STATE_HOMING)) { st_prep_buffer(); }
% Z5 a1 {; [5 O0 |5 P/ M4 J4 Q" L7 B" L+ T0 C% Q: p1 K/ C
  // If safety door was opened, actively check when safety door is closed and ready to resume.
. z+ O( s6 I- M+ y2 [5 U: P2 s  // NOTE: This unlocks the SAFETY_DOOR state to a HOLD state, such that CYCLE_START can activate a resume.       
% {& v: U) |0 O9 J  o4 D6 O. c1 z
5 K' o! _& P/ }- J9 |) K6 I$ ~//如果安全的门被打开,积极检查当安全门关闭,准备简历。
/ [3 P% C; T' r  //注意:这解锁SAFETY_DOOR状态保持状态,这样CYCLE_START可以激活一个简历。
- x5 q: H1 _) _3 I8 w, ]$ ]- n' u+ u; L
  if (sys.state == STATE_SAFETY_DOOR) {                 //安全门状态进入
7 \7 c8 _  P: ]# p3 s3 o. K  @    if (bit_istrue(sys.suspend,SUSPEND_ENABLE_READY)) {
# B( F4 z  @3 u5 T+ y7 {      if (!(system_check_safety_door_ajar())) {
" E- X9 k1 \. T        sys.state = STATE_HOLD; // Update to HOLD state to indicate door is closed and ready to resume. 更新保存状态指示门关闭,准备简历。/ T! g+ }. c5 l; c3 P4 P
      }
, o& q, A9 ~" o, A& i7 w5 E    }7 b: t; ?! E2 O% S9 L
  }6 f& A! p- y4 X* {4 j
. x6 [9 S, ?9 o/ E! c2 H; Q
  } while(sys.suspend); // Check for system suspend state before exiting.5 @/ Y. r7 O; m9 J" r; }6 G) H" ]
  
+ }4 v1 @% ?3 C4 A0 f}  
回复 支持 反对

使用道具 举报

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

点评

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

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-9-21 22:41 , Processed in 0.080998 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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