找回密码
 注册会员

QQ登录

只需一步,快速开始

搜索
查看: 19063|回复: 15

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

[复制链接]
发表于 2016-8-20 23:56:23 | 显示全部楼层 |阅读模式
本帖最后由 1五湖四海1 于 2016-8-21 00:09 编辑
. I; e5 O& p; V/ ~2 f: r
4 e4 A1 b& f. N2 T7 b! [) Z    以前制作过CNC雕刻机,是用MACH3作为上位机控制,硬件是采用PC接并口输出脉冲和方向使能信号经过隔离驱动步进电机驱动器,步进电机驱动是采用TB6560芯片控制。最后就接到步进电机。机械是用铝合金制作,主要部件有三个1605的滚珠丝杠,多个运动滑块等制作。用这台DIY CNC雕刻机可以雕刻木头塑料等东西。当时没有一直玩下去,现在发现网上有用单片机制作的雕刻机挺精巧的现在分享给大家。
+ I1 e& A( 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个运动来规划运行速度,以实现平稳的加速和无冲击的转弯。很棒吧!开始玩起。4 G% L6 |' \2 E2 B1 N# {  R' G
    还没有雕刻机的机械部分可以用废旧光驱制作个微型雕刻机运动平台。雕刻机最重要的是主控程序这次用 Arduino/AVR328单片机,价格在15元左右,主控程序是上面提到的目前很火的开源
的GRBL,还有一种基于STM32平台的开源主控程序Dlion也不错可以替代grbl。如果从性能比较这两个方案,显然是stm32平台运行速度更快毕竟他是32单片机呀!- B+ _+ Y/ S5 _6 o  F4 a
% x3 R. b- o# o. r
8 K; E/ W* t8 c
    下面介绍小这个些主控程序主要干的事,通过串口PC和主控板通讯,PC命令给控制板,控制板接收命令做不同的响应,PC可以发G代码给主控板,接收完成后可以自动开始雕刻任务。
- f  K2 J" `. }* r          在介绍下G代码因为G代码是雕刻机的核心部分
6 s8 ?6 ^: ]9 a+ pG代码是数控程序中的指令。一般都称为G指令。' I5 i& B3 J1 j, k4 G0 Z# |9 c3 R/ o
G00------快速定位( D* z* c; P% D, h  M  h1 f
G01------直线插补
1 l- |5 b. C, ~G02------顺时针方向圆弧插补
4 X( ^4 A6 d$ G) e' S* QG03------逆时针方向圆弧插补
8 k" M# W# F/ C: CG04------定时暂停- d5 N3 W# R# M+ o3 [9 H" F
G05------通过中间点圆弧插补$ q: p9 `0 N7 B: m0 X. w& X9 x
G06------抛物线插补" A9 e& M" _, I0 P/ @4 l9 Z
G07------Z 样条曲线插补1 l) h. I0 u/ Y1 a* Z
G08------进给加速
7 [1 M' o! x7 ~/ X' OG09------进给减速$ T1 [% N) K( S! H' Y1 N% L
G10------数据设置
3 _. k; A0 @% h1 R0 c* J3 cG16------极坐标编程
: g" \. C2 f& tG17------加工XY平面0 `# y. Q4 D7 }
G18------加工XZ平面5 F1 D2 k- v" l+ c
G19------加工YZ平面

$ ~" W. a& H6 r- P. G5 D' b! m核心就是解析G代码,完成步进电机驱动,和控制主轴开启关闭,还有插补算法,直线插补,圆弧插补,还有一些步进电机的加减速算法。
* l2 {0 z0 _& G$ h1 k6 e下面对grbl主结构做介绍
& j1 U* w3 x) T# e5 Qmain()主函数首先执行下面初始化函数
+ n. U% h7 [8 u! d5 \4 s        serial_init();                           // 设置串口波特率和中断+ d% n* {3 Z9 _+ p* R
        settings_init();                         // 从ROM加载grbl设置* E+ J& _9 G- W3 J" ~) Q# w4 L
        stepper_init();                          // 配置步进方向和中断定时器
$ l6 O# F6 Y" @; A1 H3 s3 a        system_init();                           // 配置引脚分配别针和pin-change中断- i; d6 w. @7 }/ S7 D  N
        memset(&sys, 0, sizeof(system_t));          // 清除所有系统变量
: w; s4 p- g8 T        sys.abort = true;                           // 中止标识位置位+ P2 Q, j% E) ]. p
        sei();                                         // 使能中断" B1 U* @% I1 J( c% n. H+ f" j
  #ifdef HOMING_INIT_LOCK                        // 宏运算(settings.flags & (1 << 4)) != 0结果flags等于执行sys.state = STATE_ALARM; k! F6 |- O+ P6 w
                                                // 系统状态赋值为报警状态3 u+ t% }) \. j' x
            if (bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE)) { sys.state = STATE_ALARM; }, X2 ?+ w+ E3 g% k' C5 T; [! d* L
  #endif
, ]+ ]6 U- ]% y6 o( z- Q+ D3 M# a_____________________________________________________________________________________________________________________________________
$ O2 c% [# n8 [: u2 p接下来是一些主要部分初始化
2 Q: X0 k6 n+ g  N3 Gfor(;;) {
' X2 D: @- ]% x        serial_reset_read_buffer();         //清除串口读缓冲区7 e- Q/ v$ K2 m. @- c
        gc_init();                         //初始化G代码功能函数# S) w5 t! l0 O8 L: K
        spindle_init();                        //主轴初始化4 w) L# u7 f+ Q9 L. D# ~2 _3 h
        coolant_init();                        //冷却液初始化9 ?7 J$ [" R: m  O( P
        limits_init();                         //极限开关初始化; v$ I! k" t. i$ e  t
        probe_init();                        //探测部件初始化* o, x: L& w2 y. s8 `  w- u3 p% E
        plan_reset();                         //清除块缓冲区和规划师变量. G6 F6 ?; t7 u
        st_reset();                         //清除步进系统变量。
9 u$ j; I0 r- n' \% s* J4 l2 k
0 G. z5 w( c0 H# o9 n; @+ h
  n8 R( }+ D4 I( j( i2 |3 i        //下面两行清除同步gcode和策划师职位当前系统位置。) M7 v: e7 E2 v7 y
        plan_sync_position();$ f4 ]( v! }! |7 N4 E7 ]
        gc_sync_position();
7 z  f: R6 g- u# K8 \' _( s9 a7 K6 W! J% [" V
& A' t* ]$ p. ^  M8 {
        //复位系统变量
$ e2 J) I( b2 N. l( S% W  B- j        sys.abort = false;                //系统中止标志  y- A" ?7 p- [& O+ b; I5 ?8 K3 F6 P
        sys_rt_exec_state = 0;                //系统标志位变量状态管理。看到EXEC位掩码。
9 N5 C# {' m7 R/ A" l$ m3 c' |        sys_rt_exec_alarm = 0;                //系统标志位变量设置不同的警报。& B. }1 }3 K, U- F8 b' c
        sys.suspend = false;                //系统暂停标志位变量管理,取消,和安全保护。
; E9 s8 t/ q/ e$ F        sys.soft_limit = false;                //限位开关限制状态机错误。(布尔)
# n9 V; |! A" D. S* R
2 Z  W1 X+ h+ D% w+ A1 ]2 R: ]/ s/ }- F6 E; A* a' l- v: S7 E
        protocol_main_loop();                //主协议循环3 V7 j: m: V/ Y2 S. x, Y
}        //
; p' {7 N8 z$ i0 b_____________________________________________________________________________________________________________________________  a$ ~3 Q. ~- j. O% a: O2 n) x
进入void protocol_main_loop()函数" K9 v1 E) X. @; S
{+ q+ c( `: K9 C% Q3 T) b7 T4 K# j
        report_init_message();                // 打印欢迎信息 * y0 X, i6 U: a7 \& I
        //重启后检验和报告报警状态如果错误重启初始化。' i4 B7 V1 f9 W- F& K+ H
        if (sys.state == STATE_ALARM) {4 `* V; n3 i+ u+ ^# J4 r* C
            report_feedback_message(MESSAGE_ALARM_LOCK); //打印信息& `) {, }- g, [; r( O  _
          } else {' z+ v" v! F  p( o5 p6 p" P
            // 如果没有报警说明一切正常!但还是要检查安全门. , W) O: I+ P+ u2 O1 F( X6 v
            if (system_check_safety_door_ajar()) {/ [- x5 |; ]! g
                     bit_true(sys_rt_exec_state, EXEC_SAFETY_DOOR);( L& F4 W, W( `- F) u
                     protocol_execute_realtime(); // 进入安全模式。应该返回空闲状态。) k% c7 m0 e2 L3 Y
            }         else {4 ?5 [2 A1 P; {6 L7 z
              sys.state = STATE_IDLE; // .设置系统做好准备。清除所有国家国旗。9 D$ b' [, v+ W" H# Z0 ^( |7 W
            } # H8 v  Q; B/ s- R
            system_execute_startup(line);    //开始执行系统脚本3 U: k" ?* I" g& I
  }
6 i( d8 ^( F+ [' V  D( M! `4 }% A- c" i9 L  Z! s

( w( x  K8 \# w( w6 L* q  // 这是主循环!在系统中止时这是出口回到主函数来重置系统。
0 k  f- g. k% _. i# V  // ---------------------------------------------------------------------------------  
+ ^, X6 ?) T- Y4 P- ~  
! z) ]2 ^! ?3 f        uint8_t comment = COMMENT_NONE;
# F: h7 y9 w8 F0 O9 z- _        uint8_t char_counter = 0;6 U0 Z3 l$ e3 t
        uint8_t c;- B! p( r; |: M/ z5 r0 H
_______________________________________________________________________________________________________________________________
7 A2 w- l4 m" X" z# {' J) ^% }接下来进入for(;;)循环                //下面代码是G代码解析核心部分,程序中comment(注释)变量会被赋不同值,代表发符号有‘(’‘)’‘;’! {0 _- Q  E+ {* B- ^# W4 ^
{
) g$ Q& j5 J/ B* f+ f' z3 w7 Q0 |//串行数据输入一行的的过程,作为数据。执行一个# Y& ]* a; n. {5 k- ?
//所有数据初始过滤去除空格和注释。
+ [) @% l" V6 [7 X* ]; r1 k$ o# y//注意:注释,空格和程序段删除(如果支持的话)处理技术, M. n  G; Z8 {- M9 x# ~
//在G代码解析器,它有助于压缩到Grbl传入的数据" o  \  g, `" w* _/ b6 M) m
//线缓冲区,这是有限的。刀位点标准实际上州一行不行
6 O9 a, X; j2 `7 c; E//不能超过256个字符,Arduino Uno没有更多内存空间。8 h8 ^* M! r, _- R& S6 |3 ^! X2 P$ l
//有更好的处理器,它会很容易把这个初步解析的5 X  T9 z) \* _+ P2 D2 w# m- H
//分离任务共享的刀位点解析器和Grbl系统命令。                                                                6 L3 p) Y# ~0 s9 S
    while((c = serial_read()) != SERIAL_NO_DATA) {                             //读取串口数据,有数据执行下面代码
7 [% k0 j0 N4 r- C2 ]: w, w      if ((c == '\n') || (c == '\r')) { // End of line reached                //如果数据是/r,/n代表一行结束
( y& ]0 ]8 C$ x; f        line[char_counter] = 0; // Set string termination character.        //设置结束标志
" x- U1 n1 U8 b; g" |        protocol_execute_line(line); // Line is complete. Execute it!        //一行完成执行此函数- {& F$ W2 X) u6 A7 y: Y5 G5 c
        comment = COMMENT_NONE;                                                //注释清零8 z% u3 F$ r4 d6 P- y: j" @6 `" s
        char_counter = 0;                                                    //字符计数清零
! ~& }0 @2 q; S$ f: N# ^  
) r7 v. U3 ]  \9 ?$ d        else {
+ O* D# A# e7 c+ a) E        if (comment != COMMENT_NONE) {
( @/ ~3 }  m: C- v' x* x- z                                                     //扔掉所有注释字符
* A; k) z+ G* |! c5 W3 |& G6 M          if (c == ')') {; ]/ w: d3 [, P+ b. S) x) V
            //最后注释。重新开始。但是如果有分号类型的注释。
+ a+ W2 s3 b% U            if (comment == COMMENT_TYPE_PARENTHESES) { comment = COMMENT_NONE; }  b7 t: R7 z, L9 c8 g& z
          }
( \( j0 `1 a4 E, Q3 r# y9 e$ M4 \      } else {+ A" T/ _% A" h4 C  L
          if (c <= ' ') {
# N8 Q' X/ w  V: z            //扔掉whitepace和控制字符+ z9 Q1 \% m; u- t
          } else if (c == '/') {
5 ]& J: P7 R$ a: M( F            //块删除不支持将忽略字符。
1 C' v: V+ Z& p! m$ I/ W            //注意:如果支持,只需要检查系统是否启用了块删除。$ ?( }5 a& W5 j
          } else if (c == '(') {0 S9 }2 o2 h) d9 {# c
            // Enable comments flag and ignore all characters until ')' or EOL.
, `7 B6 l# m- S, N* G( Z9 Y            // NOTE: This doesn't follow the NIST definition exactly, but is good enough for now.  Z& O$ T. U8 e1 O" W
            // In the future, we could simply remove the items within the comments, but retain the5 \6 i6 h, P* F+ }3 e1 a
            // comment control characters, so that the g-code parser can error-check it.
  e; _# I1 O- M: }4 h5 t            comment = COMMENT_TYPE_PARENTHESES;5 N9 ?) F" Y8 ~0 R
          } else if (c == ';') {
* J6 _' A1 q( }: b- ?            //注意:','注释EOL LinuxCNC定义。没有国家标准。
( ]! _8 e- \- \4 J  U+ r            comment = COMMENT_TYPE_SEMICOLON;+ o" g  M* E9 ]; O# X% C

/ C5 `/ N! m% L
( L- w+ _  i1 N8 z_____________________________________________________________________________________________________________________________________2 Y% j& Y9 x$ |) j
          } else if (char_counter >= (LINE_BUFFER_SIZE-1)) {                        //串口接收数据大于80字符时) j7 ~* z/ v' C; G. h9 q
            // Detect line buffer overflow. Report error and reset line buffer.        检测缓冲区溢出。报告错误和复位线缓冲区。
3 @3 i( g0 J; q# X+ f0 B6 N/ {            report_status_message(STATUS_OVERFLOW);                                //打印溢出信息
7 z, c4 X- `& B: @' _5 k7 Z" g" M            comment = COMMENT_NONE;* t& ~2 ?+ _7 ?$ t4 ]5 a
            char_counter = 0;
1 k+ E" J- P, y; B2 w+ C          } else if (c >= 'a' && c <= 'z') { // Upcase lowercase                        //小写改大写& ^* Y' T  |) v: p8 x  ?% r6 M) ?7 ]
            line[char_counter++] = c-'a'+'A';: G2 n8 x3 s* J3 C
          } else {
: x, z0 ^: y2 g8 p            line[char_counter++] = c;
) y9 b3 a8 i+ Z: v          }: G4 I( N; a7 c% j
        }
+ Q$ @& ^3 S! F; c      }
  C: Z( b. q0 y3 x! |' e  p5 c& u5 c( ^    }
, J1 |9 Q; k- w3 g+ @2 _____________________________________________________________________________________________________________________________________, _* Q5 N" `$ Y5 I8 B6 `3 a' Q. I) D
        //如果没有其他字符在串行处理读取缓冲区和执行,这表明以完成,自动启动,如果启用,任何队列动作。& J; }$ o" }: z( {( o$ t8 j3 C
        protocol_auto_cycle_start();                //自动开始协议循环
$ ^/ {' p# q& m8 C        * o* e6 L$ d# @; b% E& o+ T' G
            protocol_execute_realtime();                  //运行实时命令。2 `* B5 \6 b- O
            if (sys.abort) { return; }                 //中止标识置位程序循环重置系统。            
5 ?+ \3 E8 E, O" i# I0 m/ v  } : w9 t9 N7 T1 C2 ?2 G% u: ]' `
  return;                         //一般程序不会执行到这里
3 w: d% a' F9 q}  D. Q5 y! m) h6 N
____________________________________________________________________________________________________________________________________
9 V4 B$ }: f: T2 j$ n4 _. G! e正常情况下,读取完G代码程序会进入protocol_auto_cycle_start();//自动开始协议循环 函数下面介绍此函数
7 |( s1 }3 b3 K  N// Auto-cycle start has two purposes: 1. Resumes a plan_synchronize() call from a function that
; k% s2 U, `8 M! l  E1 U// requires the planner buffer to empty (spindle enable, dwell, etc.) 2. As a user setting that - }1 f! I, E( V
// automatically begins the cycle when a user enters a valid motion command manually. This is
+ Z# {/ ~0 M3 {// intended as a beginners feature to help new users to understand g-code. It can be disabled
6 Z+ |" K# Z& T- R- a- ~4 `// as a beginner tool, but (1.) still operates. If disabled, the operation of cycle start is
. r* J/ i0 m+ D: u1 s1 y// manually issuing a cycle start command whenever the user is ready and there is a valid motion + O1 n* O5 b2 x& w7 i' e7 b0 u
// command in the planner queue.
8 b  ]" p8 C; F7 M// NOTE: This function is called from the main loop, buffer sync, and mc_line() only and executes " t* k: F' V6 e  z2 k
// when one of these conditions exist respectively: There are no more blocks sent (i.e. streaming 2 q7 Q8 {4 m% `3 }. O
// is finished, single commands), a command that needs to wait for the motions in the buffer to 1 {: \4 C! \  a+ {3 G* l; S! j5 O
// execute calls a buffer sync, or the planner buffer is full and ready to go.
% K& b# l+ Z: v* C//自动开始有两个目的:1。回复一个plan_synchronize()调用的函数
0 i  Y* }4 B( {! q; w//需要规划师缓冲区空(主轴启用、住等)2。作为一个用户设置
5 A% p7 O7 H; P9 `  N( g//自动循环开始当一个用户输入一个有效的运动命令手动。这是
/ i* n9 w9 Q+ R//作为一个初学者的特性来帮助新用户了解刀位点。它可以被禁用
/ M# O3 I3 v' ~6 j, K7 d//作为一个初学者工具,但(1)仍然运作。如果禁用,运行周期开始" T5 F$ Y1 X' P% h$ W
//手动发出一个周期开始命令每当用户准备好,有一个有效的运动+ Z6 H" E/ D6 q+ i) @
//命令的规划师队列。0 v! o8 K; }) b/ K3 P
//注意:这个函数被称为从主循环缓冲区同步,mc_line只()并执行
! l( r' _# N" s2 o) L$ `//当其中一个条件分别存在:没有更多的块(即流发送
* N: B5 I" @& s//完成后,单一的命令),一个命令,需要等待缓冲的动作
+ U, v# }8 q7 \/ c0 k//执行调用一个缓冲区同步,或规划师缓冲区满了,准备好了。
( O" j. q2 D/ G8 A- x/ b) Nvoid protocol_auto_cycle_start() { bit_true_atomic(sys_rt_exec_state, EXEC_CYCLE_START); } ' W9 f+ u7 i+ u8 v
_______________________________________________________________________________________________
% R. e) C: g8 Y: J& [接下来程序运行protocol_execute_realtime(); /运行实时命令。! j8 Y# Q8 g8 m, @
// Executes run-time commands, when required. This is called from various check points in the main) V( R% `1 l; h) E( A  E; K6 l' r0 @
// program, primarily where there may be a while loop waiting for a buffer to clear space or any, B# k" {! e0 H9 n8 S+ a  m; c
// point where the execution time from the last check point may be more than a fraction of a second.! Z) R8 ~" K. j: n' ~; h
// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code, l6 t% @- v! _& s
// parsing and planning functions. This function also serves as an interface for the interrupts to
" ?3 ^, `6 q" O5 K/ q+ t// set the system realtime flags, where only the main program handles them, removing the need to' G- x/ w5 t/ `  e9 }& J+ R
// define more computationally-expensive volatile variables. This also provides a controlled way to / T0 a) i: v6 J
// execute certain tasks without having two or more instances of the same task, such as the planner
" K( Q& ~5 ^6 m  k$ H// recalculating the buffer upon a feedhold or override.) M1 A* }/ F6 k$ E: E+ _7 p
// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,
% A7 \% x8 S' @% f1 N  r. G// limit switches, or the main program.
* _6 f; E* L) Hvoid protocol_execute_realtime(); N+ J9 b0 A; N6 S8 K
uint8_t rt_exec; // Temp variable to avoid calling volatile multiple times.临时变量来避免多次调用不稳定。6 b4 i$ m9 Y# n6 F6 ]; H9 m; f3 }
就先分享到这吧!: I8 Q" G7 V7 }* S1 c' M
: {! W9 P) r! A: F/ t- @' q4 U7 C

! _. f6 w% [, G8 T. W6 a( u- ]. m: s3 d& B% l* P2 Z

. t2 J; ?4 ]+ T0 R, t( H5 ?# U& a3 l0 g. J

5 R+ [$ j' V" N
& I9 M) E5 c7 Z) C; E4 a' I- V$ l) C6 N2 m, p5 j

  D' C6 n+ R7 h( ^* c6 V( o/ ]4 d/ M% M8 {. f) X

4 r6 l9 v# o# U& V% C& O
8 a2 D$ x) [: h% F" Z+ `7 R5 m; X& D# t# ~

6 b4 @6 W" j! }: V! w4 O
; {, }2 a6 T/ _+ l' P* q
7 Y0 h7 S4 K5 h: \; o; y
8 H- W1 Y1 a* v- M# J7 H0 p# G
# g7 P! {+ c" G1 p, F4 z5 }1 Q( P) A& M! P; J
! q1 E8 k6 B7 l( p7 j
! m" F  ~) _- G
% [/ D, L. @& ~% R& ~

, N+ R( K& T4 A. N  r6 [: x补充内容 (2016-8-25 22:40):& E& S* N2 h0 h) n& h# J
配置说明
% y3 m- t7 }& m6 G# v; f0 j  P//这个文件包含编译时配置Grbl的内部系统。在大多数情况下,
, S: {! v. k. l( {: o2 |//用户不需要直接修改这些,但是他们在这里为特定的需求,即。! ^- H% ~+ l2 D, u% c& I
//性能调优或适应非典型的机器。
, P: C4 p! {- Q4 l3 U主要配置项:
: K; B- q* B/ R1.#define DEFAULTS_GENERIC        //在重置eepm时使用。在defaults.h改变想要的名字% L# r, S8 A0 W/ ~4 R& b9 {2 b
2.#define BAUD_RATE 115200        //配置串口波特率115200, S. ^  n. z7 d3 |! x
3.#define CPU_MAP_ATMEGA328P         // Arduino Uno CPU9 f5 G7 n. }# t+ A
4.#define CMD_STATUS_REPORT '?'        //定义实时命令特殊字符
/ v. V& G+ R; ]5.#define HOMING_INIT_LOCK         //回原点保护锁3 D8 n. o2 O# q2 x8 o4 V0 w) R
6.#define HOMING_CYCLE_0 (1<<Z_AXIS)              // 第一步Z清除工作区。
% x3 b- Y7 b5 A6 q& U  #define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // 然后X,Y在同一时间。1 I' ~0 g8 B' x6 [
7.#define N_HOMING_LOCATE_CYCLE 1 //回原点循环次数
( ]  l' r0 b$ C5 F# S/ t8.#define HOMING_FORCE_SET_ORIGIN //取消这定义迫使Grbl总是在这时候位置设置机器原点尽管开关方向。
: ~/ e1 f! c+ l5 H9.#define N_STARTUP_LINE 2 //块Grbl启动时执行的数量。
/ Q" C# W" N4 w4 J10.#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 协调或位置价值英寸2 f. V& ~9 v$ o: C
   #define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 协调在毫米或位置价值, P4 A) `6 Q. C  i+ D  o+ `
   #define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分钟的速度值7 w4 b; v- t2 _/ f
   #define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分钟! ~+ A. H  H& `) e1 Q
   #define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 对浮点小数设置值
8 o9 R0 |9 b4 n4 v11.#define LIMITS_TWO_SWITCHES_ON_AXES //如果你的机器有两个极限开关连接在平行于一个轴,您需要启用这个特性2 b0 t4 d: C4 x- u' a& Y2 K* p4 q
12.#define USE_LINE_NUMBERS         //允许GRBL跟踪和报告gcode行号1 K$ U1 U1 z8 s2 m
13.#define REPORT_REALTIME_RATE //允许GRBL报告实时进给速率
/ `6 \: d5 z5 P8 }% R& u& b; M14.#define MESSAGE_PROBE_COORDINATES  //坐标通过Grbl $ #的打印参数?
$ I  Q, y! u' {8 ^9 ]3 a15.#define SAFETY_DOOR_SPINDLE_DELAY 4000 //安全门主轴延时; x" m  ~( i# z! I; _. S
16.#define SAFETY_DOOR_COOLANT_DELAY 1000 //安全门冷却液延时6 e$ m  n. B8 T0 e
17.#define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS) //启用CoreXY运动学。
% {2 M9 }7 e( S) p18.#define COREXY // Default disabled. Uncomment to enable.改变X和Y轴的运动原理; Q9 ~' S3 G4 l
19.#define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.反转针销逻辑的控制命令6 h/ H4 r4 Q1 {, V0 f4 n
20.#define INVERT_SPINDLE_ENABLE_PIN // 反转主轴使销从low-disabled
/ X: K0 @* x- ?. }3 h4 l' P/ X2 }$ x21.#define REPORT_CONTROL_PIN_STATE //启用控制销状态反馈状态报告。* M: p8 n, f: r3 _4 Z2 b0 y
22.#define FORCE_INITIALIZATION_ALARM //启用和用户安装限位开关,Grbl将启动报警状态指示
( z4 }: G& ~. c/ r* D% u1 C% s23.#define REPORT_GUI_MODE // gui允许最小的报告反馈模式+ ]1 ?1 S$ A# }$ X6 v! N
24.#define ACCELERATION_TICKS_PER_SECOND 100 //加速度的时间分辨率管理子系统。- U, R6 T0 m# V3 v4 i" {6 {# U7 Q
25.#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING //自适应多轴步平滑(积累)是一种先进的功能 # \# {  B; n. e$ z( N( u
26.#define MAX_STEP_RATE_HZ 30000 //设置最大一步速率可以写成Grbl设置, a( f4 ?( m+ b+ P, y
27.#define DISABLE_LIMIT_PIN_PULL_UP //以下选项禁用内部上拉电阻2 Z& W/ g( v- ~* ]; b9 P4 \' Z: |
28.#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS //设置哪个轴长度补偿应用的工具。假设轴总是与选择轴工具面向负方向# \, e4 x; h, g! z. k0 u, Q' ~
29.#define VARIABLE_SPINDLE //允许变量轴输出电压不同的转速值。
2 F7 T, v3 W* C6 V4 R$ V8 r1 i3 b7 j30.#define SPINDLE_MAX_RPM 1000.0  // Max spindle RPM. This value is equal to 100% duty cycle on the PWM." Q- }0 }2 t% |% s' ^0 P
   #define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.& ]* K8 I& \8 K5 ]. L1 D
31.#define MINIMUM_SPINDLE_PWM 5 //使用的变量轴输出。这迫使PWM输出最小占空比时启用。$ z# B" J6 p! B
32.#define USE_SPINDLE_DIR_AS_ENABLE_PIN //主轴方向使能M4被删除: G& k' @8 u) |& j- W
33.#define REPORT_ECHO_LINE_RECEIVED //应该对所有正常线路送到Grbl
' n. _+ D4 ~: _0 t, [34.#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min) //最小规划师结速度。设置默认最小连接速度规划计划
1 i# q3 d& G* \' ^: k3 p' q- t/ K35.#define MINIMUM_FEED_RATE 1.0 // (mm/min)//设置计划将允许的最小进给速率
" F* O* @6 O2 k, z36.#define N_ARC_CORRECTION 12 //弧生成迭代次数之前小角度近似精确的弧线轨迹+ M7 l3 G; i" [0 X" X% H% E7 U* ?
37.#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)//定义值设置机器ε截止来确定电弧是一个原点了?
2 w' }0 A" |$ e8 l6 ~38.#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds) //延时增加表现在住。默认值设置为50毫秒( V6 `1 y, |# R# r, S; @' L/ Z' g
39.#define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.
1 d+ k; w% J# r( M6 \40.#define BLOCK_BUFFER_SIZE 18  //线性运动规划师缓冲区的数量在任何给出时间计划
; x) s8 T1 W3 D' `; X" F' w41.#define SEGMENT_BUFFER_SIZE 6 //控制之间的中间段缓冲大小的步骤执行算法
3 }! v: o9 g" Q* R42.#define LINE_BUFFER_SIZE 80 //行执行串行输入流的缓冲区大小。
( ~1 Q4 r" m  F! p+ Z: [* o( A43.define RX_BUFFER_SIZE 128 //串行发送和接收缓冲区大小4 @9 \9 d6 [4 F# v, |
44.#define TX_BUFFER_SIZE 64
$ N3 H2 w0 @2 F0 [. w* @' r# w45.#define ENABLE_XONXOFF        ////切换为串行通信发送流软件流控制。
' m4 M% A9 X, v- R3 \& |3 j" ?% h46.#define ENABLE_SOFTWARE_DEBOUNCE //一个简单的软件消除抖动特性硬限位开关。
1 @& W2 l" L# e& C47.#define HARD_LIMIT_FORCE_STATE_CHECK        //Grbl检查硬限位开关的状态
7 `' ?6 a0 G& Z' Y, c( Y48.// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:编译时错误检查的定义值:: J9 Q. x3 Z0 N- }" J

; J) j% U, s" w___________________________________________________________________________________________________  B. G) g! `1 ^" Y! G5 q# ]1 D
/*2 R& W; f7 `& y8 x* x( Z
  config.h - compile time configuration& z" ^; t  b$ S9 K0 i
  Part of Grbl) J" H. a# _' n. r6 ?5 L, `: w
& r- i* H/ _1 q
  Copyright (c) 2012-2015 Sungeun K. Jeon+ |" ~# R% X" J8 b9 c9 E  _
  Copyright (c) 2009-2011 Simen Svale Skogsrud
% ^3 W1 S& M# y# _$ v  {# j% B/ B( W: T& D
  Grbl is free software: you can redistribute it and/or modify
) f3 p" ~& m9 B4 t  it under the terms of the GNU General Public License as published by% R# A/ i/ k* H' o
  the Free Software Foundation, either version 3 of the License, or
+ J" s% {" X- U, C: C1 _; A) |$ t  (at your option) any later version.5 U. ]8 {0 I9 W) J, q; E" H

$ p$ }, _: n$ G  Grbl is distributed in the hope that it will be useful,
! B9 {8 t6 ?4 a  _! z  but WITHOUT ANY WARRANTY; without even the implied warranty of
' B% o- X! a9 Z3 V7 L! Z* I  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the3 g$ u3 v- w1 ^2 y  J* ]( @3 y
  GNU General Public License for more details.6 n, m( k: k; a0 z% K. Z

/ C4 {4 p% W+ n* {& T- c  You should have received a copy of the GNU General Public License
$ q  {9 y1 J# a+ m  along with Grbl.  If not, see <http://www.gnu.org/licenses/>.
3 N9 B3 }/ [5 {, O9 rconfig.h  -编译时配置,Grbl的一部分
: L& k' P9 u  @! Z3 j. P3 L9 l. ~5 _: P1 Q" S3 _( c$ j7 ?
版权(c)2012 - 2015 Sungeun K. Jeon5 z# R" t7 ^% G! T  }, M# E
版权(c)2009 - 2011 Simen Svale Skogsrud8 u; Z6 U9 X" n# m' S

* y0 ~! L2 m% A- C2 @9 E- qGrbl是免费软件:可以重新分配和/或修改
8 I6 Y& f! U4 u% w  u; BGNU通用公共许可证的条款下发布的自由软件基金会,版本3的许可,或(任您选)其后的版本。
0 K6 p& E$ u4 @* s4 m$ R; n% D& o2 M, L5 J& p$ _' m! j9 B- A* l6 [2 {
Grbl分布,希望这将是有用的,但是没有任何保证;没有即使的默示保证适销性或健身为特定目的。看到
1 _9 u9 c4 w- `% BGNU通用公共许可证的更多细节。
; R' U$ T. J( Y" E8 `8 c" c+ ?! \; s
你应该收到了GNU通用公共许可证的副本) `( ~! x8 l9 K/ X2 I0 i
连同Grbl。如果没有,看< http://www.gnu.org/licenses/ >。" B6 P( `- k0 v! [# H5 b

- j, x7 E6 N  I% k% T4 o*/
6 H. o$ ]  W5 o3 E  , _" c' p* z9 R" F4 @/ q) F
// This file contains compile-time configurations for Grbl's internal system. For the most part,% O( f7 }5 z9 A: X
// users will not need to directly modify these, but they are here for specific needs, i.e.  g8 x, T, W( G
// performance tuning or adjusting to non-typical machines.
8 X; W- b' N. f1 M2 q//这个文件包含编译时配置Grbl的内部系统。在大多数情况下,
8 g9 V8 k+ Y. E( |9 s+ u& j//用户不需要直接修改这些,但是他们在这里为特定的需求,即。; _6 `8 f) v" `- u$ i" Z4 z
//性能调优或适应非典型的机器。
) l& H4 T' s$ b! f3 F9 w1 {! F7 A: X! H1 x1 a6 u5 Z
// IMPORTANT: Any changes here requires a full re-compiling of the source code to propagate them.. h, v! o- `0 ^& y1 D8 m  O
//重要:任何变化需要一个完整的基于源代码的传播。. \: @- q8 j9 _( L( h& f

! S3 x, A. N; |9 t: [( ~+ d#ifndef config_h
5 Y/ \; H) }/ q# B5 u#define config_h, |1 g6 Q8 f% n
#include "grbl.h" // For Arduino IDE compatibility.4 W" `6 ?4 f  Z) z$ T
3 f; t* B# Q* \8 G, W6 t7 o( ]
// Default settings. Used when resetting EEPROM. Change to desired name in defaults.h0 T  g0 Y! H7 ]; G! m' ~
// 默认设置。在重置eepm时使用。在defaults.h改变想要的名字* n  I% l1 k' }* R8 O4 r

) _- l5 [+ [. o/ O#define DEFAULTS_GENERIC. ?0 `  m+ X0 ]5 q9 p7 z

' T. Y) y' F- ^! O; k// Serial baud rate. D' v  s3 M4 C; U( O, ^1 ]
#define BAUD_RATE 115200                //配置串口波特率115200
* t. q7 F" ]6 F( t, T7 k/ M0 _8 h8 y# O8 N1 Q
// Default cpu mappings. Grbl officially supports the Arduino Uno only. Other processor types, h" w1 \. [" k) ?4 T/ f5 A
// may exist from user-supplied templates or directly user-defined in cpu_map.h
6 ?0 r; l" ?; ?3 ~- \7 l//默认cpu映射。Grbl正式支持Arduino Uno。其他类型的处理器可能存在cpu_map.h直接从用户提供的模板或用户定义的
4 l7 }. _  x0 E  [5 D
& ^+ F% X# }$ i# ?2 {#define CPU_MAP_ATMEGA328P // Arduino Uno CPU
) N, V' `4 `5 B, H% ~, I" Q& w3 N" e. \6 c' p( t- n7 Y' k9 }: |1 k
// Define realtime command special characters. These characters are 'picked-off' directly from the
, K; \6 k$ v- X6 l) n8 ~* r# @0 u9 ]// serial read data stream and are not passed to the grbl line execution parser. Select characters- U' M6 w) V  E5 y
// that do not and must not exist in the streamed g-code program. ASCII control characters may be
4 S4 F" M. M; n) B% [, n8 Z// used, if they are available per user setup. Also, extended ASCII codes (>127), which are never in 2 d2 z3 H  s# D6 v6 E0 [
// g-code programs, maybe selected for interface programs.
. {9 Y! o6 {7 l7 b. M// NOTE: If changed, manually update help message in report.c.
/ ?% g/ |5 g, \2 c+ y: d
3 F( _* t' H. U//定义实时命令特殊字符。这些字符是直接从“各个击破”串口读取数据流并没有传递到grbl行执行解析器。选择角色! F) B! y" K  R4 S8 o! J/ W
//不,不能存在于程序流刀位点。ASCII控制字符
9 U. y& Y$ u0 \2 ?8 q) ?; u# u0 E//使用,如果他们是可用的每个用户设置。同时,扩展的ASCII码(> 127),从来没有; [6 Y- f: [5 s% ^0 J2 G8 Z5 k
//刀位点的程序,也许选择界面程序。
0 m4 m, `8 c7 b9 i7 C//注意:如果改变,手动更新report.c帮助信息。; O0 q1 v+ U2 W0 O8 v4 v

+ `8 c& w* x# H3 r- H2 r#define CMD_STATUS_REPORT '?'
0 t: Y6 ]% r% }( H$ `  I#define CMD_FEED_HOLD '!'* q( Y; [$ Q2 O
#define CMD_CYCLE_START '~'+ v. S9 t3 Q/ f- I* v
#define CMD_RESET 0x18 // ctrl-x.' L$ Z5 P' R" Z4 c
#define CMD_SAFETY_DOOR '@'  h1 V. u/ m; v8 M6 t' @! u" E$ C

. n# S! ^6 _' f7 O4 }) T& Z// If homing is enabled, homing init lock sets Grbl into an alarm state upon power up. This forces
! p( a- g" }5 u, H// the user to perform the homing cycle (or override the locks) before doing anything else. This is9 T( [4 }0 Z: c
// mainly a safety feature to remind the user to home, since position is unknown to Grbl.
$ B  R, U$ }' `7 o+ ~' N
9 u# H+ _5 O! h1 h//如果启用了回原点,导航初始化锁集Grbl进入警报状态启动。这就迫使) h( x8 e  z9 w
//用户执行归航周期(或覆盖锁)在做任何其他事情之前。这是. c1 Z6 }6 e1 L6 W
//主要安全功能,提醒用户家里,因为Grbl位置是未知的。
" ~/ o- l: A& n( N! l% T1 E8 O/ O7 f$ `' w' Q% Y4 _$ e1 ~. {" ]
#define HOMING_INIT_LOCK // Comment to disable
# r" D2 K: x' ^$ X" G. I
; m/ |4 G! R: {; s& }6 P6 b9 A5 d// Define the homing cycle patterns with bitmasks. The homing cycle first performs a search mode
, l8 S* `9 p$ v+ y// to quickly engage the limit switches, followed by a slower locate mode, and finished by a short
  W1 D; h/ }$ ~5 N, [8 a, Q/ N// pull-off motion to disengage the limit switches. The following HOMING_CYCLE_x defines are executed + D2 o2 l7 ?9 }, h/ ?' D
// in order starting with suffix 0 and completes the homing routine for the specified-axes only. If
" B  t7 E; x& @7 h, p- u// an axis is omitted from the defines, it will not home, nor will the system update its position.' w+ Y# j5 [$ _% \& z
// Meaning that this allows for users with non-standard cartesian machines, such as a lathe (x then z,
  Y2 L; R. \( J& e. H// with no y), to configure the homing cycle behavior to their needs.   j, V6 d( S* M0 O
// NOTE: The homing cycle is designed to allow sharing of limit pins, if the axes are not in the same
3 Z( a+ Q6 c1 @8 m, K5 I// cycle, but this requires some pin settings changes in cpu_map.h file. For example, the default homing
" u" C) I& |- \// cycle can share the Z limit pin with either X or Y limit pins, since they are on different cycles.! X! I: y$ M4 H  c; f6 C% B
// By sharing a pin, this frees up a precious IO pin for other purposes. In theory, all axes limit pins4 C1 X1 D! `, F! p9 h
// may be reduced to one pin, if all axes are homed with seperate cycles, or vice versa, all three axes
' R( Y# e# Y0 b' {) D6 K4 H1 f7 |// on separate pin, but homed in one cycle. Also, it should be noted that the function of hard limits
7 f' L, x7 \. n* e( H) }9 F# E// will not be affected by pin sharing.
- Z% g1 i9 l0 I3 C" H0 f% I& e2 [4 h//定义导航循环模式的位掩码。归航周期首先执行一个搜索模式
1 e% m) M+ g0 O- a3 a( C2 p3 w//快速进行限位开关,其次是较慢的定位模式,完成了由一个短
- x. N1 n  a3 F5 G6 ~//拖出运动脱离限位开关。以下HOMING_CYCLE_x定义执行% W( O4 Y, u& E9 o- ^( z; ?
//为了与后缀0开始并完成specified-axes只寻的例程。如果
( J5 n: f# m! [1 H//定义省略一个轴,它会不在家,也不会系统更新它的位置。/ h0 y( W/ k1 T2 ?$ Z
//意义,这允许用户与非标准笛卡尔的机器,比如车床(x,z,
, n. o% {0 y& D0 ~6 q) p6 B4 S1 ?" b//没有y),配置导航循环行为对他们的需求。2 q- r" L- T2 l6 S+ K$ U( T
//注意:归航周期允许共享限制针,如果轴不相同
0 F& V: l6 t. [1 B//循环,但这需要一些销设置cpu_map的变化。h文件。例如,默认的导航5 I1 b9 k: ?! p7 B1 W
//循环可以分享Z限位销X或Y限制针,因为它们是在不同的周期。2 _5 z* }) N7 P! Q, X8 W  k. @- x
//通过共享一个销,这腾出宝贵的IO销用于其他目的。从理论上讲,所有轴限制别针
  d/ ]6 p% F0 t5 {" F) l7 \//可能会减少到一个销,如果所有轴与分离周期居住的地方,反之亦然,所有三个轴
7 k; y6 S4 z- C8 p& \1 V+ L//在不同销,但这时候一个周期。同时,应该注意的是,硬限制的功能
/ y2 G0 Q/ c! t: e2 ^//将不会影响销共享。
. I- r( e( [* k; A( e//注意:默认设置为一个传统的硬件数控机器。z轴首次明确,其次是X和Y。
4 C2 j) t1 Q. t2 M' |
1 V; {. w& C" H: q( n4 E9 v6 g// NOTE: Defaults are set for a traditional 3-axis CNC machine. Z-axis first to clear, followed by X & Y.
0 ]6 ^% q5 N. V8 V2 i  c# O6 p#define HOMING_CYCLE_0 (1<<Z_AXIS)                // REQUIRED: First move Z to clear workspace. 第一步Z清除工作区。
: z% v/ E  y) l  S3 g2 t( B#define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // OPTIONAL: Then move X,Y at the same time.然后X,Y在同一时间。2 p6 V5 B- I  d3 o/ O% X& ^
// #define HOMING_CYCLE_2                         // OPTIONAL: Uncomment and add axes mask to enable
8 h" @3 t. ?, `+ N8 T8 e! h9 T  a2 h6 R# d, h1 }
// Number of homing cycles performed after when the machine initially jogs to limit switches.
  r. C' c, P( Y) G, L, q! e  P0 p9 F// This help in preventing overshoot and should improve repeatability. This value should be one or
8 x$ X7 d. q! j4 z5 _// greater.
  Z  P6 q3 w4 N% {$ c//执行回原点循环次数后,当机器最初慢跑限位开关。这个帮助防止过度,应该提高重复性。这个值应该是一个或大。
% a4 }! u1 `( V/ R5 B% m
9 q7 U" z# W/ V$ _/ B: o+ ^* Q#define N_HOMING_LOCATE_CYCLE 1 // Integer (1-128)
* Q, _: G& g- }  f5 G$ Q: K
2 L7 c8 j: R: o; G; A! _4 i4 L$ Q// After homing, Grbl will set by default the entire machine space into negative space, as is typical1 W; {) S* S' u6 ]; n2 {$ ~
// for professional CNC machines, regardless of where the limit switches are located. Uncomment this
" P" N2 ~: Z7 L// define to force Grbl to always set the machine origin at the homed location despite switch orientation.
" t/ \) }: p$ _: H- L. p" `- I& ~' j6 V9 ]2 S2 ^
//导航后,默认Grbl将整个机器空间留白,是典型的专业数控机器,不管限位开关所在的地方。  ^- ^( p! S( V! X/ U
//取消这定义迫使Grbl总是在这时候位置设置机器原点尽管开关方向。2 o2 Q5 q% ]  M+ H9 h6 O

0 Q# k$ i2 A+ s. i6 Y// #define HOMING_FORCE_SET_ORIGIN // Uncomment to enable.
: ], _' B. ~2 p9 I, f' [$ x; b/ a/ G0 t
; \& t  W- t% q  J" g" t
// Number of blocks Grbl executes upon startup. These blocks are stored in EEPROM, where the size  p7 P2 m9 b& v. m# ]6 _1 k
// and addresses are defined in settings.h. With the current settings, up to 2 startup blocks may
& ~8 Q  H) ]% s7 `1 l4 J2 ]. j// be stored and executed in order. These startup blocks would typically be used to set the g-code
+ n) O. K* c5 [2 m* h3 w// parser state depending on user preferences.
5 {6 W5 p) x, Q' H' O) }( Z; j. R! H( ]1 V' {, j% h3 Z( w1 t
//块Grbl启动时执行的数量。这些块存储在eepm,大小
" ~5 J9 m- h& c. F//和地址在settings.h中定义。与当前设置,可能2启动块
8 p" {! q3 u$ Y) W! O//存储和执行。这些启动块通常被用来设置刀位点0 Q7 x+ o& U9 k6 l# B% }
//解析器的状态取决于用户首选项。" Z2 q& J% x; h) P2 X0 @5 @& ^- x0 _

0 L7 y' O$ I3 O8 x3 R#define N_STARTUP_LINE 2 // Integer (1-2)! ^/ u7 H7 ], J1 n( O) o

* z( o8 x1 F1 G: C- w4 f/ s! i// Number of floating decimal points printed by Grbl for certain value types. These settings are
2 k8 m. g0 I5 ]// determined by realistic and commonly observed values in CNC machines. For example, position2 R3 N1 ?& M" D+ [! S$ H' `# F
// values cannot be less than 0.001mm or 0.0001in, because machines can not be physically more' x9 o/ u( M: a* a4 U# h! n& J
// precise this. So, there is likely no need to change these, but you can if you need to here.
/ w  C% D$ P/ l7 y// NOTE: Must be an integer value from 0 to ~4. More than 4 may exhibit round-off errors.
% Z. c* l1 ?0 r0 d* ]& b# I5 }& j5 n* |2 C, h0 p* k# l% U
// Grbl浮动小数点的数字印刷的特定的值类型。这些设置是
. E* N7 X# F3 p. m/ y//一般由现实和观测值在数控机器。例如,位置& q' d: b/ X5 F5 I5 ^5 l
//值不能小于0.001毫米或0.0001,因为机器不能身体更多
8 ?* l  ^/ m  B  _! F//精确。因此,有可能不需要改变这些,但你可以在这里如果你需要。  b' A2 m( Y# J' F/ w9 g2 s" n8 g
//注意:必须是一个整数值从0 ~ 4。超过4可能出现舍入错误。3 G! E9 u. v' T: I: n+ ?. o' p

! e. E! [* r) v4 U& G6 ?#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 协调或位置价值英寸, V$ I- U- G$ R# w8 N& @* N
#define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 协调在毫米或位置价值# w7 }* g4 Z6 n: n6 ?" p
#define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分钟的速度值
  \1 V- a5 D3 ]; I5 E3 J4 J#define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分钟
; D- ?( Z) C8 w#define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 对浮点小数设置值( y& W- A2 h5 R, C  a
5 h6 a0 x- _* W, y. z0 Y
// If your machine has two limits switches wired in parallel to one axis, you will need to enable
/ ~" K4 Q" Q! b# N  [// this feature. Since the two switches are sharing a single pin, there is no way for Grbl to tell4 `! v# [: s9 z6 ^3 W! }5 D3 l. @8 B
// which one is enabled. This option only effects homing, where if a limit is engaged, Grbl will % b+ |0 T/ V! ~
// alarm out and force the user to manually disengage the limit switch. Otherwise, if you have one
$ F9 R) ^3 c) ]5 B' O/ j// limit switch for each axis, don't enable this option. By keeping it disabled, you can perform a
5 D6 e- h4 d. y% r6 }  c) p// homing cycle while on the limit switch and not have to move the machine off of it.
, E" W% d& X9 @
9 @2 |5 e1 k/ |//如果你的机器有两个极限开关连接在平行于一个轴,您需要启用
3 i" D' }# U  z2 m//这个特性。自从两个交换机共享一个销,没有办法Grbl告诉
! l% T: z, s- j5 V//启用哪一个。此选项仅影响归航,如果限制,Grbl意志( N" I0 e" p' {8 t6 i; i
//报警,迫使用户手动松开限位开关。否则,如果你有一个
% {6 G1 g* K0 {4 U1 V% X//为每个轴限位开关,不启用该选项。通过保持禁用,您可以执行
! R5 q, ]4 r5 I+ o6 r% {: z//导航循环在限位开关并没有将这台机器。& y  l( {* a4 a7 W$ ~" i8 G8 x9 r
- Z* b; U9 c: i8 ^
// #define LIMITS_TWO_SWITCHES_ON_AXES' {7 ?7 V9 a3 Q% W
& `1 i; }& ]. H2 a& l
// Allows GRBL to track and report gcode line numbers.  Enabling this means that the planning buffer
! K& M4 a. `, }- {; j// goes from 18 or 16 to make room for the additional line number data in the plan_block_t struct
: f8 J& w* z2 S/ T2 n, P5 z
' a9 ~+ l, B$ J" x6 l  X. l! I  x//允许GRBL跟踪和报告gcode行号。使这意味着计划缓冲从18岁或16岁,为额外的行号plan_block_t结构中的数据2 }* d& M; M1 ]0 q9 \. [7 @

% R: _! @) [7 o& H, J// #define USE_LINE_NUMBERS // Disabled by default. Uncomment to enable.
; Y5 d4 x/ L; N- v0 f% |! }( E5 p! X9 I4 B8 W9 x$ \9 s
// Allows GRBL to report the real-time feed rate.  Enabling this means that GRBL will be reporting more % Z1 {8 Z- N" J
// data with each status update." s$ U: V* D5 S" t
// NOTE: This is experimental and doesn't quite work 100%. Maybe fixed or refactored later.+ v2 s0 ~/ J, H5 W/ R1 r4 k! W
//允许GRBL报告实时进给速率。使这意味着GRBL将报告数据和状态更新。
' A" |( U7 S3 C//注意:这是实验和100%没有工作。也许以后固定或重构。# g0 I1 J9 n+ a3 {8 Z

* V1 Y% z) G, h% q- w- {. Q// #define REPORT_REALTIME_RATE // Disabled by default. Uncomment to enable.
7 u" U+ G' P* z9 ]- U
$ O! O& z$ ~4 z0 Y8 \8 p// Upon a successful probe cycle, this option provides immediately feedback of the probe coordinates
' L. T3 P1 z8 T& R// through an automatically generated message. If disabled, users can still access the last probe
/ F0 L+ t# J2 v! K4 h% M8 z# K( N// coordinates through Grbl '$#' print parameters.
3 B' r# h5 u, ?+ x( h( U+ q/ w//在一个成功的调查周期,这个选项提供立即反馈的探测器坐标3 D6 v% y% F4 S1 v, }
//通过一个自动生成的消息。如果禁用,用户仍然能够访问调查+ q; ]# r, y! `, Q( {- v$ F
//坐标通过Grbl $ #的打印参数。4 S! {6 k& x$ p/ T* O0 N& @" {# C

( z- R$ D- @% y$ b" m  `9 C#define MESSAGE_PROBE_COORDINATES // Enabled by default. Comment to disable." n$ }& \/ |+ e3 ^) x, P# s! R
: {4 I% H% @* Q9 V9 o
// Enables a second coolant control pin via the mist coolant g-code command M7 on the Arduino Uno
% n- R( x2 {/ }) T// analog pin 5. Only use this option if you require a second coolant control pin.
! s% O+ E" n2 N7 ]" o// NOTE: The M8 flood coolant control pin on analog pin 4 will still be functional regardless.2 s% u# j9 w+ V" j# N
// #define ENABLE_M7 // Disabled by default. Uncomment to enable.- K& F% ~. ~- F0 R  }9 y0 T( z2 U) c
& ?" Z' V5 @5 s/ q9 I- A
// This option causes the feed hold input to act as a safety door switch. A safety door, when triggered,
+ z( z" c& P6 X// immediately forces a feed hold and then safely de-energizes the machine. Resuming is blocked until
% D8 `- ]5 k6 }& P1 O// the safety door is re-engaged. When it is, Grbl will re-energize the machine and then resume on the2 I& [* k* a2 ]* A; V
// previous tool path, as if nothing happened.
. P+ S2 u: F4 O* }3 C  n// #define ENABLE_SAFETY_DOOR_INPUT_PIN // Default disabled. Uncomment to enable.: s, D- H  o2 c% N1 a

9 b0 u4 Q( [# H  |7 O// After the safety door switch has been toggled and restored, this setting sets the power-up delay$ b/ w8 ?9 w6 I" E
// between restoring the spindle and coolant and resuming the cycle.
) I& f- o/ e5 C# Y. Y. L; E// NOTE: Delay value is defined in milliseconds from zero to 65,535.
* V6 j. z) \) |9 j  f4 H
- S; e* C2 J# K  G8 [6 d//定义导航循环模式的位掩码。归航周期首先执行一个搜索模式
, S) D0 t% \6 U! v//快速进行限位开关,其次是较慢的定位模式,完成了由一个短
. q% f7 _" A- z2 g. ?" q1 P% n//拖出运动脱离限位开关。以下HOMING_CYCLE_x定义执行
9 N! q* g4 c7 J- y4 w//为了与后缀0开始并完成specified-axes只寻的例程。如果( e1 e5 y/ Z) B
//定义省略一个轴,它会不在家,也不会系统更新它的位置。
+ ?7 z, j  V7 s( Z; K0 [' n//意义,这允许用户与非标准笛卡尔的机器,比如车床(x,z,
* L3 Y' P5 |" i  T- Q9 n3 i& h//没有y),配置导航循环行为对他们的需求。
8 X; z$ \2 V' O+ c4 {1 [//注意:归航周期允许共享限制针,如果轴不相同" q6 S( U4 l+ a$ V
//循环,但这需要一些销设置cpu_map的变化。h文件。例如,默认的导航: k7 H4 L7 q) z* d  l5 x0 T' X
//循环可以分享Z限位销X或Y限制针,因为它们是在不同的周期。: a" O/ J4 \" d( u
//通过共享一个销,这腾出宝贵的IO销用于其他目的。从理论上讲,所有轴限制别针$ k- @- d. F6 |. Y5 F) E
//可能会减少到一个销,如果所有轴与分离周期居住的地方,反之亦然,所有三个轴7 B5 p; p8 T. l( Y) R0 Y
//在不同销,但这时候一个周期。同时,应该注意的是,硬限制的功能2 K0 c. S$ R/ Q; c
//将不会影响销共享。+ P  q' Y# A" ~: O: R, }
//注意:默认设置为一个传统的硬件数控机器。z轴首次明确,其次是X和Y。/ P4 l7 d! ^, ^# L! ]% d5 l# t

7 v9 M- X4 R( ]: Q
$ ]; I+ u8 X: C2 A" l+ B) w7 d6 {#define SAFETY_DOOR_SPINDLE_DELAY 40006 x5 ^' E4 M( c
#define SAFETY_DOOR_COOLANT_DELAY 1000
1 t8 X7 g4 M: @" f: E& R
6 K% h( A5 e( C' q9 f  {+ D  ~// Enable CoreXY kinematics. Use ONLY with CoreXY machines. ' n, y/ x$ f3 ]7 T( T0 g# ~! j
// IMPORTANT: If homing is enabled, you must reconfigure the homing cycle #defines above to 0 m" r/ W& Z' o% {( ]% B9 D
//启用CoreXY运动学。只使用与CoreXY机器。5 t0 q+ b! V9 V0 X; ~$ }$ v/ q
//重要:如果启用了自动寻的,你必须重新配置导航循环#定义上面
4 l3 u8 @# `  ?  l% c; F" A
" ~/ }! f; Z3 w8 F7 u( w& j$ ?// #define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS)- q2 Z4 {' k' @; F; X5 R" F/ @$ t

& l$ `* l) m  @& x7 M' G1 y/ v// NOTE: This configuration option alters the motion of the X and Y axes to principle of operation
0 t$ C( `8 k8 {2 R// defined at (http://corexy.com/theory.html). Motors are assumed to positioned and wired exactly as
3 P# h1 X1 _. m3 D0 l$ C// described, if not, motions may move in strange directions. Grbl assumes the CoreXY A and B motors% ~- h1 W; b: J8 y) N
// have the same steps per mm internally.4 {8 z- R1 G5 P4 {) }7 V9 F
//注意:这种配置选项改变X和Y轴的运动原理,操作3 Z9 ]$ n9 `9 s' c
//定义(http://corexy.com/theory.html)。汽车被认为定位和连接一样- }; q% e3 M8 v" N
//描述,如果没有,运动可能会奇怪的方向移动。A和B Grbl假设CoreXY马达
2 h0 K0 r1 T! [' z% ~* N( m: q. m//每毫米内部有相同的步骤。/ L: S, t2 P" u! N' B; @$ h
9 [5 F" W$ _: }# u) u
// #define COREXY // Default disabled. Uncomment to enable.: d! W  c, }: A) K
. {4 K* q1 o; \4 p) o. i# P* w% H  [
// Inverts pin logic of the control command pins. This essentially means when this option is enabled
6 h1 Q' g: S0 U6 o// you can use normally-closed switches, rather than the default normally-open switches.
8 r1 N( C1 N9 |* v// NOTE: Will eventually be added to Grbl settings in v1.0.$ l4 r8 F- z0 O/ A/ S7 @
//反转针销逻辑的控制命令。这实质上意味着当启用这个选项
- i3 Z6 n- ?% a' B7 P5 c' ]//可以使用闭合开关,而不是默认的常开开关。1 |/ H) `4 ]1 I$ H5 |
//注意:最终将被添加到在v1.0 Grbl设置。
$ i' ^* `# c0 Z5 j/ B. w) c9 `7 o/ W* _6 Y8 V( L2 ]/ @# s) Q& m3 ^" I* V
// #define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.7 i* h5 b) s% ~$ \- G

$ \5 ^4 X- y( M) O3 @// Inverts the spindle enable pin from low-disabled/high-enabled to low-enabled/high-disabled. Useful
) e* h6 s. \$ g" L" |# ]$ S// for some pre-built electronic boards.' S7 B' H  S/ W6 A
// NOTE: If VARIABLE_SPINDLE is enabled(default), this option has no effect as the PWM output and 6 m$ N9 E; K! g9 f0 T/ e1 z) C
// spindle enable are combined to one pin. If you need both this option and spindle speed PWM,
! Y. ?0 G; b3 j* z% C' F9 o// uncomment the config option USE_SPINDLE_DIR_AS_ENABLE_PIN below.
5 o4 O: s( A/ B5 `//反转主轴使销从low-disabled / high-enabled low-enabled / high-disabled。有用的! Y' ~3 D+ i8 G: m4 }  _( _- n
//预构建的电子板。
: t6 j0 E) f, H7 h//注意:如果启用了VARIABLE_SPINDLE(默认),这个选项作为PWM输出并没有影响# M0 \' d+ v& k( V+ Y
//销轴使结合。如果你需要这个选项和主轴转速PWM,  ^" z0 z8 p+ M5 l
//取消注释以下配置选项USE_SPINDLE_DIR_AS_ENABLE_PIN5 I, v) j; M" ^6 Y$ C9 K

  _; i7 X( F  R+ \( j// #define INVERT_SPINDLE_ENABLE_PIN // Default disabled. Uncomment to enable.
0 E# J$ E4 O1 e0 L: f1 c/ z4 U+ s" E& R: D6 ]3 O
// Enable control pin states feedback in status reports. The data is presented as simple binary of
5 r- |# Q7 p! ]# n; A( W% L% }! |// the control pin port (0 (low) or 1(high)), masked to show only the input pins. Non-control pins on the - \, O7 e; t$ U  y; y9 |! \
// port will always show a 0 value. See cpu_map.h for the pin bitmap. As with the limit pin reporting,/ D7 T/ v& F& ]' @+ z- N
// we do not recommend keeping this option enabled. Try to only use this for setting up a new CNC.
7 a! x! ^0 y% j/ C( t( O& C//启用控制销状态反馈状态报告。作为简单的二进制数据/ P  u# b- @" h% J
//控制针端口(0(低)或1(高)),蒙面,只显示输入插脚。非控制性针上( G4 x: j$ a7 |' z; _% s& k
//端口总是显示0值。看到cpu_map。针位图h。与限制销报告,
! H! \# e: [8 o) }' M" X9 Z6 S//我们不推荐保持启用这个选项。尽量只使用这个设置一个新的数控。& Z7 g/ O! T' k1 O$ V& T6 o4 c+ m
; V& v& R3 L9 J% j# ?, J5 L
// #define REPORT_CONTROL_PIN_STATE // Default disabled. Uncomment to enable.
( f6 D1 r8 W8 k6 v4 n! B) e0 M/ L3 J2 Y/ X% R) t6 H* r( L% Z
// When Grbl powers-cycles or is hard reset with the Arduino reset button, Grbl boots up with no ALARM
& n5 h/ e4 o! f" d) G' m// by default. This is to make it as simple as possible for new users to start using Grbl. When homing
6 q' o( m  h9 k1 a' T$ \// is enabled and a user has installed limit switches, Grbl will boot up in an ALARM state to indicate . }6 A8 i5 I! M8 \( u- S
// Grbl doesn't know its position and to force the user to home before proceeding. This option forces
9 m7 A' L1 Q0 G0 b$ F// Grbl to always initialize into an ALARM state regardless of homing or not. This option is more for
0 e: B; r- G' @8 n9 r' Q3 M// OEMs and LinuxCNC users that would like this power-cycle behavior.
$ `8 e# e( e! z3 {* }# r//当Grbl powers-cycles还是硬重置Arduino复位按钮,Grbl启动没有报警% z# ~0 D3 j# v0 D/ ~+ R
//默认情况下。这是为了让新用户尽可能简单使用Grbl开始。当归航* c; L  u( o% D" Z0 M0 e
//启用和用户安装限位开关,Grbl将启动报警状态指示0 n" e3 r  i3 P$ u
// Grbl不知道它的位置,迫使用户在继续之前回家。这个选项部队
& c  X) n0 l0 X2 p2 x4 a- h  W& a; |// Grbl总是初始化进入警报状态不管归航。这个选项是更多/ O# c5 I( D% L' g. A0 e( i! b
//原始设备制造商和LinuxCNC用户这样的控制行为。
! A3 j# Q7 Y+ e/ V7 v& A; X5 E/ M% e( t4 g) z5 y; ^1 K  L
// #define FORCE_INITIALIZATION_ALARM // Default disabled. Uncomment to enable.2 U; E2 ~, |$ S

1 C! H- f$ N- T* u0 b2 u. }* R( r5 q, y// ---------------------------------------------------------------------------------------3 C: h* B, i; i9 F5 e
// ADVANCED CONFIGURATION OPTIONS://高级配置选项:  z* {; W( s! `

+ ~' V7 G( `: Y( `/ @& z2 Q// Enables minimal reporting feedback mode for GUIs, where human-readable strings are not as important.
) k! [' ?: n5 k1 h% ^" u7 A: e// This saves nearly 2KB of flash space and may allow enough space to install other/future features.  E5 ?( Y1 C$ Z9 L0 I' v
// GUIs will need to install a look-up table for the error-codes that Grbl sends back in their place.
+ W" ?' c  }2 ^7 C; f4 i# l// NOTE: This feature is new and experimental. Make sure the GUI you are using supports this mode.- y% S  K3 r+ I6 d7 V1 U8 V4 Y

* ]+ J5 N1 G; u1 b9 P, ?' i* c% C// gui允许最小的报告反馈模式,人类可读的字符串在哪里不重要。. h- [0 f/ J) e1 O! K: B
//这个节省近2 kb的闪存空间,允许足够的空间来安装其他/未来的功能。
3 q6 G$ {" L# k// gui需要安装一个查找表的错误代码Grbl发回。' F* b" S8 B2 j$ G
//注意:此功能是新的和实验。确保您使用的GUI支持这种模式。
" P% U& p9 g, e3 d6 x
7 _: K3 T- g& B6 v// #define REPORT_GUI_MODE // Default disabled. Uncomment to enable.# e8 Y# {  ?, u" P: l" L4 @

7 p  M/ X  N7 h. J4 C# `// The temporal resolution of the acceleration management subsystem. A higher number gives smoother2 |) m; @* {8 J  b: {; U
// acceleration, particularly noticeable on machines that run at very high feedrates, but may negatively
4 J/ ?! Z; I+ u$ B5 L# E9 s8 ?// impact performance. The correct value for this parameter is machine dependent, so it's advised to8 h$ f$ V# q0 Y# o
// set this only as high as needed. Approximate successful values can widely range from 50 to 200 or more.  ~1 H6 d( A8 B6 x
// NOTE: Changing this value also changes the execution time of a segment in the step segment buffer. , i+ G! Q/ l3 o
// When increasing this value, this stores less overall time in the segment buffer and vice versa. Make. b  o; K& A7 ]. G( l
// certain the step segment buffer is increased/decreased to account for these changes.+ ~: @7 I0 k2 p# [: J
//加速度的时间分辨率管理子系统。更多更平稳# b1 ]7 }& D" T' D
//加速度,特别明显的机器上,运行在非常高的进料速度,但可能负面( a+ y) r+ L% T8 N9 |5 K2 U: U
//影响性能。正确的值为这个参数是依赖于机器的,所以建议" x6 ~8 `" U9 U9 Y2 n& o
//这只设置为高。近似成功的价值观可以广泛的范围从50到200或者更多。
( ~4 f6 S7 ?( v- r//注意:改变这个值也变化的部分步骤的执行时间缓冲。/ e& D7 ?- I/ `8 B' Z- D
//增加这个值时,这个商店部分缓冲区的总时间减少,反之亦然。使8 `- O2 q6 E; A  X, p# b. Q
//特定步骤段缓冲是考虑这些变化增加/减少。- L% F2 P  \, ]

' g3 X2 ?$ m( R#define ACCELERATION_TICKS_PER_SECOND 100  //加速度的时间分辨率管理子系统。更多更平稳
; L) V! a  b- ~" M* z+ E! C" N$ g- y2 A" R! w0 T
// Adaptive Multi-Axis Step Smoothing (AMASS) is an advanced feature that does what its name implies,
' g( Q: V  m6 c4 |5 J// smoothing the stepping of multi-axis motions. This feature smooths motion particularly at low step
2 Y% D- o6 \3 P: f6 k// frequencies below 10kHz, where the aliasing between axes of multi-axis motions can cause audible 8 d5 o) n6 b3 r( e) }
// noise and shake your machine. At even lower step frequencies, AMASS adapts and provides even better# y) i! _1 T5 a& s& s& F
// step smoothing. See stepper.c for more details on the AMASS system works.: \0 k6 J+ O2 l; x
//自适应多轴步平滑(积累)是一种先进的功能,它的名字所暗示的那样,
% n: u" v7 i3 c9 ^  S' m' n//平滑的多轴步进运动。这个特性平滑运动尤其是在低一步
" `( y1 ?& z5 K7 P$ o//频率低于10 khz,轴之间的混叠的多轴运动可能导致音响
2 ~; D" b) p# w//噪音和震动你的机器。在更低的频率步,积累适应并提供更好
- s* a3 [  f: z9 i//步骤平滑。看到步进。c更多细节的积累系统的工作原理。8 A  ?& c3 {! U5 j: k: ^. m. ^9 n

! s" E$ E6 D4 F8 r+ e& ~#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING  // Default enabled. Comment to disable.//自适应多轴步平滑
; V: u- T' {5 x+ {; D1 j7 t& w" M) h/ u: E/ m+ ^2 X# _
// Sets the maximum step rate allowed to be written as a Grbl setting. This option enables an error   t' V! C! S1 ]! G+ {" u' G
// check in the settings module to prevent settings values that will exceed this limitation. The maximum
# U! g# E8 J: u) I# O// step rate is strictly limited by the CPU speed and will change if something other than an AVR running
" L- `/ V3 u0 q// at 16MHz is used.; }; B( M  l; [$ r( [  q8 G
// NOTE: For now disabled, will enable if flash space permits.
0 z, x% A8 [" G//设置最大一步速率可以写成Grbl设置。这个选项可以使一个错误
4 h+ F4 F, b, d7 w$ V4 Y/ V//设置模块中检查,防止设置值将超过这个限制。的最大
2 A7 i6 ~4 Q5 \//步骤严格限制的CPU速度也会改变如果是其他AVR运行/ W0 D" L$ H2 e% {* K- f
//使用16兆赫。7 v# }+ O; Q5 A' R7 F+ T8 j
//注意:现在残疾,将使如果flash空间许可。
3 Y% v3 @" m, I! J( D) r( h
- p3 K7 K3 p" Q" @8 V7 u. z6 M3 `9 n// #define MAX_STEP_RATE_HZ 30000 // Hz 设置最大一步速率
3 q  y, t7 V! V0 c0 R3 k2 V! k7 e: y' U0 d" [1 ]
// By default, Grbl sets all input pins to normal-high operation with their internal pull-up resistors
3 r) x) h4 n( C0 H// enabled. This simplifies the wiring for users by requiring only a switch connected to ground,
5 X' m: z. ^/ L// although its recommended that users take the extra step of wiring in low-pass filter to reduce
1 ?. M% f! m- O/ @7 C; E3 @# i7 V// electrical noise detected by the pin. If the user inverts the pin in Grbl settings, this just flips
! b9 z4 x% _) w$ A5 R: K// which high or low reading indicates an active signal. In normal operation, this means the user
, g1 S, z. N' ?! Q; j- E// needs to connect a normal-open switch, but if inverted, this means the user should connect a
# e0 ~5 l/ f5 B6 |; y( r// normal-closed switch. , e& p) k  h( S* x
// The following options disable the internal pull-up resistors, sets the pins to a normal-low
5 b$ C* _6 k" u8 O" G/ E// operation, and switches must be now connect to Vcc instead of ground. This also flips the meaning 2 Z' V6 n$ Z* Y( Y
// of the invert pin Grbl setting, where an inverted setting now means the user should connect a
8 P7 K/ Q# n% H2 m9 @3 v, Z0 s// normal-open switch and vice versa.! |- M& F* I- w) c: \
// NOTE: All pins associated with the feature are disabled, i.e. XYZ limit pins, not individual axes.4 {) X% P, O$ X: l) O& ?' Z8 m$ A
// WARNING: When the pull-ups are disabled, this requires additional wiring with pull-down resistors!
: w$ C  k3 G$ S2 Y' ~//默认情况下,Grbl所有输入引脚设置为正常高操作的内部上拉电阻, A* N% I# w/ _8 P7 Z
//启用。这简化了布线为用户只需要一个开关连接到地面,* }) I* ?4 y- s; g
//虽然其建议用户采取额外的步骤,在低通滤波器来减少布线" K. F  G! _+ H
//电噪音检测销。如果用户反转的销Grbl设置,这只是翻转
  s( E8 {3 P+ `& Z, [/ N) H//读高或低表明一个积极的信号。在正常操作中,这意味着用户1 E% N; C* I7 t) @2 d+ J* e" B
//需要连接一个常开开关,但如果倒,这意味着用户应该连接
) h0 I3 b7 c# J3 H/ G// normal-closed开关。( r: M8 `- H2 ?6 \( F3 P
//以下选项禁用内部上拉电阻,一般低设置别针; s6 S( |1 {' B; @/ ]4 f. y% x
//操作,现在开关必须连接到Vcc代替地面。这也掀的意思
; e# g4 a3 y" g- m7 }. `* i  b( F//反销Grbl设置,一个倒置的设置现在意味着用户应该连接  u1 }" Q! m0 p# V- _' }7 \% C& ^  p
//常开开关,反之亦然。# X5 c. {% u7 p: G/ b/ F
//注意:所有针与功能被禁用,例如XYZ限制针,而不是单独的轴。' v+ F$ E. x4 u5 t
//警告:引体向上被禁用时,这需要额外的布线与下拉电阻!
9 y. E& ]5 ^6 M4 S' a
/ I$ v: ]3 p$ F/ ~6 C5 a! W//#define DISABLE_LIMIT_PIN_PULL_UP //以下选项禁用内部上拉电阻
( g: d: ]0 P0 L/ {' ~! B//#define DISABLE_PROBE_PIN_PULL_UP8 E; s3 s* g7 }$ j* p
//#define DISABLE_CONTROL_PIN_PULL_UP
0 c$ e8 S6 M9 z
) e6 S3 n6 J0 [- h0 a- T. |// Sets which axis the tool length offset is applied. Assumes the spindle is always parallel with
' `/ j6 W( Y/ p$ b8 L+ |3 e6 Z// the selected axis with the tool oriented toward the negative direction. In other words, a positive
6 e$ h0 L: D4 y- w* l& z1 D// tool length offset value is subtracted from the current location.
2 J) T0 L& {1 U0 [) i0 ^//设置哪个轴长度补偿应用的工具。假设轴总是与: T2 h5 U7 N( u% R! ^7 r2 c$ H
//选择轴工具面向负方向。换句话说,一个积极的
1 b5 Q& j7 J# j, T//工具长度偏移值减去从当前位置。
" F$ J9 T5 f$ i$ j+ N
- d( b1 ?7 ]$ b#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS // Default z-axis. Valid values are X_AXIS, Y_AXIS, or Z_AXIS.设置哪个轴长度补偿应用的工具
3 B$ G; n) n0 ?4 l, y" U; t$ A. y* T, S8 ?$ O
// Enables variable spindle output voltage for different RPM values. On the Arduino Uno, the spindle
0 w# G. Z, H5 X. F; X8 s) ?// enable pin will output 5V for maximum RPM with 256 intermediate levels and 0V when disabled.. ]2 M8 w. u' c- b6 S. d
// NOTE: IMPORTANT for Arduino Unos! When enabled, the Z-limit pin D11 and spindle enable pin D12 switch!
4 D4 Z% V  H3 |4 h// The hardware PWM output on pin D11 is required for variable spindle output voltages.
7 `8 n- M3 O6 n0 n//允许变量轴输出电压不同的转速值。Arduino Uno,主轴' Q' y' E8 _% `" A) @
//启用销将输出5 v的最高转速256中级水平和0 v时禁用。
7 }! Z$ u  u8 K//注意:重要Arduino凯泽本人!当启用时,Z-limit销这里和轴销D12开关!# l; y. \2 L6 J% f6 r( i
//硬件PWM输出销这里需要变量轴输出电压。
5 D) u) B3 l$ \
3 {/ q0 I3 t+ [' I#define VARIABLE_SPINDLE // Default enabled. Comment to disable.//允许主轴输出电压不同的转速值
# W/ L% a# t7 T5 {1 W
- D- a- `& T' T% x// Used by the variable spindle output only. These parameters set the maximum and minimum spindle speed8 b0 L, `( p' K$ E
// "S" g-code values to correspond to the maximum and minimum pin voltages. There are 256 discrete and
& G$ m$ h, y5 u7 V( }// equally divided voltage bins between the maximum and minimum spindle speeds. So for a 5V pin, 1000- _3 D5 \# Y6 H/ F; r( z  R
// max rpm, and 250 min rpm, the spindle output voltage would be set for the following "S" commands: % F. F( v  R" c* V% w
// "S1000" @ 5V, "S250" @ 0.02V, and "S625" @ 2.5V (mid-range). The pin outputs 0V when disabled.
* |" l# D6 J! J3 }6 I//使用的变量轴输出。这些参数设置最大和最小轴转速' |" I6 s( y! ^* e/ }9 ]
//“S”刀位点值对应于销电压的最大值和最小值。有256个离散和( c2 _0 c& c: o
//电压平均分配箱主轴速度的最大值和最小值之间。所以对于一个5 v销,1000
- V" b' E6 v9 g5 s// max rpm,250分钟rpm,主轴输出电压将为以下“S”命令:( [' d+ {. o& v5 a& Z8 S
// @“S1000 5 v,“S250”@ 0.02 v,“S625”@ 2.5 v(中档)。销输出0 v时禁用。
4 }/ E# m% j  ]# y* _& h9 \" S) ]; r
#define SPINDLE_MAX_RPM 1000.0 // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.. \9 ]8 u# A& ~% Y
#define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.
/ x1 r- A7 V; s* f, C8 `: F( U5 q% u, e0 a
// Used by variable spindle output only. This forces the PWM output to a minimum duty cycle when enabled.
8 T, s- S: i% u& W+ u// When disabled, the PWM pin will still read 0V. Most users will not need this option, but it may be % }/ J9 W1 ~; U7 |# _2 K8 j
// useful in certain scenarios. This setting does not update the minimum spindle RPM calculations. Any
# i* u- E2 z8 q7 n% A" L7 F: X// spindle RPM output lower than this value will be set to this value./ J  I( ^' ^- k% `' B0 C$ T0 |
//使用的变量轴输出。这迫使PWM输出最小占空比时启用。9 R  G* L2 V0 _1 z/ D
//当禁用,PWM销仍读0 v。大多数用户不需要这个选项,但是它可能是
- z1 j/ U4 m; @: y) u//在某些情况下很有用。这个设置不会更新最小主轴转速计算。任何
/ [" Z6 w8 e* z//输出轴转速低于这个值将被设置为这个值。; R+ t$ H# N- M
: E% ]' M1 m+ x; q8 g4 y' B# H
// #define MINIMUM_SPINDLE_PWM 5 // Default disabled. Uncomment to enable. Integer (0-255): S) V* X, f& E0 B
) o/ _1 W- y4 U- n( c9 z
// By default on a 328p(Uno), Grbl combines the variable spindle PWM and the enable into one pin to help & L/ }. E6 T' N$ L. G
// preserve I/O pins. For certain setups, these may need to be separate pins. This configure option uses' B& W: l/ l; n( w
// the spindle direction pin(D13) as a separate spindle enable pin along with spindle speed PWM on pin D11. , n+ {, O6 @0 J2 k4 c8 q) C+ g
// NOTE: This configure option only works with VARIABLE_SPINDLE enabled and a 328p processor (Uno).
; _% e* u# i9 R& J// NOTE: With no direction pin, the spindle clockwise M4 g-code command will be removed. M3 and M5 still work.' A' c& v& ^) i( q! h
// NOTE: BEWARE! The Arduino bootloader toggles the D13 pin when it powers up. If you flash Grbl with
1 ?! A: k* N8 A+ U# }: X) k8 b% ~3 N( x// a programmer (you can use a spare Arduino as "Arduino as ISP". Search the web on how to wire this.), ; G- {1 h( m% F) l
// this D13 LED toggling should go away. We haven't tested this though. Please report how it goes!' G( @$ k7 h+ N5 c2 |
//默认ATmega328 p(Uno),Grbl结合变量轴PWM和使到一个销的帮助" `% V% `, j: y2 D, h# s) j
//保存I / O管脚。对于某些设置,这些可能需要单独的别针。这个配置选项使用8 ^. M# t& r3 |6 c$ x* H
//方向轴销(D13)作为一个单独的轴销上启用销以及主轴转速PWM这里。
/ {" x- V! e( J* ?5 I- }//注意:该配置选项仅适用于VARIABLE_SPINDLE启用和328 p处理器(Uno)。: r7 k  ?/ v3 j! k, U% u- W
//注意:没有方向销,主轴顺时针M4刀位点命令将被删除。M3和M5仍然工作。% `( ^, `5 c6 W6 @; }& T% Q
//注意:小心!Arduino引导装载程序切换D13销的权力。如果flash Grbl" ^  c) I, h/ z$ d) E
//程序员(您可以使用一个备用Arduino“Arduino ISP”。搜索网络如何线),
9 f% w6 X# k( a5 |: ?0 G$ S//这D13导致切换应该消失。我们还没有测试这个。请报告将会怎样!" t0 }: Z3 @* t/ G

' ~/ W$ r( y) ~2 s* S) B// #define USE_SPINDLE_DIR_AS_ENABLE_PIN // Default disabled. Uncomment to enable.' s' j/ e& h; s

$ I6 k# f& s/ k# r$ r7 G// With this enabled, Grbl sends back an echo of the line it has received, which has been pre-parsed (spaces8 I7 |' @6 k+ c. o1 |0 t9 r
// removed, capitalized letters, no comments) and is to be immediately executed by Grbl. Echoes will not be
/ N& \1 ^( ]+ g, A! s* u3 n& I// sent upon a line buffer overflow, but should for all normal lines sent to Grbl. For example, if a user . P. z6 l" E9 P# k2 A, I
// sendss the line 'g1 x1.032 y2.45 (test comment)', Grbl will echo back in the form '[echo: G1X1.032Y2.45]'.  V) m; l9 F- |# z9 m6 Y1 D
// NOTE: Only use this for debugging purposes!! When echoing, this takes up valuable resources and can effect& I# m! r( r% {4 N$ [7 v0 T
// performance. If absolutely needed for normal operation, the serial write buffer should be greatly increased
: e" z5 ]1 r7 f. [  x// to help minimize transmission waiting within the serial write protocol.- m3 J9 W9 B0 U5 z0 @9 F0 c& b
- J0 N# `8 x, h) q2 ?( I
//启用,Grbl发回的回声线已收到,已预编译(空间& }/ }  F( ?% R1 r" [2 N
//移除,大写字母,没有评论),由Grbl立即执行。回声将不会
) z8 q# l- S# K( A6 z0 N" _3 c//发送一个线缓冲区溢位,但应该对所有正常线路送到Grbl。例如,如果一个用户
; ?7 ]- I4 Z/ p; A& w//发送线的g1 x1.032 y2.45(测试评论)形式”,Grbl将回声”(回声:G1X1.032Y2.45]”。
3 e$ ], r5 w) G//注意:只使用这个调试! !当呼应,这占用了宝贵的资源,可以影响; \  E. W' b' q' F( O! y$ N
//性能。如果正常运行所需的绝对,串行写入缓冲器应该大大增加& w7 \1 Y4 O0 E$ e
//帮助最小化传输等系列内写协议。
  k( X% {8 ]0 P1 ^
8 Q2 t2 `/ G: ~& l/ Z5 C// #define REPORT_ECHO_LINE_RECEIVED // Default disabled. Uncomment to enable.( R% d2 [3 b' {: O* C

" e, Y3 s. b1 J' T2 }// Minimum planner junction speed. Sets the default minimum junction speed the planner plans to at
# b. v0 e7 h8 i/ w( x6 L// every buffer block junction, except for starting from rest and end of the buffer, which are always1 G' t, @5 C; Q* ^- {/ H' o
// zero. This value controls how fast the machine moves through junctions with no regard for acceleration+ Q2 m5 Y9 P7 Y! y; u9 Y
// limits or angle between neighboring block line move directions. This is useful for machines that can't
( E. x. b. O9 w3 \7 [3 ^1 H// tolerate the tool dwelling for a split second, i.e. 3d printers or laser cutters. If used, this value0 L; c" k9 f" J0 ]$ l
// should not be much greater than zero or to the minimum value necessary for the machine to work.$ m9 p" o9 c4 |* t
7 ]7 d# B, Y/ d: ^' ~) Z
//最小规划师结速度。设置默认最小连接速度规划计划
- o5 y% Q$ s) J% y* W  w$ v//每一个缓冲块接头,除了从结束休息和缓冲区,它总是" X: _! h8 \7 E; |  I4 w6 ^, i" m
// 0。这个值控制机器的速度穿过路口,没有考虑加速度6 F5 f+ m9 ]% G) T
//限制或相邻块之间的角线方向移动。这是有用的机器,不能# U3 ?' t- Y; h7 K
//容忍工具居住某一刹那,即3 d打印机或激光切割机。如果使用这个值
0 ?% y( D8 U, m1 w+ ]. t//不应大于零或机器工作所需的最小值。
+ z8 K" a. m2 t0 _! T, x0 Z( u! i$ o" p, D; }, T/ J  e9 r7 g
#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min)0 J$ R  c. O: n; Y

# `. m: {, K8 F: z- R" e// Sets the minimum feed rate the planner will allow. Any value below it will be set to this minimum6 f7 a9 T7 c1 ^; J7 E$ P7 h7 b# t
// value. This also ensures that a planned motion always completes and accounts for any floating-point
6 d% q$ n* P* m// round-off errors. Although not recommended, a lower value than 1.0 mm/min will likely work in smaller
4 Z1 I! Y$ y3 A// machines, perhaps to 0.1mm/min, but your success may vary based on multiple factors.% {: W+ f) P& K7 B5 [8 \/ [! Q- G
//设置计划将允许的最小进给速率。任何价值低于它将被设置为最低值。这也保证了运动计划总是完成,占任何浮点
* @3 ?( ~$ k  ~; q+ V' A6 u. {//舍入错误。虽然不推荐,价值低于1.0毫米/分钟可能会在较小的工作" e1 ?+ w! o( l7 \  A- r- E* |
//机器,也许到0.1毫米/分钟,但你的成功基于多种因素可能会有所不同。# ~$ r, a  W6 b
0 w8 M5 c1 X+ v; q; m. D2 M5 H' {' Q
#define MINIMUM_FEED_RATE 1.0 // (mm/min)//设置计划将允许的最小进给速率
. {3 V  ~+ ^4 h3 Z( V1 [, h( d5 K1 |! ]( S8 `& [
// Number of arc generation iterations by small angle approximation before exact arc trajectory ! B, U' u8 E6 G  B, X
// correction with expensive sin() and cos() calcualtions. This parameter maybe decreased if there , |: l/ f9 f# F) @1 Q. j
// are issues with the accuracy of the arc generations, or increased if arc execution is getting
' h( s' x# h+ n// bogged down by too many trig calculations.
. d# M, s& n6 F, l; f$ e//弧生成迭代次数之前小角度近似精确的弧线轨迹
0 V8 M4 O% I6 a" W! d7 m/ i//修正与昂贵的sin()和cos()calcualtions。如果有这个参数可能减少
  \7 N+ u2 Z; z8 x4 p' k2 f//与弧一代又一代的准确性问题,或如果电弧执行得到增加# K& }, l: c4 F
//太多的三角计算的泥潭。
3 l- h1 O' \3 \" h4 ]! S/ o  m3 c4 @7 z
#define N_ARC_CORRECTION 12 // Integer (1-255)
5 Z7 i. P# R9 X0 f  I  y9 N
( m9 R+ ]3 H& j: a$ @// The arc G2/3 g-code standard is problematic by definition. Radius-based arcs have horrible numerical
: Z9 X& q+ G# I) T( G7 v0 F// errors when arc at semi-circles(pi) or full-circles(2*pi). Offset-based arcs are much more accurate " `" G4 f0 |3 K5 ~
// but still have a problem when arcs are full-circles (2*pi). This define accounts for the floating
3 f) e+ k! [1 Y// point issues when offset-based arcs are commanded as full circles, but get interpreted as extremely; S# K% C7 O" h% j+ C' g
// small arcs with around machine epsilon (1.2e-7rad) due to numerical round-off and precision issues.5 e" n, w0 D) N* \& ?$ g
// This define value sets the machine epsilon cutoff to determine if the arc is a full-circle or not.
$ P& X1 R6 Q; b8 e; h! K// NOTE: Be very careful when adjusting this value. It should always be greater than 1.2e-7 but not too" i; w9 h1 x" B6 {
// much greater than this. The default setting should capture most, if not all, full arc error situations.
" |0 Z3 v/ `* A' M( n//弧G2/3刀位点的标准定义是有问题的。Radius-based弧有可怕的数值
0 F& e8 x$ Y8 s8 p" Z# ]8 t  d( w//错误当电弧在半圆(π)或原点(2 *π)。Offset-based弧更准确8 U- b+ ?$ M( Y
//但仍有一个问题当弧原点(2 *π)。这个定义占浮动* u" F2 L8 q, w  C1 Z
//当offset-based弧吩咐点问题完整的圆,但解释为极
' s% j# y6 E3 g$ n; w# n- E1 Q' E//小弧机周围ε(1.2 e-7rad)由于数字舍入和精度问题。
: u$ ^( F2 e; Z( f# ~, F+ U//定义值设置机器ε截止来确定电弧是一个原点了。
8 j) D4 @# n6 m: O" g& P//注意:调整这个值时非常小心。它应该总是大于1.2 e -但不要太/ I5 A7 t) e( B- Y
//比这大得多。默认设置应该捕获大部分,如果不是全部,全部错误的情况。8 e  a" i+ c  D6 b6 A0 A# D: l2 `7 U

3 Q, z; L6 \& }8 b) a0 R#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)4 E& J3 ]3 `! ~# n. b1 Q$ q

; X$ T0 u' h% b  f8 ]// Time delay increments performed during a dwell. The default value is set at 50ms, which provides/ G1 R4 G* u1 r1 V1 x/ a9 N5 l; i
// a maximum time delay of roughly 55 minutes, more than enough for most any application. Increasing) S# O8 G2 o( n3 a5 L! V1 C' R
// this delay will increase the maximum dwell time linearly, but also reduces the responsiveness of
! i% J9 B/ W9 S: q4 _* ~# A6 M2 Z8 S// run-time command executions, like status reports, since these are performed between each dwell ( o6 Q8 T8 I8 N; }9 |4 y
// time step. Also, keep in mind that the Arduino delay timer is not very accurate for long delays.
6 z4 E5 i# p. b& Y/ S% b  t6 ?//延时增加表现在住。默认值设置为50毫秒,它提供了
2 i7 d7 j9 s& m//最大延时约55分钟,足够对大多数任何应用程序。增加
  k) f' G# i4 L, s+ |//这种延迟将增加线性最大停留时间,也减少了响应能力$ F! m1 D9 D( a3 z! {3 J: f7 m3 d! t3 ]
//运行命令执行状态报告一样,因为这些每个住之间执行
% J1 C9 ^# @' K' _//时间步。还有,记住,Arduino延迟计时器不是很准确的长时间延误。
6 t- Z7 i$ G8 {! R8 p: h3 O: A/ S3 v( g" u; W
#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds)
  m( A0 x4 v( s3 |, D' l
2 k: q$ f, L/ E4 u& |2 G5 U& g4 l6 _" G// Creates a delay between the direction pin setting and corresponding step pulse by creating9 I& y7 u/ m* n; z# `- ]
// another interrupt (Timer2 compare) to manage it. The main Grbl interrupt (Timer1 compare) , [2 R- j" l6 l" w
// sets the direction pins, and does not immediately set the stepper pins, as it would in
' f% j3 j- A- W7 p& J9 D; z  S// normal operation. The Timer2 compare fires next to set the stepper pins after the step
* B  j1 F$ m  ^* h. C% }! O// pulse delay time, and Timer2 overflow will complete the step pulse, except now delayed
' Y* S! }& ?9 Z// by the step pulse time plus the step pulse delay. (Thanks langwadt for the idea!)
4 E# x6 p: Q8 Z/ @// NOTE: Uncomment to enable. The recommended delay must be > 3us, and, when added with the
, q" n, g% J3 }  k' H, i( c& _// user-supplied step pulse time, the total time must not exceed 127us. Reported successful
' |# d: j+ \; q! n// values for certain setups have ranged from 5 to 20us.& {! @- C: ]8 l. X- G/ c' z
//创建一个方向销之间的延迟脉冲通过创建设置和相应的步骤! h; S5 Z4 g! R) h
//另一个中断(Timer2比较)来管理它。主要Grbl中断(Timer1比较)* H( Q' l$ A1 D3 r
//设置方向针,不立即设置步进针,因为它会在
! c* U& Z1 g8 d8 M1 p- L//正常操作。Timer2比较火旁边设置步进针后一步
! y) r4 y" V1 F7 h! J; Y* s//脉冲延迟时间,Timer2溢出脉冲将完成的步骤,现在延迟除外
- F* H2 g# G9 g//脉冲时间加上的一步一步脉冲延迟。(感谢langwadt主意!)" ?& s( h: O3 D! f+ b" y% w
//注意:取消启用。必须> 3,建议延迟,当添加的
5 g. s6 p# @% a7 b8 {//用户提供的步骤脉冲时间,总时间不得超过127美元。成功的报道& Y' b7 y. P8 A0 M/ p$ j$ L" T
//值对某些设置范围从5到20。7 D# d2 i: S* c" P+ N. ^

$ J2 [* j8 t& K! D/ `0 e% f// #define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.8 H7 z/ j5 d& w* D9 S& l

. U" b$ y. _# L( g* _// The number of linear motions in the planner buffer to be planned at any give time. The vast
9 H+ p* v0 g+ a% ^# [# K- _// majority of RAM that Grbl uses is based on this buffer size. Only increase if there is extra
) i' B, ?. p0 K1 V( s) s// available RAM, like when re-compiling for a Mega or Sanguino. Or decrease if the Arduino% G7 g8 f. V9 P6 L) i
// begins to crash due to the lack of available RAM or if the CPU is having trouble keeping
" D/ ^* @8 Z! O$ T* r; v8 G4 P( Y8 T4 ^8 I// up with planning new incoming motions as they are executed. ; G. U) N  Q' @# k' l
//线性运动规划师缓冲区的数量在任何给出时间计划。绝大
+ A% O$ |% P: V//多数RAM Grbl使用基于这个缓冲区的大小。如果有额外的只会增加/ p5 @) V' g( j9 P
//可用内存,比如当基于大型或Sanguino。如果Arduino或减少7 W. v% q# p5 {! t$ l1 Y5 [
//开始崩溃由于缺乏可用的RAM或者CPU是难以保持
1 y' ~/ F& m; L0 P( s//与规划新传入的动作执行。
, k/ y% c7 a1 ?( t" S6 k3 J0 O3 ?
, j0 l6 T, e4 q- [. J// #define BLOCK_BUFFER_SIZE 18  // Uncomment to override default in planner.h.
; ]9 T# U. M! R+ X; f! ]0 H( u' D0 l5 {  w) t1 |8 d% i
// Governs the size of the intermediary step segment buffer between the step execution algorithm5 K; A9 j* N/ I0 o9 f( s
// and the planner blocks. Each segment is set of steps executed at a constant velocity over a6 {5 Y% W- l2 a% Y8 i+ M; P
// fixed time defined by ACCELERATION_TICKS_PER_SECOND. They are computed such that the planner3 V/ z; E, E) i4 P4 C- S
// block velocity profile is traced exactly. The size of this buffer governs how much step
- t  p1 T3 c" Y// execution lead time there is for other Grbl processes have to compute and do their thing ( G* f8 T" }& {% p  _7 f
// before having to come back and refill this buffer, currently at ~50msec of step moves.: m6 [+ B3 \. _9 m3 o( X9 D9 \  @! T
//控制之间的中间段缓冲大小的步骤执行算法
# ?0 E; f/ x) a3 w//和规划师块。每一部分的步骤执行在一个恒定的速度
/ D6 k% B# N* [//固定的时间由ACCELERATION_TICKS_PER_SECOND定义的。他们计算的计划% u3 A2 S+ U, `- B7 H! T# V: I5 G
//块速度剖面追踪到底。这个缓冲区的大小控制多少步骤
; H5 O, y% Y6 K& T8 F//执行时间有其他Grbl过程需要计算和做他们的事情' m4 {! T4 m7 `
//之前必须回来重新填充这个缓冲区,目前移动~ 50毫秒的一步。
6 V+ p1 H( v. i, Y$ a/ W! Q" J  P) |2 i3 Y& u6 q
// #define SEGMENT_BUFFER_SIZE 6 // Uncomment to override default in stepper.h.
. M, [  r5 d- H3 J
6 J( U' A* d. e$ k// Line buffer size from the serial input stream to be executed. Also, governs the size of ! ^% A  O1 U1 Z1 R% ~( e
// each of the startup blocks, as they are each stored as a string of this size. Make sure" V" s2 A7 L% j
// to account for the available EEPROM at the defined memory address in settings.h and for8 P* p- K1 _* y. Y
// the number of desired startup blocks.& Q+ P+ C0 I& H
// NOTE: 80 characters is not a problem except for extreme cases, but the line buffer size : i" s; d! B4 u. o. c
// can be too small and g-code blocks can get truncated. Officially, the g-code standards
$ B6 f3 k6 y  _: o4 O. x  E! X0 m// support up to 256 characters. In future versions, this default will be increased, when 6 x, O9 v1 T( J; A0 w
// we know how much extra memory space we can re-invest into this.
& G4 X" h8 A  `3 }//行执行串行输入流的缓冲区大小。同时,大小的控制
0 r1 G8 M; a$ L//每个启动模块,它们分别存储为字符串的大小。确保
+ d0 Y0 S6 D8 V' j1 a7 e//占可用eepm定义内存地址的设置。h和
& e7 @+ d& ]& F8 f& A0 [$ e//需要启动块的数量。+ t3 v. Z3 F1 }2 R
//注意:80个字符不是一个问题,除了极端的情况下,但线缓冲区大小- ?; L) D. U2 G6 m9 p' O
//可以太小和刀位点块可以截断。正式,刀位点标准
% X$ Q2 E3 u* O2 |' y4 G4 b//支持多达256个字符。在未来的版本中,这个违约将会增加,当$ G- R& H$ f: x, ?: {
//我们知道多少额外内存空间的时候我们可以再投资。
: Z: X% x8 g  @, ~7 p7 n, B  w: K, t# v; w  w3 ?/ d5 {- x
// #define LINE_BUFFER_SIZE 80  // Uncomment to override default in protocol.h2 S$ I5 d; i3 d7 W9 ?" G$ F# Z9 w
  ; {" `5 t  w) I
// Serial send and receive buffer size. The receive buffer is often used as another streaming. {& e  M; W$ Q8 J5 x  F+ i
// buffer to store incoming blocks to be processed by Grbl when its ready. Most streaming0 T/ i$ |: L. z6 X  {
// interfaces will character count and track each block send to each block response. So,
% D* _  M  O- f" p" O2 t// increase the receive buffer if a deeper receive buffer is needed for streaming and avaiable
/ X- C+ d5 s: }7 Q4 v& U9 W// memory allows. The send buffer primarily handles messages in Grbl. Only increase if large
4 ~- n, C7 e) ~0 Q// messages are sent and Grbl begins to stall, waiting to send the rest of the message.* G+ ^6 W! g) i5 K
// NOTE: Buffer size values must be greater than zero and less than 256.8 }2 @) o/ d: g- I
// #define RX_BUFFER_SIZE 128 // Uncomment to override defaults in serial.h9 [$ R/ x. W( ]3 Q+ Y( u) G" [
//串行发送和接收缓冲区大小。接收缓冲区通常用作另一个流# N& J! B3 H: g' U& [% O8 [
//缓冲存储传入的块来处理Grbl当它准备好了。最流5 w" E4 h2 }. h) w" j  M
//接口将字符计数和跟踪每一块发送给每个块的回应。所以,
1 p* _% {$ `. D; ^7 Y2 _+ M7 R0 C//增加接收缓冲区如果需要更深层次的接收缓冲区为流,、
  g  r* Y- F& p* p* r//内存允许。Grbl发送缓冲主要处理消息。只会增加如果大# m/ B. c7 o, T: \0 j, X
//消息发送和Grbl开始停滞,等待发送其余的消息。0 p. o( D  T4 p+ B8 }: C
//注意:缓冲区大小值必须大于零,小于256。1 x0 w+ b7 f3 q8 c; r3 v
// # define RX_BUFFER_SIZE 128 / /取消serial.h覆盖默认值
. `* u8 n! }9 q: A7 s
/ y+ t$ [, u* t6 a1 m/ s
" s2 \$ ~+ V5 n// #define TX_BUFFER_SIZE 64
- j/ A" V6 y# |5 ?: S) H% o  
$ [1 s% F, q6 H: x+ V$ b/ N# c- ]; Q- L// Toggles XON/XOFF software flow control for serial communications. Not officially supported
: b& k/ U9 I: j9 x2 y// due to problems involving the Atmega8U2 USB-to-serial chips on current Arduinos. The firmware. U; ]; `# F/ G! H
// on these chips do not support XON/XOFF flow control characters and the intermediate buffer
& j9 Q7 s! H* {' q; y/ m// in the chips cause latency and overflow problems with standard terminal programs. However,
; i! _+ a8 x" q2 n* M// using specifically-programmed UI's to manage this latency problem has been confirmed to work.0 m; a8 X/ l8 v/ E+ C
// As well as, older FTDI FT232RL-based Arduinos(Duemilanove) are known to work with standard8 W/ O$ r" S- x& Y  m( X0 l
// terminal programs since their firmware correctly manage these XON/XOFF characters. In any
$ e+ n' Z1 l, g0 B  g. o// case, please report any successes to grbl administrators!" z! R9 i9 T$ D' w2 U4 B. X
//切换为串行通信发送朴通/发送葡开软件流控制。不是官方支持" O+ l3 V! n  X1 i3 b
//由于问题涉及Atmega8U2 USB-to-serial当前arduino芯片。固件
! R: H. G6 v3 _0 g& v$ n//在这些芯片不支持发送朴通/发送葡开流控制字符和中间缓冲区
9 I1 |& A$ }" P; Y% }//芯片导致延迟和溢出问题的标准终端程序。然而,1 }# w& x# u9 n3 [2 @% ?$ g& m& b
//使用specifically-programmed UI的管理这个延迟问题已经确认工作。5 O3 i" t  [4 U5 W) S; {  k( {
//以及老FTDI FT232RL-based arduino(Duemilanove)是已知的标准
$ o6 k4 C) C+ k( \. _) a; I% @2 R3 ]+ ?# p//终端程序因为他们正确的固件管理这些发送朴通/发送葡开的角色。在任何: T# j  G6 L2 N; Z4 k
//情况,请报告任何成功grbl管理员!
( E, f) y$ c+ c' l  |9 {% S& l- A
// #define ENABLE_XONXOFF // Default disabled. Uncomment to enable./ z9 a8 A. ]. u( l) M) T; O3 c
# S3 n' i; u8 x% ^  e- N, m, x
// A simple software debouncing feature for hard limit switches. When enabled, the interrupt + p$ ]8 f8 m( l! \' E8 }: j5 j) Y
// monitoring the hard limit switch pins will enable the Arduino's watchdog timer to re-check
3 D; C/ G0 b4 G5 G2 q// the limit pin state after a delay of about 32msec. This can help with CNC machines with
1 k9 K  I7 m6 F: t; W0 J7 C// problematic false triggering of their hard limit switches, but it WILL NOT fix issues with   P. U# C# p: T7 E" D4 ^6 i
// electrical interference on the signal cables from external sources. It's recommended to first
& n, n# b9 ~2 [  z/ B0 S// use shielded signal cables with their shielding connected to ground (old USB/computer cables
' @: a0 k2 U) f+ R6 ?// work well and are cheap to find) and wire in a low-pass circuit into each limit pin.
. S2 E/ a  ?5 d# h//一个简单的软件消除抖动特性硬限位开关。当启用时,中断
# {2 ]+ W/ g- j//监控硬限位开关针将使Arduino的看门狗定时器重新审视
6 c" ]3 `: N% c0 {1 X9 }//销的极限状态后约32毫秒的延迟。这可以帮助与数控机器
$ w$ z/ M% ~2 N" C' o5 n8 k//问题错误引发的硬限位开关,但是它不会解决问题+ R6 i7 y* s! ^2 M  K  `
//电干扰信号电缆从外部来源。首先它的建议1 q+ k2 z& p' _3 l0 T
//使用屏蔽信号电缆的屏蔽连接到地面(老USB /计算机电缆
, G- e8 X3 B2 W6 }//工作得很好,很便宜)和线低通电路到每个限位销。
( c8 J$ A6 S2 u; I3 }
  X/ }( J. @. I8 E* v// #define ENABLE_SOFTWARE_DEBOUNCE // Default disabled. Uncomment to enable.
* @& H9 o' \6 [9 u! I1 m* y) Q/ f. n
// Force Grbl to check the state of the hard limit switches when the processor detects a pin3 n# l  h; D$ C9 y  S
// change inside the hard limit ISR routine. By default, Grbl will trigger the hard limits1 X7 c" Q  R2 ^, f0 j% v- x
// alarm upon any pin change, since bouncing switches can cause a state check like this to 0 V, k7 m( Y* I, h
// misread the pin. When hard limits are triggered, they should be 100% reliable, which is the5 A4 @; n. K9 r) ]& t% l1 y" H+ B
// reason that this option is disabled by default. Only if your system/electronics can guarantee
: k8 Z; b/ Y; O6 W7 D0 m+ C// that the switches don't bounce, we recommend enabling this option. This will help prevent! q: f  |/ O  {( `: J* S
// triggering a hard limit when the machine disengages from the switch.
" _" S. `$ n1 V// NOTE: This option has no effect if SOFTWARE_DEBOUNCE is enabled.
- E( U  N7 }; b" o//力Grbl检查硬限位开关的状态,当处理器检测到一个销" O! M9 X# K" o, e
//改变内部硬限制ISR例行公事。默认情况下,Grbl将触发硬限制! J- V1 y; ]+ |( I7 g/ a
//报警在任何销更改,因为跳开关可以导致这样的状态检查
+ W# N1 ?- `6 d3 X, P% L1 {//误读了销。硬限制触发时,他们应该100%可靠,这是
- q9 F9 V7 r3 u; H1 e' e//原因,这个选项默认是禁用的。只有在你的系统/电子产品可以保证
, v; ]/ @1 ^6 n//开关不反弹,我们建议启用这个选项。这将有助于防止7 w2 Z8 W/ }/ J3 I
//触发机退出时硬限制开关。
, V7 K$ |! ~* c, q+ h  g//注意:这个选项如果启用了SOFTWARE_DEBOUNCE没有影响。
/ Y# u. \' A# F
, R: ?2 ~3 \# }; Q% c// #define HARD_LIMIT_FORCE_STATE_CHECK // Default disabled. Uncomment to enable.
* b" [2 r# e6 e
$ _9 F! P5 w" p& _( `& x7 ?2 K7 N& U: S0 k3 a; T
// ---------------------------------------------------------------------------------------
. M, N. p" f7 ]& S3 C// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:编译时错误检查的定义值:- g+ N, o* v: P# x2 L" m

; n; N8 r7 m8 w8 a$ z#ifndef HOMING_CYCLE_0
' L. o: ^3 h2 @/ [" c( D3 a  #error "Required HOMING_CYCLE_0 not defined.", C  H5 J$ F+ b1 z0 R$ c- x5 \
#endif7 O5 S$ z' ]  l$ d  r
1 X" B% b6 U5 k  Q' x0 w
#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(VARIABLE_SPINDLE)3 i6 _- x/ P* v- q) J: R3 t) @: L
  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with VARIABLE_SPINDLE enabled"
: N/ Z6 E, h+ g0 h% p- w2 G9 y#endif
2 v; L$ R# N/ u0 ]" ]0 g0 n- f8 Z4 t; b7 z; H; d: E
#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(CPU_MAP_ATMEGA328P)
- G4 X2 z) K# b  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with a 328p processor"
5 D! F2 g' \0 C. e, _) A#endif
! ]* A5 F8 e/ v8 Y, i/ Y9 Z9 O9 {( y! X3 G! u& T: |/ L8 S* M. E" k: E
// ---------------------------------------------------------------------------------------
" D; K. Y" Q2 U8 ~- G: M' _. C" H" K; l9 h) K/ ~& p
' M( L& u0 F8 F/ O8 a. `% t+ z3 W
#endif4 M/ E# U2 \/ n# b) K2 d$ l
# M/ G3 I& O: Q

2 h6 p  \9 o2 y; I- Y. d- ?# u3 g
8 G, n, x9 t& a; r/ p: g' D/ T+ z* c& k6 _% R- |

7 q' j  U* \5 n8 Y; m  I* Z5 y: m! }$ k

! W9 d% N; o$ t' x- ]  E
  o5 o! Z: `7 y7 u- v6 q( s" E/ `/ Z% f" s  f) ]/ D
3 C$ k, o  N5 Y/ V: D6 k: }( c
1 l, w# o( ^& Y/ h$ _
9 L! E$ ~* f" M5 a0 \" E6 H
: _8 v. Q/ j6 y/ _
8 U8 }, `9 y) \
+ u/ L% m! \3 ~0 a0 N& S
" w/ B' a5 S1 p' x% j

本帖子中包含更多资源

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

×

评分

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

查看全部评分

回复

使用道具 举报

 楼主| 发表于 2016-8-21 00:11:42 | 显示全部楼层
那些没有用的照片不知道怎么就上去了好讨厌。
 楼主| 发表于 2016-8-21 00:14:16 | 显示全部楼层
4 m9 z8 j" ?. t, s9 V
发表于 2016-8-21 05:50:22 | 显示全部楼层
      楼主厉害!
发表于 2016-8-21 08:22:05 | 显示全部楼层
谢谢楼主,先收藏一下,慢慢学习
发表于 2016-8-23 15:11:25 | 显示全部楼层
这是什么宝贝?
发表于 2016-8-23 15:11:47 | 显示全部楼层
换了个浏览器Chrome,试试能否发言了。
发表于 2016-8-23 20:12:33 | 显示全部楼层
楼主厉害
回复

使用道具 举报

 楼主| 发表于 2016-8-23 23:03:17 | 显示全部楼层
补充
( S: u; {# F' h8 S& V5 V4 t) V; X程序运行protocol_execute_realtime(); /运行实时命令。0 Q1 s( }7 [- ], c1 i: t
// Executes run-time commands, when required. This is called from various check points in the main& V# F7 |- ]+ n# z3 ~' @
// program, primarily where there may be a while loop waiting for a buffer to clear space or any
6 f" y- p  F* Y% J9 V4 q// point where the execution time from the last check point may be more than a fraction of a second.
+ i! f  F& X5 H  _. N$ G// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code
2 G* h: t6 y/ s+ w( x( y4 d// parsing and planning functions. This function also serves as an interface for the interrupts to . H; b$ v: }6 P. R: [2 I2 S
// set the system realtime flags, where only the main program handles them, removing the need to
/ f" g- Y- n$ s; H& _// define more computationally-expensive volatile variables. This also provides a controlled way to % {& h$ A3 h, ^1 J3 p9 m
// execute certain tasks without having two or more instances of the same task, such as the planner
5 W' z7 R2 T, G6 `& k/ ]* f// recalculating the buffer upon a feedhold or override.0 g: l4 z0 P: @& C. u
// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,6 |0 Z/ p8 X- v: |1 R* k8 B
// limit switches, or the main program.
( Z& ^, h1 @, a+ W8 ^
' [. n6 Z, G. ?//执行运行时间命令,在需要时。这就是所谓的从各种主程序要检查站' r- z8 S8 `- t8 I' c. ]$ p0 H
//,主要是那里可能是一个while循环等待缓冲区空间或任何
" B. I9 i" V# X* ]+ u//执行时间从过去的止点可以超过几分之一秒。
6 d2 q) {% s+ u& H, U//这是一种异步执行实时命令(又名多任务)grbl的刀位点
6 n# j; z( H/ W" y/ b: [% N/ F//解析和规划功能。这个函数也可以作为一个接口,用于中断& f. ~0 p: A2 \6 V; ]
//设置系统实时的旗帜,只有主程序处理,消除的需要
* C' u4 J% b% U7 Y0 ?5 q. h2 i0 }//定义更多的计算昂贵volatile变量。这也提供了一种控制方法( e$ e# ^/ N6 I: U% e
//执行某些任务不相同的两个或多个实例的任务,比如计划1 e8 I" A. @3 _1 Z% ^, _; Y& A
//重新计算缓冲feedhold或覆盖。
8 v: v5 A) z9 }4 e+ I# p2 y//注意:sys_rt_exec_state变量标志设置任何过程,步骤或串行中断,插脚引线,/ O) _6 N: G6 o: s1 f( D
//限位开关或主程序。9 Q$ ^! J7 p& |0 R
void protocol_execute_realtime()
1 l8 w. t" W# D5 c" G, ~{
& o7 ?# L5 E# Q/ ]        // Temp variable to avoid calling volatile multiple times.0 M& Z, b* D: m" S0 p2 f
        // 临时变量来避免多次调用不稳定。
7 P, Y% L# U) m" Q. E, r6 m4 j9 R        uint8_t rt_exec; ( B' t% W( _& o
        do{7 t% a. N4 `4 C! z+ @8 H
          if (rt_exec) {                 // 有标志位置位进入
1 f$ e+ i+ w0 {8 [1 y        8 k6 h; Y8 ]; H2 |+ a& e- i
            sys.state = STATE_ALARM; // 设置系统为报警状态
" g$ G. {/ _0 n5 E; C      report_alarm_message(ALARM_HARD_LIMIT_ERROR);        //报告报警信息为接近极限值/ c, Q. o( A. e: \& J, f$ u) u; s
    } else if (rt_exec & EXEC_ALARM_SOFT_LIMIT) {                        //报告执行软件限位报警8 H& f; X2 w( x& B7 h3 u
      report_alarm_message(ALARM_SOFT_LIMIT_ERROR);        //报告出现软件限位报警+ c. c  o3 j9 R0 |3 @
    } else if (rt_exec & EXEC_ALARM_ABORT_CYCLE) {                //执行停止循环报警      
& O8 a3 Q. I- w) F5 j' q      report_alarm_message(ALARM_ABORT_CYCLE);                //出现终止循环报警
+ ?: i1 z* H! Z1 ?0 G9 D, e! l    } else if (rt_exec & EXEC_ALARM_PROBE_FAIL) {                        //执行探查失败报警
3 `. J- [4 |% S  y2 h; m      report_alarm_message(ALARM_PROBE_FAIL);                        //出现探查失败报警
$ T0 q4 K; G/ x# X0 g  w" X    } else if (rt_exec & EXEC_ALARM_HOMING_FAIL) {                //执行返回原点失败报警
/ _  W6 Q  w# w% ~      report_alarm_message(ALARM_HOMING_FAIL);                //出现返回原点失败报警9 P  W* z+ O, G: X3 n
    }) N: G: F: Z9 V  E. r9 g
0 m  ]* ^2 ~1 L5 r
    // Halt everything upon a critical event flag. Currently hard and soft limits flag this.2 T$ B4 u) Y8 A$ P/ C
    // 停止一切在一个关键事件标志。目前硬和软限制标志
- s: B( w: V: q# ~4 Q5 G, j$ ?$ }3 l; L           if (rt_exec & EXEC_CRITICAL_EVENT) {                //如果系统是循环事件进入( I' K: |! |% e
             report_feedback_message(MESSAGE_CRITICAL_EVENT);        //报告反馈信息
& r1 ~) M/ P, J, O# ?3 z              bit_false_atomic(sys_rt_exec_state,EXEC_RESET);                         //清除目前的复位状态
; ]3 u# o' _6 R( ?% w
& C9 a8 v0 |' v; I0 b& V        bit_false_atomic(sys_rt_exec_alarm,0xFF);                                 // 清除所有报警标志4 |. k! A0 L- k1 U" ~& H
        }        . Z2 o. a  E  X, v+ Z

7 o  o1 O; t# Q! x( ]( f上面代码将rt_exec = sys_rt_exec_alarm ,如果rt_exec为真,打印不同报警信息
3 K( ?" W' I- Q0 G  H+ n2 a% w和限位保护信息,然后清除报警状态
# E: {. `( @9 }2 K___________________________________________________________________________
# F5 G6 P+ M% _& x( S8 C: {; n没有报警进行执行下面代码,执行了终止命令,串口打印命令- r* @  n( }. Q, [) T2 y* G
        // Check amd execute realtime commands        校验和执行实时命令+ D/ X& g; I7 }0 }
          rt_exec = sys_rt_exec_state; // Copy volatile sys_rt_exec_state
, S/ s1 F; Z6 Q
1 p; i& ^7 G1 U9 P2 y' I. u' J4 I( r" P- t        if (rt_exec) { // 输入标志是正确的执行7 y5 C0 k: E" m

, e% y; W) D  {9 Y            // Execute system abort. 执行系统终止命令. G0 b2 m* [( ~$ K6 H/ ^
            if (rt_exec & EXEC_RESET) {* a/ c9 Y+ I5 H
              sys.abort = true;  // Only place this is set true.
7 _2 F+ X# w) z              return; // Nothing else to do but exit.. t1 n, Q3 W0 G0 c; W) X
        }
3 E; A9 l2 `1 |' j' n. M
% q" ~& r, R1 M8 d7 q* z+ f            // Execute and serial print status 执行和串口打印状态
" L# E: Y6 J1 n4 L. G( d. J7 |            if (rt_exec & EXEC_STATUS_REPORT) {
( @6 L) ]1 s% O1 `              report_realtime_status();        //报告实时状态& N2 v7 [1 |/ h) `* d- K
              bit_false_atomic(sys_rt_exec_state,EXEC_STATUS_REPORT);        //清除报告状态清零4 D4 b$ |. `- r& n9 R
            }
: G* t  [6 H: C! Y( [& e3 N_____________________________________________________________________________
& q, Y& G/ z, Z! Z( N$ K下面代码
0 j$ E' M. H  [5 T: r6 v//执行状态。
( U/ s; m6 g! N. f7 S//注意:所涉及的数学计算持有应该足够低对大多数人来说,即使不是全部,1 Y8 s7 g4 V0 \$ z  G% n
//操作场景。一旦启动,系统进入暂停状态9 s3 P" s# n4 o5 E
//主程序流程,直到重置或恢复。
4 H4 R. J5 s+ `0 i1 V/ c# c待办事项:检查模式?如何处理呢?可能没有,因为它只会在空闲,然后重置Grbl。
! X1 y! c# R2 p$ Y* P状态检查容许状态的方法。6 u' T3 K' p% Q. i3 s

) \% ]; n' s$ k3 @        //如果全局各自报警标志位其中(执行取消动作) | (执行进给保持) | (执行安全门)任意一位为真进入
% u8 c/ s: z1 h6 O. t            if (rt_exec & (EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR)) {        9 N! D- N* |* O  g% Y
$ R6 ]% A7 S( x9 U" t+ t7 Y/ \& k
        //如果是循环状态执行暂停状态5 |) Y1 t. w1 G) _- U
        if (sys.state == STATE_CYCLE) {4 J. D& A/ V( C- v
        st_update_plan_block_parameters(); //通知stepper module验算减速。
- x9 G% r8 w5 v- I1 C6 Q9 j        sys.suspend = SUSPEND_ENABLE_HOLD; // 开始暂停标志
3 W! v0 \/ s# B% T3 i7 [+ _+ g        }4 z9 z. u; n- w6 ~( N# t6 G
' k& e3 \: Y( P' V. A0 C+ X% u. a: B
        // 如果,Grbl空闲不在运动。简单的指示暂停就绪状态。
- Q4 ]" I& C. g$ R- w        if (sys.state == STATE_IDLE) { sys.suspend = SUSPEND_ENABLE_READY; }
9 @2 E9 c+ A0 E& u$ }% h
: I) s8 V' z# a# }$ e  w
# M  H+ }( ]3 t9 j: z        //执行和标志和减速运动取消并返回空闲。主要由探测使用周期2 a6 K0 m& C/ A: @/ j
        //停止和取消剩余的运动。      
4 J) X3 E: {# t) o: g$ }; W        if (rt_exec & EXEC_MOTION_CANCEL) {- a- _, Q* n- }- ^4 y
          if (sys.state == STATE_CYCLE) { sys.state = STATE_MOTION_CANCEL; }
$ z7 F2 y+ @3 q! ^$ h% y8 g          sys.suspend |= SUSPEND_MOTION_CANCEL; 4 L3 E$ _+ P& N- ?' K2 _% m' H
        }+ I  b2 q) A. v) r4 C, q# V
# q. {& ^/ n6 [- C4 D1 C- w
        // 只在循环时执行进给保持减速& q, B$ Z( i5 c% k
         if (rt_exec & EXEC_FEED_HOLD) {
& v3 T5 L3 l& n, {2 q  s" C) g        //只有安全门为1才执行保持进给状态赋值
/ |1 q9 l' X, @, I, \% y3 f2 n          if (bit_isfalse(sys.state,STATE_SAFETY_DOOR)) { sys.state = STATE_HOLD; }; L$ P; a5 S8 K1 ]# a
        }
4 Q& F. |2 K- y: z+ u
2 C* ?7 [+ r- [1 T; X        if (rt_exec & EXEC_SAFETY_DOOR) {7 t( p' s1 E, Y- c& d
          report_feedback_message(MESSAGE_SAFETY_DOOR_AJAR);
, y# |9 W$ n2 f% N/ /如果已经活跃,准备好重新开始,CYCLE_STOP标志设置为强制断开。
1 b5 Y; k9 C, ], D/ /注意:只是暂时设置“rt_exec”变量,不是动荡的“rt_exec_state”变量。: N; Z4 ]) g$ k' \
          if (sys.suspend & SUSPEND_ENABLE_READY) { bit_true(rt_exec,EXEC_CYCLE_STOP); }) Q- d6 P$ Q  @8 f1 D6 I
          sys.suspend |= SUSPEND_ENERGIZE;$ ]) e( s0 J5 v& }4 ^1 |: F
          sys.state = STATE_SAFETY_DOOR;
, U# J4 W% N" k) [        }
8 `2 `. k" J0 ~1 k7 n' i  p! p! z: W: [$ e4 N/ c# B' p
bit_false_atomic(sys_rt_exec_state,(EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR));    # @1 N% @8 J! R( m. z
& v- |  J  o" X/ e* }  \
}: z1 }' R  Y" l; `
以上代码执行了
0 k% c1 f- P" J" ?8 y1.如果全局各自报警标志位其中(执行取消动作) | (执行进给保持) | (执行安全门)任意一位为真进入
, Q8 e$ ?) ]* s# i7 T% O' u2.系统为闲着状态, 开始循环状态, 回原点状态, 控制取消状态, 开始保持状态, 开始安全门状态时进入2 Y) N' J: \' c3 e. U
3.如果是循环状态执行暂停状态  A* @+ T# [6 W% N, w& H
4.如果系统闲置状态执行暂停就绪状态1 o) O3 m1 `( p# s
5.执行动作取消
7 K  F& S2 f8 y" a6.如果是保持进给状态,执行保持进给状态+ ?8 [( _. W8 z: M9 A7 ~7 _
7.执行安全门状态
! e! R' a6 e5 E8 a/ l$ w9 N( ?最后执行bit_false_atomic清标志清除(执行取消动作)(执行进给保持)(执行安全门)标志位                 
+ d- v) M2 f( W_____________________________________________________________________________
* S: u- F# d& s0 d1 K* c/ d2 d1 [7 a
8 j8 w5 l; i6 J    // Execute a cycle start by starting the stepper interrupt to begin executing the blocks in queue.
2 e  T2 I1 }  S& O( ^. N    // 执行一个循环开始启动步进开始执行中断队列的街区% T( a3 `, [( F+ a
    if (rt_exec & EXEC_CYCLE_START) {        //循环开始状态进入
0 X7 H$ b/ S! o* o      // Block if called at same time as the hold commands: feed hold, motion cancel, and safety door.
* p" }3 s$ g, f) n) n1 C1 t0 @      // Ensures auto-cycle-start doesn't resume a hold without an explicit user-input.! L! N/ y# k2 q/ X" I8 t' h- C6 X% n
          //块如果在同时举行的命令:保持进给,运动取消,和安全的门。 //确保auto-cycle-start没有简历没有显式的用户输入。
4 p, s# l: u: o) c          
1 e4 n$ y- L( K8 K# I  m: y      if (!(rt_exec & (EXEC_FEED_HOLD | EXEC_MOTION_CANCEL | EXEC_SAFETY_DOOR))) {   //状态机如果不是保持进给,运动取消,和安全的门。 % b9 d" m) @4 ]. E' ?
        // Cycle start only when IDLE or when a hold is complete and ready to resume.. _' r' K  f% x  H( \& f
        // NOTE: SAFETY_DOOR is implicitly blocked. It reverts to HOLD when the door is closed.! D* A. K6 _+ ]: _
                //循环开始时只有当闲置或持有完成并准备简历。
6 l5 f" w+ Y3 D( l2 e                //注意:SAFETY_DOOR是隐式地屏蔽。它返回的时候门是关闭的。    5 S% e4 j. w  @2 |9 Y9 C) @
, u& x! M, S; U+ z5 }' m8 @+ g
                // 如果系统状态为闲着状态,系统状态为开始进给或运动取消,暂停标志为位重新开始& C  o5 E& Q* t: h4 n! ], V4 d
        if ((sys.state == STATE_IDLE) || ((sys.state & (STATE_HOLD | STATE_MOTION_CANCEL)) && (sys.suspend & SUSPEND_ENABLE_READY))) {2 V$ |* o' G3 x: v4 A
          // Re-energize powered components, if disabled by SAFETY_DOOR.' Q' i7 k5 {8 a- F2 M, g- Z
          //        由SAFETY_DOOR重振组件供电,如果禁用。
9 ^( Z, j6 p$ R          if (sys.suspend & SUSPEND_ENERGIZE) { 2 \1 _2 U( {' a/ r- W7 Y. \, \
            // Delayed Tasks: Restart spindle and coolant, delay to power-up, then resume cycle.
8 Y( N' g$ ^& k% K& a            //延迟任务:重新启动主轴和冷却剂,延迟升高,然后恢复周期。0 e; c+ K: H5 x' p3 l5 f
            if (gc_state.modal.spindle != SPINDLE_DISABLE) {   //主轴模式不是失能进入
0 j: j! n7 \9 Y; e* y              spindle_set_state(gc_state.modal.spindle, gc_state.spindle_speed); //设置状态和速度
$ L% q3 D+ Y; e% e/ E$ P' y: |$ A              //待办事项:阻塞函数调用。最终需要一个非阻塞。# n% C, P7 F- M5 X, W  Q
                delay_ms(SAFETY_DOOR_SPINDLE_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.+ ?) o& g/ b) `0 f5 D
            }
: `$ |9 y5 ?- V6 {1 U4 ]0 g, Z            if (gc_state.modal.coolant != COOLANT_DISABLE) {
# \4 K0 ~. _. t9 e              coolant_set_state(gc_state.modal.coolant);
8 J0 Y/ i# ~6 T/ B! j+ O              delay_ms(SAFETY_DOOR_COOLANT_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.
( |8 K# H5 d$ J  X' C            }7 J3 h3 C8 Z3 B# L
            // TODO: Install return to pre-park position.7 K2 w' N, o, m# T" W  m1 n
          }: T! V/ t$ C* A
______________________________________________________________________________________________________________
% ?8 Y. I) _, V/ H9 {          // Start cycle only if queued motions exist in planner buffer and the motion is not canceled.
. k, `: x8 q! ]/ z, n                  
, {2 v5 T9 h/ G6 V; \0 [0 q1 k                  //只有在队列马达存在规定的缓冲,并且动机没有让取消,才会循环
3 f6 K, ~) M7 V/ z2 J$ E; V  p& Z                  
, C( |/ H  z! `  O: X  A: R2 R          if (plan_get_current_block() && bit_isfalse(sys.suspend,SUSPEND_MOTION_CANCEL)) {$ ~% ?7 [' C4 k9 q3 x5 @+ |
            sys.state = STATE_CYCLE;( @7 p: ~6 ?9 y. T
            st_prep_buffer(); // Initialize step segment buffer before beginning cycle.初始化步开始循环之前6 p- ^5 ?: j1 x- j
            st_wake_up();
( J& j0 e, p  h1 A- I$ X! {: E9 C: I          } else { // Otherwise, do nothing. Set and resume IDLE state.否则,什么也不做,设置和复位空闲模式: X5 u; h) g3 j  N
            sys.state = STATE_IDLE;
) {" Q3 f7 F3 D: q  x          }( L$ I- M* c  b- k
          sys.suspend = SUSPEND_DISABLE; // Break suspend state.
0 \) g8 |0 q# z2 w4 j4 g0 K% p6 z3 `        }6 B# U- ]/ o% Q0 g+ I) M9 x& v1 |
      }   
0 l8 W# }/ [; ~: f3 R) ^$ v9 m      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_START);        2 E8 C  Z5 B. `+ v
    }( M) ]$ N$ f1 ~! G, s. T

+ F. b4 K) u4 r' o% V_______________________________________________________________________________________________________
# h( b1 ^) M& u, @( ~- F    // Reinitializes the cycle plan and stepper system after a feed hold for a resume. Called by
! f& v2 o1 f- f    // realtime command execution in the main program, ensuring that the planner re-plans safely.) v9 `" _8 {4 m, T3 H
    // NOTE: Bresenham algorithm variables are still maintained through both the planner and stepper) R4 a  l( I0 q- x
    // cycle reinitializations. The stepper path should continue exactly as if nothing has happened.   
3 s% D" `( T( u0 P: g4 |8 D    // NOTE: EXEC_CYCLE_STOP is set by the stepper subsystem when a cycle or feed hold completes.
- M: E4 p; b4 ^  R% j
& _+ t4 w3 v& t6 t' k* `9 i& \        //重新启动后循环计划和步进系统的进给保持简历。通过实时命令执行主程序,确保安全计划重新计划。
( a( b. m! R  N& O* ~0 o! W) M6 ?        //注意:画线算法变量仍保持通过规划师和步进: H2 [6 Z8 b  R
        //循环仅。步进路径应该继续,好像什么都没发生一样。        9 x% {$ I) f; R+ J/ B. @0 a' ^9 D
        //注意:EXEC_CYCLE_STOP由步进子系统周期或进给保持时完成。
. O6 C) o3 ^0 g# ~: I' w$ u: Z$ P5 r# P' H
7 s: k+ n; D' P/ j3 @    if (rt_exec & EXEC_CYCLE_STOP) {                         //如果是循环停止状态进入
7 D8 [2 R9 O, ~% D1 A4 t      if (sys.state & (STATE_HOLD | STATE_SAFETY_DOOR)) {0 R, {- e2 Y1 Y8 R
        // Hold complete. Set to indicate ready to resume.  Remain in HOLD or DOOR states until user
/ a) q/ v! D' N* M1 L) M        // has issued a resume command or reset.# u9 e. {' t* F' n& f# s
) |) d, b! u# U/ d  c- `+ D% j9 A
                //保存完整。设置为指示准备简历。继续持有或门状态,直到用户
% W! l2 N% D# f                //已发布了一份简历命令或重置。
8 I5 H3 _! P( ^' w* _                5 g- t, |8 W2 a4 c$ ^
        if (sys.suspend & SUSPEND_ENERGIZE) { // De-energize system if safety door has been opened. 如果安全的门已被打开。断开系统% W: z9 b7 `! {. A  x8 y0 N  ~2 o6 j
          spindle_stop();
$ c4 X  Z7 g. T# O5 l0 D          coolant_stop();
( n- t+ |6 e/ \3 p          // TODO: Install parking motion here. 安装停车动作。
% J& w* d# K- ?$ ?! k; y        }$ i# C5 t2 E+ K* ]7 S( U
        bit_true(sys.suspend,SUSPEND_ENABLE_READY);
5 U9 z) g  x9 P9 i  w3 ^      } else { // Motion is complete. Includes CYCLE, HOMING, and MOTION_CANCEL states. 电机完成,循环,回原点,,MOTION_CANCEL
* F7 q4 X9 R8 Q6 q        sys.suspend = SUSPEND_DISABLE;
# {) M8 ]( [* F; h6 y5 M& y+ x        sys.state = STATE_IDLE;
+ D( i8 D& m- b1 u3 Y, k      }
' m8 `) C7 q% A% v' m5 G  k      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_STOP);
5 w5 v+ g/ H2 b6 c- P    }
& A; \2 h. h5 k* Q. a* s3 V+ F    & l; ~3 h6 j  w) j
  }& o# R3 \$ `: e6 d: |
___________________________________________________________________________________________________
/ X  p$ y0 }# N& y: G3 j# _5 }0 Q, X% y8 P, D/ [; h
  // Overrides flag byte (sys.override) and execution should be installed here, since they
$ o+ _  h  s: i  // are realtime and require a direct and controlled interface to the main stepper program.
1 h+ `' D; W6 [. |& a7 c- S+ z  b, Q2 v5 N1 }" N# X5 z  |/ v
  //重写标志字节(sys.override)和执行应该安装在这里,因为他们
6 A4 g7 D8 G- l% h7 w  //实时和需要直接和控制接口的主要步进程序。
8 ?# z3 f% S8 G/ r% Y, w+ B- \3 a
( I5 i% N; w3 F8 E
; U) \6 V. w6 P/ u& m5 @; W  // Reload step segment buffer 重新加载步段缓冲
- @& \5 P8 `) D! ]. b9 W9 Z, Q- ^9 S  if (sys.state & (STATE_CYCLE | STATE_HOLD | STATE_MOTION_CANCEL | STATE_SAFETY_DOOR | STATE_HOMING)) { st_prep_buffer(); } ! Q6 [1 y$ @& ~: }# F) V9 r! G, E
" Z" _8 A8 q/ f4 S- c+ {
  // If safety door was opened, actively check when safety door is closed and ready to resume.
2 _. `0 U9 R) A& @  // NOTE: This unlocks the SAFETY_DOOR state to a HOLD state, such that CYCLE_START can activate a resume.       
9 m" `, N! J3 y1 |8 R1 C
+ k* E. c! w' V0 s. G( j4 b//如果安全的门被打开,积极检查当安全门关闭,准备简历。% k: O. l' P9 K9 ^# z& ~6 w
  //注意:这解锁SAFETY_DOOR状态保持状态,这样CYCLE_START可以激活一个简历。0 i5 _9 j" X8 M) ?/ i

6 [3 n& W7 |" P: [6 k  if (sys.state == STATE_SAFETY_DOOR) {                 //安全门状态进入" u3 l" z7 o$ T: B, ~5 p" v
    if (bit_istrue(sys.suspend,SUSPEND_ENABLE_READY)) { ) f& I( `8 \1 u/ b! o0 e, M& W
      if (!(system_check_safety_door_ajar())) {
+ ]; c* A2 q$ R2 Y5 c% \        sys.state = STATE_HOLD; // Update to HOLD state to indicate door is closed and ready to resume. 更新保存状态指示门关闭,准备简历。
( l: `6 v) _! n5 {' `9 L      }/ H2 H, [$ t8 Z) B0 h& \8 E
    }
2 B' u9 |' ^) e2 ?  p- N8 l  }; ]/ A& p: Q; \% K1 |6 [5 N

% F5 A% d0 w, W9 N  } while(sys.suspend); // Check for system suspend state before exiting.$ |  M/ b; a8 c# P1 b
  
5 }, H$ @" i+ w$ k( U) E5 H' c2 ?}  
发表于 2016-8-25 09:31:12 | 显示全部楼层
楼主这些代码。是网上搜来,然后自己组合的吗?全是自己想的,那是牛逼了

点评

外国的开源软件grbl,在研究它,将打注释了下而已,研究透彻了好移植的其他平台应用,学习阶段。 https://github.com/grbl/grbl  详情 回复 发表于 2016-8-25 22:19
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

GMT+8, 2025-7-1 07:26 , Processed in 0.107439 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.5 Licensed

© 2001-2025 Discuz! Team.

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