机械社区

 找回密码
 注册会员

QQ登录

只需一步,快速开始

搜索
查看: 18094|回复: 15

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

[复制链接]
发表于 2016-8-20 23:56:23 | 显示全部楼层 |阅读模式
本帖最后由 1五湖四海1 于 2016-8-21 00:09 编辑
( R* X9 q* u7 B) U, a% |* n
$ U) d6 E& T) t! D6 q; D: G    以前制作过CNC雕刻机,是用MACH3作为上位机控制,硬件是采用PC接并口输出脉冲和方向使能信号经过隔离驱动步进电机驱动器,步进电机驱动是采用TB6560芯片控制。最后就接到步进电机。机械是用铝合金制作,主要部件有三个1605的滚珠丝杠,多个运动滑块等制作。用这台DIY CNC雕刻机可以雕刻木头塑料等东西。当时没有一直玩下去,现在发现网上有用单片机制作的雕刻机挺精巧的现在分享给大家。
7 M  F4 k' i" d+ m6 k, K   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个运动来规划运行速度,以实现平稳的加速和无冲击的转弯。很棒吧!开始玩起。( d, U. S# A( A: ^+ K8 m
    还没有雕刻机的机械部分可以用废旧光驱制作个微型雕刻机运动平台。雕刻机最重要的是主控程序这次用 Arduino/AVR328单片机,价格在15元左右,主控程序是上面提到的目前很火的开源
的GRBL,还有一种基于STM32平台的开源主控程序Dlion也不错可以替代grbl。如果从性能比较这两个方案,显然是stm32平台运行速度更快毕竟他是32单片机呀!* h9 R% m: J) E! w' }  N
- h8 _+ n* v# _  E
- k- q" `# `! {5 A. A$ o! T
    下面介绍小这个些主控程序主要干的事,通过串口PC和主控板通讯,PC命令给控制板,控制板接收命令做不同的响应,PC可以发G代码给主控板,接收完成后可以自动开始雕刻任务。7 W; r* U: _4 j% j) b
          在介绍下G代码因为G代码是雕刻机的核心部分
8 Q1 r  k/ l6 s+ Q" SG代码是数控程序中的指令。一般都称为G指令。5 M- K& k/ ]3 h+ g
G00------快速定位& x- `8 B: C! A3 ?5 `1 t
G01------直线插补8 r" p2 o! B9 p6 F# H
G02------顺时针方向圆弧插补
- @# X- }0 M2 D% G7 ^G03------逆时针方向圆弧插补
& }- S) F# M9 F. [G04------定时暂停$ a! z3 b5 p3 {$ L
G05------通过中间点圆弧插补
/ l: s2 g3 }. @5 g' o; TG06------抛物线插补5 A* q, V1 K0 T
G07------Z 样条曲线插补% L4 F7 n  |& u  S* F1 ]6 c
G08------进给加速6 b* v: b3 w8 y3 c8 w/ l! [8 J! j
G09------进给减速& u2 k& X0 j3 v& S, b
G10------数据设置9 z8 D. N3 G) q0 Z: e/ ?% [( Q1 T
G16------极坐标编程" y/ S, ^5 u9 V" i
G17------加工XY平面; @% y4 @" I& X4 {/ X
G18------加工XZ平面2 U/ Z% o0 A$ U  a% D% Z5 d) t
G19------加工YZ平面

1 }0 k& |2 o2 j# ^核心就是解析G代码,完成步进电机驱动,和控制主轴开启关闭,还有插补算法,直线插补,圆弧插补,还有一些步进电机的加减速算法。2 C, f( x- e! U# L
下面对grbl主结构做介绍3 A# ^- ?5 k" f( ~0 [
main()主函数首先执行下面初始化函数: z  S5 R: l/ I' n6 e
        serial_init();                           // 设置串口波特率和中断% H% Q! y, G; m  c& ]4 |* j2 {
        settings_init();                         // 从ROM加载grbl设置, q: Z0 @" ~2 G; ^- ~/ m9 a
        stepper_init();                          // 配置步进方向和中断定时器1 B& Y9 ^9 n5 d; }; }8 x( K$ u
        system_init();                           // 配置引脚分配别针和pin-change中断% e0 [# S* q5 H7 n1 o% ?5 u9 f. ?
        memset(&sys, 0, sizeof(system_t));          // 清除所有系统变量" U% @6 ~+ z% O# o
        sys.abort = true;                           // 中止标识位置位& F" `, O+ g! P; c/ f
        sei();                                         // 使能中断  e( X' V: `  ^) g
  #ifdef HOMING_INIT_LOCK                        // 宏运算(settings.flags & (1 << 4)) != 0结果flags等于执行sys.state = STATE_ALARM! A' G, l9 E/ b' X0 c3 A1 V6 E
                                                // 系统状态赋值为报警状态
* \8 g- ?7 O/ l/ ^( c& B            if (bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE)) { sys.state = STATE_ALARM; }1 u: d, G$ r1 C; \6 @
  #endif
( K- E5 e+ \$ g5 F8 {3 m0 @& M_____________________________________________________________________________________________________________________________________7 P$ x) X0 ~7 h' t
接下来是一些主要部分初始化
# Q* A9 S7 U# O/ g6 Lfor(;;) {
5 |& ^" E. z( u$ ?4 ~( F2 w3 h        serial_reset_read_buffer();         //清除串口读缓冲区
7 ]. S0 t, ]( P: ?. v" }2 q' h        gc_init();                         //初始化G代码功能函数
5 P# c/ {9 V7 ~        spindle_init();                        //主轴初始化/ c) K. S' \1 c( g$ @2 T2 c
        coolant_init();                        //冷却液初始化
8 i# G0 M. C0 J) Z: E        limits_init();                         //极限开关初始化# [# m: V% ]  J/ c
        probe_init();                        //探测部件初始化6 z. S0 s; S6 [5 u( _$ O3 b: H
        plan_reset();                         //清除块缓冲区和规划师变量
/ g$ R3 ~( j/ j9 o8 S: ~        st_reset();                         //清除步进系统变量。
$ a4 t4 |0 w2 X$ R0 ]% a) {
6 p+ o& [/ y8 B5 p, g. P- O2 w2 V! A- r* g8 @* o# w
        //下面两行清除同步gcode和策划师职位当前系统位置。
* L3 t6 Z9 l% v3 W5 Y$ b
        plan_sync_position();
8 ]% ~- h8 r6 ^        gc_sync_position();
5 ~3 I  z# g/ D- _
: S- O8 z/ l# ]1 R& _& h5 T0 }2 b  p: O
        //复位系统变量3 C. d3 K+ K" Y% ^
        sys.abort = false;                //系统中止标志
- p7 U  z" G( s        sys_rt_exec_state = 0;                //系统标志位变量状态管理。看到EXEC位掩码。5 r; x0 N6 M/ \
        sys_rt_exec_alarm = 0;                //系统标志位变量设置不同的警报。
$ @1 p! Z; h& c1 I$ ]6 G        sys.suspend = false;                //系统暂停标志位变量管理,取消,和安全保护。
) F: n3 C4 n. h+ u1 Z$ z& h# u        sys.soft_limit = false;                //限位开关限制状态机错误。(布尔)
$ _2 l  P8 U& T/ l
6 @, [; N+ v# @. j4 ^1 }
& p! r/ S1 v3 R, O        protocol_main_loop();                //主协议循环
; ?% u  |/ `5 q2 {8 _}        //- @; ^: ?1 Y* |7 b
_____________________________________________________________________________________________________________________________
% ^; b( z% y$ M% [进入void protocol_main_loop()函数! ]% ^* ?+ q0 j% y
{
3 j5 g( o. r1 G        report_init_message();                // 打印欢迎信息 ! r  W/ \3 I: V& e6 ^* T
        //重启后检验和报告报警状态如果错误重启初始化。5 L9 e. Y; ?' z" T% w6 r# k5 r! W
        if (sys.state == STATE_ALARM) {
/ }) B, F+ C6 Z) ^            report_feedback_message(MESSAGE_ALARM_LOCK); //打印信息
5 s1 `# d+ E1 V% @9 N7 Q' h
          } else {
+ I" |5 @6 O, i! W            // 如果没有报警说明一切正常!但还是要检查安全门.
0 Q4 _9 T8 Z3 x, ~            if (system_check_safety_door_ajar()) {
/ c' `/ |; @4 c- N                     bit_true(sys_rt_exec_state, EXEC_SAFETY_DOOR);" |( _' M) u+ [, G& z
                     protocol_execute_realtime(); // 进入安全模式。应该返回空闲状态。, e4 O4 t4 H; M% ?
            }         else {3 x9 E/ ?5 {1 k+ ^5 t1 @9 v
              sys.state = STATE_IDLE; // .设置系统做好准备。清除所有国家国旗。
9 r8 N, f" V0 |8 @            }
8 b. ]4 U8 M) K) R            system_execute_startup(line);    //开始执行系统脚本
0 |1 i9 C4 w/ z) t& ^  } , V, n5 V0 v7 Y7 r3 @
4 S4 @/ R5 Z: j$ Z' e- J

' ]& @0 k) F$ O0 r$ u- G3 ]  // 这是主循环!在系统中止时这是出口回到主函数来重置系统。
  P# u$ ~% O) g; B( g  // ---------------------------------------------------------------------------------  $ f! S  `8 l9 o( Q: e, u, r; D9 \
  ; U0 y$ j. Z8 c" Q
        uint8_t comment = COMMENT_NONE;
8 G! m% O* p% E, _        uint8_t char_counter = 0;4 y6 ^- ]  c5 A
        uint8_t c;
; ]) R( z: M2 v  K; F7 M2 P" g) Z) k_______________________________________________________________________________________________________________________________" _3 F- r. L1 L6 K
接下来进入for(;;)循环                //下面代码是G代码解析核心部分,程序中comment(注释)变量会被赋不同值,代表发符号有‘(’‘)’‘;’
. K6 H2 T* G; a4 S{& B. B4 C. c: e) W( s
//串行数据输入一行的的过程,作为数据。执行一个
6 T' h& p/ \7 m- B! z! G0 C//所有数据初始过滤去除空格和注释。 1 t6 c; j! K  _1 {
//注意:注释,空格和程序段删除(如果支持的话)处理技术0 Q8 i8 u  k, s" ^! j: {- `
//在G代码解析器,它有助于压缩到Grbl传入的数据! a  E  N2 U/ ?' u' q
//线缓冲区,这是有限的。刀位点标准实际上州一行不行* ^" R- J/ ^- j
//不能超过256个字符,Arduino Uno没有更多内存空间。
+ J5 D) f* [* {' Z' E) Q4 p% e; T//有更好的处理器,它会很容易把这个初步解析的3 ^0 i- J; M/ Q+ u* Y
//分离任务共享的刀位点解析器和Grbl系统命令。                                                                6 l6 l% I5 j  @3 T. ]. m3 s4 i
    while((c = serial_read()) != SERIAL_NO_DATA) {                             //读取串口数据,有数据执行下面代码
6 n% j* {( S* T1 f; |+ f' G      if ((c == '\n') || (c == '\r')) { // End of line reached                //如果数据是/r,/n代表一行结束8 R4 i# r& W) _+ w" M4 {
        line[char_counter] = 0; // Set string termination character.        //设置结束标志$ V( [$ o  I9 H1 S; Z) Z) l* A: T* A
        protocol_execute_line(line); // Line is complete. Execute it!        //一行完成执行此函数
( z. D. I& [* h" ?) v+ \( Y& a        comment = COMMENT_NONE;                                                //注释清零1 e/ a/ z3 s* v" T
        char_counter = 0;                                                    //字符计数清零; r, Q  o0 w9 `9 z
  
6 a- n# W. v# i" u        else {
7 Z! j- `& x8 F1 u1 u' q* y        if (comment != COMMENT_NONE) {
7 _; A+ ~$ ?  ^8 l' c; |                                                     //扔掉所有注释字符
& U+ V' _! R' L( K# t+ Q          if (c == ')') {
9 \) h3 o& c( F0 Q* K. P            //最后注释。重新开始。但是如果有分号类型的注释。% A3 W) H  }3 V5 o3 @4 q
            if (comment == COMMENT_TYPE_PARENTHESES) { comment = COMMENT_NONE; }( M/ w& u$ E# ^6 {9 u/ [  R7 c
          }
1 V/ P$ I. T) ]% Y& p' B      } else {
6 x  }7 n9 x9 p% A$ m0 B  c7 U          if (c <= ' ') {
$ e9 s5 E' K' x- M/ R            //扔掉whitepace和控制字符  p' W# u0 m! L; G4 @; F  `
          } else if (c == '/') {
7 Q" a& j. v4 {7 T            //块删除不支持将忽略字符。/ t  g' U) D2 X' x& V
            //注意:如果支持,只需要检查系统是否启用了块删除。0 a" k4 K' J1 }3 W' w% V, o+ o
          } else if (c == '(') {
" a8 o* U2 b( z: R7 Q9 o: p% ~0 ]            // Enable comments flag and ignore all characters until ')' or EOL.
3 T2 d+ x2 _, b. ~8 k4 t/ K! j  Y% o            // NOTE: This doesn't follow the NIST definition exactly, but is good enough for now.
) R2 r) W6 T, X, ]3 T7 ~, T8 T            // In the future, we could simply remove the items within the comments, but retain the
' M/ f6 i; ], `* s) a7 Q            // comment control characters, so that the g-code parser can error-check it.
/ p+ T9 g0 Y+ c/ U( _            comment = COMMENT_TYPE_PARENTHESES;8 w0 E2 U" [: j# s  s
          } else if (c == ';') {& F) x8 \( |! M+ a
            //注意:','注释EOL LinuxCNC定义。没有国家标准。0 [# e- b. O8 h5 X9 q6 d; ?
            comment = COMMENT_TYPE_SEMICOLON;
: r8 W/ Y8 v% Q: P/ n4 \5 R. L; e4 r% z3 `- B5 a+ X+ h7 F# J& p

2 c, H* v2 E4 k2 O_____________________________________________________________________________________________________________________________________
' C" B2 r+ G; P8 H2 ?9 }6 t% @          } else if (char_counter >= (LINE_BUFFER_SIZE-1)) {                        //串口接收数据大于80字符时, l+ s2 o# N! Z) O+ W) \
            // Detect line buffer overflow. Report error and reset line buffer.        检测缓冲区溢出。报告错误和复位线缓冲区。) \% V1 T; s  C' Y: p
            report_status_message(STATUS_OVERFLOW);                                //打印溢出信息5 k! M' y3 l+ f5 {+ m
            comment = COMMENT_NONE;
$ Y2 q, k7 T5 f6 ]$ m7 d! N+ ^% q; |            char_counter = 0;% J: H: `; k% i
          } else if (c >= 'a' && c <= 'z') { // Upcase lowercase                        //小写改大写
: C  |$ e4 g4 I4 `: B            line[char_counter++] = c-'a'+'A';
0 o$ R) e  z* Y( K3 F/ I          } else {
4 x4 [$ T# P2 f# ^, a7 J- Q, W            line[char_counter++] = c;
% b5 N2 w; Q* H! g- o          }5 H5 G$ V: z- \  j- _
        }  u3 y+ I% {0 \6 p0 S# s
      }
) s9 M: w; G: g0 x4 S    }- V7 R5 ?  o  f; C- V& W
____________________________________________________________________________________________________________________________________4 O0 A% z9 _; x4 g
        //如果没有其他字符在串行处理读取缓冲区和执行,这表明以完成,自动启动,如果启用,任何队列动作。* ^6 S5 ?: U# `* A1 K
        protocol_auto_cycle_start();                //自动开始协议循环1 U3 t0 z9 l. D. E# V3 u( J/ P
        - V- |" _4 |% s9 U
            protocol_execute_realtime();                  //运行实时命令。9 e$ M9 m% z$ \' W
            if (sys.abort) { return; }                 //中止标识置位程序循环重置系统。            
9 v1 m0 n) n1 q5 g  }
8 P0 O) l; a" x- W9 K  return;                         //一般程序不会执行到这里
( K7 Y7 S  ~1 {; A( ]}9 X4 F- X; N& s1 Q
____________________________________________________________________________________________________________________________________
6 G. {  d3 Z. L& F5 Z正常情况下,读取完G代码程序会进入protocol_auto_cycle_start();//自动开始协议循环 函数下面介绍此函数. m% P8 t9 F+ ?  x# B6 R& P% K8 ^
// Auto-cycle start has two purposes: 1. Resumes a plan_synchronize() call from a function that
8 Q! ?5 I% u8 V' W" t+ q# q, u// requires the planner buffer to empty (spindle enable, dwell, etc.) 2. As a user setting that
' g: r" g" e3 s1 ]0 e  X! L// automatically begins the cycle when a user enters a valid motion command manually. This is * a0 k! R% `3 K( O7 X+ Z
// intended as a beginners feature to help new users to understand g-code. It can be disabled
9 E5 g3 L  ?! e! s& i% |* B( o2 L// as a beginner tool, but (1.) still operates. If disabled, the operation of cycle start is
4 o1 M2 d6 B) R, ^% U! B2 k// manually issuing a cycle start command whenever the user is ready and there is a valid motion 6 E" M( j3 k" D% i
// command in the planner queue.9 z  v; M1 W+ C) V
// NOTE: This function is called from the main loop, buffer sync, and mc_line() only and executes
0 o: B+ k0 S. z. o4 b0 s' J2 ~0 a0 {// when one of these conditions exist respectively: There are no more blocks sent (i.e. streaming / P3 w( ~- I$ `" c
// is finished, single commands), a command that needs to wait for the motions in the buffer to
' t4 v/ q# H# ~- M+ R0 S// execute calls a buffer sync, or the planner buffer is full and ready to go.
! k/ `/ Y6 X+ N6 A! [- v2 Y//自动开始有两个目的:1。回复一个plan_synchronize()调用的函数+ V' S5 O4 h8 ]/ T8 d$ ]) E
//需要规划师缓冲区空(主轴启用、住等)2。作为一个用户设置/ j3 G3 b! Z1 V7 }; z
//自动循环开始当一个用户输入一个有效的运动命令手动。这是
; p! \" V' x6 f5 V# ~. g//作为一个初学者的特性来帮助新用户了解刀位点。它可以被禁用  ?5 }' m4 C* U3 Z! y. x
//作为一个初学者工具,但(1)仍然运作。如果禁用,运行周期开始' e$ ]! H$ y0 f$ ?) B
//手动发出一个周期开始命令每当用户准备好,有一个有效的运动
# V. K+ \$ F0 f( h+ M. X/ ~//命令的规划师队列。0 Z3 g3 R+ F( e# Z# o- W, ]  p
//注意:这个函数被称为从主循环缓冲区同步,mc_line只()并执行8 c7 X! B7 B5 }
//当其中一个条件分别存在:没有更多的块(即流发送! r- G7 j! {" {& G
//完成后,单一的命令),一个命令,需要等待缓冲的动作
/ A6 g, W7 V2 D, Z6 d//执行调用一个缓冲区同步,或规划师缓冲区满了,准备好了。
! W1 Q1 w1 ~, v3 B6 L2 R7 T6 F; Kvoid protocol_auto_cycle_start() { bit_true_atomic(sys_rt_exec_state, EXEC_CYCLE_START); } ! s* Y; ?( b. S( I; x- q  N
_______________________________________________________________________________________________
# G" k2 @7 Y8 b1 o4 m* w6 ]接下来程序运行protocol_execute_realtime(); /运行实时命令。
  w& }7 K# f, Y$ v% R+ l$ W// Executes run-time commands, when required. This is called from various check points in the main$ X- D# O6 V' C2 T( z7 o- \
// program, primarily where there may be a while loop waiting for a buffer to clear space or any% j8 ^; x4 V7 S# h# _. ~
// point where the execution time from the last check point may be more than a fraction of a second.9 k0 T) H; `( B% r3 ~/ X1 w
// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code# a7 Z" n4 A$ d
// parsing and planning functions. This function also serves as an interface for the interrupts to
# f: W  a/ Q) j; j// set the system realtime flags, where only the main program handles them, removing the need to
" ^# U' A. o* B/ m. X; h% x1 d// define more computationally-expensive volatile variables. This also provides a controlled way to
: }/ t. [6 ?7 {' I( L# z! ~// execute certain tasks without having two or more instances of the same task, such as the planner6 T  q$ a4 M: {5 }% [- t
// recalculating the buffer upon a feedhold or override.
- A  W( {" P; h/ l// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,
+ X6 f5 X( Z2 h& ]. k0 o// limit switches, or the main program.0 a7 P! x5 A" c) c+ n( e4 ~
void protocol_execute_realtime()
% O. f7 ?4 h0 V uint8_t rt_exec; // Temp variable to avoid calling volatile multiple times.临时变量来避免多次调用不稳定。: y/ P) d. w' q
就先分享到这吧!
! x2 Q: r6 o7 K2 \# p1 v1 L7 k. n& Y+ D9 B5 V# K

, N: `9 n, {1 U/ `! \6 T( v# u
+ |4 {  O9 y; Q1 J! r
" [; {* T2 o6 Y  u" s, l+ M* O. G! c' B! y

+ [$ [0 ^+ \% J0 R+ O! A$ |" Z3 |) L( G8 `2 h
* @: J5 i! L2 g0 Q4 b" H  f
" M, X# t8 i) z
8 m$ o$ e: I4 ~) Q% P
, i5 x. s$ T, s- S0 H5 P' u
' n1 u& k  ~, j) C- k$ e
3 a7 H3 A2 x) D' \$ W; r) M* k* |0 K
3 l3 v3 e# H& r* P5 v  i) U. e! S

  W" q( ]! j3 \& @+ {  ]0 c
+ M7 W" D- v7 R' t$ y2 p" H8 n& j! B  c. `

/ a# Z* p6 b/ v  t5 r8 m
" ?' f+ ~1 T6 W' [9 I: f
% B% a! s# b+ R0 L: F% V' {

- H" z5 O! y" \6 V* _# c% `0 x/ ?' s# O3 H$ E" o
9 S$ G/ T: n- s* I* k# R
补充内容 (2016-8-25 22:40):2 L% `! B% m8 b# p5 ?/ [) X
配置说明0 B: |* I- R, `/ p2 m' k( K7 {' D, v
//这个文件包含编译时配置Grbl的内部系统。在大多数情况下,, o& ]$ s5 f  G, b  C; E5 y
//用户不需要直接修改这些,但是他们在这里为特定的需求,即。. t* _+ Q( X* u/ W/ [2 L4 ?
//性能调优或适应非典型的机器。) ^9 e8 ]: p3 A" I
主要配置项:
: A. D$ W( h8 A9 [: {! R0 N1.#define DEFAULTS_GENERIC        //在重置eepm时使用。在defaults.h改变想要的名字
% y- M) x2 q7 P% u8 d1 F' K# z2.#define BAUD_RATE 115200        //配置串口波特率1152001 \8 t0 d# @. j& `6 V
3.#define CPU_MAP_ATMEGA328P         // Arduino Uno CPU
' z  l& ]3 w& t4 {# h) k4.#define CMD_STATUS_REPORT '?'        //定义实时命令特殊字符% {: L* s0 D+ E! ^' }' Q
5.#define HOMING_INIT_LOCK         //回原点保护锁
1 e0 j: @9 {+ v0 _5 }6.#define HOMING_CYCLE_0 (1<<Z_AXIS)              // 第一步Z清除工作区。  `/ K( O) B, @$ `
  #define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // 然后X,Y在同一时间。1 s6 Z5 O  i% b
7.#define N_HOMING_LOCATE_CYCLE 1 //回原点循环次数
1 c$ a  {7 a2 W% a8.#define HOMING_FORCE_SET_ORIGIN //取消这定义迫使Grbl总是在这时候位置设置机器原点尽管开关方向。
% [, p! a, f+ m! T9.#define N_STARTUP_LINE 2 //块Grbl启动时执行的数量。! @7 U9 v7 W' O, v) h+ b/ g9 P3 ?
10.#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 协调或位置价值英寸. {1 W5 A) C- a$ j7 U
   #define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 协调在毫米或位置价值, z- Y8 k  U1 B, c( p5 O& G# b! c
   #define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分钟的速度值. X' C2 n" k4 q/ C
   #define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分钟. v% ~" o. I3 c; C) [" v
   #define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 对浮点小数设置值& \0 q$ L! [$ {
11.#define LIMITS_TWO_SWITCHES_ON_AXES //如果你的机器有两个极限开关连接在平行于一个轴,您需要启用这个特性
5 P7 t4 s& ]& n: ?6 n12.#define USE_LINE_NUMBERS         //允许GRBL跟踪和报告gcode行号8 x6 X1 E# N/ a) A1 z$ ^
13.#define REPORT_REALTIME_RATE //允许GRBL报告实时进给速率
& T3 G3 B% i7 F5 Z7 A5 x14.#define MESSAGE_PROBE_COORDINATES  //坐标通过Grbl $ #的打印参数?9 T6 s0 o2 \) x) t3 w+ Y
15.#define SAFETY_DOOR_SPINDLE_DELAY 4000 //安全门主轴延时
6 Y  o8 t6 k1 G4 ]' n2 N16.#define SAFETY_DOOR_COOLANT_DELAY 1000 //安全门冷却液延时6 d8 c& }2 y* ?$ j
17.#define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS) //启用CoreXY运动学。
" j: b( l+ c* w! W$ A9 A18.#define COREXY // Default disabled. Uncomment to enable.改变X和Y轴的运动原理
$ d  }! z3 e# P$ O19.#define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.反转针销逻辑的控制命令
+ K' I* C! b$ M1 e( F20.#define INVERT_SPINDLE_ENABLE_PIN // 反转主轴使销从low-disabled+ A( s" q  `" L
21.#define REPORT_CONTROL_PIN_STATE //启用控制销状态反馈状态报告。/ d; b4 |, f0 I# y* J2 t1 l
22.#define FORCE_INITIALIZATION_ALARM //启用和用户安装限位开关,Grbl将启动报警状态指示0 y9 \/ p8 ?9 Z
23.#define REPORT_GUI_MODE // gui允许最小的报告反馈模式# ^1 F$ v- W- P
24.#define ACCELERATION_TICKS_PER_SECOND 100 //加速度的时间分辨率管理子系统。; r  @  J. S: O5 H5 D/ |
25.#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING //自适应多轴步平滑(积累)是一种先进的功能 ! Z; l8 C, Y0 ]: e7 Y5 j
26.#define MAX_STEP_RATE_HZ 30000 //设置最大一步速率可以写成Grbl设置4 v2 b4 s3 ^. m5 P
27.#define DISABLE_LIMIT_PIN_PULL_UP //以下选项禁用内部上拉电阻
0 b1 t' O! |9 }+ H- k  D" S3 [28.#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS //设置哪个轴长度补偿应用的工具。假设轴总是与选择轴工具面向负方向; g! K" Z8 t) P0 A+ [( F
29.#define VARIABLE_SPINDLE //允许变量轴输出电压不同的转速值。
! [% o; j6 }3 J) h6 S+ u30.#define SPINDLE_MAX_RPM 1000.0  // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.( C; X9 M% E3 r; i4 i4 f- @9 J* V
   #define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.3 o+ N6 ]+ R6 p
31.#define MINIMUM_SPINDLE_PWM 5 //使用的变量轴输出。这迫使PWM输出最小占空比时启用。
0 }% P$ @7 o4 O" ]- \0 [5 n32.#define USE_SPINDLE_DIR_AS_ENABLE_PIN //主轴方向使能M4被删除
" P+ O! o) C' o( S7 [& `33.#define REPORT_ECHO_LINE_RECEIVED //应该对所有正常线路送到Grbl
4 R! F" f# }+ G, d34.#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min) //最小规划师结速度。设置默认最小连接速度规划计划1 r  s. g% ], S
35.#define MINIMUM_FEED_RATE 1.0 // (mm/min)//设置计划将允许的最小进给速率1 v. F6 l( [  J: w" Y" Q
36.#define N_ARC_CORRECTION 12 //弧生成迭代次数之前小角度近似精确的弧线轨迹' T4 `) P/ ~% w/ x2 |" T
37.#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)//定义值设置机器ε截止来确定电弧是一个原点了?1 b4 g  K3 @' S* A
38.#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds) //延时增加表现在住。默认值设置为50毫秒: g) M. M9 e/ x* U' v5 [4 K; y
39.#define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled." I. x2 f$ v4 y
40.#define BLOCK_BUFFER_SIZE 18  //线性运动规划师缓冲区的数量在任何给出时间计划
# G: o) d4 `+ H: v41.#define SEGMENT_BUFFER_SIZE 6 //控制之间的中间段缓冲大小的步骤执行算法7 \4 v1 {) L, C# C, j) }9 g- ]
42.#define LINE_BUFFER_SIZE 80 //行执行串行输入流的缓冲区大小。
% `1 t# L& b% \, y$ Q2 a: V43.define RX_BUFFER_SIZE 128 //串行发送和接收缓冲区大小8 A, U- g1 T' u& n0 K: _
44.#define TX_BUFFER_SIZE 64- L+ B. C) s  _
45.#define ENABLE_XONXOFF        ////切换为串行通信发送流软件流控制。
' Z# {# `' W) x6 Z" x& R, ]0 l46.#define ENABLE_SOFTWARE_DEBOUNCE //一个简单的软件消除抖动特性硬限位开关。6 n' U/ g& M6 I4 `1 I" U
47.#define HARD_LIMIT_FORCE_STATE_CHECK        //Grbl检查硬限位开关的状态; _- x( u/ I/ }4 W  J. k
48.// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:编译时错误检查的定义值:
# G) f7 v/ g1 T. y
: v& Y. d1 ~/ b( O4 F  l6 M* e& R___________________________________________________________________________________________________
1 A" l8 [9 H1 U/*# L0 J! p2 M" R6 E1 w$ v
  config.h - compile time configuration
2 R% \2 u. N  l9 m  Y0 B, x5 c  Part of Grbl9 i. [& l- j: c- W) p9 s3 R+ D$ i
1 X+ }, B  I4 b5 \, f" {
  Copyright (c) 2012-2015 Sungeun K. Jeon& a8 E8 h% X3 J  T
  Copyright (c) 2009-2011 Simen Svale Skogsrud
) U: {+ z" X- v3 F: _; p: g
1 m* e1 A; H  y4 m5 N) v  Grbl is free software: you can redistribute it and/or modify
# h3 N& C: g7 k# \/ O7 e% {  it under the terms of the GNU General Public License as published by+ f0 H2 |. Q! X; J0 I
  the Free Software Foundation, either version 3 of the License, or
5 F9 N  c; a& g' l0 t/ D& T  (at your option) any later version.) `. O7 b$ T- w1 V

3 C0 d( l+ u8 s% D2 l  Grbl is distributed in the hope that it will be useful,
5 D' j6 U+ j# b# v  but WITHOUT ANY WARRANTY; without even the implied warranty of
" Z# r: p9 f3 D  G  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
' W7 M: Y: R, {1 b2 k; s0 ?  GNU General Public License for more details.
! C4 _2 ^1 u3 w$ r3 L' v- v  Y
, E, z* K- L  q3 m1 b- d( r3 t  You should have received a copy of the GNU General Public License" Z& V/ N& h7 ^, j5 Y: T  d" ?
  along with Grbl.  If not, see <http://www.gnu.org/licenses/>.7 E( g4 v; x( N7 n2 [
config.h  -编译时配置,Grbl的一部分- Y# B, T- F% D1 f  [; h/ ]4 f0 X

" \8 F- ^8 |$ D% `版权(c)2012 - 2015 Sungeun K. Jeon
- l4 t  H# F0 m! d& c. R版权(c)2009 - 2011 Simen Svale Skogsrud
4 b0 C7 P3 S4 T$ _  O
/ t4 `" \" P* C! Y' h1 r5 S1 VGrbl是免费软件:可以重新分配和/或修改! ^, \4 r* j* W5 F% S- E
GNU通用公共许可证的条款下发布的自由软件基金会,版本3的许可,或(任您选)其后的版本。
/ W" O  F4 ~* r; j% l
: Z9 G3 K0 W" h! `" oGrbl分布,希望这将是有用的,但是没有任何保证;没有即使的默示保证适销性或健身为特定目的。看到% W( }6 q" G. a# Y6 ~
GNU通用公共许可证的更多细节。2 R& \) N+ }  {+ x

) e/ \6 x# d8 J% a8 A你应该收到了GNU通用公共许可证的副本( z4 S. p5 A0 M6 r& e4 @1 f: V
连同Grbl。如果没有,看< http://www.gnu.org/licenses/ >。
6 z$ Z% o  f& r8 d4 p- w / \2 X( B: s! z5 [
*/# R# v# E+ P8 Z9 _' F" ?
  5 M5 r8 t: ]' `& {
// This file contains compile-time configurations for Grbl's internal system. For the most part,
  L3 w7 `. d0 N% e9 X// users will not need to directly modify these, but they are here for specific needs, i.e.2 N6 ]# i: Y! x5 S  k' u
// performance tuning or adjusting to non-typical machines.+ j# F# i- V% O, T9 z. F: v8 p* K
//这个文件包含编译时配置Grbl的内部系统。在大多数情况下,
( |5 f, N7 Z- a0 u# H4 `* G//用户不需要直接修改这些,但是他们在这里为特定的需求,即。
; F, D2 j5 N. y& U2 b9 J, @//性能调优或适应非典型的机器。& S! f( T( L2 w3 I. F

( K9 \2 j$ e% q# N1 g// IMPORTANT: Any changes here requires a full re-compiling of the source code to propagate them.: b+ q- L$ ~9 m& N% U5 O
//重要:任何变化需要一个完整的基于源代码的传播。
- r# [: x" Y- o, M
: ^7 o% G4 I. I6 C2 Y7 v0 d; x#ifndef config_h9 D4 }) _, Z3 p+ p+ U, _  i
#define config_h$ {+ D, {% W# ^! r$ e4 }
#include "grbl.h" // For Arduino IDE compatibility.
; }5 V) I; C5 x! D& ]) N
. }8 @* V3 g: `# l# Z6 h4 F// Default settings. Used when resetting EEPROM. Change to desired name in defaults.h
2 m- G7 ^% W4 W// 默认设置。在重置eepm时使用。在defaults.h改变想要的名字  E8 N) O8 S0 r! X0 O1 G
1 J7 g! Z( J" O5 \* q
#define DEFAULTS_GENERIC% j$ z& V2 V) r. a# i3 }" V1 @
  U4 m0 B) ]+ ~- J& ~, b: g
// Serial baud rate
& x  j- n0 p! H#define BAUD_RATE 115200                //配置串口波特率1152007 @9 s/ P9 W1 V* {/ [: A3 G

' ~. Y* E# J0 K3 ~// Default cpu mappings. Grbl officially supports the Arduino Uno only. Other processor types
0 C8 r1 ^0 o: r4 C; M6 f// may exist from user-supplied templates or directly user-defined in cpu_map.h) m! l5 v% C, g$ i' F1 y, s
//默认cpu映射。Grbl正式支持Arduino Uno。其他类型的处理器可能存在cpu_map.h直接从用户提供的模板或用户定义的) d. S0 P5 H6 H+ w' D
' ^8 f2 {) w0 M' C
#define CPU_MAP_ATMEGA328P // Arduino Uno CPU1 f* Z2 b" K* X3 N) V8 }) {
, {/ d! Z, y$ H4 j6 J
// Define realtime command special characters. These characters are 'picked-off' directly from the
$ L5 G7 I: u7 d* A6 [  ?! _// serial read data stream and are not passed to the grbl line execution parser. Select characters! U1 z' V  P* B
// that do not and must not exist in the streamed g-code program. ASCII control characters may be
. ?, H, D5 I5 s0 D// used, if they are available per user setup. Also, extended ASCII codes (>127), which are never in
* t" k6 J/ N# Y! _// g-code programs, maybe selected for interface programs.
0 m1 b" g1 E7 |, M1 H8 ]' Q// NOTE: If changed, manually update help message in report.c.
  ?0 h) q$ x5 t( Y* ?, K
# e( n3 q/ o  V' @- H  n//定义实时命令特殊字符。这些字符是直接从“各个击破”串口读取数据流并没有传递到grbl行执行解析器。选择角色. v9 m- \( P$ |" s$ R
//不,不能存在于程序流刀位点。ASCII控制字符, V7 L6 o/ @6 B$ t  e$ u
//使用,如果他们是可用的每个用户设置。同时,扩展的ASCII码(> 127),从来没有# C+ k( g" k& B1 M% f& r% V
//刀位点的程序,也许选择界面程序。
- a  Z" r; D  A7 W: S3 I//注意:如果改变,手动更新report.c帮助信息。
6 Q- f& J. I; {/ c) n- d3 M
- C1 R* {7 q' o# I9 T9 g5 x#define CMD_STATUS_REPORT '?'
* r7 Z. T& h, W9 ^#define CMD_FEED_HOLD '!'
9 Q% B) x8 ]# P: {#define CMD_CYCLE_START '~'
7 _; G" k. f% O, ^$ a; ^#define CMD_RESET 0x18 // ctrl-x.  J6 _2 s% s; Z  \
#define CMD_SAFETY_DOOR '@'
; W: t) G2 A2 |' w0 _$ F
) K8 [$ [1 d. X6 [/ D4 Y. }// If homing is enabled, homing init lock sets Grbl into an alarm state upon power up. This forces+ X& B/ o3 H, Z. D8 T2 K, a
// the user to perform the homing cycle (or override the locks) before doing anything else. This is" K) b8 u- l# m1 C6 F% r/ t, R
// mainly a safety feature to remind the user to home, since position is unknown to Grbl.2 n" q, t; X- V/ \5 q9 `# k9 b
7 b$ V. {; l+ z
//如果启用了回原点,导航初始化锁集Grbl进入警报状态启动。这就迫使2 p8 ~: |& E/ g6 \8 ]! N. @
//用户执行归航周期(或覆盖锁)在做任何其他事情之前。这是
5 j/ M: H' }  x1 e+ S* J' X! K//主要安全功能,提醒用户家里,因为Grbl位置是未知的。
! x6 x$ c! [" _1 X
  t5 I# L! i  a, R#define HOMING_INIT_LOCK // Comment to disable+ W) l" O2 l5 M/ ]

* d. a* k+ G) d' p" U// Define the homing cycle patterns with bitmasks. The homing cycle first performs a search mode
5 F1 h1 n' a" ]2 v% H1 E// to quickly engage the limit switches, followed by a slower locate mode, and finished by a short
7 @. ^5 R6 h* p5 ~. U: H) m// pull-off motion to disengage the limit switches. The following HOMING_CYCLE_x defines are executed 1 U# i/ k, e# P  }. Y
// in order starting with suffix 0 and completes the homing routine for the specified-axes only. If
, f, C2 h; z  o6 d( y- x+ g// an axis is omitted from the defines, it will not home, nor will the system update its position.
7 l$ Q) b7 Y. E  p/ M- t* a6 X; _5 p// Meaning that this allows for users with non-standard cartesian machines, such as a lathe (x then z,) T/ ~, G$ `, g- w! `0 t* C
// with no y), to configure the homing cycle behavior to their needs.
3 m% W; v2 {+ Z// NOTE: The homing cycle is designed to allow sharing of limit pins, if the axes are not in the same
: Q. x; M) A5 B* S, S) e/ q// cycle, but this requires some pin settings changes in cpu_map.h file. For example, the default homing8 F8 A. j9 k+ J1 o7 d
// cycle can share the Z limit pin with either X or Y limit pins, since they are on different cycles.
% U( }5 `' j: u) C8 L" C. u6 Z// By sharing a pin, this frees up a precious IO pin for other purposes. In theory, all axes limit pins
. I! M$ c' k4 |# {# s  U6 D! O// may be reduced to one pin, if all axes are homed with seperate cycles, or vice versa, all three axes9 V" R+ \& c, e- P4 P; S9 {
// on separate pin, but homed in one cycle. Also, it should be noted that the function of hard limits
7 R# L$ W1 J, y4 {* v3 \// will not be affected by pin sharing.3 p" X1 r- ]4 S# d8 A
//定义导航循环模式的位掩码。归航周期首先执行一个搜索模式
4 @- v* ~( [' l) a: j. J9 M. N% s8 \' p//快速进行限位开关,其次是较慢的定位模式,完成了由一个短8 g7 V: |+ T" V5 a: A6 d' }4 w
//拖出运动脱离限位开关。以下HOMING_CYCLE_x定义执行) Q7 L( J* X4 K" X% X) h
//为了与后缀0开始并完成specified-axes只寻的例程。如果5 A) |2 N! E/ M
//定义省略一个轴,它会不在家,也不会系统更新它的位置。
# Q7 e/ U' K9 n/ g//意义,这允许用户与非标准笛卡尔的机器,比如车床(x,z,
" ~0 M0 M# ~! A5 r' D//没有y),配置导航循环行为对他们的需求。
6 S" s9 a" x, H) A# H//注意:归航周期允许共享限制针,如果轴不相同# ]+ A0 p. N" `' T) Q
//循环,但这需要一些销设置cpu_map的变化。h文件。例如,默认的导航7 F4 N  s, E6 D/ z# l, J: `% ~, j
//循环可以分享Z限位销X或Y限制针,因为它们是在不同的周期。
4 W8 a1 ^6 b' p6 M* |% h7 k//通过共享一个销,这腾出宝贵的IO销用于其他目的。从理论上讲,所有轴限制别针! q& R' Y, w4 B& g6 ~  d) b& C* a6 T
//可能会减少到一个销,如果所有轴与分离周期居住的地方,反之亦然,所有三个轴
- x' M: n6 O1 ]% v//在不同销,但这时候一个周期。同时,应该注意的是,硬限制的功能# E  p; B) ?* c; Y
//将不会影响销共享。. E: Q6 |( \) v6 _9 N
//注意:默认设置为一个传统的硬件数控机器。z轴首次明确,其次是X和Y。& n# B' s; P. d7 L0 v; v. I& @

$ `9 e3 }# e/ w' a9 g2 Z. S+ G// NOTE: Defaults are set for a traditional 3-axis CNC machine. Z-axis first to clear, followed by X & Y.
, N! S, N3 x/ @5 q9 A#define HOMING_CYCLE_0 (1<<Z_AXIS)                // REQUIRED: First move Z to clear workspace. 第一步Z清除工作区。, j+ {( C8 Y" `8 |
#define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // OPTIONAL: Then move X,Y at the same time.然后X,Y在同一时间。
$ t8 k8 N6 `9 E9 y% P4 v2 J// #define HOMING_CYCLE_2                         // OPTIONAL: Uncomment and add axes mask to enable3 p3 K1 M. h( Z5 q6 s# E% |( d

/ N2 B4 ?6 k& r+ d& e) r// Number of homing cycles performed after when the machine initially jogs to limit switches.
# m1 a+ P" v# K& N, N0 h// This help in preventing overshoot and should improve repeatability. This value should be one or
% O5 r0 d+ ~8 G' V2 @// greater.: h7 E! ~$ H% l3 z
//执行回原点循环次数后,当机器最初慢跑限位开关。这个帮助防止过度,应该提高重复性。这个值应该是一个或大。
% _$ u, E" l! `7 I5 i2 h1 _# R! K6 b% r5 s
#define N_HOMING_LOCATE_CYCLE 1 // Integer (1-128)
5 u$ x1 t+ u! X* O! D6 z: f& H2 W" ^6 k
// After homing, Grbl will set by default the entire machine space into negative space, as is typical
8 [+ c: {" y% t1 s% @5 l/ l* s// for professional CNC machines, regardless of where the limit switches are located. Uncomment this
" f8 V& N" P% |" v. K0 \5 W// define to force Grbl to always set the machine origin at the homed location despite switch orientation.  X, }) t6 Y$ d. `

! \# [: H9 |" M+ q3 B0 y//导航后,默认Grbl将整个机器空间留白,是典型的专业数控机器,不管限位开关所在的地方。$ x3 m6 y; H! j. P
//取消这定义迫使Grbl总是在这时候位置设置机器原点尽管开关方向。& I, N) I: h& u+ V+ R6 t" p" m
  i& g- U- n9 x
// #define HOMING_FORCE_SET_ORIGIN // Uncomment to enable.
" @1 Q( \4 e( q0 Y
* e% P9 O6 T! |8 b
  j5 A% G4 g3 _  p# A# U4 Z// Number of blocks Grbl executes upon startup. These blocks are stored in EEPROM, where the size; F2 \7 J( F9 \2 N* ~0 n
// and addresses are defined in settings.h. With the current settings, up to 2 startup blocks may
4 b/ y4 G6 z. W3 |+ ]9 K: s// be stored and executed in order. These startup blocks would typically be used to set the g-code$ r4 ?7 _: D1 `9 i: k
// parser state depending on user preferences.: `  \1 \9 s4 ^3 A1 D1 v/ c

4 e$ D5 c8 P/ v3 z: f0 ?//块Grbl启动时执行的数量。这些块存储在eepm,大小
2 ?; M$ q/ \4 i//和地址在settings.h中定义。与当前设置,可能2启动块
' @$ U4 |; ^( I- ?1 i: _& ]//存储和执行。这些启动块通常被用来设置刀位点& Z! n7 P' e5 t
//解析器的状态取决于用户首选项。# v4 q6 l0 P0 P& W
2 P+ H! l! T+ s( W0 H7 E1 L
#define N_STARTUP_LINE 2 // Integer (1-2)2 E' S; S4 j: K) Z; n& `. v

/ _' H; A9 u6 X4 F4 |0 C// Number of floating decimal points printed by Grbl for certain value types. These settings are
5 o: n, i( k; G* `9 [// determined by realistic and commonly observed values in CNC machines. For example, position# _0 O1 M0 b( d2 @
// values cannot be less than 0.001mm or 0.0001in, because machines can not be physically more
3 A) w& F) g( A' R// precise this. So, there is likely no need to change these, but you can if you need to here.3 x+ F& C4 A: `( F! j
// NOTE: Must be an integer value from 0 to ~4. More than 4 may exhibit round-off errors.
' A! m9 e: K  t* T( V5 J9 F" s( M5 p& V1 D4 |: o% ]" }
// Grbl浮动小数点的数字印刷的特定的值类型。这些设置是5 E: G1 }; f# _9 P  `& ]  L9 S  q
//一般由现实和观测值在数控机器。例如,位置1 d) l) h, }; V2 K* ]& w
//值不能小于0.001毫米或0.0001,因为机器不能身体更多
, h4 V2 z4 y$ c9 l6 l//精确。因此,有可能不需要改变这些,但你可以在这里如果你需要。
, A6 I: v& a! K  F//注意:必须是一个整数值从0 ~ 4。超过4可能出现舍入错误。' h5 i: T, ^3 n- v5 w3 [" \
/ A+ b* t! _& ]9 [8 ^5 o
#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 协调或位置价值英寸
. w/ |. B" `7 [1 }9 a#define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 协调在毫米或位置价值5 q; v+ U+ S0 \; b# C  V
#define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分钟的速度值3 W- @, h$ F- o% h( l$ Y  A8 ^
#define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分钟, L' s& U- [/ q( L, t" C  ]
#define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 对浮点小数设置值. ?( J% u7 a% g7 C6 Y( x) r& q1 y
; `5 o2 s( c: T4 D+ T3 U
// If your machine has two limits switches wired in parallel to one axis, you will need to enable
% v+ U5 p& B* f8 p- ~7 D  G& j// this feature. Since the two switches are sharing a single pin, there is no way for Grbl to tell
- [# I* g0 T3 f" C! e// which one is enabled. This option only effects homing, where if a limit is engaged, Grbl will
" k, I' x2 B( x' b- Y- p) v$ y// alarm out and force the user to manually disengage the limit switch. Otherwise, if you have one
: ~- e4 Z- w4 U// limit switch for each axis, don't enable this option. By keeping it disabled, you can perform a' w7 M) l, N0 ^7 Y: o! r4 M0 T6 ^" Z
// homing cycle while on the limit switch and not have to move the machine off of it.
5 ?+ I; t  ?0 V% E6 A7 P2 h! B
2 ~4 M6 c8 q3 y* w+ {; O//如果你的机器有两个极限开关连接在平行于一个轴,您需要启用
/ W- o$ H5 E2 Y$ ]8 o' O# {//这个特性。自从两个交换机共享一个销,没有办法Grbl告诉
; [2 w7 u- T2 s  X4 K* A' N//启用哪一个。此选项仅影响归航,如果限制,Grbl意志
8 M* n2 c) [' i, b) P* V//报警,迫使用户手动松开限位开关。否则,如果你有一个
" N" g6 N( V/ `0 p7 @5 i//为每个轴限位开关,不启用该选项。通过保持禁用,您可以执行+ Y) h4 P4 z* e4 A( ]' a7 C' ]0 H
//导航循环在限位开关并没有将这台机器。
8 o8 g7 k, `. U$ m' a: q  ]# t; u/ ~, l
// #define LIMITS_TWO_SWITCHES_ON_AXES4 Q# D* L% I/ s# Q: f+ G

0 L: ~' f2 P/ m// Allows GRBL to track and report gcode line numbers.  Enabling this means that the planning buffer
* ~8 Y) z  z4 }# j. u// goes from 18 or 16 to make room for the additional line number data in the plan_block_t struct9 K! j+ v% \4 p

7 k4 Z9 l( |) |6 e' \7 j, M9 {7 H; ]//允许GRBL跟踪和报告gcode行号。使这意味着计划缓冲从18岁或16岁,为额外的行号plan_block_t结构中的数据
/ m$ J2 V. ?0 \3 s9 ~. ~- g7 y
/ g: h. H5 w% L% v( H- C( k! j// #define USE_LINE_NUMBERS // Disabled by default. Uncomment to enable.
0 q& l" F' j3 B' G
5 Z2 T( z4 H1 o* p8 ]& e// Allows GRBL to report the real-time feed rate.  Enabling this means that GRBL will be reporting more   C+ Y, ~! Z) r" B  _6 j6 o
// data with each status update.6 P3 y8 F  a8 N% s* x* }+ p/ K
// NOTE: This is experimental and doesn't quite work 100%. Maybe fixed or refactored later.
' d- q& b- E# }6 A0 v, ]  b5 q//允许GRBL报告实时进给速率。使这意味着GRBL将报告数据和状态更新。
$ V4 i8 r/ d/ [% N+ d( R9 |//注意:这是实验和100%没有工作。也许以后固定或重构。- P6 n9 K" y/ U  N( h5 t

# p. ?6 o* y. L' Q* n, y// #define REPORT_REALTIME_RATE // Disabled by default. Uncomment to enable.
( P4 J' N) T4 Q, P+ k
9 G/ S% w' y+ D; J8 Q- h, b& g// Upon a successful probe cycle, this option provides immediately feedback of the probe coordinates. A' K9 k# u# E8 r
// through an automatically generated message. If disabled, users can still access the last probe" `& G& w6 W+ I8 W6 r( r1 I
// coordinates through Grbl '$#' print parameters.
# n; c; _. H. H9 G# [( p//在一个成功的调查周期,这个选项提供立即反馈的探测器坐标
6 |/ M5 G9 _3 R# g- }2 }//通过一个自动生成的消息。如果禁用,用户仍然能够访问调查0 Y/ ?  T- P3 j1 D1 m0 o
//坐标通过Grbl $ #的打印参数。5 ~4 ~% Q* J& A5 z) |" l
- P7 ^) ]/ p* o- B0 d( K
#define MESSAGE_PROBE_COORDINATES // Enabled by default. Comment to disable., W! @8 f: Q3 F, {7 [# E; Q

1 v$ P# ?. r  ^* m3 q// Enables a second coolant control pin via the mist coolant g-code command M7 on the Arduino Uno
( _: d) W* o: E; E7 V2 Q& k- Z& D// analog pin 5. Only use this option if you require a second coolant control pin.0 n- `7 u+ y/ ?! p
// NOTE: The M8 flood coolant control pin on analog pin 4 will still be functional regardless.- @. m! V' s3 x7 j8 ?6 O
// #define ENABLE_M7 // Disabled by default. Uncomment to enable.
) c- k  e5 M: _! i. R7 l
2 a& @1 ~8 Y6 R  w5 q3 P// This option causes the feed hold input to act as a safety door switch. A safety door, when triggered,$ U# O0 g8 x2 O9 b' v
// immediately forces a feed hold and then safely de-energizes the machine. Resuming is blocked until# O- D7 j# c  i4 [/ o# P0 K2 `8 D
// the safety door is re-engaged. When it is, Grbl will re-energize the machine and then resume on the* H2 l! g* v' @! P7 |7 w4 x
// previous tool path, as if nothing happened.! I9 p) \( r/ k/ d% B7 z: K
// #define ENABLE_SAFETY_DOOR_INPUT_PIN // Default disabled. Uncomment to enable.
& E" P& K; g5 F/ @$ R
$ A: v4 g( G' |7 J// After the safety door switch has been toggled and restored, this setting sets the power-up delay+ f2 m1 C9 Z8 M, Q, Z0 Q
// between restoring the spindle and coolant and resuming the cycle.7 Z$ g4 X9 B1 o
// NOTE: Delay value is defined in milliseconds from zero to 65,535. ! J: N2 a, C  t

1 P* I, J2 o/ O& X//定义导航循环模式的位掩码。归航周期首先执行一个搜索模式' [' K2 P! k0 i5 @9 F6 K  k
//快速进行限位开关,其次是较慢的定位模式,完成了由一个短
/ L$ _4 K* T. c; P//拖出运动脱离限位开关。以下HOMING_CYCLE_x定义执行
" @" l7 V$ f" a, ^4 [0 `//为了与后缀0开始并完成specified-axes只寻的例程。如果5 ]) w0 U& L: k! Z4 Z% C
//定义省略一个轴,它会不在家,也不会系统更新它的位置。
( K2 P- ~; f. v0 m//意义,这允许用户与非标准笛卡尔的机器,比如车床(x,z,# l7 t3 J& \( `$ R
//没有y),配置导航循环行为对他们的需求。
* V5 [1 Y; J. s//注意:归航周期允许共享限制针,如果轴不相同/ v, L9 y: Q  v- N6 g2 ~/ \2 n0 r7 M
//循环,但这需要一些销设置cpu_map的变化。h文件。例如,默认的导航
+ F# y  F* E7 c  @//循环可以分享Z限位销X或Y限制针,因为它们是在不同的周期。
8 u6 `6 f9 b# M5 I6 u. W, y. ?) I//通过共享一个销,这腾出宝贵的IO销用于其他目的。从理论上讲,所有轴限制别针
7 O) A, S5 r+ S1 Y) [1 J//可能会减少到一个销,如果所有轴与分离周期居住的地方,反之亦然,所有三个轴1 s: p+ u$ w! _( q/ u
//在不同销,但这时候一个周期。同时,应该注意的是,硬限制的功能, I0 z. S) b8 c9 D
//将不会影响销共享。
& q2 s! E6 B+ C0 }2 W. ^//注意:默认设置为一个传统的硬件数控机器。z轴首次明确,其次是X和Y。
9 T3 |+ t0 F1 L, c, E/ o
: N$ g2 O# [6 }- _2 \  g, I" p3 v7 `6 n) ]
#define SAFETY_DOOR_SPINDLE_DELAY 4000: r: x0 H: i% w- |5 I5 E
#define SAFETY_DOOR_COOLANT_DELAY 1000
8 T) P( p" G8 ~- K' w
$ x' q4 P. i0 H! E( ^: @// Enable CoreXY kinematics. Use ONLY with CoreXY machines. 4 [4 g  x, m3 E! Z. k' a( ~" V
// IMPORTANT: If homing is enabled, you must reconfigure the homing cycle #defines above to
) P+ |3 q2 D$ c9 D% M' \//启用CoreXY运动学。只使用与CoreXY机器。
# h: E+ `2 u+ w- j% c/ r$ I' H//重要:如果启用了自动寻的,你必须重新配置导航循环#定义上面9 s  Y# e7 {# w# {/ H3 ]+ X( y! k
* C! |( e) N1 c% J) `- x6 q
// #define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS)& i/ x, H; o5 a! O. k1 T& ?+ @. l
/ d: O' J) ]3 u+ q# K
// NOTE: This configuration option alters the motion of the X and Y axes to principle of operation
& i% U% D: E6 e3 \8 h8 k// defined at (http://corexy.com/theory.html). Motors are assumed to positioned and wired exactly as
. O5 I; N' _! Y  k) S' l: c// described, if not, motions may move in strange directions. Grbl assumes the CoreXY A and B motors4 N& h  ~* |$ |: W
// have the same steps per mm internally.# _; m- k- T) C1 }# F# a
//注意:这种配置选项改变X和Y轴的运动原理,操作& e/ r% N; e% ?/ I% n+ U
//定义(http://corexy.com/theory.html)。汽车被认为定位和连接一样
4 ~' T# u9 a4 ]8 j2 v//描述,如果没有,运动可能会奇怪的方向移动。A和B Grbl假设CoreXY马达
) y7 P  I6 Q& V) ^0 b" _//每毫米内部有相同的步骤。
; f' e# J/ h; E
7 U2 _0 Y. e4 A4 u- C5 {5 ~// #define COREXY // Default disabled. Uncomment to enable.
. ?- ]# ?" x* x9 ~: U
% @6 f7 J3 Z3 c" r" E// Inverts pin logic of the control command pins. This essentially means when this option is enabled
0 G2 u1 V+ S' n+ \/ Z% {// you can use normally-closed switches, rather than the default normally-open switches.
: K8 G! s( n8 e& T4 a// NOTE: Will eventually be added to Grbl settings in v1.0.
: L* `4 r% a, V4 S5 `0 t//反转针销逻辑的控制命令。这实质上意味着当启用这个选项
0 V, k/ Q0 r7 m! `  j//可以使用闭合开关,而不是默认的常开开关。
) l) Q1 O) N* w7 R/ v* f2 p//注意:最终将被添加到在v1.0 Grbl设置。
) U4 [+ c# f) b8 i+ B
' o9 ]6 y3 x5 y1 D* U4 R// #define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.  Y* f- M6 K) \4 A( z$ X
; i0 k. Z$ u. G
// Inverts the spindle enable pin from low-disabled/high-enabled to low-enabled/high-disabled. Useful
  t" {8 |7 ^% j) _// for some pre-built electronic boards.
- J; Y( q, {: S! S0 B& Q4 B// NOTE: If VARIABLE_SPINDLE is enabled(default), this option has no effect as the PWM output and 3 E2 M8 g! j3 k* p6 _1 t) ?3 s
// spindle enable are combined to one pin. If you need both this option and spindle speed PWM,
& O0 u. `6 {$ y% N3 ]& ]" s// uncomment the config option USE_SPINDLE_DIR_AS_ENABLE_PIN below.
+ w; K0 G" c9 c: D. l//反转主轴使销从low-disabled / high-enabled low-enabled / high-disabled。有用的' D# H- C8 w+ n8 t
//预构建的电子板。6 {+ E! X3 d8 u' }+ L
//注意:如果启用了VARIABLE_SPINDLE(默认),这个选项作为PWM输出并没有影响* U& T3 ~& ?: G$ r0 n1 |2 I/ g
//销轴使结合。如果你需要这个选项和主轴转速PWM,
0 s; R) r4 x. l: |//取消注释以下配置选项USE_SPINDLE_DIR_AS_ENABLE_PIN
6 E# `# _" r! f( P. R) w
# _  r$ ^* l! }, g// #define INVERT_SPINDLE_ENABLE_PIN // Default disabled. Uncomment to enable.
5 @; ^, |: P% c. d6 T5 y* w  x- O: [! W, `: K6 H: S) s" l! d
// Enable control pin states feedback in status reports. The data is presented as simple binary of3 P' d9 Y: a6 M7 _- r8 |
// the control pin port (0 (low) or 1(high)), masked to show only the input pins. Non-control pins on the
; U8 H; D: }) |7 b7 N// port will always show a 0 value. See cpu_map.h for the pin bitmap. As with the limit pin reporting,
1 H' ^5 E0 y8 j. [5 S" r// we do not recommend keeping this option enabled. Try to only use this for setting up a new CNC.
6 _8 |- @7 Q8 A9 f+ p' E. j( `# k//启用控制销状态反馈状态报告。作为简单的二进制数据
- k/ Z; G% J; R' g% R9 F% t; D. Z, l4 V//控制针端口(0(低)或1(高)),蒙面,只显示输入插脚。非控制性针上3 @% O7 y  y# i$ }9 [. ?6 b; `
//端口总是显示0值。看到cpu_map。针位图h。与限制销报告,% J; A5 H- |$ J; ?+ C2 |  n
//我们不推荐保持启用这个选项。尽量只使用这个设置一个新的数控。
# W) z$ C1 I7 {0 I
4 b' R6 c! ]2 e& B; s  U+ x// #define REPORT_CONTROL_PIN_STATE // Default disabled. Uncomment to enable.3 ]6 \: N& b+ X

( f; T1 B9 b. d9 s// When Grbl powers-cycles or is hard reset with the Arduino reset button, Grbl boots up with no ALARM- ]( Q1 i* D2 ?4 l& w! J
// by default. This is to make it as simple as possible for new users to start using Grbl. When homing; i6 u" Y% C) s' U( k' _
// is enabled and a user has installed limit switches, Grbl will boot up in an ALARM state to indicate
" ~# \" K0 r1 V- }- g6 S// Grbl doesn't know its position and to force the user to home before proceeding. This option forces
- W8 s" R( G" N, B2 [& ?. u// Grbl to always initialize into an ALARM state regardless of homing or not. This option is more for, I1 v: K6 {! b# n; V0 M/ w' `
// OEMs and LinuxCNC users that would like this power-cycle behavior.
* i8 G# n7 C6 r6 c//当Grbl powers-cycles还是硬重置Arduino复位按钮,Grbl启动没有报警: w( }2 u' T) J2 y  q& U/ E
//默认情况下。这是为了让新用户尽可能简单使用Grbl开始。当归航
2 ?: D) }* j1 B  M+ y+ H  ~//启用和用户安装限位开关,Grbl将启动报警状态指示6 W8 L& C1 q2 J& w8 \' ]
// Grbl不知道它的位置,迫使用户在继续之前回家。这个选项部队
3 r. n% C: A, ?2 ~// Grbl总是初始化进入警报状态不管归航。这个选项是更多
$ A5 [& I" V9 E//原始设备制造商和LinuxCNC用户这样的控制行为。
) S8 K/ ^3 G9 \
, p0 ^) v6 I) K3 d// #define FORCE_INITIALIZATION_ALARM // Default disabled. Uncomment to enable.
* V7 ^/ u; h% ^$ w, f9 T" f7 o( ?5 `* {
// ---------------------------------------------------------------------------------------
( N2 b& Y3 X: w, h// ADVANCED CONFIGURATION OPTIONS://高级配置选项:
: C- o& I/ `) Q9 W' m. w/ W+ I  t# d' s* y
// Enables minimal reporting feedback mode for GUIs, where human-readable strings are not as important.9 h) @# Y4 ]! _7 h
// This saves nearly 2KB of flash space and may allow enough space to install other/future features.
0 o2 u! ]; q3 ]4 Q/ I' j8 X! o// GUIs will need to install a look-up table for the error-codes that Grbl sends back in their place.& e: {" H9 R( \' r# t
// NOTE: This feature is new and experimental. Make sure the GUI you are using supports this mode.. g9 P2 B- g3 k

/ W# I0 g4 f7 F" s# {( _4 H// gui允许最小的报告反馈模式,人类可读的字符串在哪里不重要。# P8 @* g( R  X5 u/ s# J
//这个节省近2 kb的闪存空间,允许足够的空间来安装其他/未来的功能。6 V# I4 k+ g2 s+ F
// gui需要安装一个查找表的错误代码Grbl发回。! ^8 F# B& a0 @* |7 J
//注意:此功能是新的和实验。确保您使用的GUI支持这种模式。' ?& w4 s' o: _: W4 {: j
. m: b1 H( w" Z2 b9 n
// #define REPORT_GUI_MODE // Default disabled. Uncomment to enable.
4 H# e& Z2 D7 v# a7 A+ X% T$ x2 b5 m6 }8 @
// The temporal resolution of the acceleration management subsystem. A higher number gives smoother" V# f/ Q1 g8 u+ p- z
// acceleration, particularly noticeable on machines that run at very high feedrates, but may negatively
2 `, w5 w# t. t  R/ p- I  _// impact performance. The correct value for this parameter is machine dependent, so it's advised to  i: p6 K0 z- s& G: @# P$ n
// set this only as high as needed. Approximate successful values can widely range from 50 to 200 or more.
) `. O; @' s1 {8 [% M// NOTE: Changing this value also changes the execution time of a segment in the step segment buffer. 5 @/ p" Z& k- r/ ?
// When increasing this value, this stores less overall time in the segment buffer and vice versa. Make1 l% n0 B/ {  H2 V- k" i/ ~
// certain the step segment buffer is increased/decreased to account for these changes.
5 `6 V  x, j' j" ?//加速度的时间分辨率管理子系统。更多更平稳$ G" S6 d, c0 N; i0 Z
//加速度,特别明显的机器上,运行在非常高的进料速度,但可能负面4 h$ u% w9 \: |. l" z" Q! o. s
//影响性能。正确的值为这个参数是依赖于机器的,所以建议1 V5 d! f4 t! U7 N9 m. V4 a' c" Q
//这只设置为高。近似成功的价值观可以广泛的范围从50到200或者更多。
! }% o6 D! g5 X. {9 b$ a8 b//注意:改变这个值也变化的部分步骤的执行时间缓冲。5 {' v* L  t) _
//增加这个值时,这个商店部分缓冲区的总时间减少,反之亦然。使1 O4 [4 h7 A8 B
//特定步骤段缓冲是考虑这些变化增加/减少。; [& T7 ^( t6 ?/ ?- i

3 Z5 }2 n6 [1 ?! I1 F  h#define ACCELERATION_TICKS_PER_SECOND 100  //加速度的时间分辨率管理子系统。更多更平稳
# y' l6 I/ @/ I2 y, ~+ y3 a4 [  D$ ^) h* q
// Adaptive Multi-Axis Step Smoothing (AMASS) is an advanced feature that does what its name implies, 9 X( E4 m5 O4 |  p; R! i
// smoothing the stepping of multi-axis motions. This feature smooths motion particularly at low step
: e. ~9 A3 S% l// frequencies below 10kHz, where the aliasing between axes of multi-axis motions can cause audible 8 t  A' E; U1 Q7 @5 h9 u
// noise and shake your machine. At even lower step frequencies, AMASS adapts and provides even better
2 g, g: x# Y/ B6 E9 ^" q// step smoothing. See stepper.c for more details on the AMASS system works.
2 c. M: K1 F5 l( R5 Y. w9 P//自适应多轴步平滑(积累)是一种先进的功能,它的名字所暗示的那样,
9 y0 k9 F" e7 v8 ]% \) K  E//平滑的多轴步进运动。这个特性平滑运动尤其是在低一步8 P) w" i3 j8 M- b
//频率低于10 khz,轴之间的混叠的多轴运动可能导致音响
  M4 n" V% o+ ~2 L//噪音和震动你的机器。在更低的频率步,积累适应并提供更好8 a& P6 ~1 s3 ~! e' p
//步骤平滑。看到步进。c更多细节的积累系统的工作原理。
5 S8 T1 I( D4 K
% g* }4 q$ w& ~, d; Y; }1 X9 y8 b#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING  // Default enabled. Comment to disable.//自适应多轴步平滑1 R3 x) d  p/ ^: V/ S

% x$ C8 J7 R9 V# f  {// Sets the maximum step rate allowed to be written as a Grbl setting. This option enables an error : t) k/ U- g# y8 K/ }" [
// check in the settings module to prevent settings values that will exceed this limitation. The maximum
/ Q. |( j9 |: p' V+ |' A2 J1 H// step rate is strictly limited by the CPU speed and will change if something other than an AVR running
$ ]7 I  Y8 E1 e9 R) A9 g// at 16MHz is used.
3 K. {( L: Q6 e2 @) S// NOTE: For now disabled, will enable if flash space permits., D" \  I9 m" _- Z( H5 P
//设置最大一步速率可以写成Grbl设置。这个选项可以使一个错误# O5 z3 t+ v. ]  e
//设置模块中检查,防止设置值将超过这个限制。的最大/ z' ~& Z. E3 r4 H) G3 l0 A3 g
//步骤严格限制的CPU速度也会改变如果是其他AVR运行0 k0 D( K7 D/ r  D: Z" E! s( U
//使用16兆赫。* G- f# u7 ~! S( P
//注意:现在残疾,将使如果flash空间许可。6 a3 v* z. r, }  m

0 F" K0 k/ q9 m' h% ^$ g4 L7 O* h// #define MAX_STEP_RATE_HZ 30000 // Hz 设置最大一步速率; T% o2 A) B& r4 e6 E2 h+ u

& k/ M* F* R+ W9 T5 d) k- K// By default, Grbl sets all input pins to normal-high operation with their internal pull-up resistors7 d( X# m5 g* g
// enabled. This simplifies the wiring for users by requiring only a switch connected to ground, . q& T( T2 N) k8 R5 }, }; i
// although its recommended that users take the extra step of wiring in low-pass filter to reduce- v# j# E7 X/ H2 @4 t
// electrical noise detected by the pin. If the user inverts the pin in Grbl settings, this just flips# W+ j1 E, X6 X( Y# O4 k
// which high or low reading indicates an active signal. In normal operation, this means the user 0 X) {5 F8 H2 Q; M" m: T* Z
// needs to connect a normal-open switch, but if inverted, this means the user should connect a ) w" Z0 _3 T4 X, N& Z" e3 s$ T! y" ?
// normal-closed switch. 2 {$ t* \, Z0 F! \0 |, _: `$ x
// The following options disable the internal pull-up resistors, sets the pins to a normal-low + c, c" ]# _' ?1 Z- N
// operation, and switches must be now connect to Vcc instead of ground. This also flips the meaning 7 k0 b7 Y/ @1 d' Q
// of the invert pin Grbl setting, where an inverted setting now means the user should connect a ! c# Z( c( X4 R- C: Z
// normal-open switch and vice versa.
- Y1 [: R5 s5 K; `// NOTE: All pins associated with the feature are disabled, i.e. XYZ limit pins, not individual axes.
: o: I7 ?1 ^9 _& t# ]* F// WARNING: When the pull-ups are disabled, this requires additional wiring with pull-down resistors!
- A! P) R) d7 X7 R//默认情况下,Grbl所有输入引脚设置为正常高操作的内部上拉电阻
$ |) _! J5 h0 ]# t//启用。这简化了布线为用户只需要一个开关连接到地面,% ]- p1 W* x: v8 w% ~
//虽然其建议用户采取额外的步骤,在低通滤波器来减少布线' J" r: s3 l8 N0 M+ {
//电噪音检测销。如果用户反转的销Grbl设置,这只是翻转
6 R' n1 y6 O" k+ p/ x! a//读高或低表明一个积极的信号。在正常操作中,这意味着用户
& F2 a) s3 \: ?; X//需要连接一个常开开关,但如果倒,这意味着用户应该连接1 B" a+ c* `# _$ \
// normal-closed开关。
$ b. I" e7 F! O5 Y//以下选项禁用内部上拉电阻,一般低设置别针# C& K( o  r, k
//操作,现在开关必须连接到Vcc代替地面。这也掀的意思( l8 o3 b/ s5 c! J- R; ]
//反销Grbl设置,一个倒置的设置现在意味着用户应该连接. M" z( Y+ Y2 @3 }6 {6 y
//常开开关,反之亦然。; o7 M2 S/ o' T$ _
//注意:所有针与功能被禁用,例如XYZ限制针,而不是单独的轴。
- ]% V8 B; n& a//警告:引体向上被禁用时,这需要额外的布线与下拉电阻!' [' e; h. ^$ J

5 C+ |2 c9 H/ g//#define DISABLE_LIMIT_PIN_PULL_UP //以下选项禁用内部上拉电阻( p. X, G3 Q/ A6 x4 H
//#define DISABLE_PROBE_PIN_PULL_UP
- e+ Q/ N$ r$ W3 C4 G, v& w1 p//#define DISABLE_CONTROL_PIN_PULL_UP" p) A9 @1 }7 q, l' l
$ r  y; ~& }% W' T9 z( W
// Sets which axis the tool length offset is applied. Assumes the spindle is always parallel with ' V. \5 n% ]0 ]" Y; [# y
// the selected axis with the tool oriented toward the negative direction. In other words, a positive8 }! J; J1 A0 ^* T1 ]
// tool length offset value is subtracted from the current location.
. E; W, \2 t% O9 ?0 |) Z7 Z//设置哪个轴长度补偿应用的工具。假设轴总是与
: _& E( n. {! J- `# L( w//选择轴工具面向负方向。换句话说,一个积极的1 J: E" L2 E/ T
//工具长度偏移值减去从当前位置。4 G5 S4 h4 N8 H) q" A8 |
( v( z1 z2 N8 z/ Y0 ?* h
#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS // Default z-axis. Valid values are X_AXIS, Y_AXIS, or Z_AXIS.设置哪个轴长度补偿应用的工具
. }7 U# W; p. {  Y
$ C% W7 C* ~9 P% D& i// Enables variable spindle output voltage for different RPM values. On the Arduino Uno, the spindle
5 l4 q6 q* h& H: H- d( G. n// enable pin will output 5V for maximum RPM with 256 intermediate levels and 0V when disabled.5 f0 W2 N+ j. i1 s; n0 h
// NOTE: IMPORTANT for Arduino Unos! When enabled, the Z-limit pin D11 and spindle enable pin D12 switch!; s, K8 e, @. w2 e/ p/ r
// The hardware PWM output on pin D11 is required for variable spindle output voltages." P+ q; |6 O- O% R* r6 T4 h5 Q" ?
//允许变量轴输出电压不同的转速值。Arduino Uno,主轴/ G- y/ l9 v! ^
//启用销将输出5 v的最高转速256中级水平和0 v时禁用。# {! F( B* \  x! U' q6 D* G. a( F
//注意:重要Arduino凯泽本人!当启用时,Z-limit销这里和轴销D12开关!$ y3 t+ ]9 ~- i9 X! Y( y! B2 W
//硬件PWM输出销这里需要变量轴输出电压。; b. N9 {  ]! F! K* P, S0 }

$ I" ~7 n3 Z) L: q#define VARIABLE_SPINDLE // Default enabled. Comment to disable.//允许主轴输出电压不同的转速值, g' Z6 Z- s. X

2 |1 O" s; j3 J: X1 T( j2 H1 j// Used by the variable spindle output only. These parameters set the maximum and minimum spindle speed2 M3 K* q1 {! p4 }* q
// "S" g-code values to correspond to the maximum and minimum pin voltages. There are 256 discrete and
5 i# o, ]2 I" H: [9 K  v& \, V, Y// equally divided voltage bins between the maximum and minimum spindle speeds. So for a 5V pin, 1000
1 s/ J) c+ x1 E# J// max rpm, and 250 min rpm, the spindle output voltage would be set for the following "S" commands: 1 t9 P, ~2 t( u+ ]9 m
// "S1000" @ 5V, "S250" @ 0.02V, and "S625" @ 2.5V (mid-range). The pin outputs 0V when disabled.$ W% M9 ]+ n1 T+ T4 M5 {6 e: s
//使用的变量轴输出。这些参数设置最大和最小轴转速/ c' u" i4 c+ G" F( u) Z
//“S”刀位点值对应于销电压的最大值和最小值。有256个离散和
1 Z$ A6 y& H. D- l: R; ?$ c, C9 g8 [//电压平均分配箱主轴速度的最大值和最小值之间。所以对于一个5 v销,1000- e! _3 Y9 R! c& M. v; `4 H
// max rpm,250分钟rpm,主轴输出电压将为以下“S”命令:1 _* ~& n8 P# y" W3 D: F
// @“S1000 5 v,“S250”@ 0.02 v,“S625”@ 2.5 v(中档)。销输出0 v时禁用。- ?# O, E1 N3 }! |4 i3 P

9 U0 y, k5 d- }4 v* X; ?8 m. L#define SPINDLE_MAX_RPM 1000.0 // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.
' Y( d* u: a& q5 h9 e#define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.
3 h7 M8 g; C4 b
+ b' c, o4 r( J  [// Used by variable spindle output only. This forces the PWM output to a minimum duty cycle when enabled.
5 U( E/ m4 r  J& Y* @( ]9 H// When disabled, the PWM pin will still read 0V. Most users will not need this option, but it may be ( P. R, I: D& W% q
// useful in certain scenarios. This setting does not update the minimum spindle RPM calculations. Any8 B. M9 w! |1 m0 a% v3 `7 \6 N! y
// spindle RPM output lower than this value will be set to this value.8 O) j  E7 v# }- j5 ]0 r8 k
//使用的变量轴输出。这迫使PWM输出最小占空比时启用。' S. Y- M; X+ T4 v3 h! C
//当禁用,PWM销仍读0 v。大多数用户不需要这个选项,但是它可能是) B# b: @9 o" h1 l& k
//在某些情况下很有用。这个设置不会更新最小主轴转速计算。任何, m% Q0 ~" e6 I! p9 C9 F9 P- ~# ^
//输出轴转速低于这个值将被设置为这个值。
8 D! k0 ]& l. N' Z2 p
/ v$ t7 K% z; j- M// #define MINIMUM_SPINDLE_PWM 5 // Default disabled. Uncomment to enable. Integer (0-255)+ V6 R$ V) H) R. Z8 G* k

) ]+ R1 }- {0 W, z// By default on a 328p(Uno), Grbl combines the variable spindle PWM and the enable into one pin to help
2 W+ ^8 R2 C) K" i! h1 L// preserve I/O pins. For certain setups, these may need to be separate pins. This configure option uses
; [! f! @9 \$ e" ~// the spindle direction pin(D13) as a separate spindle enable pin along with spindle speed PWM on pin D11.
# F2 z9 B7 _4 k! j# ^7 P( I. B, x# `// NOTE: This configure option only works with VARIABLE_SPINDLE enabled and a 328p processor (Uno).
& ^; \# @' e7 D4 Z# T( T4 i3 E0 U// NOTE: With no direction pin, the spindle clockwise M4 g-code command will be removed. M3 and M5 still work.( i2 z& e. O/ F: G
// NOTE: BEWARE! The Arduino bootloader toggles the D13 pin when it powers up. If you flash Grbl with8 y, ~  }1 b! I6 E
// a programmer (you can use a spare Arduino as "Arduino as ISP". Search the web on how to wire this.), - i% L+ t( ]4 S; N- c
// this D13 LED toggling should go away. We haven't tested this though. Please report how it goes!
4 x' [) P; t* i# @1 y# P+ T. g: c//默认ATmega328 p(Uno),Grbl结合变量轴PWM和使到一个销的帮助
* y; q: g, k: u0 m//保存I / O管脚。对于某些设置,这些可能需要单独的别针。这个配置选项使用
" A* S& D# _( D  E; a, Y//方向轴销(D13)作为一个单独的轴销上启用销以及主轴转速PWM这里。5 o( I  S( m) l
//注意:该配置选项仅适用于VARIABLE_SPINDLE启用和328 p处理器(Uno)。) G. v6 @+ G% a; n7 a( [8 g0 t
//注意:没有方向销,主轴顺时针M4刀位点命令将被删除。M3和M5仍然工作。
1 x% Z9 b* e, _//注意:小心!Arduino引导装载程序切换D13销的权力。如果flash Grbl$ F. x* Z* u# l, ^5 @* ?& ?1 P
//程序员(您可以使用一个备用Arduino“Arduino ISP”。搜索网络如何线),
0 s; y! ]& k: G$ L+ U//这D13导致切换应该消失。我们还没有测试这个。请报告将会怎样!
8 ~8 }. K5 H6 u! c8 e" T4 N" Z( t9 v6 t; p) W1 v8 C) h
// #define USE_SPINDLE_DIR_AS_ENABLE_PIN // Default disabled. Uncomment to enable.
! t# [1 {+ m+ L; D1 w4 R; _4 O3 |2 m$ M# V. q
// With this enabled, Grbl sends back an echo of the line it has received, which has been pre-parsed (spaces
# f1 N( y. K1 k: C- f" E// removed, capitalized letters, no comments) and is to be immediately executed by Grbl. Echoes will not be
( w1 ~% S: l8 L; u2 v// sent upon a line buffer overflow, but should for all normal lines sent to Grbl. For example, if a user
7 ~% l, P7 X" Q& I. A// sendss the line 'g1 x1.032 y2.45 (test comment)', Grbl will echo back in the form '[echo: G1X1.032Y2.45]'.8 C; C5 I8 b/ f, z  w
// NOTE: Only use this for debugging purposes!! When echoing, this takes up valuable resources and can effect
% P; k8 n/ x4 W1 d6 P$ A0 N// performance. If absolutely needed for normal operation, the serial write buffer should be greatly increased
. k8 b! _: \. E" U5 G* P( S// to help minimize transmission waiting within the serial write protocol.8 h# H1 {0 v( m

, t6 |) k+ F* Q4 l//启用,Grbl发回的回声线已收到,已预编译(空间
- Y* A( F4 j& W. t$ N7 l  c  r//移除,大写字母,没有评论),由Grbl立即执行。回声将不会
8 l% e6 m: {* o1 o, t& i//发送一个线缓冲区溢位,但应该对所有正常线路送到Grbl。例如,如果一个用户
8 Q9 O! E  V& @- [3 A//发送线的g1 x1.032 y2.45(测试评论)形式”,Grbl将回声”(回声:G1X1.032Y2.45]”。
3 a7 D8 h+ N, |, e5 K//注意:只使用这个调试! !当呼应,这占用了宝贵的资源,可以影响
9 Q1 {! |7 r, S8 c$ _0 I9 P( m//性能。如果正常运行所需的绝对,串行写入缓冲器应该大大增加
: W8 o2 r: Z3 u1 Y' V+ A; _//帮助最小化传输等系列内写协议。! @/ e* S7 T1 K# s/ w" Y8 l# P+ Y

% H* B. v$ R2 [0 b// #define REPORT_ECHO_LINE_RECEIVED // Default disabled. Uncomment to enable.0 v& O" M, J# s2 x) R% g( g; B8 U1 c

# y5 O  M9 Q' b( y1 D/ Y) M# }. p// Minimum planner junction speed. Sets the default minimum junction speed the planner plans to at5 I. g* t" `* V3 C7 R+ _) H
// every buffer block junction, except for starting from rest and end of the buffer, which are always
' w0 q& L/ g# I; z" G  v, w// zero. This value controls how fast the machine moves through junctions with no regard for acceleration
5 N% Q5 d0 R" S: Y3 U// limits or angle between neighboring block line move directions. This is useful for machines that can't
% i* T/ h- m( R/ y9 h) a6 G3 ~. m// tolerate the tool dwelling for a split second, i.e. 3d printers or laser cutters. If used, this value" q( u" Y- E3 i. u' H
// should not be much greater than zero or to the minimum value necessary for the machine to work.
" m( v" [, T8 D0 `5 ]; R1 V6 M1 T: I9 \
//最小规划师结速度。设置默认最小连接速度规划计划- Y% c) L9 ?. o4 N4 `
//每一个缓冲块接头,除了从结束休息和缓冲区,它总是
. }4 e) H! _9 J# z- M1 ^: Y) i+ N// 0。这个值控制机器的速度穿过路口,没有考虑加速度
5 `5 G! [0 \+ {4 e3 l$ ~//限制或相邻块之间的角线方向移动。这是有用的机器,不能3 Z  t* c: }8 z# P7 c
//容忍工具居住某一刹那,即3 d打印机或激光切割机。如果使用这个值
( e: \0 m0 x) A/ K- [4 Y//不应大于零或机器工作所需的最小值。
3 d  C1 }! E4 }! }) H! Y4 R+ c' k. F  o% L' P: v% c
#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min)
( F( `9 t4 p/ u' c( Z% f/ P' X3 P  b9 j- X5 d' G. B6 j
// Sets the minimum feed rate the planner will allow. Any value below it will be set to this minimum% m/ [5 x4 _9 W7 e2 u) Z5 e
// value. This also ensures that a planned motion always completes and accounts for any floating-point
, l+ ~2 r# m- W// round-off errors. Although not recommended, a lower value than 1.0 mm/min will likely work in smaller
( F3 \7 o+ D" c$ q2 U// machines, perhaps to 0.1mm/min, but your success may vary based on multiple factors.
: `; u; L. r8 i//设置计划将允许的最小进给速率。任何价值低于它将被设置为最低值。这也保证了运动计划总是完成,占任何浮点
4 x: a8 k* y% D" }//舍入错误。虽然不推荐,价值低于1.0毫米/分钟可能会在较小的工作
0 e/ `/ ]. P) d0 z3 x//机器,也许到0.1毫米/分钟,但你的成功基于多种因素可能会有所不同。
% E6 u) p% k& C# M$ N4 c) d/ `- V0 n# O3 H0 O' o$ f
#define MINIMUM_FEED_RATE 1.0 // (mm/min)//设置计划将允许的最小进给速率
1 A& s. C- d% W1 Q- ?+ E8 Z, s0 V1 p# J, h2 k
// Number of arc generation iterations by small angle approximation before exact arc trajectory
2 {1 F3 N( ?+ J$ Q; E// correction with expensive sin() and cos() calcualtions. This parameter maybe decreased if there
: G, M( v7 t- n2 U- v; m// are issues with the accuracy of the arc generations, or increased if arc execution is getting
' {( k$ L& X" j' @/ u4 n// bogged down by too many trig calculations.
% j+ n. H  ~9 t/ M1 j//弧生成迭代次数之前小角度近似精确的弧线轨迹$ R1 w2 Q$ E3 W0 d2 b
//修正与昂贵的sin()和cos()calcualtions。如果有这个参数可能减少
0 B/ y7 N4 P) V& K! \2 n: a//与弧一代又一代的准确性问题,或如果电弧执行得到增加+ w- z! \7 d7 [: K& r6 r
//太多的三角计算的泥潭。
# F+ y( A+ I) D
$ c; L0 ?, f9 J#define N_ARC_CORRECTION 12 // Integer (1-255)
; I6 D8 S8 u) L) c  M! X& w/ g; O* d& |8 ?8 d$ N; k
// The arc G2/3 g-code standard is problematic by definition. Radius-based arcs have horrible numerical
% g/ G& P9 D( c) P3 s// errors when arc at semi-circles(pi) or full-circles(2*pi). Offset-based arcs are much more accurate
7 g7 `& R8 s8 K' J% A// but still have a problem when arcs are full-circles (2*pi). This define accounts for the floating
  ?" E' c- \9 k$ m// point issues when offset-based arcs are commanded as full circles, but get interpreted as extremely
+ j8 b9 B' c, w4 h, T// small arcs with around machine epsilon (1.2e-7rad) due to numerical round-off and precision issues.
0 K( C0 d% w1 u1 X// This define value sets the machine epsilon cutoff to determine if the arc is a full-circle or not.
9 W& h2 ?! [$ B+ L// NOTE: Be very careful when adjusting this value. It should always be greater than 1.2e-7 but not too: v, {& z2 s$ C
// much greater than this. The default setting should capture most, if not all, full arc error situations.
# c$ ~% X( P+ g//弧G2/3刀位点的标准定义是有问题的。Radius-based弧有可怕的数值. b3 Q! t& a  m& s; i4 J4 F
//错误当电弧在半圆(π)或原点(2 *π)。Offset-based弧更准确6 ]% K( Q1 f( V, v* p; M* {+ `
//但仍有一个问题当弧原点(2 *π)。这个定义占浮动, l/ e. G4 ?/ N  p' F2 ~" H7 Q" ]$ D
//当offset-based弧吩咐点问题完整的圆,但解释为极
8 t- w' V! S% ^3 u- W//小弧机周围ε(1.2 e-7rad)由于数字舍入和精度问题。
, P1 v8 K3 @0 T0 P//定义值设置机器ε截止来确定电弧是一个原点了。
2 z" ~$ D& h1 w7 f$ Q//注意:调整这个值时非常小心。它应该总是大于1.2 e -但不要太
+ Z! R7 s+ m2 O, Q//比这大得多。默认设置应该捕获大部分,如果不是全部,全部错误的情况。+ o% {# F9 W2 S, a: X5 Y
- N; g$ K5 ?" e
#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)
! Z( [% ]% o6 Q9 F8 b/ w- E
4 ^6 Y% @' R; M( ~4 a  d, E; Y- j// Time delay increments performed during a dwell. The default value is set at 50ms, which provides
! K6 s* E. [$ e// a maximum time delay of roughly 55 minutes, more than enough for most any application. Increasing
& _; H; Q1 F* C8 M4 V( i% s// this delay will increase the maximum dwell time linearly, but also reduces the responsiveness of & S4 Z& t" _' I4 E
// run-time command executions, like status reports, since these are performed between each dwell 8 H6 E/ `$ i) w
// time step. Also, keep in mind that the Arduino delay timer is not very accurate for long delays.& d, y7 ~2 Y* [7 f8 d, ?: |/ z, n/ C
//延时增加表现在住。默认值设置为50毫秒,它提供了
! O  }' |( z4 ?//最大延时约55分钟,足够对大多数任何应用程序。增加- ~. ]- O$ ^! g$ _* ]
//这种延迟将增加线性最大停留时间,也减少了响应能力9 p* S1 I6 J" v( P3 T9 u7 U7 r
//运行命令执行状态报告一样,因为这些每个住之间执行; o  E$ j. K3 {/ e. `8 s5 \
//时间步。还有,记住,Arduino延迟计时器不是很准确的长时间延误。. w5 X1 U3 M' N

4 l( V  y7 G( [& V- o% }% l#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds)
+ J" b* n1 G$ e+ t% V% v2 H' q) S+ J4 {3 O( B# u+ W' C
// Creates a delay between the direction pin setting and corresponding step pulse by creating
* W$ c/ f* c5 ^0 Y8 b9 V// another interrupt (Timer2 compare) to manage it. The main Grbl interrupt (Timer1 compare)
4 U' p4 ]" m, ^1 h// sets the direction pins, and does not immediately set the stepper pins, as it would in
! a" O' |+ U; U// normal operation. The Timer2 compare fires next to set the stepper pins after the step
3 v- R! P! ^/ _; {0 t// pulse delay time, and Timer2 overflow will complete the step pulse, except now delayed
8 c6 X! R, q: H& k// by the step pulse time plus the step pulse delay. (Thanks langwadt for the idea!)
- N; {1 c2 g1 p& c* o4 g// NOTE: Uncomment to enable. The recommended delay must be > 3us, and, when added with the1 C+ z3 h( ]" G
// user-supplied step pulse time, the total time must not exceed 127us. Reported successful
( q0 O( v, U& g$ o. N// values for certain setups have ranged from 5 to 20us.3 E. O- q4 T: L5 G6 F8 p8 k, J) P
//创建一个方向销之间的延迟脉冲通过创建设置和相应的步骤3 S; R0 d7 P2 Q' [5 |! C
//另一个中断(Timer2比较)来管理它。主要Grbl中断(Timer1比较)
* a% T( L/ O; H, G$ J% P//设置方向针,不立即设置步进针,因为它会在+ m4 O% F5 q4 Q7 k, K
//正常操作。Timer2比较火旁边设置步进针后一步
& t3 g) N; D+ ?) s0 L//脉冲延迟时间,Timer2溢出脉冲将完成的步骤,现在延迟除外
  e2 e) u6 i% T+ c2 S) y+ ~% n//脉冲时间加上的一步一步脉冲延迟。(感谢langwadt主意!)2 B. i3 P+ w5 v. h. \  q- b" G
//注意:取消启用。必须> 3,建议延迟,当添加的
2 p% ~" Z4 P$ _# e2 I' [//用户提供的步骤脉冲时间,总时间不得超过127美元。成功的报道9 G6 O. ]; T# x' Z5 \; D* h) d4 x
//值对某些设置范围从5到20。
& a: [. S0 F& l+ b% H9 t6 I# T  }: I8 H% G
// #define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.4 N) g$ A! B( Q9 R$ a( p

* F. b! `& C6 j# ], f// The number of linear motions in the planner buffer to be planned at any give time. The vast
- L7 d+ @+ |' Q# ]// majority of RAM that Grbl uses is based on this buffer size. Only increase if there is extra
+ o  x: U  x' q3 u// available RAM, like when re-compiling for a Mega or Sanguino. Or decrease if the Arduino
! c: h  O0 K# z) b3 `' d6 f// begins to crash due to the lack of available RAM or if the CPU is having trouble keeping1 F2 b: m+ h0 v9 g
// up with planning new incoming motions as they are executed.
2 T+ ?" A2 F8 ]" |; b; q* d2 V//线性运动规划师缓冲区的数量在任何给出时间计划。绝大
3 d. \+ w/ A1 H! f4 l% C  ^//多数RAM Grbl使用基于这个缓冲区的大小。如果有额外的只会增加- v$ ]) A$ h2 Z% w6 a$ P* |
//可用内存,比如当基于大型或Sanguino。如果Arduino或减少$ e5 ?2 v/ p0 \4 e; Q, V5 e- j
//开始崩溃由于缺乏可用的RAM或者CPU是难以保持
3 D1 U* _3 h8 U/ G& @//与规划新传入的动作执行。
% r' h4 R( w$ e8 s! Z) A9 i" D, |3 i' \9 G" z( s0 h& w6 I: N
// #define BLOCK_BUFFER_SIZE 18  // Uncomment to override default in planner.h.
( P* m7 t! W* y" ]; ?, E, l% ]; b% s- u4 Q: z; i4 n
// Governs the size of the intermediary step segment buffer between the step execution algorithm& ^2 h9 _. a5 _' {/ D& G
// and the planner blocks. Each segment is set of steps executed at a constant velocity over a
5 r1 Q6 V- ?1 v2 y8 U/ [$ R// fixed time defined by ACCELERATION_TICKS_PER_SECOND. They are computed such that the planner1 j; n4 p5 g- c
// block velocity profile is traced exactly. The size of this buffer governs how much step ! T& `$ q  _% m1 k( `
// execution lead time there is for other Grbl processes have to compute and do their thing 7 V+ ~* K* b8 z) S
// before having to come back and refill this buffer, currently at ~50msec of step moves.
! x' S1 I2 t4 a( ?1 v//控制之间的中间段缓冲大小的步骤执行算法  @2 }/ T* r# {. P: a8 z7 a
//和规划师块。每一部分的步骤执行在一个恒定的速度
  R; [$ s. J$ m7 w//固定的时间由ACCELERATION_TICKS_PER_SECOND定义的。他们计算的计划
( v& U3 M) i& ^& d//块速度剖面追踪到底。这个缓冲区的大小控制多少步骤
& X2 `( \! D/ @. ?7 I//执行时间有其他Grbl过程需要计算和做他们的事情+ B$ v" u# t# Z* n
//之前必须回来重新填充这个缓冲区,目前移动~ 50毫秒的一步。
: v  S$ {1 M% [, U7 a; _; E4 N) h/ P' Z! M4 R
// #define SEGMENT_BUFFER_SIZE 6 // Uncomment to override default in stepper.h.
1 P& z4 d( B4 v2 I& x
! W& j3 e, e" r  Y// Line buffer size from the serial input stream to be executed. Also, governs the size of : z" P2 p" z* k0 ?0 E8 P
// each of the startup blocks, as they are each stored as a string of this size. Make sure
' n: n' i( c6 `) {. |// to account for the available EEPROM at the defined memory address in settings.h and for7 p" M6 u+ {9 j1 P& Y$ e' p" o! r
// the number of desired startup blocks.
' C# w! C# h. {. f// NOTE: 80 characters is not a problem except for extreme cases, but the line buffer size & @/ L" f  K& @  m) c' t& `& J
// can be too small and g-code blocks can get truncated. Officially, the g-code standards 2 T0 E6 _; A2 l9 V; |* k6 |% p1 t
// support up to 256 characters. In future versions, this default will be increased, when
6 p/ B% D. @- E5 n8 {- Z' S, A// we know how much extra memory space we can re-invest into this.
# E1 Z5 N: V5 |0 G: H//行执行串行输入流的缓冲区大小。同时,大小的控制
7 ~) H) z% G9 X( p( |; j/ o' m$ p  \4 W//每个启动模块,它们分别存储为字符串的大小。确保- l% O5 w& o2 O3 @5 G/ f
//占可用eepm定义内存地址的设置。h和5 R0 Z6 x: b/ W4 @) }# Y- `1 ^3 a
//需要启动块的数量。  I, G( l! P& Q1 t. `: |
//注意:80个字符不是一个问题,除了极端的情况下,但线缓冲区大小( H2 J/ N( y9 E
//可以太小和刀位点块可以截断。正式,刀位点标准! _% E: T7 v4 U1 T2 n
//支持多达256个字符。在未来的版本中,这个违约将会增加,当
) j$ @( U4 t0 [//我们知道多少额外内存空间的时候我们可以再投资。
% o4 D- O* M9 [& l: A' X
7 b1 y/ F( ~+ A+ y# ~// #define LINE_BUFFER_SIZE 80  // Uncomment to override default in protocol.h( p: m' _* L/ V  m
  , H7 `7 n" h, u' C# P$ ^3 b
// Serial send and receive buffer size. The receive buffer is often used as another streaming) [! }* J) u: f4 y8 b! a$ j& i
// buffer to store incoming blocks to be processed by Grbl when its ready. Most streaming
- X1 F/ Q& N7 n$ N2 ?7 H2 u  D2 K// interfaces will character count and track each block send to each block response. So,
& [2 h% |7 |5 A: \3 w$ _// increase the receive buffer if a deeper receive buffer is needed for streaming and avaiable7 x" h- ~4 }9 \6 }" }
// memory allows. The send buffer primarily handles messages in Grbl. Only increase if large
+ }# B% Z8 m$ c4 I5 t) {" N0 V// messages are sent and Grbl begins to stall, waiting to send the rest of the message.
# ~* `' p4 f# F- j. c0 G5 b) y// NOTE: Buffer size values must be greater than zero and less than 256.- D& F, t! E+ {" G9 f6 K
// #define RX_BUFFER_SIZE 128 // Uncomment to override defaults in serial.h
) k% v; s+ M. O: `//串行发送和接收缓冲区大小。接收缓冲区通常用作另一个流0 S. ?) e$ S0 j: Z. j# |3 K3 t
//缓冲存储传入的块来处理Grbl当它准备好了。最流( m& G9 \3 S4 ~8 m) S# j
//接口将字符计数和跟踪每一块发送给每个块的回应。所以,
8 F8 H% H( l" {9 z, m) N/ l//增加接收缓冲区如果需要更深层次的接收缓冲区为流,、
! j1 o9 [. R- M* B3 u5 E//内存允许。Grbl发送缓冲主要处理消息。只会增加如果大
( {3 \% S) [( U, J$ t//消息发送和Grbl开始停滞,等待发送其余的消息。( y) D- [6 E/ b
//注意:缓冲区大小值必须大于零,小于256。
% K! @) b4 X, B4 t& Q. q2 v& y// # define RX_BUFFER_SIZE 128 / /取消serial.h覆盖默认值  A9 \$ y# l  e5 S9 r

2 J& P" @$ W& I( ?8 v
5 f; h5 N6 k0 x9 {# U5 e5 h// #define TX_BUFFER_SIZE 64
9 X( D; b4 N: k  
2 [: ?: X8 u9 C5 z: ~+ {6 Q4 j& r// Toggles XON/XOFF software flow control for serial communications. Not officially supported( J: G5 H6 h! }$ v; R% X0 R+ x
// due to problems involving the Atmega8U2 USB-to-serial chips on current Arduinos. The firmware9 R$ V( ~- I: @0 @
// on these chips do not support XON/XOFF flow control characters and the intermediate buffer ' p6 C- ?2 x% L  M! @2 ?2 g# ^
// in the chips cause latency and overflow problems with standard terminal programs. However,
( P% i1 Q0 D1 \- J// using specifically-programmed UI's to manage this latency problem has been confirmed to work.9 O1 b0 Z7 V8 [- G
// As well as, older FTDI FT232RL-based Arduinos(Duemilanove) are known to work with standard
$ W9 u( I% v6 G2 K// terminal programs since their firmware correctly manage these XON/XOFF characters. In any2 f1 `. B/ F; b( ^. |# p
// case, please report any successes to grbl administrators!3 E8 L* b6 N+ K( B
//切换为串行通信发送朴通/发送葡开软件流控制。不是官方支持* y7 a: I' v% }0 B* ?
//由于问题涉及Atmega8U2 USB-to-serial当前arduino芯片。固件
# c0 i- f/ L, _  j3 z//在这些芯片不支持发送朴通/发送葡开流控制字符和中间缓冲区- P" z% }% E) n  I7 f- `
//芯片导致延迟和溢出问题的标准终端程序。然而,- S( j7 S' C4 T* a6 Q! _( `
//使用specifically-programmed UI的管理这个延迟问题已经确认工作。8 n- E6 p2 O5 |  _+ {- |
//以及老FTDI FT232RL-based arduino(Duemilanove)是已知的标准
# N: \. B. A" y0 n7 s" S+ h//终端程序因为他们正确的固件管理这些发送朴通/发送葡开的角色。在任何, ?9 b3 Q( E( \- C/ b
//情况,请报告任何成功grbl管理员!$ m* R0 ]1 k- z7 V7 [
% Y" ~8 |1 s0 e8 o2 I
// #define ENABLE_XONXOFF // Default disabled. Uncomment to enable.
+ s7 X; U2 h5 g0 A0 P: ?- h% r9 b5 @' Z3 i2 `& u7 _; K
// A simple software debouncing feature for hard limit switches. When enabled, the interrupt
' Q, [3 C3 X: ?. c// monitoring the hard limit switch pins will enable the Arduino's watchdog timer to re-check ; h5 E$ v* f0 U  o$ T  L+ q; X- |
// the limit pin state after a delay of about 32msec. This can help with CNC machines with , o; X. \& x! ?2 w& F1 j
// problematic false triggering of their hard limit switches, but it WILL NOT fix issues with 9 b' D! j0 ]; v2 e/ ?! ~
// electrical interference on the signal cables from external sources. It's recommended to first+ `. C# L0 ?3 B' Y! d6 F
// use shielded signal cables with their shielding connected to ground (old USB/computer cables % ~4 D0 {, }& L' C0 v( ?. R$ y  S; x
// work well and are cheap to find) and wire in a low-pass circuit into each limit pin.% S6 a* E8 J7 B' N( g9 k: b
//一个简单的软件消除抖动特性硬限位开关。当启用时,中断) S3 T7 a( g. W$ I
//监控硬限位开关针将使Arduino的看门狗定时器重新审视2 N0 D1 W- F3 y" k: x
//销的极限状态后约32毫秒的延迟。这可以帮助与数控机器
6 X% a. a" ]$ D2 W% K" N//问题错误引发的硬限位开关,但是它不会解决问题5 P, E% A: g. T8 x- i2 P
//电干扰信号电缆从外部来源。首先它的建议0 ~' w/ R- Y( T8 S! a
//使用屏蔽信号电缆的屏蔽连接到地面(老USB /计算机电缆
0 V; q6 F5 e( L' m( F6 n//工作得很好,很便宜)和线低通电路到每个限位销。
) B# _. C) {0 G, F( b1 z* V$ J+ Z  z) N; I0 R1 h
// #define ENABLE_SOFTWARE_DEBOUNCE // Default disabled. Uncomment to enable.
/ b$ o  T3 c2 q! L  @: B8 U2 W8 z3 ~" s# h
// Force Grbl to check the state of the hard limit switches when the processor detects a pin
$ _8 `# y( u/ `# O* ^& U6 p// change inside the hard limit ISR routine. By default, Grbl will trigger the hard limits
* g( }, x) I) ]// alarm upon any pin change, since bouncing switches can cause a state check like this to
% G( h  L9 k7 z/ U6 b$ f; K// misread the pin. When hard limits are triggered, they should be 100% reliable, which is the7 `: N+ W7 _/ Y5 ?2 D2 G3 r
// reason that this option is disabled by default. Only if your system/electronics can guarantee  c' n) s1 h  b3 [9 @
// that the switches don't bounce, we recommend enabling this option. This will help prevent
, o( \/ j# |" |, i// triggering a hard limit when the machine disengages from the switch.
% |8 x5 \5 B( j8 k// NOTE: This option has no effect if SOFTWARE_DEBOUNCE is enabled.
; I" n+ e) f; B, |! G//力Grbl检查硬限位开关的状态,当处理器检测到一个销5 J/ n1 Y. n5 N. q' N) b7 @$ h
//改变内部硬限制ISR例行公事。默认情况下,Grbl将触发硬限制. U: p/ k3 @/ f) ]% j- q* u
//报警在任何销更改,因为跳开关可以导致这样的状态检查. W$ V; o% }$ L' _& c: N
//误读了销。硬限制触发时,他们应该100%可靠,这是
# E" ^8 {1 G7 y//原因,这个选项默认是禁用的。只有在你的系统/电子产品可以保证
) n, C3 t" D  H# E//开关不反弹,我们建议启用这个选项。这将有助于防止- v" F; O* W4 Y; x; e
//触发机退出时硬限制开关。
- {1 ^  [! _# W- B( R9 ^//注意:这个选项如果启用了SOFTWARE_DEBOUNCE没有影响。
( q$ ]/ D/ @) F  ?# T: D" _, t
4 k- m/ A; O6 [' Q$ H3 i+ s// #define HARD_LIMIT_FORCE_STATE_CHECK // Default disabled. Uncomment to enable.
0 A" S, r7 T- r* _8 V! H% _% n2 X8 i$ U( o

- N& n: d; p0 S! V// ---------------------------------------------------------------------------------------
, F( C4 F% P- X' s) n$ L// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:编译时错误检查的定义值:. W; W: j% {' L( ^8 N6 m# M
$ ~$ v- _- Q+ z: k# r8 C7 l
#ifndef HOMING_CYCLE_0
: N5 I' O  k! ~& |+ j1 _4 E  o  #error "Required HOMING_CYCLE_0 not defined."
% _" \- f4 y) c+ D) g#endif) f# Z  Q) R; P# @+ g

; F8 z% A; w0 V+ W#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(VARIABLE_SPINDLE)+ S$ }: R) ]; o* `8 n0 o
  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with VARIABLE_SPINDLE enabled"
( h6 L. r! X" r#endif2 {% Q* m: c% p$ }+ f6 _3 J

5 T1 E4 {" V7 ^4 _#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(CPU_MAP_ATMEGA328P)- i. y% w8 N/ v4 o8 E' u! Q+ E
  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with a 328p processor"" s+ Z! a5 X: L
#endif# s( w* U- g" C6 E! s: b8 s

% _& I7 P$ l( _- W& }// ---------------------------------------------------------------------------------------
! i+ J3 d) M% A; m
( j" |3 u3 k) R7 z9 B1 o6 r9 X8 f2 O6 }4 E* W' O! i; C" T5 q9 t
#endif
8 Z  i1 T: {( ~
3 `# I. J  k: g% J: ?" O4 U  b  M" Q0 q% h1 H# E5 [

" i! E) m9 R0 |2 y& ~- H4 y
5 [& F( ?9 U% o! k+ {8 |& f# M5 S% `- q5 m  W' `
8 ]: d2 {1 `( ~7 U

! s$ J) ~) {: U* I7 b. i; }* S- D
) [, w) J5 B4 F; f2 N$ L4 J; b) p7 S' S& O8 X! N& ~  p

. v9 E- o5 i: M9 c0 u: d7 x
) _" L- E. r4 _8 H; u+ H/ P: i/ w) ]$ h  w$ z

9 i/ z. P3 Q; {* V
- p& C" `; a! X, q% G3 m) Z! J6 O& G0 ]
$ J4 s% p2 q  ]! G

本帖子中包含更多资源

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

x

评分

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

查看全部评分

回复

使用道具 举报

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

使用道具 举报

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

" S0 D% ^$ S, ~) M! l9 q
回复 支持 反对

使用道具 举报

发表于 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 | 显示全部楼层
补充  O4 \4 P( ~, Y5 e1 |
程序运行protocol_execute_realtime(); /运行实时命令。
3 R/ E  C$ d4 H2 ?9 E// Executes run-time commands, when required. This is called from various check points in the main2 N0 _8 }6 o3 b' K9 L3 a4 Y! i
// program, primarily where there may be a while loop waiting for a buffer to clear space or any% O9 R  h2 D! Y
// point where the execution time from the last check point may be more than a fraction of a second.
$ @1 K: ?$ h. N  Q5 U* {// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code0 s5 I0 @" @" T1 K( i; w& q+ O
// parsing and planning functions. This function also serves as an interface for the interrupts to " v: O, ~3 V/ o; Y9 i
// set the system realtime flags, where only the main program handles them, removing the need to. p, C9 ?7 d# I6 y4 Y4 M3 x. a
// define more computationally-expensive volatile variables. This also provides a controlled way to
" X! i9 O; n* R8 k% I$ r- k" ]// execute certain tasks without having two or more instances of the same task, such as the planner
8 ~; y% \& r% {// recalculating the buffer upon a feedhold or override.' d, K/ [/ u% f$ n6 {. T( s
// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,
- J' b0 Y& ~; r: \5 x// limit switches, or the main program., Q8 F. Y) b/ y& v+ k8 I( E5 N
  v7 X: U0 z6 D( x  J; d+ V6 u
//执行运行时间命令,在需要时。这就是所谓的从各种主程序要检查站. K8 W7 ^* q6 F5 O5 B0 q
//,主要是那里可能是一个while循环等待缓冲区空间或任何
# q, I) M; ~: G0 S8 f( i' h0 |//执行时间从过去的止点可以超过几分之一秒。% ]0 j9 R: Q  R. B) R0 Q1 k0 p7 s" x
//这是一种异步执行实时命令(又名多任务)grbl的刀位点
  s4 {$ Q! I4 z1 i$ \//解析和规划功能。这个函数也可以作为一个接口,用于中断" w. s2 {* j& z0 x# [
//设置系统实时的旗帜,只有主程序处理,消除的需要" n. Q5 ?: i7 e# _$ X  D
//定义更多的计算昂贵volatile变量。这也提供了一种控制方法* r* O! W- E0 d# ]2 Y
//执行某些任务不相同的两个或多个实例的任务,比如计划* W3 l' ^* x4 _' r$ k% u
//重新计算缓冲feedhold或覆盖。; u& t' ^! h% h( T( I
//注意:sys_rt_exec_state变量标志设置任何过程,步骤或串行中断,插脚引线,
' Z+ m3 A0 n, O/ }$ h//限位开关或主程序。
! Z. `. ]' w; i$ Uvoid protocol_execute_realtime()2 Y3 Z8 D* G' i( k% G. Y
{
; @. W' t- ]! x( ~5 \7 i        // Temp variable to avoid calling volatile multiple times.- v" z3 M* f, H* |: P% X
        // 临时变量来避免多次调用不稳定。1 N. h0 A% ~. K! y  U1 O9 \: k) j
        uint8_t rt_exec;
3 q. p( g5 d3 J' q5 b- U$ I        do{4 |/ }8 N" e" c3 d
          if (rt_exec) {                 // 有标志位置位进入* f! `  t# d- o5 E
        ; Q4 J0 K' [8 E; h0 {; p" I
            sys.state = STATE_ALARM; // 设置系统为报警状态
; f7 [6 R- @4 T1 t# s7 B8 M      report_alarm_message(ALARM_HARD_LIMIT_ERROR);        //报告报警信息为接近极限值
1 _2 B9 _/ G+ S- n    } else if (rt_exec & EXEC_ALARM_SOFT_LIMIT) {                        //报告执行软件限位报警8 X5 Q$ C1 p: q$ w' H$ i, j4 C$ s
      report_alarm_message(ALARM_SOFT_LIMIT_ERROR);        //报告出现软件限位报警
3 Q/ ^) s: c- l9 ^, d6 T    } else if (rt_exec & EXEC_ALARM_ABORT_CYCLE) {                //执行停止循环报警      8 a( d, {  @  a) K
      report_alarm_message(ALARM_ABORT_CYCLE);                //出现终止循环报警) D0 J, Q4 |# s" `. w+ z8 ^- w; l
    } else if (rt_exec & EXEC_ALARM_PROBE_FAIL) {                        //执行探查失败报警
$ Z( a  A. n" p, W      report_alarm_message(ALARM_PROBE_FAIL);                        //出现探查失败报警4 z$ H8 `5 a' X4 C9 O
    } else if (rt_exec & EXEC_ALARM_HOMING_FAIL) {                //执行返回原点失败报警3 G: \$ y$ E+ ?/ V) s
      report_alarm_message(ALARM_HOMING_FAIL);                //出现返回原点失败报警
' ~! K9 Y5 R" Z& ?    }
% P- h; U1 L# l* _0 @" S; a: S8 D' O0 w' K
    // Halt everything upon a critical event flag. Currently hard and soft limits flag this.
$ J2 r  T! o; Q! H3 P    // 停止一切在一个关键事件标志。目前硬和软限制标志
. a2 S, N5 g  K1 M: T           if (rt_exec & EXEC_CRITICAL_EVENT) {                //如果系统是循环事件进入
; j( f9 ?2 x: A) ]; |/ k* P3 v             report_feedback_message(MESSAGE_CRITICAL_EVENT);        //报告反馈信息5 Z+ u7 b3 S3 E2 l, p/ _4 r
              bit_false_atomic(sys_rt_exec_state,EXEC_RESET);                         //清除目前的复位状态
  l- r  S' T( e/ z4 V  I8 o! C% x) M
: f' N3 Y9 q1 j$ I  q        bit_false_atomic(sys_rt_exec_alarm,0xFF);                                 // 清除所有报警标志
, O9 w5 E9 I& x+ X+ D# U5 a        }        * W' i( p8 }. |% D9 Q) A4 g7 c  j; I1 @

1 s: e6 b+ v  P' T上面代码将rt_exec = sys_rt_exec_alarm ,如果rt_exec为真,打印不同报警信息: {" }3 P# p! U- e: h# B2 ^
和限位保护信息,然后清除报警状态, D+ T( a0 n8 B# ?, m
___________________________________________________________________________
. R/ E$ z6 j' B没有报警进行执行下面代码,执行了终止命令,串口打印命令" \% h9 k$ J+ U. q- O4 g
        // Check amd execute realtime commands        校验和执行实时命令
+ F. d' X  F! ^          rt_exec = sys_rt_exec_state; // Copy volatile sys_rt_exec_state$ r/ h6 v* P) {6 S6 O* B! I

" W8 _  P8 P6 b5 K5 D9 F        if (rt_exec) { // 输入标志是正确的执行
# {2 J- p$ ?) {0 E8 N2 F
1 p* ]. Z6 Y' P. e            // Execute system abort. 执行系统终止命令
. K# `) X8 q+ O8 V; I2 D( @            if (rt_exec & EXEC_RESET) {
- h5 F  K- k  E+ S              sys.abort = true;  // Only place this is set true.
8 R5 I5 H5 t9 K& h* `7 I! }. q              return; // Nothing else to do but exit.6 Q' P* ~) R# |+ t2 x- e
        }: [5 ~0 I, ~  A6 k( s
7 D. R7 s2 A! i/ w+ R- B
            // Execute and serial print status 执行和串口打印状态
& D# l- }5 j+ H+ m            if (rt_exec & EXEC_STATUS_REPORT) {
" M6 x7 S1 K2 b( y& |              report_realtime_status();        //报告实时状态5 ~) Z! O' ^5 O9 O/ \+ ?) {1 C
              bit_false_atomic(sys_rt_exec_state,EXEC_STATUS_REPORT);        //清除报告状态清零5 ]4 w% @' i( K' S4 i6 i
            }
/ L% e' l7 i; d6 U4 b% [3 a_____________________________________________________________________________
" T2 K( W2 G* _5 S" d4 |下面代码7 x8 v# A9 z8 D) s9 e8 t
//执行状态。: M5 B, N! {( u& {/ ^
//注意:所涉及的数学计算持有应该足够低对大多数人来说,即使不是全部,
# L5 e. z" S! W% N7 ~: t1 @$ ]//操作场景。一旦启动,系统进入暂停状态
6 ~8 f, i) P6 q! }6 B" F' V//主程序流程,直到重置或恢复。
' x5 @- D0 N- r% i- L( F' Z9 U待办事项:检查模式?如何处理呢?可能没有,因为它只会在空闲,然后重置Grbl。
; F6 C; d* W$ p. q+ @状态检查容许状态的方法。
5 o. K$ e1 Y- a. v
+ f! ^7 x, m( {3 y        //如果全局各自报警标志位其中(执行取消动作) | (执行进给保持) | (执行安全门)任意一位为真进入
, z# d  ^0 C8 U, b' N. \3 E( K            if (rt_exec & (EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR)) {       
' Z9 y/ _9 I! c2 K0 @  d" D* e) V
        //如果是循环状态执行暂停状态
, v0 a6 h* H- L2 Z        if (sys.state == STATE_CYCLE) {
/ u" I0 S* {7 x2 z- u4 f1 z        st_update_plan_block_parameters(); //通知stepper module验算减速。
9 Z: b( _5 L+ n  q# p- g, m& G        sys.suspend = SUSPEND_ENABLE_HOLD; // 开始暂停标志
  j7 l3 C( p* p* `2 C        }
# r$ _2 v& {4 Y) C% k) P# ]
' i& l4 q9 v* v% f6 y5 S7 T5 C        // 如果,Grbl空闲不在运动。简单的指示暂停就绪状态。
/ Y- k! k% r! O5 `        if (sys.state == STATE_IDLE) { sys.suspend = SUSPEND_ENABLE_READY; }2 Q  _& t4 u6 J: S) s- d! |. X

/ n9 Z- ?6 ~4 X" k
; E' b# I: M* @! o1 o9 k        //执行和标志和减速运动取消并返回空闲。主要由探测使用周期
3 ]7 b8 r7 Z3 P7 d7 s  S& x- o) l1 X        //停止和取消剩余的运动。      
: t: s& n$ y% q! i+ t4 V  k; H        if (rt_exec & EXEC_MOTION_CANCEL) {, P5 \) E4 b5 e1 U8 A
          if (sys.state == STATE_CYCLE) { sys.state = STATE_MOTION_CANCEL; }* Q1 {' c  g$ C1 @! j
          sys.suspend |= SUSPEND_MOTION_CANCEL;   p- n3 X1 D1 Z
        }
6 q- O- ?. C, G, [8 G7 l9 ?
, W: D% P' F0 E7 q. x8 W2 v6 T        // 只在循环时执行进给保持减速
2 v4 ?0 l: Z$ ]6 ]/ q5 a         if (rt_exec & EXEC_FEED_HOLD) {- W1 `+ c" K5 c
        //只有安全门为1才执行保持进给状态赋值- A5 Q. |: W5 L) i8 c
          if (bit_isfalse(sys.state,STATE_SAFETY_DOOR)) { sys.state = STATE_HOLD; }
! f1 _% k3 N: D2 b$ j* k) C9 i        }2 E* ?9 ]+ q7 \9 V
$ o; N, R( ^8 U  b  X, g
        if (rt_exec & EXEC_SAFETY_DOOR) {
5 ]9 q6 ^$ w* H          report_feedback_message(MESSAGE_SAFETY_DOOR_AJAR);
. `% K1 `* c4 W" ~/ /如果已经活跃,准备好重新开始,CYCLE_STOP标志设置为强制断开。+ o! y# e7 w8 K
/ /注意:只是暂时设置“rt_exec”变量,不是动荡的“rt_exec_state”变量。6 p( T3 `: _! |4 R1 X
          if (sys.suspend & SUSPEND_ENABLE_READY) { bit_true(rt_exec,EXEC_CYCLE_STOP); }& D8 [7 ?7 Z% K: s% a) Q
          sys.suspend |= SUSPEND_ENERGIZE;
1 q1 ?, D# ^  G0 [; D3 ^: \          sys.state = STATE_SAFETY_DOOR;
+ o# t3 f1 f3 @8 ]; Q6 E% i' {        }# p& S8 A9 G" x: y1 ]& L  G# m
% u; L/ ~: M4 O; s( C
bit_false_atomic(sys_rt_exec_state,(EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR));   
  x2 A( _0 _5 ?) \2 n5 [8 x  p; h& w" G  _) b
}2 G: R, F9 ^4 O1 h9 A5 S
以上代码执行了% e4 ?+ C# C* T7 o3 ^! o
1.如果全局各自报警标志位其中(执行取消动作) | (执行进给保持) | (执行安全门)任意一位为真进入% Z3 }& I9 c& R
2.系统为闲着状态, 开始循环状态, 回原点状态, 控制取消状态, 开始保持状态, 开始安全门状态时进入" p! R0 m: T+ I
3.如果是循环状态执行暂停状态& \) t( }$ J) z7 i5 w
4.如果系统闲置状态执行暂停就绪状态
: C) u" z. s) ~+ E8 g+ b/ r$ N% ~5.执行动作取消# {' }1 S$ p) S  ^5 P' ^
6.如果是保持进给状态,执行保持进给状态
4 ~- X. W- [4 U0 U% [. Q' \7.执行安全门状态( L% U; o& i1 J3 R1 \: {8 |
最后执行bit_false_atomic清标志清除(执行取消动作)(执行进给保持)(执行安全门)标志位                  / a& z2 O* G1 y- E3 ?( _
_____________________________________________________________________________
% ~' y  a- R1 s1 {5 c7 z2 R7 r5 q4 T  \
    // Execute a cycle start by starting the stepper interrupt to begin executing the blocks in queue.
2 ?2 d0 F* t2 \! `: [    // 执行一个循环开始启动步进开始执行中断队列的街区1 O& j+ {$ p# e( k
    if (rt_exec & EXEC_CYCLE_START) {        //循环开始状态进入# c- H5 s& S) ^2 @9 m& K
      // Block if called at same time as the hold commands: feed hold, motion cancel, and safety door.
4 z: u  m& a- p" \/ ]) O! c      // Ensures auto-cycle-start doesn't resume a hold without an explicit user-input.
' o$ R4 V6 f" c7 X          //块如果在同时举行的命令:保持进给,运动取消,和安全的门。 //确保auto-cycle-start没有简历没有显式的用户输入。0 T1 g. K) {) d
          
/ m/ J, D9 P0 y/ c' y, p      if (!(rt_exec & (EXEC_FEED_HOLD | EXEC_MOTION_CANCEL | EXEC_SAFETY_DOOR))) {   //状态机如果不是保持进给,运动取消,和安全的门。 6 C3 w: b& R* |0 [; O' J! k' u
        // Cycle start only when IDLE or when a hold is complete and ready to resume.+ w7 E+ n) `1 f4 ?
        // NOTE: SAFETY_DOOR is implicitly blocked. It reverts to HOLD when the door is closed.
5 A, [/ J7 y$ T' |4 X. O                //循环开始时只有当闲置或持有完成并准备简历。0 U: q" m( e5 e. l
                //注意:SAFETY_DOOR是隐式地屏蔽。它返回的时候门是关闭的。   
$ b8 j2 v& L* }1 R+ C) n3 S5 g6 h. s4 i8 p2 O( `
                // 如果系统状态为闲着状态,系统状态为开始进给或运动取消,暂停标志为位重新开始
0 E( ^0 k3 e7 R5 Z        if ((sys.state == STATE_IDLE) || ((sys.state & (STATE_HOLD | STATE_MOTION_CANCEL)) && (sys.suspend & SUSPEND_ENABLE_READY))) {
8 y4 a# A- e' M$ \3 [          // Re-energize powered components, if disabled by SAFETY_DOOR.
9 T& [  c. B4 t& i- u% U* Z& \7 K. i          //        由SAFETY_DOOR重振组件供电,如果禁用。  V! T9 _1 N) U) v% d% C  V
          if (sys.suspend & SUSPEND_ENERGIZE) { / E1 @( g2 g3 {; S
            // Delayed Tasks: Restart spindle and coolant, delay to power-up, then resume cycle.
4 d0 r. Z0 k1 S% b            //延迟任务:重新启动主轴和冷却剂,延迟升高,然后恢复周期。- C; }- r. Y5 t& n% m
            if (gc_state.modal.spindle != SPINDLE_DISABLE) {   //主轴模式不是失能进入
" I# h+ Q8 S. ~; x/ a7 X              spindle_set_state(gc_state.modal.spindle, gc_state.spindle_speed); //设置状态和速度
, u) j6 q( E. u, C) T              //待办事项:阻塞函数调用。最终需要一个非阻塞。
+ c6 ]! i3 o/ ^" R" _                delay_ms(SAFETY_DOOR_SPINDLE_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.& O! n* M+ R8 |8 u4 W
            }' u2 F" G! v$ P; V( p& v
            if (gc_state.modal.coolant != COOLANT_DISABLE) {   _$ U) V" u3 c$ Z( o; z7 [) U8 I
              coolant_set_state(gc_state.modal.coolant);
: h$ y2 S' a2 M; \0 Q) W              delay_ms(SAFETY_DOOR_COOLANT_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.
& P* w0 X/ B9 ?            }
# g; M8 j) F' ]: z; |/ W            // TODO: Install return to pre-park position.
5 B8 f8 V9 \$ Q- n) V          }$ |$ q) j4 n$ r; b, z5 [$ f' ^
______________________________________________________________________________________________________________; x6 m. e, U* `& i3 p0 w7 h
          // Start cycle only if queued motions exist in planner buffer and the motion is not canceled., _/ ?9 r% |2 }. r, D
                  % v$ k1 S, V) h* \5 r
                  //只有在队列马达存在规定的缓冲,并且动机没有让取消,才会循环
6 O  `8 t) S2 y* C% g3 m  a. M                  
( F* o+ ?- _7 L          if (plan_get_current_block() && bit_isfalse(sys.suspend,SUSPEND_MOTION_CANCEL)) {$ F! \0 n8 l6 K. x+ b
            sys.state = STATE_CYCLE;8 T+ i3 p  z5 N4 Z
            st_prep_buffer(); // Initialize step segment buffer before beginning cycle.初始化步开始循环之前4 Y" N3 ?2 T& @* K% N) ]
            st_wake_up();
4 L$ R0 ~6 v9 s1 Y# q          } else { // Otherwise, do nothing. Set and resume IDLE state.否则,什么也不做,设置和复位空闲模式7 M# g: [% x9 P
            sys.state = STATE_IDLE;/ b; c$ T: F' {5 \2 u1 W
          }, d- b3 T0 H2 f! X% D5 |" B+ s
          sys.suspend = SUSPEND_DISABLE; // Break suspend state.
! E6 s+ T" D! u7 N' ?        }% z+ H5 v( a& Y3 C4 `$ i
      }    . p$ y. M/ O$ K) X+ j7 @, _0 D3 z4 t
      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_START);       
; Y; q7 e0 W$ r. J3 O    }
( \  d8 S# f" c% Y4 Z! _6 |) h! v3 ^% A
_______________________________________________________________________________________________________
6 p6 r- _  l  \6 C3 A* [    // Reinitializes the cycle plan and stepper system after a feed hold for a resume. Called by - Y! B' d+ _0 C& j
    // realtime command execution in the main program, ensuring that the planner re-plans safely.  ^: {0 c0 L7 D
    // NOTE: Bresenham algorithm variables are still maintained through both the planner and stepper- o" C# z' [0 q  Z3 c
    // cycle reinitializations. The stepper path should continue exactly as if nothing has happened.   8 f# q7 h9 u, F
    // NOTE: EXEC_CYCLE_STOP is set by the stepper subsystem when a cycle or feed hold completes.
3 q$ v+ E# V; f
% d& i7 f4 @  g) Q' S        //重新启动后循环计划和步进系统的进给保持简历。通过实时命令执行主程序,确保安全计划重新计划。
( Q5 k! L2 p& x! l1 E5 }9 s        //注意:画线算法变量仍保持通过规划师和步进
( B* N8 Q& N; [; P/ P# t        //循环仅。步进路径应该继续,好像什么都没发生一样。       
  T: }) R' ^" n( v& r' \3 m% {  P- O        //注意:EXEC_CYCLE_STOP由步进子系统周期或进给保持时完成。& S+ m& I" |) Z# `% n
6 |% I; p5 n9 g7 ~- Q
    if (rt_exec & EXEC_CYCLE_STOP) {                         //如果是循环停止状态进入* D+ F7 k0 y. Z6 r) `
      if (sys.state & (STATE_HOLD | STATE_SAFETY_DOOR)) {
% x# p9 `5 D9 ?! U        // Hold complete. Set to indicate ready to resume.  Remain in HOLD or DOOR states until user7 r! e7 a. J* M3 ^/ p
        // has issued a resume command or reset.
. r1 w# }1 o/ }5 N% p+ J$ S# o" R+ c4 y4 N0 [
                //保存完整。设置为指示准备简历。继续持有或门状态,直到用户& c# U& G( R6 R( ~! f, d2 w
                //已发布了一份简历命令或重置。
% g- D4 n2 R1 l% Q7 f; o               
6 f5 j8 E- F2 x" b0 s" f0 o* Z        if (sys.suspend & SUSPEND_ENERGIZE) { // De-energize system if safety door has been opened. 如果安全的门已被打开。断开系统: f. X7 B) _# g
          spindle_stop();9 j6 f; N* i  f* H3 R, K
          coolant_stop();
. Q3 Y9 o( F8 u4 f) z          // TODO: Install parking motion here. 安装停车动作。
* G5 l! p* u7 f$ u6 C# _        }! z4 J% `- Q8 U8 F2 s# d# W& i5 M
        bit_true(sys.suspend,SUSPEND_ENABLE_READY);( y5 @8 g! V4 E# }& N
      } else { // Motion is complete. Includes CYCLE, HOMING, and MOTION_CANCEL states. 电机完成,循环,回原点,,MOTION_CANCEL
9 l& `( h5 R6 a        sys.suspend = SUSPEND_DISABLE;
' N- H2 n/ b" h/ G* H        sys.state = STATE_IDLE;6 O  Z& g" W9 W* Q
      }
9 ^. e2 d5 T* X( h/ r      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_STOP);
9 B# d" R! a2 m6 {" v' Y, n/ l0 b- U9 Y    }+ b+ e1 l6 y3 _, j+ v
   
+ [# h4 L  T" f& w, u0 ]6 {! K  }
; G# M7 e* P3 y  m& V% P' p___________________________________________________________________________________________________8 H% S% p4 `% y  P

& f3 o) `: n. [$ o8 _, U9 X( S  // Overrides flag byte (sys.override) and execution should be installed here, since they
% i0 f0 A/ Z! \  // are realtime and require a direct and controlled interface to the main stepper program.
, Q3 H6 d) T9 C' m  p1 }$ C+ T) p& Z6 o8 v
  //重写标志字节(sys.override)和执行应该安装在这里,因为他们+ X' [) C8 X) d0 S' P! S
  //实时和需要直接和控制接口的主要步进程序。7 t& i  T& |" _1 z
/ Y0 ]0 Q1 E8 s' p: }" Y8 W
' ~3 ~! L1 C  ?9 x# D9 ?
  // Reload step segment buffer 重新加载步段缓冲
1 f9 ]* v! l0 x4 ?' y  if (sys.state & (STATE_CYCLE | STATE_HOLD | STATE_MOTION_CANCEL | STATE_SAFETY_DOOR | STATE_HOMING)) { st_prep_buffer(); } - J+ u3 N) S( N* ~$ a2 u0 q
4 h, {5 K6 }( o
  // If safety door was opened, actively check when safety door is closed and ready to resume.
4 {2 ?7 l  }) F/ l" N/ g/ Z9 f' }  // NOTE: This unlocks the SAFETY_DOOR state to a HOLD state, such that CYCLE_START can activate a resume.       
: g) n3 c9 G) s* @, _+ P6 B) }: Q" C5 k( K. @
//如果安全的门被打开,积极检查当安全门关闭,准备简历。
' T* r& s' M9 v4 r+ w! _) }  //注意:这解锁SAFETY_DOOR状态保持状态,这样CYCLE_START可以激活一个简历。
( V  _5 J# c) J; c7 a. O$ A0 Q4 K8 h/ n
  if (sys.state == STATE_SAFETY_DOOR) {                 //安全门状态进入
! P! g, y7 D* m6 t0 T+ o" d: f1 w* U- p    if (bit_istrue(sys.suspend,SUSPEND_ENABLE_READY)) { 6 @3 q: q* M- C7 Z  J
      if (!(system_check_safety_door_ajar())) {
2 X! e2 S+ z! e. U        sys.state = STATE_HOLD; // Update to HOLD state to indicate door is closed and ready to resume. 更新保存状态指示门关闭,准备简历。
4 ^7 ~  ?) _8 |3 f: _0 j7 c- T      }
* Z7 @0 S7 q* E. j    }- t9 v, Q5 Z. p; T4 D5 F
  }( a: ?! E) U/ W, k, Q2 r5 O

) Z" q, ~+ ^- X8 A  } while(sys.suspend); // Check for system suspend state before exiting.
3 ?; [8 C$ H/ W5 S$ B  - p/ G* k$ D1 y5 x& a! Z8 R! Q2 l
}  
回复 支持 反对

使用道具 举报

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

点评

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

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-17 06:56 , Processed in 0.090928 second(s), 22 queries , Gzip On.

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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