找回密码
 注册会员

QQ登录

只需一步,快速开始

搜索
查看: 19274|回复: 15

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

[复制链接]
发表于 2016-8-20 23:56:23 | 显示全部楼层 |阅读模式
本帖最后由 1五湖四海1 于 2016-8-21 00:09 编辑 9 e8 z/ t, O: j( t2 ]

4 G2 W8 X8 U/ N  ~* a0 S4 _    以前制作过CNC雕刻机,是用MACH3作为上位机控制,硬件是采用PC接并口输出脉冲和方向使能信号经过隔离驱动步进电机驱动器,步进电机驱动是采用TB6560芯片控制。最后就接到步进电机。机械是用铝合金制作,主要部件有三个1605的滚珠丝杠,多个运动滑块等制作。用这台DIY CNC雕刻机可以雕刻木头塑料等东西。当时没有一直玩下去,现在发现网上有用单片机制作的雕刻机挺精巧的现在分享给大家。) q, L: A* W9 |7 l- y, @! t7 J
   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个运动来规划运行速度,以实现平稳的加速和无冲击的转弯。很棒吧!开始玩起。
, O1 }' [5 C8 \3 `    还没有雕刻机的机械部分可以用废旧光驱制作个微型雕刻机运动平台。雕刻机最重要的是主控程序这次用 Arduino/AVR328单片机,价格在15元左右,主控程序是上面提到的目前很火的开源
的GRBL,还有一种基于STM32平台的开源主控程序Dlion也不错可以替代grbl。如果从性能比较这两个方案,显然是stm32平台运行速度更快毕竟他是32单片机呀!
2 u0 R5 Z! ^$ D$ {( a  T9 K( N: A# p0 \: Y8 H
* F+ f3 S1 n1 `+ @8 ?2 l# Q
    下面介绍小这个些主控程序主要干的事,通过串口PC和主控板通讯,PC命令给控制板,控制板接收命令做不同的响应,PC可以发G代码给主控板,接收完成后可以自动开始雕刻任务。4 _. L) V0 t. z
          在介绍下G代码因为G代码是雕刻机的核心部分
9 w! x" I6 j" u* f4 J; L9 J! ~0 zG代码是数控程序中的指令。一般都称为G指令。
+ n$ s1 R& w0 x, qG00------快速定位
+ I- O7 m2 ?! T# n  t  WG01------直线插补
2 N: t6 Q; E9 @/ p3 SG02------顺时针方向圆弧插补# M4 n% R2 o- F+ t8 |
G03------逆时针方向圆弧插补; n; D6 E' ~/ r- X4 y
G04------定时暂停
. V* M: K* y- _G05------通过中间点圆弧插补
; b1 y( U) E# y& f  i. iG06------抛物线插补$ c7 d8 y& d9 x- z1 @
G07------Z 样条曲线插补
8 `% u& n5 f6 l* R; bG08------进给加速
! [0 B2 x. o$ m( T$ ?G09------进给减速
5 A: _4 h3 \# x1 Q" a6 u/ SG10------数据设置2 K; T% K4 Y+ W' O: l' L
G16------极坐标编程+ n+ w1 Q, W$ `& n  }
G17------加工XY平面, |, ^' }* s& j4 E( \
G18------加工XZ平面( W1 ?* f$ e. e5 w1 W5 C
G19------加工YZ平面
6 h! z& [4 t$ P" n0 F
核心就是解析G代码,完成步进电机驱动,和控制主轴开启关闭,还有插补算法,直线插补,圆弧插补,还有一些步进电机的加减速算法。( h- x) d4 o$ H7 V) r/ y# s; S( [5 X
下面对grbl主结构做介绍1 B* D, Y* {) g, Q4 h
main()主函数首先执行下面初始化函数
- F: [( }6 F6 X! W+ u        serial_init();                           // 设置串口波特率和中断
: x8 g4 Y6 n8 z2 B$ A" y9 B        settings_init();                         // 从ROM加载grbl设置
) L0 l8 [. n8 j; ~4 u; O# l$ g/ X        stepper_init();                          // 配置步进方向和中断定时器6 t6 s4 L- G) \) t1 r0 a
        system_init();                           // 配置引脚分配别针和pin-change中断. I+ U/ ~: m0 z+ u% W1 ^" C
        memset(&sys, 0, sizeof(system_t));          // 清除所有系统变量& j' Y  G! R7 s- E+ E
        sys.abort = true;                           // 中止标识位置位
+ z8 P0 |0 s3 |        sei();                                         // 使能中断
  i% t% t# x& @! i1 y1 y& M5 ~: O6 ]  #ifdef HOMING_INIT_LOCK                        // 宏运算(settings.flags & (1 << 4)) != 0结果flags等于执行sys.state = STATE_ALARM8 y8 }, s9 ]  c* t# ?+ Y3 {
                                                // 系统状态赋值为报警状态7 A; x+ u. P: Y/ q/ G3 `: O# R
            if (bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE)) { sys.state = STATE_ALARM; }
  g0 P( _( Z: K5 U( a1 `  #endif
  t# `# u+ S. m1 A_____________________________________________________________________________________________________________________________________
& ^/ w+ ]: ^6 o& \# Y/ H接下来是一些主要部分初始化  K6 q# P/ e& }  ?$ b
for(;;) {
! ?, a4 ^$ Z5 q2 ^+ a9 J$ C. {        serial_reset_read_buffer();         //清除串口读缓冲区3 k6 X) N0 W9 f* P
        gc_init();                         //初始化G代码功能函数
0 Z4 e7 v8 x* t7 p6 o        spindle_init();                        //主轴初始化# @" \, T- f9 _% R' n
        coolant_init();                        //冷却液初始化
4 t+ w9 T1 ]! B' e% g- [        limits_init();                         //极限开关初始化# v! X( H3 D6 ]. y6 S0 L5 ^% _
        probe_init();                        //探测部件初始化3 R" D% S* d4 q7 Y; T$ S
        plan_reset();                         //清除块缓冲区和规划师变量/ Y# D1 U- a0 j% ?
        st_reset();                         //清除步进系统变量。
- ~# `1 Q4 f# j# H4 L; l2 M
+ a! o# G0 q4 |8 E7 E( L: y. \3 i; [8 W. G. G
        //下面两行清除同步gcode和策划师职位当前系统位置。# @  o4 [) V( O; y
        plan_sync_position();
6 p& ~. ?  Z  g3 W* P" b! d        gc_sync_position();
' m$ \- a6 Z9 T9 p2 I1 D+ Z
! T$ O; R: \* L" z0 Y2 _! a! U: e: J0 S+ I3 ?* _
        //复位系统变量+ U1 _; D. a7 N, [
        sys.abort = false;                //系统中止标志- X. [0 B$ x9 ^. I
        sys_rt_exec_state = 0;                //系统标志位变量状态管理。看到EXEC位掩码。
4 }0 `0 G5 z0 B        sys_rt_exec_alarm = 0;                //系统标志位变量设置不同的警报。) {# @- `) F5 k1 k1 m- M4 B+ O
        sys.suspend = false;                //系统暂停标志位变量管理,取消,和安全保护。, W# L1 n3 E0 j& y* \6 v* J$ f
        sys.soft_limit = false;                //限位开关限制状态机错误。(布尔)' C" A. x, t; k7 d0 {7 q+ l% T

6 ^8 U5 d  o& a, B3 H8 E# u% e! D" E! q
        protocol_main_loop();                //主协议循环
" w$ ^( L) n8 K* z+ X$ E0 m}        //' a" K- y; V' ]$ L. a1 n; H2 E
_____________________________________________________________________________________________________________________________- p3 n+ e; q) q4 g* u  @
进入void protocol_main_loop()函数8 Z6 e7 Y0 I8 o' e; A
{$ k9 Z3 z$ p. S" L6 q- \
        report_init_message();                // 打印欢迎信息 1 ]- K8 C$ Y# B( f% _6 `/ f' |
        //重启后检验和报告报警状态如果错误重启初始化。
, R0 J% h3 i1 j/ _3 {& y$ D
        if (sys.state == STATE_ALARM) {% x5 \6 J( U2 u. k
            report_feedback_message(MESSAGE_ALARM_LOCK); //打印信息
  ~& [' |$ t7 L1 l8 S( o( U" K
          } else {! n1 K( W! }$ V) l* G  W( V$ U( `
            // 如果没有报警说明一切正常!但还是要检查安全门. + [  X9 `  q; G  N  F+ R; F) h/ f
            if (system_check_safety_door_ajar()) {) X5 W+ w3 G9 Z
                     bit_true(sys_rt_exec_state, EXEC_SAFETY_DOOR);
  [  u% {" {% E0 Q6 q3 {% d: v                     protocol_execute_realtime(); // 进入安全模式。应该返回空闲状态。) Z2 l, c3 _% l  r1 T4 ]7 W5 \7 j
            }         else {5 E9 y8 Q. M( X* b
              sys.state = STATE_IDLE; // .设置系统做好准备。清除所有国家国旗。
" {) H$ c/ k" {0 C3 e8 N            } 1 n6 z- q' |% I; H1 Y5 A
            system_execute_startup(line);    //开始执行系统脚本
; \' z$ `: u" _" X1 [$ B! G7 @3 X. N  }
1 u$ f0 p( `0 o) o  O
5 r+ I" e% k" L$ Z+ x1 |' Z$ a* z  U8 [1 h
  // 这是主循环!在系统中止时这是出口回到主函数来重置系统。
& V8 P3 M5 C$ n  // ---------------------------------------------------------------------------------  
6 R; X; Z; w( `. y  . J8 ?# P' C' e5 Q, H' n% E5 d
        uint8_t comment = COMMENT_NONE;
2 a8 A3 V( i' T- q        uint8_t char_counter = 0;
" ]: b! L3 U7 w& o        uint8_t c;, g& s( _) x- I/ B: z6 {
_______________________________________________________________________________________________________________________________( ]: l7 Z- |* H: u0 \- q2 P4 B
接下来进入for(;;)循环                //下面代码是G代码解析核心部分,程序中comment(注释)变量会被赋不同值,代表发符号有‘(’‘)’‘;’
+ }$ W0 X: {+ k+ v{: v$ E; G* p% E; N9 c6 u- y
//串行数据输入一行的的过程,作为数据。执行一个/ U6 Y# {7 f4 ~& V3 B9 L2 n8 ^
//所有数据初始过滤去除空格和注释。
. i( N7 g& T/ J; ^3 U% N  \& }//注意:注释,空格和程序段删除(如果支持的话)处理技术8 q2 _3 K# r  L6 B% ~( k
//在G代码解析器,它有助于压缩到Grbl传入的数据
- n5 O+ @0 e2 M- ]1 t" {; C8 L3 h//线缓冲区,这是有限的。刀位点标准实际上州一行不行
7 a  d: w/ Q, x# V//不能超过256个字符,Arduino Uno没有更多内存空间。
. z" }: e1 |& s& c//有更好的处理器,它会很容易把这个初步解析的
- u/ s# s* a+ i- J- R: Z//分离任务共享的刀位点解析器和Grbl系统命令。                                                                - Q& w/ t4 T, @- v+ U  G) T1 a, _) H
    while((c = serial_read()) != SERIAL_NO_DATA) {                             //读取串口数据,有数据执行下面代码( Y* s! [3 l9 i- E' p3 J
      if ((c == '\n') || (c == '\r')) { // End of line reached                //如果数据是/r,/n代表一行结束% W) j6 u$ G, l* q* k6 s
        line[char_counter] = 0; // Set string termination character.        //设置结束标志
: S% ]9 G8 m1 v' A- q        protocol_execute_line(line); // Line is complete. Execute it!        //一行完成执行此函数+ m& U( Z3 O; d
        comment = COMMENT_NONE;                                                //注释清零
# M. J1 |! k; M6 V        char_counter = 0;                                                    //字符计数清零2 d8 \% W: W3 Z1 ?6 K
  
" u, |# f, [# V# d* |1 r! C- G9 E        else {; d% p- p" M7 C* g! r1 E
        if (comment != COMMENT_NONE) {
. H: ?& L" V9 N( x1 ?. l, ~                                                     //扔掉所有注释字符
: f5 _& D; I4 L. H# Z5 H: P1 b          if (c == ')') {+ v1 E! \) h7 X. H, z8 A+ v) M
            //最后注释。重新开始。但是如果有分号类型的注释。
- l& t5 b, u4 Z' V6 `" S            if (comment == COMMENT_TYPE_PARENTHESES) { comment = COMMENT_NONE; }
; `5 T+ M" _' V4 X2 r- e# \# B- M          }
5 K1 r! J: T! [( Q; I% d      } else {7 S* l0 F, k2 w3 Y& v
          if (c <= ' ') { ; ^$ v* L- F. D  L8 `/ V
            //扔掉whitepace和控制字符
/ D5 F: a+ C. ?: {6 K          } else if (c == '/') {
% g; ^( k, N% X$ [' C, E            //块删除不支持将忽略字符。4 E9 E) M, S* \' a
            //注意:如果支持,只需要检查系统是否启用了块删除。
7 U3 V, |  ]5 d2 u4 d( _3 L- U5 u& V          } else if (c == '(') {
- A+ V' K) Z+ @            // Enable comments flag and ignore all characters until ')' or EOL.8 E1 F: _5 H  _; y7 c
            // NOTE: This doesn't follow the NIST definition exactly, but is good enough for now.5 j) E& Z2 y* X
            // In the future, we could simply remove the items within the comments, but retain the/ ?* q5 e( y, ^. L9 L& y
            // comment control characters, so that the g-code parser can error-check it.2 V/ F! P8 B" E
            comment = COMMENT_TYPE_PARENTHESES;
* U' k& W, |2 m& }! J' E& E, @          } else if (c == ';') {
% @5 w& X& z+ q( n6 n  A            //注意:','注释EOL LinuxCNC定义。没有国家标准。
! s$ _8 k% X3 e! Q2 H% n  n0 x& [2 q. }            comment = COMMENT_TYPE_SEMICOLON;5 ~  \7 u  X" u0 z0 {, Q
! |+ ^0 y1 \& _& v; L, t3 N# J) Z
8 p( k" }5 K9 R1 ~5 P9 q5 v4 O; [
_____________________________________________________________________________________________________________________________________; s: A5 R" b( p' p3 d4 e
          } else if (char_counter >= (LINE_BUFFER_SIZE-1)) {                        //串口接收数据大于80字符时% S( U/ I6 m8 l
            // Detect line buffer overflow. Report error and reset line buffer.        检测缓冲区溢出。报告错误和复位线缓冲区。
  s2 u# q$ P, t/ q# I7 n            report_status_message(STATUS_OVERFLOW);                                //打印溢出信息, _. m+ k( H% L9 c/ ?. ~
            comment = COMMENT_NONE;  [, p' s$ o" `3 a# I6 x
            char_counter = 0;: e: A, g, x0 V+ v* h. R4 B1 j& o
          } else if (c >= 'a' && c <= 'z') { // Upcase lowercase                        //小写改大写4 i3 n( x$ I+ _
            line[char_counter++] = c-'a'+'A';! C2 f' D$ G2 h8 \" ^! v) l
          } else {
6 A1 _' k" J& D+ U& r            line[char_counter++] = c;
# s7 v2 n) C- y+ U, d( J; m* K          }
7 S1 S8 R+ z5 @. h        }
4 }6 ]+ j, A8 a" T      }
" L% u0 w: @. Q& h0 I- I5 z% f    }7 m* e6 |6 S* v. N
____________________________________________________________________________________________________________________________________! T- I+ ^  S! Q' O; _
        //如果没有其他字符在串行处理读取缓冲区和执行,这表明以完成,自动启动,如果启用,任何队列动作。3 c, j# E  Y5 }) g. J; ?4 d$ B5 M
        protocol_auto_cycle_start();                //自动开始协议循环
, g. ]* t7 g7 z) W) F; E* {9 f8 a1 S* Z# I        
! U* z  h; H) s* q5 L1 I7 a. u            protocol_execute_realtime();                  //运行实时命令。  U8 h$ R# x/ [
            if (sys.abort) { return; }                 //中止标识置位程序循环重置系统。            
4 h$ R! N+ h3 @1 v( a6 l! J  o  } , D3 J4 ]7 W: S( H" F
  return;                         //一般程序不会执行到这里$ W8 w/ {, P' V& F. n7 m* Y
}/ O: b) K! K  p. j3 k/ i7 K8 c4 {
____________________________________________________________________________________________________________________________________2 g# V- c6 c) K  L" {6 M& [
正常情况下,读取完G代码程序会进入protocol_auto_cycle_start();//自动开始协议循环 函数下面介绍此函数
* L$ {, w5 R( e% `% K, ^// Auto-cycle start has two purposes: 1. Resumes a plan_synchronize() call from a function that0 C/ \, }7 e* V. M4 C% l
// requires the planner buffer to empty (spindle enable, dwell, etc.) 2. As a user setting that
" \( `! T" Z( I' I' _// automatically begins the cycle when a user enters a valid motion command manually. This is 8 v7 }# w1 R7 J2 R
// intended as a beginners feature to help new users to understand g-code. It can be disabled
/ g! Q! T6 ]8 s) o" K6 ]$ \: j// as a beginner tool, but (1.) still operates. If disabled, the operation of cycle start is
3 S2 M6 M1 |4 Y# d' p( O; \& l// manually issuing a cycle start command whenever the user is ready and there is a valid motion
0 x, U- h! }3 u7 t" g! I+ z, q; U// command in the planner queue.
! ^8 p0 m- q2 I6 B/ d2 k: @; }// NOTE: This function is called from the main loop, buffer sync, and mc_line() only and executes
& T+ s2 A/ t. e8 f% g, |// when one of these conditions exist respectively: There are no more blocks sent (i.e. streaming $ Q8 D+ t& Z( l/ W
// is finished, single commands), a command that needs to wait for the motions in the buffer to . r, o5 o8 C3 j* a  m
// execute calls a buffer sync, or the planner buffer is full and ready to go.
9 D) s: {9 i7 _( o8 a  v& s3 C//自动开始有两个目的:1。回复一个plan_synchronize()调用的函数( h& B; S3 G1 j: a/ N# |
//需要规划师缓冲区空(主轴启用、住等)2。作为一个用户设置
6 [& m% I0 S5 \* n//自动循环开始当一个用户输入一个有效的运动命令手动。这是
- ]% x9 j% X8 }  i3 ^//作为一个初学者的特性来帮助新用户了解刀位点。它可以被禁用
9 I+ Y5 I5 e4 G8 H  t# k//作为一个初学者工具,但(1)仍然运作。如果禁用,运行周期开始
( {1 L: [$ q) Y% U' U) w' _' g$ O//手动发出一个周期开始命令每当用户准备好,有一个有效的运动
4 C6 b& M9 J9 ^' j& {//命令的规划师队列。) @! k+ V% g3 l% k1 o( {$ \- G
//注意:这个函数被称为从主循环缓冲区同步,mc_line只()并执行
; ]! H  i, v( V; }//当其中一个条件分别存在:没有更多的块(即流发送
: V; _1 s: }! C8 h//完成后,单一的命令),一个命令,需要等待缓冲的动作
: _+ K% Z% x( A2 Y9 Z//执行调用一个缓冲区同步,或规划师缓冲区满了,准备好了。/ C, w, }, v7 S# d) Y  `
void protocol_auto_cycle_start() { bit_true_atomic(sys_rt_exec_state, EXEC_CYCLE_START); } . n) h7 L4 O4 p
_______________________________________________________________________________________________2 h9 j2 \( d$ W
接下来程序运行protocol_execute_realtime(); /运行实时命令。7 B  v3 x& v  P8 U. e) A
// Executes run-time commands, when required. This is called from various check points in the main
+ C* s* S( H7 u" r! f+ |3 O% s// program, primarily where there may be a while loop waiting for a buffer to clear space or any
& F- e! L7 z& l) f// point where the execution time from the last check point may be more than a fraction of a second.
2 W6 j+ X9 R; @0 K1 G' d// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code) J- a7 [1 [. e  _
// parsing and planning functions. This function also serves as an interface for the interrupts to ! Q% }/ @- _' x/ r* D/ c3 D- ?
// set the system realtime flags, where only the main program handles them, removing the need to
! [# f! \6 E  O9 |; U2 f$ S- c& H0 k// define more computationally-expensive volatile variables. This also provides a controlled way to
, q7 v& `& ^; f2 G1 z// execute certain tasks without having two or more instances of the same task, such as the planner. r- x2 m4 H! v$ Y$ s, F5 }9 C
// recalculating the buffer upon a feedhold or override.
9 v1 B7 K0 o. }0 o* Q// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,. Y. p3 C7 B2 k; A1 h2 n% h* b
// limit switches, or the main program.
9 U1 d. M0 ^$ @0 Q- V7 @void protocol_execute_realtime()
* U. W9 h; w& Z) Y) {; T, z9 e uint8_t rt_exec; // Temp variable to avoid calling volatile multiple times.临时变量来避免多次调用不稳定。
6 L* A3 t1 A/ X8 |2 m- M" S就先分享到这吧!
+ U7 p( N! s- X/ H- P/ e$ M! Y- k3 `

* d( f1 }) E0 _6 @' g  e$ F( R0 ]' Y/ O* n
. d8 u+ `' V( Y) j- C6 |3 t9 ?1 C
  m) W2 Q" y( P  j7 a& T& F

( e9 |1 A  f! c8 T: U
. c2 o& _9 L% v% _- D& W( ?' P
; m& p# ^' |! o: H6 [2 k, z6 H2 g) y5 ~# C" ]+ x! T

9 f$ F( a6 ]3 [: H2 [; {: u, M+ I1 ?) V' A3 \/ Z/ t
$ N/ [# m1 ~; \( \( |
) ~6 c9 A3 q+ o& i) N3 Q  B8 g
" s# [, y8 d+ H" C, l# z

4 L+ {9 e8 ]# q7 h5 v7 p5 J% S
2 s( R3 X1 g; Y
* O+ G% F. f7 {2 ~& O% H6 V6 y

! L* Z, W! g  c% C- w: L8 L

$ ]' b; I  V' E% `* o$ y5 s) [
0 [4 h0 t* a: m+ ~  L
, i. o9 ]# Q* X$ _4 h
% h- i& W+ X8 p/ |补充内容 (2016-8-25 22:40):, \! i! t/ D" \
配置说明3 F* A: H7 G; z" p1 |! ?
//这个文件包含编译时配置Grbl的内部系统。在大多数情况下,
* _2 C! X3 l) I" y; L; v& E' _//用户不需要直接修改这些,但是他们在这里为特定的需求,即。
' h: y/ C9 V9 R$ q//性能调优或适应非典型的机器。# @/ \" W% u; ^% c0 v6 G
主要配置项:
3 L1 W  h; c0 @; d& @1.#define DEFAULTS_GENERIC        //在重置eepm时使用。在defaults.h改变想要的名字, X  O8 d$ [% h$ C0 q, \1 v3 A
2.#define BAUD_RATE 115200        //配置串口波特率115200# H# G4 |0 X3 k+ P7 V: w# b3 p
3.#define CPU_MAP_ATMEGA328P         // Arduino Uno CPU
3 B, \% Z6 {" D: |" M' b4.#define CMD_STATUS_REPORT '?'        //定义实时命令特殊字符
) [  U  a* l$ |2 C' p+ E5.#define HOMING_INIT_LOCK         //回原点保护锁
$ E) w+ A" N6 s2 P; n5 K6.#define HOMING_CYCLE_0 (1<<Z_AXIS)              // 第一步Z清除工作区。0 ~) C* v3 e0 P+ ^
  #define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // 然后X,Y在同一时间。% v6 E' `) T; Z3 J8 C# Q
7.#define N_HOMING_LOCATE_CYCLE 1 //回原点循环次数* Y! L% J$ [: W  Y: O+ Z
8.#define HOMING_FORCE_SET_ORIGIN //取消这定义迫使Grbl总是在这时候位置设置机器原点尽管开关方向。8 M) d. K+ X% @6 o
9.#define N_STARTUP_LINE 2 //块Grbl启动时执行的数量。
5 p! J1 p" h8 T" Q5 _8 f0 g10.#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 协调或位置价值英寸% t% H: U& e, w/ x
   #define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 协调在毫米或位置价值
& e/ E. o5 c3 a, Y" J, q   #define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分钟的速度值' w* T, T; W0 I' ?
   #define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分钟6 _$ R, v% O7 {3 K8 i
   #define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 对浮点小数设置值
+ \: e' ?8 h9 d7 Q11.#define LIMITS_TWO_SWITCHES_ON_AXES //如果你的机器有两个极限开关连接在平行于一个轴,您需要启用这个特性3 i# v1 C* p, l9 B9 N  e. \% I
12.#define USE_LINE_NUMBERS         //允许GRBL跟踪和报告gcode行号
* T( P9 k, U$ m. s. X" @! L; C: K13.#define REPORT_REALTIME_RATE //允许GRBL报告实时进给速率
. p8 p2 X9 T; _14.#define MESSAGE_PROBE_COORDINATES  //坐标通过Grbl $ #的打印参数?7 e5 ^# M' @: \1 s7 r
15.#define SAFETY_DOOR_SPINDLE_DELAY 4000 //安全门主轴延时' n1 O/ L" u' B  [  W+ ~6 ^' ]
16.#define SAFETY_DOOR_COOLANT_DELAY 1000 //安全门冷却液延时$ E! z7 X' @* |1 j9 M
17.#define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS) //启用CoreXY运动学。) J" N- p! c# E* P. K, x
18.#define COREXY // Default disabled. Uncomment to enable.改变X和Y轴的运动原理8 ]0 `6 l  U: q- V. [. h
19.#define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.反转针销逻辑的控制命令$ N, o" B2 \5 [2 }8 {' ~
20.#define INVERT_SPINDLE_ENABLE_PIN // 反转主轴使销从low-disabled0 S0 {: C) Q6 q5 k- r% v, u* P
21.#define REPORT_CONTROL_PIN_STATE //启用控制销状态反馈状态报告。
+ O" V2 A- d- w# Q! _7 D/ _5 w+ R+ A/ H8 l22.#define FORCE_INITIALIZATION_ALARM //启用和用户安装限位开关,Grbl将启动报警状态指示
( j- ~; a6 ~* A1 k23.#define REPORT_GUI_MODE // gui允许最小的报告反馈模式
2 \) h) F: [; Y6 y24.#define ACCELERATION_TICKS_PER_SECOND 100 //加速度的时间分辨率管理子系统。
: @3 ]& e" r3 S2 G# ^25.#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING //自适应多轴步平滑(积累)是一种先进的功能
0 e6 q% s8 ]2 A3 o, E26.#define MAX_STEP_RATE_HZ 30000 //设置最大一步速率可以写成Grbl设置
/ E6 f9 M: R! n. \/ X7 @& c27.#define DISABLE_LIMIT_PIN_PULL_UP //以下选项禁用内部上拉电阻
- ?! a4 V& e  c# B* R28.#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS //设置哪个轴长度补偿应用的工具。假设轴总是与选择轴工具面向负方向8 J) z( [6 T' r
29.#define VARIABLE_SPINDLE //允许变量轴输出电压不同的转速值。% r) L" ^7 C! p0 L: d: u
30.#define SPINDLE_MAX_RPM 1000.0  // Max spindle RPM. This value is equal to 100% duty cycle on the PWM./ l* j3 a! G! I
   #define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.
) K& W4 H% q4 a31.#define MINIMUM_SPINDLE_PWM 5 //使用的变量轴输出。这迫使PWM输出最小占空比时启用。5 ]& t2 r9 f( t: x6 V6 B
32.#define USE_SPINDLE_DIR_AS_ENABLE_PIN //主轴方向使能M4被删除
3 Z! u% A; _+ a; P) l, T33.#define REPORT_ECHO_LINE_RECEIVED //应该对所有正常线路送到Grbl
. O, |) H5 k( L* w0 y6 a34.#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min) //最小规划师结速度。设置默认最小连接速度规划计划; ^8 Q$ C6 V1 T* {! `
35.#define MINIMUM_FEED_RATE 1.0 // (mm/min)//设置计划将允许的最小进给速率# e7 v( b' K* k5 z6 W- Q
36.#define N_ARC_CORRECTION 12 //弧生成迭代次数之前小角度近似精确的弧线轨迹6 z4 I- o& K) Y( e  e3 E
37.#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)//定义值设置机器ε截止来确定电弧是一个原点了?: Y& x4 [& X* U  c8 H9 h2 X
38.#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds) //延时增加表现在住。默认值设置为50毫秒
, ]* n- D( ~; Z* ^39.#define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.
* w+ d7 {# }) u- t) c+ h40.#define BLOCK_BUFFER_SIZE 18  //线性运动规划师缓冲区的数量在任何给出时间计划
2 U+ M3 W8 {: n* [, }41.#define SEGMENT_BUFFER_SIZE 6 //控制之间的中间段缓冲大小的步骤执行算法
# L% G4 R8 A  \+ L42.#define LINE_BUFFER_SIZE 80 //行执行串行输入流的缓冲区大小。
' c- \7 ~& j- a2 r& @/ ~2 h  X; ]4 \43.define RX_BUFFER_SIZE 128 //串行发送和接收缓冲区大小; @- O- w6 R$ r" n3 ?
44.#define TX_BUFFER_SIZE 64
( ]9 u' e" }: l* N  j6 O8 i45.#define ENABLE_XONXOFF        ////切换为串行通信发送流软件流控制。
3 W0 v: r' l0 N% b) G7 e. n  e0 x46.#define ENABLE_SOFTWARE_DEBOUNCE //一个简单的软件消除抖动特性硬限位开关。# Q( I* C& ^) e7 }/ }
47.#define HARD_LIMIT_FORCE_STATE_CHECK        //Grbl检查硬限位开关的状态  S/ H* `. v2 W# Y, f
48.// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:编译时错误检查的定义值:
3 r5 r( c. B+ e" F* W4 t# |$ U- w: \. C
: E4 f! W4 N* J: o6 `___________________________________________________________________________________________________. @& V/ \# O( Q0 }5 G: h
/*
( @1 J5 L* A  N  config.h - compile time configuration$ r. u% ]0 _4 b# h- e
  Part of Grbl% [5 e2 ]. ~6 n) v; h  h$ l* a
! y3 d# q5 ?5 i3 J0 c# a2 w& `0 V
  Copyright (c) 2012-2015 Sungeun K. Jeon
3 _1 t( h" n5 X, G  Copyright (c) 2009-2011 Simen Svale Skogsrud" [( w* P1 k6 R( D( D
2 M) C* D3 m* |
  Grbl is free software: you can redistribute it and/or modify
. x" E) T9 |% n3 O  it under the terms of the GNU General Public License as published by* ]6 O* L+ _  ~- w! t7 E6 u+ i& \
  the Free Software Foundation, either version 3 of the License, or
$ K5 l/ z- L' J- m$ u; }& y" K  (at your option) any later version.( W# T) ~6 V* q+ O

+ A4 l$ z8 P% _* U6 u  Grbl is distributed in the hope that it will be useful,, h2 V9 M' O+ {$ V8 E: B. A
  but WITHOUT ANY WARRANTY; without even the implied warranty of; m) Y3 r. F* `# _
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1 Q) X+ g! \3 f" S  GNU General Public License for more details.
+ t# a2 Z  H' x5 b# P* W0 w% _3 q/ B
  You should have received a copy of the GNU General Public License4 o( L7 ?0 F% G0 q+ k: Q
  along with Grbl.  If not, see <http://www.gnu.org/licenses/>.' U1 q; w3 f& h+ I" @
config.h  -编译时配置,Grbl的一部分: w! W- G# D+ L4 S' S4 d4 p9 A9 p

/ o. }  W/ g2 J( F版权(c)2012 - 2015 Sungeun K. Jeon$ [3 `+ P3 E% n
版权(c)2009 - 2011 Simen Svale Skogsrud, Z" K6 ]" h1 O9 y8 n/ {8 \6 Q" _9 e
( u3 l! @8 c' N* N
Grbl是免费软件:可以重新分配和/或修改
+ m% _0 ^+ O/ \" LGNU通用公共许可证的条款下发布的自由软件基金会,版本3的许可,或(任您选)其后的版本。
  i1 g. g. l# u+ W: ^
+ E! j7 F3 n9 \  _+ p: HGrbl分布,希望这将是有用的,但是没有任何保证;没有即使的默示保证适销性或健身为特定目的。看到3 f& Y& J- X! H; ^
GNU通用公共许可证的更多细节。" R2 i2 Y- ]) `) f7 q  I: ~5 U
8 @0 Z. @& g5 J. D
你应该收到了GNU通用公共许可证的副本
8 @5 ?, W+ q# X连同Grbl。如果没有,看< http://www.gnu.org/licenses/ >。
0 j$ \7 t" C0 ?  \& _0 }; r, y # q+ G+ a$ k4 g! o& z; a
*/1 r0 {9 i4 `: |3 L
  
6 C0 S7 P5 j# h' x8 E  U' U8 m// This file contains compile-time configurations for Grbl's internal system. For the most part,9 N* b- b( i# m
// users will not need to directly modify these, but they are here for specific needs, i.e.2 u) R; V4 N, m0 x$ k3 D" Z& i
// performance tuning or adjusting to non-typical machines.6 g) c, E) K( {8 K
//这个文件包含编译时配置Grbl的内部系统。在大多数情况下,
3 [, ?! ?( `8 l& u& t//用户不需要直接修改这些,但是他们在这里为特定的需求,即。
& v* T7 f8 w6 v' t7 }7 p" [//性能调优或适应非典型的机器。
! K0 N( i: _1 ?% B. w; W  o7 t* Q9 V4 L
// IMPORTANT: Any changes here requires a full re-compiling of the source code to propagate them.5 h" Y. n3 C* o) I  U6 M
//重要:任何变化需要一个完整的基于源代码的传播。$ Q" s( u) i2 g# E
) V. P. U+ x4 Z5 K5 @( C% x
#ifndef config_h
7 U" ?! Q$ A8 e5 M3 G; T  s: ^" X; w#define config_h
! h$ g8 ?3 h7 S2 {1 ]% T8 R  H#include "grbl.h" // For Arduino IDE compatibility.. p. k* f% R7 d

. L5 H* V; i8 }// Default settings. Used when resetting EEPROM. Change to desired name in defaults.h( L5 N/ U" t$ K  f# Q* Z
// 默认设置。在重置eepm时使用。在defaults.h改变想要的名字! U( |% f) }4 ]- Q5 c3 ~9 c
) Y/ c: V% v- P7 Z2 U) @) F
#define DEFAULTS_GENERIC
6 Q7 }3 d5 W/ {6 x
7 Q8 a- A* d$ X7 S: y+ k// Serial baud rate* t" f& t0 B$ i9 i+ D8 U- L
#define BAUD_RATE 115200                //配置串口波特率115200
) W2 T& S8 e- K9 M! i2 y- i
  w. k) G5 E% G0 e2 a% `. P2 @7 g// Default cpu mappings. Grbl officially supports the Arduino Uno only. Other processor types
: G4 Z! F) ?6 n$ t  s// may exist from user-supplied templates or directly user-defined in cpu_map.h+ A4 T1 J7 j" @% h
//默认cpu映射。Grbl正式支持Arduino Uno。其他类型的处理器可能存在cpu_map.h直接从用户提供的模板或用户定义的
4 |5 }9 p0 Q, o  @- R, }1 r5 l+ l' k% k) y1 }: d
#define CPU_MAP_ATMEGA328P // Arduino Uno CPU
7 n* P+ p9 y. u5 x$ I: I: z8 {  ~2 I! R9 A! m- Z' j
// Define realtime command special characters. These characters are 'picked-off' directly from the
/ |" k& |, m- \* }: Y9 _; K; v+ m// serial read data stream and are not passed to the grbl line execution parser. Select characters; g" v; e/ O4 I. D, H# X1 H9 p/ O# @# t
// that do not and must not exist in the streamed g-code program. ASCII control characters may be
, ~" h* P5 F, `# e// used, if they are available per user setup. Also, extended ASCII codes (>127), which are never in
- U5 p& t( c" ?9 W// g-code programs, maybe selected for interface programs.6 Q% f$ M& a9 i. `- P& w9 z
// NOTE: If changed, manually update help message in report.c.
2 |' }; u- R6 P: b& d6 s$ c, j( S- T
5 ^' \  o; D0 i5 L# s0 d, H% J//定义实时命令特殊字符。这些字符是直接从“各个击破”串口读取数据流并没有传递到grbl行执行解析器。选择角色
  w/ Z* j3 z6 _, B% t8 a//不,不能存在于程序流刀位点。ASCII控制字符7 B. `, S" M( Q- [
//使用,如果他们是可用的每个用户设置。同时,扩展的ASCII码(> 127),从来没有
; r" A0 T2 X; W1 l. _0 Y7 K* u//刀位点的程序,也许选择界面程序。$ j; r/ d2 H6 m5 S* m* m! s! a
//注意:如果改变,手动更新report.c帮助信息。' W4 f9 E* v' j$ A  T
8 c) ^6 `: U; Y; I: B
#define CMD_STATUS_REPORT '?'
  S. S% q, r$ m' c#define CMD_FEED_HOLD '!'( C3 W  h, g2 ?0 G
#define CMD_CYCLE_START '~'' k; P- ]9 g4 {: Q! r! h7 _: p
#define CMD_RESET 0x18 // ctrl-x.3 v6 D& V2 k# u. D+ P* Y
#define CMD_SAFETY_DOOR '@'0 E1 @1 z5 R$ e
1 S7 q, s( U. M4 ?# q) G- G0 C
// If homing is enabled, homing init lock sets Grbl into an alarm state upon power up. This forces
: w: a/ ?" ~8 I" L9 f// the user to perform the homing cycle (or override the locks) before doing anything else. This is. }, h7 E2 s- A- C. Z2 i
// mainly a safety feature to remind the user to home, since position is unknown to Grbl.
9 x5 k* e) F* R4 l# j! h% {" r  [8 n7 E4 M+ A
//如果启用了回原点,导航初始化锁集Grbl进入警报状态启动。这就迫使2 @, Z, e3 G  Z6 x' ]
//用户执行归航周期(或覆盖锁)在做任何其他事情之前。这是
$ h% a) l6 @' m4 o//主要安全功能,提醒用户家里,因为Grbl位置是未知的。
' }9 c! v1 @- ?  y0 f: r: Z# B. }, H
#define HOMING_INIT_LOCK // Comment to disable
) h' Q) W+ z4 ]' \# j! ^
, a5 M' y) W0 z/ h: t; O3 _* d5 C' K// Define the homing cycle patterns with bitmasks. The homing cycle first performs a search mode
6 v# z. v/ l3 U" B( O// to quickly engage the limit switches, followed by a slower locate mode, and finished by a short* n# R4 u# |4 R& r  S9 i, \2 C* ?3 x
// pull-off motion to disengage the limit switches. The following HOMING_CYCLE_x defines are executed 5 L! `/ ~3 j6 M- Y; @
// in order starting with suffix 0 and completes the homing routine for the specified-axes only. If
; q6 x( L* j9 l8 s; V: A// an axis is omitted from the defines, it will not home, nor will the system update its position.
1 q5 y  g7 k& v9 L% r) h// Meaning that this allows for users with non-standard cartesian machines, such as a lathe (x then z,0 D  \% p( i. @# i& h8 [
// with no y), to configure the homing cycle behavior to their needs.
! E, Y8 g& M3 I. x. c. C// NOTE: The homing cycle is designed to allow sharing of limit pins, if the axes are not in the same9 o. \% \% p6 a; L3 K* _& q" o% g
// cycle, but this requires some pin settings changes in cpu_map.h file. For example, the default homing) I6 x6 D2 ~2 |+ O
// cycle can share the Z limit pin with either X or Y limit pins, since they are on different cycles.
2 `% X: W- g4 f# y" Z# w// By sharing a pin, this frees up a precious IO pin for other purposes. In theory, all axes limit pins
3 O2 {! v6 d; V: r- d' w// may be reduced to one pin, if all axes are homed with seperate cycles, or vice versa, all three axes# U/ U! I: m2 B3 [5 r
// on separate pin, but homed in one cycle. Also, it should be noted that the function of hard limits
$ M8 _  b1 D8 Q# l' `- _5 g// will not be affected by pin sharing.! @: u8 @5 q$ g! {" t/ m) m: V5 w& a
//定义导航循环模式的位掩码。归航周期首先执行一个搜索模式: o4 O0 V5 N+ _% L: p
//快速进行限位开关,其次是较慢的定位模式,完成了由一个短- ]. ~$ ?( y' `
//拖出运动脱离限位开关。以下HOMING_CYCLE_x定义执行* x4 |, ~) D' N2 z# F/ _5 c! U- j/ l
//为了与后缀0开始并完成specified-axes只寻的例程。如果
8 |2 x8 `' j) N. R# P# c//定义省略一个轴,它会不在家,也不会系统更新它的位置。9 B3 E* Q# C4 p& c
//意义,这允许用户与非标准笛卡尔的机器,比如车床(x,z,
% `1 i, z! R3 d1 t. o" j: {//没有y),配置导航循环行为对他们的需求。
0 {! q( h0 s* G//注意:归航周期允许共享限制针,如果轴不相同) I! S" o/ V' |. _
//循环,但这需要一些销设置cpu_map的变化。h文件。例如,默认的导航
( r% f- l' I0 l; j4 X//循环可以分享Z限位销X或Y限制针,因为它们是在不同的周期。
' p0 r+ ~2 j- \" z//通过共享一个销,这腾出宝贵的IO销用于其他目的。从理论上讲,所有轴限制别针
- k8 o  |+ w& y1 k2 ^/ Q//可能会减少到一个销,如果所有轴与分离周期居住的地方,反之亦然,所有三个轴
; b# }$ o# U' u7 H8 v6 r//在不同销,但这时候一个周期。同时,应该注意的是,硬限制的功能! [, u$ z4 ~, w  z
//将不会影响销共享。
! U# S, M% O- N+ a3 n//注意:默认设置为一个传统的硬件数控机器。z轴首次明确,其次是X和Y。
% j0 ^% a+ ?% l/ A$ I
! i. F  v& G% \* P// NOTE: Defaults are set for a traditional 3-axis CNC machine. Z-axis first to clear, followed by X & Y.! z: i9 A7 T# u+ z9 s
#define HOMING_CYCLE_0 (1<<Z_AXIS)                // REQUIRED: First move Z to clear workspace. 第一步Z清除工作区。9 a. q0 x0 }( z+ D3 x2 E
#define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // OPTIONAL: Then move X,Y at the same time.然后X,Y在同一时间。
* q( X. y; r6 o// #define HOMING_CYCLE_2                         // OPTIONAL: Uncomment and add axes mask to enable, t4 {2 E: t' j) t0 W; y6 \( E: j8 }: t

* Y6 ^0 T3 V. T5 C! Z// Number of homing cycles performed after when the machine initially jogs to limit switches.
1 X+ h/ F7 o( x$ q8 A" T// This help in preventing overshoot and should improve repeatability. This value should be one or
; `3 c! a% k5 f( k$ O; t0 u) y// greater." }* x/ i  T) S
//执行回原点循环次数后,当机器最初慢跑限位开关。这个帮助防止过度,应该提高重复性。这个值应该是一个或大。. U) G. t( ]2 H  L% {: u2 S

, h; s8 {* ~! T  T. e; s#define N_HOMING_LOCATE_CYCLE 1 // Integer (1-128)5 F3 X( _* r, o- D

. C8 @! ^9 B( T+ j// After homing, Grbl will set by default the entire machine space into negative space, as is typical
& a1 Z  T' Z. k: N  J' Q* k// for professional CNC machines, regardless of where the limit switches are located. Uncomment this
2 R5 O$ `& I5 d! P3 n4 V// define to force Grbl to always set the machine origin at the homed location despite switch orientation.7 w5 J) w* o$ W' E

' u8 {* ]; D) _/ Z1 B//导航后,默认Grbl将整个机器空间留白,是典型的专业数控机器,不管限位开关所在的地方。# x; E4 _- V( T  @3 _
//取消这定义迫使Grbl总是在这时候位置设置机器原点尽管开关方向。
+ v3 _- Y/ z) D# S5 t$ n( @" P" }3 f3 g' l3 D
// #define HOMING_FORCE_SET_ORIGIN // Uncomment to enable.
, \( r! h+ z; K- H* \# {9 O3 O# H2 k5 G; W5 ~: u  _

( @& Z8 d0 S; R6 {2 c// Number of blocks Grbl executes upon startup. These blocks are stored in EEPROM, where the size
# p# @" F& r: \, l1 U// and addresses are defined in settings.h. With the current settings, up to 2 startup blocks may
' N& P6 ~0 y' ]" j# i: z// be stored and executed in order. These startup blocks would typically be used to set the g-code% ^, C( ]* f# I( x
// parser state depending on user preferences./ a- a. {5 }* }; b9 T

! H3 F6 ?! |7 e9 y//块Grbl启动时执行的数量。这些块存储在eepm,大小
* |2 |) W" A* l8 j//和地址在settings.h中定义。与当前设置,可能2启动块" g# W; V6 ]9 j3 E4 _
//存储和执行。这些启动块通常被用来设置刀位点
7 h; e. o" p2 O5 N4 c: {4 {! u//解析器的状态取决于用户首选项。. R9 ]' E' X9 F2 K3 Z0 l

  I5 Z- k4 V2 c  E7 c  b1 f' S#define N_STARTUP_LINE 2 // Integer (1-2)8 e( ~3 B5 O, e4 h) v/ m% {
. ]4 e6 `$ p7 ]
// Number of floating decimal points printed by Grbl for certain value types. These settings are
+ s8 Y' n) w) B8 g2 q( u5 _// determined by realistic and commonly observed values in CNC machines. For example, position
+ [4 V8 f6 F2 ~; C6 p6 ^// values cannot be less than 0.001mm or 0.0001in, because machines can not be physically more
; S- K2 z. [6 s: X. d7 t0 W// precise this. So, there is likely no need to change these, but you can if you need to here.: X3 k0 }# U' @  z! \- Z
// NOTE: Must be an integer value from 0 to ~4. More than 4 may exhibit round-off errors.8 P# v+ I3 I5 C2 M) j( D

8 U( B1 e2 c7 W  E( d// Grbl浮动小数点的数字印刷的特定的值类型。这些设置是
% |4 ?# F" }0 L3 K" O: ~  F//一般由现实和观测值在数控机器。例如,位置
/ f4 E3 z% d) x+ [4 C6 a2 n//值不能小于0.001毫米或0.0001,因为机器不能身体更多
: d. ^! c& X) {/ Q. G//精确。因此,有可能不需要改变这些,但你可以在这里如果你需要。; E. `/ Q  e- E6 ?
//注意:必须是一个整数值从0 ~ 4。超过4可能出现舍入错误。
. X: D& D% y8 F6 @3 u- q' g7 m+ F. C
#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 协调或位置价值英寸  P  n0 ^3 o; s2 @  q' i1 {
#define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 协调在毫米或位置价值
" c- x- u$ Y4 B( B3 U& g. `* E#define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分钟的速度值
8 v) X4 c( B) F( {, ^0 R#define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分钟
( |' [5 E5 K: G#define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 对浮点小数设置值+ ], X: D* g4 _, e' w: j

0 F: x+ D7 T0 r& N: Q// If your machine has two limits switches wired in parallel to one axis, you will need to enable& b. O3 m# l. F1 O
// this feature. Since the two switches are sharing a single pin, there is no way for Grbl to tell
7 o+ ?+ T+ Z0 N/ u// which one is enabled. This option only effects homing, where if a limit is engaged, Grbl will
) L4 {* {$ }5 S5 K+ B7 U// alarm out and force the user to manually disengage the limit switch. Otherwise, if you have one
! O# g$ o. \1 x3 G; k// limit switch for each axis, don't enable this option. By keeping it disabled, you can perform a
6 o7 b3 j% J. P" k* [$ M  n2 d" p// homing cycle while on the limit switch and not have to move the machine off of it.
2 g! L. N) l& t9 M+ k1 o
3 @4 D. h. `* L7 s//如果你的机器有两个极限开关连接在平行于一个轴,您需要启用
: q- E, w$ U2 G1 k5 A; Q7 B* }//这个特性。自从两个交换机共享一个销,没有办法Grbl告诉
$ j4 n" |+ @! K" Z* s2 f//启用哪一个。此选项仅影响归航,如果限制,Grbl意志
$ P% \, `& p$ ~5 j/ L  A0 V//报警,迫使用户手动松开限位开关。否则,如果你有一个
6 H% h& }, G8 y, u7 l2 i: ~7 O//为每个轴限位开关,不启用该选项。通过保持禁用,您可以执行
' h% x0 \& K. p5 K//导航循环在限位开关并没有将这台机器。
: w) e3 ?: p1 X. d! h1 }2 r4 ^* }& h7 g/ ~; w9 ^/ _" N$ r/ t
// #define LIMITS_TWO_SWITCHES_ON_AXES
, e  f8 X% e) H6 I7 O, Z$ t9 J1 o0 x* m' _/ ^& F0 J& M0 \
// Allows GRBL to track and report gcode line numbers.  Enabling this means that the planning buffer/ p7 x. K$ A' ]- ^% a$ q
// goes from 18 or 16 to make room for the additional line number data in the plan_block_t struct+ L1 Y, b% D& r8 x- f
& V: O/ s4 S- Y! s# t
//允许GRBL跟踪和报告gcode行号。使这意味着计划缓冲从18岁或16岁,为额外的行号plan_block_t结构中的数据9 }2 R  h2 z, W( @- B

7 O* d2 ^$ d' k) k! O// #define USE_LINE_NUMBERS // Disabled by default. Uncomment to enable.
2 W' D6 C- F) j, W/ J' f, p7 O! m- G( D& D
// Allows GRBL to report the real-time feed rate.  Enabling this means that GRBL will be reporting more
: J3 E7 H! [* ^- m5 r// data with each status update.
* A' N+ }; v* r0 e6 S// NOTE: This is experimental and doesn't quite work 100%. Maybe fixed or refactored later.; G/ |: {( W  F/ z
//允许GRBL报告实时进给速率。使这意味着GRBL将报告数据和状态更新。7 [2 u5 `9 x# ?# D& x. a% F
//注意:这是实验和100%没有工作。也许以后固定或重构。) P, F' e6 o. P- @1 t" \
! L; q/ t. \3 g* q0 B$ I
// #define REPORT_REALTIME_RATE // Disabled by default. Uncomment to enable.' P" ]4 ]; ?9 E
) M( u7 `; Z! o0 k$ J& u; N& N
// Upon a successful probe cycle, this option provides immediately feedback of the probe coordinates7 {: z6 G0 T$ G% b0 |, G
// through an automatically generated message. If disabled, users can still access the last probe: ~: U; Y5 O) r& S( b- u% ]+ M: I
// coordinates through Grbl '$#' print parameters.
* {2 T8 u3 n5 z8 p! e6 W//在一个成功的调查周期,这个选项提供立即反馈的探测器坐标# T* N( |4 \7 E; w8 D
//通过一个自动生成的消息。如果禁用,用户仍然能够访问调查9 a: ]  z% \' y* _
//坐标通过Grbl $ #的打印参数。
& |6 F: H$ l8 t& @
4 N( U3 _5 D. i, _- M, g& m  p4 b#define MESSAGE_PROBE_COORDINATES // Enabled by default. Comment to disable.
4 t9 ]) w3 h% e; |' W 4 R3 g5 S" w3 J) ^( s5 E4 t( [! N5 H8 P
// Enables a second coolant control pin via the mist coolant g-code command M7 on the Arduino Uno
9 P2 x2 i' V' B8 D! _// analog pin 5. Only use this option if you require a second coolant control pin.
* a$ w. W' |* c1 |) d- {+ R* e% M// NOTE: The M8 flood coolant control pin on analog pin 4 will still be functional regardless.
( b& H0 ~+ G% a/ R/ x3 s7 ]// #define ENABLE_M7 // Disabled by default. Uncomment to enable.
8 d( z% G& y% ~8 ?- \( J
0 V% C0 r3 u$ q- R! s" z! ^// This option causes the feed hold input to act as a safety door switch. A safety door, when triggered," r. g" u9 ~; K
// immediately forces a feed hold and then safely de-energizes the machine. Resuming is blocked until* K6 ?; p1 D1 p2 ~( Y
// the safety door is re-engaged. When it is, Grbl will re-energize the machine and then resume on the  u( T2 ]. g; K# ^
// previous tool path, as if nothing happened.
9 M" ]6 _7 ?! r7 W/ Y// #define ENABLE_SAFETY_DOOR_INPUT_PIN // Default disabled. Uncomment to enable.
/ w" R' i" k6 r. s" H3 _: p
8 s; l/ w. C/ Z+ c9 }3 A, f4 b( Z# a// After the safety door switch has been toggled and restored, this setting sets the power-up delay5 o' f! S, \  P% w/ K! ]
// between restoring the spindle and coolant and resuming the cycle.7 D3 d, R: x$ z8 H" q- G2 }  N$ h
// NOTE: Delay value is defined in milliseconds from zero to 65,535. ( j" D- S' f( m# g

2 d. d0 o5 r& h& \/ ^1 D//定义导航循环模式的位掩码。归航周期首先执行一个搜索模式
  w" K, |2 @8 P2 v//快速进行限位开关,其次是较慢的定位模式,完成了由一个短
: T4 Y1 c) [/ D+ s: E. S# m# D//拖出运动脱离限位开关。以下HOMING_CYCLE_x定义执行
4 C- y# f+ ]$ w, {0 d( \+ @. T5 Z//为了与后缀0开始并完成specified-axes只寻的例程。如果
! G6 l- J* e/ @2 |//定义省略一个轴,它会不在家,也不会系统更新它的位置。1 j8 w) F. D$ i/ ~; R
//意义,这允许用户与非标准笛卡尔的机器,比如车床(x,z,$ v. @9 Q* h# i1 ?
//没有y),配置导航循环行为对他们的需求。+ E: H  S7 u( E- v. K# b4 C5 s
//注意:归航周期允许共享限制针,如果轴不相同' C; V0 t, k; i3 F+ ~
//循环,但这需要一些销设置cpu_map的变化。h文件。例如,默认的导航
/ e0 [( x# Z  I//循环可以分享Z限位销X或Y限制针,因为它们是在不同的周期。1 ~7 U9 g- Q) l) ~
//通过共享一个销,这腾出宝贵的IO销用于其他目的。从理论上讲,所有轴限制别针
7 X' `- X& ~& ]* v//可能会减少到一个销,如果所有轴与分离周期居住的地方,反之亦然,所有三个轴' h) Y9 d7 n$ ]
//在不同销,但这时候一个周期。同时,应该注意的是,硬限制的功能
/ j3 I+ w) Q& t/ p, t//将不会影响销共享。5 C" [# ]' ~$ P+ c; I7 J
//注意:默认设置为一个传统的硬件数控机器。z轴首次明确,其次是X和Y。
1 B2 x. x& Q: l( r3 c4 `
4 C) b; n! }( b# r3 M/ c, T6 d7 l1 x' a4 ?, H% r- G& v2 K' q
#define SAFETY_DOOR_SPINDLE_DELAY 4000
/ u( Z6 u, D1 a, y4 @  J& w" w3 G#define SAFETY_DOOR_COOLANT_DELAY 10001 y+ }0 U$ v1 S; \. I% {: K4 B" n9 h
: X9 \5 ]5 x5 ]
// Enable CoreXY kinematics. Use ONLY with CoreXY machines.
, ^" G, E  g: U! ]$ U2 e$ E. X// IMPORTANT: If homing is enabled, you must reconfigure the homing cycle #defines above to $ Q9 G2 ~% w' H; ^( X) Z9 a5 o; Q
//启用CoreXY运动学。只使用与CoreXY机器。
0 o% {$ w) Z2 d" b; \# D//重要:如果启用了自动寻的,你必须重新配置导航循环#定义上面
) W# J+ |0 c+ c
7 q: l1 p% p; }& ?/ m# \// #define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS)% w' k# K$ g" s- v& w/ G

; s4 H/ G; w* O$ Z" y5 x// NOTE: This configuration option alters the motion of the X and Y axes to principle of operation8 H5 X9 t2 i% e) w  _
// defined at (http://corexy.com/theory.html). Motors are assumed to positioned and wired exactly as
" R, J. \# Z. g+ M// described, if not, motions may move in strange directions. Grbl assumes the CoreXY A and B motors
( P( F& H! @; m. q( o; L. E// have the same steps per mm internally.
4 X& Q5 a6 z2 T! q; M" {//注意:这种配置选项改变X和Y轴的运动原理,操作
* C8 k4 Y: _0 x//定义(http://corexy.com/theory.html)。汽车被认为定位和连接一样" L/ u! a- Y' ~1 h- O
//描述,如果没有,运动可能会奇怪的方向移动。A和B Grbl假设CoreXY马达; Z7 B7 z( G8 `# Y, Q( e
//每毫米内部有相同的步骤。
! x( x- k* \# m3 ]/ i& p* R$ Z" s% e) r9 U
// #define COREXY // Default disabled. Uncomment to enable.
- N* J, C, U; x7 r3 Y; O$ Y) c4 i' N6 N
// Inverts pin logic of the control command pins. This essentially means when this option is enabled
( ?4 X( w3 U8 z4 N; w// you can use normally-closed switches, rather than the default normally-open switches.0 m- Q( R; h, ], s
// NOTE: Will eventually be added to Grbl settings in v1.0.
; g. [& w+ c, K& \//反转针销逻辑的控制命令。这实质上意味着当启用这个选项
5 B3 M" u( m; [1 _+ ~//可以使用闭合开关,而不是默认的常开开关。
( Y. n6 d! Z1 y! w; C  k* I( Y1 L//注意:最终将被添加到在v1.0 Grbl设置。" C  N& o6 t8 z

- h$ ^( i  V& w9 }// #define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.8 ]1 D1 T: D1 T3 C9 x2 S

* ~5 c) M( v5 C8 C  ?. X/ L// Inverts the spindle enable pin from low-disabled/high-enabled to low-enabled/high-disabled. Useful
, y; S) O& f/ w4 g' v  J// for some pre-built electronic boards.% G5 [9 f) }# [* e7 \
// NOTE: If VARIABLE_SPINDLE is enabled(default), this option has no effect as the PWM output and
4 x% t. F0 z* M* s// spindle enable are combined to one pin. If you need both this option and spindle speed PWM,
1 q+ s& P1 E3 L8 `// uncomment the config option USE_SPINDLE_DIR_AS_ENABLE_PIN below.$ f. D5 h0 z: S& `
//反转主轴使销从low-disabled / high-enabled low-enabled / high-disabled。有用的' Z2 o" G  S: a7 p, L# h
//预构建的电子板。! h% c* b' ?* Y. |! m* s
//注意:如果启用了VARIABLE_SPINDLE(默认),这个选项作为PWM输出并没有影响
  _1 c4 C% D% U//销轴使结合。如果你需要这个选项和主轴转速PWM,
2 W# D! x" u7 ?+ q* ^8 }3 L//取消注释以下配置选项USE_SPINDLE_DIR_AS_ENABLE_PIN
3 ^. r7 D' k& X% A# S9 d: s" B# ^( i& }# T3 T1 m0 D+ w
// #define INVERT_SPINDLE_ENABLE_PIN // Default disabled. Uncomment to enable.4 w8 J1 i9 j6 F2 n% W
1 |  u8 j# X% s% v8 z6 `8 S
// Enable control pin states feedback in status reports. The data is presented as simple binary of
0 z! J8 _, w* E; @// the control pin port (0 (low) or 1(high)), masked to show only the input pins. Non-control pins on the
$ B0 Z' p; `% {4 l8 ~2 h0 {// port will always show a 0 value. See cpu_map.h for the pin bitmap. As with the limit pin reporting,5 j: N. b# I$ H$ d, H7 K( A8 @# k
// we do not recommend keeping this option enabled. Try to only use this for setting up a new CNC.
4 Z* Z/ c% A5 N  I- r//启用控制销状态反馈状态报告。作为简单的二进制数据" h; a  P, w* M% m5 m
//控制针端口(0(低)或1(高)),蒙面,只显示输入插脚。非控制性针上
3 Y9 `/ N* I; i( [6 W//端口总是显示0值。看到cpu_map。针位图h。与限制销报告,6 }, h' V- q& s; r
//我们不推荐保持启用这个选项。尽量只使用这个设置一个新的数控。
' s0 s( E3 ], _$ P$ ]
0 ^: q0 v, u9 ]4 R: ~// #define REPORT_CONTROL_PIN_STATE // Default disabled. Uncomment to enable.
5 b& z: q2 v( X4 b& m2 P/ [+ M/ O7 [, k- Z
// When Grbl powers-cycles or is hard reset with the Arduino reset button, Grbl boots up with no ALARM
- H" J# a8 @: V1 K0 \5 P// by default. This is to make it as simple as possible for new users to start using Grbl. When homing4 O6 t+ j' U/ Y" _+ i: b
// is enabled and a user has installed limit switches, Grbl will boot up in an ALARM state to indicate
2 D7 h8 F8 m; _) I/ ^// Grbl doesn't know its position and to force the user to home before proceeding. This option forces
% N+ }- F" c  U5 e' W// Grbl to always initialize into an ALARM state regardless of homing or not. This option is more for5 R' P, e* d# R0 y7 O
// OEMs and LinuxCNC users that would like this power-cycle behavior.
- p' x7 M  D) e6 U//当Grbl powers-cycles还是硬重置Arduino复位按钮,Grbl启动没有报警
! q* _& Z5 I+ i+ o& U. c//默认情况下。这是为了让新用户尽可能简单使用Grbl开始。当归航
( O( F$ D" X0 ~1 w- F, ?1 P//启用和用户安装限位开关,Grbl将启动报警状态指示' J% B3 o7 W2 Q0 z
// Grbl不知道它的位置,迫使用户在继续之前回家。这个选项部队; Z/ [6 B9 F- L/ t3 i
// Grbl总是初始化进入警报状态不管归航。这个选项是更多3 u2 j+ Y# G7 _' k# j6 w
//原始设备制造商和LinuxCNC用户这样的控制行为。! g5 J6 k1 J+ r1 n

; p2 Y) J. O$ Q( s5 O; C// #define FORCE_INITIALIZATION_ALARM // Default disabled. Uncomment to enable.- Q. I7 D) R7 A1 g* |# |
6 \2 `& v" r; S3 I# e3 o/ F' D; P
// ---------------------------------------------------------------------------------------
' N0 W) E5 x% ]7 f0 f, [4 E+ k# m// ADVANCED CONFIGURATION OPTIONS://高级配置选项:
9 w2 l- f5 ?  N& r3 h
. B! }" C2 n# u3 ^' _( O// Enables minimal reporting feedback mode for GUIs, where human-readable strings are not as important.8 o5 N7 m* C9 g5 K; o6 x9 L- S5 W
// This saves nearly 2KB of flash space and may allow enough space to install other/future features.
; o6 i7 D7 {( ^# f7 g// GUIs will need to install a look-up table for the error-codes that Grbl sends back in their place.  q3 I7 c; o( @! T' o6 V
// NOTE: This feature is new and experimental. Make sure the GUI you are using supports this mode.: q0 m1 n+ U$ d; ~
4 u; H* z2 g2 h- W- J, p
// gui允许最小的报告反馈模式,人类可读的字符串在哪里不重要。9 q! p" a% W9 z# Z7 d8 C
//这个节省近2 kb的闪存空间,允许足够的空间来安装其他/未来的功能。
) \( ]' h" M, i" `' f* b- M// gui需要安装一个查找表的错误代码Grbl发回。
6 z, u. O8 y& q6 O2 b//注意:此功能是新的和实验。确保您使用的GUI支持这种模式。
7 C8 N+ K8 H3 y1 J* u6 O
  P3 Z, z5 B( t/ a// #define REPORT_GUI_MODE // Default disabled. Uncomment to enable.* m4 e7 E0 a8 z5 A/ H
: f" ]& f9 C5 J( n$ T$ h6 `6 M6 z" ?
// The temporal resolution of the acceleration management subsystem. A higher number gives smoother
" R/ N. ?% f6 n) p. T0 b7 S7 \5 R// acceleration, particularly noticeable on machines that run at very high feedrates, but may negatively
- u+ m% a) s. _// impact performance. The correct value for this parameter is machine dependent, so it's advised to
, e0 j; g; n; M// set this only as high as needed. Approximate successful values can widely range from 50 to 200 or more.( K, u5 t3 K4 Z' _* }" Z( [
// NOTE: Changing this value also changes the execution time of a segment in the step segment buffer. 8 w" p+ @! T& I
// When increasing this value, this stores less overall time in the segment buffer and vice versa. Make
& r# x4 M- I! s' `" M5 o// certain the step segment buffer is increased/decreased to account for these changes.) H9 ^% T/ }5 C  K+ S% p
//加速度的时间分辨率管理子系统。更多更平稳& T- m6 e+ h6 ]) ?8 F: H
//加速度,特别明显的机器上,运行在非常高的进料速度,但可能负面- e" l1 O4 j7 d/ K: D, f' N3 f" k
//影响性能。正确的值为这个参数是依赖于机器的,所以建议
7 ]0 i! @, A% Z, p& c1 L( J//这只设置为高。近似成功的价值观可以广泛的范围从50到200或者更多。
3 i% V5 |1 [: f2 ]6 h//注意:改变这个值也变化的部分步骤的执行时间缓冲。
- |* D5 ]* K& O2 k/ d7 d, b) ^//增加这个值时,这个商店部分缓冲区的总时间减少,反之亦然。使
0 f+ B& Z: d9 \  n) }3 v) x4 t//特定步骤段缓冲是考虑这些变化增加/减少。7 B4 J9 ^: ~, T$ b9 z' d# A6 }+ G' o
$ j7 |: \0 `; h" S! E
#define ACCELERATION_TICKS_PER_SECOND 100  //加速度的时间分辨率管理子系统。更多更平稳; w0 H; F- L) b& {' K

& D3 z$ h) [! _- I// Adaptive Multi-Axis Step Smoothing (AMASS) is an advanced feature that does what its name implies, 1 W1 g8 X3 x4 `. [9 M6 m1 r
// smoothing the stepping of multi-axis motions. This feature smooths motion particularly at low step8 r1 {2 [. x& P9 [4 P* ]$ v
// frequencies below 10kHz, where the aliasing between axes of multi-axis motions can cause audible
1 N$ [3 O% Z) C- ~7 I// noise and shake your machine. At even lower step frequencies, AMASS adapts and provides even better
9 Q! k) q& [0 i, P( a// step smoothing. See stepper.c for more details on the AMASS system works.+ A7 @; G) H, v7 Q; {# b# E
//自适应多轴步平滑(积累)是一种先进的功能,它的名字所暗示的那样,
" T9 \& D2 ]2 ]+ L' J( p& g//平滑的多轴步进运动。这个特性平滑运动尤其是在低一步
* s* C6 ~1 H& a. ]% B//频率低于10 khz,轴之间的混叠的多轴运动可能导致音响( ?8 a/ S/ r$ E
//噪音和震动你的机器。在更低的频率步,积累适应并提供更好" l4 J* u! X% {0 ]8 |* C3 e% W6 \
//步骤平滑。看到步进。c更多细节的积累系统的工作原理。4 M3 q8 W$ z) A# c+ Y# z8 Y4 o
+ l6 [# i/ X$ r3 i0 i9 u
#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING  // Default enabled. Comment to disable.//自适应多轴步平滑) g4 m* r; m0 \! m7 y+ l' u
) X% A9 b5 R6 x& f" W" }1 S1 K. r
// Sets the maximum step rate allowed to be written as a Grbl setting. This option enables an error
/ P+ }  l( H1 u0 t7 w// check in the settings module to prevent settings values that will exceed this limitation. The maximum3 r- Y4 k' _, I! T- v$ A
// step rate is strictly limited by the CPU speed and will change if something other than an AVR running
  S" `; J7 S0 w6 a// at 16MHz is used., q: ?3 W7 r6 N$ S+ W1 O; u" ]
// NOTE: For now disabled, will enable if flash space permits.0 z  Q/ q6 @( M1 y  q& Q. ]
//设置最大一步速率可以写成Grbl设置。这个选项可以使一个错误
  V7 M, v$ W) ^1 B( E//设置模块中检查,防止设置值将超过这个限制。的最大7 P. `( P! A) j" H4 r
//步骤严格限制的CPU速度也会改变如果是其他AVR运行
) A1 v8 d/ B- ?8 l; V0 D5 |//使用16兆赫。
+ h# t' t6 N  o, B6 N' |//注意:现在残疾,将使如果flash空间许可。9 b9 a  E$ d) U+ ^, q

7 O3 a5 p4 x6 m1 p* j* o// #define MAX_STEP_RATE_HZ 30000 // Hz 设置最大一步速率
: n" Z# A) {4 E% Y
7 N9 G3 l  [' \: F% H/ n! N// By default, Grbl sets all input pins to normal-high operation with their internal pull-up resistors  E7 L* M' ^, G2 Y6 q+ V
// enabled. This simplifies the wiring for users by requiring only a switch connected to ground, + l0 |  j/ e4 R
// although its recommended that users take the extra step of wiring in low-pass filter to reduce
3 ~' _" Y1 n, a+ P0 O5 V// electrical noise detected by the pin. If the user inverts the pin in Grbl settings, this just flips
7 \7 e' Z/ a) E& |$ i9 l7 p# K// which high or low reading indicates an active signal. In normal operation, this means the user 3 ~8 E. x8 M3 i5 n  @% H! N
// needs to connect a normal-open switch, but if inverted, this means the user should connect a
( o0 h, r6 f4 ]) Q/ g// normal-closed switch. 3 n) I. `$ q/ P; m
// The following options disable the internal pull-up resistors, sets the pins to a normal-low
' s$ v8 J& c: H6 F3 G3 Z// operation, and switches must be now connect to Vcc instead of ground. This also flips the meaning 2 [2 r- s2 O* j+ S  M1 e$ I0 d
// of the invert pin Grbl setting, where an inverted setting now means the user should connect a
9 Q& ?8 W; W$ K- G1 V// normal-open switch and vice versa.7 B' q  M2 T$ k1 b/ B
// NOTE: All pins associated with the feature are disabled, i.e. XYZ limit pins, not individual axes.
# g1 E8 _' d; I6 `4 _+ ]& G// WARNING: When the pull-ups are disabled, this requires additional wiring with pull-down resistors!
, y' ^3 m2 u$ C! }9 ]//默认情况下,Grbl所有输入引脚设置为正常高操作的内部上拉电阻- p2 N( g" C- n2 F
//启用。这简化了布线为用户只需要一个开关连接到地面,0 s0 w$ v# _8 U; {6 k: U# L- O
//虽然其建议用户采取额外的步骤,在低通滤波器来减少布线  V: N: M! W8 S" `
//电噪音检测销。如果用户反转的销Grbl设置,这只是翻转
( b" }* |: C4 W1 _: l//读高或低表明一个积极的信号。在正常操作中,这意味着用户$ \$ b, c% \7 U2 D6 e! D' \
//需要连接一个常开开关,但如果倒,这意味着用户应该连接
  @! S  _2 e) [$ A- v: K// normal-closed开关。
1 X0 m* l: g9 a, ?2 M6 E9 F6 M4 E7 q//以下选项禁用内部上拉电阻,一般低设置别针9 c. p3 v; K8 m
//操作,现在开关必须连接到Vcc代替地面。这也掀的意思9 T( k  d4 A+ S' Y- E
//反销Grbl设置,一个倒置的设置现在意味着用户应该连接/ i9 g9 \0 z5 {; |2 B
//常开开关,反之亦然。
% R& z3 {) f6 @- R" Q//注意:所有针与功能被禁用,例如XYZ限制针,而不是单独的轴。5 V0 G( q6 w" T. E
//警告:引体向上被禁用时,这需要额外的布线与下拉电阻!
2 ]+ W$ O( S: p9 A+ |* w
# l6 B% A2 n/ E# I4 E//#define DISABLE_LIMIT_PIN_PULL_UP //以下选项禁用内部上拉电阻
7 u2 E0 i- X/ V# I//#define DISABLE_PROBE_PIN_PULL_UP
, m( V: B2 Y, b0 c! r; Q//#define DISABLE_CONTROL_PIN_PULL_UP# J+ M, ~6 s0 J( J
+ I& t/ {" M% C" W: Y
// Sets which axis the tool length offset is applied. Assumes the spindle is always parallel with
6 }- g6 P. \  k5 o) ?& d// the selected axis with the tool oriented toward the negative direction. In other words, a positive2 X" J/ L# n$ d& H& ]1 b1 g! `' o
// tool length offset value is subtracted from the current location.
) a, O& V3 u6 N$ k% h//设置哪个轴长度补偿应用的工具。假设轴总是与8 `/ S; h) o: F& a3 b, W$ i
//选择轴工具面向负方向。换句话说,一个积极的; M0 n) g: [+ c$ R' z/ l" {8 r
//工具长度偏移值减去从当前位置。
+ j3 W" R8 i! M3 z! \
4 Y( R5 C$ z) ^& e#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS // Default z-axis. Valid values are X_AXIS, Y_AXIS, or Z_AXIS.设置哪个轴长度补偿应用的工具) H/ B4 c; _# ~$ A; w2 L% P

4 M5 |: L% x! Z// Enables variable spindle output voltage for different RPM values. On the Arduino Uno, the spindle
/ S0 d3 Y- Y9 R4 P0 |, n// enable pin will output 5V for maximum RPM with 256 intermediate levels and 0V when disabled.1 n' `* l+ j( s6 q( k
// NOTE: IMPORTANT for Arduino Unos! When enabled, the Z-limit pin D11 and spindle enable pin D12 switch!
) Z0 ?  O# C- @/ U7 o// The hardware PWM output on pin D11 is required for variable spindle output voltages.& \  L. s8 b% Y# |
//允许变量轴输出电压不同的转速值。Arduino Uno,主轴5 z" S2 o; ]) i5 ?
//启用销将输出5 v的最高转速256中级水平和0 v时禁用。+ l0 r+ Z, d, ^/ t* r/ t: u
//注意:重要Arduino凯泽本人!当启用时,Z-limit销这里和轴销D12开关!
$ T' @1 B0 S% E$ G6 }6 u& u, W//硬件PWM输出销这里需要变量轴输出电压。: ~$ S/ C# y* ^
0 M' q& U6 y9 d7 l5 R
#define VARIABLE_SPINDLE // Default enabled. Comment to disable.//允许主轴输出电压不同的转速值
& x' g; U: l- J4 {0 J, }/ F/ t8 D4 a1 |3 E. @9 ~
// Used by the variable spindle output only. These parameters set the maximum and minimum spindle speed
1 W, m. a8 U4 c- C// "S" g-code values to correspond to the maximum and minimum pin voltages. There are 256 discrete and ( s0 u% e' V+ R; m; V
// equally divided voltage bins between the maximum and minimum spindle speeds. So for a 5V pin, 1000
2 x, N) I+ d3 P7 \1 n$ Q// max rpm, and 250 min rpm, the spindle output voltage would be set for the following "S" commands: 2 |) Q' b5 q, Z, [+ Z6 [$ |2 C
// "S1000" @ 5V, "S250" @ 0.02V, and "S625" @ 2.5V (mid-range). The pin outputs 0V when disabled.
7 `' Q5 `0 Z! C//使用的变量轴输出。这些参数设置最大和最小轴转速
" G2 J5 D# E, a. e1 L3 [8 ?//“S”刀位点值对应于销电压的最大值和最小值。有256个离散和! K# B& w) o- ^! k8 T9 I4 F5 |
//电压平均分配箱主轴速度的最大值和最小值之间。所以对于一个5 v销,1000
# E' C8 w& w* q' q. }. s& K" _// max rpm,250分钟rpm,主轴输出电压将为以下“S”命令:
9 r, g# g  |  N+ ?! b3 g// @“S1000 5 v,“S250”@ 0.02 v,“S625”@ 2.5 v(中档)。销输出0 v时禁用。7 }1 J5 B( M4 O% e
1 g! }* h$ ]. }% ?& c
#define SPINDLE_MAX_RPM 1000.0 // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.
! B* X/ N" L- r2 e#define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.9 [- c  A" {& g2 `& J
0 @% ]; f" ^% E9 h: H9 q
// Used by variable spindle output only. This forces the PWM output to a minimum duty cycle when enabled.
( {! u& X$ q+ s// When disabled, the PWM pin will still read 0V. Most users will not need this option, but it may be + f3 D3 g. J7 a
// useful in certain scenarios. This setting does not update the minimum spindle RPM calculations. Any
* ]) D! m' T  v, L7 q// spindle RPM output lower than this value will be set to this value.
4 z8 P7 T2 r( g3 N, A" ?2 Y, R//使用的变量轴输出。这迫使PWM输出最小占空比时启用。1 @% f+ W# R) j8 C" x
//当禁用,PWM销仍读0 v。大多数用户不需要这个选项,但是它可能是
1 o2 `2 [% _. O0 u' h, K//在某些情况下很有用。这个设置不会更新最小主轴转速计算。任何
' p2 M8 d% L/ ^: {: D; ~2 i//输出轴转速低于这个值将被设置为这个值。
* m! @3 M7 i4 e1 o, U
4 L: |) _- {. n4 R4 ~. {  J// #define MINIMUM_SPINDLE_PWM 5 // Default disabled. Uncomment to enable. Integer (0-255): @% N9 L) I) v
7 o; Q7 I( n) ~
// By default on a 328p(Uno), Grbl combines the variable spindle PWM and the enable into one pin to help ! f8 ~# l% o: X4 c+ J! {
// preserve I/O pins. For certain setups, these may need to be separate pins. This configure option uses
2 ]: L" u* C" d5 W3 {9 b* S// the spindle direction pin(D13) as a separate spindle enable pin along with spindle speed PWM on pin D11. $ W% j- X& I+ g2 j4 y8 F
// NOTE: This configure option only works with VARIABLE_SPINDLE enabled and a 328p processor (Uno).
( ]  I7 Z; d8 y6 Y// NOTE: With no direction pin, the spindle clockwise M4 g-code command will be removed. M3 and M5 still work.
( G# o4 i+ N  x2 [  q; t// NOTE: BEWARE! The Arduino bootloader toggles the D13 pin when it powers up. If you flash Grbl with: U$ F, r: ]. M$ M) |8 Z) B0 K
// a programmer (you can use a spare Arduino as "Arduino as ISP". Search the web on how to wire this.), 0 E) N7 C0 s5 C
// this D13 LED toggling should go away. We haven't tested this though. Please report how it goes!
0 J5 [; k1 q9 Y//默认ATmega328 p(Uno),Grbl结合变量轴PWM和使到一个销的帮助4 F* V6 @( ?) \0 M  |6 Z! K! s
//保存I / O管脚。对于某些设置,这些可能需要单独的别针。这个配置选项使用8 z' J7 d$ m' X" X
//方向轴销(D13)作为一个单独的轴销上启用销以及主轴转速PWM这里。
" r# A/ X  v: t6 j  g//注意:该配置选项仅适用于VARIABLE_SPINDLE启用和328 p处理器(Uno)。7 G" M, c. X2 y, t6 B
//注意:没有方向销,主轴顺时针M4刀位点命令将被删除。M3和M5仍然工作。
. g3 n7 L0 G) r& N//注意:小心!Arduino引导装载程序切换D13销的权力。如果flash Grbl
3 ~$ n9 }, y6 @//程序员(您可以使用一个备用Arduino“Arduino ISP”。搜索网络如何线),+ e7 b* _. i- O9 _: P- J
//这D13导致切换应该消失。我们还没有测试这个。请报告将会怎样!1 I7 ?4 n& D$ L+ s7 X0 V# h

, w1 J8 t1 F/ ]/ g5 w8 s5 W5 @; c. O// #define USE_SPINDLE_DIR_AS_ENABLE_PIN // Default disabled. Uncomment to enable.. [6 R# U, _& j5 l- H7 B! Q: D

& W( S& I" A0 [7 C3 n0 R// With this enabled, Grbl sends back an echo of the line it has received, which has been pre-parsed (spaces
$ I6 @! C' k2 C. [( J9 d$ s8 W0 V// removed, capitalized letters, no comments) and is to be immediately executed by Grbl. Echoes will not be
& G) J& b8 w; t: C- m9 @' `/ ]// sent upon a line buffer overflow, but should for all normal lines sent to Grbl. For example, if a user
7 Z/ j1 s; X2 D; S) p+ f// sendss the line 'g1 x1.032 y2.45 (test comment)', Grbl will echo back in the form '[echo: G1X1.032Y2.45]'./ A9 q- |3 \% u4 N% x) j) `0 c
// NOTE: Only use this for debugging purposes!! When echoing, this takes up valuable resources and can effect
( W+ e- a  I: v// performance. If absolutely needed for normal operation, the serial write buffer should be greatly increased: x5 s0 e! `" }# B+ R
// to help minimize transmission waiting within the serial write protocol.
% _4 j8 C+ E& W# m$ O- E/ J# {0 d( e2 B# z+ M
//启用,Grbl发回的回声线已收到,已预编译(空间8 E. {) o2 j3 q. g# ?  p( Q
//移除,大写字母,没有评论),由Grbl立即执行。回声将不会
9 ^; L6 i" s. k9 q! e( l' y! `5 h//发送一个线缓冲区溢位,但应该对所有正常线路送到Grbl。例如,如果一个用户+ J0 t5 e' A$ |, [
//发送线的g1 x1.032 y2.45(测试评论)形式”,Grbl将回声”(回声:G1X1.032Y2.45]”。# ]1 u& P7 n4 E6 i5 Z: E) x1 y0 S
//注意:只使用这个调试! !当呼应,这占用了宝贵的资源,可以影响6 K; w! ]6 r9 z# X8 Z% y
//性能。如果正常运行所需的绝对,串行写入缓冲器应该大大增加, s, p" A6 a( S1 c1 a* H
//帮助最小化传输等系列内写协议。
/ H, |: y# `. R3 |: E7 X. |( S
$ I6 W# v; l1 c: k" N9 v. H// #define REPORT_ECHO_LINE_RECEIVED // Default disabled. Uncomment to enable.1 ~7 e( T% L  p- v; m
; B: ]+ ?6 j' }
// Minimum planner junction speed. Sets the default minimum junction speed the planner plans to at
  R4 Y1 g+ |9 s! V8 J6 g5 N  K// every buffer block junction, except for starting from rest and end of the buffer, which are always
) m8 I) X) h7 \; C5 A4 i# k// zero. This value controls how fast the machine moves through junctions with no regard for acceleration
/ K3 z1 @1 y- m* x5 h; v' m# b// limits or angle between neighboring block line move directions. This is useful for machines that can't
* {, G% e- D9 O% W// tolerate the tool dwelling for a split second, i.e. 3d printers or laser cutters. If used, this value/ x! W' X7 r9 ~+ X, }9 C
// should not be much greater than zero or to the minimum value necessary for the machine to work.0 R" v3 a! c& \. o
: h  Q" V5 t! U9 z
//最小规划师结速度。设置默认最小连接速度规划计划
# ?) @; ~# K7 e1 e6 t' R//每一个缓冲块接头,除了从结束休息和缓冲区,它总是# `; g7 a( W" Q: b  u6 ?& R
// 0。这个值控制机器的速度穿过路口,没有考虑加速度
( o. q% x/ {& J- v- h//限制或相邻块之间的角线方向移动。这是有用的机器,不能
1 }' R8 P8 x6 ]4 z0 M5 N& I//容忍工具居住某一刹那,即3 d打印机或激光切割机。如果使用这个值5 d3 k" _$ l8 U- o! |4 Z
//不应大于零或机器工作所需的最小值。
" _' v5 e- w3 z% P7 `$ r! ^8 ~* J/ d, E) Z2 S
#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min), j7 ?5 s, F  d; q+ V
: u  b9 S5 X/ X: @' w3 i$ ~7 v) S3 ^
// Sets the minimum feed rate the planner will allow. Any value below it will be set to this minimum
* w3 D7 n. s0 i2 N+ a0 p" v; G// value. This also ensures that a planned motion always completes and accounts for any floating-point" d! Z$ |4 L" ]! s8 p! z- Y
// round-off errors. Although not recommended, a lower value than 1.0 mm/min will likely work in smaller
. e" I& }5 y( C! h$ E" L// machines, perhaps to 0.1mm/min, but your success may vary based on multiple factors.
0 n6 ?" W/ r1 u% a* \//设置计划将允许的最小进给速率。任何价值低于它将被设置为最低值。这也保证了运动计划总是完成,占任何浮点
+ T: m/ U) t5 `& U: z//舍入错误。虽然不推荐,价值低于1.0毫米/分钟可能会在较小的工作
* D4 s$ m. ~1 i//机器,也许到0.1毫米/分钟,但你的成功基于多种因素可能会有所不同。
: M* X; p& _, k% K# z& Z
% a1 L8 h3 l& N( N#define MINIMUM_FEED_RATE 1.0 // (mm/min)//设置计划将允许的最小进给速率
  ?+ |1 @2 I$ l( H" g+ E; H6 \8 o) G: b9 D+ G- A' F
// Number of arc generation iterations by small angle approximation before exact arc trajectory
! X) |* S7 Y5 n5 A9 T7 ?// correction with expensive sin() and cos() calcualtions. This parameter maybe decreased if there 7 o. s$ \3 |: A# O, G
// are issues with the accuracy of the arc generations, or increased if arc execution is getting( s" H" W/ O! }/ W. a4 g8 M
// bogged down by too many trig calculations. 5 I. J9 i) M, u! a/ K0 Q6 \# y
//弧生成迭代次数之前小角度近似精确的弧线轨迹4 M. q/ |- P! Q: Z
//修正与昂贵的sin()和cos()calcualtions。如果有这个参数可能减少" x, `2 q9 w8 B4 N0 p+ g/ ^
//与弧一代又一代的准确性问题,或如果电弧执行得到增加
- y6 }& [* F. S1 N//太多的三角计算的泥潭。
9 l  X% _( k. f9 Z# ]/ \! S1 y. Y0 R# q
#define N_ARC_CORRECTION 12 // Integer (1-255)8 O# f4 T  `7 P' z/ @7 _

' b$ N5 L# v, W) t! k// The arc G2/3 g-code standard is problematic by definition. Radius-based arcs have horrible numerical - ~! U5 L, D+ C) |4 N9 l, A- k
// errors when arc at semi-circles(pi) or full-circles(2*pi). Offset-based arcs are much more accurate
8 b( }* V- q8 C! ^- V+ G8 v, U// but still have a problem when arcs are full-circles (2*pi). This define accounts for the floating ( v$ B! `0 Q. r  ]
// point issues when offset-based arcs are commanded as full circles, but get interpreted as extremely
% |3 _" H5 j0 u// small arcs with around machine epsilon (1.2e-7rad) due to numerical round-off and precision issues., R. K% h. R3 a3 w+ X2 f, O5 \3 o
// This define value sets the machine epsilon cutoff to determine if the arc is a full-circle or not.
6 K9 c) p" t9 c// NOTE: Be very careful when adjusting this value. It should always be greater than 1.2e-7 but not too
6 T+ H0 [+ M5 O  V// much greater than this. The default setting should capture most, if not all, full arc error situations.5 P" \0 L5 o! L3 n2 J% T
//弧G2/3刀位点的标准定义是有问题的。Radius-based弧有可怕的数值/ c6 a% p! O% j. Z7 x8 c
//错误当电弧在半圆(π)或原点(2 *π)。Offset-based弧更准确$ D6 I% q* I  u/ C
//但仍有一个问题当弧原点(2 *π)。这个定义占浮动
  s, E6 U8 e6 w6 D//当offset-based弧吩咐点问题完整的圆,但解释为极# v! K+ H% y. ^4 I" `& n3 K
//小弧机周围ε(1.2 e-7rad)由于数字舍入和精度问题。; v' c9 g3 @- w: U1 K, w: K# h
//定义值设置机器ε截止来确定电弧是一个原点了。
: F( ~( }7 K$ g! M: m5 T; G6 a//注意:调整这个值时非常小心。它应该总是大于1.2 e -但不要太
7 J$ B" W% ?- V- W2 t# o//比这大得多。默认设置应该捕获大部分,如果不是全部,全部错误的情况。
% A% X# d/ O2 {, x5 u1 L4 ?. `: \/ Y$ x$ U: U! G
#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)
( W/ e9 ^1 ^- _2 S% B* @7 Q7 G& S; s
0 m& ^5 c4 y0 ~// Time delay increments performed during a dwell. The default value is set at 50ms, which provides8 e' L/ G; g' Q- O
// a maximum time delay of roughly 55 minutes, more than enough for most any application. Increasing( R+ N$ i6 K4 p+ g) z' f0 X, {
// this delay will increase the maximum dwell time linearly, but also reduces the responsiveness of
$ h) Y0 j& J( E' y. }' u& T5 r// run-time command executions, like status reports, since these are performed between each dwell 1 w/ {8 ^) b3 N, W4 V& c  r
// time step. Also, keep in mind that the Arduino delay timer is not very accurate for long delays.
8 H& Y# D. v9 }% \- c//延时增加表现在住。默认值设置为50毫秒,它提供了4 g6 ~1 q2 S# J0 M' W# A
//最大延时约55分钟,足够对大多数任何应用程序。增加/ L. p; y7 e/ X8 X% Y
//这种延迟将增加线性最大停留时间,也减少了响应能力+ W3 O6 E. m7 K- [  x+ @8 D) U& l
//运行命令执行状态报告一样,因为这些每个住之间执行3 k+ p# D- |' D
//时间步。还有,记住,Arduino延迟计时器不是很准确的长时间延误。
6 M6 E1 y4 N% z% d. W/ S4 e1 [& d9 |0 n  }9 D
#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds)
1 N" u$ C3 X& Q. Z( w! l
* ]5 H: r4 v' S0 w) [9 M+ c// Creates a delay between the direction pin setting and corresponding step pulse by creating4 Y/ F" w0 M! v. E
// another interrupt (Timer2 compare) to manage it. The main Grbl interrupt (Timer1 compare)
; N: u/ X! [3 p4 W# e1 M) R6 _5 j6 T// sets the direction pins, and does not immediately set the stepper pins, as it would in 4 v8 U& o. L6 I
// normal operation. The Timer2 compare fires next to set the stepper pins after the step
$ c/ D& X- I$ |// pulse delay time, and Timer2 overflow will complete the step pulse, except now delayed
) g2 ]5 V4 c. [( V// by the step pulse time plus the step pulse delay. (Thanks langwadt for the idea!)
* x9 o! a3 z% Z# c, x) g// NOTE: Uncomment to enable. The recommended delay must be > 3us, and, when added with the9 k0 v& o+ e$ a& E9 I
// user-supplied step pulse time, the total time must not exceed 127us. Reported successful3 k1 S/ o* ?5 K! M) z0 `& I
// values for certain setups have ranged from 5 to 20us.
+ Q9 N4 w. t7 k& J//创建一个方向销之间的延迟脉冲通过创建设置和相应的步骤8 J# @7 I5 T# o+ Z2 o4 ]
//另一个中断(Timer2比较)来管理它。主要Grbl中断(Timer1比较)
$ B2 y0 }# @$ P- E$ w//设置方向针,不立即设置步进针,因为它会在
; Q; R( l- c8 t* L2 p/ L//正常操作。Timer2比较火旁边设置步进针后一步9 s. b, [* u6 y6 \# ]0 w
//脉冲延迟时间,Timer2溢出脉冲将完成的步骤,现在延迟除外& \- O6 ]# o. V* c, c+ d; T, r
//脉冲时间加上的一步一步脉冲延迟。(感谢langwadt主意!)
3 f: v5 {+ g  q  l1 x//注意:取消启用。必须> 3,建议延迟,当添加的, m9 {- E1 _7 J' _# o: q2 w
//用户提供的步骤脉冲时间,总时间不得超过127美元。成功的报道5 o: ?2 _& |6 D8 }; y+ @
//值对某些设置范围从5到20。# x4 R+ @& w+ m4 K9 V7 q. i
1 c# A0 z+ t: b6 m2 G- X
// #define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.
- G' K% G( ~) |( K& A. |6 z! g6 e+ n# t0 D; I3 O* N
// The number of linear motions in the planner buffer to be planned at any give time. The vast
& X1 j1 [* H6 x! J$ r// majority of RAM that Grbl uses is based on this buffer size. Only increase if there is extra
; J6 h1 H4 F0 ~8 J1 S% r// available RAM, like when re-compiling for a Mega or Sanguino. Or decrease if the Arduino
, Y0 B, k- H) H: b" C// begins to crash due to the lack of available RAM or if the CPU is having trouble keeping; P0 h& U$ a0 \+ s( m( x8 T# u
// up with planning new incoming motions as they are executed. ) z* U- [0 i3 C; c8 {/ V/ R
//线性运动规划师缓冲区的数量在任何给出时间计划。绝大
, z- d- M0 C0 b0 }. K//多数RAM Grbl使用基于这个缓冲区的大小。如果有额外的只会增加4 B" C$ m" g6 |% L& K3 Y0 {2 F
//可用内存,比如当基于大型或Sanguino。如果Arduino或减少
: R$ f, J# ^5 |) M. ~  b//开始崩溃由于缺乏可用的RAM或者CPU是难以保持2 m# \7 y: \+ F2 U6 y! ?. C, k
//与规划新传入的动作执行。
0 n- x6 n4 R0 z. h2 j5 J2 X' C
6 A' v! x$ A4 @  ?& f// #define BLOCK_BUFFER_SIZE 18  // Uncomment to override default in planner.h.
' r0 t/ d' a# c1 v1 }* W) B* {* j4 C, W7 U; y' g$ ?
// Governs the size of the intermediary step segment buffer between the step execution algorithm& r7 f1 y" `; v9 L3 \- L7 o
// and the planner blocks. Each segment is set of steps executed at a constant velocity over a
( B* y0 c! T/ q) @/ M// fixed time defined by ACCELERATION_TICKS_PER_SECOND. They are computed such that the planner
7 ~) [, ?3 o$ C) h9 ^// block velocity profile is traced exactly. The size of this buffer governs how much step
$ Y% y, s! o/ r* d( J// execution lead time there is for other Grbl processes have to compute and do their thing
3 L! g- M2 y- l( q. Q0 s// before having to come back and refill this buffer, currently at ~50msec of step moves.
2 p# u; c8 [, Y- S" r//控制之间的中间段缓冲大小的步骤执行算法, o6 z3 d' W, `6 W- E, W
//和规划师块。每一部分的步骤执行在一个恒定的速度
0 ?3 ?* E1 y. k0 v//固定的时间由ACCELERATION_TICKS_PER_SECOND定义的。他们计算的计划
- F2 U, N* e7 \" U/ q7 l8 m/ F/ x//块速度剖面追踪到底。这个缓冲区的大小控制多少步骤  K8 `- ~  K/ p
//执行时间有其他Grbl过程需要计算和做他们的事情3 Q. h: E' y$ M
//之前必须回来重新填充这个缓冲区,目前移动~ 50毫秒的一步。; z1 J3 A2 w# b% ~0 P0 Y

- _. c( i7 _. g1 m3 h// #define SEGMENT_BUFFER_SIZE 6 // Uncomment to override default in stepper.h.5 Z2 k$ {- |5 u6 F3 \/ @7 I
0 [0 C! y( B" v0 n9 I
// Line buffer size from the serial input stream to be executed. Also, governs the size of ; d: a/ c  W2 E. o# q
// each of the startup blocks, as they are each stored as a string of this size. Make sure
' Y  s. R. F" g% R" H// to account for the available EEPROM at the defined memory address in settings.h and for
. [9 {& ^, y% Q! q// the number of desired startup blocks.
) J& B' Q* A6 |6 C" h4 N) t// NOTE: 80 characters is not a problem except for extreme cases, but the line buffer size
( n/ b* [5 x, S4 J& I$ V  {// can be too small and g-code blocks can get truncated. Officially, the g-code standards 6 P, K. T9 ~2 `9 v. {: q
// support up to 256 characters. In future versions, this default will be increased, when
$ z) X# e) U+ W0 c+ V// we know how much extra memory space we can re-invest into this.
; V. A8 t7 \6 V% e: U- a//行执行串行输入流的缓冲区大小。同时,大小的控制
" S/ c1 W0 [) Z6 o//每个启动模块,它们分别存储为字符串的大小。确保5 M* I! c" a# m  i
//占可用eepm定义内存地址的设置。h和
( Y9 ^" @/ b) O: Y+ L//需要启动块的数量。) H: R6 f! B8 _; W/ e8 \
//注意:80个字符不是一个问题,除了极端的情况下,但线缓冲区大小) Y. Q% S. R5 d, P  v0 E9 ^# Q1 R" z
//可以太小和刀位点块可以截断。正式,刀位点标准
8 P( i1 Q0 n7 G* y- j' O( t//支持多达256个字符。在未来的版本中,这个违约将会增加,当
; y7 C0 x7 A" U8 G3 H7 u//我们知道多少额外内存空间的时候我们可以再投资。
, r. R5 Z9 s( T
7 b7 Y3 z3 J1 ^4 C6 @8 V9 C3 o// #define LINE_BUFFER_SIZE 80  // Uncomment to override default in protocol.h
6 @8 T% k7 ?" M" _7 E6 ~& P" l  / V( x" y* y% g- }- v: E  d
// Serial send and receive buffer size. The receive buffer is often used as another streaming4 g3 ~, Z8 F& X+ p- |+ r1 S" |4 u
// buffer to store incoming blocks to be processed by Grbl when its ready. Most streaming* r1 I+ s: M' @# ~! n% M3 Z, k1 Y# i
// interfaces will character count and track each block send to each block response. So, 8 K) y  H8 U" ^- G& E# e
// increase the receive buffer if a deeper receive buffer is needed for streaming and avaiable
& h* s# [3 o. d& m3 A2 z0 [// memory allows. The send buffer primarily handles messages in Grbl. Only increase if large
9 f1 m8 _2 @9 Z! ^7 }// messages are sent and Grbl begins to stall, waiting to send the rest of the message.
& i& Z( B, g# _) m" ^// NOTE: Buffer size values must be greater than zero and less than 256.
* }' G3 |* ^1 [+ Y% z' m' V// #define RX_BUFFER_SIZE 128 // Uncomment to override defaults in serial.h
# q$ h- k( z9 J& k//串行发送和接收缓冲区大小。接收缓冲区通常用作另一个流
5 h2 Q9 p5 Z( D//缓冲存储传入的块来处理Grbl当它准备好了。最流7 g' Z+ }9 p. T! {6 B# d6 h
//接口将字符计数和跟踪每一块发送给每个块的回应。所以,! u# p0 Q! I0 U+ [' [
//增加接收缓冲区如果需要更深层次的接收缓冲区为流,、& J! f4 ]& I1 I
//内存允许。Grbl发送缓冲主要处理消息。只会增加如果大" @6 N) v, n1 b7 B/ p& ~6 A- n, a
//消息发送和Grbl开始停滞,等待发送其余的消息。$ ]% E# ~- }% M) |, W$ Z5 F# c4 v
//注意:缓冲区大小值必须大于零,小于256。( _" r# r7 j' o, M# w8 }1 p+ e  i
// # define RX_BUFFER_SIZE 128 / /取消serial.h覆盖默认值9 t% r7 E7 w: f4 G$ d1 ~
; C6 T( H6 x6 Y6 W; ~$ X2 H
, {6 i9 T$ J. e4 d8 ~1 K; h# R
// #define TX_BUFFER_SIZE 64
* W  b; C1 T) @2 Z  q( R( t. F  
* w. k" J! H( p7 q3 n/ k! W// Toggles XON/XOFF software flow control for serial communications. Not officially supported
0 n" y6 `9 m( l. ]# S7 U// due to problems involving the Atmega8U2 USB-to-serial chips on current Arduinos. The firmware
. @( Z) B; s5 q( C# ~// on these chips do not support XON/XOFF flow control characters and the intermediate buffer $ b) o8 J% ~! q. ?- }9 p
// in the chips cause latency and overflow problems with standard terminal programs. However, " z8 L, Q* v3 F0 Q$ m2 z4 ~  `
// using specifically-programmed UI's to manage this latency problem has been confirmed to work.4 b6 z8 W; H1 ^# x& O$ Q
// As well as, older FTDI FT232RL-based Arduinos(Duemilanove) are known to work with standard0 x0 E# U! S2 U7 S! f3 w/ c2 L( P
// terminal programs since their firmware correctly manage these XON/XOFF characters. In any# c% n3 _  t/ s1 w/ ~, j) S
// case, please report any successes to grbl administrators!% E8 o" i6 U0 A" [! p
//切换为串行通信发送朴通/发送葡开软件流控制。不是官方支持
! V$ s5 e  u1 @) q' ]5 s//由于问题涉及Atmega8U2 USB-to-serial当前arduino芯片。固件
& ^2 k% F+ H) g5 U7 h//在这些芯片不支持发送朴通/发送葡开流控制字符和中间缓冲区# ?+ `2 X, |2 K, V5 e
//芯片导致延迟和溢出问题的标准终端程序。然而,
3 n3 ~6 N  e" f* _1 J2 }- G* c: I//使用specifically-programmed UI的管理这个延迟问题已经确认工作。" S2 c+ {: C: t
//以及老FTDI FT232RL-based arduino(Duemilanove)是已知的标准
; P  U+ g# }/ n( o//终端程序因为他们正确的固件管理这些发送朴通/发送葡开的角色。在任何
$ g+ T8 B& [$ J7 W//情况,请报告任何成功grbl管理员!) A6 ]7 [/ ~, g$ P* B8 `" V
9 G+ [6 d. c. }
// #define ENABLE_XONXOFF // Default disabled. Uncomment to enable.
5 ]& `. \- k5 z+ D- m+ {0 |& J/ f: g$ Q% {, o5 |2 O, D
// A simple software debouncing feature for hard limit switches. When enabled, the interrupt ! ?/ q7 C# _9 a9 P: Y& k# i3 U
// monitoring the hard limit switch pins will enable the Arduino's watchdog timer to re-check ( i7 |! w" e( k4 p, @5 u! Y, P
// the limit pin state after a delay of about 32msec. This can help with CNC machines with , ?+ m6 I: ~3 o1 u% J
// problematic false triggering of their hard limit switches, but it WILL NOT fix issues with
4 L, P! p9 e+ C8 x! o// electrical interference on the signal cables from external sources. It's recommended to first
4 t  c1 G! x8 c$ b// use shielded signal cables with their shielding connected to ground (old USB/computer cables 3 E/ ]+ A. V# C, }4 u1 i
// work well and are cheap to find) and wire in a low-pass circuit into each limit pin.
* M9 K) J8 V3 [0 u% n//一个简单的软件消除抖动特性硬限位开关。当启用时,中断) c/ t- W: P  X9 A/ H3 Z
//监控硬限位开关针将使Arduino的看门狗定时器重新审视
* H% Z/ u1 E9 a9 I//销的极限状态后约32毫秒的延迟。这可以帮助与数控机器
: O# C. F; u* `, B& O$ P0 T8 ?//问题错误引发的硬限位开关,但是它不会解决问题5 ?( _* H- N3 ?- C+ m
//电干扰信号电缆从外部来源。首先它的建议9 |0 d3 z6 G# D% u- j' w
//使用屏蔽信号电缆的屏蔽连接到地面(老USB /计算机电缆
+ V2 k6 R8 f* s, ]//工作得很好,很便宜)和线低通电路到每个限位销。& w! M+ {1 v' k  Z1 T5 L

1 Q# a+ l% W1 @* g// #define ENABLE_SOFTWARE_DEBOUNCE // Default disabled. Uncomment to enable.
4 }4 p. C6 O, Z; C- r! R5 T$ V: L& g5 L/ t; Z# I
// Force Grbl to check the state of the hard limit switches when the processor detects a pin
4 o# N) r- k6 s' J  b// change inside the hard limit ISR routine. By default, Grbl will trigger the hard limits8 G; Z6 {' b1 h- t' z" c- Z+ W
// alarm upon any pin change, since bouncing switches can cause a state check like this to
3 P$ f! L  F# m1 K% O. o// misread the pin. When hard limits are triggered, they should be 100% reliable, which is the  c0 l. U& j7 R% U
// reason that this option is disabled by default. Only if your system/electronics can guarantee
, O0 E1 {9 d! w& B// that the switches don't bounce, we recommend enabling this option. This will help prevent2 x, _- \$ [& c2 k
// triggering a hard limit when the machine disengages from the switch.9 Q4 U8 ]- v. {; [5 u
// NOTE: This option has no effect if SOFTWARE_DEBOUNCE is enabled.
2 ?: |4 ]* M# |% W! r/ m//力Grbl检查硬限位开关的状态,当处理器检测到一个销
. V* ~1 y' A+ q$ U//改变内部硬限制ISR例行公事。默认情况下,Grbl将触发硬限制; r8 |. A9 o: i+ l
//报警在任何销更改,因为跳开关可以导致这样的状态检查0 W. B6 Q. t. R* Y' C& U0 v4 l. e
//误读了销。硬限制触发时,他们应该100%可靠,这是
6 X% c1 a  T% p/ x. r- F//原因,这个选项默认是禁用的。只有在你的系统/电子产品可以保证
8 x& G' |. ~3 l7 F! `, P7 W//开关不反弹,我们建议启用这个选项。这将有助于防止/ D  E) \! A  O( @6 |
//触发机退出时硬限制开关。1 \% C) ~8 f6 a; L0 V" w/ S/ d4 }
//注意:这个选项如果启用了SOFTWARE_DEBOUNCE没有影响。
9 Q1 q# @% Y5 ^# i( C& `" ]. y7 A
( P) V" t/ }  c4 _" g& y! K// #define HARD_LIMIT_FORCE_STATE_CHECK // Default disabled. Uncomment to enable.1 P# t1 X4 t( T  @& g
% d! f2 K- [$ _

3 n# w5 ?. r7 i// ---------------------------------------------------------------------------------------
1 n1 K9 ~; O/ I; O$ j// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:编译时错误检查的定义值:/ f; V7 j2 I7 Y( A- R

1 ?3 x/ d* N# z4 Y$ T7 J#ifndef HOMING_CYCLE_0
) V* e+ ~: W1 ^& S- |" |9 {  #error "Required HOMING_CYCLE_0 not defined."5 v- J# W4 @# S
#endif
2 G( o2 U) `, P* s9 \; A' ?8 B6 ?4 X* J
#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(VARIABLE_SPINDLE)
, h  S( M4 e% [  M- A$ s, N  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with VARIABLE_SPINDLE enabled"
0 n* w$ l1 ]! g: H+ k#endif
( M2 T5 t1 A7 T  c
; Z0 s0 ]0 L8 q, W6 Q7 ]#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(CPU_MAP_ATMEGA328P), s+ X& _, E3 J
  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with a 328p processor"* T# F4 }3 z$ P( E: p
#endif$ F3 R9 _0 h0 v% i7 y& z! j
$ z- [% J! j$ T! L1 x
// ---------------------------------------------------------------------------------------( {! P3 M1 A. e$ w
1 G+ F7 S) X" k6 t

- E/ V- J+ L4 P7 d/ ~8 @2 \/ o#endif+ R/ _- n! l2 j, C3 B8 X! L3 s# Z

! O  f6 T( A. `7 I  j* V( k, d' W" d3 h/ K( `1 I- x
6 E; P, n% I3 a
. ^" ?& x2 ^: Y% W4 [+ D5 a

. Q7 g( ~3 x0 S1 g6 n6 t# ?# j. r
% ~# G& C0 w" p3 y' O7 B! s6 L( r2 S2 [

) u! s! B; x& M, I0 l) D
+ L4 C4 T4 {) f/ ]& [9 S3 Y
; ]  v2 h; B. B% i0 x5 I0 a0 `6 t5 o  J9 B

) Q* ?6 H5 W) p6 W5 c5 O' H, n, J: J+ \) q9 u7 o5 r: P
. R6 c0 Y' J6 B" T7 |6 W: R

& O4 j  c- T5 J! R& I
4 r4 Q* S* g6 f* F6 i! h

本帖子中包含更多资源

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

×

评分

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

查看全部评分

回复

使用道具 举报

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

* W, T+ L8 `2 [) X
发表于 2016-8-21 05:50:22 | 显示全部楼层
      楼主厉害!
发表于 2016-8-21 08:22:05 | 显示全部楼层
谢谢楼主,先收藏一下,慢慢学习
发表于 2016-8-23 15:11:25 | 显示全部楼层
这是什么宝贝?
发表于 2016-8-23 15:11:47 | 显示全部楼层
换了个浏览器Chrome,试试能否发言了。
发表于 2016-8-23 20:12:33 | 显示全部楼层
楼主厉害
回复

使用道具 举报

 楼主| 发表于 2016-8-23 23:03:17 | 显示全部楼层
补充$ Z9 N! g6 {, I( O2 w, u
程序运行protocol_execute_realtime(); /运行实时命令。* E/ N2 s; a0 W
// Executes run-time commands, when required. This is called from various check points in the main) c6 ?+ b' b& P( y5 r' ^1 l6 c
// program, primarily where there may be a while loop waiting for a buffer to clear space or any
  |4 j9 C/ M7 o0 n+ q// point where the execution time from the last check point may be more than a fraction of a second.* a% A, f- i$ B' J. ]* b6 X$ r; |6 C
// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code3 H9 d& b% \1 \; s; F, g: e3 d
// parsing and planning functions. This function also serves as an interface for the interrupts to $ L3 a5 C/ W6 A: {' H4 K) f* x* a3 g
// set the system realtime flags, where only the main program handles them, removing the need to9 }) l3 p# A2 C! M1 {: g
// define more computationally-expensive volatile variables. This also provides a controlled way to * S, _$ W# T8 b6 J6 o( |& h, T
// execute certain tasks without having two or more instances of the same task, such as the planner
) L, V/ U' r' m' K) Q( N. C7 U// recalculating the buffer upon a feedhold or override.
& @% |4 T; R- y, h// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,8 u( P1 K" w1 v# C8 v
// limit switches, or the main program.# V2 c+ V$ g! ?

4 h6 f5 a& M0 p' h//执行运行时间命令,在需要时。这就是所谓的从各种主程序要检查站" i) h' N+ Z& h' M/ ~  p
//,主要是那里可能是一个while循环等待缓冲区空间或任何
5 t4 C2 N# ?# G6 Q4 q% t//执行时间从过去的止点可以超过几分之一秒。
$ v. L( _& d! B! b( T* l; ]//这是一种异步执行实时命令(又名多任务)grbl的刀位点
7 L: v7 d) E+ M- C//解析和规划功能。这个函数也可以作为一个接口,用于中断
% b  r4 B  K3 z, f5 S, H3 k0 E" _//设置系统实时的旗帜,只有主程序处理,消除的需要1 N) R% H" h! i/ b3 A
//定义更多的计算昂贵volatile变量。这也提供了一种控制方法, @' d! j1 {1 D$ g$ Z+ U3 W
//执行某些任务不相同的两个或多个实例的任务,比如计划
; ]3 S! k4 }* I+ `/ D8 S$ G//重新计算缓冲feedhold或覆盖。9 f, y; H- Z. @  N/ E
//注意:sys_rt_exec_state变量标志设置任何过程,步骤或串行中断,插脚引线,
/ |' P% Q" B" ]8 ?) o; P5 i4 [//限位开关或主程序。
- C6 ^6 l4 \8 ]  K( |void protocol_execute_realtime()
$ D4 x% T7 j% `/ _& L- Y2 [/ g6 v{
0 @3 V4 k2 l/ Y6 O+ a9 q9 b) G        // Temp variable to avoid calling volatile multiple times.
2 w4 w( `1 @5 a9 r5 t5 A0 {        // 临时变量来避免多次调用不稳定。
- S0 ~; i7 _8 w5 `& \        uint8_t rt_exec; 8 k4 v$ R# O% A5 Q8 d
        do{! a9 E* A2 @9 W! x* F
          if (rt_exec) {                 // 有标志位置位进入
$ w4 W4 d3 r/ f/ r        % Z# ?! c: p: o9 Z/ y5 c
            sys.state = STATE_ALARM; // 设置系统为报警状态8 J6 w8 `+ k3 @* m
      report_alarm_message(ALARM_HARD_LIMIT_ERROR);        //报告报警信息为接近极限值
3 l4 g5 o- O9 K/ i    } else if (rt_exec & EXEC_ALARM_SOFT_LIMIT) {                        //报告执行软件限位报警
/ W3 c4 ]+ R3 C2 G& {      report_alarm_message(ALARM_SOFT_LIMIT_ERROR);        //报告出现软件限位报警: n* l0 @% l! {& I
    } else if (rt_exec & EXEC_ALARM_ABORT_CYCLE) {                //执行停止循环报警      " w" j& u; ]% H4 O
      report_alarm_message(ALARM_ABORT_CYCLE);                //出现终止循环报警
: [  ^9 v9 Q4 V: e5 A0 [4 D    } else if (rt_exec & EXEC_ALARM_PROBE_FAIL) {                        //执行探查失败报警" m; P- o6 V4 f) ], r* s; ~# b
      report_alarm_message(ALARM_PROBE_FAIL);                        //出现探查失败报警
0 Q+ o& |8 v+ S4 k7 w7 {7 J* m    } else if (rt_exec & EXEC_ALARM_HOMING_FAIL) {                //执行返回原点失败报警
* p! G9 e5 @/ K; Q# E, Y3 F, e$ U      report_alarm_message(ALARM_HOMING_FAIL);                //出现返回原点失败报警
9 {4 v. I: M0 T: f, `5 g    }
) s' N* E$ j$ \$ T5 @& ^, v; l* Y8 P8 j" W! b4 E
    // Halt everything upon a critical event flag. Currently hard and soft limits flag this.
( t) L6 _6 A" A    // 停止一切在一个关键事件标志。目前硬和软限制标志
! ^* ]$ s: \: r7 ?0 e. G4 O' y           if (rt_exec & EXEC_CRITICAL_EVENT) {                //如果系统是循环事件进入
2 a/ }4 z- R( t7 E% K2 f7 t             report_feedback_message(MESSAGE_CRITICAL_EVENT);        //报告反馈信息: s* S. A0 K9 _9 ?9 m" y. N
              bit_false_atomic(sys_rt_exec_state,EXEC_RESET);                         //清除目前的复位状态
% T1 [# e. q& U! x  b0 i# M& C4 v9 I4 S3 B- @+ s
        bit_false_atomic(sys_rt_exec_alarm,0xFF);                                 // 清除所有报警标志' f$ k, ^: R6 W" b5 T
        }        4 \* a4 u( k/ S' ?! v  M) E  w( g
% b- W- Y! |2 Z, q4 N' e
上面代码将rt_exec = sys_rt_exec_alarm ,如果rt_exec为真,打印不同报警信息7 \- ?7 P% f1 W6 T/ \
和限位保护信息,然后清除报警状态
' S: U4 Q/ K" _& O5 g% l___________________________________________________________________________* ~/ S9 x" f- v+ h
没有报警进行执行下面代码,执行了终止命令,串口打印命令
  z" v* O" Y& p5 c  L+ w. F         // Check amd execute realtime commands        校验和执行实时命令! Y) }4 m/ p  j% N
          rt_exec = sys_rt_exec_state; // Copy volatile sys_rt_exec_state  H# M- v$ ~. a: v7 C
+ N7 o) B/ y' E# |: B
        if (rt_exec) { // 输入标志是正确的执行/ u) R& T3 ]$ q8 O- i4 l2 K
4 v# n# w. h' ]; g9 Z4 |
            // Execute system abort. 执行系统终止命令. A5 \* A' J! S1 `7 G% T
            if (rt_exec & EXEC_RESET) {" R4 R' ^5 H$ }! y7 ^) s
              sys.abort = true;  // Only place this is set true.+ ~5 [( B% a" s" b& v: b0 H
              return; // Nothing else to do but exit.8 D8 W4 a: a  |' N; `
        }
# w* T& \6 [& O  e$ ~, o$ p* ~5 a( T( M2 o7 X8 C# w
            // Execute and serial print status 执行和串口打印状态
; M8 [# ]& f: E. k% q. v            if (rt_exec & EXEC_STATUS_REPORT) {
$ k6 V, A! \& C# H% ^# @2 t8 K              report_realtime_status();        //报告实时状态
! L$ V9 ]5 k3 z% l$ D              bit_false_atomic(sys_rt_exec_state,EXEC_STATUS_REPORT);        //清除报告状态清零
6 G9 D/ Z( e) f" s8 @& x            }  ]: E& a1 b9 H+ v: u
_____________________________________________________________________________
* @% H* T+ b$ q0 y. ?- P  S) B下面代码3 o; w; m, z5 x1 i( _9 c9 W6 B
//执行状态。' {  m6 h* c% ~4 _) F* R
//注意:所涉及的数学计算持有应该足够低对大多数人来说,即使不是全部,. I" m0 F) T4 }  l; T8 B1 j* T
//操作场景。一旦启动,系统进入暂停状态
5 D9 d5 G1 M; g/ S//主程序流程,直到重置或恢复。# F4 V7 G" ~5 m3 T1 g6 A& W
待办事项:检查模式?如何处理呢?可能没有,因为它只会在空闲,然后重置Grbl。
& ~0 v) b; a3 r' ~% p( _状态检查容许状态的方法。( G9 m5 A+ i; e7 N9 }

2 N  L7 e/ R+ r, t: H        //如果全局各自报警标志位其中(执行取消动作) | (执行进给保持) | (执行安全门)任意一位为真进入
7 q! T. ?5 J0 v3 I            if (rt_exec & (EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR)) {        6 E1 h* U0 r7 o$ p6 N3 w+ a

( _8 w6 h- @, e# P( r  N        //如果是循环状态执行暂停状态
& U7 ^& W6 p7 `/ j4 n9 n7 H: H        if (sys.state == STATE_CYCLE) {( @% V" ?, J, d& X8 |
        st_update_plan_block_parameters(); //通知stepper module验算减速。# V6 z( k: @+ j% c% l
        sys.suspend = SUSPEND_ENABLE_HOLD; // 开始暂停标志
' Y, b+ \* ]! |, P1 t& T5 g        }2 t& X5 }: t: _, n: c) Q
9 d8 r* S9 j7 _6 R. C. D: o5 |
        // 如果,Grbl空闲不在运动。简单的指示暂停就绪状态。
9 B" W( E8 Q8 O5 b/ ~# [        if (sys.state == STATE_IDLE) { sys.suspend = SUSPEND_ENABLE_READY; }0 R; D4 @0 k# `/ W0 z

2 p; g  c0 R/ t( L: [0 m7 R" {, D5 _7 L* x3 X* ^1 \
        //执行和标志和减速运动取消并返回空闲。主要由探测使用周期4 X9 Y; [1 o  {: h
        //停止和取消剩余的运动。       2 X# U8 k- |4 |0 C3 _( P+ E: H
        if (rt_exec & EXEC_MOTION_CANCEL) {
2 [8 z/ v  x% j9 E$ n2 f8 F9 O8 T          if (sys.state == STATE_CYCLE) { sys.state = STATE_MOTION_CANCEL; }% G6 r6 R+ X! R. l
          sys.suspend |= SUSPEND_MOTION_CANCEL;
6 c$ A) Z8 P8 f. r" Q7 b% F% \# p1 |        }/ ^- y) ?; d- V$ A8 E: I
$ {' H4 X- ~1 j  Q- h4 ~
        // 只在循环时执行进给保持减速
  x' S9 Z4 {7 S         if (rt_exec & EXEC_FEED_HOLD) {
2 q2 t! _! Q6 I; Z        //只有安全门为1才执行保持进给状态赋值6 f4 B( E# I. I& v8 g, l  K: W, F
          if (bit_isfalse(sys.state,STATE_SAFETY_DOOR)) { sys.state = STATE_HOLD; }
% N; `% U# R7 z' m+ e. J        }! ]( _  ~' ]; u) Y
9 V( J/ [. f( V* {: A
        if (rt_exec & EXEC_SAFETY_DOOR) {
- f, B) J' e  c# F; y3 d) j% m, S          report_feedback_message(MESSAGE_SAFETY_DOOR_AJAR); 1 ^# u: t' F8 z+ w' Q! v: j
/ /如果已经活跃,准备好重新开始,CYCLE_STOP标志设置为强制断开。
9 s1 O. }! N* B# H+ K: L- y0 V; f/ /注意:只是暂时设置“rt_exec”变量,不是动荡的“rt_exec_state”变量。
/ n: n2 |1 W% T/ C% P          if (sys.suspend & SUSPEND_ENABLE_READY) { bit_true(rt_exec,EXEC_CYCLE_STOP); }; j, C: G" S( \+ e: T$ [' m- X
          sys.suspend |= SUSPEND_ENERGIZE;
" L+ ~  I( B4 c1 Y          sys.state = STATE_SAFETY_DOOR;3 F+ }) r* W6 G& X# E6 r* c
        }
8 }' }3 ?4 ~: k2 x2 C) j" y( _6 F" W+ K. W* O: l
bit_false_atomic(sys_rt_exec_state,(EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR));   
( c9 F# X$ _& G' r! M
* I/ x* ]: {  A. |+ y. ^}* D& r3 \3 K6 i+ g" w! L
以上代码执行了; @" {/ F% s+ o& y# S
1.如果全局各自报警标志位其中(执行取消动作) | (执行进给保持) | (执行安全门)任意一位为真进入+ b/ Z: [% |2 @2 g1 P* R' G
2.系统为闲着状态, 开始循环状态, 回原点状态, 控制取消状态, 开始保持状态, 开始安全门状态时进入% o! j8 ^# H; z- B# f
3.如果是循环状态执行暂停状态
) G" l% E) \. c+ K; r4.如果系统闲置状态执行暂停就绪状态; n- `4 L5 h  ^/ t
5.执行动作取消
3 n& P0 M" f4 P# E+ P6.如果是保持进给状态,执行保持进给状态* z* D, ]; z5 j+ Q  m' R7 Z/ O
7.执行安全门状态$ A, ^9 S( J; I5 `% D
最后执行bit_false_atomic清标志清除(执行取消动作)(执行进给保持)(执行安全门)标志位                  : g% M, e8 ]4 A
_____________________________________________________________________________9 p- n) O/ O8 N, O1 z3 y
1 v5 f1 p- k7 t
    // Execute a cycle start by starting the stepper interrupt to begin executing the blocks in queue.
" M6 i* W* C* {9 S    // 执行一个循环开始启动步进开始执行中断队列的街区
+ L$ q6 i$ O# X% P/ o    if (rt_exec & EXEC_CYCLE_START) {        //循环开始状态进入$ X0 K, J  }+ t  {& k7 I7 D! l6 x
      // Block if called at same time as the hold commands: feed hold, motion cancel, and safety door.) `1 X( R$ V+ ~5 t' z$ a
      // Ensures auto-cycle-start doesn't resume a hold without an explicit user-input.5 b: X0 B* v. @  w/ @" K: {, Y
          //块如果在同时举行的命令:保持进给,运动取消,和安全的门。 //确保auto-cycle-start没有简历没有显式的用户输入。  A, z% m' J: l$ z. e9 X  I
          
) q3 R6 m* x* |' {! A1 J      if (!(rt_exec & (EXEC_FEED_HOLD | EXEC_MOTION_CANCEL | EXEC_SAFETY_DOOR))) {   //状态机如果不是保持进给,运动取消,和安全的门。 . M" _$ `5 H; g7 ^5 {, \
        // Cycle start only when IDLE or when a hold is complete and ready to resume.
2 M, `+ _( L; G; j        // NOTE: SAFETY_DOOR is implicitly blocked. It reverts to HOLD when the door is closed.; T4 Y! Z$ T8 r" _- T0 D+ p
                //循环开始时只有当闲置或持有完成并准备简历。
1 h' Q9 {$ l; i+ F1 w+ l                //注意:SAFETY_DOOR是隐式地屏蔽。它返回的时候门是关闭的。    9 V# j' a* K* L/ U, S

8 |# Y& u( j( M: ]" {2 L                // 如果系统状态为闲着状态,系统状态为开始进给或运动取消,暂停标志为位重新开始
3 o2 `; G& ?. x4 U& d7 _% b        if ((sys.state == STATE_IDLE) || ((sys.state & (STATE_HOLD | STATE_MOTION_CANCEL)) && (sys.suspend & SUSPEND_ENABLE_READY))) {/ o$ U! {, J. X+ n8 o" y
          // Re-energize powered components, if disabled by SAFETY_DOOR.
5 ?1 s- t8 B3 F( N          //        由SAFETY_DOOR重振组件供电,如果禁用。
4 @7 @9 z& X) ^& r+ _! }          if (sys.suspend & SUSPEND_ENERGIZE) {
! \7 Y0 u! K/ D, a% o            // Delayed Tasks: Restart spindle and coolant, delay to power-up, then resume cycle.' L0 d) \# L: }; @, K0 h# T
            //延迟任务:重新启动主轴和冷却剂,延迟升高,然后恢复周期。
) m$ H& F' U3 W6 E            if (gc_state.modal.spindle != SPINDLE_DISABLE) {   //主轴模式不是失能进入
- ?( W$ d5 k7 G) c% ]( {( m0 m              spindle_set_state(gc_state.modal.spindle, gc_state.spindle_speed); //设置状态和速度# u, n* [7 F5 O' {& v
              //待办事项:阻塞函数调用。最终需要一个非阻塞。* q: l9 i5 Z$ V* g* ]2 `3 D7 K
                delay_ms(SAFETY_DOOR_SPINDLE_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.
( d" B1 E2 y2 O9 q            }
0 C) X' n/ }0 r8 O" l            if (gc_state.modal.coolant != COOLANT_DISABLE) {
7 O; E2 w! N, T4 S/ B* t              coolant_set_state(gc_state.modal.coolant); / q5 d6 _# G7 }" ~2 a
              delay_ms(SAFETY_DOOR_COOLANT_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.* V' f, M/ t7 m  e
            }! Z  F9 U7 t3 y/ [9 G' L1 f
            // TODO: Install return to pre-park position.$ h7 v/ M! O( _1 Z# ~4 r
          }- Z0 D0 `% m0 [/ s; [* ^5 q, j
______________________________________________________________________________________________________________
0 f& l' T  H6 [& a# M% s, P          // Start cycle only if queued motions exist in planner buffer and the motion is not canceled.( @& U7 l7 e0 O) [0 O+ O
                  & M7 u# X4 V( j5 u/ D2 V
                  //只有在队列马达存在规定的缓冲,并且动机没有让取消,才会循环
* _' `$ M- A7 d& Y9 o. p: u                  , s2 x3 Z6 i) N! P* W
          if (plan_get_current_block() && bit_isfalse(sys.suspend,SUSPEND_MOTION_CANCEL)) {5 y1 a: L. j; v! f1 w
            sys.state = STATE_CYCLE;+ A! s" E4 h8 |! o% D5 L; O
            st_prep_buffer(); // Initialize step segment buffer before beginning cycle.初始化步开始循环之前" [% z( `; F9 D
            st_wake_up();
8 y& {2 s" U1 e5 p6 m% T          } else { // Otherwise, do nothing. Set and resume IDLE state.否则,什么也不做,设置和复位空闲模式
, G$ C; d# Z( H2 t            sys.state = STATE_IDLE;
/ v$ s, v9 K/ O$ s7 `6 }. k          }# T' ~- ?3 Z; Q# j7 J
          sys.suspend = SUSPEND_DISABLE; // Break suspend state.* o* ~- _' O8 Q. \$ j
        }$ r4 u( f& W) q8 H
      }    4 f7 P0 ]' ?% h9 u3 \
      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_START);        : h' x1 g7 f1 `5 p, c
    }5 Q/ i- W+ h' f

0 ~$ ^2 j! h( N' `2 ~_______________________________________________________________________________________________________
: K2 W. Q/ q$ z/ i    // Reinitializes the cycle plan and stepper system after a feed hold for a resume. Called by
4 v, J  P; k- A5 `0 o4 C& o- x/ V5 G    // realtime command execution in the main program, ensuring that the planner re-plans safely.
! M- W, x) \2 W& ]- q7 X    // NOTE: Bresenham algorithm variables are still maintained through both the planner and stepper
- z' \: L* c5 E) ?    // cycle reinitializations. The stepper path should continue exactly as if nothing has happened.   
$ E7 f- n6 U" v    // NOTE: EXEC_CYCLE_STOP is set by the stepper subsystem when a cycle or feed hold completes.% M3 y8 p& L6 o
# L3 k* j) \* x$ }& b
        //重新启动后循环计划和步进系统的进给保持简历。通过实时命令执行主程序,确保安全计划重新计划。. S9 y8 Z4 x1 |
        //注意:画线算法变量仍保持通过规划师和步进
1 C. l% ~% f- ~6 e( K        //循环仅。步进路径应该继续,好像什么都没发生一样。        9 k/ N0 [+ C' g4 C1 Z
        //注意:EXEC_CYCLE_STOP由步进子系统周期或进给保持时完成。% t* ~( U. }3 m3 V! m

3 J; Q, @% }% v% t8 B  b    if (rt_exec & EXEC_CYCLE_STOP) {                         //如果是循环停止状态进入
. ^7 {, |% x: ~, m2 n! \      if (sys.state & (STATE_HOLD | STATE_SAFETY_DOOR)) {9 z/ H/ U  F+ U0 p& v. \
        // Hold complete. Set to indicate ready to resume.  Remain in HOLD or DOOR states until user
* [) W) x1 ?! g5 \  Q        // has issued a resume command or reset.
/ Z- L' y/ ]7 B* o( o7 j$ D/ U. f8 V0 U8 b/ ]1 T7 z
                //保存完整。设置为指示准备简历。继续持有或门状态,直到用户7 r$ J# }7 z  S- {+ o
                //已发布了一份简历命令或重置。* ^9 Q% O. |+ ~" z$ v6 k8 k
               
. ~; W5 f" I6 v! X1 x3 Q        if (sys.suspend & SUSPEND_ENERGIZE) { // De-energize system if safety door has been opened. 如果安全的门已被打开。断开系统6 {+ N! V2 l+ n9 i
          spindle_stop();
0 g5 ?! u2 p5 O! o. d9 ~; Z          coolant_stop();. K3 t3 _* q: T
          // TODO: Install parking motion here. 安装停车动作。
5 v% ^8 i5 A1 L6 F        }
1 c) N# k& c: `2 n  U6 J        bit_true(sys.suspend,SUSPEND_ENABLE_READY);* r: g4 _) C, N9 J8 y3 b
      } else { // Motion is complete. Includes CYCLE, HOMING, and MOTION_CANCEL states. 电机完成,循环,回原点,,MOTION_CANCEL4 h8 s0 y9 F! r8 k5 X: O7 x3 m
        sys.suspend = SUSPEND_DISABLE;
2 c' x) k- ~/ s) e        sys.state = STATE_IDLE;
6 K- \3 M; e7 I& v& X      }
# J9 a0 {7 }. \      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_STOP);- G( j) _# q2 v0 L
    }
# [- P- W+ ]% }2 Y/ a5 U( P* t: M8 Y    " }& x1 ^8 V" x, u
  }2 s! o. e4 M: W. a$ {
___________________________________________________________________________________________________$ j  P' b( D, g
/ }/ K. j: z/ ?
  // Overrides flag byte (sys.override) and execution should be installed here, since they
, A( p* z  v6 x  // are realtime and require a direct and controlled interface to the main stepper program.3 \2 h. q: b( B& D# U
. s; \' o! z# S! n" }0 e! D
  //重写标志字节(sys.override)和执行应该安装在这里,因为他们! n- z# A; t/ E0 m) V9 R
  //实时和需要直接和控制接口的主要步进程序。2 |2 `& P9 e) x) ?/ V

1 f5 p* o+ F7 _
: S& g8 x& y6 {  z- _  // Reload step segment buffer 重新加载步段缓冲3 V! H6 C, O# s, p0 R% Q# k' S
  if (sys.state & (STATE_CYCLE | STATE_HOLD | STATE_MOTION_CANCEL | STATE_SAFETY_DOOR | STATE_HOMING)) { st_prep_buffer(); }
% B4 j- V" O; N# ~0 N9 O7 M( ?; J8 m. `
  // If safety door was opened, actively check when safety door is closed and ready to resume.7 @# k$ J) z) }: c
  // NOTE: This unlocks the SAFETY_DOOR state to a HOLD state, such that CYCLE_START can activate a resume.        5 Y: O( t+ q" _, X6 Y! l
1 D# m( U. b+ C% P, M( j
//如果安全的门被打开,积极检查当安全门关闭,准备简历。
6 i& N- O0 Y: f  //注意:这解锁SAFETY_DOOR状态保持状态,这样CYCLE_START可以激活一个简历。, Q: F9 M- p) N- k

7 B8 t& }! o5 p$ Y  if (sys.state == STATE_SAFETY_DOOR) {                 //安全门状态进入) N; U" S) Z; }1 d2 n6 l
    if (bit_istrue(sys.suspend,SUSPEND_ENABLE_READY)) {
. l2 i4 F7 ?0 M- J8 ]8 L      if (!(system_check_safety_door_ajar())) {
+ x. ^% z1 z2 L2 s, C        sys.state = STATE_HOLD; // Update to HOLD state to indicate door is closed and ready to resume. 更新保存状态指示门关闭,准备简历。! d! C; a( |7 E, Y9 A9 \: l9 ^
      }
* q2 k) Q, l8 l+ P    }
+ D0 B' x2 ]9 |7 B" R5 r  }6 M. S6 K2 p/ }4 o: l
5 ?5 z/ X1 y% a
  } while(sys.suspend); // Check for system suspend state before exiting.
2 K  u$ q# H+ T! T  - G4 R; s6 r, E
}  
发表于 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-8-27 21:19 , Processed in 0.116407 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.5 Licensed

© 2001-2025 Discuz! Team.

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