找回密码
 注册会员

QQ登录

只需一步,快速开始

搜索
查看: 19003|回复: 15

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

[复制链接]
发表于 2016-8-20 23:56:23 | 显示全部楼层 |阅读模式
本帖最后由 1五湖四海1 于 2016-8-21 00:09 编辑 6 z1 U$ a) A9 v- F

; x8 n$ E7 j7 |! a) {8 |    以前制作过CNC雕刻机,是用MACH3作为上位机控制,硬件是采用PC接并口输出脉冲和方向使能信号经过隔离驱动步进电机驱动器,步进电机驱动是采用TB6560芯片控制。最后就接到步进电机。机械是用铝合金制作,主要部件有三个1605的滚珠丝杠,多个运动滑块等制作。用这台DIY CNC雕刻机可以雕刻木头塑料等东西。当时没有一直玩下去,现在发现网上有用单片机制作的雕刻机挺精巧的现在分享给大家。
# w9 u+ t, a2 L1 J3 v   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个运动来规划运行速度,以实现平稳的加速和无冲击的转弯。很棒吧!开始玩起。$ y; ]3 c' W1 \' T
    还没有雕刻机的机械部分可以用废旧光驱制作个微型雕刻机运动平台。雕刻机最重要的是主控程序这次用 Arduino/AVR328单片机,价格在15元左右,主控程序是上面提到的目前很火的开源
的GRBL,还有一种基于STM32平台的开源主控程序Dlion也不错可以替代grbl。如果从性能比较这两个方案,显然是stm32平台运行速度更快毕竟他是32单片机呀!  E' s1 ^, J. r
  j- }! y& n3 X7 Z0 [( ]

% q1 Q& I0 K( w0 V: B2 `    下面介绍小这个些主控程序主要干的事,通过串口PC和主控板通讯,PC命令给控制板,控制板接收命令做不同的响应,PC可以发G代码给主控板,接收完成后可以自动开始雕刻任务。
, F# V& V. R& ?# q( G+ E          在介绍下G代码因为G代码是雕刻机的核心部分8 C# [3 s! O! B! p& M( B/ |
G代码是数控程序中的指令。一般都称为G指令。
! w6 S# U4 S3 A+ N+ OG00------快速定位" ~$ G; ?! P8 s  |
G01------直线插补$ ~2 E$ b# b, }; z( C
G02------顺时针方向圆弧插补
- T# u+ ?# p0 q$ |% p$ aG03------逆时针方向圆弧插补2 s% i! N- i$ h9 _: W
G04------定时暂停4 P" ^+ j1 @2 J8 B8 p
G05------通过中间点圆弧插补
* ^8 a5 s5 @: C5 CG06------抛物线插补
0 C5 `; ?" s7 Q% {9 G- N- nG07------Z 样条曲线插补* y2 L- O" [* N( [
G08------进给加速
, [8 l/ \5 g- x5 U  `  d5 C& PG09------进给减速
& f' B+ c* g: r( VG10------数据设置& O% J4 W- I; y5 e+ L" V
G16------极坐标编程  N& o7 J; \/ e1 i
G17------加工XY平面
$ ^* ?- F  D, v4 V* jG18------加工XZ平面0 y! x( m+ f6 J' \
G19------加工YZ平面
8 u2 v$ _9 [& T/ |
核心就是解析G代码,完成步进电机驱动,和控制主轴开启关闭,还有插补算法,直线插补,圆弧插补,还有一些步进电机的加减速算法。
# N  e! B3 _2 n1 A; \下面对grbl主结构做介绍% o: q( g3 q1 s
main()主函数首先执行下面初始化函数' H/ q$ u  ~5 U7 _
        serial_init();                           // 设置串口波特率和中断
' j1 _# W4 u$ `$ I) V/ T        settings_init();                         // 从ROM加载grbl设置
3 d( G% _! H. s! |9 F( ?' @" E        stepper_init();                          // 配置步进方向和中断定时器$ U" g8 f7 L. S/ s0 P5 h
        system_init();                           // 配置引脚分配别针和pin-change中断
. P8 W" K5 r4 L6 H        memset(&sys, 0, sizeof(system_t));          // 清除所有系统变量
; b5 Q3 I0 x# R  m' \6 u        sys.abort = true;                           // 中止标识位置位+ b+ R) Z' y5 X: J: ?# ~: L' u( A6 o
        sei();                                         // 使能中断
+ N8 i) x2 w' `- W  #ifdef HOMING_INIT_LOCK                        // 宏运算(settings.flags & (1 << 4)) != 0结果flags等于执行sys.state = STATE_ALARM- g) p( D* m7 ~  q
                                                // 系统状态赋值为报警状态
5 n2 c1 ]: o# E, v( e+ q! P            if (bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE)) { sys.state = STATE_ALARM; }, _  U' M- R9 O6 r1 i) a7 ]
  #endif. w+ q8 X7 e2 D; S4 A1 B! U4 P
_____________________________________________________________________________________________________________________________________3 H9 q7 G; I/ z9 T
接下来是一些主要部分初始化2 P- A) O- E. p
for(;;) {0 w. e7 J6 @; Z
        serial_reset_read_buffer();         //清除串口读缓冲区2 @: ~) b: m+ a: s( b
        gc_init();                         //初始化G代码功能函数
$ p5 R5 L$ u" y$ I        spindle_init();                        //主轴初始化, e- g2 L& t# k. _+ n6 {* W
        coolant_init();                        //冷却液初始化
+ q2 ^4 s5 q: U- a& b) t        limits_init();                         //极限开关初始化' f, V) k6 b& d0 u! k
        probe_init();                        //探测部件初始化
# q* f! N8 P" n; x! ?5 @        plan_reset();                         //清除块缓冲区和规划师变量; P" c+ J  R- s% u  f3 T
        st_reset();                         //清除步进系统变量。
# Q- D' {( b7 W& t. [$ U5 D. z. n- j7 e- }

1 E2 o  B4 o; y3 a6 Q. [! w        //下面两行清除同步gcode和策划师职位当前系统位置。
* Q7 P4 w# ]; A/ J/ g+ m) F0 Z
        plan_sync_position();' o4 k! S6 c5 G0 R( Z. v/ P7 g
        gc_sync_position();
( D4 ^, P* J' y3 V; K4 V7 @. x8 d. X" Q4 Z( O1 G# u
# C+ S7 p" E% |0 G8 N$ M* I+ a
        //复位系统变量
" V2 D, o# i" m5 G. b        sys.abort = false;                //系统中止标志
! I, a. b7 C, Y" y8 D3 Q        sys_rt_exec_state = 0;                //系统标志位变量状态管理。看到EXEC位掩码。$ ~/ z% i& i& d4 s8 q
        sys_rt_exec_alarm = 0;                //系统标志位变量设置不同的警报。9 R4 ]7 Q5 C8 ^. S( \
        sys.suspend = false;                //系统暂停标志位变量管理,取消,和安全保护。: v& ~+ L! b4 K; v7 N
        sys.soft_limit = false;                //限位开关限制状态机错误。(布尔)' E* I7 X, K: k" J8 M" N
0 A5 c5 `: P$ J- s

3 Y- u$ M" c. k7 m% q        protocol_main_loop();                //主协议循环
$ a6 ~, d$ P+ q  z}        //+ u- M: W! I2 `
_____________________________________________________________________________________________________________________________
$ N2 ~6 E; ?- Q# ~进入void protocol_main_loop()函数
. r0 D: e9 |; _; h% M1 E4 E{/ s  I, v0 G2 v9 b5 F& P9 A8 z
        report_init_message();                // 打印欢迎信息 0 ?# M) s: V% i  w$ D  f
        //重启后检验和报告报警状态如果错误重启初始化。: L1 o' l1 z/ A" ~# {+ a3 d0 t
        if (sys.state == STATE_ALARM) {, I  i  n" ]6 J& y5 Q
            report_feedback_message(MESSAGE_ALARM_LOCK); //打印信息
- r! V9 R8 {. u  Y7 [6 l* `. O0 t7 a; @
          } else {& X& l/ o# G  Q# E
            // 如果没有报警说明一切正常!但还是要检查安全门.
. {& }/ W$ Z7 G2 l4 q# |& G$ k% Y            if (system_check_safety_door_ajar()) {5 d" ?. R3 T1 I
                     bit_true(sys_rt_exec_state, EXEC_SAFETY_DOOR);
0 i! {5 \) u% c  F* R4 ]* {. u                     protocol_execute_realtime(); // 进入安全模式。应该返回空闲状态。
/ \) q& m+ l" c- N: u            }         else {0 `. n( I# K: }( {
              sys.state = STATE_IDLE; // .设置系统做好准备。清除所有国家国旗。
, t9 h3 L, E  L4 Q# J5 W5 T            }
0 y( b9 f9 U; w! n3 c            system_execute_startup(line);    //开始执行系统脚本2 q* J1 j2 A1 s, h
  }
# }! X: `6 r; @
. i' e0 S8 {% Q1 c: `1 Z2 F) o( `# F% |. x
  // 这是主循环!在系统中止时这是出口回到主函数来重置系统。
$ U; Y$ k) p8 ~  // ---------------------------------------------------------------------------------  % g/ o4 J" O1 c2 i+ n# O. n* ]
  
4 M7 A+ T4 a3 Z! j% y9 I  K        uint8_t comment = COMMENT_NONE;
  ?2 K3 l7 j5 ]) i" [# @, q# G! k( W        uint8_t char_counter = 0;
9 F$ V! x) ^0 a" ^7 W- }- p( F        uint8_t c;% p# a- }$ E3 y7 @3 X
_______________________________________________________________________________________________________________________________1 J: a- i  Y3 P. M. ~  p- t
接下来进入for(;;)循环                //下面代码是G代码解析核心部分,程序中comment(注释)变量会被赋不同值,代表发符号有‘(’‘)’‘;’
, [% r9 ]. Q3 o+ g{$ ?1 {& ~! h- b
//串行数据输入一行的的过程,作为数据。执行一个
% e/ P0 }5 ~  @2 q//所有数据初始过滤去除空格和注释。   g8 C& Q: U* j# S
//注意:注释,空格和程序段删除(如果支持的话)处理技术  ^' g. t+ d; n" i: b# [- U' n. C- }
//在G代码解析器,它有助于压缩到Grbl传入的数据& t. E: O; b; k9 W% j
//线缓冲区,这是有限的。刀位点标准实际上州一行不行% w% s2 t8 p! [$ z, y
//不能超过256个字符,Arduino Uno没有更多内存空间。$ h" N! S$ }1 ^8 [1 q: m! C
//有更好的处理器,它会很容易把这个初步解析的2 s8 h& S1 C8 K/ J( \
//分离任务共享的刀位点解析器和Grbl系统命令。                                                               
( ~/ P  L% G' S    while((c = serial_read()) != SERIAL_NO_DATA) {                             //读取串口数据,有数据执行下面代码
; w) b: O7 M5 b# R, U6 d+ o      if ((c == '\n') || (c == '\r')) { // End of line reached                //如果数据是/r,/n代表一行结束- t, p/ W- D. y  z$ D( E
        line[char_counter] = 0; // Set string termination character.        //设置结束标志
/ \+ \* Q% Q7 {' U; U5 c* ~        protocol_execute_line(line); // Line is complete. Execute it!        //一行完成执行此函数
8 z% U0 g7 V: y" ?2 s  O        comment = COMMENT_NONE;                                                //注释清零
1 A/ d1 V" T4 Q/ h' G        char_counter = 0;                                                    //字符计数清零" z+ U) p3 S" c! o3 R
  / ]- }& J. T9 e6 _$ M, w2 Z/ f
        else {
* s7 I7 R. |$ e        if (comment != COMMENT_NONE) {: E4 Z) Q+ c/ A0 V5 c
                                                     //扔掉所有注释字符3 x3 d/ \+ V0 I: h2 U5 x. U
          if (c == ')') {
6 _. C/ X; g3 g# v& \3 Q' Z            //最后注释。重新开始。但是如果有分号类型的注释。
+ B4 @9 k$ ]! |+ l" T. f            if (comment == COMMENT_TYPE_PARENTHESES) { comment = COMMENT_NONE; }
0 a' H  d5 S8 V: }2 h, O          }4 |5 c: ~% E! Y: a% ]" J5 Z2 M  W
      } else {
0 t- L' }" U- Q+ f' U% m, G          if (c <= ' ') {
4 Q7 ]8 p) P0 h' J+ }. r) X            //扔掉whitepace和控制字符1 d& A9 \$ d+ I/ `9 }- d  t& q
          } else if (c == '/') {
0 N3 s6 O5 ~0 h0 G4 r$ F) N            //块删除不支持将忽略字符。
0 a( s0 b) |) @            //注意:如果支持,只需要检查系统是否启用了块删除。+ J2 i, N0 ^; D5 m6 @+ x
          } else if (c == '(') {" q; a' c9 k2 ]% m; r6 Y
            // Enable comments flag and ignore all characters until ')' or EOL.
* J% _+ U$ g2 H            // NOTE: This doesn't follow the NIST definition exactly, but is good enough for now.
  N$ K" V2 \; o& q  \- A* T, Z            // In the future, we could simply remove the items within the comments, but retain the3 Z: U' L9 c+ A$ q) k
            // comment control characters, so that the g-code parser can error-check it.4 H- {0 l' k9 {7 h
            comment = COMMENT_TYPE_PARENTHESES;: m$ c- z) z' K$ m  s* W
          } else if (c == ';') {
3 C4 X/ n9 |' Z, `* J4 g            //注意:','注释EOL LinuxCNC定义。没有国家标准。
) s$ j3 b( v# a/ }/ H            comment = COMMENT_TYPE_SEMICOLON;& U& ]( Y% x  V) a% `+ b! d9 K0 ^
% y( F% j4 ]+ M) ?. M' t0 g
& ^' A: D7 W' ]2 O
_____________________________________________________________________________________________________________________________________
/ b) u' `# G4 q  n% p' K2 Y3 g! u/ Q          } else if (char_counter >= (LINE_BUFFER_SIZE-1)) {                        //串口接收数据大于80字符时
  b  n- K/ c1 t1 U            // Detect line buffer overflow. Report error and reset line buffer.        检测缓冲区溢出。报告错误和复位线缓冲区。' ^; v! c  }" h/ Y" h$ t; x
            report_status_message(STATUS_OVERFLOW);                                //打印溢出信息9 l( r9 R( ~' c  D" z2 w* z% a
            comment = COMMENT_NONE;8 M$ `: h* t( D. S/ d3 [
            char_counter = 0;/ Y4 A# P2 h, U6 a+ S- L) ]; X
          } else if (c >= 'a' && c <= 'z') { // Upcase lowercase                        //小写改大写
" f: W2 H+ W1 X8 j            line[char_counter++] = c-'a'+'A';/ p- N% {1 H2 F5 S4 B4 ^3 A2 B
          } else {
( p3 }4 n6 H9 W4 e  W8 B) P            line[char_counter++] = c;
) N9 ~( V: d- q6 }% c          }
" R3 R2 Q1 W3 s1 }/ N6 r. e        }
+ Y9 v% |: g+ m# n2 v      }
! ?& b) _4 [' e7 w/ s. Y    }7 b  X& s0 ]7 Z
____________________________________________________________________________________________________________________________________
1 Q. Y' ]) c- R- L, f" [        //如果没有其他字符在串行处理读取缓冲区和执行,这表明以完成,自动启动,如果启用,任何队列动作。
( b& D+ O5 R) M1 I/ l! [& Y        protocol_auto_cycle_start();                //自动开始协议循环
9 t8 K6 R$ K1 O$ Q; W4 Y' L        
/ y3 C: _; e  e; @% j" j, ]            protocol_execute_realtime();                  //运行实时命令。! R% K9 _9 w) W& s# a' g8 M# c
            if (sys.abort) { return; }                 //中止标识置位程序循环重置系统。            
9 x+ Q1 R! b' |# t, c  } % |. [1 E$ W: x) _8 O
  return;                         //一般程序不会执行到这里
3 f( G- w6 y4 m7 q8 @: f}
* s9 L9 t2 g; C, d6 p/ F____________________________________________________________________________________________________________________________________: d) r: t7 \# g" o  R; ]* a
正常情况下,读取完G代码程序会进入protocol_auto_cycle_start();//自动开始协议循环 函数下面介绍此函数' K& ?" Z) n: y: U
// Auto-cycle start has two purposes: 1. Resumes a plan_synchronize() call from a function that% [" y& P% Y9 v7 n: E1 F
// requires the planner buffer to empty (spindle enable, dwell, etc.) 2. As a user setting that ! ?* u; ?, n) l. C
// automatically begins the cycle when a user enters a valid motion command manually. This is
4 Q% z, ^: [) ?// intended as a beginners feature to help new users to understand g-code. It can be disabled: k4 f  H  X" D, H0 r1 h6 C7 G
// as a beginner tool, but (1.) still operates. If disabled, the operation of cycle start is
! g) w* J; g! k5 f) d9 i- U// manually issuing a cycle start command whenever the user is ready and there is a valid motion 9 L+ P+ }" ~9 d, g, }) }& o
// command in the planner queue.+ d! B, r0 z' }: A& @' P! R( E
// NOTE: This function is called from the main loop, buffer sync, and mc_line() only and executes
2 O) u# Y: ]: F8 q( _// when one of these conditions exist respectively: There are no more blocks sent (i.e. streaming 2 N: s# _8 k* ^! m
// is finished, single commands), a command that needs to wait for the motions in the buffer to $ N" q& ~; [6 V/ B9 G
// execute calls a buffer sync, or the planner buffer is full and ready to go.
, G1 p( B1 Y% O4 E' H//自动开始有两个目的:1。回复一个plan_synchronize()调用的函数% W* c$ N* }6 Y5 v1 j, m3 M+ ~2 {
//需要规划师缓冲区空(主轴启用、住等)2。作为一个用户设置
+ b' G& H. k- _$ j9 h. g- I4 k//自动循环开始当一个用户输入一个有效的运动命令手动。这是
1 Q) G0 }! U4 B! a. N//作为一个初学者的特性来帮助新用户了解刀位点。它可以被禁用" v* p( h% z+ [- w* C- q) ?% s9 w
//作为一个初学者工具,但(1)仍然运作。如果禁用,运行周期开始
; M( o: h% C) y8 n. x//手动发出一个周期开始命令每当用户准备好,有一个有效的运动6 _+ A; v) s& Z
//命令的规划师队列。
: {! i* m9 M: _- k+ ?; ^: O//注意:这个函数被称为从主循环缓冲区同步,mc_line只()并执行2 M# S$ u( [# A2 B8 G! P
//当其中一个条件分别存在:没有更多的块(即流发送
, s4 @" _0 B0 q$ ~' l) Z( q//完成后,单一的命令),一个命令,需要等待缓冲的动作
5 X0 F7 y5 v: h. ~//执行调用一个缓冲区同步,或规划师缓冲区满了,准备好了。
6 |0 ?* J. f. r2 j: P$ j" Q0 zvoid protocol_auto_cycle_start() { bit_true_atomic(sys_rt_exec_state, EXEC_CYCLE_START); } . o% D3 S; `; }5 I- E3 g# T( {+ ?  T
_______________________________________________________________________________________________
' e/ l' }% ]6 g: D3 y! b接下来程序运行protocol_execute_realtime(); /运行实时命令。/ u7 u$ ]: J9 K/ @
// Executes run-time commands, when required. This is called from various check points in the main
' k/ R' o1 n  ~' }  R% O5 C$ O: W// program, primarily where there may be a while loop waiting for a buffer to clear space or any
8 }* n& _" N9 h2 `& i* M// point where the execution time from the last check point may be more than a fraction of a second.
+ q8 M  R6 G- ^0 B6 B// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code
* K: M- ^( S7 G6 y' Y& D// parsing and planning functions. This function also serves as an interface for the interrupts to
' N( ]1 O6 ]) b$ e  r// set the system realtime flags, where only the main program handles them, removing the need to4 G, F' u0 f6 e4 v+ _8 l& X; T
// define more computationally-expensive volatile variables. This also provides a controlled way to
) _" e" [+ K  I6 A( V9 s; z// execute certain tasks without having two or more instances of the same task, such as the planner
2 e- m/ v3 ~- f6 H$ `// recalculating the buffer upon a feedhold or override.( P* [+ f. d: n# t( O" l! \
// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,
0 S' q% C" N& W1 P7 T7 L// limit switches, or the main program.5 [8 ~8 \0 v& P: b8 R3 |' e- w
void protocol_execute_realtime()! B9 H9 S9 W4 S& z
uint8_t rt_exec; // Temp variable to avoid calling volatile multiple times.临时变量来避免多次调用不稳定。# I: [( L0 u; \5 n
就先分享到这吧!
* i( M9 W: ^3 E! A0 ?0 X. v% K( N* O# }5 w# M6 Z. K% i
9 l6 g+ u" K9 e* u; J

. V0 E! |* v9 |8 J6 p6 Z6 d0 X' |% g% v/ j5 H7 U+ I

7 {9 S/ i3 r) H# n% V9 e" N% u4 u) K6 k9 z8 _

3 t7 c' S1 ~4 |2 L8 \8 g# L% F. U
" t& ^$ \4 Y0 k6 `# q3 d- K
; s: Q1 \5 g% M
8 ^4 g, ], ~+ q& Z$ _+ Q8 m5 E' @4 B
; }  J) `9 c0 r. U! S8 F
+ A' Z' D; ]8 V, m
& B3 ?* h: r; {7 ~8 r
# H; d0 [" M7 b, e6 e
; @' J! S  h1 x  F- p
0 \6 t6 x* g' ^# y, H) ]* F1 ^
0 |6 H  m3 z# L

( N' x6 K) J# n

2 b4 N3 W! W( G+ C2 {  y
$ I) Y. ~3 l9 Q" s8 o0 K: Q
% P; R: S! f4 K6 n- Z1 Q* U  s: D' m+ K, Z
补充内容 (2016-8-25 22:40):/ g7 J. R# k3 J. B- |7 v
配置说明
* J8 P; l* a) S9 v$ P//这个文件包含编译时配置Grbl的内部系统。在大多数情况下,
  d7 Y4 ^- H& }1 f3 h/ R% ]//用户不需要直接修改这些,但是他们在这里为特定的需求,即。9 q  C4 I$ B; m
//性能调优或适应非典型的机器。7 Q4 @5 B" Z9 ]3 h; H
主要配置项:
# \) K+ Q, M, J8 V! `# o; u2 f1.#define DEFAULTS_GENERIC        //在重置eepm时使用。在defaults.h改变想要的名字
5 [3 b# q) b& e4 R) R0 D4 ^2.#define BAUD_RATE 115200        //配置串口波特率115200) x& e% o+ f$ ?: [
3.#define CPU_MAP_ATMEGA328P         // Arduino Uno CPU# W+ I8 }: Q0 V5 @, h: o4 J
4.#define CMD_STATUS_REPORT '?'        //定义实时命令特殊字符
$ b. n# v" q/ F/ P5.#define HOMING_INIT_LOCK         //回原点保护锁9 C6 M+ n" _2 V; r0 e! M4 {3 p
6.#define HOMING_CYCLE_0 (1<<Z_AXIS)              // 第一步Z清除工作区。
2 A3 L9 o. k. y, L  #define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // 然后X,Y在同一时间。
9 f3 {: _0 |# b/ a/ E, ]7.#define N_HOMING_LOCATE_CYCLE 1 //回原点循环次数) g0 g) P& X. n. G1 s, ^3 f
8.#define HOMING_FORCE_SET_ORIGIN //取消这定义迫使Grbl总是在这时候位置设置机器原点尽管开关方向。
) q6 @1 k% K7 g2 k. ^9.#define N_STARTUP_LINE 2 //块Grbl启动时执行的数量。
4 U) C. Z1 }! E% I( C: N- Q. p2 A10.#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 协调或位置价值英寸
! Q. C% o; Z' h- n   #define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 协调在毫米或位置价值' }) d& O- X; E2 f; P; A, o# E1 [
   #define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分钟的速度值
) K2 g8 `, _9 D# s& u( j2 D+ ^   #define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分钟( }; N# _  K# E) Q* E
   #define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 对浮点小数设置值, w/ S7 W0 N' o. b, O* y
11.#define LIMITS_TWO_SWITCHES_ON_AXES //如果你的机器有两个极限开关连接在平行于一个轴,您需要启用这个特性5 N# n1 h7 c1 c6 q" H
12.#define USE_LINE_NUMBERS         //允许GRBL跟踪和报告gcode行号
1 I, a7 _. ^2 `4 t% }$ q13.#define REPORT_REALTIME_RATE //允许GRBL报告实时进给速率! X: j6 H) {/ P; U6 q
14.#define MESSAGE_PROBE_COORDINATES  //坐标通过Grbl $ #的打印参数?7 T! c  ]. S6 C5 M
15.#define SAFETY_DOOR_SPINDLE_DELAY 4000 //安全门主轴延时& D  V1 p7 y! D! A2 y0 p
16.#define SAFETY_DOOR_COOLANT_DELAY 1000 //安全门冷却液延时% z# L  f( `- M9 m% ~7 @
17.#define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS) //启用CoreXY运动学。! C( z! B% M1 W) W7 F/ ~
18.#define COREXY // Default disabled. Uncomment to enable.改变X和Y轴的运动原理
% x- v6 E) ?- a4 K0 b* @+ i! V9 z- F19.#define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.反转针销逻辑的控制命令
% ]8 j2 D5 c# l- H4 k& R- Y& x20.#define INVERT_SPINDLE_ENABLE_PIN // 反转主轴使销从low-disabled
! R4 Z8 C% k, _5 q6 R21.#define REPORT_CONTROL_PIN_STATE //启用控制销状态反馈状态报告。3 Y7 f0 I$ t3 u  x
22.#define FORCE_INITIALIZATION_ALARM //启用和用户安装限位开关,Grbl将启动报警状态指示' s! e& ^. X, S7 U) F- I6 o+ Q* B2 Z
23.#define REPORT_GUI_MODE // gui允许最小的报告反馈模式9 L+ Y/ F- n3 n( F4 z/ h+ Z
24.#define ACCELERATION_TICKS_PER_SECOND 100 //加速度的时间分辨率管理子系统。
4 Z, g* t7 A2 l) b8 H25.#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING //自适应多轴步平滑(积累)是一种先进的功能
# h* m, y- D) s/ r7 w26.#define MAX_STEP_RATE_HZ 30000 //设置最大一步速率可以写成Grbl设置
5 u& ?; j& S6 Z( a27.#define DISABLE_LIMIT_PIN_PULL_UP //以下选项禁用内部上拉电阻1 ?" Q* J2 ?1 X* a
28.#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS //设置哪个轴长度补偿应用的工具。假设轴总是与选择轴工具面向负方向
; ]6 }, [/ b! U$ w; \) S- j0 P29.#define VARIABLE_SPINDLE //允许变量轴输出电压不同的转速值。$ V! _; M# Y9 V% ?
30.#define SPINDLE_MAX_RPM 1000.0  // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.  c4 S/ B# E3 N. a( E' D; R; p
   #define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.
* L+ ^( c0 i4 }7 _- S+ \4 D5 A31.#define MINIMUM_SPINDLE_PWM 5 //使用的变量轴输出。这迫使PWM输出最小占空比时启用。* h7 ^/ a7 A1 h3 P! I; h
32.#define USE_SPINDLE_DIR_AS_ENABLE_PIN //主轴方向使能M4被删除8 |, H# P& ]$ f# f+ G' V9 R' {
33.#define REPORT_ECHO_LINE_RECEIVED //应该对所有正常线路送到Grbl( k- B1 [  {1 u9 o' U
34.#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min) //最小规划师结速度。设置默认最小连接速度规划计划4 X3 k! w0 W. F- G% M; h
35.#define MINIMUM_FEED_RATE 1.0 // (mm/min)//设置计划将允许的最小进给速率
; {4 }& X" `3 O1 D36.#define N_ARC_CORRECTION 12 //弧生成迭代次数之前小角度近似精确的弧线轨迹6 {% n5 n" ^9 T6 n# Y: z
37.#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)//定义值设置机器ε截止来确定电弧是一个原点了?* }" O  X) _" n) S  |
38.#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds) //延时增加表现在住。默认值设置为50毫秒
8 a, u9 `5 p- P" e) t% s39.#define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled., ]" d, t/ s' B2 b9 h' A
40.#define BLOCK_BUFFER_SIZE 18  //线性运动规划师缓冲区的数量在任何给出时间计划8 Z; r  l$ ^$ m, Q! u4 P+ P
41.#define SEGMENT_BUFFER_SIZE 6 //控制之间的中间段缓冲大小的步骤执行算法
+ w# S: V5 f( C0 ~8 ]42.#define LINE_BUFFER_SIZE 80 //行执行串行输入流的缓冲区大小。
, f  n3 H" z7 ]0 z* e. i43.define RX_BUFFER_SIZE 128 //串行发送和接收缓冲区大小: O" h; ~3 C0 ]" m' r! I$ Q- y
44.#define TX_BUFFER_SIZE 64
5 `- g: d" [9 x# p$ D45.#define ENABLE_XONXOFF        ////切换为串行通信发送流软件流控制。: H1 r( ^% l( h8 ]2 E: z  B6 s  l
46.#define ENABLE_SOFTWARE_DEBOUNCE //一个简单的软件消除抖动特性硬限位开关。
3 z' P0 L# b$ l1 C0 o' b47.#define HARD_LIMIT_FORCE_STATE_CHECK        //Grbl检查硬限位开关的状态
2 Q* V, n( C' q- x2 z4 t% `48.// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:编译时错误检查的定义值:( A5 d* z+ q# @0 l0 o
! A3 J3 H! R( @# I
___________________________________________________________________________________________________
* n) F2 e2 G) R$ c! M/*
, [1 y! L- Q$ l1 ?+ R: b* {$ m1 c  config.h - compile time configuration* G% o7 o% ?( a8 `3 s: d! D
  Part of Grbl6 h4 o# Q7 M8 u  W% l. h  L
' D7 y& x4 P; Z
  Copyright (c) 2012-2015 Sungeun K. Jeon
+ C% e9 |, A7 r* u- v  Copyright (c) 2009-2011 Simen Svale Skogsrud& I1 P' I$ V" K6 r4 b( R
+ `5 R5 q6 \, \/ n
  Grbl is free software: you can redistribute it and/or modify
+ C# Q2 ~, D% z6 V! J' W  it under the terms of the GNU General Public License as published by
1 [$ w5 [% v4 R( B) s: L9 T1 C! I  the Free Software Foundation, either version 3 of the License, or1 s* ]/ @" O1 n, R2 y
  (at your option) any later version.# @( q, A& W2 n( k( c1 ?

5 y$ o+ H3 N; i% ]% ~  Grbl is distributed in the hope that it will be useful,
0 V7 p) q/ q& J1 u! h8 t2 b: g3 I  but WITHOUT ANY WARRANTY; without even the implied warranty of
, F/ u/ q' F, ^3 E. p5 v  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the" _0 ~. L& ~" {* g
  GNU General Public License for more details.. a0 x( i! Y/ P/ y3 q

- p7 C/ X- O; Y  You should have received a copy of the GNU General Public License
/ k. ?, `# S& e. y( w* |7 K  along with Grbl.  If not, see <http://www.gnu.org/licenses/>.
( K7 ~& G, U% U* u- Zconfig.h  -编译时配置,Grbl的一部分8 q/ O; u8 Q1 Y6 Y

% d2 N5 i0 z8 T6 I& p4 x版权(c)2012 - 2015 Sungeun K. Jeon
, B) e) r: p/ u* }1 n版权(c)2009 - 2011 Simen Svale Skogsrud- W# u7 R, k1 j) J
2 q' j; r( j& a% R
Grbl是免费软件:可以重新分配和/或修改4 V+ O7 W. ~/ T2 s
GNU通用公共许可证的条款下发布的自由软件基金会,版本3的许可,或(任您选)其后的版本。
$ X/ M/ P% n1 G# b
* |$ n. W6 X; ]5 }4 r0 f# Z, t0 \; OGrbl分布,希望这将是有用的,但是没有任何保证;没有即使的默示保证适销性或健身为特定目的。看到
2 u- @, g. q6 _% D1 @/ zGNU通用公共许可证的更多细节。, e2 X7 _" I/ W0 ~: P5 p3 k/ V

" z3 T* C7 g+ X9 C0 Y你应该收到了GNU通用公共许可证的副本. k! r" H5 ^  {% d  H& {" U) v
连同Grbl。如果没有,看< http://www.gnu.org/licenses/ >。# d9 D" b0 a. N4 u9 @

! Z3 K; ~: G: Q6 M*/
+ G! d% S+ b9 X8 w) }  7 X8 O- N7 h+ ^+ L, V, A) U
// This file contains compile-time configurations for Grbl's internal system. For the most part,* p2 z, w" E, n8 W! S
// users will not need to directly modify these, but they are here for specific needs, i.e.
# C1 @. P% {+ o% Y; D! t// performance tuning or adjusting to non-typical machines.8 d* c- Q' C% j" T
//这个文件包含编译时配置Grbl的内部系统。在大多数情况下,
8 M  D6 \  ^; {# f//用户不需要直接修改这些,但是他们在这里为特定的需求,即。" m3 Q3 ]% W7 q' d4 U) }
//性能调优或适应非典型的机器。
0 Y1 ]9 O1 G0 d8 g$ B
0 h; M# L+ K4 F4 U! s// IMPORTANT: Any changes here requires a full re-compiling of the source code to propagate them.  b5 o5 b$ |5 f+ z! @: \4 g% _
//重要:任何变化需要一个完整的基于源代码的传播。
- }5 ~' F. y$ f( r) A3 [  N" b# _! ~! f/ V+ i% u: Q( @0 _% y  {
#ifndef config_h
" s& \2 u( W" G. P#define config_h
* r  I+ ^+ I( {. y#include "grbl.h" // For Arduino IDE compatibility.
3 o6 q/ w$ V- s' W4 x
5 E; P* t# \6 W1 r5 J  r// Default settings. Used when resetting EEPROM. Change to desired name in defaults.h' K7 s- J% G/ {  w4 ]! N' U& u
// 默认设置。在重置eepm时使用。在defaults.h改变想要的名字) Y  k5 ^  ~& v* ]- y

4 C) x8 `; r- c! f" w5 Y% R# D#define DEFAULTS_GENERIC
  A! q3 i( L9 z2 e  O  k! J9 }
) x9 `+ B$ G9 f( N% T* u" }7 ^  a// Serial baud rate
* Z6 |0 O) d5 F+ U- v* B; m0 H#define BAUD_RATE 115200                //配置串口波特率115200
$ o" Z" y1 ]* Q: j2 S* q4 K
0 D% Z% \, Y9 k( j// Default cpu mappings. Grbl officially supports the Arduino Uno only. Other processor types# P8 \" d1 n# v2 D
// may exist from user-supplied templates or directly user-defined in cpu_map.h
4 d  C1 _+ b2 [! z$ h//默认cpu映射。Grbl正式支持Arduino Uno。其他类型的处理器可能存在cpu_map.h直接从用户提供的模板或用户定义的) W* p5 q4 S* |, ?% \

8 P! g1 G% G, p& R3 L#define CPU_MAP_ATMEGA328P // Arduino Uno CPU
' r1 R+ @( V7 Z2 H6 U; w- l: P1 a% M5 y- Q) V% `; \% H, U% c
// Define realtime command special characters. These characters are 'picked-off' directly from the# y' E, h6 T: H- p- e
// serial read data stream and are not passed to the grbl line execution parser. Select characters
! U6 L, S( W" z9 T2 I// that do not and must not exist in the streamed g-code program. ASCII control characters may be
; }! @9 c1 u! o3 C) T// used, if they are available per user setup. Also, extended ASCII codes (>127), which are never in 4 [" R, m$ T) u! g
// g-code programs, maybe selected for interface programs.3 R8 V, B# L- W8 C6 `
// NOTE: If changed, manually update help message in report.c.. ?: v9 A6 q5 }1 P. R9 q( b( e

2 q" O) q3 E- H//定义实时命令特殊字符。这些字符是直接从“各个击破”串口读取数据流并没有传递到grbl行执行解析器。选择角色
/ ~4 @! L+ J- d1 ^; Y4 {+ f0 x8 R//不,不能存在于程序流刀位点。ASCII控制字符# A3 `. x7 n& C! z: N4 ~. s
//使用,如果他们是可用的每个用户设置。同时,扩展的ASCII码(> 127),从来没有: C. S4 |4 J4 m1 m
//刀位点的程序,也许选择界面程序。2 h. {; {6 B6 ~! o, l% `3 W0 S' _$ P
//注意:如果改变,手动更新report.c帮助信息。
5 i. s; l% T& `6 @: H5 R7 Z: b
6 B/ S& f; D! S& C- Q* q; e" ?#define CMD_STATUS_REPORT '?'
. k+ Z4 k1 p+ g1 U#define CMD_FEED_HOLD '!'
8 t# l7 h1 S+ Y3 R; _+ \2 P. Y# X#define CMD_CYCLE_START '~'5 x* a$ J2 c- v, _
#define CMD_RESET 0x18 // ctrl-x.; V0 M6 T/ j, J$ H$ ~
#define CMD_SAFETY_DOOR '@'
* M# Q! K9 L( o4 \& N2 E; f" Y& m3 R6 B3 X0 l
// If homing is enabled, homing init lock sets Grbl into an alarm state upon power up. This forces1 l, g) q1 s3 _  }" d' L. J  }
// the user to perform the homing cycle (or override the locks) before doing anything else. This is
3 X) t4 j# t! e. F, ~8 N' u+ P3 X// mainly a safety feature to remind the user to home, since position is unknown to Grbl.2 `/ B) o/ d8 R: B8 R" I; u

/ f0 ]5 f) ?) m//如果启用了回原点,导航初始化锁集Grbl进入警报状态启动。这就迫使6 e7 O( P: a  m. ^
//用户执行归航周期(或覆盖锁)在做任何其他事情之前。这是
4 ?/ j% P4 p0 Q" a3 d0 j//主要安全功能,提醒用户家里,因为Grbl位置是未知的。
& t3 L( P3 l1 v8 s$ |- O/ U# C8 m; S) e
#define HOMING_INIT_LOCK // Comment to disable* s3 m! H+ K/ _5 F
# U! G4 `; V; t
// Define the homing cycle patterns with bitmasks. The homing cycle first performs a search mode5 C5 Y& \% {7 ]- X4 Y  R2 p; u; R: ]. H
// to quickly engage the limit switches, followed by a slower locate mode, and finished by a short0 g0 G+ D/ D, f, l
// pull-off motion to disengage the limit switches. The following HOMING_CYCLE_x defines are executed   w% X# R. N7 D* X9 @) A
// in order starting with suffix 0 and completes the homing routine for the specified-axes only. If& |4 D3 v1 l; V2 m5 U! l* d2 i
// an axis is omitted from the defines, it will not home, nor will the system update its position.4 R4 _& M* X7 a; l1 A+ S0 O+ c8 D
// Meaning that this allows for users with non-standard cartesian machines, such as a lathe (x then z,4 D3 Y' e9 D& q
// with no y), to configure the homing cycle behavior to their needs. 7 Y  k! n" ?9 R6 m) G0 Y
// NOTE: The homing cycle is designed to allow sharing of limit pins, if the axes are not in the same- }  l: z' s* A: c; q
// cycle, but this requires some pin settings changes in cpu_map.h file. For example, the default homing
; _, L8 z+ T! Q4 D* v// cycle can share the Z limit pin with either X or Y limit pins, since they are on different cycles.
2 h( Q9 H4 }& R) e5 s# j// By sharing a pin, this frees up a precious IO pin for other purposes. In theory, all axes limit pins% S. w/ Y+ M! q2 \. U( w
// may be reduced to one pin, if all axes are homed with seperate cycles, or vice versa, all three axes" ^# D' D) o1 h: x
// on separate pin, but homed in one cycle. Also, it should be noted that the function of hard limits : P( Z3 |4 ?9 v" l4 U6 e+ O8 y
// will not be affected by pin sharing.
# Z! x* j" K, u$ W3 `+ N3 C. k- X//定义导航循环模式的位掩码。归航周期首先执行一个搜索模式
* ?% R; q: R$ `4 C8 a, f5 j: u//快速进行限位开关,其次是较慢的定位模式,完成了由一个短
) s0 s, B7 y2 `; E) [//拖出运动脱离限位开关。以下HOMING_CYCLE_x定义执行
& c! ]/ F7 L0 g# Y1 Y3 i* Q# b/ f, W& ~//为了与后缀0开始并完成specified-axes只寻的例程。如果2 q$ P- u) A1 Q6 B9 ^
//定义省略一个轴,它会不在家,也不会系统更新它的位置。1 U& H7 ^6 Q$ X+ N6 I
//意义,这允许用户与非标准笛卡尔的机器,比如车床(x,z,. X2 k, ~) s5 V' V2 z9 U5 [1 C$ L
//没有y),配置导航循环行为对他们的需求。
8 h0 @) E( y% Z7 h//注意:归航周期允许共享限制针,如果轴不相同9 g: e# s: P, w* |, \0 T7 x5 `
//循环,但这需要一些销设置cpu_map的变化。h文件。例如,默认的导航- b1 g% H" K* G- t) H7 w* B) `
//循环可以分享Z限位销X或Y限制针,因为它们是在不同的周期。
) t7 r( _) D* E: q- m3 K. y: t/ z# o; j//通过共享一个销,这腾出宝贵的IO销用于其他目的。从理论上讲,所有轴限制别针
! q" [! t7 d: g" D0 [( ^$ L5 x//可能会减少到一个销,如果所有轴与分离周期居住的地方,反之亦然,所有三个轴: L" w) g- _7 d4 l
//在不同销,但这时候一个周期。同时,应该注意的是,硬限制的功能
# c0 a' s& h2 b1 o" T. Z2 t3 u//将不会影响销共享。
' _. S# G( y( h' u//注意:默认设置为一个传统的硬件数控机器。z轴首次明确,其次是X和Y。
+ h4 ^" P5 r0 m2 G  R( X! K! v% z: O2 b8 y1 V9 N, r- \
// NOTE: Defaults are set for a traditional 3-axis CNC machine. Z-axis first to clear, followed by X & Y.
  O' I3 N' X; [0 r$ f0 j#define HOMING_CYCLE_0 (1<<Z_AXIS)                // REQUIRED: First move Z to clear workspace. 第一步Z清除工作区。  d* P# w. @. x2 v
#define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // OPTIONAL: Then move X,Y at the same time.然后X,Y在同一时间。
3 u# r  g$ m, i+ `  z// #define HOMING_CYCLE_2                         // OPTIONAL: Uncomment and add axes mask to enable
- B# x; L4 r* `! i0 H. U$ Y+ K1 [0 \- a" c% d0 A0 u2 s$ M/ t2 {
// Number of homing cycles performed after when the machine initially jogs to limit switches.
6 }  Q6 R/ w3 |/ {4 h- X- l// This help in preventing overshoot and should improve repeatability. This value should be one or " U6 u; X1 `) X1 r7 S/ C5 I4 j: m
// greater.- x# D4 N% N2 T% F
//执行回原点循环次数后,当机器最初慢跑限位开关。这个帮助防止过度,应该提高重复性。这个值应该是一个或大。
5 t: w( u' ]: u& y( O: {, [
4 l6 E% i* {: _9 }2 }#define N_HOMING_LOCATE_CYCLE 1 // Integer (1-128)
% T1 G; F* e9 Z
' V+ D0 K$ [. t// After homing, Grbl will set by default the entire machine space into negative space, as is typical
, U0 J  l5 Z/ M$ I8 E9 Z// for professional CNC machines, regardless of where the limit switches are located. Uncomment this
+ Q/ s- D: w- R+ g3 D// define to force Grbl to always set the machine origin at the homed location despite switch orientation.) F, m: b! f8 S6 F6 }: x

4 [/ t' C# b% p! I3 W' `! n//导航后,默认Grbl将整个机器空间留白,是典型的专业数控机器,不管限位开关所在的地方。5 [7 @* r' y" J) M7 v9 ]1 B
//取消这定义迫使Grbl总是在这时候位置设置机器原点尽管开关方向。1 Z" q0 v' k! s& k7 q3 Z

1 h: b6 Z- V# w. m  Q5 }// #define HOMING_FORCE_SET_ORIGIN // Uncomment to enable.
8 a4 Q" e6 o* M0 M/ R, Y. d. Y% j& @8 p* V5 p, H  L

# ?% H" }; K3 r+ q. k// Number of blocks Grbl executes upon startup. These blocks are stored in EEPROM, where the size
. c& m( N. U9 m// and addresses are defined in settings.h. With the current settings, up to 2 startup blocks may
3 e5 y6 ^  ]- p// be stored and executed in order. These startup blocks would typically be used to set the g-code
7 q/ p! T$ e8 ^// parser state depending on user preferences.
% n4 Z( X- q) X0 c" n* C% P! W1 F
2 Z8 s" Z$ M6 I//块Grbl启动时执行的数量。这些块存储在eepm,大小- x. V  P# ~7 J/ K$ |
//和地址在settings.h中定义。与当前设置,可能2启动块1 t0 z5 e) X  f, `
//存储和执行。这些启动块通常被用来设置刀位点& ~7 N/ R8 k: b$ v: `9 p- o" C
//解析器的状态取决于用户首选项。. h5 ~$ \# }" h4 s' o0 P
2 H. m* \; J" V" {, R
#define N_STARTUP_LINE 2 // Integer (1-2)
- |8 q" q& `4 x, J: l' \$ }
; `! F) |% z! q% ]// Number of floating decimal points printed by Grbl for certain value types. These settings are
9 H( k  S7 f% }" i// determined by realistic and commonly observed values in CNC machines. For example, position
0 g" I& C0 ~) E9 ^// values cannot be less than 0.001mm or 0.0001in, because machines can not be physically more) o& \" e1 p/ `8 S% B7 s1 ?6 M
// precise this. So, there is likely no need to change these, but you can if you need to here.1 r" j/ P' m/ \" ]. I7 O6 E
// NOTE: Must be an integer value from 0 to ~4. More than 4 may exhibit round-off errors.
7 M( ]4 k( P  t
- k) o: m6 i  [2 \( W7 `// Grbl浮动小数点的数字印刷的特定的值类型。这些设置是1 D1 a# `- I* t" k4 ?" A0 @2 Z
//一般由现实和观测值在数控机器。例如,位置0 e$ O# a7 d# X1 r5 c0 ^7 k
//值不能小于0.001毫米或0.0001,因为机器不能身体更多# J2 D' y+ ]2 \9 o
//精确。因此,有可能不需要改变这些,但你可以在这里如果你需要。* R8 i( x5 d" o/ i& y. ?0 T
//注意:必须是一个整数值从0 ~ 4。超过4可能出现舍入错误。
" E$ M) u/ l: A+ N6 q; n) N
2 a& V3 N& C1 c4 j/ B. |- s. c5 ^#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 协调或位置价值英寸9 C4 j/ a/ [0 I
#define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 协调在毫米或位置价值5 @9 A. Z9 ]6 t8 N/ U5 H, n& P
#define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分钟的速度值
, f2 S* b9 ]8 @/ ]1 Q6 H5 W1 c4 g#define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分钟
/ N1 f! s. `( x0 E3 V* A#define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 对浮点小数设置值
# Q* Q2 c/ E5 K  O& d
1 s: c. T2 \# x$ F6 _4 f5 _7 ^// If your machine has two limits switches wired in parallel to one axis, you will need to enable' v% c: c: M6 A1 X* }! y$ H) `
// this feature. Since the two switches are sharing a single pin, there is no way for Grbl to tell2 P& m: n" Q( z# M5 O8 I
// which one is enabled. This option only effects homing, where if a limit is engaged, Grbl will , X) Y. e- l1 [0 ?0 g& o. C
// alarm out and force the user to manually disengage the limit switch. Otherwise, if you have one" t! G* C: u2 h
// limit switch for each axis, don't enable this option. By keeping it disabled, you can perform a
1 a8 b/ q& Z( b5 |$ x) r% g, h// homing cycle while on the limit switch and not have to move the machine off of it.9 G8 U4 f% s3 v/ W5 l/ ^4 N% \; K

$ }8 m2 d) X. V# \) r9 e+ I8 g//如果你的机器有两个极限开关连接在平行于一个轴,您需要启用3 r; C) V& X" O# @6 l
//这个特性。自从两个交换机共享一个销,没有办法Grbl告诉
  q9 C" W) A7 H! |//启用哪一个。此选项仅影响归航,如果限制,Grbl意志
* L% [! d' P# a# b0 [6 x//报警,迫使用户手动松开限位开关。否则,如果你有一个  f$ W: |: f( W/ Y% a; N9 P- F
//为每个轴限位开关,不启用该选项。通过保持禁用,您可以执行
6 w* n. x, @2 x" E) h( H$ A//导航循环在限位开关并没有将这台机器。
. x& s4 Z$ g3 C/ b  m7 c* I$ b7 i1 ~" X2 x& H
// #define LIMITS_TWO_SWITCHES_ON_AXES
, w2 V6 L, l  X: ^& W* d- @) Y4 x
// Allows GRBL to track and report gcode line numbers.  Enabling this means that the planning buffer$ Q4 w! ?7 a) m
// goes from 18 or 16 to make room for the additional line number data in the plan_block_t struct
8 e( n/ O- R0 K/ s- E1 [2 J! O: y3 \
//允许GRBL跟踪和报告gcode行号。使这意味着计划缓冲从18岁或16岁,为额外的行号plan_block_t结构中的数据
2 c/ [. i2 t. c. s' _
5 G  f5 q  k& r9 E3 \( R1 [// #define USE_LINE_NUMBERS // Disabled by default. Uncomment to enable.
8 l* r9 d6 O5 p" Y- U/ A" B
0 Q. T6 E& I& d! Z// Allows GRBL to report the real-time feed rate.  Enabling this means that GRBL will be reporting more " G1 f$ c% B  P  Q( O; [2 ?
// data with each status update.) \7 `# U: }) O- ?
// NOTE: This is experimental and doesn't quite work 100%. Maybe fixed or refactored later.8 j  R% R9 X5 m0 {
//允许GRBL报告实时进给速率。使这意味着GRBL将报告数据和状态更新。" H( F& X3 @1 K
//注意:这是实验和100%没有工作。也许以后固定或重构。4 j, p2 ~8 v2 ^

0 r: ?8 Q: [5 @4 s- h3 P7 s// #define REPORT_REALTIME_RATE // Disabled by default. Uncomment to enable.
5 M, P! y, C" R: c4 \. n9 n% q' G
7 x0 n+ s- t$ n  y// Upon a successful probe cycle, this option provides immediately feedback of the probe coordinates  G) x/ t/ P" F% N# Q$ \/ q
// through an automatically generated message. If disabled, users can still access the last probe5 h3 Q- ]/ ~# e; a
// coordinates through Grbl '$#' print parameters.: }. L9 [2 L1 |8 @4 X
//在一个成功的调查周期,这个选项提供立即反馈的探测器坐标- b; ^, b1 J* h& F* D
//通过一个自动生成的消息。如果禁用,用户仍然能够访问调查
/ l8 w' a# e. U( D5 g6 i" @/ G; m$ f//坐标通过Grbl $ #的打印参数。
% O; N# t: t: h, Z& p) [" A7 o2 c, a+ B, ~
#define MESSAGE_PROBE_COORDINATES // Enabled by default. Comment to disable.* u0 g5 Z. p" Z; {5 F

5 b' Y. D2 J7 ]// Enables a second coolant control pin via the mist coolant g-code command M7 on the Arduino Uno
2 k9 d7 q* b8 ?& V# w! a// analog pin 5. Only use this option if you require a second coolant control pin.
1 Z( _; D4 D- v8 y* l5 F// NOTE: The M8 flood coolant control pin on analog pin 4 will still be functional regardless.+ e. M# w( o& H+ Z! I6 d% E) U
// #define ENABLE_M7 // Disabled by default. Uncomment to enable.
& c: {  b+ B1 _1 L& {& b$ y& @% {1 [. y- N8 W6 M
// This option causes the feed hold input to act as a safety door switch. A safety door, when triggered,- W, Y' L' K+ }! h# _* v+ p2 Z2 }3 g
// immediately forces a feed hold and then safely de-energizes the machine. Resuming is blocked until: X: B  X) \" ]* Z1 o+ t
// the safety door is re-engaged. When it is, Grbl will re-energize the machine and then resume on the
4 \$ {4 |. p  `7 F' W// previous tool path, as if nothing happened.' }. T7 \! o! ~% D
// #define ENABLE_SAFETY_DOOR_INPUT_PIN // Default disabled. Uncomment to enable.
% a& r- n8 J1 a& H! G' R+ h
/ n0 ~# V" q5 q3 v3 h// After the safety door switch has been toggled and restored, this setting sets the power-up delay
3 e4 ~# Z0 t# t) A& R// between restoring the spindle and coolant and resuming the cycle.
8 f1 s; U2 V, V2 F- Z; x6 w// NOTE: Delay value is defined in milliseconds from zero to 65,535. - l; e9 [8 l" A* @- s

9 e' D1 D6 o) V! M- G5 X//定义导航循环模式的位掩码。归航周期首先执行一个搜索模式9 c9 t2 q* b# h" c$ N6 o
//快速进行限位开关,其次是较慢的定位模式,完成了由一个短/ u7 R+ U- s5 Q* b, p8 F' u& E5 t/ L
//拖出运动脱离限位开关。以下HOMING_CYCLE_x定义执行( ~! t/ H4 S) G8 `& H: {
//为了与后缀0开始并完成specified-axes只寻的例程。如果
" W' @2 ?  q% h8 B0 F. a//定义省略一个轴,它会不在家,也不会系统更新它的位置。
( r" k) J# Z8 V3 y* Q. h3 {9 }//意义,这允许用户与非标准笛卡尔的机器,比如车床(x,z,
7 U4 a+ _: h; }/ D8 M( R//没有y),配置导航循环行为对他们的需求。
, L' y3 ~7 N+ x$ |+ g' X- X//注意:归航周期允许共享限制针,如果轴不相同* K1 Z4 z6 L- Y: D0 u
//循环,但这需要一些销设置cpu_map的变化。h文件。例如,默认的导航' N& C% D/ V3 U2 i2 i& T& S" _) k8 c/ q0 h
//循环可以分享Z限位销X或Y限制针,因为它们是在不同的周期。0 G+ Z, ?0 h+ x; u; L
//通过共享一个销,这腾出宝贵的IO销用于其他目的。从理论上讲,所有轴限制别针: }; {! p7 s: f' _
//可能会减少到一个销,如果所有轴与分离周期居住的地方,反之亦然,所有三个轴  b: c% D9 ]1 |8 p, H+ M
//在不同销,但这时候一个周期。同时,应该注意的是,硬限制的功能
6 v4 H; l- d/ X' I9 ?8 F' o, t5 y//将不会影响销共享。! j! W4 z5 x) e2 `8 w' R
//注意:默认设置为一个传统的硬件数控机器。z轴首次明确,其次是X和Y。' z/ k; p0 [$ Y' Z2 D3 ?+ ?

: ^' ]  h4 g# U4 J/ I
5 X4 |8 c. B! z# @1 Y#define SAFETY_DOOR_SPINDLE_DELAY 4000: u7 f3 h$ U' C/ z, R' U- W3 n
#define SAFETY_DOOR_COOLANT_DELAY 1000
0 H( C* c# n1 ?. b. `
0 F! c8 v9 V4 q: Z// Enable CoreXY kinematics. Use ONLY with CoreXY machines.
9 b5 e* t' t7 M: B. w+ ]$ Q# H// IMPORTANT: If homing is enabled, you must reconfigure the homing cycle #defines above to
1 R  i, g+ B' k0 y; u9 v" Z5 `//启用CoreXY运动学。只使用与CoreXY机器。1 @9 N% j; l7 d+ i5 f
//重要:如果启用了自动寻的,你必须重新配置导航循环#定义上面: V$ B' K4 y: ]) o7 a, m

9 i2 r& ?4 m4 p7 R( o" G! Y// #define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS)+ I2 H* Q, R8 D/ V3 F6 n) b: v6 f! F. h/ N

5 A& J; e3 v+ k5 X% U4 Q// NOTE: This configuration option alters the motion of the X and Y axes to principle of operation
/ Q7 t6 e5 j+ c+ T' J// defined at (http://corexy.com/theory.html). Motors are assumed to positioned and wired exactly as9 o& [% \. ?' c, ^! A* q+ L
// described, if not, motions may move in strange directions. Grbl assumes the CoreXY A and B motors+ t; b; m0 f9 y' W9 [7 k
// have the same steps per mm internally.
# A& \) N' R( t/ J8 A  U//注意:这种配置选项改变X和Y轴的运动原理,操作
) I2 e2 A# R3 G# E4 o* H4 C//定义(http://corexy.com/theory.html)。汽车被认为定位和连接一样
9 ^: i3 n* c8 U# d//描述,如果没有,运动可能会奇怪的方向移动。A和B Grbl假设CoreXY马达
8 b3 S! e0 y3 [$ y% J//每毫米内部有相同的步骤。
; t! Z* X$ j: j/ ^3 l: N: T' @$ U+ p) ]2 l
// #define COREXY // Default disabled. Uncomment to enable.
' K- f0 F8 d1 o5 G+ [8 h: U: m7 P$ O8 P6 m8 a1 z- U+ o
// Inverts pin logic of the control command pins. This essentially means when this option is enabled
3 O* K5 E4 \- R5 G8 j) w// you can use normally-closed switches, rather than the default normally-open switches.2 R1 `& M$ q9 B$ m9 \2 U
// NOTE: Will eventually be added to Grbl settings in v1.0.
8 V, I4 D$ u( F0 b: E0 n//反转针销逻辑的控制命令。这实质上意味着当启用这个选项
6 Q7 T$ P8 B* H6 \/ @/ N//可以使用闭合开关,而不是默认的常开开关。9 ~6 }  Y( j6 D/ q3 K
//注意:最终将被添加到在v1.0 Grbl设置。
: z! L- {1 u* G, m
' K8 j/ S1 \* X- `2 H5 ^7 |// #define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.
7 U1 J9 L/ D: o: g. k; Z, s9 [) S
+ [1 |) H) ^: C  ?% W% S// Inverts the spindle enable pin from low-disabled/high-enabled to low-enabled/high-disabled. Useful( K! \7 ^# E; N  p2 [8 l6 c
// for some pre-built electronic boards.# a  i; ?- ~/ i& e+ [
// NOTE: If VARIABLE_SPINDLE is enabled(default), this option has no effect as the PWM output and + ]' A$ X  r9 f: ?+ u4 j& o& F
// spindle enable are combined to one pin. If you need both this option and spindle speed PWM, 7 q' J5 a5 l* R
// uncomment the config option USE_SPINDLE_DIR_AS_ENABLE_PIN below.! H* y* E. F5 z* @# g" G
//反转主轴使销从low-disabled / high-enabled low-enabled / high-disabled。有用的: q( y8 n0 s  u/ l/ ~% Z; v
//预构建的电子板。
* O. G) P) [$ t3 Z5 c//注意:如果启用了VARIABLE_SPINDLE(默认),这个选项作为PWM输出并没有影响
9 P  G$ M, r1 q& {5 p//销轴使结合。如果你需要这个选项和主轴转速PWM,' ^7 @0 |" z# [+ e, w
//取消注释以下配置选项USE_SPINDLE_DIR_AS_ENABLE_PIN! u# I" y! T9 ]$ l- I' j
# q5 e- R0 B; H  m  h
// #define INVERT_SPINDLE_ENABLE_PIN // Default disabled. Uncomment to enable.
+ i4 U/ g, o: c& H! C5 t1 x0 x! d0 h+ n5 r5 E
// Enable control pin states feedback in status reports. The data is presented as simple binary of
- g( S0 o2 L  V  ^, s// the control pin port (0 (low) or 1(high)), masked to show only the input pins. Non-control pins on the
) Q! h  D/ R5 S# M// port will always show a 0 value. See cpu_map.h for the pin bitmap. As with the limit pin reporting,
7 T; I1 E! ?0 n// we do not recommend keeping this option enabled. Try to only use this for setting up a new CNC.) G% [1 L6 Y  L7 S- T+ C
//启用控制销状态反馈状态报告。作为简单的二进制数据3 B% k- }+ P5 q2 g; ^5 T) @) v
//控制针端口(0(低)或1(高)),蒙面,只显示输入插脚。非控制性针上
- u+ G! n9 K9 Y/ [+ u+ w# l: C. T. V/ l//端口总是显示0值。看到cpu_map。针位图h。与限制销报告,
- ?. m8 F3 X8 I- L) D' m//我们不推荐保持启用这个选项。尽量只使用这个设置一个新的数控。* p! N3 G% m/ T$ d; l
! H2 L5 |" i0 s
// #define REPORT_CONTROL_PIN_STATE // Default disabled. Uncomment to enable.( X& Y  H7 F8 j' U3 X3 G3 B
  N  j3 t8 C& w" X# J
// When Grbl powers-cycles or is hard reset with the Arduino reset button, Grbl boots up with no ALARM* B# @: E- u$ ]6 y2 K4 \/ [! R
// by default. This is to make it as simple as possible for new users to start using Grbl. When homing
) `# [8 ]* F! z/ ^' [- i/ V// is enabled and a user has installed limit switches, Grbl will boot up in an ALARM state to indicate
9 ^8 E8 o$ c8 I$ ?/ t// Grbl doesn't know its position and to force the user to home before proceeding. This option forces
, K* `8 T3 N& N# P* C7 z- ], V// Grbl to always initialize into an ALARM state regardless of homing or not. This option is more for
9 p: a8 O2 l2 l! g  G0 _4 b// OEMs and LinuxCNC users that would like this power-cycle behavior.
) R. {1 L8 t' B+ a//当Grbl powers-cycles还是硬重置Arduino复位按钮,Grbl启动没有报警: W* H- o0 G+ ^. }9 t' o) w
//默认情况下。这是为了让新用户尽可能简单使用Grbl开始。当归航
1 J7 s- C$ i9 j4 p4 e6 U' ]//启用和用户安装限位开关,Grbl将启动报警状态指示+ ~9 Q" j) E: c
// Grbl不知道它的位置,迫使用户在继续之前回家。这个选项部队
8 U/ A* ~& L4 U" R- a# [2 N// Grbl总是初始化进入警报状态不管归航。这个选项是更多
0 `5 Z+ Y$ F) ?- X- i- t//原始设备制造商和LinuxCNC用户这样的控制行为。  N( S; N3 c  {1 Z$ ~

: }0 S0 z' l6 c: G; M// #define FORCE_INITIALIZATION_ALARM // Default disabled. Uncomment to enable.8 I& z% \- I( X! w3 b  A+ N% e' E
# b  k, ]9 }3 H2 [+ Y3 h
// ---------------------------------------------------------------------------------------( V  N7 Q8 x- K4 Y$ r3 w" X
// ADVANCED CONFIGURATION OPTIONS://高级配置选项:
' y4 \8 u- t; B- f: k5 x1 O' g. }
+ B: o, b% c$ L, D* A- I// Enables minimal reporting feedback mode for GUIs, where human-readable strings are not as important.
6 l  C/ d. U; |// This saves nearly 2KB of flash space and may allow enough space to install other/future features.
1 x% r* s& J+ s$ s// GUIs will need to install a look-up table for the error-codes that Grbl sends back in their place.
5 r7 L1 c, a8 B/ y// NOTE: This feature is new and experimental. Make sure the GUI you are using supports this mode.
* j2 `9 S8 F& `: u/ }) j0 N* `) A; d% y( G2 z
// gui允许最小的报告反馈模式,人类可读的字符串在哪里不重要。
& j1 O) y' O  O# U6 o! r//这个节省近2 kb的闪存空间,允许足够的空间来安装其他/未来的功能。  Z" u. W5 @3 M  D5 i& }6 H# w; b
// gui需要安装一个查找表的错误代码Grbl发回。. j, b8 S8 X9 J; Z) c
//注意:此功能是新的和实验。确保您使用的GUI支持这种模式。; A, ]* O& U% i7 D
- n0 b0 @; M  W* o& _4 |7 c
// #define REPORT_GUI_MODE // Default disabled. Uncomment to enable.
' N8 r% Q3 p/ |8 B7 ^3 f  p8 H7 C
// The temporal resolution of the acceleration management subsystem. A higher number gives smoother
! t; p! Y5 [9 o; D/ y( h# f1 x- L// acceleration, particularly noticeable on machines that run at very high feedrates, but may negatively2 w. \# a+ Y4 M5 U" J+ o
// impact performance. The correct value for this parameter is machine dependent, so it's advised to$ l: @. S7 h: i: k4 t
// set this only as high as needed. Approximate successful values can widely range from 50 to 200 or more.
" H. B; [2 ^+ M8 [// NOTE: Changing this value also changes the execution time of a segment in the step segment buffer. ! j% s! Z: x8 q5 M
// When increasing this value, this stores less overall time in the segment buffer and vice versa. Make: j! [6 m2 `* X2 V( |  w5 L
// certain the step segment buffer is increased/decreased to account for these changes.
8 \% @( r4 x; J8 M9 e/ C: m//加速度的时间分辨率管理子系统。更多更平稳4 r* U  M0 v8 A: u
//加速度,特别明显的机器上,运行在非常高的进料速度,但可能负面
  b* p& m1 I7 a7 X% j9 ?# L//影响性能。正确的值为这个参数是依赖于机器的,所以建议
% K. e+ X  H7 p" x! `! b" p//这只设置为高。近似成功的价值观可以广泛的范围从50到200或者更多。
) s) O4 C2 S2 X' Y- ]  ~! g//注意:改变这个值也变化的部分步骤的执行时间缓冲。
) k7 \  `  W5 A! [  q//增加这个值时,这个商店部分缓冲区的总时间减少,反之亦然。使
9 M2 v  [  s- L6 U2 e4 b# W//特定步骤段缓冲是考虑这些变化增加/减少。
; P$ g; {0 W5 J0 O  o( ?" I5 r7 E
5 F: _4 h, W  j: z+ V8 f#define ACCELERATION_TICKS_PER_SECOND 100  //加速度的时间分辨率管理子系统。更多更平稳: g& _) j0 {! ]  F

6 q& d+ F" K; ~) g- D9 l// Adaptive Multi-Axis Step Smoothing (AMASS) is an advanced feature that does what its name implies, ) a* h, v9 |% q& W0 ~9 Q$ u. X- }
// smoothing the stepping of multi-axis motions. This feature smooths motion particularly at low step2 ^% m# j. |, h0 Q0 B& I
// frequencies below 10kHz, where the aliasing between axes of multi-axis motions can cause audible
; b& u5 f! a! O$ d// noise and shake your machine. At even lower step frequencies, AMASS adapts and provides even better/ w' m  x* T+ G: P8 F9 K
// step smoothing. See stepper.c for more details on the AMASS system works.
8 h; [8 I  J2 p. b& W0 m: i//自适应多轴步平滑(积累)是一种先进的功能,它的名字所暗示的那样,
0 j3 C+ W+ P& p, Y4 {5 ^+ j$ V//平滑的多轴步进运动。这个特性平滑运动尤其是在低一步6 B0 u+ Y. M  T- x1 W% S1 K
//频率低于10 khz,轴之间的混叠的多轴运动可能导致音响
4 {! k$ I- _- ]1 r" H//噪音和震动你的机器。在更低的频率步,积累适应并提供更好' _1 R# l& O2 A
//步骤平滑。看到步进。c更多细节的积累系统的工作原理。* J/ G; L8 {% J  e, y+ L4 e
: @% A2 A! c3 s
#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING  // Default enabled. Comment to disable.//自适应多轴步平滑% k' m9 J  [: n  ~" c6 ]

9 n0 g/ ?( H& ^4 Z- I// Sets the maximum step rate allowed to be written as a Grbl setting. This option enables an error
4 k1 x4 E0 ~/ l+ F; k// check in the settings module to prevent settings values that will exceed this limitation. The maximum
& T, b3 `% e! c3 h// step rate is strictly limited by the CPU speed and will change if something other than an AVR running* O3 i* M8 F3 R2 _' F8 L2 N2 u" Y8 u
// at 16MHz is used." u# }. n/ ?. m3 ~7 O
// NOTE: For now disabled, will enable if flash space permits.
3 L1 Y" z: Q0 w2 c- w//设置最大一步速率可以写成Grbl设置。这个选项可以使一个错误
/ }! g. p# o0 x4 y//设置模块中检查,防止设置值将超过这个限制。的最大, i/ l3 S# L) ?. \* M
//步骤严格限制的CPU速度也会改变如果是其他AVR运行, {) C; u: A( g0 }, Q  D1 F3 K1 p
//使用16兆赫。
; i: D# l* k( {$ |" k& A//注意:现在残疾,将使如果flash空间许可。: a7 X9 `& E! C

/ Y$ ?' v' f2 }* g( F// #define MAX_STEP_RATE_HZ 30000 // Hz 设置最大一步速率
& p. D2 i4 p) r8 M
5 Q0 ^: q7 D0 I7 l! C7 @// By default, Grbl sets all input pins to normal-high operation with their internal pull-up resistors: C( x: i- k: `" H
// enabled. This simplifies the wiring for users by requiring only a switch connected to ground, , o3 k1 ~' M; E5 I
// although its recommended that users take the extra step of wiring in low-pass filter to reduce7 P) V0 q! _( }8 B2 d
// electrical noise detected by the pin. If the user inverts the pin in Grbl settings, this just flips
! b' [* L3 j1 @1 \' d// which high or low reading indicates an active signal. In normal operation, this means the user ; p/ u, U+ r5 |" Q
// needs to connect a normal-open switch, but if inverted, this means the user should connect a # o+ v/ w6 [# M9 i% T3 ]& S
// normal-closed switch.
5 A1 H4 R. l/ p6 _2 v2 D: b// The following options disable the internal pull-up resistors, sets the pins to a normal-low " C- z1 q' n& b( E* F3 t# G
// operation, and switches must be now connect to Vcc instead of ground. This also flips the meaning
; D/ F* Y1 r( K. K5 w// of the invert pin Grbl setting, where an inverted setting now means the user should connect a
+ W/ t4 T8 j$ z" R( n* e// normal-open switch and vice versa." j; H" K" v1 g5 e. ^
// NOTE: All pins associated with the feature are disabled, i.e. XYZ limit pins, not individual axes.  H7 s- e: G4 h- @* D: o7 l* {
// WARNING: When the pull-ups are disabled, this requires additional wiring with pull-down resistors!
& q6 W- g  |  d! }/ F9 B//默认情况下,Grbl所有输入引脚设置为正常高操作的内部上拉电阻+ f: F" x1 {' ?3 [7 O
//启用。这简化了布线为用户只需要一个开关连接到地面,
! L8 C# d8 Q3 ]//虽然其建议用户采取额外的步骤,在低通滤波器来减少布线
' c2 l" l) ]& x1 G//电噪音检测销。如果用户反转的销Grbl设置,这只是翻转
& ?6 J' }) ^) x7 T8 ]2 x5 A& |//读高或低表明一个积极的信号。在正常操作中,这意味着用户
9 s- D$ z; f) y) ?: N3 l- g5 a" A) N//需要连接一个常开开关,但如果倒,这意味着用户应该连接
1 y0 C, O5 J; L+ t0 g. W! S// normal-closed开关。& h5 }  ^2 r, C
//以下选项禁用内部上拉电阻,一般低设置别针( C+ K5 K- T6 b
//操作,现在开关必须连接到Vcc代替地面。这也掀的意思
5 e5 K8 r- L) \* l  e3 D//反销Grbl设置,一个倒置的设置现在意味着用户应该连接
# A: n" K/ f1 M4 b/ P4 t3 g6 e//常开开关,反之亦然。
/ e% n: Z1 _, U( S  T; f1 Y+ U//注意:所有针与功能被禁用,例如XYZ限制针,而不是单独的轴。0 m9 p$ b& J( X& P' k8 s
//警告:引体向上被禁用时,这需要额外的布线与下拉电阻!
2 b+ k! c3 t1 y, Z# e1 ^5 L0 ~, X2 H8 h$ g- ]
//#define DISABLE_LIMIT_PIN_PULL_UP //以下选项禁用内部上拉电阻& [8 C  E/ ?* k/ e
//#define DISABLE_PROBE_PIN_PULL_UP: M7 u# ?+ [4 T. q$ u6 F
//#define DISABLE_CONTROL_PIN_PULL_UP5 C' ~) p, n/ j/ \

1 V% k6 O2 A( U6 d& V// Sets which axis the tool length offset is applied. Assumes the spindle is always parallel with
) |1 h, c) i' ^. B) ~+ b; p// the selected axis with the tool oriented toward the negative direction. In other words, a positive/ u* H: y- W: [+ S
// tool length offset value is subtracted from the current location.+ n, c8 h3 R! v  x- C6 p- L# c
//设置哪个轴长度补偿应用的工具。假设轴总是与
- y1 s- _8 T9 A3 @% i) I( N( U7 g8 A//选择轴工具面向负方向。换句话说,一个积极的
6 H- R# @% R8 P9 Z* \) W! Z3 l//工具长度偏移值减去从当前位置。
' d# {2 _6 r+ ?! x7 z9 g/ T0 c9 y+ l" u  [3 {" _. K
#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS // Default z-axis. Valid values are X_AXIS, Y_AXIS, or Z_AXIS.设置哪个轴长度补偿应用的工具
$ c# v/ G; Q$ B5 J: q* P9 r. e
// Enables variable spindle output voltage for different RPM values. On the Arduino Uno, the spindle
* y7 |; e) `: W+ s6 h& x$ F1 F// enable pin will output 5V for maximum RPM with 256 intermediate levels and 0V when disabled.( g, Y9 @- _5 M  L: t: ^) B
// NOTE: IMPORTANT for Arduino Unos! When enabled, the Z-limit pin D11 and spindle enable pin D12 switch!
8 c9 a. W( v" q+ H' T$ J// The hardware PWM output on pin D11 is required for variable spindle output voltages.; R% z7 e; Y- V- s3 K& l- S1 K
//允许变量轴输出电压不同的转速值。Arduino Uno,主轴
; a" {/ }9 Z8 s" {+ ], D$ A% J//启用销将输出5 v的最高转速256中级水平和0 v时禁用。
% ~2 ]8 G* ~% H6 L' ], d, ]8 Y//注意:重要Arduino凯泽本人!当启用时,Z-limit销这里和轴销D12开关!
( v& O, a5 s+ N" d+ x//硬件PWM输出销这里需要变量轴输出电压。- j' w. y: q& G& \3 y& L
' K; Z; ^  I: b# v0 C
#define VARIABLE_SPINDLE // Default enabled. Comment to disable.//允许主轴输出电压不同的转速值1 G4 }  H) v$ c, S

! ^& g7 S+ L* ]2 W' u// Used by the variable spindle output only. These parameters set the maximum and minimum spindle speed
/ P' u! K( i8 `// "S" g-code values to correspond to the maximum and minimum pin voltages. There are 256 discrete and
# r& @3 W  U( }# O// equally divided voltage bins between the maximum and minimum spindle speeds. So for a 5V pin, 1000: N( G2 T; E6 E4 j
// max rpm, and 250 min rpm, the spindle output voltage would be set for the following "S" commands:
0 h4 v/ y5 V+ x  {, x" U// "S1000" @ 5V, "S250" @ 0.02V, and "S625" @ 2.5V (mid-range). The pin outputs 0V when disabled.  o- L& p* V9 y+ ^& ^
//使用的变量轴输出。这些参数设置最大和最小轴转速
5 t5 ~' R0 I% l+ @% H//“S”刀位点值对应于销电压的最大值和最小值。有256个离散和
, N& x  _; K1 ]: T; d- I# R//电压平均分配箱主轴速度的最大值和最小值之间。所以对于一个5 v销,10007 p/ {) N1 |; B6 q4 [5 p) T
// max rpm,250分钟rpm,主轴输出电压将为以下“S”命令:
& ]& I% E" @$ G0 e// @“S1000 5 v,“S250”@ 0.02 v,“S625”@ 2.5 v(中档)。销输出0 v时禁用。9 S" E: A6 A* k, H# _- }
( |- u% y5 b- t0 b! D( N! F8 H
#define SPINDLE_MAX_RPM 1000.0 // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.& N9 g' J3 ]3 p5 b' W3 B' A
#define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.
7 n2 \% B8 }1 P% [+ n' d3 x7 V. f) x+ j+ Q$ |$ u
// Used by variable spindle output only. This forces the PWM output to a minimum duty cycle when enabled.1 i( j% O* d+ G  G, N1 {
// When disabled, the PWM pin will still read 0V. Most users will not need this option, but it may be 8 _  J' s# x/ t
// useful in certain scenarios. This setting does not update the minimum spindle RPM calculations. Any: x2 I- y1 S3 p5 a' s' x
// spindle RPM output lower than this value will be set to this value.) L: C  [* r& ?# a: y8 z# d' ?
//使用的变量轴输出。这迫使PWM输出最小占空比时启用。
! K2 W, m. y) h0 j//当禁用,PWM销仍读0 v。大多数用户不需要这个选项,但是它可能是' q$ }% N" I% s( B# w  U, v
//在某些情况下很有用。这个设置不会更新最小主轴转速计算。任何
) o5 Y; f: o1 P6 o; E//输出轴转速低于这个值将被设置为这个值。
; D1 F! M: O5 ]' |
( q* H% b8 `7 d0 Z6 O& H// #define MINIMUM_SPINDLE_PWM 5 // Default disabled. Uncomment to enable. Integer (0-255)- M/ F7 ^5 }# G, `9 t" v

+ Q% ~) b' l0 S- v8 d6 Q1 `// By default on a 328p(Uno), Grbl combines the variable spindle PWM and the enable into one pin to help
# Y( q' d1 Y0 N; h3 `$ Q" m: k6 z// preserve I/O pins. For certain setups, these may need to be separate pins. This configure option uses
# B8 L' q1 X0 R+ c$ \7 `// the spindle direction pin(D13) as a separate spindle enable pin along with spindle speed PWM on pin D11. # v+ W- F6 U$ U2 P
// NOTE: This configure option only works with VARIABLE_SPINDLE enabled and a 328p processor (Uno). ) Q5 z9 r- u" s' n. Q" T6 ]
// NOTE: With no direction pin, the spindle clockwise M4 g-code command will be removed. M3 and M5 still work.
) d8 I0 M4 Z8 `9 C9 t2 C$ B7 o+ {// NOTE: BEWARE! The Arduino bootloader toggles the D13 pin when it powers up. If you flash Grbl with
4 h6 i  w2 d1 o4 L# U8 ~) D// a programmer (you can use a spare Arduino as "Arduino as ISP". Search the web on how to wire this.),
/ D- n- h; T/ D3 R// this D13 LED toggling should go away. We haven't tested this though. Please report how it goes!: q& V; k7 x; U! E
//默认ATmega328 p(Uno),Grbl结合变量轴PWM和使到一个销的帮助+ D  Z& u/ w: ?+ Y0 P4 G, X
//保存I / O管脚。对于某些设置,这些可能需要单独的别针。这个配置选项使用
$ @1 E+ |7 f/ }; V7 o, O4 L9 [) ]) V//方向轴销(D13)作为一个单独的轴销上启用销以及主轴转速PWM这里。
7 }; W& ^, I. @. N; |, G( S//注意:该配置选项仅适用于VARIABLE_SPINDLE启用和328 p处理器(Uno)。
7 z: V1 r6 h  F//注意:没有方向销,主轴顺时针M4刀位点命令将被删除。M3和M5仍然工作。( j/ \5 \+ q9 T  J2 b3 E
//注意:小心!Arduino引导装载程序切换D13销的权力。如果flash Grbl1 t: e) t' r) U* _; _+ g& x4 L
//程序员(您可以使用一个备用Arduino“Arduino ISP”。搜索网络如何线),
- P- o3 T& u, k; }$ ~1 l: H* y; V( V//这D13导致切换应该消失。我们还没有测试这个。请报告将会怎样!2 d+ u$ }. `3 o- p" K( x' A4 K

+ ~. {4 P  S! a- h2 c// #define USE_SPINDLE_DIR_AS_ENABLE_PIN // Default disabled. Uncomment to enable.
( |& U3 k0 X6 {
2 m: y+ }( E3 j, y# F// With this enabled, Grbl sends back an echo of the line it has received, which has been pre-parsed (spaces  b( t: _$ E$ Z7 a( T( ]4 a
// removed, capitalized letters, no comments) and is to be immediately executed by Grbl. Echoes will not be 4 W$ P  o6 I7 r% I2 {7 Z( E
// sent upon a line buffer overflow, but should for all normal lines sent to Grbl. For example, if a user 1 c) ]# Q+ E4 ~
// sendss the line 'g1 x1.032 y2.45 (test comment)', Grbl will echo back in the form '[echo: G1X1.032Y2.45]'.
' C# c# v/ r6 B4 T$ [( x// NOTE: Only use this for debugging purposes!! When echoing, this takes up valuable resources and can effect
: w3 `1 C/ [0 n3 j// performance. If absolutely needed for normal operation, the serial write buffer should be greatly increased
' c/ [# m8 V6 y% H# W: f% [8 T// to help minimize transmission waiting within the serial write protocol.
$ W; {+ r, m8 `# C* Y* K: F* N. c; H" V9 m3 Q6 w3 V
//启用,Grbl发回的回声线已收到,已预编译(空间& x8 u& ^. e. B" Z& l- d; _7 B4 r
//移除,大写字母,没有评论),由Grbl立即执行。回声将不会# s5 g) z; d1 n& {, d& N6 a( S1 V
//发送一个线缓冲区溢位,但应该对所有正常线路送到Grbl。例如,如果一个用户
' V0 L& Y9 E% |$ U0 I//发送线的g1 x1.032 y2.45(测试评论)形式”,Grbl将回声”(回声:G1X1.032Y2.45]”。1 m' h. N: P% o8 R
//注意:只使用这个调试! !当呼应,这占用了宝贵的资源,可以影响
7 u9 L" A3 c6 p9 l( J3 G//性能。如果正常运行所需的绝对,串行写入缓冲器应该大大增加$ \% A8 y3 v! A0 x3 Z
//帮助最小化传输等系列内写协议。* j* p5 S/ T5 C% k. w
7 ?8 O& l* g8 z/ f$ Q6 y8 N6 h
// #define REPORT_ECHO_LINE_RECEIVED // Default disabled. Uncomment to enable.
# d8 v  _7 F% e3 s/ I* u! x# I, h3 J6 x, d) C! R: c
// Minimum planner junction speed. Sets the default minimum junction speed the planner plans to at
( Q* I0 ^" Y2 j) Q* s0 |// every buffer block junction, except for starting from rest and end of the buffer, which are always0 [0 ]' M% u8 W( w) `
// zero. This value controls how fast the machine moves through junctions with no regard for acceleration
, Y* o, y# A. c; u( ?8 {2 L// limits or angle between neighboring block line move directions. This is useful for machines that can't# }0 Q0 ^( a3 O* s
// tolerate the tool dwelling for a split second, i.e. 3d printers or laser cutters. If used, this value
- I5 o7 ]- W) N( [; }// should not be much greater than zero or to the minimum value necessary for the machine to work.6 r( J* s5 @* s8 P& |0 V

6 _* m/ v/ I7 }, C" k" W0 G//最小规划师结速度。设置默认最小连接速度规划计划1 k- D! _# H" N; \9 n  e* S
//每一个缓冲块接头,除了从结束休息和缓冲区,它总是; ?* O4 t5 N# ~2 V4 l
// 0。这个值控制机器的速度穿过路口,没有考虑加速度
  `3 |; \: G" ]! O2 X- H//限制或相邻块之间的角线方向移动。这是有用的机器,不能
# d" h3 s/ A# C//容忍工具居住某一刹那,即3 d打印机或激光切割机。如果使用这个值1 [+ x) v) _. Q& U* ^5 [3 _) @
//不应大于零或机器工作所需的最小值。8 H3 y6 u8 ?3 P& m

( ~% v# h$ q- m  V/ y) w2 {+ `#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min)( C) i3 s$ s$ I  X  e/ G
( M# c5 h1 {! h. h" j
// Sets the minimum feed rate the planner will allow. Any value below it will be set to this minimum1 @* N* R7 n3 N" N, h
// value. This also ensures that a planned motion always completes and accounts for any floating-point
* [: Y, ]* y# g2 m) m, |' A// round-off errors. Although not recommended, a lower value than 1.0 mm/min will likely work in smaller) Y! w6 W! R' |9 v7 {
// machines, perhaps to 0.1mm/min, but your success may vary based on multiple factors.. m; A9 y* c2 U7 q" J
//设置计划将允许的最小进给速率。任何价值低于它将被设置为最低值。这也保证了运动计划总是完成,占任何浮点
2 l* d% X1 f) d8 ~$ W7 V" l//舍入错误。虽然不推荐,价值低于1.0毫米/分钟可能会在较小的工作
! O# W1 g6 y$ U  ~, J: k+ i0 J* R//机器,也许到0.1毫米/分钟,但你的成功基于多种因素可能会有所不同。
  ~) j! ?! S0 @0 {: s! I" V: n
& w. g- o) |) P7 r0 P: [#define MINIMUM_FEED_RATE 1.0 // (mm/min)//设置计划将允许的最小进给速率; R3 o. k* ?8 b8 F3 r

+ d8 I0 W6 U$ N4 ]// Number of arc generation iterations by small angle approximation before exact arc trajectory 6 \$ K, H1 Y' v  U7 ~4 b3 E! E
// correction with expensive sin() and cos() calcualtions. This parameter maybe decreased if there % f* {3 d' e3 ^- n  r2 I4 R9 m
// are issues with the accuracy of the arc generations, or increased if arc execution is getting! I8 i; f# u# ^0 o* i" m# x
// bogged down by too many trig calculations. 1 U% E1 U. S7 z! e, V
//弧生成迭代次数之前小角度近似精确的弧线轨迹
0 _+ W, k3 |1 V2 s7 t//修正与昂贵的sin()和cos()calcualtions。如果有这个参数可能减少
2 j6 u3 S- \) X9 K& o//与弧一代又一代的准确性问题,或如果电弧执行得到增加) K0 V' t+ `7 D1 \  \
//太多的三角计算的泥潭。
/ @6 r+ q0 ~8 v" A0 {- W" [/ I4 x/ g, P# Q0 {- O
#define N_ARC_CORRECTION 12 // Integer (1-255)2 a5 x: W8 q  v8 D' ]: x) l

& {! B0 h9 x, V% }4 d' a7 J& `# ^// The arc G2/3 g-code standard is problematic by definition. Radius-based arcs have horrible numerical
, W& Z  n. A5 }: M// errors when arc at semi-circles(pi) or full-circles(2*pi). Offset-based arcs are much more accurate
+ b+ `; V2 z2 Z1 n2 y// but still have a problem when arcs are full-circles (2*pi). This define accounts for the floating
5 G) |- m! C5 Y7 U0 _// point issues when offset-based arcs are commanded as full circles, but get interpreted as extremely
7 [& Y- [! H3 Y3 ]. I// small arcs with around machine epsilon (1.2e-7rad) due to numerical round-off and precision issues.
" c$ ~- J- l& f$ A* ^$ P// This define value sets the machine epsilon cutoff to determine if the arc is a full-circle or not.( o1 x7 [# H0 m  y- \2 @
// NOTE: Be very careful when adjusting this value. It should always be greater than 1.2e-7 but not too
! T6 o% z" V: v// much greater than this. The default setting should capture most, if not all, full arc error situations.! v$ ^* Q# u" N5 c4 M% k
//弧G2/3刀位点的标准定义是有问题的。Radius-based弧有可怕的数值  `$ a$ ]* s0 H9 ]) r' o2 p9 F
//错误当电弧在半圆(π)或原点(2 *π)。Offset-based弧更准确4 f! C+ h6 M- z; i; u
//但仍有一个问题当弧原点(2 *π)。这个定义占浮动
! W" ?& N3 U7 A( L//当offset-based弧吩咐点问题完整的圆,但解释为极4 i( D; M* i  x) B
//小弧机周围ε(1.2 e-7rad)由于数字舍入和精度问题。  E0 O% e- }" O7 `3 m
//定义值设置机器ε截止来确定电弧是一个原点了。
" x; V' X- J2 C4 e3 E//注意:调整这个值时非常小心。它应该总是大于1.2 e -但不要太9 I! K6 }6 G8 c" V
//比这大得多。默认设置应该捕获大部分,如果不是全部,全部错误的情况。
3 M# R0 d+ H7 R5 M/ a5 K) r
# Q7 s% c0 y$ G* `#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)3 ]& ]2 P% K  D+ G

  y5 y; h8 |/ Z8 `+ v// Time delay increments performed during a dwell. The default value is set at 50ms, which provides0 f! J. b5 }7 B% [" W6 k; s
// a maximum time delay of roughly 55 minutes, more than enough for most any application. Increasing% Z; p9 G  l4 r; o/ _; F1 t2 W3 H
// this delay will increase the maximum dwell time linearly, but also reduces the responsiveness of
5 M2 F- T- Q- I6 |// run-time command executions, like status reports, since these are performed between each dwell . m8 Z" Q2 ~7 v( V2 E
// time step. Also, keep in mind that the Arduino delay timer is not very accurate for long delays.( p1 l  ^9 \0 {( f- |
//延时增加表现在住。默认值设置为50毫秒,它提供了
. u# w! ^, |1 q//最大延时约55分钟,足够对大多数任何应用程序。增加* a) R# l* }. e! ]8 t1 d4 a
//这种延迟将增加线性最大停留时间,也减少了响应能力
( E8 A. B* k! ^! r# \2 Q& n//运行命令执行状态报告一样,因为这些每个住之间执行
! a& s# R3 e5 \1 Z5 a//时间步。还有,记住,Arduino延迟计时器不是很准确的长时间延误。
! _0 e/ _! v* v! }+ A9 E8 O; A- Q# K7 N/ C* p6 T0 B6 c/ e
#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds)9 g& h6 l6 a+ q, z) T  N. K
( m/ z% h, S- j$ H7 w0 N' x0 p
// Creates a delay between the direction pin setting and corresponding step pulse by creating/ j# E: \  _1 e6 o& e4 F$ R; m
// another interrupt (Timer2 compare) to manage it. The main Grbl interrupt (Timer1 compare)
) I9 _3 v6 G% ~+ H// sets the direction pins, and does not immediately set the stepper pins, as it would in
- `8 y" w# r, L. D// normal operation. The Timer2 compare fires next to set the stepper pins after the step
+ ^# D. a. q, G$ `: n9 z; {// pulse delay time, and Timer2 overflow will complete the step pulse, except now delayed
) T1 T, J" q5 w' \' _# F// by the step pulse time plus the step pulse delay. (Thanks langwadt for the idea!)$ X3 _2 \# F) z, ?3 ?  j
// NOTE: Uncomment to enable. The recommended delay must be > 3us, and, when added with the# ~0 W7 f% r1 A) p- A. k1 d- J' N
// user-supplied step pulse time, the total time must not exceed 127us. Reported successful
7 H" _- q3 G/ i6 E$ Z// values for certain setups have ranged from 5 to 20us." y0 i- V# _$ ~* n
//创建一个方向销之间的延迟脉冲通过创建设置和相应的步骤
) t( w' q4 Q  ^$ |5 S//另一个中断(Timer2比较)来管理它。主要Grbl中断(Timer1比较)" r( R) G+ @- y# n) @
//设置方向针,不立即设置步进针,因为它会在/ W7 y2 ~+ M: A+ t% S+ a
//正常操作。Timer2比较火旁边设置步进针后一步' R1 i8 y0 q, a6 \3 o5 O( v
//脉冲延迟时间,Timer2溢出脉冲将完成的步骤,现在延迟除外
9 E. t/ [- l7 z! w//脉冲时间加上的一步一步脉冲延迟。(感谢langwadt主意!)
+ X' f: B( ~1 r8 u4 H, Q% C5 F3 }//注意:取消启用。必须> 3,建议延迟,当添加的9 e; |( I* \; r$ F$ N6 S" A$ e
//用户提供的步骤脉冲时间,总时间不得超过127美元。成功的报道& V* [% E! n% U) O
//值对某些设置范围从5到20。
# W; y: s+ j& Y( ~
. P; _$ u& c# x$ G, m! q// #define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.
$ V% ]$ |4 n# ^: Y  d! B* `
; N8 R8 h7 i% c) b2 F// The number of linear motions in the planner buffer to be planned at any give time. The vast
5 F3 e# d8 R" B" ~9 L/ n1 C// majority of RAM that Grbl uses is based on this buffer size. Only increase if there is extra & I$ ^  x, b- ]6 _) \+ B
// available RAM, like when re-compiling for a Mega or Sanguino. Or decrease if the Arduino
1 l4 b& i/ T( l, b// begins to crash due to the lack of available RAM or if the CPU is having trouble keeping. Z% {" L* p4 R" F# G, W
// up with planning new incoming motions as they are executed.
+ {' ~. Y! J7 h4 _//线性运动规划师缓冲区的数量在任何给出时间计划。绝大/ O/ c$ S& X1 V- D/ x  o6 N! r
//多数RAM Grbl使用基于这个缓冲区的大小。如果有额外的只会增加
3 T6 d7 `7 ^" E4 H. L9 z7 q2 q//可用内存,比如当基于大型或Sanguino。如果Arduino或减少
( G) d/ i, B( d9 n& q! G//开始崩溃由于缺乏可用的RAM或者CPU是难以保持! ?  x7 w1 T9 ?$ G/ a3 _- l7 f8 i
//与规划新传入的动作执行。+ u0 I0 i& z1 c- O# R: W

: E3 {3 H, b$ z6 c  z# a/ g" e+ g// #define BLOCK_BUFFER_SIZE 18  // Uncomment to override default in planner.h.2 N, L" a7 N0 o6 q3 g1 O6 ?& S; d
- m1 p  y6 v' o+ Y# n% g5 T% G
// Governs the size of the intermediary step segment buffer between the step execution algorithm+ r; v& c3 H$ k" d
// and the planner blocks. Each segment is set of steps executed at a constant velocity over a
& g! y, o' H* r7 z2 _' I// fixed time defined by ACCELERATION_TICKS_PER_SECOND. They are computed such that the planner# h' @* m: [" X& c8 r! n5 `  ~# n9 C# e
// block velocity profile is traced exactly. The size of this buffer governs how much step
# n  n' o! A: w& `3 g! o// execution lead time there is for other Grbl processes have to compute and do their thing
; H$ ?! G) y9 c, N( g) t* a' y' `// before having to come back and refill this buffer, currently at ~50msec of step moves.
/ w8 ]9 H* @0 W; `1 s, r9 u//控制之间的中间段缓冲大小的步骤执行算法
  @. m2 G" B4 U* b//和规划师块。每一部分的步骤执行在一个恒定的速度  F1 s' O) p* M9 g9 T- r
//固定的时间由ACCELERATION_TICKS_PER_SECOND定义的。他们计算的计划
8 b+ x6 |6 p$ j2 W//块速度剖面追踪到底。这个缓冲区的大小控制多少步骤
1 |- {4 A+ w# O( c! J/ g7 r+ o9 L" l( n//执行时间有其他Grbl过程需要计算和做他们的事情; V% N" {! F% s( y4 |7 j! G2 w3 }' A
//之前必须回来重新填充这个缓冲区,目前移动~ 50毫秒的一步。
6 _/ Z  ?& e( }* d- g; ?1 l% Q; M5 O  l( ~$ M7 j
// #define SEGMENT_BUFFER_SIZE 6 // Uncomment to override default in stepper.h.* X8 Q/ s6 K( X3 D' U1 m% @
( R0 J5 c. s/ C$ s
// Line buffer size from the serial input stream to be executed. Also, governs the size of 3 o9 `. x; b% j! l* @3 E! \4 G; Z
// each of the startup blocks, as they are each stored as a string of this size. Make sure
- L3 A) b& ~$ c6 X1 R: D+ Z// to account for the available EEPROM at the defined memory address in settings.h and for
3 w: q: L0 f6 ~7 k5 E// the number of desired startup blocks.$ x6 w) Z1 V. K# P3 J; R- h3 C
// NOTE: 80 characters is not a problem except for extreme cases, but the line buffer size
# {, `/ X' T9 z; A+ `, |5 Y// can be too small and g-code blocks can get truncated. Officially, the g-code standards
  O+ g+ U3 o# u$ n' W  K. Z1 w) T& ^// support up to 256 characters. In future versions, this default will be increased, when " q; [! ?$ b' N) c
// we know how much extra memory space we can re-invest into this.. _6 o# V; D2 {! A) D+ H
//行执行串行输入流的缓冲区大小。同时,大小的控制
# R0 I% }" g! o! k. M. ^/ A//每个启动模块,它们分别存储为字符串的大小。确保
3 ^: y8 l& c" c  X0 v5 q8 D& }//占可用eepm定义内存地址的设置。h和- q+ U/ [1 l+ ^" M6 J: l9 Y
//需要启动块的数量。
, ~" @9 H" B/ R//注意:80个字符不是一个问题,除了极端的情况下,但线缓冲区大小
6 U' V% z/ e, W4 k2 `- N% }//可以太小和刀位点块可以截断。正式,刀位点标准$ V/ F& o2 \/ {; r3 r
//支持多达256个字符。在未来的版本中,这个违约将会增加,当4 v. `; W9 M+ f" k
//我们知道多少额外内存空间的时候我们可以再投资。3 [0 F3 O2 {5 i$ }" l! i
6 H9 t  ]. H6 y2 L' S
// #define LINE_BUFFER_SIZE 80  // Uncomment to override default in protocol.h* M0 B; b( `1 I; F) ~- ?5 y( c& j
  1 o* e7 [$ ?5 j
// Serial send and receive buffer size. The receive buffer is often used as another streaming
" s- f7 d' M& B. Q2 z+ U2 {  L// buffer to store incoming blocks to be processed by Grbl when its ready. Most streaming
. t9 k, Z8 [1 q% P5 o8 I// interfaces will character count and track each block send to each block response. So,
( l9 b% j2 N& P7 k$ F+ i. D, k// increase the receive buffer if a deeper receive buffer is needed for streaming and avaiable( R) Q6 z8 n! s% {0 v& \3 J
// memory allows. The send buffer primarily handles messages in Grbl. Only increase if large
# o6 F6 [" c% Y; j" W9 \, K// messages are sent and Grbl begins to stall, waiting to send the rest of the message.3 S( g2 o7 H$ P; g" Q
// NOTE: Buffer size values must be greater than zero and less than 256.( a- U. ^+ l1 i4 J) ~' i: |
// #define RX_BUFFER_SIZE 128 // Uncomment to override defaults in serial.h" S0 b6 v3 t+ c9 H( _- d
//串行发送和接收缓冲区大小。接收缓冲区通常用作另一个流
1 q$ b  g  y5 v) s0 e//缓冲存储传入的块来处理Grbl当它准备好了。最流
4 F2 C# k8 C+ a9 y' Q$ b//接口将字符计数和跟踪每一块发送给每个块的回应。所以,9 d0 A1 L! J5 W$ S$ g
//增加接收缓冲区如果需要更深层次的接收缓冲区为流,、1 O8 H; \4 j; ^9 d8 L  \# |, ~; ~
//内存允许。Grbl发送缓冲主要处理消息。只会增加如果大9 O' S2 K4 ^/ ^  ~' r
//消息发送和Grbl开始停滞,等待发送其余的消息。
  |# S) r0 K0 S+ O: I//注意:缓冲区大小值必须大于零,小于256。
7 g, n+ m! O* L! r// # define RX_BUFFER_SIZE 128 / /取消serial.h覆盖默认值" ]( b7 X/ S8 ?$ i
" E7 `0 w4 L* h5 H
& o$ u3 y' D* ^3 l
// #define TX_BUFFER_SIZE 64* I- \# S5 b0 ]
  , g) W- b2 a& s$ l7 U% [4 m
// Toggles XON/XOFF software flow control for serial communications. Not officially supported2 U& k. w8 i! P$ h' C
// due to problems involving the Atmega8U2 USB-to-serial chips on current Arduinos. The firmware
0 r* |4 F% H( `+ C( _// on these chips do not support XON/XOFF flow control characters and the intermediate buffer
* R7 @- O! A8 Z/ D' b8 Z// in the chips cause latency and overflow problems with standard terminal programs. However,
, C8 y) m8 G5 f* H// using specifically-programmed UI's to manage this latency problem has been confirmed to work.& U4 O* P$ q. D: o& p
// As well as, older FTDI FT232RL-based Arduinos(Duemilanove) are known to work with standard0 t- q8 U' M& C1 X( Q  Q2 ]
// terminal programs since their firmware correctly manage these XON/XOFF characters. In any2 D* p1 K/ B( |6 H
// case, please report any successes to grbl administrators!
+ c6 k& O- _+ g, C//切换为串行通信发送朴通/发送葡开软件流控制。不是官方支持7 E- z* p& ~; I# M! b
//由于问题涉及Atmega8U2 USB-to-serial当前arduino芯片。固件$ Y* q  G# C. V% n$ U
//在这些芯片不支持发送朴通/发送葡开流控制字符和中间缓冲区; ^* U& ?1 S+ t8 a
//芯片导致延迟和溢出问题的标准终端程序。然而,; R. i" ^3 K/ V
//使用specifically-programmed UI的管理这个延迟问题已经确认工作。. G! e7 z* A% L6 i- r6 G
//以及老FTDI FT232RL-based arduino(Duemilanove)是已知的标准! ?6 a/ p/ |0 {0 W6 r
//终端程序因为他们正确的固件管理这些发送朴通/发送葡开的角色。在任何6 r1 u8 F! P8 _. N5 y8 o# X0 C- \- r
//情况,请报告任何成功grbl管理员!
5 t/ y1 O/ W% y; [/ s$ \% k) Q& N: y8 o2 t: l5 e$ C
// #define ENABLE_XONXOFF // Default disabled. Uncomment to enable.4 y( Q3 B& L9 o
$ }5 r! ?9 u+ v9 r" z/ U
// A simple software debouncing feature for hard limit switches. When enabled, the interrupt 4 b/ [7 x: t6 m$ s: U7 m- Y
// monitoring the hard limit switch pins will enable the Arduino's watchdog timer to re-check
& M' A* c4 R: ^: P; T& N// the limit pin state after a delay of about 32msec. This can help with CNC machines with
  Z2 G7 s8 t" Q* j- v// problematic false triggering of their hard limit switches, but it WILL NOT fix issues with
1 O) p5 h8 Y* Y% M- M// electrical interference on the signal cables from external sources. It's recommended to first! J' z  O4 o% V; d& v( T+ U
// use shielded signal cables with their shielding connected to ground (old USB/computer cables
' ]8 F. g2 Q7 i8 Z// work well and are cheap to find) and wire in a low-pass circuit into each limit pin.% J& r: @% G% x: u, n
//一个简单的软件消除抖动特性硬限位开关。当启用时,中断
- n7 K; {- Q0 }( j//监控硬限位开关针将使Arduino的看门狗定时器重新审视
3 |0 J% F; I% ?//销的极限状态后约32毫秒的延迟。这可以帮助与数控机器( I: L. r( t, \3 ~, C2 P( W7 o* M
//问题错误引发的硬限位开关,但是它不会解决问题
1 \& ?% g0 |4 P6 ]3 u  f//电干扰信号电缆从外部来源。首先它的建议0 n# ^& N* {7 y& _7 A
//使用屏蔽信号电缆的屏蔽连接到地面(老USB /计算机电缆
# m* h2 L# C7 i+ Y* p# C; r//工作得很好,很便宜)和线低通电路到每个限位销。
- ~! `! S2 ^) A
! v! m; B& [- I- \/ ^* p% A// #define ENABLE_SOFTWARE_DEBOUNCE // Default disabled. Uncomment to enable.- T* b) c1 e6 W* J1 t, w

# j. m9 S6 N+ m; I) y6 X- Y: r// Force Grbl to check the state of the hard limit switches when the processor detects a pin6 P1 U5 z0 C* c1 ?5 K8 `  j0 h
// change inside the hard limit ISR routine. By default, Grbl will trigger the hard limits$ s3 U1 a: W! }$ h3 X
// alarm upon any pin change, since bouncing switches can cause a state check like this to
3 G1 ^2 q6 V1 q) p, B( M// misread the pin. When hard limits are triggered, they should be 100% reliable, which is the
0 {  _5 F7 {7 g. q// reason that this option is disabled by default. Only if your system/electronics can guarantee7 @+ ~! O( `+ b
// that the switches don't bounce, we recommend enabling this option. This will help prevent
$ I* K0 S" G- ?: E" \  b% p7 }// triggering a hard limit when the machine disengages from the switch.
( n$ S' O& W! h; q7 s: p// NOTE: This option has no effect if SOFTWARE_DEBOUNCE is enabled.
; m" m# r+ p' {2 _. D8 {4 |//力Grbl检查硬限位开关的状态,当处理器检测到一个销
. ]$ A' @' T- W7 V( M$ g9 _% ]% n//改变内部硬限制ISR例行公事。默认情况下,Grbl将触发硬限制
( {$ d. n. x2 U( T//报警在任何销更改,因为跳开关可以导致这样的状态检查
% \, i4 D% w; f4 s//误读了销。硬限制触发时,他们应该100%可靠,这是
$ p( y6 B2 Z0 m& P! _//原因,这个选项默认是禁用的。只有在你的系统/电子产品可以保证
5 |$ p! K$ G' n2 Y6 L- ^. X//开关不反弹,我们建议启用这个选项。这将有助于防止
9 W& u! T4 i2 \9 o//触发机退出时硬限制开关。
8 e- y/ O' R# G- n$ B' }. `1 j//注意:这个选项如果启用了SOFTWARE_DEBOUNCE没有影响。9 k% P3 \. _9 I3 _/ _2 {
- l: W% G  j$ _8 r4 [( G
// #define HARD_LIMIT_FORCE_STATE_CHECK // Default disabled. Uncomment to enable.; `8 {' A: {$ ]# C! {" `9 t
8 G6 K: n* c7 Q" S7 G: d4 r

6 i: `& n4 t0 c% ?( ~5 U// ---------------------------------------------------------------------------------------
4 d$ t! T8 L+ G* t% A6 u# `8 t// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:编译时错误检查的定义值:) J3 G1 Q( {, i5 p
% r3 y9 \5 S2 ^$ u9 u
#ifndef HOMING_CYCLE_0: V& ^, u. _5 ]  n" }
  #error "Required HOMING_CYCLE_0 not defined."( Q  G$ k3 D: \
#endif
) O/ [' ^" _' q: N8 b3 n: e+ a) L+ Q/ ~, f0 q* l6 b
#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(VARIABLE_SPINDLE)! b/ \& U- H0 k* s$ h0 W) [
  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with VARIABLE_SPINDLE enabled"7 E0 E  b8 [, N! U$ Z2 C. x: s1 ~
#endif
" j9 x# g- h& S5 k6 Y. y" J
+ M. X% n2 X! k. F7 ?#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(CPU_MAP_ATMEGA328P)7 p! N8 }8 e9 y. e7 G! G' n
  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with a 328p processor"4 w/ D# i3 p) @$ h
#endif9 ]5 y; Q, w6 N9 R5 \, G
$ q5 T7 h) J; y" _! h( N
// ---------------------------------------------------------------------------------------! Q  f0 a/ W! {+ y

' C0 y% g8 ]% V2 f/ C0 ?
$ x+ h1 y/ h0 n1 K8 q#endif- @# P. _% O8 d4 n- T! a

( A: |" ~" V: j0 G+ I# g
3 X+ \8 Y8 q% p  l: A5 f3 v1 n' l% U# D  a- I5 ]) Q0 T

% M0 m5 |1 g/ H0 A$ ]/ Y/ v, N/ Y8 ?7 c) c
" j6 f& s; q1 W1 }% h; [# m

# A0 ?* B6 A8 R$ `. q) `  D. a0 r! ]

( [6 B% k) f# K" Y0 c  z$ h1 l8 d: H. ^4 F/ E0 z+ }7 M7 u
1 T- i/ L; Y# D# }

+ o' f  o) z3 }2 d. F  D( L( l- f. j9 D1 ]% v0 V4 S

* c* S) S( |6 \4 q4 I$ a% t) i, r; F) ^8 b3 Q6 }: V6 w) U
) ~% S, n) ?: p1 d3 t% v  y9 s% Q) y2 J/ g

本帖子中包含更多资源

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

×

评分

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

查看全部评分

回复

使用道具 举报

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

4 E  j3 a: M6 B( T9 z3 ?6 {
发表于 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 | 显示全部楼层
补充
5 d# i0 z9 e5 f$ R- z7 }2 S6 k程序运行protocol_execute_realtime(); /运行实时命令。6 \( O! Z: j3 T; [# k
// Executes run-time commands, when required. This is called from various check points in the main
2 a. ^' `3 s+ _% |9 m- W# Q// program, primarily where there may be a while loop waiting for a buffer to clear space or any; Z( S+ N- r! \" D" A( W
// point where the execution time from the last check point may be more than a fraction of a second.  Y% V7 E+ H( V
// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code( A1 \$ g3 {0 W) H! n
// parsing and planning functions. This function also serves as an interface for the interrupts to
- y$ q! q0 v% B. H" x# Q4 J// set the system realtime flags, where only the main program handles them, removing the need to2 P1 H+ \* a3 V
// define more computationally-expensive volatile variables. This also provides a controlled way to
8 E9 t- M3 s4 v6 _. L, \  Z0 a// execute certain tasks without having two or more instances of the same task, such as the planner
* m  i2 @( z* K) c, J// recalculating the buffer upon a feedhold or override.9 `2 \& }: O& ^0 ^0 Z! c
// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,% b/ F+ t1 L2 }, ~7 _
// limit switches, or the main program.
. c3 v! R/ P) i4 K# W
- h8 \- ?+ b0 f  }# r2 `% v" N8 k6 V//执行运行时间命令,在需要时。这就是所谓的从各种主程序要检查站
; j' f' A2 W2 D& D- q6 ~; K//,主要是那里可能是一个while循环等待缓冲区空间或任何
3 V& U$ l; m% v0 |0 n1 z& N//执行时间从过去的止点可以超过几分之一秒。( V1 M6 t: _* k  O
//这是一种异步执行实时命令(又名多任务)grbl的刀位点
* H# i& o4 k+ ?//解析和规划功能。这个函数也可以作为一个接口,用于中断
3 f/ l$ t0 l6 N! G//设置系统实时的旗帜,只有主程序处理,消除的需要
' J0 u4 I0 f" t$ @2 r. t9 ]7 p//定义更多的计算昂贵volatile变量。这也提供了一种控制方法
9 @2 g' M1 o( }4 d) t//执行某些任务不相同的两个或多个实例的任务,比如计划: r- ]! l* B. M% q  k
//重新计算缓冲feedhold或覆盖。
" S6 X' g+ J% t. G//注意:sys_rt_exec_state变量标志设置任何过程,步骤或串行中断,插脚引线,
4 C% o2 X( r* X9 u//限位开关或主程序。7 k- |  Y, l! w; |3 \
void protocol_execute_realtime()
* n% }" G' }/ K4 c- r+ t{
( a6 p6 n9 u: g3 D! x        // Temp variable to avoid calling volatile multiple times.
2 F9 T5 a0 c! [        // 临时变量来避免多次调用不稳定。
3 C( w; H0 R0 K& |2 h) ^7 d8 f        uint8_t rt_exec;
! b3 M$ |" A% |/ {        do{5 H/ y" E" i! A
          if (rt_exec) {                 // 有标志位置位进入
0 H$ Q: Q1 ^2 ?8 I        : t/ l( l) {! w8 c0 e. Q5 |
            sys.state = STATE_ALARM; // 设置系统为报警状态0 b& F  w. H+ m3 i8 P
      report_alarm_message(ALARM_HARD_LIMIT_ERROR);        //报告报警信息为接近极限值
& ^7 U6 }% w; [1 a' D1 t( N0 {$ m    } else if (rt_exec & EXEC_ALARM_SOFT_LIMIT) {                        //报告执行软件限位报警9 `9 @% T3 N6 x2 N3 G/ D1 ?
      report_alarm_message(ALARM_SOFT_LIMIT_ERROR);        //报告出现软件限位报警
/ H7 i4 E9 L' m; q. j+ q$ ~' g0 R    } else if (rt_exec & EXEC_ALARM_ABORT_CYCLE) {                //执行停止循环报警      & P  ~/ p7 m! v& V! S
      report_alarm_message(ALARM_ABORT_CYCLE);                //出现终止循环报警
. i! S) R6 i0 A6 A2 O    } else if (rt_exec & EXEC_ALARM_PROBE_FAIL) {                        //执行探查失败报警# L2 H+ g3 ?9 M* P  x0 n3 f
      report_alarm_message(ALARM_PROBE_FAIL);                        //出现探查失败报警* c  m6 i5 i0 Y5 |& y% D
    } else if (rt_exec & EXEC_ALARM_HOMING_FAIL) {                //执行返回原点失败报警
) l) K1 O9 {4 c4 t      report_alarm_message(ALARM_HOMING_FAIL);                //出现返回原点失败报警3 Y7 R! C5 a' Q# Z* x8 z* B: O5 U
    }
5 X7 Q: o- L  a/ P  z* y- k. X
- |" K/ ?$ I: A    // Halt everything upon a critical event flag. Currently hard and soft limits flag this.4 B2 \6 j! z0 Y; P
    // 停止一切在一个关键事件标志。目前硬和软限制标志
5 Z& ~" K1 B1 J5 _           if (rt_exec & EXEC_CRITICAL_EVENT) {                //如果系统是循环事件进入
4 l- T8 [% W  G7 G% I$ z             report_feedback_message(MESSAGE_CRITICAL_EVENT);        //报告反馈信息3 F( o1 O! F' j5 {4 t
              bit_false_atomic(sys_rt_exec_state,EXEC_RESET);                         //清除目前的复位状态6 l% \3 Z- n% H
- H( z- N/ b% m2 _
        bit_false_atomic(sys_rt_exec_alarm,0xFF);                                 // 清除所有报警标志: r9 `9 Y9 \: v
        }       
2 ^* ^7 S* b" {1 e; x; F4 f0 f! h; F3 Y# Q6 b' d
上面代码将rt_exec = sys_rt_exec_alarm ,如果rt_exec为真,打印不同报警信息
5 @8 M7 Q9 D% M: @6 c和限位保护信息,然后清除报警状态  m' N+ t) T; n" H! z2 L& k
___________________________________________________________________________9 u) M4 Q4 N- Y
没有报警进行执行下面代码,执行了终止命令,串口打印命令! l! V3 ]8 F( S0 r3 t, M; O
        // Check amd execute realtime commands        校验和执行实时命令& L# Q8 ~7 g1 ]" i
          rt_exec = sys_rt_exec_state; // Copy volatile sys_rt_exec_state/ `$ F, h# Q+ w' G/ C* f/ x# C+ A* d
& {" B. J3 Q2 Q9 E( h; y& }* E
        if (rt_exec) { // 输入标志是正确的执行7 ^( E: S, ^6 E9 h% n
) E: j/ J% s5 e2 r* m
            // Execute system abort. 执行系统终止命令
" d& X& b1 `, T1 Q9 @            if (rt_exec & EXEC_RESET) {" a9 ?) }9 `& N! X0 H, I
              sys.abort = true;  // Only place this is set true.
! S% {5 r6 u) L' t7 |              return; // Nothing else to do but exit.
* i. w5 ^4 ?) L" f& e. L  P        }
0 z9 J) v7 x% x8 a& W- J+ S& n
' w: q9 ~# V- x: D+ @            // Execute and serial print status 执行和串口打印状态
# H! B$ _5 y3 I- [7 r            if (rt_exec & EXEC_STATUS_REPORT) { * C1 k7 _$ \+ v8 E
              report_realtime_status();        //报告实时状态
! }9 ?: A& t/ L& u& P7 L/ V& B0 ^              bit_false_atomic(sys_rt_exec_state,EXEC_STATUS_REPORT);        //清除报告状态清零# V) L5 s4 j! E# \6 d
            }
! [, ?5 ]: l5 m, b+ a4 O" y_____________________________________________________________________________+ E8 K9 v4 [7 J% i, p( N
下面代码
1 @2 u8 w2 d/ w  F% O% ]; Z//执行状态。" x" N0 r: N1 l" f# V: Y% J2 {1 s
//注意:所涉及的数学计算持有应该足够低对大多数人来说,即使不是全部,
5 R2 y7 \7 Y& L) z% y8 r+ @& h//操作场景。一旦启动,系统进入暂停状态
) `% _+ @( }1 @//主程序流程,直到重置或恢复。
+ v6 k4 B. q; Y$ @待办事项:检查模式?如何处理呢?可能没有,因为它只会在空闲,然后重置Grbl。6 p0 b) g# W/ ?) N
状态检查容许状态的方法。: M, _3 A# }; C  B# _

  s8 O: B1 H3 T& d1 Z1 i2 f        //如果全局各自报警标志位其中(执行取消动作) | (执行进给保持) | (执行安全门)任意一位为真进入2 ]3 j& t- r' o$ g
            if (rt_exec & (EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR)) {       
! x. H0 W6 o& R7 N( D+ ?4 g. }( L
1 _# E  t" `" D4 [2 l% C        //如果是循环状态执行暂停状态
9 j$ @0 y  v( }        if (sys.state == STATE_CYCLE) {
9 x- v  ^/ ?" n: Y" C" V8 I" G        st_update_plan_block_parameters(); //通知stepper module验算减速。8 ^* v7 u+ r; K8 r0 X  @  [3 K# B
        sys.suspend = SUSPEND_ENABLE_HOLD; // 开始暂停标志
! }$ y8 d( J6 ?/ o, X2 `9 D! R4 w        }5 g4 E6 @9 @) M* }9 O

8 W: a9 L$ q' Y% D/ H        // 如果,Grbl空闲不在运动。简单的指示暂停就绪状态。
& ?- y/ R' B+ K4 Z        if (sys.state == STATE_IDLE) { sys.suspend = SUSPEND_ENABLE_READY; }, i; o: E7 [$ f: k7 Q4 `
% L5 v* `5 I8 E. ]* u. Q
% G6 c* s+ y7 z) f) L! _
        //执行和标志和减速运动取消并返回空闲。主要由探测使用周期
% _6 [' _7 t9 i" i        //停止和取消剩余的运动。      
% L: e- D- N$ ?/ d; ~        if (rt_exec & EXEC_MOTION_CANCEL) {  K2 U$ i1 y8 P2 B2 F2 y
          if (sys.state == STATE_CYCLE) { sys.state = STATE_MOTION_CANCEL; }$ j4 K% R+ `, O) T: E& B# X
          sys.suspend |= SUSPEND_MOTION_CANCEL; " P# S" ^3 i8 a& M" F
        }
, k0 H% d9 e# q; T( R. L6 x2 y4 p. k4 Z" O& G+ O
        // 只在循环时执行进给保持减速
) k3 b' e2 [- m9 ~! ?9 ?         if (rt_exec & EXEC_FEED_HOLD) {0 _8 z# b% z& }& j% d
        //只有安全门为1才执行保持进给状态赋值
/ g* `2 s- }& p1 f) H          if (bit_isfalse(sys.state,STATE_SAFETY_DOOR)) { sys.state = STATE_HOLD; }
( V: q8 ]5 H0 ?0 z+ o, t        }
( i: F0 s9 o. E3 R* O9 Q+ d' j& N) D9 v, t8 s% b
        if (rt_exec & EXEC_SAFETY_DOOR) {! w& @" T8 }2 `. ~% }( q" K
          report_feedback_message(MESSAGE_SAFETY_DOOR_AJAR); 8 _4 U* m) x) `/ b" S$ w2 }& l- \0 B
/ /如果已经活跃,准备好重新开始,CYCLE_STOP标志设置为强制断开。9 ]" X# |: k5 F% w/ \) F/ G2 d0 \6 q
/ /注意:只是暂时设置“rt_exec”变量,不是动荡的“rt_exec_state”变量。) W7 I* V7 F& J0 I
          if (sys.suspend & SUSPEND_ENABLE_READY) { bit_true(rt_exec,EXEC_CYCLE_STOP); }  n/ {1 A$ D' B& t0 z2 s
          sys.suspend |= SUSPEND_ENERGIZE;/ T% x1 n* F- u& }1 L# `
          sys.state = STATE_SAFETY_DOOR;
$ R4 Z4 t5 Z3 K& V# W        }! I. a* j5 Z! v( I+ m4 ?

) J) A  C6 G: x' S' A1 Mbit_false_atomic(sys_rt_exec_state,(EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR));    % d- P3 t' s- F9 G4 ^  S  z2 s

% q; r, Y" O2 g( A8 z+ p}6 ]; r; |8 W/ y, a. u
以上代码执行了
8 ?' N( T# M! }; [" X+ B1.如果全局各自报警标志位其中(执行取消动作) | (执行进给保持) | (执行安全门)任意一位为真进入6 |" j- _$ x3 E" L) y" }
2.系统为闲着状态, 开始循环状态, 回原点状态, 控制取消状态, 开始保持状态, 开始安全门状态时进入
( q( A# j1 U5 p1 f! o# U' r% }3.如果是循环状态执行暂停状态% v' h" A' `3 X& W) I* L
4.如果系统闲置状态执行暂停就绪状态$ ~+ R# |# B. G0 f% h) v' Z$ O& F
5.执行动作取消
- b4 |! ]1 }) F! \  Y6 I: n6.如果是保持进给状态,执行保持进给状态" k5 P! p" L2 @, E6 \6 b
7.执行安全门状态$ {0 c( r! E# u" {) F# ?' e- p- u
最后执行bit_false_atomic清标志清除(执行取消动作)(执行进给保持)(执行安全门)标志位                  ! ]" |" y1 _, A! i
_____________________________________________________________________________
7 t7 ?+ G4 M0 I9 M/ a( C6 j- u5 C- f0 E# m$ P+ w
    // Execute a cycle start by starting the stepper interrupt to begin executing the blocks in queue.9 Q9 s' H# v( ?8 ]" p( z+ |& s1 ]' L
    // 执行一个循环开始启动步进开始执行中断队列的街区
8 n! W/ h! I9 C7 x, K# P4 w    if (rt_exec & EXEC_CYCLE_START) {        //循环开始状态进入
$ G0 N+ _, j  m      // Block if called at same time as the hold commands: feed hold, motion cancel, and safety door.! W, M% f4 }+ F7 E, W: U3 H& n* [  s
      // Ensures auto-cycle-start doesn't resume a hold without an explicit user-input.$ M9 w, G; y! I: v, P
          //块如果在同时举行的命令:保持进给,运动取消,和安全的门。 //确保auto-cycle-start没有简历没有显式的用户输入。
: e2 n- J$ v2 N! i2 k6 l           ( {3 F; Q4 p7 J0 K# ~6 q5 K6 f' H
      if (!(rt_exec & (EXEC_FEED_HOLD | EXEC_MOTION_CANCEL | EXEC_SAFETY_DOOR))) {   //状态机如果不是保持进给,运动取消,和安全的门。
) S  V% L; M& J        // Cycle start only when IDLE or when a hold is complete and ready to resume.( S8 ^% G' O, _& ^% {' a2 p
        // NOTE: SAFETY_DOOR is implicitly blocked. It reverts to HOLD when the door is closed.% `# C4 }' D: _
                //循环开始时只有当闲置或持有完成并准备简历。% t6 ~9 y- b7 r. C+ N
                //注意:SAFETY_DOOR是隐式地屏蔽。它返回的时候门是关闭的。   
2 A* L+ ?( w3 o! w
1 X+ x6 n4 e/ _- `: P3 y% J' E                // 如果系统状态为闲着状态,系统状态为开始进给或运动取消,暂停标志为位重新开始
3 F" ^: }! W! m+ ], j        if ((sys.state == STATE_IDLE) || ((sys.state & (STATE_HOLD | STATE_MOTION_CANCEL)) && (sys.suspend & SUSPEND_ENABLE_READY))) {
  Q# i4 F% p* L& M          // Re-energize powered components, if disabled by SAFETY_DOOR.3 C, i( v) x4 l* d
          //        由SAFETY_DOOR重振组件供电,如果禁用。" s3 z. U3 s8 M+ N6 `
          if (sys.suspend & SUSPEND_ENERGIZE) { & G3 Y- g2 G' q7 Z% R
            // Delayed Tasks: Restart spindle and coolant, delay to power-up, then resume cycle.2 b2 T% V  D/ X1 S; u$ Q
            //延迟任务:重新启动主轴和冷却剂,延迟升高,然后恢复周期。
' h: l9 F& `: P8 B) u$ L7 z            if (gc_state.modal.spindle != SPINDLE_DISABLE) {   //主轴模式不是失能进入* ^$ y! ?) J& ]3 b  k6 F
              spindle_set_state(gc_state.modal.spindle, gc_state.spindle_speed); //设置状态和速度
- \" I/ z2 b* [9 J  @" N2 \. c              //待办事项:阻塞函数调用。最终需要一个非阻塞。
9 H  S: r  p( P! }/ }, ]* E" \; E8 n                delay_ms(SAFETY_DOOR_SPINDLE_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.! ]) a2 F: d: m" n- l
            }
! G" x. {. u* w) m# V$ h% J) p4 r/ j7 K            if (gc_state.modal.coolant != COOLANT_DISABLE) {
* Z& l4 N/ r: t& i7 R& t( ^  J              coolant_set_state(gc_state.modal.coolant); 3 H" B1 p. K5 z3 |7 [; r" {) J
              delay_ms(SAFETY_DOOR_COOLANT_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.+ L& T' [; e% j- c' J
            }
+ ]( i. |5 h1 @6 {5 |6 x6 G, ~1 a) }            // TODO: Install return to pre-park position.4 m) G) [4 u0 P( Y) n
          }
5 D, c* ~" w  [/ [; X______________________________________________________________________________________________________________' J) W* n3 q4 @6 k# A
          // Start cycle only if queued motions exist in planner buffer and the motion is not canceled.
" q) s( Z% W: M& A$ E- B                  
4 ~2 I2 P' Y; L                  //只有在队列马达存在规定的缓冲,并且动机没有让取消,才会循环
5 J& J& j4 ~8 r0 p9 j: l8 s                  
/ v" r5 x1 k  s! R0 ~$ b          if (plan_get_current_block() && bit_isfalse(sys.suspend,SUSPEND_MOTION_CANCEL)) {
% d- ?9 w& [4 ^# A* ~: ^9 T            sys.state = STATE_CYCLE;. U" P( V: \2 w
            st_prep_buffer(); // Initialize step segment buffer before beginning cycle.初始化步开始循环之前8 V2 \4 F  Q/ Y5 K! X6 M
            st_wake_up();- }' u8 r9 P& X7 h, k; J
          } else { // Otherwise, do nothing. Set and resume IDLE state.否则,什么也不做,设置和复位空闲模式9 F5 {3 @+ h3 a6 z  @
            sys.state = STATE_IDLE;+ U3 T* W" P, \& B( l1 L
          }
( y4 V% N4 B! H# e          sys.suspend = SUSPEND_DISABLE; // Break suspend state.
2 g. J* m" }+ V- c        }
* L6 q7 X  W, p5 _      }   
1 v  X# `3 e1 @0 @8 T! J: d      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_START);       
7 `/ g' _+ ]$ P$ W; [5 J    }
9 j, e( A" x1 G- D; w  l( m# b3 G/ ~2 a5 p  Z) G# e- N- T9 `
_______________________________________________________________________________________________________
+ A4 @" y0 p8 b0 c    // Reinitializes the cycle plan and stepper system after a feed hold for a resume. Called by
" @0 T6 ?8 e9 [9 R( Z3 J    // realtime command execution in the main program, ensuring that the planner re-plans safely.
7 s% R2 s; |' _9 q8 c    // NOTE: Bresenham algorithm variables are still maintained through both the planner and stepper
9 _& O7 z, W( g& q    // cycle reinitializations. The stepper path should continue exactly as if nothing has happened.   
9 ~! U! F0 p. f/ D    // NOTE: EXEC_CYCLE_STOP is set by the stepper subsystem when a cycle or feed hold completes.% w7 w+ M/ m# N. n3 e
# ^% `& o& C; i) K
        //重新启动后循环计划和步进系统的进给保持简历。通过实时命令执行主程序,确保安全计划重新计划。
2 ~/ b9 U3 q4 U        //注意:画线算法变量仍保持通过规划师和步进2 X# T  P1 W3 ]* j4 J  l  A
        //循环仅。步进路径应该继续,好像什么都没发生一样。        & J6 G7 t  n. ~/ I' `% C: _
        //注意:EXEC_CYCLE_STOP由步进子系统周期或进给保持时完成。
$ M. o  D2 G+ O/ ~5 C% v7 @9 }  i3 N/ d/ D$ d# _
    if (rt_exec & EXEC_CYCLE_STOP) {                         //如果是循环停止状态进入9 y! Q* I9 o% e/ v3 q
      if (sys.state & (STATE_HOLD | STATE_SAFETY_DOOR)) {
+ _% P" L. e, `, U( s        // Hold complete. Set to indicate ready to resume.  Remain in HOLD or DOOR states until user5 P" y; V3 W1 n
        // has issued a resume command or reset.
4 t' y2 V" f5 }( S0 K6 |! R/ U; t  y( X0 y
                //保存完整。设置为指示准备简历。继续持有或门状态,直到用户& i8 L$ v# Y# u7 @
                //已发布了一份简历命令或重置。
. b  S, X6 T0 n  V- e. K. d                % n# `, n/ v  L, X  I  s
        if (sys.suspend & SUSPEND_ENERGIZE) { // De-energize system if safety door has been opened. 如果安全的门已被打开。断开系统2 v6 C9 h* }1 v: D
          spindle_stop();
! W/ w9 l$ z0 X& W, y3 e          coolant_stop();
9 h: X5 z4 ~4 U9 ^# o          // TODO: Install parking motion here. 安装停车动作。  z9 ~. a: {' k2 R- D
        }
2 c0 m% O1 C$ l, o( Z' n; W3 `/ G        bit_true(sys.suspend,SUSPEND_ENABLE_READY);0 w% [! p, \+ t( H
      } else { // Motion is complete. Includes CYCLE, HOMING, and MOTION_CANCEL states. 电机完成,循环,回原点,,MOTION_CANCEL
! m! [) w( f8 k7 r$ V# r$ Y        sys.suspend = SUSPEND_DISABLE;) N" I  r# t5 a* J# ^; Z+ z5 h9 s
        sys.state = STATE_IDLE;" d  V' b; r9 ^9 E$ ~0 [# Q
      }
5 N' r8 A3 x! L      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_STOP);0 b3 z  `5 z5 \2 S
    }& b8 |3 \) ^  C/ c  d/ s; V
   
# i* A! l  S) k  }
& J# u0 _+ W2 I; r5 j  p___________________________________________________________________________________________________
- L, {5 z! i" A
0 H1 Y; g. B6 S7 \1 A. q  // Overrides flag byte (sys.override) and execution should be installed here, since they
" A9 M: s' `6 R7 p. y! F6 _  // are realtime and require a direct and controlled interface to the main stepper program.
( P6 y* h+ \" ~2 i8 M+ i& o
0 C, Q0 T5 l% ^0 p: D* c* Z  \  //重写标志字节(sys.override)和执行应该安装在这里,因为他们+ S$ G6 d) d  X
  //实时和需要直接和控制接口的主要步进程序。
& S0 n' {2 q! m
% d$ i! I: z7 M4 w7 u2 S8 |& `
+ t7 b% ]2 [2 Z1 z5 y  // Reload step segment buffer 重新加载步段缓冲
# ?  R- F5 L$ Q2 s1 t# C+ i  if (sys.state & (STATE_CYCLE | STATE_HOLD | STATE_MOTION_CANCEL | STATE_SAFETY_DOOR | STATE_HOMING)) { st_prep_buffer(); }
9 J3 P; {& f7 L8 o' F( n$ h# p+ ~! U% U# A/ u- k6 z/ h  B: A
  // If safety door was opened, actively check when safety door is closed and ready to resume.8 |8 T" h) K0 h+ W9 d$ `. _
  // NOTE: This unlocks the SAFETY_DOOR state to a HOLD state, such that CYCLE_START can activate a resume.       
2 T% U: a  x# l0 ^1 ~, F# f3 l. G) q& [( ~5 B1 g% T# W
//如果安全的门被打开,积极检查当安全门关闭,准备简历。
/ S' G0 h' c, {% m: H5 C* Q  //注意:这解锁SAFETY_DOOR状态保持状态,这样CYCLE_START可以激活一个简历。
( E# U1 G) p& c; ]8 h
5 E8 B. e4 H+ k- }# w  if (sys.state == STATE_SAFETY_DOOR) {                 //安全门状态进入! }8 m- C2 }7 L, \7 m% {; N" p
    if (bit_istrue(sys.suspend,SUSPEND_ENABLE_READY)) { : R/ x7 @- |! m: F2 K! G# h, a
      if (!(system_check_safety_door_ajar())) {
' D+ @/ v) h! y$ L        sys.state = STATE_HOLD; // Update to HOLD state to indicate door is closed and ready to resume. 更新保存状态指示门关闭,准备简历。  d/ F  d) b( n2 `( F- ~# e! ^
      }
4 T2 U$ w9 Z" z) k4 g. @; r4 B    }1 k8 ?2 X' a4 J: Y# R. Y9 f0 R0 G: \
  }
5 O, E; E. n' \: H$ Y0 M' F
' }$ I, @9 n& ^7 m  } while(sys.suspend); // Check for system suspend state before exiting.
+ j! N1 @2 x2 X9 @5 T: R$ L" w! m  
3 G) z# H8 s1 [! V) f! 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, 2025-6-17 03:00 , Processed in 0.103482 second(s), 22 queries , Gzip On.

Powered by Discuz! X3.5 Licensed

© 2001-2025 Discuz! Team.

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