机械必威体育网址

 找回密码
 注册会员

QQ登录

只需一步,快速开始

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

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

[复制链接]
跳转到指定楼层
1#
发表于 2016-8-20 23:56:23 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 1五湖四海1 于 2016-8-21 00:09 编辑 - S2 V  z, D5 R$ [# a0 u7 |% M
* R% o3 g8 w8 Y' W, Z/ x
    以前制作过CNC雕刻机,是用MACH3作为上位机控制,硬件是采用PC接并口输出脉冲和方向使能信号经过隔离驱动步进电机驱动器,步进电机驱动是采用TB6560芯片控制。最后就接到步进电机。机械是用铝合金制作,主要部件有三个1605的滚珠丝杠,多个运动滑块等制作。用这台DIY CNC雕刻机可以雕刻木头塑料等东西。当时没有一直玩下去,现在发现网上有用单片机制作的雕刻机挺精巧的现在分享给大家。
1 o8 d" A! Q, {   GRBL CNC 3D打印机,这就是我说的可以用单片机来控制的3D打印机,我先照着百度科普下grbl,Grbl是性能高,成本低,基于并口运动控制,用于CNC雕刻。它可以运行在Vanilla Arduino (Duemillanove/Uno) 只要它配备了Atmega 328型芯片。 控制器由C编写并优化,利用了AVR 芯片的每一个灵巧特性来实现精确时序和异步控制。它可以保持超过30kHz的稳定、无偏差的控制脉冲 它接受标准的G代码而且通过了数个CAM工具的输出测试。弧形、圆形和螺旋的运动都可以像其他一些基本G代码命令一样完美支持。函数和变量目前并不支持,但是会作为预处理器包含在将来发布的版本之中。 Grbl 包含完整的前瞻性加速度控制。它意味着控制器将提前16到20个运动来规划运行速度,以实现平稳的加速和无冲击的转弯。Grbl是性能高,成本低,基于并口运动控制,用于CNC雕刻。它可以运行在Vanilla Arduino (Duemillanove/Uno) 只要它配备了Atmega 328型芯片。 控制器由C编写并优化,利用了AVR 芯片的每一个灵巧特性来实现精确时序和异步控制。它可以保持超过30kHz的稳定、无偏差的控制脉冲 它接受标准的G代码而且通过了数个CAM工具的输出测试。弧形、圆形和螺旋的运动都可以像其他一些基本G代码命令一样完美支持。函数和变量目前并不支持,但是会作为预处理器包含在将来发布的版本之中。 Grbl 包含完整的前瞻性加速度控制。它意味着控制器将提前16到20个运动来规划运行速度,以实现平稳的加速和无冲击的转弯。很棒吧!开始玩起。
; ~; {: n* i- U0 b8 c% l; r9 O    还没有雕刻机的机械部分可以用废旧光驱制作个微型雕刻机运动平台。雕刻机最重要的是主控程序这次用 Arduino/AVR328单片机,价格在15元左右,主控程序是上面提到的目前很火的开源
的GRBL,还有一种基于STM32平台的开源主控程序Dlion也不错可以替代grbl。如果从性能比较这两个方案,显然是stm32平台运行速度更快毕竟他是32单片机呀!4 v9 {# {+ @! z, }+ M2 u
# _$ ^8 J. o5 v. s

' K' w; q! S% F" X5 Z9 x    下面介绍小这个些主控程序主要干的事,通过串口PC和主控板通讯,PC命令给控制板,控制板接收命令做不同的响应,PC可以发G代码给主控板,接收完成后可以自动开始雕刻任务。
- V  I  D3 ^. x% C! q% s! L          在介绍下G代码因为G代码是雕刻机的核心部分
2 w; @1 H9 D( B8 k# kG代码是数控程序中的指令。一般都称为G指令。
; g5 U# w, c0 A8 l5 jG00------快速定位
) o' M1 p. e4 ?4 s0 zG01------直线插补
- n" Z) n# c9 I! Z0 \1 M2 j" ^G02------顺时针方向圆弧插补2 g' C( S- q6 @% G4 B6 @( u
G03------逆时针方向圆弧插补) E7 J1 J/ `/ B5 W# i
G04------定时暂停  G, P- ~: A6 U0 y8 B& q$ J/ Z1 p
G05------通过中间点圆弧插补
+ o5 l" _6 ]6 ?0 b- Z* DG06------抛物线插补4 y1 L8 e% Z+ R% v/ Y
G07------Z 样条曲线插补3 ^/ D" R6 q9 X  m& h# J
G08------进给加速) J. r, M; y; f! R9 W0 V
G09------进给减速
( f$ }7 P0 x# U; NG10------数据设置$ J5 z2 w3 t: J% C  p2 X
G16------极坐标编程) C5 ]1 x% [# \6 H
G17------加工XY平面
, `+ ~2 F! q0 g- aG18------加工XZ平面0 U8 s2 o& r- M# L
G19------加工YZ平面

) u  K* U& `* y: \( }核心就是解析G代码,完成步进电机驱动,和控制主轴开启关闭,还有插补算法,直线插补,圆弧插补,还有一些步进电机的加减速算法。1 u9 s9 ~( D' O
下面对grbl主结构做介绍3 X9 o( p1 C- \/ z( e8 e7 Q, A
main()主函数首先执行下面初始化函数7 G) o6 j. _$ K2 L" M+ y
        serial_init();                           // 设置串口波特率和中断# Q) u- O+ k. v+ a# [, T
        settings_init();                         // 从ROM加载grbl设置. r% S1 v/ n- E0 |. O4 ~# A' R
        stepper_init();                          // 配置步进方向和中断定时器. u: c8 y+ I5 g$ |% h
        system_init();                           // 配置引脚分配别针和pin-change中断
/ p  _) g. D4 m; h0 H        memset(&sys, 0, sizeof(system_t));          // 清除所有系统变量7 ~( U: e/ e9 g: }1 v! a
        sys.abort = true;                           // 中止标识位置位
' \$ }# U& ^. o5 ^; w& Q- }: a% A        sei();                                         // 使能中断
! e+ ~5 A4 ~* e: g/ k: Z6 [; o  #ifdef HOMING_INIT_LOCK                        // 宏运算(settings.flags & (1 << 4)) != 0结果flags等于执行sys.state = STATE_ALARM" C, w0 B# @1 m" O2 t5 J" G3 Q
                                                // 系统状态赋值为报警状态
: d# y. a; Q: I' u$ ?5 [3 _4 ?            if (bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE)) { sys.state = STATE_ALARM; }
1 y0 R" o( D, i+ {2 I  #endif
5 z. N: m( c' Z1 y! u+ }: Q% @* Q# q) B& h_____________________________________________________________________________________________________________________________________
% f) h' q+ V" C接下来是一些主要部分初始化& A' V: p6 J! ~# a# z! J( r2 F
for(;;) {& m# O. {3 x) S, T! L$ p
        serial_reset_read_buffer();         //清除串口读缓冲区4 n2 a, a7 V# E9 U
        gc_init();                         //初始化G代码功能函数
- o/ N! G1 e& B6 I% j  B3 [        spindle_init();                        //主轴初始化& e5 L2 i0 s/ L7 [% X
        coolant_init();                        //冷却液初始化8 Y# x, _* s- X: S. O) `
        limits_init();                         //极限开关初始化
9 |3 C, L- G2 X: I* f2 G" P        probe_init();                        //探测部件初始化
/ P2 ]6 G, J& }& U9 v9 L) `4 }# x        plan_reset();                         //清除块缓冲区和规划师变量
4 D  B. c; ^: \9 r9 m        st_reset();                         //清除步进系统变量。+ R/ h1 y$ b. t5 ~6 q
. N% K* G: f* X

' u( O) k. a: T2 {( Z        //下面两行清除同步gcode和策划师职位当前系统位置。: y1 l  \% T" d9 j& c8 |0 Q9 I
        plan_sync_position();+ w1 A! d# x" _5 Z+ Y
        gc_sync_position();7 {, }6 L6 `$ B" [

6 b9 M) h# `# s- ]' Q( b  z8 d% w$ }/ e
        //复位系统变量
) j/ g5 {+ S! k+ _: }        sys.abort = false;                //系统中止标志: U, }/ M' o" _/ k4 }
        sys_rt_exec_state = 0;                //系统标志位变量状态管理。看到EXEC位掩码。
( J1 ~% ^. W7 Q8 i3 h+ Q. N        sys_rt_exec_alarm = 0;                //系统标志位变量设置不同的警报。
% c% V0 `& V; P# R' H        sys.suspend = false;                //系统暂停标志位变量管理,取消,和安全保护。/ O; k- j* c( \, H2 a
        sys.soft_limit = false;                //限位开关限制状态机错误。(布尔)
. r3 {% n4 t' m; n, i( X% x2 B8 P% B7 d( g9 |

2 c0 N# f* w2 `. F4 d2 [        protocol_main_loop();                //主协议循环
2 z4 u( Q$ j" ^* r}        //: f1 J& a* s6 n6 V
_____________________________________________________________________________________________________________________________
3 w, q. L# A" `/ i进入void protocol_main_loop()函数
! R2 T+ \2 m$ i9 U! T/ R% }{
! Y& b/ _. t# S( B0 a. \. Y        report_init_message();                // 打印欢迎信息
5 L6 v" U4 M% H5 \0 X, x* q, B        //重启后检验和报告报警状态如果错误重启初始化。# b. F/ K4 i; S- z
        if (sys.state == STATE_ALARM) {0 e2 F2 [# j7 l) H& v: _
            report_feedback_message(MESSAGE_ALARM_LOCK); //打印信息, _5 P0 q1 @8 C# {+ [: O) P
          } else {
  g- u& B/ Z' J; e" M/ g+ _0 Z6 e            // 如果没有报警说明一切正常!但还是要检查安全门.
( T* R4 C! C' A; v3 Z            if (system_check_safety_door_ajar()) {( g: A6 _0 \, W1 k' _! q) D) e
                     bit_true(sys_rt_exec_state, EXEC_SAFETY_DOOR);4 x" r4 K& P$ \6 @
                     protocol_execute_realtime(); // 进入安全模式。应该返回空闲状态。, W+ L7 m3 s- ~2 p7 s; h  j
            }         else {! Z* b# k3 ?7 t8 c4 h  d5 H
              sys.state = STATE_IDLE; // .设置系统做好准备。清除所有国家国旗。6 r  I" A! X2 j+ X4 V! o
            } ; C: S. t7 y. L6 Z2 g/ u( V
            system_execute_startup(line);    //开始执行系统脚本9 y# i: y  c% m& F0 J2 e  p8 s
  } ) y3 S% T* p) k8 Z0 g. \( Q
" `7 t. R  F" @& D2 ~2 t  L4 ^6 D$ x

5 @9 P/ o2 }: `/ Y. o2 G  // 这是主循环!在系统中止时这是出口回到主函数来重置系统。
. t6 p0 [5 S. `' Z# k: c1 J  // ---------------------------------------------------------------------------------  4 K: G6 t& y1 ^$ {
  
, u9 }4 j! }' \5 ]        uint8_t comment = COMMENT_NONE;7 Z* S+ V0 s4 n* ?' g* b# U  Q
        uint8_t char_counter = 0;
$ I4 |7 q% f7 w% @) u6 `6 m        uint8_t c;3 |8 A2 Z# a" A. Z3 ~, w. K
_______________________________________________________________________________________________________________________________. r* P: U3 n9 F. M8 r
接下来进入for(;;)循环                //下面代码是G代码解析核心部分,程序中comment(注释)变量会被赋不同值,代表发符号有‘(’‘)’‘;’
( k$ c5 t: b# p3 G6 c0 G{  J/ g3 i; Q! H/ y1 W
//串行数据输入一行的的过程,作为数据。执行一个
. `/ B4 G, H+ ~! m& F' E3 V//所有数据初始过滤去除空格和注释。 ' t6 r% W/ X( g% l" J' C( j: A
//注意:注释,空格和程序段删除(如果支持的话)处理技术9 y  F- @6 j: {6 Y0 N3 x
//在G代码解析器,它有助于压缩到Grbl传入的数据
% @/ L# B3 J! _* T3 m) E. R% q//线缓冲区,这是有限的。刀位点标准实际上州一行不行- R8 `1 e6 E7 s8 P. P% b, p( n
//不能超过256个字符,Arduino Uno没有更多内存空间。, B8 E6 d! z4 c) K- D! q7 x& T
//有更好的处理器,它会很容易把这个初步解析的
  X- S' ^4 k/ X* \' N. o, l//分离任务共享的刀位点解析器和Grbl系统命令。                                                               
( x! Y$ [5 K9 ~    while((c = serial_read()) != SERIAL_NO_DATA) {                             //读取串口数据,有数据执行下面代码7 `# v( }& J7 }* t
      if ((c == '\n') || (c == '\r')) { // End of line reached                //如果数据是/r,/n代表一行结束7 t# f  p4 G6 B
        line[char_counter] = 0; // Set string termination character.        //设置结束标志4 N7 F5 F1 A( I* l: C  t
        protocol_execute_line(line); // Line is complete. Execute it!        //一行完成执行此函数
/ {5 B0 B- D, Y( H        comment = COMMENT_NONE;                                                //注释清零* w3 G( ~( g) }& Z' O
        char_counter = 0;                                                    //字符计数清零
- o; d0 s4 f5 C% W; r  
; S* E- b& J9 `6 J! {. r" `        else {; [4 j) G* y$ z, j, ?; N$ s
        if (comment != COMMENT_NONE) {
2 A) q5 y% Q" W" l' K) U                                                     //扔掉所有注释字符& j$ B& L2 A: P, Q# A& |
          if (c == ')') {& k) i0 {4 u3 H; b2 Z1 C8 v! g
            //最后注释。重新开始。但是如果有分号类型的注释。2 O' O# Q5 P6 A* b( z
            if (comment == COMMENT_TYPE_PARENTHESES) { comment = COMMENT_NONE; }
! T4 e# A3 c6 R1 v+ ~+ p9 U          }
9 u; n" J; e- d- r4 N4 O# Z0 B3 |      } else {: W( E/ N" G* ]1 v% o. j9 X
          if (c <= ' ') { 1 h. w/ d5 b, g# a! r) `8 w
            //扔掉whitepace和控制字符( w7 ~$ G% Q2 m& f9 Y, b3 M
          } else if (c == '/') { ) b# A# z6 h9 w! o
            //块删除不支持将忽略字符。# g* U: i( G: s  Y4 H$ j2 S) _% f) E5 ^
            //注意:如果支持,只需要检查系统是否启用了块删除。! p3 h. V% K! k3 j& Z, b" K4 @
          } else if (c == '(') {
$ B5 S( V  i9 T: Z            // Enable comments flag and ignore all characters until ')' or EOL.# C, X8 X9 l. D/ U$ \- G
            // NOTE: This doesn't follow the NIST definition exactly, but is good enough for now.
6 l0 ~# Q* Q6 a/ R' Z& r            // In the future, we could simply remove the items within the comments, but retain the
0 G% E4 c$ G& @, t            // comment control characters, so that the g-code parser can error-check it.
$ O8 }! U5 @& V            comment = COMMENT_TYPE_PARENTHESES;2 V* }' {: s+ g3 z' v
          } else if (c == ';') {; s9 }1 {' R" X7 g6 n1 L2 |  `0 w
            //注意:','注释EOL LinuxCNC定义。没有国家标准。
. }# s5 D% c2 |4 w8 V1 c" P0 e; h9 g            comment = COMMENT_TYPE_SEMICOLON;( V9 X6 s# i5 O8 G6 t
3 Z# D* a  L( a  s, q
- I" V! h3 w7 m. c
_____________________________________________________________________________________________________________________________________! D8 {8 ^4 D, l# H* `
          } else if (char_counter >= (LINE_BUFFER_SIZE-1)) {                        //串口接收数据大于80字符时  _$ o5 z( I/ r% }" S
            // Detect line buffer overflow. Report error and reset line buffer.        检测缓冲区溢出。报告错误和复位线缓冲区。
6 H! n" p6 H8 [. F, @. f            report_status_message(STATUS_OVERFLOW);                                //打印溢出信息
* p  N' G' c, v2 l            comment = COMMENT_NONE;. B* Z5 v8 I) a' q
            char_counter = 0;1 S7 I2 o/ _" E2 l
          } else if (c >= 'a' && c <= 'z') { // Upcase lowercase                        //小写改大写
3 a1 o8 L9 I% j8 k3 R4 {; z5 c            line[char_counter++] = c-'a'+'A';6 {- e" t( |2 F3 c& V
          } else {
% |) a# x6 @9 d' t0 w            line[char_counter++] = c;. l9 ?) e$ \4 Z9 ?' o  f' i! \, E
          }
/ f; ]0 m: f) k' N# r+ I+ ?3 i        }
  ~9 ?* D; r2 W" @. {8 [      }- K. k# W* o, D- H
    }) H9 g$ O; r6 V
____________________________________________________________________________________________________________________________________
$ W  k; o1 g0 r3 u! e' G" S! x        //如果没有其他字符在串行处理读取缓冲区和执行,这表明以完成,自动启动,如果启用,任何队列动作。
  O5 ?2 M5 \+ J  r* z* W5 U  S" ~; O% Y" s        protocol_auto_cycle_start();                //自动开始协议循环
2 T; H# f5 J- }7 `/ A0 J        " z% Y; i8 i8 I" [) M: k
            protocol_execute_realtime();                  //运行实时命令。
2 i4 K6 ?# w! E) d            if (sys.abort) { return; }                 //中止标识置位程序循环重置系统。            $ E' p- J! q! T
  } ( ?2 h; h* r6 W; i  Z; p) u
  return;                         //一般程序不会执行到这里5 @% G( ]$ k0 q  y; z
}. R  G5 {& O3 f
____________________________________________________________________________________________________________________________________
: k$ P% y0 p; M& U' k2 t; G9 d# J0 U正常情况下,读取完G代码程序会进入protocol_auto_cycle_start();//自动开始协议循环 函数下面介绍此函数
# g- h8 @: |% n. W7 x$ H, v4 {// Auto-cycle start has two purposes: 1. Resumes a plan_synchronize() call from a function that
6 X" O8 ]5 O- }. x% q5 @8 c  s, Y// requires the planner buffer to empty (spindle enable, dwell, etc.) 2. As a user setting that ) V+ v6 m, z" {! a: d% H
// automatically begins the cycle when a user enters a valid motion command manually. This is % b( w+ V6 ~* E/ Z
// intended as a beginners feature to help new users to understand g-code. It can be disabled% n/ u: D7 J! D
// as a beginner tool, but (1.) still operates. If disabled, the operation of cycle start is5 S. G% B' X6 ]! F6 Y
// manually issuing a cycle start command whenever the user is ready and there is a valid motion
0 z' s* e, p/ p// command in the planner queue.
" G5 v- V  b3 T: u' k. N) e- |, i/ ]// NOTE: This function is called from the main loop, buffer sync, and mc_line() only and executes ! ]' [9 ~1 A4 f
// when one of these conditions exist respectively: There are no more blocks sent (i.e. streaming / w/ W& O- L2 @2 o; i& Y! m
// is finished, single commands), a command that needs to wait for the motions in the buffer to " x- i' l, A" [
// execute calls a buffer sync, or the planner buffer is full and ready to go.
/ o/ E3 i/ J% y/ M7 U//自动开始有两个目的:1。回复一个plan_synchronize()调用的函数
1 X9 Q+ D4 `) l1 v5 P2 j//需要规划师缓冲区空(主轴启用、住等)2。作为一个用户设置
' p5 X/ z% l9 L" Z: `//自动循环开始当一个用户输入一个有效的运动命令手动。这是
, Y: n, r( X' w9 a% Y//作为一个初学者的特性来帮助新用户了解刀位点。它可以被禁用
7 r7 m0 n+ u" z9 n//作为一个初学者工具,但(1)仍然运作。如果禁用,运行周期开始
9 y; W. G9 D8 H0 q$ g//手动发出一个周期开始命令每当用户准备好,有一个有效的运动9 E  F$ p. v# }5 q6 A  {# H. U3 C
//命令的规划师队列。
! \2 U5 V% W- z' s. Q! g//注意:这个函数被称为从主循环缓冲区同步,mc_line只()并执行/ s( Q* I0 j' q  H3 F
//当其中一个条件分别存在:没有更多的块(即流发送
. @( k2 u5 y. L2 Z0 j3 X- G//完成后,单一的命令),一个命令,需要等待缓冲的动作6 G7 l7 Y+ c- l# T6 I. |
//执行调用一个缓冲区同步,或规划师缓冲区满了,准备好了。
: b: @/ ?! r$ x( O6 svoid protocol_auto_cycle_start() { bit_true_atomic(sys_rt_exec_state, EXEC_CYCLE_START); }
, o1 R) S% p; V6 j7 [% o$ t_______________________________________________________________________________________________# v7 C# G9 }  y
接下来程序运行protocol_execute_realtime(); /运行实时命令。
% C2 Z& p; y, ^, t  U// Executes run-time commands, when required. This is called from various check points in the main
, ^7 n) W0 s3 e8 e! D! r+ q3 W' x// program, primarily where there may be a while loop waiting for a buffer to clear space or any2 h1 |' y3 ]& N1 W1 W& \8 R
// point where the execution time from the last check point may be more than a fraction of a second.. u" j% G3 T) m! H6 G3 L
// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code1 Q1 r% \9 E& \  v
// parsing and planning functions. This function also serves as an interface for the interrupts to 7 {- m3 g1 Q7 C7 h: v
// set the system realtime flags, where only the main program handles them, removing the need to
# K6 E4 ]' ]+ d; p, O0 i, \// define more computationally-expensive volatile variables. This also provides a controlled way to 9 _9 y: }9 l* ^
// execute certain tasks without having two or more instances of the same task, such as the planner
6 x' ~3 A" f; z1 l# L// recalculating the buffer upon a feedhold or override.1 M2 R% S" k+ A9 P) }* J
// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,
. G! D3 e- X* M/ y// limit switches, or the main program.
7 m3 S& ?6 d* R8 B* `void protocol_execute_realtime()- Y" @; k, `8 U& x% A$ c
uint8_t rt_exec; // Temp variable to avoid calling volatile multiple times.临时变量来避免多次调用不稳定。9 K% s& W% a3 T( Q- j9 G, P+ F
就先分享到这吧!: f1 P3 r( v3 V: K% F, D1 M5 }
2 c% \6 b: o! M1 z) U

1 w; \: `- R, A; `2 p! ]7 x6 {3 @& M+ M8 L8 u

! o% ^9 k# Y% W# u" L  B8 F4 z1 S  b, B0 T: c

- K3 L# H0 ^, M1 y" [
' E  R, ~7 P$ w) e
5 t7 Q1 Z" Q! p# ]2 }3 I/ A$ L) }  e; v- R) X1 Q- F$ O
, X( h+ a) w9 F  j; s6 J9 @
+ D% J0 \- n, y5 c& Q4 y% T9 G
5 I, F/ X8 T1 D! d& r: p

1 z0 ^4 B' ~! W. {5 P- k" i9 T& u. H$ F
) h$ \, ~2 R. D/ m9 z

* ^: A. E8 i1 I5 j& T
7 t: x  v8 s6 H2 T+ [) d& F& s7 S0 H1 C+ d. @9 A% Z% m
- R4 F9 j! z# Z2 T3 L
5 J9 \5 W& g: k) g

# q" g/ s# ?3 b. V& B2 N" V0 w5 L( z1 p$ `& W

! t4 c4 Y2 X: `. H% \$ f( `3 V8 ^$ I补充内容 (2016-8-25 22:40):- P) t3 j! R# ?# f
配置说明% ~" E% \; p& `5 V! s5 X; ?
//这个文件包含编译时配置Grbl的内部系统。在大多数情况下,9 t' X+ Z+ Q- @: J  i" a; a- F4 f6 a
//用户不需要直接修改这些,但是他们在这里为特定的需求,即。2 O, Z- M- r  {  G4 g
//性能调优或适应非典型的机器。
9 E" L: J+ y  C; _9 H主要配置项:  J- d, M- g1 O9 p9 E5 V) a
1.#define DEFAULTS_GENERIC        //在重置eepm时使用。在defaults.h改变想要的名字- ]/ y: S; n5 ]
2.#define BAUD_RATE 115200        //配置串口波特率1152004 ]# ?1 w7 p7 @
3.#define CPU_MAP_ATMEGA328P         // Arduino Uno CPU
7 z4 G# w8 s+ i& ?4.#define CMD_STATUS_REPORT '?'        //定义实时命令特殊字符) ~; g6 b$ k% L/ l5 b' _( [
5.#define HOMING_INIT_LOCK         //回原点保护锁
3 j$ g+ l- V9 }" p! R6.#define HOMING_CYCLE_0 (1<<Z_AXIS)              // 第一步Z清除工作区。2 o. T) `0 D- r3 f
  #define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // 然后X,Y在同一时间。
2 O& ^* G, U0 V4 `- w* i+ H7.#define N_HOMING_LOCATE_CYCLE 1 //回原点循环次数$ H4 R4 p) }: ^6 p
8.#define HOMING_FORCE_SET_ORIGIN //取消这定义迫使Grbl总是在这时候位置设置机器原点尽管开关方向。
% |) s" r( n; f4 J% o4 T4 G4 T9.#define N_STARTUP_LINE 2 //块Grbl启动时执行的数量。
8 O  g+ \! C* b$ F! u' z; K' S10.#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 协调或位置价值英寸
- m2 c) G5 R& w; Q& }# J$ z   #define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 协调在毫米或位置价值
% }( W  g4 `( i1 o: B  U   #define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分钟的速度值- N0 b5 B. D5 C6 K/ c) j" U  F3 b
   #define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分钟
3 _6 _' H' _3 w; Z   #define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 对浮点小数设置值+ u9 K+ B% q" h8 f
11.#define LIMITS_TWO_SWITCHES_ON_AXES //如果你的机器有两个极限开关连接在平行于一个轴,您需要启用这个特性
" z9 c6 R6 `& Z) y4 C" X12.#define USE_LINE_NUMBERS         //允许GRBL跟踪和报告gcode行号
. G2 Z2 a8 Q# D8 I+ V0 L13.#define REPORT_REALTIME_RATE //允许GRBL报告实时进给速率. L( g: N' K( L& e
14.#define MESSAGE_PROBE_COORDINATES  //坐标通过Grbl $ #的打印参数?0 s/ C% A8 h3 {# ]) A; f
15.#define SAFETY_DOOR_SPINDLE_DELAY 4000 //安全门主轴延时# h- {( \1 V- R4 ~" U" W) G
16.#define SAFETY_DOOR_COOLANT_DELAY 1000 //安全门冷却液延时
+ N+ c' {6 K, C& l6 d, \17.#define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS) //启用CoreXY运动学。& W$ W, E" U0 o* [' j
18.#define COREXY // Default disabled. Uncomment to enable.改变X和Y轴的运动原理8 m+ t# B5 J& ^& }" I8 ^
19.#define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.反转针销逻辑的控制命令7 W- {6 w; w  T7 N
20.#define INVERT_SPINDLE_ENABLE_PIN // 反转主轴使销从low-disabled% i) K( {# q% D8 v7 z
21.#define REPORT_CONTROL_PIN_STATE //启用控制销状态反馈状态报告。; s5 ]# H' j2 f- I& C2 F
22.#define FORCE_INITIALIZATION_ALARM //启用和用户安装限位开关,Grbl将启动报警状态指示* ^8 P& }9 J+ p
23.#define REPORT_GUI_MODE // gui允许最小的报告反馈模式
+ @0 e4 j% r: {) c" C& n" T; c24.#define ACCELERATION_TICKS_PER_SECOND 100 //加速度的时间分辨率管理子系统。
3 {7 g* S: H3 k/ w* m4 }& }/ ]' ]" `3 w25.#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING //自适应多轴步平滑(积累)是一种先进的功能
1 [9 @/ X6 S- R26.#define MAX_STEP_RATE_HZ 30000 //设置最大一步速率可以写成Grbl设置; p. |. V" M0 [) X
27.#define DISABLE_LIMIT_PIN_PULL_UP //以下选项禁用内部上拉电阻: S: Q9 a" @! D6 L
28.#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS //设置哪个轴长度补偿应用的工具。假设轴总是与选择轴工具面向负方向
8 u/ J& e- a( W3 f29.#define VARIABLE_SPINDLE //允许变量轴输出电压不同的转速值。6 \2 D. _8 b$ N) Q
30.#define SPINDLE_MAX_RPM 1000.0  // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.
# ]  o9 K% _' t   #define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.
6 L) I) e' d/ X& C1 r  H' y31.#define MINIMUM_SPINDLE_PWM 5 //使用的变量轴输出。这迫使PWM输出最小占空比时启用。/ k( g* H: v( X7 `
32.#define USE_SPINDLE_DIR_AS_ENABLE_PIN //主轴方向使能M4被删除: U* D1 o$ V* F: c4 n: ~+ R) [3 p5 }% P
33.#define REPORT_ECHO_LINE_RECEIVED //应该对所有正常线路送到Grbl1 W0 J: o: Q' u* j
34.#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min) //最小规划师结速度。设置默认最小连接速度规划计划/ W" I* q0 x$ @  q
35.#define MINIMUM_FEED_RATE 1.0 // (mm/min)//设置计划将允许的最小进给速率5 D! {" u. c. ?
36.#define N_ARC_CORRECTION 12 //弧生成迭代次数之前小角度近似精确的弧线轨迹1 |1 ]4 z+ J- w2 T- B: [
37.#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)//定义值设置机器ε截止来确定电弧是一个原点了?
7 w6 u/ {( H7 [# L38.#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds) //延时增加表现在住。默认值设置为50毫秒. t! o/ I3 n* H% b" H0 @' l; N
39.#define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.
* {5 x/ S# W: M40.#define BLOCK_BUFFER_SIZE 18  //线性运动规划师缓冲区的数量在任何给出时间计划
3 j" l$ w" p, A( U* {- R41.#define SEGMENT_BUFFER_SIZE 6 //控制之间的中间段缓冲大小的步骤执行算法
/ b) W" z$ Z, \0 c$ C8 M42.#define LINE_BUFFER_SIZE 80 //行执行串行输入流的缓冲区大小。# L9 g+ r, S! c
43.define RX_BUFFER_SIZE 128 //串行发送和接收缓冲区大小
% r% {) B$ x9 v44.#define TX_BUFFER_SIZE 645 J; G% p: H6 L
45.#define ENABLE_XONXOFF        ////切换为串行通信发送流软件流控制。
6 k; K( J4 @! P& N+ A46.#define ENABLE_SOFTWARE_DEBOUNCE //一个简单的软件消除抖动特性硬限位开关。: Z8 U3 r: ^  D1 J* N% g: x
47.#define HARD_LIMIT_FORCE_STATE_CHECK        //Grbl检查硬限位开关的状态
/ F3 e) Q. H* y7 t48.// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:编译时错误检查的定义值:
# U; I& K( |' k7 e$ P+ C7 G! F4 @$ ^9 q8 Q, Y3 b# g& m' S5 E
___________________________________________________________________________________________________1 i5 b$ a7 }5 j. \1 d
/*/ h6 K' _. M2 M/ p& I2 K' K
  config.h - compile time configuration1 n! y, L! @) H; X9 j% n& |" @
  Part of Grbl
; Y  ~9 T  ?; ^1 d
. Q0 r/ [! \9 R. B; b  Copyright (c) 2012-2015 Sungeun K. Jeon
! a: a3 n( B$ S  Copyright (c) 2009-2011 Simen Svale Skogsrud
6 G* ], c, x4 O3 _+ m' ?. \7 L& L1 R: k' m. K; ]$ L+ a- k
  Grbl is free software: you can redistribute it and/or modify# i! i5 i' H+ g3 G& e4 s8 j, c, D# b
  it under the terms of the GNU General Public License as published by  j% p$ [: S7 K9 v1 ^0 c
  the Free Software Foundation, either version 3 of the License, or$ R: h% o) P5 `7 L; K" A; ~
  (at your option) any later version.
/ u- l( A; g5 i4 d# E' x( V4 G' f+ E! @
  Grbl is distributed in the hope that it will be useful,
- k- K! u5 F% O& ~% v. ?  but WITHOUT ANY WARRANTY; without even the implied warranty of
% A) ^- a. Z0 g  m8 g  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* a! V' S1 G: ]# Y' W8 a  GNU General Public License for more details.
5 k0 j6 Z1 c" x
2 g4 P4 H: M, S' M  You should have received a copy of the GNU General Public License# K7 e' v/ A) g0 G
  along with Grbl.  If not, see <http://www.gnu.org/licenses/>.) }3 p+ q  D; Z& W+ x
config.h  -编译时配置,Grbl的一部分
6 \1 h: k' [/ O6 d1 X% K( _2 p5 x* i" B( Q( i! g: D: S; ~$ A
版权(c)2012 - 2015 Sungeun K. Jeon
. U! T- S% y9 V/ @版权(c)2009 - 2011 Simen Svale Skogsrud
4 t, O1 q. A" s/ a- n+ @6 _) L* s" ~# t* F
Grbl是免费软件:可以重新分配和/或修改
3 x( R0 G; E( H) C  r5 L/ cGNU通用公共许可证的条款下发布的自由软件基金会,版本3的许可,或(任您选)其后的版本。9 P' u) N+ F: s/ B$ z5 |
1 r! F, q2 Y+ D% \& X8 D# V% [( M0 O
Grbl分布,希望这将是有用的,但是没有任何保证;没有即使的默示保证适销性或健身为特定目的。看到
+ W) m4 @* b6 }1 l8 o$ hGNU通用公共许可证的更多细节。* R" S+ M! {) u, Q$ @2 c

9 V# d# c4 f1 [( d你应该收到了GNU通用公共许可证的副本
" b/ L+ n- E. [& I连同Grbl。如果没有,看< http://www.gnu.org/licenses/ >。9 N, u- ^' _" p6 K1 y2 l% J: |
1 t5 ~& v( }- t$ f" x  P( }
*/
+ v/ k! t" t" w; [0 I3 p  : @0 n5 n9 Y3 ~
// This file contains compile-time configurations for Grbl's internal system. For the most part,
# h, r, d; A+ y7 _, G3 k/ d// users will not need to directly modify these, but they are here for specific needs, i.e.
/ ~# [8 n! g0 r" ?, y// performance tuning or adjusting to non-typical machines./ \# I# ]- u) m+ T' n
//这个文件包含编译时配置Grbl的内部系统。在大多数情况下,+ y2 M$ y" S, p4 A' P7 m
//用户不需要直接修改这些,但是他们在这里为特定的需求,即。. D5 K+ {3 b! k$ U" F
//性能调优或适应非典型的机器。- C' F# d: z5 g3 Y# O

" F0 \3 {/ [0 X' l// IMPORTANT: Any changes here requires a full re-compiling of the source code to propagate them.% Z- p9 L0 Y5 V
//重要:任何变化需要一个完整的基于源代码的传播。, W+ Q% l% a: M9 X
+ r6 `# k  ^5 h4 d
#ifndef config_h
7 A2 L# A! l& ?8 {& b#define config_h
. t* t3 z$ R, o1 b( u4 R#include "grbl.h" // For Arduino IDE compatibility.- M. `% ], r% w

! n$ r( Q' ]8 @3 X% u0 g7 |" m+ F% [// Default settings. Used when resetting EEPROM. Change to desired name in defaults.h
' }% k( T3 ]9 ?1 Y& Z  v// 默认设置。在重置eepm时使用。在defaults.h改变想要的名字
: m9 Z2 [2 g! e, O% M- w( f, i! w, `+ I" g& `! W
#define DEFAULTS_GENERIC9 ~$ \, a/ @6 r9 D5 u; t

+ H! S6 W  i7 k0 u% _. w// Serial baud rate& T0 B" @% g! K# I7 r
#define BAUD_RATE 115200                //配置串口波特率115200
! o+ J0 F. Q. e. w9 X" W8 I0 B
$ w- e  J- g' M: V9 X" y& f. I// Default cpu mappings. Grbl officially supports the Arduino Uno only. Other processor types* v8 x# H) m8 H
// may exist from user-supplied templates or directly user-defined in cpu_map.h
; v2 {2 ?4 l# d, a  o  E//默认cpu映射。Grbl正式支持Arduino Uno。其他类型的处理器可能存在cpu_map.h直接从用户提供的模板或用户定义的
5 b$ ?# F; c4 N  [( M! C
7 ]5 L" U% V9 n$ {#define CPU_MAP_ATMEGA328P // Arduino Uno CPU
* c1 u  P) s* J+ K, @" y8 ^, [7 l3 y2 u0 Q: k+ n, H! q1 Y
// Define realtime command special characters. These characters are 'picked-off' directly from the# \5 X7 w# Z4 x5 K8 v% {; F
// serial read data stream and are not passed to the grbl line execution parser. Select characters/ p. n8 T5 Y6 z- Q* ?, Q) c
// that do not and must not exist in the streamed g-code program. ASCII control characters may be 5 h; _, [. Q/ q% T9 P8 ~
// used, if they are available per user setup. Also, extended ASCII codes (>127), which are never in
, c" C$ q- u% u! i) q% a// g-code programs, maybe selected for interface programs.
0 K% E  y+ [$ j: n, S& y// NOTE: If changed, manually update help message in report.c.
2 N8 ~% F- t0 R4 b  h- u, ^
! h' Z+ Q8 ^# ?9 i2 T1 \//定义实时命令特殊字符。这些字符是直接从“各个击破”串口读取数据流并没有传递到grbl行执行解析器。选择角色2 N, a) A& t5 k# y( `
//不,不能存在于程序流刀位点。ASCII控制字符
$ I" b! U9 j  W' r, `& f1 e! y8 ~( _//使用,如果他们是可用的每个用户设置。同时,扩展的ASCII码(> 127),从来没有% ]) R4 n6 O0 c, e& a- N
//刀位点的程序,也许选择界面程序。
4 @/ C7 O- F) J//注意:如果改变,手动更新report.c帮助信息。5 O0 G' }' k, l; S2 q2 U( k6 ^
6 D  x0 z: @, m4 y& v: y
#define CMD_STATUS_REPORT '?': @4 \% _4 y" l% v7 J% D9 t% |; d
#define CMD_FEED_HOLD '!'+ }; e- B4 Y. l; G! R" p! k9 J: M
#define CMD_CYCLE_START '~'
% r7 _% u; |0 r' M+ Z$ H4 [#define CMD_RESET 0x18 // ctrl-x.4 ]" r  H6 ~' T
#define CMD_SAFETY_DOOR '@'7 k+ p$ H/ Z( L6 p

: o* c/ ~) _+ F" @7 N& L// If homing is enabled, homing init lock sets Grbl into an alarm state upon power up. This forces
! x. c6 i: P% O# B/ b// the user to perform the homing cycle (or override the locks) before doing anything else. This is& X) V- O& i7 K) i: ?% s6 m
// mainly a safety feature to remind the user to home, since position is unknown to Grbl.
0 F' H: ]5 x" I* |" e, ?7 x$ j
- ]% C  W) T: Y; S- k3 _; m& |/ n: E//如果启用了回原点,导航初始化锁集Grbl进入警报状态启动。这就迫使6 {5 }8 f: W4 \7 A5 a
//用户执行归航周期(或覆盖锁)在做任何其他事情之前。这是6 m) U' |& D  S
//主要安全功能,提醒用户家里,因为Grbl位置是未知的。+ \' }- K' L0 _* i8 h% }
- d; Y8 ]/ i! @% u+ D9 q, K5 |. s& w
#define HOMING_INIT_LOCK // Comment to disable
  O# N: z4 G# ]. D7 q8 K9 J
7 b, J. ^+ a2 J" y2 i7 }8 d( z* n" d// Define the homing cycle patterns with bitmasks. The homing cycle first performs a search mode) X4 c9 d1 ?8 |( D3 k; u: h: f
// to quickly engage the limit switches, followed by a slower locate mode, and finished by a short
2 m+ x+ l3 S" t7 Q" O( H9 |. K// pull-off motion to disengage the limit switches. The following HOMING_CYCLE_x defines are executed
' \1 I3 w1 S. S( P// in order starting with suffix 0 and completes the homing routine for the specified-axes only. If6 P2 I4 Z7 g' @; |/ _  b
// an axis is omitted from the defines, it will not home, nor will the system update its position.
& L0 c& c' b) r; @3 ?// Meaning that this allows for users with non-standard cartesian machines, such as a lathe (x then z,
! d3 {4 x0 ?) s6 ^- E2 M* X// with no y), to configure the homing cycle behavior to their needs.
: z! B9 _) }) n5 H, a3 ^1 h// NOTE: The homing cycle is designed to allow sharing of limit pins, if the axes are not in the same& ?! o4 Z9 x3 f* ~( \2 k) P  m+ k2 G
// cycle, but this requires some pin settings changes in cpu_map.h file. For example, the default homing
9 @4 n; I  V2 Z2 P1 a7 j1 G; W// cycle can share the Z limit pin with either X or Y limit pins, since they are on different cycles.- t- e& E4 P$ L
// By sharing a pin, this frees up a precious IO pin for other purposes. In theory, all axes limit pins1 H, d" c! P* ~1 d
// may be reduced to one pin, if all axes are homed with seperate cycles, or vice versa, all three axes& q" S1 t# z; ]; P: ?! x4 y) ?
// on separate pin, but homed in one cycle. Also, it should be noted that the function of hard limits
) a2 Q+ }5 q( }1 s) ^( C* }// will not be affected by pin sharing.3 C5 D: O+ ~+ t6 q! L' a
//定义导航循环模式的位掩码。归航周期首先执行一个搜索模式9 V1 f9 h5 i" f) j; J. [% N9 R- a
//快速进行限位开关,其次是较慢的定位模式,完成了由一个短# y$ T- T/ A$ J0 C6 k# Z
//拖出运动脱离限位开关。以下HOMING_CYCLE_x定义执行0 ?5 ~' ?2 V% j' Z+ {
//为了与后缀0开始并完成specified-axes只寻的例程。如果0 Y- {. g5 |% J. T
//定义省略一个轴,它会不在家,也不会系统更新它的位置。
, w6 \" z) Z* T# t% k//意义,这允许用户与非标准笛卡尔的机器,比如车床(x,z,
: R: S' {3 p/ @//没有y),配置导航循环行为对他们的需求。% q6 B' L6 l' p- g6 m2 N# z$ f
//注意:归航周期允许共享限制针,如果轴不相同4 V; v; k+ A& h8 H5 }$ e9 J. d3 o
//循环,但这需要一些销设置cpu_map的变化。h文件。例如,默认的导航+ J9 Q0 {2 e. g% {9 F: b& z* y
//循环可以分享Z限位销X或Y限制针,因为它们是在不同的周期。
: M: n' ^$ {+ Y5 q$ L//通过共享一个销,这腾出宝贵的IO销用于其他目的。从理论上讲,所有轴限制别针! C1 E0 K, o7 g. Q" U, q! y
//可能会减少到一个销,如果所有轴与分离周期居住的地方,反之亦然,所有三个轴
9 i, U8 H# a6 s0 Y' H" g+ w//在不同销,但这时候一个周期。同时,应该注意的是,硬限制的功能
0 }# M) y) q: E% i//将不会影响销共享。$ Q# R6 T5 m2 G  d% [& {/ D
//注意:默认设置为一个传统的硬件数控机器。z轴首次明确,其次是X和Y。) j$ T$ z  O: x* d, R
" @! O% d' u2 D% k$ t
// NOTE: Defaults are set for a traditional 3-axis CNC machine. Z-axis first to clear, followed by X & Y.5 B$ b  f9 g  e" T2 S3 q
#define HOMING_CYCLE_0 (1<<Z_AXIS)                // REQUIRED: First move Z to clear workspace. 第一步Z清除工作区。
& u. K0 [1 z3 ]9 O+ B#define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // OPTIONAL: Then move X,Y at the same time.然后X,Y在同一时间。
3 n; A. P6 t" l// #define HOMING_CYCLE_2                         // OPTIONAL: Uncomment and add axes mask to enable/ L+ c2 i, ^# b' {
3 L9 A5 j3 j7 k2 Z) V1 d
// Number of homing cycles performed after when the machine initially jogs to limit switches.
$ A! T' O) P* R- \) S8 @// This help in preventing overshoot and should improve repeatability. This value should be one or & x5 I: F. B8 O. S0 L
// greater./ W! J! {8 a. T: K2 o' U+ U. H
//执行回原点循环次数后,当机器最初慢跑限位开关。这个帮助防止过度,应该提高重复性。这个值应该是一个或大。
, T4 E3 D  |9 G2 _, B2 z/ r1 {4 S) N* M3 E
#define N_HOMING_LOCATE_CYCLE 1 // Integer (1-128)
: {7 ?: z( |7 {2 g3 b
7 r  a, C& g6 O2 G1 j6 ~" k7 Q// After homing, Grbl will set by default the entire machine space into negative space, as is typical
1 _& T6 N  J0 A& n// for professional CNC machines, regardless of where the limit switches are located. Uncomment this 3 {3 h( B8 w1 R: n& k3 Y* j2 y5 ^
// define to force Grbl to always set the machine origin at the homed location despite switch orientation.2 V! e9 O2 s, r: @! U9 C
* O" {. T$ o, p: j* e( l5 d
//导航后,默认Grbl将整个机器空间留白,是典型的专业数控机器,不管限位开关所在的地方。
$ Y% J9 o, D& E5 q//取消这定义迫使Grbl总是在这时候位置设置机器原点尽管开关方向。- h# X( I6 X" p
- g% n6 m# S9 e
// #define HOMING_FORCE_SET_ORIGIN // Uncomment to enable.4 W& Q# I' w/ R* ~& i, ~  y

3 i) w* \) S, z/ x% j  W/ n, k. `
: O# C+ C3 D6 v) f3 w// Number of blocks Grbl executes upon startup. These blocks are stored in EEPROM, where the size
/ ~! x0 h4 J/ e. i- `/ s% z; ?// and addresses are defined in settings.h. With the current settings, up to 2 startup blocks may
3 ~) J; X; l! z5 v& A// be stored and executed in order. These startup blocks would typically be used to set the g-code
. P' X/ P* G$ X" X2 }  o// parser state depending on user preferences.
! A& P& u& ^9 J7 E6 M1 f7 v
+ k7 E+ B% ?5 f//块Grbl启动时执行的数量。这些块存储在eepm,大小; x2 g1 O' H$ k, q0 r6 L; u: C" A
//和地址在settings.h中定义。与当前设置,可能2启动块/ W5 T7 N* _6 y( H! B8 }0 {0 {
//存储和执行。这些启动块通常被用来设置刀位点2 y% {( A4 l! b& {. ~
//解析器的状态取决于用户首选项。- V0 `# U+ n2 b* M0 x

2 v( \$ l& {. R3 C6 o1 k#define N_STARTUP_LINE 2 // Integer (1-2)
: L/ ^, n% I% W7 p0 z
$ I: f: I, O: ~1 |' A# Z# O' `// Number of floating decimal points printed by Grbl for certain value types. These settings are
7 F, U5 d( ~8 j: g  z// determined by realistic and commonly observed values in CNC machines. For example, position
( Z3 m2 R# ~. V% j7 r4 E// values cannot be less than 0.001mm or 0.0001in, because machines can not be physically more
' q+ ~& Y# G) L( G// precise this. So, there is likely no need to change these, but you can if you need to here.
, q- L, }4 @( ^) X3 h1 j( R// NOTE: Must be an integer value from 0 to ~4. More than 4 may exhibit round-off errors.
0 K1 p0 f3 P' K9 v
2 s- L; a1 S4 s5 _// Grbl浮动小数点的数字印刷的特定的值类型。这些设置是& q: r4 N- o) Y
//一般由现实和观测值在数控机器。例如,位置
" a4 r+ F2 x7 a//值不能小于0.001毫米或0.0001,因为机器不能身体更多
" J4 T" m) {* k( Z, h) y//精确。因此,有可能不需要改变这些,但你可以在这里如果你需要。
. E$ O, y& F: W. x# x' S//注意:必须是一个整数值从0 ~ 4。超过4可能出现舍入错误。) E2 w& @$ `' p7 L& ]4 R' w1 c5 ~
* l) u9 \7 W% ?" w
#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 协调或位置价值英寸
* x( ]( c' r" w# f#define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 协调在毫米或位置价值
* B/ z, D5 c) ^; n) A#define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分钟的速度值
2 _- U  ?) O5 s9 N" I6 O* \; Y#define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分钟/ t, z$ s/ g9 D/ m
#define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 对浮点小数设置值
& X; a# a3 q, v6 O; r
5 p/ d' u) l% y1 F9 F0 q8 G// If your machine has two limits switches wired in parallel to one axis, you will need to enable
- h% L' D! L% K. `7 d9 e3 U// this feature. Since the two switches are sharing a single pin, there is no way for Grbl to tell- k- H$ y5 u$ H% E9 Z
// which one is enabled. This option only effects homing, where if a limit is engaged, Grbl will ) E9 Z; b' ?2 {4 \1 j
// alarm out and force the user to manually disengage the limit switch. Otherwise, if you have one5 {( o" e  y$ R. M4 E' t
// limit switch for each axis, don't enable this option. By keeping it disabled, you can perform a! w) |. o$ f' w" n) ^
// homing cycle while on the limit switch and not have to move the machine off of it.  L3 _+ d6 f$ N- B6 ^

- O4 j; |& w* b1 Q/ a  F//如果你的机器有两个极限开关连接在平行于一个轴,您需要启用1 R6 i6 `# a& M6 t7 r
//这个特性。自从两个交换机共享一个销,没有办法Grbl告诉, v. a& Y& b0 L6 c
//启用哪一个。此选项仅影响归航,如果限制,Grbl意志& i( o$ J6 g$ T3 s4 e0 Z
//报警,迫使用户手动松开限位开关。否则,如果你有一个
1 W( a" X+ b; j' t6 a1 M//为每个轴限位开关,不启用该选项。通过保持禁用,您可以执行% ~% A5 |) M2 g- o8 A
//导航循环在限位开关并没有将这台机器。- W4 n( c% L/ l. l+ J! \- E9 O

! f. X$ r. s! I; i( p  v. F# \6 W// #define LIMITS_TWO_SWITCHES_ON_AXES
1 f4 G( n7 W* f' \( }( a: c  i2 |: ~; B: ~1 R2 M
// Allows GRBL to track and report gcode line numbers.  Enabling this means that the planning buffer3 V1 a* @$ i! s
// goes from 18 or 16 to make room for the additional line number data in the plan_block_t struct# `+ S5 p8 x" r; b2 s' W
7 E* J  ~% Y: k- r( @% T" s
//允许GRBL跟踪和报告gcode行号。使这意味着计划缓冲从18岁或16岁,为额外的行号plan_block_t结构中的数据: W. V$ Z" C6 V+ ~

  n% S. k$ O& \( J; v; F// #define USE_LINE_NUMBERS // Disabled by default. Uncomment to enable.
) E5 T2 F0 f$ w! @  n  p8 z& O, P$ [1 q/ s0 S3 O  K. u$ d
// Allows GRBL to report the real-time feed rate.  Enabling this means that GRBL will be reporting more 7 l# l8 k1 V% E: E/ ?' C# z3 X1 K
// data with each status update.* Z  N7 d8 \* \/ _* V' @' [! e
// NOTE: This is experimental and doesn't quite work 100%. Maybe fixed or refactored later.( \% |# ~  `7 a3 u
//允许GRBL报告实时进给速率。使这意味着GRBL将报告数据和状态更新。
/ K! t% h4 [) _//注意:这是实验和100%没有工作。也许以后固定或重构。
& _6 Y" M0 e  `; G, g( I# v! }/ [
( v' d$ D% [& @9 V  S// #define REPORT_REALTIME_RATE // Disabled by default. Uncomment to enable.
9 l% J' p6 E/ `8 m$ {) O1 }% D4 F2 X$ o5 D
// Upon a successful probe cycle, this option provides immediately feedback of the probe coordinates; e1 G: }, _1 ^) _
// through an automatically generated message. If disabled, users can still access the last probe
# N$ V( T6 g* M// coordinates through Grbl '$#' print parameters.
! y, E# S0 D6 z& V0 O  N  Z0 \3 k! x//在一个成功的调查周期,这个选项提供立即反馈的探测器坐标
, e* W: N! P! j( _/ c//通过一个自动生成的消息。如果禁用,用户仍然能够访问调查
% X" @3 ?0 t' K' q//坐标通过Grbl $ #的打印参数。
, E7 U. P; r' \9 a, K. A& ]( z9 n2 |2 \8 C- C- c. }
#define MESSAGE_PROBE_COORDINATES // Enabled by default. Comment to disable.
' E9 o- i9 k2 j3 y1 Z
+ a( c% f/ L2 }, ]8 m4 ?( v// Enables a second coolant control pin via the mist coolant g-code command M7 on the Arduino Uno
2 f! h2 l' ]) A// analog pin 5. Only use this option if you require a second coolant control pin.9 x; h+ N' U/ O4 I/ z/ ?) @
// NOTE: The M8 flood coolant control pin on analog pin 4 will still be functional regardless.. x$ ]  \3 ?* {" |+ B$ Q
// #define ENABLE_M7 // Disabled by default. Uncomment to enable.$ N& e  A  p2 a" P  X

9 m4 u& @: s( i1 j$ X: \1 O6 Q// This option causes the feed hold input to act as a safety door switch. A safety door, when triggered,
* i+ \1 `4 s5 u& C// immediately forces a feed hold and then safely de-energizes the machine. Resuming is blocked until' I5 c: I: U% H; z; Y" V
// the safety door is re-engaged. When it is, Grbl will re-energize the machine and then resume on the
0 z" u. ?, P; H$ j7 k// previous tool path, as if nothing happened.- {& V; o/ E  B8 }7 @
// #define ENABLE_SAFETY_DOOR_INPUT_PIN // Default disabled. Uncomment to enable.
8 M; S7 E/ Z  m6 v
; @' U" M. U! \7 H// After the safety door switch has been toggled and restored, this setting sets the power-up delay
% x3 g8 R5 D& v// between restoring the spindle and coolant and resuming the cycle.
9 D$ l' z8 T/ }9 S// NOTE: Delay value is defined in milliseconds from zero to 65,535.
$ Q9 O- ?' c* q- `$ Q* f, b' ~
//定义导航循环模式的位掩码。归航周期首先执行一个搜索模式, L0 D% z# ?: u5 v, w+ W
//快速进行限位开关,其次是较慢的定位模式,完成了由一个短2 `. [% g  V8 J) t
//拖出运动脱离限位开关。以下HOMING_CYCLE_x定义执行
/ e  d2 d. R  r% I, ?3 N1 X//为了与后缀0开始并完成specified-axes只寻的例程。如果
* G. q# W1 B- }  ?+ S* ~//定义省略一个轴,它会不在家,也不会系统更新它的位置。
2 G0 y& p% A- W5 U//意义,这允许用户与非标准笛卡尔的机器,比如车床(x,z,3 P% s7 ]9 u) C
//没有y),配置导航循环行为对他们的需求。
' R  O! X7 B7 F- w$ s  J+ }  C) H//注意:归航周期允许共享限制针,如果轴不相同' |3 j6 |6 \$ k
//循环,但这需要一些销设置cpu_map的变化。h文件。例如,默认的导航
0 }2 D2 `& C: v5 ]: R8 |. ]//循环可以分享Z限位销X或Y限制针,因为它们是在不同的周期。" N) ?. [1 _; G" m
//通过共享一个销,这腾出宝贵的IO销用于其他目的。从理论上讲,所有轴限制别针; w9 G9 w! J! j" O4 L3 {* G) ^
//可能会减少到一个销,如果所有轴与分离周期居住的地方,反之亦然,所有三个轴
' D/ U% c' O# I8 Z4 b//在不同销,但这时候一个周期。同时,应该注意的是,硬限制的功能7 B' x) Y* v5 Y. D5 y& O* D
//将不会影响销共享。. W1 M5 M% }, T8 r4 N; B+ x
//注意:默认设置为一个传统的硬件数控机器。z轴首次明确,其次是X和Y。
2 d& d! e7 u( I6 b% L! A
: e! e; }& f2 x- }+ J3 ?3 R- \5 q
/ F$ h1 B. G3 B7 h+ q#define SAFETY_DOOR_SPINDLE_DELAY 40006 ?6 i' p% |+ F! Y! a
#define SAFETY_DOOR_COOLANT_DELAY 1000
2 A3 n9 N+ w: B& m$ }
2 M) w0 u6 k2 y" H: C9 S( n2 j8 B// Enable CoreXY kinematics. Use ONLY with CoreXY machines.
( \* ~; ]4 [! u/ e( E# k// IMPORTANT: If homing is enabled, you must reconfigure the homing cycle #defines above to
: X& Z/ B5 M8 r2 ~: O& Q//启用CoreXY运动学。只使用与CoreXY机器。
2 T3 ^/ F0 P) N- [! ~9 l* {//重要:如果启用了自动寻的,你必须重新配置导航循环#定义上面4 u) Z+ Y! g2 \4 ?

+ `, K/ b5 B1 b% h* ^// #define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS)- |8 V. o3 L' X7 }$ x. Z9 q$ V
+ D4 z- j, \; Y. X
// NOTE: This configuration option alters the motion of the X and Y axes to principle of operation7 q/ ~* ?. I& w% {9 y7 ?% L
// defined at (http://corexy.com/theory.html). Motors are assumed to positioned and wired exactly as0 P/ g" e: _% f2 z' T/ V/ S
// described, if not, motions may move in strange directions. Grbl assumes the CoreXY A and B motors
# o6 d- U+ N6 O& k% s// have the same steps per mm internally.
2 O5 z2 i/ k. u//注意:这种配置选项改变X和Y轴的运动原理,操作
0 T* V3 F* V  L//定义(http://corexy.com/theory.html)。汽车被认为定位和连接一样7 ?/ N& `8 d8 b3 [  s, h
//描述,如果没有,运动可能会奇怪的方向移动。A和B Grbl假设CoreXY马达& o: v2 n3 B2 R% F; V. y
//每毫米内部有相同的步骤。: @  j( k2 S) D' b/ X. ~% d

5 c+ E( p( r2 w, K( A% l: M// #define COREXY // Default disabled. Uncomment to enable.- N" F  d9 H2 g: L

0 G3 v# Q  H+ Z3 ?: _+ v4 b6 Z// Inverts pin logic of the control command pins. This essentially means when this option is enabled6 z) @, \: y3 o* X& b1 X) U
// you can use normally-closed switches, rather than the default normally-open switches.
$ R& `+ J$ p" I) {7 s/ _5 u: N" j// NOTE: Will eventually be added to Grbl settings in v1.0.
$ Y  i( L- L  N6 ?; g5 j& ]: ?//反转针销逻辑的控制命令。这实质上意味着当启用这个选项
3 l1 \, q2 ^3 J: j+ V//可以使用闭合开关,而不是默认的常开开关。2 k; i6 n; w  }/ @. I
//注意:最终将被添加到在v1.0 Grbl设置。
# V: D& C" ^6 s( B
. l. E2 {6 n; i# B6 _// #define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.
5 w. j: J7 T! |" x
4 e( ]/ y4 O$ ~- Y+ V0 \( Y// Inverts the spindle enable pin from low-disabled/high-enabled to low-enabled/high-disabled. Useful
! p8 S  C- E' I& x1 |2 Z// for some pre-built electronic boards.
+ B5 x  g& K6 {; O// NOTE: If VARIABLE_SPINDLE is enabled(default), this option has no effect as the PWM output and 8 H  B4 L5 S* L5 Q8 r+ ?
// spindle enable are combined to one pin. If you need both this option and spindle speed PWM, 6 y$ N) h8 {! b5 P/ `
// uncomment the config option USE_SPINDLE_DIR_AS_ENABLE_PIN below.
0 W6 A" C& J9 l' `. \//反转主轴使销从low-disabled / high-enabled low-enabled / high-disabled。有用的
9 I* f) U, s" S; M//预构建的电子板。
8 w" r* H0 d& a//注意:如果启用了VARIABLE_SPINDLE(默认),这个选项作为PWM输出并没有影响9 c9 |0 _$ D, p5 x: l
//销轴使结合。如果你需要这个选项和主轴转速PWM,
: z4 c1 g! R& S( x2 p+ g7 O//取消注释以下配置选项USE_SPINDLE_DIR_AS_ENABLE_PIN+ _! I% u! o$ R% n" @

  c: M) l3 `" D8 ^$ J. z/ B// #define INVERT_SPINDLE_ENABLE_PIN // Default disabled. Uncomment to enable.
8 K, k% t# l2 f, A4 E# g8 V5 g; G
/ Q/ x1 V  _1 h: u  k. ?$ D// Enable control pin states feedback in status reports. The data is presented as simple binary of
& N+ X" E4 e) M# d// the control pin port (0 (low) or 1(high)), masked to show only the input pins. Non-control pins on the
9 l* S' Z8 V: s0 e1 E// port will always show a 0 value. See cpu_map.h for the pin bitmap. As with the limit pin reporting,# U8 p) ?7 u. s
// we do not recommend keeping this option enabled. Try to only use this for setting up a new CNC./ j% }, ]; O- y8 d) d2 b
//启用控制销状态反馈状态报告。作为简单的二进制数据
) k) h% ?4 ^( i- W6 \0 ?//控制针端口(0(低)或1(高)),蒙面,只显示输入插脚。非控制性针上3 B0 l; m* N3 @0 j3 T
//端口总是显示0值。看到cpu_map。针位图h。与限制销报告,
* H4 @' `# I0 ~3 q: {5 r. c//我们不推荐保持启用这个选项。尽量只使用这个设置一个新的数控。$ a: s5 }* V. u5 E
3 d1 y0 L( `( f
// #define REPORT_CONTROL_PIN_STATE // Default disabled. Uncomment to enable.
5 G) u9 f- c* ~: c) n! H( ~& L, _, g: F! x+ w* l
// When Grbl powers-cycles or is hard reset with the Arduino reset button, Grbl boots up with no ALARM
3 f! j$ z8 [# O7 o2 h3 i1 {// by default. This is to make it as simple as possible for new users to start using Grbl. When homing5 J: S6 P& U, T& r% z/ Q
// is enabled and a user has installed limit switches, Grbl will boot up in an ALARM state to indicate
* i! ]( W! n4 v// Grbl doesn't know its position and to force the user to home before proceeding. This option forces
% m& D( a$ q- ]3 [1 K* z; o6 D! w// Grbl to always initialize into an ALARM state regardless of homing or not. This option is more for; F( V1 s0 Q4 h* p( {% Z5 v! [/ Z  y
// OEMs and LinuxCNC users that would like this power-cycle behavior.
9 S7 i5 R9 i. ^7 K% [( p//当Grbl powers-cycles还是硬重置Arduino复位按钮,Grbl启动没有报警6 _9 p' w. A" L! l+ I5 S
//默认情况下。这是为了让新用户尽可能简单使用Grbl开始。当归航
3 a/ v1 J( e* u7 R% i9 {//启用和用户安装限位开关,Grbl将启动报警状态指示9 g6 e6 x; N/ Y6 [3 D  Z: N
// Grbl不知道它的位置,迫使用户在继续之前回家。这个选项部队
4 q& w; [9 e; T  u// Grbl总是初始化进入警报状态不管归航。这个选项是更多, g- I" h. t% {# a
//原始设备制造商和LinuxCNC用户这样的控制行为。
8 p# q2 P; @% ?) z  r
9 w8 A6 t8 W+ ?7 g+ m% F0 S// #define FORCE_INITIALIZATION_ALARM // Default disabled. Uncomment to enable.$ c( P* Y  d% j2 |0 c9 l" k

5 X# k. n+ \5 v5 Q// ---------------------------------------------------------------------------------------; h; g" Z9 v( @5 `7 d8 Q% w1 s6 Y
// ADVANCED CONFIGURATION OPTIONS://高级配置选项:
0 o( P0 z/ L4 ^" b4 w
  g4 Z4 n* ]/ c( x// Enables minimal reporting feedback mode for GUIs, where human-readable strings are not as important.+ ]# g. \$ J7 G/ o, N$ H' n! C
// This saves nearly 2KB of flash space and may allow enough space to install other/future features.
% f* f/ P4 z3 T) k& z. r5 P// GUIs will need to install a look-up table for the error-codes that Grbl sends back in their place.2 ?: b, t, C+ ?5 P
// NOTE: This feature is new and experimental. Make sure the GUI you are using supports this mode.! f1 z: }! l. {% E+ c2 z- y
  T: G# X/ _6 J& K5 |
// gui允许最小的报告反馈模式,人类可读的字符串在哪里不重要。
% _, b0 j% N0 p  U! Q/ j9 i//这个节省近2 kb的闪存空间,允许足够的空间来安装其他/未来的功能。
( R1 o3 h, Y5 D7 ^// gui需要安装一个查找表的错误代码Grbl发回。
( u4 s2 I" I3 P3 U' G//注意:此功能是新的和实验。确保您使用的GUI支持这种模式。' r! }( ?1 V( U; V1 P& C7 {
3 p3 k# U; E% v6 ]+ e* j- e+ P
// #define REPORT_GUI_MODE // Default disabled. Uncomment to enable.
! g9 l# q; g/ W% \$ z9 K% Q, B& _; j- O/ C3 Y+ y0 f8 o; R$ m
// The temporal resolution of the acceleration management subsystem. A higher number gives smoother1 [! M- u/ z8 x1 Z5 J
// acceleration, particularly noticeable on machines that run at very high feedrates, but may negatively
3 _. J, A, W7 x3 n1 L0 c, _// impact performance. The correct value for this parameter is machine dependent, so it's advised to& e8 ^" k* _( H: W
// set this only as high as needed. Approximate successful values can widely range from 50 to 200 or more., k3 ]/ X1 W2 z
// NOTE: Changing this value also changes the execution time of a segment in the step segment buffer.
, }# ^8 T1 b, W. f' s5 d+ d// When increasing this value, this stores less overall time in the segment buffer and vice versa. Make
7 v% S* B- x( S: Z( S// certain the step segment buffer is increased/decreased to account for these changes., v/ M. l" T2 ?& \5 @8 R  f% n
//加速度的时间分辨率管理子系统。更多更平稳
- D7 ^  h- U  n8 L1 `; ~& T" D//加速度,特别明显的机器上,运行在非常高的进料速度,但可能负面
6 ^. \- G5 t- q7 p1 r//影响性能。正确的值为这个参数是依赖于机器的,所以建议/ J) n7 i2 }& h
//这只设置为高。近似成功的价值观可以广泛的范围从50到200或者更多。
& c# E. q. k, W3 Q) `; \# c//注意:改变这个值也变化的部分步骤的执行时间缓冲。
+ F+ ~* t& B# O" |" }$ H9 B6 f//增加这个值时,这个商店部分缓冲区的总时间减少,反之亦然。使
* P$ Q' Y8 M5 x//特定步骤段缓冲是考虑这些变化增加/减少。1 N" L  C* Q7 i' \
, [1 |- m2 W" O7 k4 s, W
#define ACCELERATION_TICKS_PER_SECOND 100  //加速度的时间分辨率管理子系统。更多更平稳
- F% R, W0 L* R8 ]9 c7 j' [% Y& Y5 V
// Adaptive Multi-Axis Step Smoothing (AMASS) is an advanced feature that does what its name implies, 9 J' B# {* K/ n, f) @8 v% }& R
// smoothing the stepping of multi-axis motions. This feature smooths motion particularly at low step
, p% ?; e) B2 }2 l4 l$ }; G// frequencies below 10kHz, where the aliasing between axes of multi-axis motions can cause audible $ \4 b2 E; b( s' F% Q. t3 N: G* W% Q
// noise and shake your machine. At even lower step frequencies, AMASS adapts and provides even better2 ^) L" D1 f7 E+ h' }4 }
// step smoothing. See stepper.c for more details on the AMASS system works.. @% n' g8 ^* d& O5 o
//自适应多轴步平滑(积累)是一种先进的功能,它的名字所暗示的那样,
# p0 j0 ~0 d- z& l! s5 @//平滑的多轴步进运动。这个特性平滑运动尤其是在低一步% p. M0 J% ~) y
//频率低于10 khz,轴之间的混叠的多轴运动可能导致音响5 k* F; U0 h) ^. x
//噪音和震动你的机器。在更低的频率步,积累适应并提供更好5 d# d+ H0 Y/ Z2 @- Q1 y& U
//步骤平滑。看到步进。c更多细节的积累系统的工作原理。: q0 t! P! H0 }
" a- ~/ ]+ P, Y9 U
#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING  // Default enabled. Comment to disable.//自适应多轴步平滑
, M6 v- F4 f, i
5 ~) c9 E6 w8 X% M- R; M' T$ h// Sets the maximum step rate allowed to be written as a Grbl setting. This option enables an error " T  O& B' a1 _: Z4 d0 W* l
// check in the settings module to prevent settings values that will exceed this limitation. The maximum
+ |: C4 z' p. \; Y! e! a, w: U4 [# C3 S// step rate is strictly limited by the CPU speed and will change if something other than an AVR running! X7 y# ^) a( K; X4 s
// at 16MHz is used.% F* R2 c* @2 J, ]5 G3 \5 c
// NOTE: For now disabled, will enable if flash space permits.
2 @& h8 M! R  b, w& S* i//设置最大一步速率可以写成Grbl设置。这个选项可以使一个错误
0 v( ~+ G( B- A; h//设置模块中检查,防止设置值将超过这个限制。的最大
4 a, w3 \. F" R; L& S# S//步骤严格限制的CPU速度也会改变如果是其他AVR运行% K2 g4 h* [' ^, c
//使用16兆赫。
3 w+ i- E' h& L! H: r8 V% e//注意:现在残疾,将使如果flash空间许可。/ |7 [( t2 a/ g7 H& ]
/ O9 L( |7 x: l( `3 v
// #define MAX_STEP_RATE_HZ 30000 // Hz 设置最大一步速率
' E& U! A6 v+ o, @7 c/ T% G* s
7 T+ N" x: P, R  d7 B; Z+ O// By default, Grbl sets all input pins to normal-high operation with their internal pull-up resistors
0 p  W2 s: J' f6 ^2 N// enabled. This simplifies the wiring for users by requiring only a switch connected to ground,
/ T- |7 I; P5 \+ r// although its recommended that users take the extra step of wiring in low-pass filter to reduce
1 f1 ?! a% \5 P# N" K: U- S" B# `// electrical noise detected by the pin. If the user inverts the pin in Grbl settings, this just flips
8 o9 |8 J1 R& N: z// which high or low reading indicates an active signal. In normal operation, this means the user
& t, k% R. R& s9 s& t" _// needs to connect a normal-open switch, but if inverted, this means the user should connect a
3 }; X2 S. m* `  {  c// normal-closed switch. " K8 b0 ]3 e5 r& D% z; L  j
// The following options disable the internal pull-up resistors, sets the pins to a normal-low
- o( m2 T' w: L2 L( a/ a// operation, and switches must be now connect to Vcc instead of ground. This also flips the meaning
, x7 b* b. Z( N// of the invert pin Grbl setting, where an inverted setting now means the user should connect a
% h1 R5 {/ H" x6 {' p+ V// normal-open switch and vice versa.
/ h1 c% W+ {8 y7 t2 n& c// NOTE: All pins associated with the feature are disabled, i.e. XYZ limit pins, not individual axes.* @$ z/ T2 d7 g( a% l
// WARNING: When the pull-ups are disabled, this requires additional wiring with pull-down resistors!
  k- D7 Y4 W% o6 l, d//默认情况下,Grbl所有输入引脚设置为正常高操作的内部上拉电阻# b' c) `$ ?, c8 N$ c
//启用。这简化了布线为用户只需要一个开关连接到地面,7 p+ a1 ?' f; s3 p& J1 r( A$ l/ i. D
//虽然其建议用户采取额外的步骤,在低通滤波器来减少布线. [1 P4 t* B- @# R- _! n
//电噪音检测销。如果用户反转的销Grbl设置,这只是翻转8 v$ n  s- N* B7 V1 D
//读高或低表明一个积极的信号。在正常操作中,这意味着用户5 u  B; s5 \5 X# X# q6 R
//需要连接一个常开开关,但如果倒,这意味着用户应该连接% ]3 X- D5 ^( {) M( O
// normal-closed开关。
! V! t8 T3 n9 g# j! |//以下选项禁用内部上拉电阻,一般低设置别针3 E$ H3 }+ V! V# u6 e
//操作,现在开关必须连接到Vcc代替地面。这也掀的意思
- ?  u7 k% t( a4 B//反销Grbl设置,一个倒置的设置现在意味着用户应该连接+ k( J* m3 O. ~( u8 y
//常开开关,反之亦然。$ O( |* ?; L" E' w& N& F
//注意:所有针与功能被禁用,例如XYZ限制针,而不是单独的轴。
8 j7 D5 E; W( W4 \% i//警告:引体向上被禁用时,这需要额外的布线与下拉电阻!
) f# Y+ I& |. w- d) x8 W! p+ p' U& W  V3 w9 y. U5 [8 w! d: R  X: U
//#define DISABLE_LIMIT_PIN_PULL_UP //以下选项禁用内部上拉电阻
" u+ @2 M$ R& |4 @" o+ G! b//#define DISABLE_PROBE_PIN_PULL_UP
- b. X7 R+ u, [; W//#define DISABLE_CONTROL_PIN_PULL_UP, N* Y5 I) B9 k
9 G# ?/ V; l1 u3 i3 _
// Sets which axis the tool length offset is applied. Assumes the spindle is always parallel with
9 f) i8 N5 K- g  L// the selected axis with the tool oriented toward the negative direction. In other words, a positive
8 A5 B5 L  C, ]/ r// tool length offset value is subtracted from the current location.
* c3 c2 @. [' Q( l& o: u* W4 s//设置哪个轴长度补偿应用的工具。假设轴总是与9 Y5 J5 K- _% t( A1 ~
//选择轴工具面向负方向。换句话说,一个积极的
" Q' g$ H4 F: y3 [//工具长度偏移值减去从当前位置。( n0 A! ]$ {6 [7 a% z' G
, {* B0 Z( u. l
#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS // Default z-axis. Valid values are X_AXIS, Y_AXIS, or Z_AXIS.设置哪个轴长度补偿应用的工具1 _0 J" A. }6 P) i7 E
6 J( p: g  j8 w# `0 n+ O: Q+ X
// Enables variable spindle output voltage for different RPM values. On the Arduino Uno, the spindle+ X! C  ?2 Z( ^! b
// enable pin will output 5V for maximum RPM with 256 intermediate levels and 0V when disabled.1 g$ b6 u6 T: Q8 T$ W: \. k# G
// NOTE: IMPORTANT for Arduino Unos! When enabled, the Z-limit pin D11 and spindle enable pin D12 switch!* K% v' t- ^4 O
// The hardware PWM output on pin D11 is required for variable spindle output voltages.
2 G+ e9 K7 |6 s//允许变量轴输出电压不同的转速值。Arduino Uno,主轴
6 j3 ^9 ?6 n1 `//启用销将输出5 v的最高转速256中级水平和0 v时禁用。
3 n8 I0 w5 A* D2 e//注意:重要Arduino凯泽本人!当启用时,Z-limit销这里和轴销D12开关!( c1 J/ m& d' z2 [/ T
//硬件PWM输出销这里需要变量轴输出电压。9 K. M  T! p4 Q# b0 ^& P
2 |% l$ U  G2 G; @* w6 i% U
#define VARIABLE_SPINDLE // Default enabled. Comment to disable.//允许主轴输出电压不同的转速值
! I# N" \7 J& r3 l
7 |4 I; W3 o" f( ?  X// Used by the variable spindle output only. These parameters set the maximum and minimum spindle speed3 M, z1 ]2 N0 ]3 F7 b2 M/ U" c" |# [
// "S" g-code values to correspond to the maximum and minimum pin voltages. There are 256 discrete and 6 k# c! e/ g+ ]. p7 L+ L6 w  m
// equally divided voltage bins between the maximum and minimum spindle speeds. So for a 5V pin, 10008 N, W5 `; v: B' Z0 U! D
// max rpm, and 250 min rpm, the spindle output voltage would be set for the following "S" commands:
  ~# ?$ _- b; o: a: Y9 E# D  m// "S1000" @ 5V, "S250" @ 0.02V, and "S625" @ 2.5V (mid-range). The pin outputs 0V when disabled.' m' ?: x* y' [* u. ^. ^8 v
//使用的变量轴输出。这些参数设置最大和最小轴转速* y2 z" m8 a% o0 J4 X, h3 N+ U! T
//“S”刀位点值对应于销电压的最大值和最小值。有256个离散和
4 Q! q$ A) b0 V9 @: \! {//电压平均分配箱主轴速度的最大值和最小值之间。所以对于一个5 v销,1000# h  l% d7 i# A/ D
// max rpm,250分钟rpm,主轴输出电压将为以下“S”命令:
6 O# }) T: {/ \// @“S1000 5 v,“S250”@ 0.02 v,“S625”@ 2.5 v(中档)。销输出0 v时禁用。
7 ~% `9 G4 q9 U3 J3 v2 C$ B. ]; X5 {- s4 E
#define SPINDLE_MAX_RPM 1000.0 // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.
' c) R- v" j0 b#define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.
- p1 Z9 d: ^9 T3 n5 }: [
8 ^4 _7 }. r2 C. Z// Used by variable spindle output only. This forces the PWM output to a minimum duty cycle when enabled.3 Z: V  L0 i  d( _8 Y, S# i+ k$ n  ]+ Z
// When disabled, the PWM pin will still read 0V. Most users will not need this option, but it may be
- D  s: c/ R( s' B// useful in certain scenarios. This setting does not update the minimum spindle RPM calculations. Any0 I# A0 k0 j9 E- H, g6 E: O
// spindle RPM output lower than this value will be set to this value.3 }3 H) o- A" e+ P% A# C/ c2 h
//使用的变量轴输出。这迫使PWM输出最小占空比时启用。
  Q+ K4 w0 z! N& v1 k//当禁用,PWM销仍读0 v。大多数用户不需要这个选项,但是它可能是
, t  q! z. I5 c/ t. r2 P//在某些情况下很有用。这个设置不会更新最小主轴转速计算。任何
2 p9 z1 Z0 C9 {. k0 v* J//输出轴转速低于这个值将被设置为这个值。
3 }: V( K6 U& o6 X0 M  v1 Q, `1 k
// #define MINIMUM_SPINDLE_PWM 5 // Default disabled. Uncomment to enable. Integer (0-255)) o. r& [7 w+ ^2 t' Y
3 o# m( j  g9 K' k% r0 O& ]6 w
// By default on a 328p(Uno), Grbl combines the variable spindle PWM and the enable into one pin to help & @* l/ W5 B& I. \0 X; x
// preserve I/O pins. For certain setups, these may need to be separate pins. This configure option uses) W1 ?% X* b" g# K( w' l5 K  v
// the spindle direction pin(D13) as a separate spindle enable pin along with spindle speed PWM on pin D11. 5 r: G8 ?' p$ g7 w# P
// NOTE: This configure option only works with VARIABLE_SPINDLE enabled and a 328p processor (Uno).
6 o% J+ e' p9 x6 O$ y// NOTE: With no direction pin, the spindle clockwise M4 g-code command will be removed. M3 and M5 still work.
6 V9 m5 o! Q; _2 k" K( @5 K* e// NOTE: BEWARE! The Arduino bootloader toggles the D13 pin when it powers up. If you flash Grbl with7 T  c- ]% P3 a1 n; f
// a programmer (you can use a spare Arduino as "Arduino as ISP". Search the web on how to wire this.),
# S& W  d! ~' e4 y// this D13 LED toggling should go away. We haven't tested this though. Please report how it goes!
% V, c) X" Y  a+ ?//默认ATmega328 p(Uno),Grbl结合变量轴PWM和使到一个销的帮助' E# R; P. t. Y& a# y/ U9 o9 N
//保存I / O管脚。对于某些设置,这些可能需要单独的别针。这个配置选项使用
' t: i! n5 T( Z$ \//方向轴销(D13)作为一个单独的轴销上启用销以及主轴转速PWM这里。
2 _( k- a( i  N% W5 |! D& Q//注意:该配置选项仅适用于VARIABLE_SPINDLE启用和328 p处理器(Uno)。$ @# v  o  Z! V. }# m
//注意:没有方向销,主轴顺时针M4刀位点命令将被删除。M3和M5仍然工作。- f) w  Q6 b" O/ U
//注意:小心!Arduino引导装载程序切换D13销的权力。如果flash Grbl
" q; n* i. J: }' w9 R+ z: F* V//程序员(您可以使用一个备用Arduino“Arduino ISP”。搜索网络如何线),2 |! s, |4 t9 m5 v: s' [% x
//这D13导致切换应该消失。我们还没有测试这个。请报告将会怎样!8 |8 C: Q- w; m" `! P1 o7 L+ e

# H" z1 D  ?" I- H% c3 \// #define USE_SPINDLE_DIR_AS_ENABLE_PIN // Default disabled. Uncomment to enable.
5 c# s* ~* N' {. ?! r, K# j. @. u9 ~5 s' k
// With this enabled, Grbl sends back an echo of the line it has received, which has been pre-parsed (spaces& c2 T% w# t6 k, t5 z% i' C
// removed, capitalized letters, no comments) and is to be immediately executed by Grbl. Echoes will not be : o7 _7 h/ a3 r" s9 G! ~; @
// sent upon a line buffer overflow, but should for all normal lines sent to Grbl. For example, if a user 9 r( d, Q0 s+ q, U
// sendss the line 'g1 x1.032 y2.45 (test comment)', Grbl will echo back in the form '[echo: G1X1.032Y2.45]'.. ?& x# W: D! F2 B1 [, X! g; r" }; E
// NOTE: Only use this for debugging purposes!! When echoing, this takes up valuable resources and can effect, l6 R! r. @* o/ I
// performance. If absolutely needed for normal operation, the serial write buffer should be greatly increased
2 L: `% _  x2 Y( j. [' Y) A$ Z4 F$ k// to help minimize transmission waiting within the serial write protocol.
: o& O9 F# v7 K" u; T
; j. C! K; {) W4 m6 H* @* O//启用,Grbl发回的回声线已收到,已预编译(空间/ F. A, }# ]% J1 {
//移除,大写字母,没有评论),由Grbl立即执行。回声将不会
- ?0 b% p4 _1 K$ y* P# w' M. t5 S//发送一个线缓冲区溢位,但应该对所有正常线路送到Grbl。例如,如果一个用户$ y; P3 C7 e6 A7 h: F) G
//发送线的g1 x1.032 y2.45(测试评论)形式”,Grbl将回声”(回声:G1X1.032Y2.45]”。
+ _4 z) E" m) w! L//注意:只使用这个调试! !当呼应,这占用了宝贵的资源,可以影响6 ^. m! M0 q  r: d) p
//性能。如果正常运行所需的绝对,串行写入缓冲器应该大大增加
' J( a8 d. Q: ^) v* Z//帮助最小化传输等系列内写协议。
6 V5 p8 |. R- S! F- N, _- E  `4 b) U7 @9 q
// #define REPORT_ECHO_LINE_RECEIVED // Default disabled. Uncomment to enable.
8 X4 ^* R+ n$ a+ X: h" w. t9 Q2 ~. t- }2 B. b% _- k  u  Z
// Minimum planner junction speed. Sets the default minimum junction speed the planner plans to at
  G7 W1 B8 m& [4 w. I// every buffer block junction, except for starting from rest and end of the buffer, which are always
8 [5 s1 B5 p9 D// zero. This value controls how fast the machine moves through junctions with no regard for acceleration
0 W9 A5 ?6 A) L( A: n7 p6 Z' N// limits or angle between neighboring block line move directions. This is useful for machines that can't
- |1 k6 p  [  z0 w0 A// tolerate the tool dwelling for a split second, i.e. 3d printers or laser cutters. If used, this value" e* a. Q% P) r: B. x
// should not be much greater than zero or to the minimum value necessary for the machine to work.3 n7 t% c  K# o; V+ \! c+ L9 p4 W

5 J+ D  Y3 |* ^//最小规划师结速度。设置默认最小连接速度规划计划6 @; q3 H6 e3 N
//每一个缓冲块接头,除了从结束休息和缓冲区,它总是
. _/ i6 [0 ~6 V0 T( d! r// 0。这个值控制机器的速度穿过路口,没有考虑加速度
; i4 c8 W2 i; p3 m  X/ g, ~//限制或相邻块之间的角线方向移动。这是有用的机器,不能( B+ j7 _4 n& p' ]
//容忍工具居住某一刹那,即3 d打印机或激光切割机。如果使用这个值2 c6 n8 `4 K7 u1 k
//不应大于零或机器工作所需的最小值。" k8 n, D8 @' g( u% b5 z3 b& J

: ^/ o- t+ ]0 @6 `" Q- g! O#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min)
. {) ~3 U- T- b3 `
/ W% ^/ [$ b* H; Y) v4 G8 r// Sets the minimum feed rate the planner will allow. Any value below it will be set to this minimum
/ B+ `& O2 d9 K- }// value. This also ensures that a planned motion always completes and accounts for any floating-point
' d9 i& d/ [0 m7 b/ s! {1 u// round-off errors. Although not recommended, a lower value than 1.0 mm/min will likely work in smaller2 _. [! U/ d! b$ U3 z% w
// machines, perhaps to 0.1mm/min, but your success may vary based on multiple factors.1 n0 ^5 D8 ~  d7 j6 n2 r) f( @+ F
//设置计划将允许的最小进给速率。任何价值低于它将被设置为最低值。这也保证了运动计划总是完成,占任何浮点! O! v4 X( V  h8 @6 ~( ~
//舍入错误。虽然不推荐,价值低于1.0毫米/分钟可能会在较小的工作
% K' u1 `9 G! J//机器,也许到0.1毫米/分钟,但你的成功基于多种因素可能会有所不同。
( c9 U$ I1 q7 W  T* B8 b
' Y7 o& A4 e+ L; Y' F$ w8 V#define MINIMUM_FEED_RATE 1.0 // (mm/min)//设置计划将允许的最小进给速率
4 r+ [3 O; U& y! G* s
. E$ t% H6 G9 e+ c/ N; Z// Number of arc generation iterations by small angle approximation before exact arc trajectory
3 W. i' D2 f3 e/ b// correction with expensive sin() and cos() calcualtions. This parameter maybe decreased if there ; H% z- C; [! J" |4 _' V+ f! T
// are issues with the accuracy of the arc generations, or increased if arc execution is getting& d  m/ j7 N: F" m- {
// bogged down by too many trig calculations.
  {+ h& F0 X6 I; w! Q//弧生成迭代次数之前小角度近似精确的弧线轨迹( I0 v+ v& z6 @7 S
//修正与昂贵的sin()和cos()calcualtions。如果有这个参数可能减少
7 X, U4 T, }5 u! D( D- k% O//与弧一代又一代的准确性问题,或如果电弧执行得到增加
* K! E, v5 j" F1 K0 K//太多的三角计算的泥潭。
9 ]* H7 A( a7 U2 H2 O9 m2 g8 h& A/ W9 T) y5 L$ d8 _
#define N_ARC_CORRECTION 12 // Integer (1-255)& c! n) Y! D1 o

! e2 p0 V) c8 b7 q7 E+ q// The arc G2/3 g-code standard is problematic by definition. Radius-based arcs have horrible numerical
, e1 H( t! j# e9 t0 n% r( ?// errors when arc at semi-circles(pi) or full-circles(2*pi). Offset-based arcs are much more accurate
, c6 ^9 f* |- N2 T# I// but still have a problem when arcs are full-circles (2*pi). This define accounts for the floating 8 w, {# I4 \0 @% A. F6 `
// point issues when offset-based arcs are commanded as full circles, but get interpreted as extremely+ j8 C( ?/ V$ n1 t) [
// small arcs with around machine epsilon (1.2e-7rad) due to numerical round-off and precision issues.6 v) w/ A1 i7 ^6 e1 L. P
// This define value sets the machine epsilon cutoff to determine if the arc is a full-circle or not.
- ]9 H6 K' B* Q8 A& g/ L: S: w// NOTE: Be very careful when adjusting this value. It should always be greater than 1.2e-7 but not too# Q- c1 ?" F. U& z# z
// much greater than this. The default setting should capture most, if not all, full arc error situations.# F- q+ ?, M6 C; k. I# x2 u
//弧G2/3刀位点的标准定义是有问题的。Radius-based弧有可怕的数值) }, o( h: W% ~
//错误当电弧在半圆(π)或原点(2 *π)。Offset-based弧更准确5 B. b* Y0 y3 r. \- q1 o, l
//但仍有一个问题当弧原点(2 *π)。这个定义占浮动
0 J# k; [' A. U  H( S' w//当offset-based弧吩咐点问题完整的圆,但解释为极9 c2 U: Y$ S+ `/ Y2 _( F1 K; y
//小弧机周围ε(1.2 e-7rad)由于数字舍入和精度问题。, y& C3 z2 k2 ^9 N; N
//定义值设置机器ε截止来确定电弧是一个原点了。
3 U/ S3 A' q  A% O$ q8 j4 q+ u) Y# R//注意:调整这个值时非常小心。它应该总是大于1.2 e -但不要太
8 X+ A& n. m$ o//比这大得多。默认设置应该捕获大部分,如果不是全部,全部错误的情况。
. y1 Q, a; q9 q* i! y0 Z
1 [" ^, p2 `5 r; j; y0 J#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)
' N  o* {' o/ B# ~
$ _+ r& s: T3 i( D' N// Time delay increments performed during a dwell. The default value is set at 50ms, which provides
% W; U! |6 S5 M9 p. m// a maximum time delay of roughly 55 minutes, more than enough for most any application. Increasing+ K" Q% I$ m) T2 ?: P" l  d
// this delay will increase the maximum dwell time linearly, but also reduces the responsiveness of
0 d7 w6 U: W' S$ [" Y- f" n// run-time command executions, like status reports, since these are performed between each dwell - k5 [$ h7 a6 y2 @. c
// time step. Also, keep in mind that the Arduino delay timer is not very accurate for long delays.5 v/ \7 a# ?9 f+ S) `
//延时增加表现在住。默认值设置为50毫秒,它提供了( ?  P! D: b' d* c( K
//最大延时约55分钟,足够对大多数任何应用程序。增加
; y9 |% m/ @* ^/ Y//这种延迟将增加线性最大停留时间,也减少了响应能力
! C( e- M7 I3 P6 `- ~1 E. E2 S- C//运行命令执行状态报告一样,因为这些每个住之间执行
: ], O& H" D& U: V//时间步。还有,记住,Arduino延迟计时器不是很准确的长时间延误。
- B* D  S% M$ l- N" ?! b$ l9 x' O6 o, d
#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds)
, D2 m  q  o: p' m0 q( H+ W4 F& n) N) z2 k6 ]+ R1 [7 z: x
// Creates a delay between the direction pin setting and corresponding step pulse by creating; e- X& \- u+ H. z) P8 j9 a
// another interrupt (Timer2 compare) to manage it. The main Grbl interrupt (Timer1 compare)
- z+ R; }  g, U0 n9 c// sets the direction pins, and does not immediately set the stepper pins, as it would in ' x8 I  j1 p" J) b: z- w
// normal operation. The Timer2 compare fires next to set the stepper pins after the step 3 s. M8 t2 \, S
// pulse delay time, and Timer2 overflow will complete the step pulse, except now delayed
9 j: ]( a: v+ F6 g) P3 z. z  H) L; J// by the step pulse time plus the step pulse delay. (Thanks langwadt for the idea!)
9 d9 C2 x( a: U- {0 G) \# W// NOTE: Uncomment to enable. The recommended delay must be > 3us, and, when added with the
  q* F- |( Z5 Z! F9 }// user-supplied step pulse time, the total time must not exceed 127us. Reported successful
7 q# b7 Q1 d, t% ]$ k+ K7 k4 U/ o// values for certain setups have ranged from 5 to 20us.: s* U5 l6 X" x$ H0 C/ ~
//创建一个方向销之间的延迟脉冲通过创建设置和相应的步骤0 G! P- V: K- j0 A3 z7 w
//另一个中断(Timer2比较)来管理它。主要Grbl中断(Timer1比较)- f6 v/ u+ @! ?& @7 [9 Y) w
//设置方向针,不立即设置步进针,因为它会在3 f2 ?7 e- n/ W4 Q
//正常操作。Timer2比较火旁边设置步进针后一步) P- |$ h0 R% Y8 l! {9 W  B- I
//脉冲延迟时间,Timer2溢出脉冲将完成的步骤,现在延迟除外
: z/ G" k  {+ Y! Z//脉冲时间加上的一步一步脉冲延迟。(感谢langwadt主意!)
$ P) |/ C) i/ S! V8 G6 }  y" V//注意:取消启用。必须> 3,建议延迟,当添加的
& J! j) B% Z6 E8 ^- |//用户提供的步骤脉冲时间,总时间不得超过127美元。成功的报道
& {" s4 f. l2 Z; r/ S//值对某些设置范围从5到20。
: [! Z- A9 C! }- k' b
" T+ y3 f; {" r, b* A; u. R// #define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.5 b1 ], u# h$ @4 [- K% A1 C
$ ~! [9 ?# O+ \1 ?# m( m
// The number of linear motions in the planner buffer to be planned at any give time. The vast
) ^0 @/ V: h$ a" H// majority of RAM that Grbl uses is based on this buffer size. Only increase if there is extra
* @8 y: y- P, R% B/ h// available RAM, like when re-compiling for a Mega or Sanguino. Or decrease if the Arduino0 V/ N9 t( M3 {
// begins to crash due to the lack of available RAM or if the CPU is having trouble keeping" c) r  J6 u- ^  a4 J7 n% d9 R
// up with planning new incoming motions as they are executed. * S  v( y4 K- ^9 K1 y
//线性运动规划师缓冲区的数量在任何给出时间计划。绝大
# {- H' q; s) e; |( c0 M  l//多数RAM Grbl使用基于这个缓冲区的大小。如果有额外的只会增加$ j9 S0 T4 D3 t3 Z; m
//可用内存,比如当基于大型或Sanguino。如果Arduino或减少
( t! I9 [5 v0 J- I1 G% g//开始崩溃由于缺乏可用的RAM或者CPU是难以保持( F2 R! e% G" T6 [7 ]: b/ [( D! i
//与规划新传入的动作执行。
, ^( P, Y* _3 q! N  i6 n5 N, H2 v7 D' b
// #define BLOCK_BUFFER_SIZE 18  // Uncomment to override default in planner.h.
6 z0 Y3 n! a4 U. C, k- c. l" L) J3 U
// Governs the size of the intermediary step segment buffer between the step execution algorithm2 c9 }8 @" z( P" U& |) g# B
// and the planner blocks. Each segment is set of steps executed at a constant velocity over a
( k( p+ B3 B* x0 c1 P// fixed time defined by ACCELERATION_TICKS_PER_SECOND. They are computed such that the planner
* J1 J, @; ~7 ?0 P' W// block velocity profile is traced exactly. The size of this buffer governs how much step
' e7 v' l/ z7 ]( n8 W' I  u// execution lead time there is for other Grbl processes have to compute and do their thing + M7 ]+ h" W5 T0 c5 f' S; K
// before having to come back and refill this buffer, currently at ~50msec of step moves.( ~1 z" j* O4 T4 z
//控制之间的中间段缓冲大小的步骤执行算法
& b+ U2 ~( k" n4 o$ [; B+ H//和规划师块。每一部分的步骤执行在一个恒定的速度
# I: Q) i2 E( `; ~* Y( j! ?% L//固定的时间由ACCELERATION_TICKS_PER_SECOND定义的。他们计算的计划! S) o% M0 R  m" Y
//块速度剖面追踪到底。这个缓冲区的大小控制多少步骤
( L3 T+ e& ~, A8 B; w. X//执行时间有其他Grbl过程需要计算和做他们的事情
' `  W0 E- e, I//之前必须回来重新填充这个缓冲区,目前移动~ 50毫秒的一步。  {' b, u' R* [2 \& Q

; h( q: u* e) l8 @6 v* _// #define SEGMENT_BUFFER_SIZE 6 // Uncomment to override default in stepper.h.
+ G- j! S) ^( m$ `2 u! g. F; t6 J2 e7 L
// Line buffer size from the serial input stream to be executed. Also, governs the size of 2 U- D- N, \5 l: R
// each of the startup blocks, as they are each stored as a string of this size. Make sure  l) ^' a, L$ i9 z
// to account for the available EEPROM at the defined memory address in settings.h and for# p/ t! J: T4 J; R
// the number of desired startup blocks.
2 _- U3 M/ w# @4 k1 M// NOTE: 80 characters is not a problem except for extreme cases, but the line buffer size
* w9 }+ K8 F$ v4 x. q3 c// can be too small and g-code blocks can get truncated. Officially, the g-code standards / W$ k# O' S! g
// support up to 256 characters. In future versions, this default will be increased, when . |( W+ b- ?' T# L, b0 b
// we know how much extra memory space we can re-invest into this.
. P, Y% j' j4 U  c//行执行串行输入流的缓冲区大小。同时,大小的控制5 L! ~% H1 M& P$ r9 U: `1 {1 D
//每个启动模块,它们分别存储为字符串的大小。确保9 M0 ~; P+ p+ S) j1 Y% u
//占可用eepm定义内存地址的设置。h和7 X# z2 ?+ w! L/ R6 H# A7 S, l
//需要启动块的数量。
  s6 T2 R/ h6 _6 [//注意:80个字符不是一个问题,除了极端的情况下,但线缓冲区大小
  H. X) M$ _# B9 p3 _+ ^//可以太小和刀位点块可以截断。正式,刀位点标准3 o# f# M4 M, o) W
//支持多达256个字符。在未来的版本中,这个违约将会增加,当
- h" v7 |. p9 W' d6 \//我们知道多少额外内存空间的时候我们可以再投资。. |. X0 U% |% [( O9 g
+ E4 f, |; p( U% O, {
// #define LINE_BUFFER_SIZE 80  // Uncomment to override default in protocol.h
! Q$ ]- I2 R- `! Q  H  1 c$ d* ]& y# h5 k6 I$ O
// Serial send and receive buffer size. The receive buffer is often used as another streaming. [$ B- i- F1 U
// buffer to store incoming blocks to be processed by Grbl when its ready. Most streaming
4 \3 F4 I4 ~# o' o# T/ |! S; N// interfaces will character count and track each block send to each block response. So,
* d! W0 c1 G! U* y" e1 [  g* Y// increase the receive buffer if a deeper receive buffer is needed for streaming and avaiable
1 _% |/ b4 f$ T9 y9 Z2 J+ B// memory allows. The send buffer primarily handles messages in Grbl. Only increase if large
# K  X& V. Y" @, }) Y// messages are sent and Grbl begins to stall, waiting to send the rest of the message.4 \5 h& s2 |" \; n; g% J9 ?6 x
// NOTE: Buffer size values must be greater than zero and less than 256.
* H& r4 \, h( U4 Z! F9 {// #define RX_BUFFER_SIZE 128 // Uncomment to override defaults in serial.h" t. U+ E3 g% |. l: d# J2 ?, |
//串行发送和接收缓冲区大小。接收缓冲区通常用作另一个流
5 @1 L& t2 f, |/ o1 X//缓冲存储传入的块来处理Grbl当它准备好了。最流
* ~- c. q, J- K- \2 [8 r  B  k//接口将字符计数和跟踪每一块发送给每个块的回应。所以,
: g; G4 r  Q3 y//增加接收缓冲区如果需要更深层次的接收缓冲区为流,、+ K0 A1 a. W/ E, U# M6 U  Q' b
//内存允许。Grbl发送缓冲主要处理消息。只会增加如果大
' Z  A  c$ O. B% {6 T$ A//消息发送和Grbl开始停滞,等待发送其余的消息。
. P/ e) A/ m) U/ x" q: d//注意:缓冲区大小值必须大于零,小于256。& Z5 B' X8 B& T+ n) e2 s) }
// # define RX_BUFFER_SIZE 128 / /取消serial.h覆盖默认值! A! S- R! Q, v$ R+ L3 u

! R4 W; Q  o& H( M7 ^) b, y: D* n6 o) Z0 H( }
// #define TX_BUFFER_SIZE 648 A' Y/ Q9 p1 X/ n7 u; @* ~
  
2 C3 Y0 O& r" V8 }- |1 p) {2 `" c// Toggles XON/XOFF software flow control for serial communications. Not officially supported
8 O3 L5 C$ K; r' @4 g* s// due to problems involving the Atmega8U2 USB-to-serial chips on current Arduinos. The firmware$ V- q3 u" o! Y2 ]9 Q
// on these chips do not support XON/XOFF flow control characters and the intermediate buffer
0 x/ {' d% |1 \// in the chips cause latency and overflow problems with standard terminal programs. However, - P8 E# L9 `: K: r: V1 F
// using specifically-programmed UI's to manage this latency problem has been confirmed to work.
+ I  ]% T9 O7 P( G// As well as, older FTDI FT232RL-based Arduinos(Duemilanove) are known to work with standard6 _' H3 ]! [: Y# \$ m$ O1 I
// terminal programs since their firmware correctly manage these XON/XOFF characters. In any* q$ S; A- n2 M0 i1 P) q, g
// case, please report any successes to grbl administrators!
# L8 N" j0 |- A! G) a/ X/ h//切换为串行通信发送朴通/发送葡开软件流控制。不是官方支持
: M8 Y& m+ Q% y( ^1 M+ E//由于问题涉及Atmega8U2 USB-to-serial当前arduino芯片。固件
  d1 T4 V3 Z# g0 j) U# I+ l//在这些芯片不支持发送朴通/发送葡开流控制字符和中间缓冲区
6 M( h- s, k: a1 z. F& q//芯片导致延迟和溢出问题的标准终端程序。然而,# A3 H% K( T+ S) p; X- `* L
//使用specifically-programmed UI的管理这个延迟问题已经确认工作。
8 @, S) R3 l  Y( U6 @//以及老FTDI FT232RL-based arduino(Duemilanove)是已知的标准/ q# b9 G3 D% p; @
//终端程序因为他们正确的固件管理这些发送朴通/发送葡开的角色。在任何
* M8 k. s! G- ~//情况,请报告任何成功grbl管理员!
3 T& _3 ?$ j2 ]1 ~' J7 O3 Q1 v5 p& P4 s; y" ^) _" i' t  w
// #define ENABLE_XONXOFF // Default disabled. Uncomment to enable.9 G9 D  z' G% S7 S! j2 M! F4 w: @
) u% v. C6 H3 C( _/ U
// A simple software debouncing feature for hard limit switches. When enabled, the interrupt
" K" d7 k2 H4 v8 u// monitoring the hard limit switch pins will enable the Arduino's watchdog timer to re-check
6 [( }) t: |6 e// the limit pin state after a delay of about 32msec. This can help with CNC machines with * i; Q3 ]" e) E; N( b
// problematic false triggering of their hard limit switches, but it WILL NOT fix issues with ' A% g# ~& h  \# {- L
// electrical interference on the signal cables from external sources. It's recommended to first
  `8 o. {) H+ J3 W: ?9 Z( g, A4 L// use shielded signal cables with their shielding connected to ground (old USB/computer cables 1 s) f: V; k2 K* `
// work well and are cheap to find) and wire in a low-pass circuit into each limit pin.& O" p' \" ?% H# g1 @
//一个简单的软件消除抖动特性硬限位开关。当启用时,中断
4 u7 E: S" U3 I/ R  d//监控硬限位开关针将使Arduino的看门狗定时器重新审视
9 }# C& r* \  i& ?//销的极限状态后约32毫秒的延迟。这可以帮助与数控机器
7 H' h+ E- G' M  u: B& X  N//问题错误引发的硬限位开关,但是它不会解决问题
  G. L6 o$ }9 W//电干扰信号电缆从外部来源。首先它的建议" L* V2 l# x, Y* ]. I
//使用屏蔽信号电缆的屏蔽连接到地面(老USB /计算机电缆
. i5 z5 N. [: X& C9 B; H) x//工作得很好,很便宜)和线低通电路到每个限位销。9 G- y: J  E, Z5 j/ ^5 U1 d
0 d* p+ m; D5 \" E% ^* E5 f" @3 r
// #define ENABLE_SOFTWARE_DEBOUNCE // Default disabled. Uncomment to enable.1 G( [1 ^7 M0 D; y0 M* l6 {; [

9 `$ p7 ~; s  @- s9 Q// Force Grbl to check the state of the hard limit switches when the processor detects a pin
# `6 Q2 t* N0 N  V// change inside the hard limit ISR routine. By default, Grbl will trigger the hard limits$ M, A- y) s/ C& }
// alarm upon any pin change, since bouncing switches can cause a state check like this to 3 d1 Y1 X0 d) \* Y
// misread the pin. When hard limits are triggered, they should be 100% reliable, which is the3 J1 T4 F3 n. ^
// reason that this option is disabled by default. Only if your system/electronics can guarantee
$ L- X' e7 n+ ^2 d: o% X6 d// that the switches don't bounce, we recommend enabling this option. This will help prevent
) N/ x9 a( h$ N& m% `, ]// triggering a hard limit when the machine disengages from the switch.
" i8 u; X( C: n; b! t. i4 Y& i// NOTE: This option has no effect if SOFTWARE_DEBOUNCE is enabled.
: Y+ K  k1 }2 ^8 Q) u) M* z7 W//力Grbl检查硬限位开关的状态,当处理器检测到一个销  P- ~- `( b9 G. M6 }
//改变内部硬限制ISR例行公事。默认情况下,Grbl将触发硬限制4 R9 S- }5 c! S, z) D* U/ g- P
//报警在任何销更改,因为跳开关可以导致这样的状态检查
! Q, ]* {, g1 r- d$ [8 ~- I5 E//误读了销。硬限制触发时,他们应该100%可靠,这是" y: e6 ~! {' B, z" S
//原因,这个选项默认是禁用的。只有在你的系统/电子产品可以保证; }, x8 X, w! K
//开关不反弹,我们建议启用这个选项。这将有助于防止- x% w% A$ T: q: O' b
//触发机退出时硬限制开关。! F4 l' w( ~9 ~& L
//注意:这个选项如果启用了SOFTWARE_DEBOUNCE没有影响。
. M- M0 ]- J0 x8 ~) h) B" h& K- t/ q4 o* G8 c8 e
// #define HARD_LIMIT_FORCE_STATE_CHECK // Default disabled. Uncomment to enable.
7 I$ q- H; U4 t1 O
* _# j$ M! `  L5 w1 H
$ T/ Z7 |# v# A/ l- T// ---------------------------------------------------------------------------------------
. z" S% I, O, S7 K) o5 z& u// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:编译时错误检查的定义值:
# o8 F+ a1 p( n2 q- a
  ^$ N9 e1 Q# A; S  k8 f6 T#ifndef HOMING_CYCLE_0# q8 x1 }3 a3 w( s
  #error "Required HOMING_CYCLE_0 not defined."
# H, E0 w: ?( U+ K6 g: F% o; U& w#endif$ \& ^! m% W6 h: N1 d7 c

8 r* h' a  F, a& I* O4 v#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(VARIABLE_SPINDLE)  n! Q& {2 Q& R( P3 ]+ O6 x
  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with VARIABLE_SPINDLE enabled"7 p% `  C3 e7 h
#endif
4 c3 Z5 t( J) C+ L3 `; g" b
. Z' g, z) B4 P2 [8 Y#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(CPU_MAP_ATMEGA328P)- l/ \/ b7 [3 r( U% D/ s
  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with a 328p processor"
: Q4 V5 T5 L7 K- {& d#endif
7 T" z/ Q+ h8 _& [6 J, e2 o! v; C( z6 j9 @' k4 K/ [
// ---------------------------------------------------------------------------------------/ D: |! E1 q  j9 P: ?

7 F# D) V& x2 V8 y/ C# Q9 d) L; `. A( q1 }
#endif; ~2 Q/ R' K& _* w7 V
3 Q: }, w) @# q0 M
5 O" k- ]& V( Y% l8 `! G5 a

/ Z% n3 T% R: c  B9 S8 w& @4 ]
% ?3 o7 C5 I% Q, R4 }
/ w3 p% B, V1 M# d* I  D. ^9 b5 M9 G. t8 u1 S. R
  h* y9 M1 L; p, x# u! \$ h

' q3 }: J% Q) C! v  C" B7 C) k& B( h4 R; R5 R

' M/ A2 ^: z7 n# i+ m
, f) B9 }) q' D$ B. ?
: |- l3 E: X5 s# r6 C" V1 w" X& B7 X: }# @

3 k# U7 d& [3 F4 z# H) |6 H. r5 H, C
3 e) G# H+ R+ K$ L4 O

本帖子中包含更多资源

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

x

评分

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

查看全部评分

回复

使用道具 举报

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

使用道具 举报

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

8 H( [# j  c! p) |0 Z/ z1 m
回复 支持 反对

使用道具 举报

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

使用道具 举报

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

使用道具 举报

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

使用道具 举报

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

使用道具 举报

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

使用道具 举报

9#
 楼主| 发表于 2016-8-23 23:03:17 | 只看该作者
补充
( s$ Z8 k, m/ D9 Q4 H, e+ r) `程序运行protocol_execute_realtime(); /运行实时命令。9 I2 d! d7 `$ m$ s. h3 |9 B
// Executes run-time commands, when required. This is called from various check points in the main; \5 F& C, M$ M! f' p/ m
// program, primarily where there may be a while loop waiting for a buffer to clear space or any
0 d3 _+ C9 O# h1 j: M// point where the execution time from the last check point may be more than a fraction of a second.0 p" x" g, }% H7 m
// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code
6 ^( a' j6 c9 _1 g: W" u, E// parsing and planning functions. This function also serves as an interface for the interrupts to . U7 R2 e! f$ C
// set the system realtime flags, where only the main program handles them, removing the need to; @& s, g& E' ?
// define more computationally-expensive volatile variables. This also provides a controlled way to
& d, r) U. d+ E, Z9 ?// execute certain tasks without having two or more instances of the same task, such as the planner6 k1 \( ]- v7 J8 `9 W& x  G
// recalculating the buffer upon a feedhold or override.1 j' ?9 h. z; ]" v; s
// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,% m; U7 \- s, F" o4 i
// limit switches, or the main program.% U/ W" p; q) J0 b! A) s
6 |0 m/ S/ D' V$ ?
//执行运行时间命令,在需要时。这就是所谓的从各种主程序要检查站
( B& {8 t/ T* a- o//,主要是那里可能是一个while循环等待缓冲区空间或任何
' l$ v% ]6 k- c, X; w$ x//执行时间从过去的止点可以超过几分之一秒。, R/ j2 E6 o0 a8 {
//这是一种异步执行实时命令(又名多任务)grbl的刀位点
5 {+ n2 s% W( z8 M6 L//解析和规划功能。这个函数也可以作为一个接口,用于中断
4 u' |7 ~$ \. ?9 T1 J//设置系统实时的旗帜,只有主程序处理,消除的需要! a& ?. Q* x9 r3 i6 F
//定义更多的计算昂贵volatile变量。这也提供了一种控制方法' C9 D. ^& k# S! l+ E) I
//执行某些任务不相同的两个或多个实例的任务,比如计划  X& Y4 o2 l1 ^/ b0 |1 I* q- ]
//重新计算缓冲feedhold或覆盖。
( a. N! D5 ]+ x9 B- m+ [) E0 c//注意:sys_rt_exec_state变量标志设置任何过程,步骤或串行中断,插脚引线,
: h7 G3 b: E9 Q' K( k+ k, l% F//限位开关或主程序。$ S" M" t- E  K5 ^
void protocol_execute_realtime()2 R$ g" y0 {* l7 e1 i- A
{) b; t7 c' ^7 {9 M- x6 c
        // Temp variable to avoid calling volatile multiple times.
* x7 ~8 z5 z  m5 Z2 A        // 临时变量来避免多次调用不稳定。# o3 p3 S$ h7 l* }& D2 v
        uint8_t rt_exec; 1 f; y4 T" [  N4 Y- Z9 }9 C/ \
        do{6 }% i( K! Y. k0 Z+ p! C
          if (rt_exec) {                 // 有标志位置位进入
( f& ?' f- L& P+ V7 ?. c& `        & r0 }) }6 d+ B- w" a
            sys.state = STATE_ALARM; // 设置系统为报警状态
. K1 Q& h0 |( C  f5 ~9 N  A, w0 X      report_alarm_message(ALARM_HARD_LIMIT_ERROR);        //报告报警信息为接近极限值: |" U0 e0 @, ?
    } else if (rt_exec & EXEC_ALARM_SOFT_LIMIT) {                        //报告执行软件限位报警9 |7 I: ~, r) _" O. b# @" {4 \5 S
      report_alarm_message(ALARM_SOFT_LIMIT_ERROR);        //报告出现软件限位报警
' c0 y* o4 }0 m, J4 ]+ g    } else if (rt_exec & EXEC_ALARM_ABORT_CYCLE) {                //执行停止循环报警      1 D# }) S% ~6 ]9 f
      report_alarm_message(ALARM_ABORT_CYCLE);                //出现终止循环报警) {! B- u" X, D0 h! T9 O/ u) M8 ?9 A
    } else if (rt_exec & EXEC_ALARM_PROBE_FAIL) {                        //执行探查失败报警
9 v( o& Q0 d" p! [! y: N9 u      report_alarm_message(ALARM_PROBE_FAIL);                        //出现探查失败报警
4 s" S' @5 q2 ^* t/ N0 U, O, Q% ]    } else if (rt_exec & EXEC_ALARM_HOMING_FAIL) {                //执行返回原点失败报警
! E  y1 J) G2 G! Z+ q, N. a) ^      report_alarm_message(ALARM_HOMING_FAIL);                //出现返回原点失败报警
0 t5 v3 R5 J8 _0 N1 D  g! F    }, @% G4 @) |$ `; w- I
* X; i- y& O3 p" ~
    // Halt everything upon a critical event flag. Currently hard and soft limits flag this.& C# h+ X) d9 ?  R+ G; L
    // 停止一切在一个关键事件标志。目前硬和软限制标志# M" z" O! V) x
           if (rt_exec & EXEC_CRITICAL_EVENT) {                //如果系统是循环事件进入
/ {8 C% R& t  y& N1 s2 V. ]             report_feedback_message(MESSAGE_CRITICAL_EVENT);        //报告反馈信息+ s( m, r7 G6 V$ Z: e1 U% ]
              bit_false_atomic(sys_rt_exec_state,EXEC_RESET);                         //清除目前的复位状态
( t  x% A' Q5 e
& \* }8 ?- z0 p  H& b        bit_false_atomic(sys_rt_exec_alarm,0xFF);                                 // 清除所有报警标志$ ?6 k% k6 y" W$ x8 t! R
        }        9 D) f' W' v6 ?7 k4 i: q+ u

, \2 H1 _2 o" Z) i& y上面代码将rt_exec = sys_rt_exec_alarm ,如果rt_exec为真,打印不同报警信息4 ?, ^& Z! U6 p: l- f
和限位保护信息,然后清除报警状态  A' C' ^; Q; t/ M9 w
___________________________________________________________________________
/ C& f5 A: `4 `8 n没有报警进行执行下面代码,执行了终止命令,串口打印命令
- M; n6 N4 h2 ~! D2 _+ [         // Check amd execute realtime commands        校验和执行实时命令
2 D7 l. N, L! b          rt_exec = sys_rt_exec_state; // Copy volatile sys_rt_exec_state( O2 e* M) h: U  ~' [

- y3 j7 _8 E8 @        if (rt_exec) { // 输入标志是正确的执行2 C$ {, x$ V1 ]4 ~7 Y6 u3 |
4 {% z! f* K2 ^8 c5 j1 C
            // Execute system abort. 执行系统终止命令9 R4 z1 n5 R$ t1 x
            if (rt_exec & EXEC_RESET) {: ^. h3 ~3 i. u3 [
              sys.abort = true;  // Only place this is set true." g- x: b$ p* o2 i7 Q$ e' y; P: p
              return; // Nothing else to do but exit.
9 t9 K! A0 Q0 c$ s" K) Y; f/ j        }/ j( b9 m5 u! _  v" E2 @1 P, ~* j
/ R. R) [# z! R8 q1 x( I4 n
            // Execute and serial print status 执行和串口打印状态
3 ~, g. F' b; [, u$ a            if (rt_exec & EXEC_STATUS_REPORT) { $ s$ {6 l8 `7 Y
              report_realtime_status();        //报告实时状态
" Y+ U, E# K+ a( a+ k              bit_false_atomic(sys_rt_exec_state,EXEC_STATUS_REPORT);        //清除报告状态清零+ I( e5 v6 }3 }; t0 F( Z* H
            }/ n  j$ g" k; ^, x4 f4 t( t5 y& c
_____________________________________________________________________________
! w2 D" s3 h  y' X1 w5 v, }) q* {: \下面代码5 o7 t5 L1 \0 f, H" ?- O
//执行状态。
/ f" F5 x# ]9 z  ~, o//注意:所涉及的数学计算持有应该足够低对大多数人来说,即使不是全部,
6 o: F# Z' Y' R1 ]* K- F//操作场景。一旦启动,系统进入暂停状态- V: F) c; T; `1 }! n) \5 W2 w; O5 {4 O; L7 R
//主程序流程,直到重置或恢复。
3 p/ \6 G. J5 \& ~1 m+ e待办事项:检查模式?如何处理呢?可能没有,因为它只会在空闲,然后重置Grbl。* }6 j% ?; f7 `5 v0 Z$ ~
状态检查容许状态的方法。
& W1 p0 l; K5 I2 Z8 M
. q+ F- w, q; c        //如果全局各自报警标志位其中(执行取消动作) | (执行进给保持) | (执行安全门)任意一位为真进入, R" S6 p+ ~( A& H: p$ L! m
            if (rt_exec & (EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR)) {       
! n. S) l  g, B$ h( _6 `9 C' N0 `2 Q" J; D3 c
        //如果是循环状态执行暂停状态* I! T. F4 z! f
        if (sys.state == STATE_CYCLE) {
+ j% w" t+ G4 B' e        st_update_plan_block_parameters(); //通知stepper module验算减速。
3 H, l; u5 Q! e: w        sys.suspend = SUSPEND_ENABLE_HOLD; // 开始暂停标志% u  W$ w+ o9 F! \% i; g. K
        }# I3 }& Q& ~2 N4 v* o+ |( z
: Z! H1 O3 C* T
        // 如果,Grbl空闲不在运动。简单的指示暂停就绪状态。
+ C! l4 f# U& }$ i0 u  e+ x7 D        if (sys.state == STATE_IDLE) { sys.suspend = SUSPEND_ENABLE_READY; }
- I- o2 t) e4 a# E1 r  x1 d! |% w2 A2 p
+ A& m% g+ B8 G9 N5 g! u$ O
        //执行和标志和减速运动取消并返回空闲。主要由探测使用周期( l1 F/ A" ?2 `3 P8 w9 h
        //停止和取消剩余的运动。       3 ]: L' A, P* B3 o6 Y
        if (rt_exec & EXEC_MOTION_CANCEL) {
6 T( T. l- F/ K4 f- o+ n          if (sys.state == STATE_CYCLE) { sys.state = STATE_MOTION_CANCEL; }
0 W  v# P- ^+ n          sys.suspend |= SUSPEND_MOTION_CANCEL;
3 v* }, _& x. j' O: Z, _        }
/ ?# ]2 M" i3 K6 H& S7 j+ L& u4 W3 H
        // 只在循环时执行进给保持减速
# @# c, j- j: A* M6 J: v         if (rt_exec & EXEC_FEED_HOLD) {
# @8 L. T8 T6 c9 u9 s8 ?        //只有安全门为1才执行保持进给状态赋值
5 f% W& h& ~9 b  F8 C          if (bit_isfalse(sys.state,STATE_SAFETY_DOOR)) { sys.state = STATE_HOLD; }
! w6 K' N. R; N7 G2 v  ]6 E        }
( c) K7 h; @# E) l# U/ F. h' {# ^) _) K6 g
        if (rt_exec & EXEC_SAFETY_DOOR) {& K3 K% P5 G( N- O0 E- u( Z8 v
          report_feedback_message(MESSAGE_SAFETY_DOOR_AJAR);
) _+ }8 y( s$ D8 ]4 Z+ M& k" [) B/ /如果已经活跃,准备好重新开始,CYCLE_STOP标志设置为强制断开。% H' X1 n- ~: }2 D) G/ W
/ /注意:只是暂时设置“rt_exec”变量,不是动荡的“rt_exec_state”变量。  X8 Z  ]/ p( R$ |
          if (sys.suspend & SUSPEND_ENABLE_READY) { bit_true(rt_exec,EXEC_CYCLE_STOP); }: j$ v: g" M# d1 z% S  a) k# o  \
          sys.suspend |= SUSPEND_ENERGIZE;! C$ C( d+ s/ z$ m5 r8 v: Y, B( e+ O  U
          sys.state = STATE_SAFETY_DOOR;
  L# u; f6 ^: `. q5 U        }% n7 ~. R3 n! [2 E% Q2 r& i% t3 ]3 Z! {
: K( o1 \( @5 u% O$ I, f8 l/ O; H
bit_false_atomic(sys_rt_exec_state,(EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR));   
- Z2 z6 n$ _! \7 V- t7 C
/ i5 z! E) z7 J/ d' V+ y}" W" H7 R9 N% s1 \4 S* Q$ _1 G/ W6 N
以上代码执行了! ~  J7 X9 ]5 q8 X3 H& d8 Q4 @# X
1.如果全局各自报警标志位其中(执行取消动作) | (执行进给保持) | (执行安全门)任意一位为真进入9 q$ V( X0 `$ \, i
2.系统为闲着状态, 开始循环状态, 回原点状态, 控制取消状态, 开始保持状态, 开始安全门状态时进入: I* K/ J0 [/ m: m& A
3.如果是循环状态执行暂停状态- \) R3 U  s% S! T+ E
4.如果系统闲置状态执行暂停就绪状态
* \; J" r/ m5 ]1 ~$ F8 e+ b( C3 ~5.执行动作取消
9 E+ [& o3 ^: P- W" y' k" n/ }4 j6.如果是保持进给状态,执行保持进给状态
8 f8 a+ J! j/ Q- r: l! J1 v, ~7.执行安全门状态
3 X6 N* y; n- e# w4 _* d. e9 Y8 T8 Y最后执行bit_false_atomic清标志清除(执行取消动作)(执行进给保持)(执行安全门)标志位                 
, \, W: y- u' R4 Y_____________________________________________________________________________; i& E# F& t! z/ M8 N

$ g0 C1 T6 `* X- h    // Execute a cycle start by starting the stepper interrupt to begin executing the blocks in queue.4 J0 C# p0 s7 H
    // 执行一个循环开始启动步进开始执行中断队列的街区
, d* g0 S+ t( t9 {/ ^# r    if (rt_exec & EXEC_CYCLE_START) {        //循环开始状态进入
1 ^  j. Z: t2 _2 B6 M8 Y      // Block if called at same time as the hold commands: feed hold, motion cancel, and safety door.- ^; M% h8 J! B4 Q& \6 B$ r5 {5 m0 ~
      // Ensures auto-cycle-start doesn't resume a hold without an explicit user-input.- F+ Q* [" c- A" f- m
          //块如果在同时举行的命令:保持进给,运动取消,和安全的门。 //确保auto-cycle-start没有简历没有显式的用户输入。
1 P7 {4 p/ g* J4 M5 f  J/ S          
; Z9 Z: u* s4 h( n3 @      if (!(rt_exec & (EXEC_FEED_HOLD | EXEC_MOTION_CANCEL | EXEC_SAFETY_DOOR))) {   //状态机如果不是保持进给,运动取消,和安全的门。
. M: y; n; i) Q) {( @" i        // Cycle start only when IDLE or when a hold is complete and ready to resume.
( N* z( B+ {1 J        // NOTE: SAFETY_DOOR is implicitly blocked. It reverts to HOLD when the door is closed.
& y5 y0 M: B& I8 L7 _2 K- F/ H# Y                //循环开始时只有当闲置或持有完成并准备简历。
+ I; ?; y' Z) k8 ~                //注意:SAFETY_DOOR是隐式地屏蔽。它返回的时候门是关闭的。    8 M- p. v" N* N4 f  u. A

5 m+ L" r+ ~/ c; P% l) N                // 如果系统状态为闲着状态,系统状态为开始进给或运动取消,暂停标志为位重新开始
  R" U2 }3 Q  D& p: z        if ((sys.state == STATE_IDLE) || ((sys.state & (STATE_HOLD | STATE_MOTION_CANCEL)) && (sys.suspend & SUSPEND_ENABLE_READY))) {+ W& B7 K( {3 b4 V  ]  H4 S
          // Re-energize powered components, if disabled by SAFETY_DOOR.  ^3 g3 G; w: J; K
          //        由SAFETY_DOOR重振组件供电,如果禁用。
$ x5 _& A5 d! }& w& B          if (sys.suspend & SUSPEND_ENERGIZE) { 2 a2 F. k7 F& ~0 X2 B( o2 p
            // Delayed Tasks: Restart spindle and coolant, delay to power-up, then resume cycle.8 O7 V$ H) N8 J% O" s, Z
            //延迟任务:重新启动主轴和冷却剂,延迟升高,然后恢复周期。1 X$ d% Y) y, W0 W; a& f1 Y( t
            if (gc_state.modal.spindle != SPINDLE_DISABLE) {   //主轴模式不是失能进入
4 f6 n  G; p" c& n6 s5 q1 q              spindle_set_state(gc_state.modal.spindle, gc_state.spindle_speed); //设置状态和速度
1 ]$ s# ]9 j2 r0 F+ M              //待办事项:阻塞函数调用。最终需要一个非阻塞。
5 I. h/ B2 J, L1 T! i                delay_ms(SAFETY_DOOR_SPINDLE_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.. F* _: D- C( N* d- a) {  c
            }
/ M6 z0 f7 z0 k7 c, G7 C            if (gc_state.modal.coolant != COOLANT_DISABLE) {
+ q! T: [9 N# Q$ s              coolant_set_state(gc_state.modal.coolant); 5 v' O. g4 B/ @3 F8 F
              delay_ms(SAFETY_DOOR_COOLANT_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.1 p* u; h- \8 ^" S4 V$ }) `) j4 F9 S
            }# w- D! e$ x( M  [' S$ ]/ K) J$ J1 T& I
            // TODO: Install return to pre-park position.- f8 @2 G) k# {! T+ P* `
          }- |$ X/ V) X( U  d/ R2 G/ H, x
______________________________________________________________________________________________________________
3 @: k! Z2 C* c          // Start cycle only if queued motions exist in planner buffer and the motion is not canceled.
" N+ I' D9 v  I9 p                  0 G, Y2 Q  X* P% V/ P3 X  {5 B
                  //只有在队列马达存在规定的缓冲,并且动机没有让取消,才会循环
6 O, O" o+ r6 _                  - B6 i  P0 S7 I, K6 C; d9 d
          if (plan_get_current_block() && bit_isfalse(sys.suspend,SUSPEND_MOTION_CANCEL)) {6 g! |3 a+ |3 ^8 P& F8 S
            sys.state = STATE_CYCLE;# L. i7 G9 i% u. ~9 z# H
            st_prep_buffer(); // Initialize step segment buffer before beginning cycle.初始化步开始循环之前
' a* W/ G) X3 n  Q' Q* z            st_wake_up();+ G, P; j$ N) n) x8 g! b; o
          } else { // Otherwise, do nothing. Set and resume IDLE state.否则,什么也不做,设置和复位空闲模式
* |, U' t3 l2 Z, p& p9 _) h            sys.state = STATE_IDLE;
0 N- G% b( m" z' q$ O          }4 q2 X5 |- c6 c9 L+ h  M3 [& B0 [
          sys.suspend = SUSPEND_DISABLE; // Break suspend state.3 _. I4 F9 S5 X
        }  P5 r% p6 O  G; r5 X! x
      }   
! C) r4 }3 b; B6 a  T7 C$ c      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_START);       
2 c! Y1 P) }2 K* G$ B/ N' o; f    }
4 B$ n" m( M9 M6 A7 h4 j9 S6 ^$ r) k/ p0 x5 W0 O2 D
_______________________________________________________________________________________________________
% S. b& }' c7 B% ~$ w& I' \    // Reinitializes the cycle plan and stepper system after a feed hold for a resume. Called by 3 X# f5 t  ^1 V" p$ q! u
    // realtime command execution in the main program, ensuring that the planner re-plans safely.' N7 s9 e; W# H$ \4 |7 t( L$ R2 s
    // NOTE: Bresenham algorithm variables are still maintained through both the planner and stepper! T/ E7 h' y! e( T% b2 o# e
    // cycle reinitializations. The stepper path should continue exactly as if nothing has happened.   ( N" d# I- Y9 v* m
    // NOTE: EXEC_CYCLE_STOP is set by the stepper subsystem when a cycle or feed hold completes.2 u. p1 l. V# Y) I7 [8 O1 o' ]
( j+ q" A$ c  a1 R% ~
        //重新启动后循环计划和步进系统的进给保持简历。通过实时命令执行主程序,确保安全计划重新计划。+ W/ }+ x4 c* j3 v% h2 b
        //注意:画线算法变量仍保持通过规划师和步进6 }0 j8 h9 W6 g) {* B1 A* U) |
        //循环仅。步进路径应该继续,好像什么都没发生一样。       
. f3 c& N8 ?' I) \/ z- ^        //注意:EXEC_CYCLE_STOP由步进子系统周期或进给保持时完成。
' e2 S3 m3 D0 v" [9 y2 ?
5 |  I" O, T' z5 V/ ~    if (rt_exec & EXEC_CYCLE_STOP) {                         //如果是循环停止状态进入
$ ]7 i3 `& k' V3 r! M0 @0 O      if (sys.state & (STATE_HOLD | STATE_SAFETY_DOOR)) {% i" O2 s4 L5 L
        // Hold complete. Set to indicate ready to resume.  Remain in HOLD or DOOR states until user% p* m$ c! ^; p# ~# o
        // has issued a resume command or reset.
& V1 M% y$ |, V7 {2 Z# `3 h6 J( d5 a" \9 Z) t: O
                //保存完整。设置为指示准备简历。继续持有或门状态,直到用户" }* B. N* `" d& X9 z! W" V: n& G
                //已发布了一份简历命令或重置。- a; P( u6 ]& e% |. \9 h
               
3 f7 g- x' c! E0 p% Y  l4 [        if (sys.suspend & SUSPEND_ENERGIZE) { // De-energize system if safety door has been opened. 如果安全的门已被打开。断开系统3 g- m/ N% i. J& Y8 W! g
          spindle_stop();/ G9 A5 e5 o: v1 [, ^
          coolant_stop();
4 U) F7 C/ E) z1 E( ~# u          // TODO: Install parking motion here. 安装停车动作。
( q, y- ]/ _6 _. ~% W8 h6 _        }" J% [" s3 c& C$ V, p& d# e3 Z
        bit_true(sys.suspend,SUSPEND_ENABLE_READY);1 }6 ]# v7 J1 f2 [; o3 x5 j
      } else { // Motion is complete. Includes CYCLE, HOMING, and MOTION_CANCEL states. 电机完成,循环,回原点,,MOTION_CANCEL
8 ~" @$ s" F8 y- I1 U        sys.suspend = SUSPEND_DISABLE;
; b1 r! l) C7 D) C- \) ]8 p4 a        sys.state = STATE_IDLE;  j- V  W0 i" ?
      }
3 q& j  z$ l, z      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_STOP);
) i# n' A/ p+ x1 `" f    }
# d5 D, H0 L0 V6 w% t) d8 s' N    ' U( F  S; ^' b$ _/ L
  }
5 t3 \4 O: z  C2 V9 f  O1 `8 p* [___________________________________________________________________________________________________5 ]* L( S. a. h$ ^; y, K

8 G; x+ p; M: s# |. G  // Overrides flag byte (sys.override) and execution should be installed here, since they * n. w1 C7 o$ }6 D' y! P
  // are realtime and require a direct and controlled interface to the main stepper program.
) F, j' ?7 r$ J! O% [7 F
  {( m8 F6 O8 p' k' i% M  //重写标志字节(sys.override)和执行应该安装在这里,因为他们2 r6 K2 L; _/ l' ?1 O* X
  //实时和需要直接和控制接口的主要步进程序。
! R% v- \8 R5 N5 G4 \9 Y1 y1 t! _) B: z+ n# `* b' `3 o( v# r" h" t

2 g8 S/ l6 F5 v- n  // Reload step segment buffer 重新加载步段缓冲/ \2 u$ G6 H; B' n1 f$ V
  if (sys.state & (STATE_CYCLE | STATE_HOLD | STATE_MOTION_CANCEL | STATE_SAFETY_DOOR | STATE_HOMING)) { st_prep_buffer(); }
# K+ a. z' W5 E: P$ v
# S5 @* f* z  {* f  // If safety door was opened, actively check when safety door is closed and ready to resume.
1 k8 E) Q- Q) e+ P  // NOTE: This unlocks the SAFETY_DOOR state to a HOLD state, such that CYCLE_START can activate a resume.        4 v/ r9 l7 {8 z% _0 G
5 V& [8 q3 K  O- e- C6 {- N
//如果安全的门被打开,积极检查当安全门关闭,准备简历。3 ^( f8 H8 n: \: c) I
  //注意:这解锁SAFETY_DOOR状态保持状态,这样CYCLE_START可以激活一个简历。6 ]5 X- o( h8 }* k

8 g+ C% |- ^( Q  if (sys.state == STATE_SAFETY_DOOR) {                 //安全门状态进入* L+ s: q9 t- D, S* t1 D
    if (bit_istrue(sys.suspend,SUSPEND_ENABLE_READY)) { : I, f2 c; \# m9 |9 Q! O
      if (!(system_check_safety_door_ajar())) {
9 B) D& L5 O: d1 D* I        sys.state = STATE_HOLD; // Update to HOLD state to indicate door is closed and ready to resume. 更新保存状态指示门关闭,准备简历。0 P) _* Y1 Z( z" O( G" @
      }: E" \3 p" s3 q* |  v4 ]1 N3 W
    }
7 Z1 p6 X$ p6 B% ~% M) f  }" F; W5 E' f0 ?

& J* P4 ^" t, `+ |  h! {  } while(sys.suspend); // Check for system suspend state before exiting.
; Z' B: E" Y! K+ @! p* l' Y  
! C' n7 E5 H$ q$ r, S7 z}  
回复 支持 反对

使用道具 举报

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

点评

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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-2-19 06:31 , Processed in 0.121825 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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