找回密码
 注册会员

QQ登录

只需一步,快速开始

搜索
查看: 19514|回复: 15

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

[复制链接]
发表于 2016-8-20 23:56:23 | 显示全部楼层 |阅读模式
本帖最后由 1五湖四海1 于 2016-8-21 00:09 编辑 , C/ L3 X6 e6 n

" ~* d! }& K! v    以前制作过CNC雕刻机,是用MACH3作为上位机控制,硬件是采用PC接并口输出脉冲和方向使能信号经过隔离驱动步进电机驱动器,步进电机驱动是采用TB6560芯片控制。最后就接到步进电机。机械是用铝合金制作,主要部件有三个1605的滚珠丝杠,多个运动滑块等制作。用这台DIY CNC雕刻机可以雕刻木头塑料等东西。当时没有一直玩下去,现在发现网上有用单片机制作的雕刻机挺精巧的现在分享给大家。
, r6 A! i) |8 \/ w4 h   GRBL CNC 3D打印机,这就是我说的可以用单片机来控制的3D打印机,我先照着百度科普下grbl,Grbl是性能高,成本低,基于并口运动控制,用于CNC雕刻。它可以运行在Vanilla Arduino (Duemillanove/Uno) 只要它配备了Atmega 328型芯片。 控制器由C编写并优化,利用了AVR 芯片的每一个灵巧特性来实现精确时序和异步控制。它可以保持超过30kHz的稳定、无偏差的控制脉冲 它接受标准的G代码而且通过了数个CAM工具的输出测试。弧形、圆形和螺旋的运动都可以像其他一些基本G代码命令一样完美支持。函数和变量目前并不支持,但是会作为预处理器包含在将来发布的版本之中。 Grbl 包含完整的前瞻性加速度控制。它意味着控制器将提前16到20个运动来规划运行速度,以实现平稳的加速和无冲击的转弯。Grbl是性能高,成本低,基于并口运动控制,用于CNC雕刻。它可以运行在Vanilla Arduino (Duemillanove/Uno) 只要它配备了Atmega 328型芯片。 控制器由C编写并优化,利用了AVR 芯片的每一个灵巧特性来实现精确时序和异步控制。它可以保持超过30kHz的稳定、无偏差的控制脉冲 它接受标准的G代码而且通过了数个CAM工具的输出测试。弧形、圆形和螺旋的运动都可以像其他一些基本G代码命令一样完美支持。函数和变量目前并不支持,但是会作为预处理器包含在将来发布的版本之中。 Grbl 包含完整的前瞻性加速度控制。它意味着控制器将提前16到20个运动来规划运行速度,以实现平稳的加速和无冲击的转弯。很棒吧!开始玩起。4 s9 O+ B) N9 p/ E* w
    还没有雕刻机的机械部分可以用废旧光驱制作个微型雕刻机运动平台。雕刻机最重要的是主控程序这次用 Arduino/AVR328单片机,价格在15元左右,主控程序是上面提到的目前很火的开源
的GRBL,还有一种基于STM32平台的开源主控程序Dlion也不错可以替代grbl。如果从性能比较这两个方案,显然是stm32平台运行速度更快毕竟他是32单片机呀!9 W& r$ L& q# f# n

; E! m( R/ }  q

' n% Y' ]) P+ ~    下面介绍小这个些主控程序主要干的事,通过串口PC和主控板通讯,PC命令给控制板,控制板接收命令做不同的响应,PC可以发G代码给主控板,接收完成后可以自动开始雕刻任务。
7 h7 N6 S7 T5 L, L          在介绍下G代码因为G代码是雕刻机的核心部分9 A9 u0 _3 U5 b2 t/ @  W  M5 T
G代码是数控程序中的指令。一般都称为G指令。: g9 F6 o; B# S6 d4 B
G00------快速定位- y; O. d6 M; D* U9 h' ?
G01------直线插补, |1 G9 J) X- ]( K4 U& l5 U2 d
G02------顺时针方向圆弧插补
/ j4 d* j3 q; T+ U$ e- {6 z. ~G03------逆时针方向圆弧插补
$ Q2 I  `8 N7 u9 ^% Y- fG04------定时暂停
% E/ o1 U7 ]! z& w' b4 k2 vG05------通过中间点圆弧插补! q: F3 R' f8 W; ]4 P% P
G06------抛物线插补
* M5 _% e. ^& x. f8 `3 D. `8 m7 gG07------Z 样条曲线插补$ D" J7 O; l+ ]& N" y4 D
G08------进给加速) o- `! I; w7 N
G09------进给减速
5 l& B  X2 c( u, u$ u. c# ~4 x! EG10------数据设置
0 ]) l5 h( H$ A+ P9 k+ _G16------极坐标编程
  N  z; I3 N; IG17------加工XY平面! ]# N$ q) h( L6 o  m5 C  C: _
G18------加工XZ平面
6 g+ Y6 f; V, F+ w, [0 nG19------加工YZ平面
- Q* H) o: j3 O1 x6 k
核心就是解析G代码,完成步进电机驱动,和控制主轴开启关闭,还有插补算法,直线插补,圆弧插补,还有一些步进电机的加减速算法。
8 Y7 C' T8 L. X下面对grbl主结构做介绍
: N; c: Z6 v$ @* e: Umain()主函数首先执行下面初始化函数7 _- O/ x$ S* b! s! i
        serial_init();                           // 设置串口波特率和中断
; ?! T% v) f, l8 s6 C# G        settings_init();                         // 从ROM加载grbl设置: X  w5 \+ N, i# B! N
        stepper_init();                          // 配置步进方向和中断定时器4 _2 O5 v- f# W  y0 l9 Q. {  A7 ]
        system_init();                           // 配置引脚分配别针和pin-change中断
7 u. _7 u) U+ f. D' L        memset(&sys, 0, sizeof(system_t));          // 清除所有系统变量! e1 i4 w) j& d
        sys.abort = true;                           // 中止标识位置位
$ H6 f+ G+ |4 P2 r+ Q8 w) P        sei();                                         // 使能中断
( i5 B* Z6 {) u& ]: r: q  #ifdef HOMING_INIT_LOCK                        // 宏运算(settings.flags & (1 << 4)) != 0结果flags等于执行sys.state = STATE_ALARM3 d% F4 a/ u! a* t9 s
                                                // 系统状态赋值为报警状态
% v. r. W7 ~0 g, K/ B/ a& p            if (bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE)) { sys.state = STATE_ALARM; }: _- s1 m" @9 k5 K) z
  #endif1 ?, S- l2 c5 a$ }' F1 o
_____________________________________________________________________________________________________________________________________' Z# t" x( r+ ?' k
接下来是一些主要部分初始化
5 b* @& ?% e& n1 rfor(;;) {
' {8 R0 c. U5 K6 h        serial_reset_read_buffer();         //清除串口读缓冲区4 \7 h; d$ y9 v0 j) Q
        gc_init();                         //初始化G代码功能函数5 _1 p; |9 `$ N; j8 g8 R! f6 m8 B( s
        spindle_init();                        //主轴初始化1 Z3 g, w. r. j  L& D, c
        coolant_init();                        //冷却液初始化' x* \3 D9 ?! m. x/ Z- k( A3 S
        limits_init();                         //极限开关初始化, O) [9 \: I8 b5 b5 I
        probe_init();                        //探测部件初始化
, g! p: u2 b& O) h5 L        plan_reset();                         //清除块缓冲区和规划师变量) k* O  {# Q1 G8 `  z/ B2 M
        st_reset();                         //清除步进系统变量。% X$ p9 ^0 o$ x
1 W/ g# B4 |+ _3 i" V- a+ _( G3 r+ k7 ^
) T9 q. b$ T( q4 q$ O9 f- J% u
        //下面两行清除同步gcode和策划师职位当前系统位置。
' W' c( p3 ]3 `. |$ F1 X" ^
        plan_sync_position();
  L5 t" U* K% F+ k% f        gc_sync_position();
1 \+ k; p: _/ ^- S0 @) A
  k: ~* f& V2 Y/ S3 p$ s. l5 b1 [$ l! A1 U6 X( v
        //复位系统变量
5 M- C6 y0 \* k- v# c/ E        sys.abort = false;                //系统中止标志
9 B1 a) F# b- X1 ^        sys_rt_exec_state = 0;                //系统标志位变量状态管理。看到EXEC位掩码。
4 D1 s- |6 I6 D6 F5 d/ }% `  V        sys_rt_exec_alarm = 0;                //系统标志位变量设置不同的警报。2 \/ }1 P& @" V, s7 u3 o! o
        sys.suspend = false;                //系统暂停标志位变量管理,取消,和安全保护。  T/ w" c" @7 |' f
        sys.soft_limit = false;                //限位开关限制状态机错误。(布尔)
! A- D0 t9 f" o& P$ d1 P* q! ]- i: ?+ a6 o1 |! k( W
9 w; m! z7 L, K; E8 t8 u. K
        protocol_main_loop();                //主协议循环  u* _$ `  U- F
}        //5 S/ J4 B5 g' U
_____________________________________________________________________________________________________________________________
1 Z  L+ g% T5 G: v2 y进入void protocol_main_loop()函数, r  c6 F3 y+ O, J. O( R0 L- {2 d( h
{6 y* Z1 N$ g, k" _7 A4 C' m0 j
        report_init_message();                // 打印欢迎信息 ; r& y$ m! M8 `2 C$ T3 j( g& y
        //重启后检验和报告报警状态如果错误重启初始化。
, F/ J# D# D+ v3 m
        if (sys.state == STATE_ALARM) {
0 X2 f' z; Z; u            report_feedback_message(MESSAGE_ALARM_LOCK); //打印信息
' V" M' v( K$ Y* ]7 B- S, Q' u
          } else {' I/ r, g! q- l. W
            // 如果没有报警说明一切正常!但还是要检查安全门. $ \$ R: v1 w  r: ~0 E( l  z2 G0 C  b5 s9 X
            if (system_check_safety_door_ajar()) {# l  d6 G9 u  d9 y" [; d* F3 ~7 C5 V
                     bit_true(sys_rt_exec_state, EXEC_SAFETY_DOOR);' g0 K2 r+ I- v, d; c+ s0 w
                     protocol_execute_realtime(); // 进入安全模式。应该返回空闲状态。
: U3 M& r+ P3 Q) s0 e            }         else {
/ y) q  X, m$ b& ]; D              sys.state = STATE_IDLE; // .设置系统做好准备。清除所有国家国旗。
' D$ W& z- b+ P5 ^! H            }
( p, j1 ~) J9 W            system_execute_startup(line);    //开始执行系统脚本
0 G: z9 J1 w0 j2 f  }
3 h) r0 t3 }  `" ?. ~5 A; @- j; p: z5 z2 u& m7 P1 `  P

+ {# j! i8 Y% C- h2 Z0 Q  // 这是主循环!在系统中止时这是出口回到主函数来重置系统。# a" s+ D( N& N5 d
  // ---------------------------------------------------------------------------------  
4 o# l; S/ h  G# e  n8 ]7 d  3 x6 l; h% h4 D/ L7 P3 L
        uint8_t comment = COMMENT_NONE;7 d# D& b' d5 P; S
        uint8_t char_counter = 0;
: v9 h3 W3 C" _. j5 R8 I5 q2 b        uint8_t c;2 |) K7 r7 G  N& ?+ |
_______________________________________________________________________________________________________________________________
' j5 V: l* m0 G7 A6 |接下来进入for(;;)循环                //下面代码是G代码解析核心部分,程序中comment(注释)变量会被赋不同值,代表发符号有‘(’‘)’‘;’
2 k9 U8 `3 G9 F; Z{! a  e5 X9 O4 w- U. ]3 N
//串行数据输入一行的的过程,作为数据。执行一个
" F0 _5 B- F% f3 K  S//所有数据初始过滤去除空格和注释。 6 g; I4 I  f6 ?' C. l9 v+ X
//注意:注释,空格和程序段删除(如果支持的话)处理技术
% D$ S$ a% Y/ j. p' b) D//在G代码解析器,它有助于压缩到Grbl传入的数据
7 y* I1 _' {7 w8 X) P8 r$ n//线缓冲区,这是有限的。刀位点标准实际上州一行不行8 S2 z! w+ U4 {/ q
//不能超过256个字符,Arduino Uno没有更多内存空间。
8 l  p" [; H6 k! x, ?# q9 N4 a//有更好的处理器,它会很容易把这个初步解析的7 u& v7 }7 g; Z: c7 f4 C( M/ ?
//分离任务共享的刀位点解析器和Grbl系统命令。                                                               
4 L9 u6 d9 N0 |, ^$ a0 E8 O- w  I    while((c = serial_read()) != SERIAL_NO_DATA) {                             //读取串口数据,有数据执行下面代码! @$ D" K: Z  p* Z/ Z. k
      if ((c == '\n') || (c == '\r')) { // End of line reached                //如果数据是/r,/n代表一行结束: ^& f7 O  }: O3 H
        line[char_counter] = 0; // Set string termination character.        //设置结束标志9 z3 ^) V+ `! O7 e+ o1 J
        protocol_execute_line(line); // Line is complete. Execute it!        //一行完成执行此函数
$ E" e$ S- F% l/ l9 I3 ]        comment = COMMENT_NONE;                                                //注释清零
& W4 d7 n6 y1 f* q. D  P' y+ q        char_counter = 0;                                                    //字符计数清零
, u  N- Z* n  K# v3 F* Y    Q$ v& U) l) F5 m
        else {4 z8 u; B: J4 i. Z
        if (comment != COMMENT_NONE) {
6 j$ z+ {, w" v+ u% |8 `" M                                                     //扔掉所有注释字符
/ S. k# J; ]. ?) G          if (c == ')') {
' y! c# Y3 _3 O" X& x            //最后注释。重新开始。但是如果有分号类型的注释。
% [* s( @! R/ Y/ e2 K0 c% i9 V( q            if (comment == COMMENT_TYPE_PARENTHESES) { comment = COMMENT_NONE; }
, }; H& {  m  m" r6 [- d- l/ s          }# u* v- E# m: f! B( K* x0 t3 y9 w
      } else {# W$ `! i, k, V# a/ @1 \/ u% ?
          if (c <= ' ') {
. O2 U, K9 n% q  [/ \* j            //扔掉whitepace和控制字符. {5 O0 @8 i  j# l) q1 s% I3 F
          } else if (c == '/') {
7 \1 y3 |3 g7 l, d* S            //块删除不支持将忽略字符。
6 E2 p1 b' f  k9 k            //注意:如果支持,只需要检查系统是否启用了块删除。
2 w  K" t0 X, y5 }          } else if (c == '(') {& Y* V* O' |; \( j& j
            // Enable comments flag and ignore all characters until ')' or EOL.
  R9 ^7 h; R( I: N$ @1 _. w            // NOTE: This doesn't follow the NIST definition exactly, but is good enough for now.2 i$ F5 X+ S$ r8 Z
            // In the future, we could simply remove the items within the comments, but retain the/ J! @! b8 `; f
            // comment control characters, so that the g-code parser can error-check it.+ X* j5 h$ n, D( j
            comment = COMMENT_TYPE_PARENTHESES;
1 ~% X& i7 }8 P: A          } else if (c == ';') {
' H9 j1 D/ W1 G* f            //注意:','注释EOL LinuxCNC定义。没有国家标准。# K; k5 [( L" I8 W4 `
            comment = COMMENT_TYPE_SEMICOLON;. f* n; f  _, ?( l/ b# W  T! d- v
4 h9 H# v/ ~) P. ?) H. I# ^2 V$ U
3 q. v! O: j8 a3 B  D" G
_____________________________________________________________________________________________________________________________________$ |2 |- X: V3 y7 v
          } else if (char_counter >= (LINE_BUFFER_SIZE-1)) {                        //串口接收数据大于80字符时
: A& Z: I9 K5 j            // Detect line buffer overflow. Report error and reset line buffer.        检测缓冲区溢出。报告错误和复位线缓冲区。
5 s7 c! R  U9 {3 r$ e4 f            report_status_message(STATUS_OVERFLOW);                                //打印溢出信息
8 N/ \; B% w; t            comment = COMMENT_NONE;
2 M1 o) _5 ]9 C3 W+ H; }7 {            char_counter = 0;6 a( U. D9 k6 Z! o+ g& F/ ]- W
          } else if (c >= 'a' && c <= 'z') { // Upcase lowercase                        //小写改大写
0 H. f; j+ h4 w. x' d2 T; E            line[char_counter++] = c-'a'+'A';
, L( k. D, [4 o) s. M! ^          } else {
/ r3 [0 I9 y3 ^0 X0 o4 g            line[char_counter++] = c;( c, S4 |2 v* Y% V) W
          }- q' F7 L! O1 f3 U
        }  m8 `% K& {/ r& P- i2 n6 Z- ~
      }
4 d6 h: Z" P! j9 `8 n    }* w1 v5 b4 a4 k' t( W8 R8 i
____________________________________________________________________________________________________________________________________
) I& ]8 \8 c, D1 [. U/ Y        //如果没有其他字符在串行处理读取缓冲区和执行,这表明以完成,自动启动,如果启用,任何队列动作。
. {0 H% Y% j3 ~0 u  L2 z' {        protocol_auto_cycle_start();                //自动开始协议循环: {- p2 G/ b' k  J$ f* d
        
- e% T. s% l# w% ?+ y+ j6 }! ~            protocol_execute_realtime();                  //运行实时命令。* D# O; ?: [" \+ X" x- }1 m4 a
            if (sys.abort) { return; }                 //中止标识置位程序循环重置系统。            % Y/ J$ u6 v7 g0 B) G. }
  }
( t, J. G) X# `7 s  return;                         //一般程序不会执行到这里
) Y( |: u: _! Y# Y3 P2 E5 O2 J, R}
' H- j0 W( {6 ~5 [____________________________________________________________________________________________________________________________________- g% c$ b* O8 o# L6 D9 [! T
正常情况下,读取完G代码程序会进入protocol_auto_cycle_start();//自动开始协议循环 函数下面介绍此函数% r* O9 n* y7 c7 l) J" i, M
// Auto-cycle start has two purposes: 1. Resumes a plan_synchronize() call from a function that
. h3 d! }2 {, F// requires the planner buffer to empty (spindle enable, dwell, etc.) 2. As a user setting that + E& i4 a; u0 \& b: E# ^
// automatically begins the cycle when a user enters a valid motion command manually. This is
  S$ T& ^8 ~2 ^& {/ r: c% n// intended as a beginners feature to help new users to understand g-code. It can be disabled- T2 l6 Y8 I# X+ u) U. a! A
// as a beginner tool, but (1.) still operates. If disabled, the operation of cycle start is
  `- {/ J9 z* w' U+ C! e// manually issuing a cycle start command whenever the user is ready and there is a valid motion . X3 U; A! }: w0 W$ P1 F
// command in the planner queue.
$ ]0 N6 m( ?3 L8 z" c% N// NOTE: This function is called from the main loop, buffer sync, and mc_line() only and executes   ^- ]9 ^4 W7 x
// when one of these conditions exist respectively: There are no more blocks sent (i.e. streaming
2 N, C( T  ?, ~, \5 o4 f// is finished, single commands), a command that needs to wait for the motions in the buffer to
1 U) k5 r- ]) o// execute calls a buffer sync, or the planner buffer is full and ready to go.1 f$ d2 E- h) ^* k% \) d
//自动开始有两个目的:1。回复一个plan_synchronize()调用的函数
# y; l2 Y$ g8 N% o, \. w) t: n//需要规划师缓冲区空(主轴启用、住等)2。作为一个用户设置/ V+ X" s! n8 Z% U' z/ r4 n/ Z$ F
//自动循环开始当一个用户输入一个有效的运动命令手动。这是& O' g* {# j  k# u8 O/ U( E2 Z
//作为一个初学者的特性来帮助新用户了解刀位点。它可以被禁用7 @4 q7 y" b  C2 _4 N; |
//作为一个初学者工具,但(1)仍然运作。如果禁用,运行周期开始' w9 u  W: U' }" Z2 N5 K
//手动发出一个周期开始命令每当用户准备好,有一个有效的运动
0 h& v3 @- R8 G# Z% G. z//命令的规划师队列。
: e8 R& C4 m" Y7 Z//注意:这个函数被称为从主循环缓冲区同步,mc_line只()并执行$ _& ]* x+ F! G
//当其中一个条件分别存在:没有更多的块(即流发送
2 p# h  L8 g' ~8 x8 y3 P% D" ?! P0 }//完成后,单一的命令),一个命令,需要等待缓冲的动作
7 p) i! Z& J% M- h, A( [$ v0 ]. i//执行调用一个缓冲区同步,或规划师缓冲区满了,准备好了。
/ O9 Y2 M) R) n* e& ]0 e# Jvoid protocol_auto_cycle_start() { bit_true_atomic(sys_rt_exec_state, EXEC_CYCLE_START); }
4 }: F5 r4 @* P+ r! T  O_______________________________________________________________________________________________, O% u5 I) \9 G& b/ h4 _
接下来程序运行protocol_execute_realtime(); /运行实时命令。
1 a  r! G; }6 o4 x7 x4 ~' y! J// Executes run-time commands, when required. This is called from various check points in the main
, {/ G& t# S( l4 p, c! w" h+ Y$ E// program, primarily where there may be a while loop waiting for a buffer to clear space or any
3 j/ r# Z7 ^3 o" n5 _7 Z5 Y5 k5 v// point where the execution time from the last check point may be more than a fraction of a second.
+ u  Z- L3 `2 [0 X$ w/ k// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code, \9 z6 F9 x$ G$ M( M3 \
// parsing and planning functions. This function also serves as an interface for the interrupts to 4 P$ X/ A5 C% h0 R0 J7 \# Q6 N% F
// set the system realtime flags, where only the main program handles them, removing the need to
1 y9 T$ k, A+ y3 ]4 J// define more computationally-expensive volatile variables. This also provides a controlled way to 9 v- f/ |7 Z1 u$ S
// execute certain tasks without having two or more instances of the same task, such as the planner
/ ^; G: f8 q7 _  }" w  R// recalculating the buffer upon a feedhold or override.8 f+ a. y, G  @, }5 b
// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,0 i% {, ~2 G2 R0 z
// limit switches, or the main program.
4 Q6 a' t% n0 J& |void protocol_execute_realtime()
, ]/ x7 Z4 x/ ^ uint8_t rt_exec; // Temp variable to avoid calling volatile multiple times.临时变量来避免多次调用不稳定。: `. z$ L$ i$ G  K; s  ]& z- O: F/ c
就先分享到这吧!
6 }$ t" @; \6 ~" i$ n) O  m" E% {
/ @) Y6 v* D; Y8 l& d5 D" b; \4 h! P" V! ]

& f2 C( ^$ @. {- x& Y, R5 \( k& k7 ]
! x; C0 ?( I2 t& ]( r: @& \
. G$ R1 x! j' I( ]6 I" F

5 S& W3 F' _; d0 Y* |; k- ?) y/ y; F( s6 n8 q" g# G! J
2 ^" k* k. ]8 P' N3 n2 ?9 b8 P
: }: R; m; D' t4 v4 N
( q+ z8 {: H  {- j5 z3 q' ]
, V) u& p( `7 h: ~5 p
, G6 M+ G* m5 F$ X# N# g. ^6 c

7 F6 @" n3 S. P& Q! r
3 `7 m% I6 Q2 b* |* J- u  f+ j- |5 r# U3 N" l7 ^0 H) i
5 u# G. }6 M/ N" J7 ]+ r
! `2 |+ I% k2 P

+ z( G/ j- q: Y: l, E8 B/ y
" ^3 |7 ^- o3 g+ G
+ h' }+ {1 \+ S4 @! r
- D1 z/ v% X' t/ X
* ]5 g" v! R' b8 p/ P! G
补充内容 (2016-8-25 22:40):
1 F0 c+ |/ U, P' F- g4 ~配置说明; Y1 t! z, B. H( y, ]! l# Z
//这个文件包含编译时配置Grbl的内部系统。在大多数情况下,
9 H3 g5 v: A# A( b8 ]//用户不需要直接修改这些,但是他们在这里为特定的需求,即。
1 v" D: S+ s' r# n& I//性能调优或适应非典型的机器。
* N+ ]% L! i& H( _主要配置项:
5 {. \4 s" X7 p) D* U# `, a6 [1.#define DEFAULTS_GENERIC        //在重置eepm时使用。在defaults.h改变想要的名字
' P3 Z6 X1 \8 n6 p2.#define BAUD_RATE 115200        //配置串口波特率115200+ z/ h" W; E5 Q( Y) H
3.#define CPU_MAP_ATMEGA328P         // Arduino Uno CPU
# \* W" r0 k( ~8 p, \3 w% `4.#define CMD_STATUS_REPORT '?'        //定义实时命令特殊字符
/ `2 u- ?/ u/ E( w: p& G5.#define HOMING_INIT_LOCK         //回原点保护锁
8 n: E, r4 ]$ X% |6.#define HOMING_CYCLE_0 (1<<Z_AXIS)              // 第一步Z清除工作区。$ L9 T3 G7 ~6 h2 p, N
  #define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // 然后X,Y在同一时间。
% U) [5 p5 P( n( m7.#define N_HOMING_LOCATE_CYCLE 1 //回原点循环次数
$ J% i& ^- ^$ D* H8.#define HOMING_FORCE_SET_ORIGIN //取消这定义迫使Grbl总是在这时候位置设置机器原点尽管开关方向。& e" ]" N, [! n4 l
9.#define N_STARTUP_LINE 2 //块Grbl启动时执行的数量。
' |6 N6 q+ v% |! {/ S' S10.#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 协调或位置价值英寸! `( I5 }  D$ z% ^9 g9 i6 q
   #define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 协调在毫米或位置价值! _! J. u5 E2 K8 B
   #define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分钟的速度值( O0 r6 K, v& M8 S2 J
   #define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分钟8 }: d5 _2 P* C- e
   #define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 对浮点小数设置值: R+ e  E5 m) _3 q2 I
11.#define LIMITS_TWO_SWITCHES_ON_AXES //如果你的机器有两个极限开关连接在平行于一个轴,您需要启用这个特性+ Q: g4 Q- v0 p9 A+ g
12.#define USE_LINE_NUMBERS         //允许GRBL跟踪和报告gcode行号
  h5 [% w' E2 ]" m* E7 L13.#define REPORT_REALTIME_RATE //允许GRBL报告实时进给速率' T) \1 O  n1 h( e: Q
14.#define MESSAGE_PROBE_COORDINATES  //坐标通过Grbl $ #的打印参数?
/ K6 g# J# \) V9 m& K9 B! F15.#define SAFETY_DOOR_SPINDLE_DELAY 4000 //安全门主轴延时
9 e  y. Z3 |# F: i16.#define SAFETY_DOOR_COOLANT_DELAY 1000 //安全门冷却液延时
( H8 o: M' Q- f- i- q17.#define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS) //启用CoreXY运动学。
8 ?0 R$ f/ t8 f; D" ?6 U18.#define COREXY // Default disabled. Uncomment to enable.改变X和Y轴的运动原理8 r* U* m" ]! g- V
19.#define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.反转针销逻辑的控制命令
0 S6 h0 C  Y0 n, l2 A6 f/ r5 S- K20.#define INVERT_SPINDLE_ENABLE_PIN // 反转主轴使销从low-disabled
* R$ U- P4 k; D* n/ P' o4 p& N21.#define REPORT_CONTROL_PIN_STATE //启用控制销状态反馈状态报告。5 t5 a7 Z9 E# x  e! `9 T3 o/ B& w8 |
22.#define FORCE_INITIALIZATION_ALARM //启用和用户安装限位开关,Grbl将启动报警状态指示
& _: P' h! Z/ y2 c, r% C5 N( K23.#define REPORT_GUI_MODE // gui允许最小的报告反馈模式
; V; L+ c& K2 X/ h. l" c3 F24.#define ACCELERATION_TICKS_PER_SECOND 100 //加速度的时间分辨率管理子系统。1 c, A0 B3 }' d
25.#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING //自适应多轴步平滑(积累)是一种先进的功能 1 C" n" G- Y! d  y
26.#define MAX_STEP_RATE_HZ 30000 //设置最大一步速率可以写成Grbl设置  L  m3 }( w4 a( Q4 N! A. K
27.#define DISABLE_LIMIT_PIN_PULL_UP //以下选项禁用内部上拉电阻0 q/ Z; A# l' r2 J7 u! p1 b% S
28.#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS //设置哪个轴长度补偿应用的工具。假设轴总是与选择轴工具面向负方向+ f2 O5 @/ r; T+ Q4 b0 N! A; `1 ^
29.#define VARIABLE_SPINDLE //允许变量轴输出电压不同的转速值。6 Q6 u: v# P% |5 ^$ e0 S
30.#define SPINDLE_MAX_RPM 1000.0  // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.
8 d# v' K9 \! Y   #define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.( t% J6 ]" U6 b4 `
31.#define MINIMUM_SPINDLE_PWM 5 //使用的变量轴输出。这迫使PWM输出最小占空比时启用。
0 [& j6 m, Y4 }) `- P& p32.#define USE_SPINDLE_DIR_AS_ENABLE_PIN //主轴方向使能M4被删除
) c! _- E& z' w% ^& ~+ \2 a, \: ~33.#define REPORT_ECHO_LINE_RECEIVED //应该对所有正常线路送到Grbl
2 V+ T* q+ M/ [34.#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min) //最小规划师结速度。设置默认最小连接速度规划计划8 X( p/ w$ e' d( M% P/ q
35.#define MINIMUM_FEED_RATE 1.0 // (mm/min)//设置计划将允许的最小进给速率, [% g% w6 P" Y* ?3 e& ?, s7 M% C
36.#define N_ARC_CORRECTION 12 //弧生成迭代次数之前小角度近似精确的弧线轨迹
% G5 H" D4 l3 Q( k2 y+ @37.#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)//定义值设置机器ε截止来确定电弧是一个原点了?
5 j7 l. P* O8 w! s$ O9 t2 Y38.#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds) //延时增加表现在住。默认值设置为50毫秒3 T5 i6 A: i0 \+ s
39.#define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.9 q- ^9 V! ^' w/ w. M8 U/ X8 ?
40.#define BLOCK_BUFFER_SIZE 18  //线性运动规划师缓冲区的数量在任何给出时间计划: o; `6 K" J- v- k
41.#define SEGMENT_BUFFER_SIZE 6 //控制之间的中间段缓冲大小的步骤执行算法
* I3 B# Y4 g$ Z42.#define LINE_BUFFER_SIZE 80 //行执行串行输入流的缓冲区大小。
" j) }4 M* E7 s& Z+ C43.define RX_BUFFER_SIZE 128 //串行发送和接收缓冲区大小/ ]9 X2 K7 a5 o2 J3 c, `( w
44.#define TX_BUFFER_SIZE 64
; Q# X+ u4 \$ B: A* G45.#define ENABLE_XONXOFF        ////切换为串行通信发送流软件流控制。8 c" q: i! d! ^0 e9 W& ^; C. O
46.#define ENABLE_SOFTWARE_DEBOUNCE //一个简单的软件消除抖动特性硬限位开关。
( ^' `$ H: B" j9 g8 t# M0 Z" r0 p47.#define HARD_LIMIT_FORCE_STATE_CHECK        //Grbl检查硬限位开关的状态, V$ e1 Q* O& j8 U, v
48.// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:编译时错误检查的定义值:
; S: A$ e8 N' l6 I% j, I' ~
  [+ u" U' F0 W___________________________________________________________________________________________________5 z% T1 I7 B; F' e: |; j  z
/*5 l1 `3 ~9 L1 G  E
  config.h - compile time configuration+ V4 f  e/ O5 R2 |* h* p
  Part of Grbl# ^: }( Q0 @6 m. V6 R
% K, C# h: e$ `0 F
  Copyright (c) 2012-2015 Sungeun K. Jeon
' m, R1 L. j8 B  Copyright (c) 2009-2011 Simen Svale Skogsrud
3 w( i1 a- R) c4 H- j7 @' n) I, V
7 x* G3 n& T" e  Grbl is free software: you can redistribute it and/or modify' W  h# H4 \2 _0 e; Z8 ?3 [1 G
  it under the terms of the GNU General Public License as published by
! y  I4 k# N) U  B  the Free Software Foundation, either version 3 of the License, or/ k3 s2 a+ v6 u% T
  (at your option) any later version.
# b- r, r: \% D" N6 D6 Y( J0 @; {) v6 ?6 Z4 d; U  m" ~' N
  Grbl is distributed in the hope that it will be useful,( b0 X1 v% Z0 X& q6 {6 a
  but WITHOUT ANY WARRANTY; without even the implied warranty of8 E4 E% @; a+ v+ m# e$ v. t7 `
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the7 F; ^% T/ N3 D' A8 t- b$ D5 ?
  GNU General Public License for more details.
- {2 @# C" m& t4 I2 F8 u, g. m6 m5 ^% ]. r* h/ o3 N
  You should have received a copy of the GNU General Public License  o3 F6 A( i! p2 z* e
  along with Grbl.  If not, see <http://www.gnu.org/licenses/>.: n: F( [" r. R+ a% M
config.h  -编译时配置,Grbl的一部分
: @2 Q2 x: J3 ~/ s$ r$ p$ Q( d  j2 ]8 x/ D8 W: R+ p
版权(c)2012 - 2015 Sungeun K. Jeon! K( Z( s$ P/ M( Q; O, W" U
版权(c)2009 - 2011 Simen Svale Skogsrud2 L0 Z& d, d# V1 Y7 B

" I  ^/ C6 H0 FGrbl是免费软件:可以重新分配和/或修改
7 `4 e/ {4 }# k% yGNU通用公共许可证的条款下发布的自由软件基金会,版本3的许可,或(任您选)其后的版本。1 h, m9 V+ b2 l" x/ S

$ ]5 U3 {8 F0 k' [5 i: b) U; F" c: m8 rGrbl分布,希望这将是有用的,但是没有任何保证;没有即使的默示保证适销性或健身为特定目的。看到. V+ t! l- t  r! u+ G7 O! t
GNU通用公共许可证的更多细节。5 N+ B% e& ^* O

  r2 i+ M4 \' Q. q# `$ e- D7 {你应该收到了GNU通用公共许可证的副本
7 @" s+ S7 H  E; U连同Grbl。如果没有,看< http://www.gnu.org/licenses/ >。' v: o8 b$ }/ S: S# F

7 `) o/ o6 G4 e- [8 v6 f*/0 O& X2 @0 n/ J# {2 f# V4 b# c
  3 O" A4 r4 B& ^0 M" ~" W' z
// This file contains compile-time configurations for Grbl's internal system. For the most part,
2 y: H* S$ M5 A; ?7 X1 Z' I// users will not need to directly modify these, but they are here for specific needs, i.e.
8 D/ s3 \) z8 i, V+ o5 k// performance tuning or adjusting to non-typical machines.9 ]* m7 `3 G  |$ l, f4 _6 Y9 g
//这个文件包含编译时配置Grbl的内部系统。在大多数情况下,
; S5 z! k, m3 }! Y  ~: A! ^//用户不需要直接修改这些,但是他们在这里为特定的需求,即。
3 |# I; `) i8 z" [//性能调优或适应非典型的机器。0 v/ @, A( V: C1 \2 S! A6 w
% ]& s+ ~  f4 V/ ?' v
// IMPORTANT: Any changes here requires a full re-compiling of the source code to propagate them.; c. c$ l; X( P/ G1 \3 t
//重要:任何变化需要一个完整的基于源代码的传播。7 K6 l5 ~) E9 A& v

: ?* S% C' ?6 \6 ^8 Y2 T#ifndef config_h
' V( j& d9 G% ^) q( I#define config_h9 H* v4 ?$ O, F- G9 y5 t: J& j
#include "grbl.h" // For Arduino IDE compatibility.
9 L6 U; }- w( R9 \& ?- v1 O
' Z/ o' v/ A; M4 \// Default settings. Used when resetting EEPROM. Change to desired name in defaults.h
; s( N3 T) C. n// 默认设置。在重置eepm时使用。在defaults.h改变想要的名字6 k' O, K+ @6 {4 C
0 D0 a1 i5 U* `8 J' h: k/ ^( d
#define DEFAULTS_GENERIC
2 L5 J$ W5 O1 `( U- B4 x, @" c- d
1 u! \- `, i) R9 v  \// Serial baud rate
; c" |' I" P' F# j& r; m' O#define BAUD_RATE 115200                //配置串口波特率115200
0 }3 D4 p. k! u0 e
; m" s0 W* d1 ?/ F// Default cpu mappings. Grbl officially supports the Arduino Uno only. Other processor types
8 C/ h+ k: M6 L$ y9 K7 w( ?// may exist from user-supplied templates or directly user-defined in cpu_map.h
9 `% d0 Z2 W+ E! V$ J//默认cpu映射。Grbl正式支持Arduino Uno。其他类型的处理器可能存在cpu_map.h直接从用户提供的模板或用户定义的/ Q8 X1 g' x4 ]
0 v/ I; l  k* F+ X: k
#define CPU_MAP_ATMEGA328P // Arduino Uno CPU5 W1 B: U4 V9 W6 `4 f
6 B8 W+ G0 [' u
// Define realtime command special characters. These characters are 'picked-off' directly from the! L$ o/ h1 L% }, c8 j
// serial read data stream and are not passed to the grbl line execution parser. Select characters& G/ v, x" w* Q
// that do not and must not exist in the streamed g-code program. ASCII control characters may be
- Z' \, r9 P, b& Q// used, if they are available per user setup. Also, extended ASCII codes (>127), which are never in 4 _# Q& z2 x4 ]+ T) x
// g-code programs, maybe selected for interface programs.4 Z9 _  G0 p8 F2 i  q7 q0 R6 T
// NOTE: If changed, manually update help message in report.c.
6 p0 }8 [. Z  ]! g: o! e
: g6 N$ @9 S+ R& C& @  o* K//定义实时命令特殊字符。这些字符是直接从“各个击破”串口读取数据流并没有传递到grbl行执行解析器。选择角色8 Q" U, W. l9 O" i3 N
//不,不能存在于程序流刀位点。ASCII控制字符& @5 C: j5 g% A+ K0 M2 J
//使用,如果他们是可用的每个用户设置。同时,扩展的ASCII码(> 127),从来没有
# |" J  Q& `6 s& P* ?$ |* V//刀位点的程序,也许选择界面程序。3 f4 K- D2 B1 y! G. I
//注意:如果改变,手动更新report.c帮助信息。/ C& r+ u- n4 E% O
, |- s* W; S' |& r! r1 `% \$ r
#define CMD_STATUS_REPORT '?'' D4 ]3 R/ A2 }3 z
#define CMD_FEED_HOLD '!'! L! K( g0 S1 P2 q1 H
#define CMD_CYCLE_START '~'
' [: l; D" P( F) j1 k+ _5 x#define CMD_RESET 0x18 // ctrl-x.
' f# ?  u2 h" S$ Y) f+ K#define CMD_SAFETY_DOOR '@'9 d& z8 m. ?8 f
1 X7 p3 a6 F, |
// If homing is enabled, homing init lock sets Grbl into an alarm state upon power up. This forces
4 ?" b2 \& |& P1 O) {// the user to perform the homing cycle (or override the locks) before doing anything else. This is
8 O# T! _7 D% r// mainly a safety feature to remind the user to home, since position is unknown to Grbl.
, c$ B% ^( o- U& X- B+ y7 F( u( i/ H5 M4 ~+ z  g
//如果启用了回原点,导航初始化锁集Grbl进入警报状态启动。这就迫使
7 i/ u. F, E0 u4 f. @1 N8 f//用户执行归航周期(或覆盖锁)在做任何其他事情之前。这是
1 Q: `/ J0 K% t& S& X//主要安全功能,提醒用户家里,因为Grbl位置是未知的。
- [0 B4 G8 M" ^8 ]8 y9 w5 ~7 \& X0 j) u; x, ]
#define HOMING_INIT_LOCK // Comment to disable0 @! ^6 A. W* j3 b
+ k: U1 o. F& H+ y" Y
// Define the homing cycle patterns with bitmasks. The homing cycle first performs a search mode" _( `. C' b) M; C
// to quickly engage the limit switches, followed by a slower locate mode, and finished by a short
, F/ b; o0 Y0 j( J: R// pull-off motion to disengage the limit switches. The following HOMING_CYCLE_x defines are executed $ N7 H* T& P& |/ R( B( d: f
// in order starting with suffix 0 and completes the homing routine for the specified-axes only. If! D. S, R! i3 I7 v
// an axis is omitted from the defines, it will not home, nor will the system update its position.
- i4 ]3 R" ?9 u// Meaning that this allows for users with non-standard cartesian machines, such as a lathe (x then z,
/ y) j% W/ S$ o4 A; V- L// with no y), to configure the homing cycle behavior to their needs. 0 ^" i7 L# a3 W" M2 a+ I: z' \
// NOTE: The homing cycle is designed to allow sharing of limit pins, if the axes are not in the same
* P' f3 Q1 e3 c4 \// cycle, but this requires some pin settings changes in cpu_map.h file. For example, the default homing: ^' x- O, ^+ u0 f0 X3 `! u& \2 _
// cycle can share the Z limit pin with either X or Y limit pins, since they are on different cycles.3 J4 E# S* R6 q) S- @/ y
// By sharing a pin, this frees up a precious IO pin for other purposes. In theory, all axes limit pins6 e) {& z! D: U. D6 \; h
// may be reduced to one pin, if all axes are homed with seperate cycles, or vice versa, all three axes
( [  O4 k) s* p' R, r4 B0 Y# o# L// on separate pin, but homed in one cycle. Also, it should be noted that the function of hard limits
1 \  f* _7 r- b6 |1 S4 v/ v3 ^// will not be affected by pin sharing.
* O" ?8 j1 x  T' |: v6 A5 i//定义导航循环模式的位掩码。归航周期首先执行一个搜索模式
7 B( e- r* \7 Q$ y//快速进行限位开关,其次是较慢的定位模式,完成了由一个短
$ X7 x; N+ g7 _//拖出运动脱离限位开关。以下HOMING_CYCLE_x定义执行
: ~" V& \1 o. ]$ [, l' P' E//为了与后缀0开始并完成specified-axes只寻的例程。如果
4 v/ t$ H3 }( m( `8 s//定义省略一个轴,它会不在家,也不会系统更新它的位置。
6 n! q9 h9 @$ P5 t( C( C& d//意义,这允许用户与非标准笛卡尔的机器,比如车床(x,z,
3 V% m8 o0 Y) c% E% D( `# ^# o2 Z//没有y),配置导航循环行为对他们的需求。0 _/ k5 e5 V2 T# {7 c! B  O$ \
//注意:归航周期允许共享限制针,如果轴不相同
* Z# D0 T5 k5 H1 I( h& f+ ]//循环,但这需要一些销设置cpu_map的变化。h文件。例如,默认的导航+ H5 y" X4 @$ {- h$ p
//循环可以分享Z限位销X或Y限制针,因为它们是在不同的周期。1 B2 K! T  K- ?7 k! |
//通过共享一个销,这腾出宝贵的IO销用于其他目的。从理论上讲,所有轴限制别针2 U5 ^6 b1 I7 z: }
//可能会减少到一个销,如果所有轴与分离周期居住的地方,反之亦然,所有三个轴
7 i5 M' g, @& i2 r' y//在不同销,但这时候一个周期。同时,应该注意的是,硬限制的功能  d0 G. S: C& m3 {9 a
//将不会影响销共享。
; p" U: U, ~2 Y! W//注意:默认设置为一个传统的硬件数控机器。z轴首次明确,其次是X和Y。. v+ b/ u& n- E4 P. S; O

! ]. L" w- r2 z// NOTE: Defaults are set for a traditional 3-axis CNC machine. Z-axis first to clear, followed by X & Y.
+ H9 Y" M# S* m; B9 Q  B3 R#define HOMING_CYCLE_0 (1<<Z_AXIS)                // REQUIRED: First move Z to clear workspace. 第一步Z清除工作区。
3 c; l* w6 P) F; j#define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // OPTIONAL: Then move X,Y at the same time.然后X,Y在同一时间。
$ H5 R9 l. u4 j/ c2 U! E' ^// #define HOMING_CYCLE_2                         // OPTIONAL: Uncomment and add axes mask to enable2 p  B8 s( |; N. e$ S' v
7 ~5 {! g3 s" Z) O
// Number of homing cycles performed after when the machine initially jogs to limit switches.6 g" m, J5 w0 N) t) h: j
// This help in preventing overshoot and should improve repeatability. This value should be one or
3 O- G( |3 Q5 E( ]// greater.  R0 L% W2 C, x( g% T2 Y
//执行回原点循环次数后,当机器最初慢跑限位开关。这个帮助防止过度,应该提高重复性。这个值应该是一个或大。3 x  {2 Z" r0 v4 o$ g% j! p

; \! u1 n8 N8 P#define N_HOMING_LOCATE_CYCLE 1 // Integer (1-128)! i* D; h! T4 {# i4 t$ R
8 X6 g7 P$ f# z$ j# T
// After homing, Grbl will set by default the entire machine space into negative space, as is typical
* a/ f2 Q: q! V// for professional CNC machines, regardless of where the limit switches are located. Uncomment this
! l; O2 k: G8 W: T! c, j// define to force Grbl to always set the machine origin at the homed location despite switch orientation./ b- `7 F, y9 ?/ k6 C  K% C4 `3 G

* J, v2 i. p1 m  w- k//导航后,默认Grbl将整个机器空间留白,是典型的专业数控机器,不管限位开关所在的地方。1 u+ e3 d( R# n9 s9 ^
//取消这定义迫使Grbl总是在这时候位置设置机器原点尽管开关方向。
. n$ ]. g) W% g8 f4 f
, b/ I) Y& b# Q: i- Y8 G// #define HOMING_FORCE_SET_ORIGIN // Uncomment to enable.
. I' w+ {- A2 d
/ p' {6 q6 R2 k4 `! n
4 f, W! N" N# w6 e, V6 w// Number of blocks Grbl executes upon startup. These blocks are stored in EEPROM, where the size6 d, I. U% u) r
// and addresses are defined in settings.h. With the current settings, up to 2 startup blocks may
; x9 X& A9 M* M// be stored and executed in order. These startup blocks would typically be used to set the g-code0 s0 b' C8 y* {; F6 ]6 u. I: [
// parser state depending on user preferences.
8 }5 Q7 ]2 Y( B+ P* h/ M/ [
! d0 A  A* T! G# h+ P//块Grbl启动时执行的数量。这些块存储在eepm,大小
& S' i; ]5 p  s- |- m' w//和地址在settings.h中定义。与当前设置,可能2启动块
( B. J" F$ ~4 _8 m//存储和执行。这些启动块通常被用来设置刀位点
! u+ q# G9 B/ c1 b//解析器的状态取决于用户首选项。
/ k$ t; v! u5 ]% G, P  O- W( R0 Z: J6 z) l( Z$ _
#define N_STARTUP_LINE 2 // Integer (1-2)1 ?. W' Q  z; D. t$ ]
  |5 y% J  l1 b5 a5 D
// Number of floating decimal points printed by Grbl for certain value types. These settings are 4 \$ f5 Q' ?' M0 j2 C* _4 V7 q
// determined by realistic and commonly observed values in CNC machines. For example, position. t1 j; s+ ^3 P+ O' x0 n; z
// values cannot be less than 0.001mm or 0.0001in, because machines can not be physically more: U6 {- Q' J& X( [8 K  w' `6 e: \4 Y
// precise this. So, there is likely no need to change these, but you can if you need to here.
6 _* T: x" q! ^" d// NOTE: Must be an integer value from 0 to ~4. More than 4 may exhibit round-off errors.$ X; c, Y* J* m& N2 v

! J8 O" ^  ]5 Y( R// Grbl浮动小数点的数字印刷的特定的值类型。这些设置是
4 N7 ?1 P# L% S4 k//一般由现实和观测值在数控机器。例如,位置2 s1 G( Q" Z" r& t9 W
//值不能小于0.001毫米或0.0001,因为机器不能身体更多
( V3 ]0 S/ a$ {( m' z8 k//精确。因此,有可能不需要改变这些,但你可以在这里如果你需要。
/ l" a& n% t/ B4 q//注意:必须是一个整数值从0 ~ 4。超过4可能出现舍入错误。4 |$ w) e- f1 [0 A' N

, b7 C6 g5 R6 l  s3 d5 h#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 协调或位置价值英寸
" S' e; E- U5 m& V4 \( }  m#define N_DECIMAL_COORDVALUE_MM   3 // Coordinate or position value in mm 协调在毫米或位置价值  t9 X$ h1 f% u
#define N_DECIMAL_RATEVALUE_INCH  1 // Rate or velocity value in in/min 率或/分钟的速度值( g/ t/ D, M8 B7 r1 B- r
#define N_DECIMAL_RATEVALUE_MM    0 // Rate or velocity value in mm/min 速率或速度值在毫米/分钟
( E+ s+ h- E  h6 X  m#define N_DECIMAL_SETTINGVALUE    3 // Decimals for floating point setting values 对浮点小数设置值' H" G8 Q) k( a: e7 q4 @2 D

7 M' n  O6 O  F; {+ h// If your machine has two limits switches wired in parallel to one axis, you will need to enable: D0 j/ [0 A: u) F# P" C0 R
// this feature. Since the two switches are sharing a single pin, there is no way for Grbl to tell
! a! P2 p- F9 K// which one is enabled. This option only effects homing, where if a limit is engaged, Grbl will
. T; q: C9 ?# t4 F8 o// alarm out and force the user to manually disengage the limit switch. Otherwise, if you have one# o, _9 d6 \  E6 J5 S; y
// limit switch for each axis, don't enable this option. By keeping it disabled, you can perform a
) C% [# s! N( m+ R7 X2 y// homing cycle while on the limit switch and not have to move the machine off of it.! a& b0 u; n* ]" ]. c
  f" U. L3 l& M9 q2 P
//如果你的机器有两个极限开关连接在平行于一个轴,您需要启用
: [% x6 r  E/ G- H' P: g# M//这个特性。自从两个交换机共享一个销,没有办法Grbl告诉
4 y+ o2 l/ |2 R' S//启用哪一个。此选项仅影响归航,如果限制,Grbl意志  {% x! y. |8 B) b8 ]1 w) \9 {
//报警,迫使用户手动松开限位开关。否则,如果你有一个3 @" q5 w8 w1 M) \
//为每个轴限位开关,不启用该选项。通过保持禁用,您可以执行
  p( |  |( P# a$ G6 V//导航循环在限位开关并没有将这台机器。
' J/ ~$ ]9 S; y4 c2 ?; n% X- _! g$ |0 n. D* X+ S
// #define LIMITS_TWO_SWITCHES_ON_AXES
& N9 l9 i6 I6 P2 R" Q+ _" \6 d
1 z- J$ i+ G) I+ z// Allows GRBL to track and report gcode line numbers.  Enabling this means that the planning buffer
% L; L) p- d# P$ |5 ^  R// goes from 18 or 16 to make room for the additional line number data in the plan_block_t struct# V) F" w3 P1 ?$ n2 s& p1 s7 R
& s, m8 V7 r9 I6 L# @4 g' n
//允许GRBL跟踪和报告gcode行号。使这意味着计划缓冲从18岁或16岁,为额外的行号plan_block_t结构中的数据
1 z5 A4 l6 F, ]  {+ B  w+ w) R2 p/ t& q6 ^
// #define USE_LINE_NUMBERS // Disabled by default. Uncomment to enable.1 ?4 `9 g% T$ B
5 P) m5 q2 }' \7 {6 o. v+ p
// Allows GRBL to report the real-time feed rate.  Enabling this means that GRBL will be reporting more
3 Q# l$ G& [/ J% }/ {// data with each status update.
6 T/ P# V& [% u- _5 L# z, F// NOTE: This is experimental and doesn't quite work 100%. Maybe fixed or refactored later.7 A5 B9 _9 n- A. s
//允许GRBL报告实时进给速率。使这意味着GRBL将报告数据和状态更新。8 k: t) L5 g8 Y
//注意:这是实验和100%没有工作。也许以后固定或重构。0 F- u# Q0 ?! v! H& x" r  D
1 d6 [$ R" P; k7 U; B: d
// #define REPORT_REALTIME_RATE // Disabled by default. Uncomment to enable.  j) H6 _+ ^1 k1 {6 D
- o" M$ U' P9 j8 Y: j: [# M1 s
// Upon a successful probe cycle, this option provides immediately feedback of the probe coordinates( l% C0 ]! V5 [: q
// through an automatically generated message. If disabled, users can still access the last probe) h& Z! f  I6 ]0 p% c' j; o4 M$ L* k# u
// coordinates through Grbl '$#' print parameters.
7 \! z1 r' B# u( Z/ L& b//在一个成功的调查周期,这个选项提供立即反馈的探测器坐标
" x/ a" v# {7 T8 F$ o; h6 r//通过一个自动生成的消息。如果禁用,用户仍然能够访问调查4 N4 G* b1 A6 y0 {$ g
//坐标通过Grbl $ #的打印参数。+ ?$ Z3 d8 w% p
/ r/ x% m, d  n- u
#define MESSAGE_PROBE_COORDINATES // Enabled by default. Comment to disable.
. ]5 N) @* a8 _9 y4 b# k
% D: l* N9 J3 Z// Enables a second coolant control pin via the mist coolant g-code command M7 on the Arduino Uno( Y& \" ?# w1 j9 @. W4 d6 w: }
// analog pin 5. Only use this option if you require a second coolant control pin.
  ]( k9 H/ x+ u( E# j5 p4 k// NOTE: The M8 flood coolant control pin on analog pin 4 will still be functional regardless.3 I5 \$ \. c* S7 b0 E
// #define ENABLE_M7 // Disabled by default. Uncomment to enable.% U# \$ l5 C# r) Y" Y
# Q  X+ b- G, F! Q2 a
// This option causes the feed hold input to act as a safety door switch. A safety door, when triggered,; s9 T1 m6 N& t
// immediately forces a feed hold and then safely de-energizes the machine. Resuming is blocked until
$ o& R3 q3 T# z/ G0 s0 Z// the safety door is re-engaged. When it is, Grbl will re-energize the machine and then resume on the& ]3 Z3 }/ ]6 h8 @
// previous tool path, as if nothing happened.& C# r( |, h5 R# `9 h
// #define ENABLE_SAFETY_DOOR_INPUT_PIN // Default disabled. Uncomment to enable.
/ r4 _" r9 n. a. ~% Y$ j; E
7 U8 L( m3 h3 _" o9 d$ R- b6 R// After the safety door switch has been toggled and restored, this setting sets the power-up delay  w1 O* [7 L* Y$ N7 J' m  I8 J
// between restoring the spindle and coolant and resuming the cycle.
( P5 G* x! t, P, a  c3 Y( o// NOTE: Delay value is defined in milliseconds from zero to 65,535.
/ ?) }+ S, \$ X: j( r" v7 z
& Q' Q/ Q/ z' `% p" V1 P//定义导航循环模式的位掩码。归航周期首先执行一个搜索模式
6 D. o& Q/ `. e7 a' }; v; D& h//快速进行限位开关,其次是较慢的定位模式,完成了由一个短
/ q- @2 c& s. }* z- {//拖出运动脱离限位开关。以下HOMING_CYCLE_x定义执行
3 i' d8 Q) ]& c) N) w//为了与后缀0开始并完成specified-axes只寻的例程。如果
! K3 z$ C; F  q) h//定义省略一个轴,它会不在家,也不会系统更新它的位置。: \. X0 {* u1 j; E
//意义,这允许用户与非标准笛卡尔的机器,比如车床(x,z,9 o3 @# Z6 ~$ V+ ?& }8 T7 @% i9 V( F( |
//没有y),配置导航循环行为对他们的需求。
$ u; c, |/ d- [1 t# I7 I  N//注意:归航周期允许共享限制针,如果轴不相同
5 d& I/ C2 P! L; W+ f- `- x//循环,但这需要一些销设置cpu_map的变化。h文件。例如,默认的导航
) a0 M( f" p' }# a5 I% U  K+ I//循环可以分享Z限位销X或Y限制针,因为它们是在不同的周期。; y: C, O) p/ U% ?
//通过共享一个销,这腾出宝贵的IO销用于其他目的。从理论上讲,所有轴限制别针# A3 I& r" T5 n: L; C( V
//可能会减少到一个销,如果所有轴与分离周期居住的地方,反之亦然,所有三个轴8 x9 _& _2 M( N0 g+ p, O" P' q: w
//在不同销,但这时候一个周期。同时,应该注意的是,硬限制的功能9 D& a& V; M9 p- ^2 O. D
//将不会影响销共享。
0 Y: B" i# ~9 D; X% y7 x/ n$ j% ?: _//注意:默认设置为一个传统的硬件数控机器。z轴首次明确,其次是X和Y。1 D) F" r* H! o8 Y8 _
! j, ~" Q3 c( e& S! Z( }

: K% ?' S! {9 L6 D7 A" H#define SAFETY_DOOR_SPINDLE_DELAY 4000; m! H9 o7 g1 E* U
#define SAFETY_DOOR_COOLANT_DELAY 1000! D' ?) e+ N4 y' c4 c2 h

- ?) s8 ?3 \" \1 n// Enable CoreXY kinematics. Use ONLY with CoreXY machines.
) d) ?) x8 S3 M// IMPORTANT: If homing is enabled, you must reconfigure the homing cycle #defines above to
$ V8 p) T- W: V//启用CoreXY运动学。只使用与CoreXY机器。! r/ Y% y. g" r
//重要:如果启用了自动寻的,你必须重新配置导航循环#定义上面
' v, N7 i1 Y- `) l  t' n& F; P  e
. y6 o- Y! A* B/ z( C// #define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS)
! s7 e. [& I, m0 R5 p
/ m3 D. a% U! l* Z8 H1 o0 g0 v// NOTE: This configuration option alters the motion of the X and Y axes to principle of operation
+ P1 W1 N, i  g# H// defined at (http://corexy.com/theory.html). Motors are assumed to positioned and wired exactly as
+ s0 c. h" K- u4 f4 b& B$ ^$ |// described, if not, motions may move in strange directions. Grbl assumes the CoreXY A and B motors& Z- @' J8 I( u9 y2 o/ g& c
// have the same steps per mm internally.8 e# k/ m* E  X: L
//注意:这种配置选项改变X和Y轴的运动原理,操作
3 r2 A- \- A) C( L//定义(http://corexy.com/theory.html)。汽车被认为定位和连接一样7 ?9 ]* q* S1 H9 k) x" U
//描述,如果没有,运动可能会奇怪的方向移动。A和B Grbl假设CoreXY马达! z. a/ T' U) t3 c/ D5 X
//每毫米内部有相同的步骤。
5 t8 E- r# U7 b- S3 T8 u6 K
5 D) x6 j- t3 I- a4 s+ `6 D5 l5 k// #define COREXY // Default disabled. Uncomment to enable.
2 x" \5 w% M0 ?3 }
: B, N4 C/ r) Q1 ?// Inverts pin logic of the control command pins. This essentially means when this option is enabled
6 ]* a/ X9 }! y  [// you can use normally-closed switches, rather than the default normally-open switches.0 }$ O, s0 b+ P; W# {& Y9 U- `
// NOTE: Will eventually be added to Grbl settings in v1.0.
' v/ q" T( B; [9 w# f) w//反转针销逻辑的控制命令。这实质上意味着当启用这个选项
$ a' [+ R8 c  N* j, t//可以使用闭合开关,而不是默认的常开开关。
- ?- f0 v5 F; T; L! z//注意:最终将被添加到在v1.0 Grbl设置。
+ v& O' b" o  n8 n- S/ U2 g( w; s3 m  B2 H  J9 f+ @% X
// #define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.6 k* I: n1 W5 `
! L2 ]6 b! S, `$ G* ^4 o
// Inverts the spindle enable pin from low-disabled/high-enabled to low-enabled/high-disabled. Useful
2 b& R6 p) k  N* g// for some pre-built electronic boards.0 O; [4 V" U% B3 d# f5 l
// NOTE: If VARIABLE_SPINDLE is enabled(default), this option has no effect as the PWM output and
# l0 q% |3 ~5 B// spindle enable are combined to one pin. If you need both this option and spindle speed PWM,
0 H* h  b/ O; Q' ]3 K+ m1 z3 E/ k7 h// uncomment the config option USE_SPINDLE_DIR_AS_ENABLE_PIN below.; t. ?% i6 v5 a# {( b1 `2 Q, c+ `
//反转主轴使销从low-disabled / high-enabled low-enabled / high-disabled。有用的
5 G* V) m+ j. D" N4 e; g, I//预构建的电子板。
/ [9 X; i6 s8 V3 |) r4 \//注意:如果启用了VARIABLE_SPINDLE(默认),这个选项作为PWM输出并没有影响+ J1 x6 K- m7 E. S: E- E5 L+ A' X& a, ~
//销轴使结合。如果你需要这个选项和主轴转速PWM,# h) V5 `0 P& z7 Z$ d
//取消注释以下配置选项USE_SPINDLE_DIR_AS_ENABLE_PIN
  l4 ^3 [5 x% B; M8 R: Q
# Z: t6 e, u0 X// #define INVERT_SPINDLE_ENABLE_PIN // Default disabled. Uncomment to enable.
% l) k5 z1 P3 i, Y2 C; q8 f8 m8 c8 ?
7 y$ `: O6 I1 j. H( d3 z// Enable control pin states feedback in status reports. The data is presented as simple binary of
0 U  h- c. J* o* [: ~' P, r// the control pin port (0 (low) or 1(high)), masked to show only the input pins. Non-control pins on the + F9 @( ~' D" \- W1 N8 t, z
// port will always show a 0 value. See cpu_map.h for the pin bitmap. As with the limit pin reporting,8 a- P" O0 N& l2 F$ T4 q
// we do not recommend keeping this option enabled. Try to only use this for setting up a new CNC.) X3 L( R3 o( u1 e0 t( t* q
//启用控制销状态反馈状态报告。作为简单的二进制数据
6 P/ K( W; G0 X, A0 ^//控制针端口(0(低)或1(高)),蒙面,只显示输入插脚。非控制性针上: |! L6 q' u( r
//端口总是显示0值。看到cpu_map。针位图h。与限制销报告,
4 [7 R+ V' J& X* ?; W  h( ?//我们不推荐保持启用这个选项。尽量只使用这个设置一个新的数控。$ i8 X. j3 C# m+ f3 o

, c. j1 G) `  k: z' L/ K// #define REPORT_CONTROL_PIN_STATE // Default disabled. Uncomment to enable.9 }. U7 r( X* V: J+ m( d, \
9 k/ b' h6 E8 f( P, Q# q
// When Grbl powers-cycles or is hard reset with the Arduino reset button, Grbl boots up with no ALARM; x: m- k* a7 [$ ~0 F$ y& E+ }1 v
// by default. This is to make it as simple as possible for new users to start using Grbl. When homing9 U, C/ P, w! f9 B9 ~# P  |) D2 G
// is enabled and a user has installed limit switches, Grbl will boot up in an ALARM state to indicate
' w; U5 Q: r* P0 T! i// Grbl doesn't know its position and to force the user to home before proceeding. This option forces2 t4 ~* ]! q2 e0 H. O: [0 L+ [
// Grbl to always initialize into an ALARM state regardless of homing or not. This option is more for5 _# n& A' r1 d" R' w. V
// OEMs and LinuxCNC users that would like this power-cycle behavior.
$ Q' j/ D4 o& ~/ m8 F* C% Q/ d//当Grbl powers-cycles还是硬重置Arduino复位按钮,Grbl启动没有报警
6 a5 W9 K, D- \1 x# P//默认情况下。这是为了让新用户尽可能简单使用Grbl开始。当归航
8 |$ W- L+ M' v5 K& T8 ~. X1 B$ ]0 Q//启用和用户安装限位开关,Grbl将启动报警状态指示7 S+ [, l2 o3 a4 }' p
// Grbl不知道它的位置,迫使用户在继续之前回家。这个选项部队
/ K1 v5 ^7 V. K, l7 x3 [// Grbl总是初始化进入警报状态不管归航。这个选项是更多
( L+ G3 B) c6 y' O6 H  W1 j//原始设备制造商和LinuxCNC用户这样的控制行为。" c1 K4 c, i% r8 h

! u3 [5 s2 o/ s* [6 }1 I2 {+ F: C// #define FORCE_INITIALIZATION_ALARM // Default disabled. Uncomment to enable.% v% H  |/ e0 _
, E( i1 `# ?) V
// ---------------------------------------------------------------------------------------, Y1 G; |7 g5 l$ M) k+ S8 v. i1 r
// ADVANCED CONFIGURATION OPTIONS://高级配置选项:
; l; v7 C6 j/ P2 Z% u: I, x
* L* u, o( z1 w3 m; E. x* O9 Z// Enables minimal reporting feedback mode for GUIs, where human-readable strings are not as important.
) O: }" X+ i( |( K; d3 \+ @// This saves nearly 2KB of flash space and may allow enough space to install other/future features.
0 U; p3 @- ^+ f6 c* C// GUIs will need to install a look-up table for the error-codes that Grbl sends back in their place.  X6 p+ b8 A# |$ }0 q
// NOTE: This feature is new and experimental. Make sure the GUI you are using supports this mode.+ |1 [/ p* |) j% x: [; L1 Q) q

* Y; Y) x% D3 p2 W" [// gui允许最小的报告反馈模式,人类可读的字符串在哪里不重要。
; [; @$ m, I2 N4 J//这个节省近2 kb的闪存空间,允许足够的空间来安装其他/未来的功能。
) k9 T9 d, r0 Q2 Y+ B// gui需要安装一个查找表的错误代码Grbl发回。
6 }8 P+ N6 |" @/ l0 G: I. K//注意:此功能是新的和实验。确保您使用的GUI支持这种模式。
) q5 m2 W9 o- y* ~) q& q/ j
: c3 h+ a# X! \" l: |+ ]// #define REPORT_GUI_MODE // Default disabled. Uncomment to enable.
! q4 d9 R2 U* Y; j! |5 Z, n, p: x2 V" s
// The temporal resolution of the acceleration management subsystem. A higher number gives smoother
8 n0 q! f8 y7 }" a// acceleration, particularly noticeable on machines that run at very high feedrates, but may negatively
) v; l2 |  U# f8 E# y) `+ d- y( _// impact performance. The correct value for this parameter is machine dependent, so it's advised to
1 U, k  u# E' ^) y& u  O) R: p// set this only as high as needed. Approximate successful values can widely range from 50 to 200 or more.; D+ X9 n! [. U9 t
// NOTE: Changing this value also changes the execution time of a segment in the step segment buffer. 9 f9 s9 ?; l) `4 P  @* b
// When increasing this value, this stores less overall time in the segment buffer and vice versa. Make
) ]" }2 g# H0 c" E3 i4 E// certain the step segment buffer is increased/decreased to account for these changes.
8 j) _, [' u- R//加速度的时间分辨率管理子系统。更多更平稳
, e  G* B1 u: H( M( l3 [5 B//加速度,特别明显的机器上,运行在非常高的进料速度,但可能负面
6 F$ J+ e5 ^+ V7 [# ]. W6 u//影响性能。正确的值为这个参数是依赖于机器的,所以建议
# v$ D) ^4 s5 Q* Y& l( z# L//这只设置为高。近似成功的价值观可以广泛的范围从50到200或者更多。9 G1 l) L5 Z$ R' v
//注意:改变这个值也变化的部分步骤的执行时间缓冲。6 O5 n' l8 J' B. B& ^) |+ _# o
//增加这个值时,这个商店部分缓冲区的总时间减少,反之亦然。使: p. G4 B# h/ [/ V6 \
//特定步骤段缓冲是考虑这些变化增加/减少。- c& w& O, w6 `" G6 y% v7 |
' k* h* _; k5 x) [5 F) o
#define ACCELERATION_TICKS_PER_SECOND 100  //加速度的时间分辨率管理子系统。更多更平稳/ U$ J& b, b. U3 E* [) i2 l4 w

5 ~  i; x  q/ \. r// Adaptive Multi-Axis Step Smoothing (AMASS) is an advanced feature that does what its name implies, ! B8 `, }0 |; Z6 O! W
// smoothing the stepping of multi-axis motions. This feature smooths motion particularly at low step  U. G8 {: A. s
// frequencies below 10kHz, where the aliasing between axes of multi-axis motions can cause audible ) j9 ~5 X* T5 k4 X
// noise and shake your machine. At even lower step frequencies, AMASS adapts and provides even better# }# X$ \* ]0 ?6 V
// step smoothing. See stepper.c for more details on the AMASS system works.8 t- k; e3 |+ _- r1 C! e6 Y
//自适应多轴步平滑(积累)是一种先进的功能,它的名字所暗示的那样,
. f, }4 w7 S0 R3 q1 d' B' D5 l* k2 c//平滑的多轴步进运动。这个特性平滑运动尤其是在低一步
& T! s' S" ^) L5 ?% `5 Y# H6 T//频率低于10 khz,轴之间的混叠的多轴运动可能导致音响; B/ \' H' O/ Q2 q5 D* ~
//噪音和震动你的机器。在更低的频率步,积累适应并提供更好9 N. h1 H& ^. I6 U
//步骤平滑。看到步进。c更多细节的积累系统的工作原理。- V0 N  K! H1 [& P! G2 D0 Z

8 F& Z, C3 w3 d2 u: ]( }3 V3 L5 E#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING  // Default enabled. Comment to disable.//自适应多轴步平滑
6 U% C# v& l1 m3 g; M; S! j/ G4 s: g
// Sets the maximum step rate allowed to be written as a Grbl setting. This option enables an error 1 |- u* a, j9 u* D0 @' e; A
// check in the settings module to prevent settings values that will exceed this limitation. The maximum) J( x9 a5 B8 l8 n9 J, Z
// step rate is strictly limited by the CPU speed and will change if something other than an AVR running3 S! q3 a+ A" k9 {( m
// at 16MHz is used.
- H  K# k% ^% ?! G7 ~+ @) ^8 O8 L// NOTE: For now disabled, will enable if flash space permits.
8 t" t) o9 A' A8 n//设置最大一步速率可以写成Grbl设置。这个选项可以使一个错误
, E/ p8 S/ q% v//设置模块中检查,防止设置值将超过这个限制。的最大/ w- B$ Q5 \7 U; G
//步骤严格限制的CPU速度也会改变如果是其他AVR运行: U7 ?2 _* W( G4 h
//使用16兆赫。
9 R" T8 M6 p9 a& K3 S; C3 g1 R//注意:现在残疾,将使如果flash空间许可。
6 j9 j0 s0 g. R  t1 m2 {7 y& i; v1 _
// #define MAX_STEP_RATE_HZ 30000 // Hz 设置最大一步速率
: G& `% V6 a, m, a" a- g" z% p1 j5 t
/ G& o, y. b6 {; v$ O8 d// By default, Grbl sets all input pins to normal-high operation with their internal pull-up resistors
5 S' W4 `# ~: G, m4 x( C% W+ d( ^// enabled. This simplifies the wiring for users by requiring only a switch connected to ground, 9 |1 |1 W) w8 J: l7 p
// although its recommended that users take the extra step of wiring in low-pass filter to reduce: R. ]# D9 Q4 c4 W7 ?7 \
// electrical noise detected by the pin. If the user inverts the pin in Grbl settings, this just flips2 J4 X' P5 D' v) C. O/ z& L0 O+ s' Y
// which high or low reading indicates an active signal. In normal operation, this means the user
: [8 R. X- O6 B// needs to connect a normal-open switch, but if inverted, this means the user should connect a 4 H8 T  S# G' u0 U. O- F
// normal-closed switch. 3 o: v+ P% m( O0 N) N8 n4 G8 j
// The following options disable the internal pull-up resistors, sets the pins to a normal-low 4 P' n& i' s4 g
// operation, and switches must be now connect to Vcc instead of ground. This also flips the meaning 4 I; I; \5 f: _% R
// of the invert pin Grbl setting, where an inverted setting now means the user should connect a
4 q- O8 h- i4 R+ h: w+ m: h% @// normal-open switch and vice versa.* C2 ~3 F) ^- ?2 |* b; D0 L- s
// NOTE: All pins associated with the feature are disabled, i.e. XYZ limit pins, not individual axes.
* T( U# W& {; s" h) y/ D) c& @, O  C// WARNING: When the pull-ups are disabled, this requires additional wiring with pull-down resistors!0 _  k( R' \1 Y0 \* D2 W* V
//默认情况下,Grbl所有输入引脚设置为正常高操作的内部上拉电阻
  I- Z! D* m9 \//启用。这简化了布线为用户只需要一个开关连接到地面,% i. _  F: {& z) c! p) ]; q
//虽然其建议用户采取额外的步骤,在低通滤波器来减少布线
" [6 p5 s. o$ I) w; }# R# \//电噪音检测销。如果用户反转的销Grbl设置,这只是翻转+ T' K3 I9 d( M, ^# p7 u9 U
//读高或低表明一个积极的信号。在正常操作中,这意味着用户
+ m8 l$ N% r8 O; c//需要连接一个常开开关,但如果倒,这意味着用户应该连接
( n$ ]0 U4 i# Q. d8 Y// normal-closed开关。
$ S+ d; ]. t+ v! p//以下选项禁用内部上拉电阻,一般低设置别针7 l/ B0 ~' J6 M: f, _3 q! g' k
//操作,现在开关必须连接到Vcc代替地面。这也掀的意思* H/ v/ x2 K1 |6 ?* N; o* N3 C
//反销Grbl设置,一个倒置的设置现在意味着用户应该连接9 \( r8 l% K: C
//常开开关,反之亦然。& C. v8 h' T8 H+ C
//注意:所有针与功能被禁用,例如XYZ限制针,而不是单独的轴。: e- C0 U7 ]  D
//警告:引体向上被禁用时,这需要额外的布线与下拉电阻!
1 ?7 q, U" n. w7 l9 \8 v: E
4 ]- q: K* u. F; _5 u//#define DISABLE_LIMIT_PIN_PULL_UP //以下选项禁用内部上拉电阻  d# n% d! D2 j  C$ c  b6 `
//#define DISABLE_PROBE_PIN_PULL_UP, L( m: G5 R- f& e# ]% u$ {. L3 m
//#define DISABLE_CONTROL_PIN_PULL_UP+ q6 A: Y6 e% D, k+ {3 c) v
' C' T, y, S5 t+ D& B8 W! V. \
// Sets which axis the tool length offset is applied. Assumes the spindle is always parallel with
* L: c: @" }' A$ V; `5 o// the selected axis with the tool oriented toward the negative direction. In other words, a positive$ V5 X. b- }+ G. p5 _
// tool length offset value is subtracted from the current location.' }5 _  ~1 O( k# n/ N+ T* i8 l4 O
//设置哪个轴长度补偿应用的工具。假设轴总是与4 c  s7 z+ h& Z, Z, r; o- K. t
//选择轴工具面向负方向。换句话说,一个积极的; c3 P% a+ `' @% P
//工具长度偏移值减去从当前位置。2 e# P8 s+ A% e6 w+ \

( c" K5 p) d1 n/ Y; _3 T#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS // Default z-axis. Valid values are X_AXIS, Y_AXIS, or Z_AXIS.设置哪个轴长度补偿应用的工具& q$ Z& Y5 ]8 b- T
8 M8 l  W# [; \  U* \5 K
// Enables variable spindle output voltage for different RPM values. On the Arduino Uno, the spindle
6 J* [' _8 z0 L  t. s: R- Q// enable pin will output 5V for maximum RPM with 256 intermediate levels and 0V when disabled.
, [0 h3 `! V" U) z+ @, G: G/ k2 u// NOTE: IMPORTANT for Arduino Unos! When enabled, the Z-limit pin D11 and spindle enable pin D12 switch!( x6 d# d' J  p2 K9 C( d
// The hardware PWM output on pin D11 is required for variable spindle output voltages.
, z! {8 T) F3 [; \( z7 O//允许变量轴输出电压不同的转速值。Arduino Uno,主轴
: H) @- |( m; @# R8 m9 F+ c7 D//启用销将输出5 v的最高转速256中级水平和0 v时禁用。1 y. d) ?) {/ {% e8 x0 d
//注意:重要Arduino凯泽本人!当启用时,Z-limit销这里和轴销D12开关!% b7 o  n: a9 V
//硬件PWM输出销这里需要变量轴输出电压。4 ~, J& ~  K; u; d8 E

' K* ^& y9 _7 Z% w( {#define VARIABLE_SPINDLE // Default enabled. Comment to disable.//允许主轴输出电压不同的转速值
' x" u9 H, ?9 p; I; Y
; c% i' P2 e# d4 {, C' y& k3 D// Used by the variable spindle output only. These parameters set the maximum and minimum spindle speed" C, ?  Y5 k8 f9 Z
// "S" g-code values to correspond to the maximum and minimum pin voltages. There are 256 discrete and
" B* ^# ^/ b: V% [3 Z8 h6 m8 l// equally divided voltage bins between the maximum and minimum spindle speeds. So for a 5V pin, 1000
; t4 i+ `+ l' ^9 F2 m0 {& [) g% j- ^- T// max rpm, and 250 min rpm, the spindle output voltage would be set for the following "S" commands:   V7 U3 k4 x# p$ {/ C4 h
// "S1000" @ 5V, "S250" @ 0.02V, and "S625" @ 2.5V (mid-range). The pin outputs 0V when disabled.
& d9 i; N* k" s# a  [6 g//使用的变量轴输出。这些参数设置最大和最小轴转速& W0 e) Y: E; w; O; I9 N& h2 N
//“S”刀位点值对应于销电压的最大值和最小值。有256个离散和
" R( z+ s  e/ o//电压平均分配箱主轴速度的最大值和最小值之间。所以对于一个5 v销,1000
6 f& T" U: ~4 t, [/ D8 m& C4 @9 J// max rpm,250分钟rpm,主轴输出电压将为以下“S”命令:$ m& Z, u' h( _
// @“S1000 5 v,“S250”@ 0.02 v,“S625”@ 2.5 v(中档)。销输出0 v时禁用。" X3 R, I6 B9 }( a- p4 S
# J0 O2 Y. ]( C8 V; l$ P
#define SPINDLE_MAX_RPM 1000.0 // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.( a- b+ R& H) i. y  O. f
#define SPINDLE_MIN_RPM 0.0    // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.7 h* ~0 I" C$ E. t9 B' q* h( I& z& Z3 I
. n- D" v# |, S0 h
// Used by variable spindle output only. This forces the PWM output to a minimum duty cycle when enabled.
7 }  D8 A. v, U// When disabled, the PWM pin will still read 0V. Most users will not need this option, but it may be 6 ^% [2 U2 J! F4 S! a, n
// useful in certain scenarios. This setting does not update the minimum spindle RPM calculations. Any
+ y  O9 ]) P3 y// spindle RPM output lower than this value will be set to this value.' Z) v: I& B( }7 d9 p
//使用的变量轴输出。这迫使PWM输出最小占空比时启用。
8 u8 N2 y+ c2 z& \//当禁用,PWM销仍读0 v。大多数用户不需要这个选项,但是它可能是3 N! Y0 x0 M* N4 A( O2 x
//在某些情况下很有用。这个设置不会更新最小主轴转速计算。任何
; b- ?6 o# @2 B9 e//输出轴转速低于这个值将被设置为这个值。
. u+ ]! _. J+ j% e6 s& ~2 Q
. v0 X: |2 S* r+ r- `// #define MINIMUM_SPINDLE_PWM 5 // Default disabled. Uncomment to enable. Integer (0-255)
7 o% P  Q# y1 b, f4 u' `! c. [* `( S' h4 j3 m- |7 |( j, e! q* O
// By default on a 328p(Uno), Grbl combines the variable spindle PWM and the enable into one pin to help 9 {% o: n, L0 y; T
// preserve I/O pins. For certain setups, these may need to be separate pins. This configure option uses5 P( h% _7 O; K' [8 d
// the spindle direction pin(D13) as a separate spindle enable pin along with spindle speed PWM on pin D11. 1 W0 s! k3 S/ S
// NOTE: This configure option only works with VARIABLE_SPINDLE enabled and a 328p processor (Uno). & z* J9 [% P) q; _* a! d2 O
// NOTE: With no direction pin, the spindle clockwise M4 g-code command will be removed. M3 and M5 still work.7 B$ ?4 B* R$ z' H/ }
// NOTE: BEWARE! The Arduino bootloader toggles the D13 pin when it powers up. If you flash Grbl with
( H% ^( l( m1 t+ Y( n( y8 C// a programmer (you can use a spare Arduino as "Arduino as ISP". Search the web on how to wire this.), / R1 U, d* l. n4 q, {9 E6 h
// this D13 LED toggling should go away. We haven't tested this though. Please report how it goes!- k4 A1 v. K0 u
//默认ATmega328 p(Uno),Grbl结合变量轴PWM和使到一个销的帮助. y# d4 F! k$ ]- Y
//保存I / O管脚。对于某些设置,这些可能需要单独的别针。这个配置选项使用
% n' D4 X; M  ^, s, i( g//方向轴销(D13)作为一个单独的轴销上启用销以及主轴转速PWM这里。
& j. L* f; N  I  `1 o) r5 a$ }//注意:该配置选项仅适用于VARIABLE_SPINDLE启用和328 p处理器(Uno)。/ N2 Y6 ]9 V' ?6 _& d+ g8 Q$ z$ D
//注意:没有方向销,主轴顺时针M4刀位点命令将被删除。M3和M5仍然工作。! [7 p& d+ G. C& H# g
//注意:小心!Arduino引导装载程序切换D13销的权力。如果flash Grbl6 G. o- A  p1 R- s4 H: ^
//程序员(您可以使用一个备用Arduino“Arduino ISP”。搜索网络如何线),
& P1 [0 W1 u/ [9 i//这D13导致切换应该消失。我们还没有测试这个。请报告将会怎样!. W, c) y9 X: f* I, `
, f, S0 t8 z* ^. f: S# X1 O2 @
// #define USE_SPINDLE_DIR_AS_ENABLE_PIN // Default disabled. Uncomment to enable.  O% |2 h$ m8 e" D
1 w8 s$ j1 k3 Y5 C( R! l# X( O
// With this enabled, Grbl sends back an echo of the line it has received, which has been pre-parsed (spaces
$ P3 b# H) d1 y( q% k( z: ~5 i// removed, capitalized letters, no comments) and is to be immediately executed by Grbl. Echoes will not be
( M0 ]5 a2 p  F, D0 j// sent upon a line buffer overflow, but should for all normal lines sent to Grbl. For example, if a user 3 a1 C+ l  J5 z  E; \
// sendss the line 'g1 x1.032 y2.45 (test comment)', Grbl will echo back in the form '[echo: G1X1.032Y2.45]'.
# D$ }: a0 a' V// NOTE: Only use this for debugging purposes!! When echoing, this takes up valuable resources and can effect
2 F. F/ D2 W) Y& G4 ]// performance. If absolutely needed for normal operation, the serial write buffer should be greatly increased" e0 [) L4 }+ z7 _" P5 c
// to help minimize transmission waiting within the serial write protocol.
: K' T8 g- D8 p" Z
) Y' Q, U% w2 |//启用,Grbl发回的回声线已收到,已预编译(空间+ h0 Z4 F/ K0 t% |2 Y
//移除,大写字母,没有评论),由Grbl立即执行。回声将不会* q% z  T" Q0 U# z  ~; \3 H# ~
//发送一个线缓冲区溢位,但应该对所有正常线路送到Grbl。例如,如果一个用户
8 i  h; _  h/ v, ?//发送线的g1 x1.032 y2.45(测试评论)形式”,Grbl将回声”(回声:G1X1.032Y2.45]”。
. s. z" ~, n8 G) @. L//注意:只使用这个调试! !当呼应,这占用了宝贵的资源,可以影响
  |. M& Z0 y# Q9 ]. V//性能。如果正常运行所需的绝对,串行写入缓冲器应该大大增加
: @1 ~& O8 [8 S! b//帮助最小化传输等系列内写协议。
% j( v* d/ j5 s: E* y9 c9 {; A/ z/ V/ \, h7 v7 [6 N# Y
// #define REPORT_ECHO_LINE_RECEIVED // Default disabled. Uncomment to enable.
8 p. A$ l+ L, Y3 N5 i- [7 o& c! X8 S( ^- }% C7 s1 j
// Minimum planner junction speed. Sets the default minimum junction speed the planner plans to at$ e( Q4 M3 d: C8 @  _4 o3 `+ H
// every buffer block junction, except for starting from rest and end of the buffer, which are always, ]* @( n7 V$ M2 L- h
// zero. This value controls how fast the machine moves through junctions with no regard for acceleration! p0 C5 C, ~# I+ x+ ?6 r- C0 F
// limits or angle between neighboring block line move directions. This is useful for machines that can't
- f& d* ?/ I4 C9 a, L" @* Z, U6 E// tolerate the tool dwelling for a split second, i.e. 3d printers or laser cutters. If used, this value
* a4 C5 b. q6 e// should not be much greater than zero or to the minimum value necessary for the machine to work.
0 S6 o6 x" z& R: d! t6 S0 U1 Y" H# f( M) q2 j7 ?$ G. _4 |6 s
//最小规划师结速度。设置默认最小连接速度规划计划: s- c5 N0 H" S- p, ^2 v
//每一个缓冲块接头,除了从结束休息和缓冲区,它总是1 @" Q, f) N5 c& t8 k# ^* j
// 0。这个值控制机器的速度穿过路口,没有考虑加速度
5 }* [2 B$ \, f. D# p( G, j9 ^9 g+ b//限制或相邻块之间的角线方向移动。这是有用的机器,不能
! F  a7 y7 ]5 b6 t0 ^//容忍工具居住某一刹那,即3 d打印机或激光切割机。如果使用这个值
& G: V5 m  C8 D% ]  S. I//不应大于零或机器工作所需的最小值。4 U* `0 w/ a- a7 Y
6 p% g4 z; r. l
#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min)
: F! X& |/ }7 Y- S
; N! A3 C! w0 T+ I- [* b7 e) w// Sets the minimum feed rate the planner will allow. Any value below it will be set to this minimum# U. }! i5 [+ f/ ^8 n0 W% R2 _
// value. This also ensures that a planned motion always completes and accounts for any floating-point6 R$ ]/ M' y1 J# V) b1 O( z
// round-off errors. Although not recommended, a lower value than 1.0 mm/min will likely work in smaller% s% h7 T0 W( I9 i( |) {
// machines, perhaps to 0.1mm/min, but your success may vary based on multiple factors.
! t4 j0 p8 @. s1 O# t& `//设置计划将允许的最小进给速率。任何价值低于它将被设置为最低值。这也保证了运动计划总是完成,占任何浮点
9 z1 y# n7 Z' M/ x//舍入错误。虽然不推荐,价值低于1.0毫米/分钟可能会在较小的工作
% c0 a+ I3 {3 Z' M2 t. x4 q* `. u//机器,也许到0.1毫米/分钟,但你的成功基于多种因素可能会有所不同。
' M( |0 y$ a  B, s6 |0 {
- ]) T! N- Q, X9 [#define MINIMUM_FEED_RATE 1.0 // (mm/min)//设置计划将允许的最小进给速率
  X# b" B$ C5 v3 k- A
4 X4 y/ E# r8 w1 o5 q7 f0 A// Number of arc generation iterations by small angle approximation before exact arc trajectory
3 B# D  p3 s, P3 q! C" h// correction with expensive sin() and cos() calcualtions. This parameter maybe decreased if there
/ D1 C: j' j8 n5 [// are issues with the accuracy of the arc generations, or increased if arc execution is getting
: F% W/ R" v  Y2 O// bogged down by too many trig calculations.
7 V! u1 @, A  T! Z//弧生成迭代次数之前小角度近似精确的弧线轨迹' M$ K; T: p+ _( a% W
//修正与昂贵的sin()和cos()calcualtions。如果有这个参数可能减少
5 s0 Q5 `; W7 o//与弧一代又一代的准确性问题,或如果电弧执行得到增加
, x2 N5 f) N5 l1 y5 ^3 x! N3 q//太多的三角计算的泥潭。1 U4 ]% v' c6 d5 X  N$ m! s

- O4 h) ^# l: n9 z+ @3 X#define N_ARC_CORRECTION 12 // Integer (1-255)
. ^: \, i# D4 F, ^: l, {. J4 [6 t  G. s" g9 y/ m# u
// The arc G2/3 g-code standard is problematic by definition. Radius-based arcs have horrible numerical 9 {2 _$ ~: r- f. N4 _
// errors when arc at semi-circles(pi) or full-circles(2*pi). Offset-based arcs are much more accurate
% M( `5 Q8 I5 I! }, d# P// but still have a problem when arcs are full-circles (2*pi). This define accounts for the floating . _0 C* K" M+ J6 B# r
// point issues when offset-based arcs are commanded as full circles, but get interpreted as extremely/ ^" d" m0 W) Y
// small arcs with around machine epsilon (1.2e-7rad) due to numerical round-off and precision issues.
- x6 y- x" }3 ~) d1 e" y( n5 s3 q// This define value sets the machine epsilon cutoff to determine if the arc is a full-circle or not.& u0 E. l0 _4 u# B7 r0 ^
// NOTE: Be very careful when adjusting this value. It should always be greater than 1.2e-7 but not too5 G9 q( P! j6 F- r
// much greater than this. The default setting should capture most, if not all, full arc error situations.
; j! N4 Y: D" _% N9 z- z. w3 p//弧G2/3刀位点的标准定义是有问题的。Radius-based弧有可怕的数值* z/ C% v# ?! M8 j# l8 a
//错误当电弧在半圆(π)或原点(2 *π)。Offset-based弧更准确
1 P4 r* g  g% s# N//但仍有一个问题当弧原点(2 *π)。这个定义占浮动0 D: s9 N; R" ]0 j; s8 e. ]' W
//当offset-based弧吩咐点问题完整的圆,但解释为极" w, e, Y- b7 |- k
//小弧机周围ε(1.2 e-7rad)由于数字舍入和精度问题。
3 E3 Q; V! ?8 ^  R+ z8 u//定义值设置机器ε截止来确定电弧是一个原点了。/ ^! H6 `/ C( r3 J: h
//注意:调整这个值时非常小心。它应该总是大于1.2 e -但不要太
4 F& u  l0 k$ f2 K4 a5 v9 y8 Q//比这大得多。默认设置应该捕获大部分,如果不是全部,全部错误的情况。$ c3 b1 ~0 ^# l2 z  B
5 U2 v" Y( [! Q. I8 M, X
#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)
5 m, B2 _3 k6 D( S* j: Q5 a! {$ v; D: A" k! [+ y" E, J2 _
// Time delay increments performed during a dwell. The default value is set at 50ms, which provides; l% e  a* ~. U& E: `
// a maximum time delay of roughly 55 minutes, more than enough for most any application. Increasing3 i- z$ m3 P$ Q2 o: K
// this delay will increase the maximum dwell time linearly, but also reduces the responsiveness of $ r/ w% Y& b9 x8 I% i6 d- ]
// run-time command executions, like status reports, since these are performed between each dwell * O; p3 T2 @. c3 H2 d/ y% F
// time step. Also, keep in mind that the Arduino delay timer is not very accurate for long delays.
" q9 a# k: a- X! q7 @; D//延时增加表现在住。默认值设置为50毫秒,它提供了* d/ w. D, |3 [8 L5 z, _
//最大延时约55分钟,足够对大多数任何应用程序。增加7 a# F. A2 }6 i# c. J5 x
//这种延迟将增加线性最大停留时间,也减少了响应能力+ e7 h* Q" F3 ~) O
//运行命令执行状态报告一样,因为这些每个住之间执行
* b/ ?' P+ u& f1 }3 e//时间步。还有,记住,Arduino延迟计时器不是很准确的长时间延误。
: [% ?- x+ g& n, @  c4 ?7 ]% v+ o* T+ C% @7 k! T
#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds)3 |' R( |. _0 G9 y8 r+ K
/ B0 E% R) a: ]' v/ z# L3 t* n
// Creates a delay between the direction pin setting and corresponding step pulse by creating# b6 l$ d( d# ]& F: }
// another interrupt (Timer2 compare) to manage it. The main Grbl interrupt (Timer1 compare)
  c4 f% l2 G/ |' k* `// sets the direction pins, and does not immediately set the stepper pins, as it would in
1 }! c9 B& A6 c( A( D% j6 Y// normal operation. The Timer2 compare fires next to set the stepper pins after the step
6 C6 h3 j$ x2 r4 @. `- j// pulse delay time, and Timer2 overflow will complete the step pulse, except now delayed
. c8 L5 l% I) V0 K// by the step pulse time plus the step pulse delay. (Thanks langwadt for the idea!)
$ _5 Y. `% }5 C- J& T/ I( j. w// NOTE: Uncomment to enable. The recommended delay must be > 3us, and, when added with the7 d* T1 w# Y1 A# R+ b9 @
// user-supplied step pulse time, the total time must not exceed 127us. Reported successful
8 w3 ^0 m. |5 r9 a- h  F  a// values for certain setups have ranged from 5 to 20us.
* r+ O; n+ L; P2 ]4 K//创建一个方向销之间的延迟脉冲通过创建设置和相应的步骤. `" [# X1 n: z! z3 }
//另一个中断(Timer2比较)来管理它。主要Grbl中断(Timer1比较)
; m0 `) y: K/ I0 V8 M* t//设置方向针,不立即设置步进针,因为它会在* x1 z4 u/ o4 I9 Y, z
//正常操作。Timer2比较火旁边设置步进针后一步
, J6 \; t) d$ B5 Z7 Q( n//脉冲延迟时间,Timer2溢出脉冲将完成的步骤,现在延迟除外
/ T- P2 U- t- ], x! ^( _  X( f% V//脉冲时间加上的一步一步脉冲延迟。(感谢langwadt主意!)
9 ]/ A; i0 a" z0 ^- e; d8 ]//注意:取消启用。必须> 3,建议延迟,当添加的
) a/ K- h" G" c, g' `1 ^: z//用户提供的步骤脉冲时间,总时间不得超过127美元。成功的报道! V! L1 N( Q0 ]( Q
//值对某些设置范围从5到20。, [2 b' d$ U3 O6 G+ y3 g# K

) {3 [& ^5 z& g; d// #define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled." X/ Q' m# p; L2 y5 N
+ Q* C( K3 E" m
// The number of linear motions in the planner buffer to be planned at any give time. The vast1 N. \0 |, W( X3 ]  X2 F, N4 g
// majority of RAM that Grbl uses is based on this buffer size. Only increase if there is extra 5 J" h+ S9 l/ h: H; P& k
// available RAM, like when re-compiling for a Mega or Sanguino. Or decrease if the Arduino
0 L/ z% `" D" v; r// begins to crash due to the lack of available RAM or if the CPU is having trouble keeping) N. Q7 B# ^* |8 B; V: m2 @
// up with planning new incoming motions as they are executed.
: B, l$ ~1 m1 g: V//线性运动规划师缓冲区的数量在任何给出时间计划。绝大
. A2 V+ a0 N) v4 s8 i$ m//多数RAM Grbl使用基于这个缓冲区的大小。如果有额外的只会增加
  M0 ?. y, g, }8 K3 z9 `4 z//可用内存,比如当基于大型或Sanguino。如果Arduino或减少$ U% y4 G. ]4 S0 m1 O) [1 u, ]
//开始崩溃由于缺乏可用的RAM或者CPU是难以保持3 o% X4 x, V, s" X2 p1 b" {: e
//与规划新传入的动作执行。5 V; \) Q. H+ q, |) R1 Y  V

" x7 V# F- n& L# P// #define BLOCK_BUFFER_SIZE 18  // Uncomment to override default in planner.h.! D2 b7 C0 n! ?5 L' t/ i" ^- r% }/ X
. L. O  e" f6 Y' c: ?6 o
// Governs the size of the intermediary step segment buffer between the step execution algorithm; {8 B3 d2 n+ h* e6 A8 P
// and the planner blocks. Each segment is set of steps executed at a constant velocity over a1 \, R* V/ k2 T! b  ~
// fixed time defined by ACCELERATION_TICKS_PER_SECOND. They are computed such that the planner* s. M" ^5 B, U* R& [0 H. p
// block velocity profile is traced exactly. The size of this buffer governs how much step
, X  L2 Y. k  _3 j$ y% k) @& T// execution lead time there is for other Grbl processes have to compute and do their thing $ n" n+ _& U: ]+ k
// before having to come back and refill this buffer, currently at ~50msec of step moves.
/ I2 U: k; h2 d: W; e9 i/ C//控制之间的中间段缓冲大小的步骤执行算法" c1 x! S1 q2 \/ B4 k$ {
//和规划师块。每一部分的步骤执行在一个恒定的速度- j7 m. N" ~  f# `3 u2 n. N
//固定的时间由ACCELERATION_TICKS_PER_SECOND定义的。他们计算的计划
+ f6 A$ }7 \% N, B: w//块速度剖面追踪到底。这个缓冲区的大小控制多少步骤/ f3 _2 p; p  n3 H  _
//执行时间有其他Grbl过程需要计算和做他们的事情
5 {2 @( u- v3 Y//之前必须回来重新填充这个缓冲区,目前移动~ 50毫秒的一步。1 q: D$ }8 M8 S6 B. a. _

2 N6 g: L9 |: Y% t4 y4 w' v// #define SEGMENT_BUFFER_SIZE 6 // Uncomment to override default in stepper.h.
( s& {/ E/ ^8 s0 I# q
) a3 t: A! D, I. K// Line buffer size from the serial input stream to be executed. Also, governs the size of
  y4 ~( Q; H- g  F, o4 z: Q// each of the startup blocks, as they are each stored as a string of this size. Make sure
: e: U2 B' j. P  l6 _+ y2 i// to account for the available EEPROM at the defined memory address in settings.h and for" n# I/ P/ s' o' u2 v7 {" S
// the number of desired startup blocks.% i! _' V/ i% b; p. E  H$ _5 }
// NOTE: 80 characters is not a problem except for extreme cases, but the line buffer size 9 B2 v& m( y( {# {% g
// can be too small and g-code blocks can get truncated. Officially, the g-code standards
! u% p1 S. F$ {2 N2 }// support up to 256 characters. In future versions, this default will be increased, when
5 r2 g2 e' O5 y& q/ S$ i, B// we know how much extra memory space we can re-invest into this.3 m1 {! P; |9 C) I2 a3 ~! f. r
//行执行串行输入流的缓冲区大小。同时,大小的控制
3 E* F# ]  D' a//每个启动模块,它们分别存储为字符串的大小。确保7 z+ w. X4 u' a5 F! t0 h
//占可用eepm定义内存地址的设置。h和6 K( l# @! x3 s
//需要启动块的数量。( F6 n, i5 ?& [8 k$ e6 x" m6 k
//注意:80个字符不是一个问题,除了极端的情况下,但线缓冲区大小
2 L9 C* e. g2 d/ u5 p( h//可以太小和刀位点块可以截断。正式,刀位点标准  x  A/ i) t; J/ M- o- _+ q, {
//支持多达256个字符。在未来的版本中,这个违约将会增加,当* }9 R/ x0 `7 k( b
//我们知道多少额外内存空间的时候我们可以再投资。* S; v  U: |: k8 ?7 C6 V& z) V1 _: w
0 J, X# d, @' A8 a  e2 w) U: y) [3 d& ]
// #define LINE_BUFFER_SIZE 80  // Uncomment to override default in protocol.h
3 q" M/ F6 I$ {& |  
; T6 R7 ~  Z% F& R, B% L// Serial send and receive buffer size. The receive buffer is often used as another streaming
4 m. x, U! Q8 n9 l// buffer to store incoming blocks to be processed by Grbl when its ready. Most streaming
& ]5 S' X) `/ P2 S! y( U1 G// interfaces will character count and track each block send to each block response. So, 5 p' \) d+ b  o4 u! |
// increase the receive buffer if a deeper receive buffer is needed for streaming and avaiable! b7 \( Y- l( u4 r% q
// memory allows. The send buffer primarily handles messages in Grbl. Only increase if large
% u. s; ?' i$ q5 X% b- \// messages are sent and Grbl begins to stall, waiting to send the rest of the message.
3 s! I8 y# t- q. s$ p. J- o' T% b// NOTE: Buffer size values must be greater than zero and less than 256.
) V9 p8 H5 g, P4 ]' g, _// #define RX_BUFFER_SIZE 128 // Uncomment to override defaults in serial.h
( A$ C  g2 q" C% N6 ^8 T3 C# o//串行发送和接收缓冲区大小。接收缓冲区通常用作另一个流9 F6 y9 p! N0 H- M
//缓冲存储传入的块来处理Grbl当它准备好了。最流% H4 F$ s& N* p0 V3 P$ I( U
//接口将字符计数和跟踪每一块发送给每个块的回应。所以,. z) ^5 C4 l" n# v+ f/ H
//增加接收缓冲区如果需要更深层次的接收缓冲区为流,、
2 F# V9 x2 ?2 S/ x% k: t//内存允许。Grbl发送缓冲主要处理消息。只会增加如果大5 u# ?5 U. I, ^, ?3 d
//消息发送和Grbl开始停滞,等待发送其余的消息。. i" i% s( U+ V. h& J
//注意:缓冲区大小值必须大于零,小于256。" B+ \/ c7 C& E4 j) w
// # define RX_BUFFER_SIZE 128 / /取消serial.h覆盖默认值
7 M: J3 [5 m5 G9 r( a6 g- d: r+ F6 U% P2 s$ `/ Y

/ ~- y5 l$ s) x0 w# V3 g// #define TX_BUFFER_SIZE 64
1 E" R/ _* i. `( S4 |( a. [+ O- S  6 D$ q% ^# B/ a/ J/ @
// Toggles XON/XOFF software flow control for serial communications. Not officially supported
' d2 ]+ e, E/ _// due to problems involving the Atmega8U2 USB-to-serial chips on current Arduinos. The firmware! R/ u# t; R3 n
// on these chips do not support XON/XOFF flow control characters and the intermediate buffer   ~2 w$ P4 L- s0 w, E* R8 ^
// in the chips cause latency and overflow problems with standard terminal programs. However, 4 R+ E% ~8 i  }4 N: {$ U9 V- @) b3 P
// using specifically-programmed UI's to manage this latency problem has been confirmed to work.
. D9 t) d- @( K8 }/ l9 B// As well as, older FTDI FT232RL-based Arduinos(Duemilanove) are known to work with standard8 N! I7 d( y6 s( c, q
// terminal programs since their firmware correctly manage these XON/XOFF characters. In any. M! Q/ j1 L+ I! g* w
// case, please report any successes to grbl administrators!
0 j) d9 ^& o4 u3 i, ]* L//切换为串行通信发送朴通/发送葡开软件流控制。不是官方支持8 s; X1 |8 x' X% k& f" @& ]( q% U
//由于问题涉及Atmega8U2 USB-to-serial当前arduino芯片。固件
% f) n: q) |9 Z0 M* O//在这些芯片不支持发送朴通/发送葡开流控制字符和中间缓冲区
. o2 ]) ]" h; N6 D5 G, D+ y//芯片导致延迟和溢出问题的标准终端程序。然而,, r7 b6 w0 m% y, h3 v
//使用specifically-programmed UI的管理这个延迟问题已经确认工作。
: b: w/ V8 D% D! i9 e//以及老FTDI FT232RL-based arduino(Duemilanove)是已知的标准( y9 K, O& L1 V' P; a+ S& O
//终端程序因为他们正确的固件管理这些发送朴通/发送葡开的角色。在任何2 r* ?' G) ]2 e1 o+ a# r4 p0 n4 a
//情况,请报告任何成功grbl管理员!
) D  P) Y& w$ [1 k2 V3 ~0 g* q& ?! A( b2 R4 r) M6 }
// #define ENABLE_XONXOFF // Default disabled. Uncomment to enable.
. B/ y. J" x( F0 M2 e1 n5 z# J; P0 N2 y
// A simple software debouncing feature for hard limit switches. When enabled, the interrupt
: X1 L' P1 ~6 }2 F/ O/ `// monitoring the hard limit switch pins will enable the Arduino's watchdog timer to re-check 6 {9 k# m* B7 M: L$ k/ t
// the limit pin state after a delay of about 32msec. This can help with CNC machines with 2 @" L9 }8 E. w+ b5 G
// problematic false triggering of their hard limit switches, but it WILL NOT fix issues with
6 K2 j6 L9 ^* X: B// electrical interference on the signal cables from external sources. It's recommended to first
# P/ |2 C/ I% K% H! O% [" J// use shielded signal cables with their shielding connected to ground (old USB/computer cables ' [5 l8 }% ?) ]. ^- W
// work well and are cheap to find) and wire in a low-pass circuit into each limit pin.
  z5 _* o( x( }9 G9 M, H7 C//一个简单的软件消除抖动特性硬限位开关。当启用时,中断
; B5 ~  d6 ]' K/ ~. e$ w. X5 R+ B+ p//监控硬限位开关针将使Arduino的看门狗定时器重新审视
4 z; w& d4 r2 n1 o2 @: f//销的极限状态后约32毫秒的延迟。这可以帮助与数控机器' O3 L; R$ o2 L* |% T; w$ {: Y$ B: n
//问题错误引发的硬限位开关,但是它不会解决问题, s* @" E7 c( p4 Z! k( R9 W
//电干扰信号电缆从外部来源。首先它的建议
0 V' R# u% a3 G. n//使用屏蔽信号电缆的屏蔽连接到地面(老USB /计算机电缆+ d+ P7 J7 U! q0 S7 n0 M0 n* Y* L
//工作得很好,很便宜)和线低通电路到每个限位销。
! H3 ^' u- n$ c
6 `0 Z6 l$ o1 Q! c// #define ENABLE_SOFTWARE_DEBOUNCE // Default disabled. Uncomment to enable.
  S, D% \5 G7 R7 a1 k; u) w9 R; m2 A3 b0 k& p0 m$ T- x/ k
// Force Grbl to check the state of the hard limit switches when the processor detects a pin
6 ?( {9 i4 ?. f! v* |6 b0 p6 B// change inside the hard limit ISR routine. By default, Grbl will trigger the hard limits
9 t$ E; B9 k7 R6 F+ P# j0 K// alarm upon any pin change, since bouncing switches can cause a state check like this to
# Y5 r4 L: S7 `% i// misread the pin. When hard limits are triggered, they should be 100% reliable, which is the
- S5 q9 N# S: o// reason that this option is disabled by default. Only if your system/electronics can guarantee
6 A+ H! Q/ g7 n" a/ v9 R& I// that the switches don't bounce, we recommend enabling this option. This will help prevent
) u1 ^$ a& t  d3 _* P5 B+ h* G// triggering a hard limit when the machine disengages from the switch.9 d8 v. \0 k2 k/ J: v% u
// NOTE: This option has no effect if SOFTWARE_DEBOUNCE is enabled.) |; d7 O/ @; Z' S
//力Grbl检查硬限位开关的状态,当处理器检测到一个销
) p3 {( C# O1 |6 L3 A9 v* x" I1 h//改变内部硬限制ISR例行公事。默认情况下,Grbl将触发硬限制
- `- ]" w: G; m$ |  j$ @0 t//报警在任何销更改,因为跳开关可以导致这样的状态检查4 T1 A: U9 o$ V% Y7 y0 u- t
//误读了销。硬限制触发时,他们应该100%可靠,这是+ s* @* S: i0 z0 |6 W* n" Z
//原因,这个选项默认是禁用的。只有在你的系统/电子产品可以保证/ r3 W1 Y) Q1 [9 [. |0 V1 f# Y0 V
//开关不反弹,我们建议启用这个选项。这将有助于防止
' i& D$ f# w' t  \: E//触发机退出时硬限制开关。3 ]5 R2 e3 D1 R4 g$ c
//注意:这个选项如果启用了SOFTWARE_DEBOUNCE没有影响。
8 n+ f/ J: e3 b# H' n# U7 n$ [. F" u1 k+ b2 c4 N; ]$ Q: F
// #define HARD_LIMIT_FORCE_STATE_CHECK // Default disabled. Uncomment to enable.; x+ r, H4 j( p1 A

5 a0 }% E4 a# Z6 b9 p( c% o
8 t* R9 U6 @6 f* K* p// ---------------------------------------------------------------------------------------3 H  e2 H9 e' L4 u9 ?* K! j
// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:编译时错误检查的定义值:7 O& G  q/ x/ C: f* E

/ x; M: |2 H; z) o  K$ ?* u#ifndef HOMING_CYCLE_04 n$ E& j: J  @* L- h7 a
  #error "Required HOMING_CYCLE_0 not defined."
8 i1 W; v* _& c9 P8 ~#endif& i  d& c: d& s) d( u% n
0 V. D* v6 c3 \
#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(VARIABLE_SPINDLE)  |% B: b5 J, @3 Q
  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with VARIABLE_SPINDLE enabled"
. P" E% j! _/ ]: {: X2 R5 a; T% z#endif$ Z5 _8 \1 v7 i1 p( i; w/ {

1 t5 g5 B% _( D0 ]4 k  e#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(CPU_MAP_ATMEGA328P)
0 F* l+ i9 F& }, A& Q7 X  #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with a 328p processor". O  @6 a/ M. A
#endif6 N- z4 {& u8 Z- t- P
8 Y% n2 _0 n% s! _+ h1 q
// ---------------------------------------------------------------------------------------
  a" ^2 y! t- o7 i9 T2 v7 \, q1 s% p, w/ C1 b" o/ ^  ^
: V1 y  @# @( |+ V5 W# Z* w
#endif: L3 f5 \  K* N% g

6 V; c1 R. K" ]& a% j! N- e, z. A" f
/ C9 t6 y* p. \  K! [+ B  L$ L) d+ H; r# c
" o; U+ r- S) e: D0 q. ]
; T, t6 ~% s6 w( k  z
: C/ y' i0 B( d- U$ |

+ A- b; o0 l+ e: \* M
" x# w9 L4 u2 o2 ~0 ?& R3 L
2 w7 s8 _, Y' J* q) F* i3 O6 m2 ~# o* P$ k

9 a2 y6 W) ]& k, O
! T  i7 w- l) `% @0 [. G* r! s5 ^8 f2 B: n* J& c( J
& S0 N. L/ Y4 X, ~8 |& B
  T% b" @9 G( N, Z$ c

$ t* P0 `. r; @* t: L

本帖子中包含更多资源

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

×

评分

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

查看全部评分

回复

使用道具 举报

 楼主| 发表于 2016-8-21 00:11:42 | 显示全部楼层
那些没有用的照片不知道怎么就上去了好讨厌。
 楼主| 发表于 2016-8-21 00:14:16 | 显示全部楼层
5 m' Y: U9 S" A) S& S
发表于 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 | 显示全部楼层
补充
$ C, J8 U* J) V程序运行protocol_execute_realtime(); /运行实时命令。6 L2 T% C2 \# q
// Executes run-time commands, when required. This is called from various check points in the main' P: x8 i7 b2 ~
// program, primarily where there may be a while loop waiting for a buffer to clear space or any  j0 v# z' m9 B: |8 C7 C
// point where the execution time from the last check point may be more than a fraction of a second.
5 M! s2 k5 {. n// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code7 c/ t- C2 U& F3 L* }
// parsing and planning functions. This function also serves as an interface for the interrupts to + n6 D& F- H5 N3 t) r2 X0 {7 n
// set the system realtime flags, where only the main program handles them, removing the need to. G- ?" Y3 |, w& t( C
// define more computationally-expensive volatile variables. This also provides a controlled way to ! c7 v# L) b  G. B' A& }! N- Y
// execute certain tasks without having two or more instances of the same task, such as the planner: K( e+ Z4 \* M% M6 q
// recalculating the buffer upon a feedhold or override.- s9 p+ B) C3 R$ t; j6 l
// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,/ b; C' x0 A) ?! ?' U
// limit switches, or the main program.$ ?% i, E$ |3 O

' S! O: e9 u" w1 h& `//执行运行时间命令,在需要时。这就是所谓的从各种主程序要检查站4 h; h5 q) ?7 W& [% D% v; d
//,主要是那里可能是一个while循环等待缓冲区空间或任何' H& H8 ]# U" a0 N. V
//执行时间从过去的止点可以超过几分之一秒。
9 J$ _3 Z! W9 G% s5 c. d6 b//这是一种异步执行实时命令(又名多任务)grbl的刀位点  g  ~# @/ l3 c
//解析和规划功能。这个函数也可以作为一个接口,用于中断
- [, R: Y# S. [6 a4 U4 V//设置系统实时的旗帜,只有主程序处理,消除的需要( g6 y/ O0 E$ }, H+ }
//定义更多的计算昂贵volatile变量。这也提供了一种控制方法
. e4 |; |3 ~( e: Y7 h//执行某些任务不相同的两个或多个实例的任务,比如计划, y- T/ w. O; b/ n1 u2 J2 D  X
//重新计算缓冲feedhold或覆盖。) L4 ^* A* a! u- I/ S% k- b3 q5 c
//注意:sys_rt_exec_state变量标志设置任何过程,步骤或串行中断,插脚引线,
* j: g, \7 U/ [& S0 A//限位开关或主程序。
! e4 ]9 I7 }8 ]5 L' n5 dvoid protocol_execute_realtime()+ J9 D) G2 k7 V& p6 X
{
4 S6 V& g( ?; Z: y- }        // Temp variable to avoid calling volatile multiple times.7 Z7 I4 d# G  [6 B
        // 临时变量来避免多次调用不稳定。+ P. x5 e' j! ^  b0 H" K
        uint8_t rt_exec;
& o3 E" M: j" j; ~4 B        do{3 H& r* l+ b& C" j  q% ?
          if (rt_exec) {                 // 有标志位置位进入# I4 }0 r* u- z( O( K8 `
        + j+ g" Z  R% C
            sys.state = STATE_ALARM; // 设置系统为报警状态- |7 `( B2 ^6 H4 T. ]1 p' H4 s4 d
      report_alarm_message(ALARM_HARD_LIMIT_ERROR);        //报告报警信息为接近极限值$ t7 e, b7 q- h& ^0 o# A
    } else if (rt_exec & EXEC_ALARM_SOFT_LIMIT) {                        //报告执行软件限位报警! |' x- j9 G) Z( k
      report_alarm_message(ALARM_SOFT_LIMIT_ERROR);        //报告出现软件限位报警% J; r' H5 _+ n$ [1 ]& C1 G  X
    } else if (rt_exec & EXEC_ALARM_ABORT_CYCLE) {                //执行停止循环报警      * {) J7 E. `7 C, e4 Q2 Q% _
      report_alarm_message(ALARM_ABORT_CYCLE);                //出现终止循环报警1 o2 W$ M% T! j0 g1 C
    } else if (rt_exec & EXEC_ALARM_PROBE_FAIL) {                        //执行探查失败报警
. R- c2 |: O+ ^& C      report_alarm_message(ALARM_PROBE_FAIL);                        //出现探查失败报警, V- V7 n; U8 m) L. d
    } else if (rt_exec & EXEC_ALARM_HOMING_FAIL) {                //执行返回原点失败报警
: _7 ?9 Z9 k4 u6 b      report_alarm_message(ALARM_HOMING_FAIL);                //出现返回原点失败报警  x+ x! f+ n$ d7 a
    }9 m$ ?6 m: V& B. r6 c/ ~
/ I; b8 s, f; Y- g$ E# b' N
    // Halt everything upon a critical event flag. Currently hard and soft limits flag this.
0 f* B+ b! k+ {6 W8 K% {% m    // 停止一切在一个关键事件标志。目前硬和软限制标志1 E% y3 m$ B6 J2 M1 m: N5 g
           if (rt_exec & EXEC_CRITICAL_EVENT) {                //如果系统是循环事件进入
' _) R3 a& t. o7 ~             report_feedback_message(MESSAGE_CRITICAL_EVENT);        //报告反馈信息2 y7 B7 o- R$ x: Z' L
              bit_false_atomic(sys_rt_exec_state,EXEC_RESET);                         //清除目前的复位状态2 r  d$ g3 }0 m- |- M3 n, J
9 D1 d2 U+ E3 q* G2 a3 m; Y
        bit_false_atomic(sys_rt_exec_alarm,0xFF);                                 // 清除所有报警标志* @; H0 b! T! q7 @. a
        }        7 T5 E: X" ?+ t! e9 @

( K# v: d# Z3 A; g上面代码将rt_exec = sys_rt_exec_alarm ,如果rt_exec为真,打印不同报警信息
4 o3 p7 x& [4 E5 y* x. n, C和限位保护信息,然后清除报警状态8 n! f$ y# o7 C: r9 ^
___________________________________________________________________________
/ T+ D! c' e' e没有报警进行执行下面代码,执行了终止命令,串口打印命令
! q8 |6 R8 I9 z) b, b; r         // Check amd execute realtime commands        校验和执行实时命令
: Q% k; x0 z/ v4 D9 P4 s. T          rt_exec = sys_rt_exec_state; // Copy volatile sys_rt_exec_state
" J- y' b$ l# E, e" K& H; g1 W# w2 G3 t
        if (rt_exec) { // 输入标志是正确的执行6 z9 m/ T7 v# s2 N
, K% L' p; j; \. h' E; D8 v# Y
            // Execute system abort. 执行系统终止命令
' ?4 Q$ r0 X  O- C/ u3 b7 [            if (rt_exec & EXEC_RESET) {; `( p4 m# I6 v( Y% L' N3 r
              sys.abort = true;  // Only place this is set true.$ m. {8 y6 x2 Y4 X/ e
              return; // Nothing else to do but exit.
" B4 j! c8 s3 J; i- @1 z# }- f        }4 F* P9 o4 @& M; w! M
: B0 g# P' N$ g, ?, K& X; L; ?1 [
            // Execute and serial print status 执行和串口打印状态, o4 p; q+ ]" W5 p% u6 U
            if (rt_exec & EXEC_STATUS_REPORT) {
' M0 }( g1 D3 ^3 ~              report_realtime_status();        //报告实时状态: [* C$ _3 g8 c
              bit_false_atomic(sys_rt_exec_state,EXEC_STATUS_REPORT);        //清除报告状态清零
, Z" ~3 ?# R4 ]            }
6 b* F9 M9 `; M( W- ]- [3 H_____________________________________________________________________________" `; N0 H' X  E0 r. P! Q4 Z
下面代码2 B5 f6 v7 F" L* s$ w  G8 c3 b
//执行状态。
% S, O- T; I* t* g, j: g5 q//注意:所涉及的数学计算持有应该足够低对大多数人来说,即使不是全部,
/ Y8 m: O, h; I0 [: B4 a" G8 h//操作场景。一旦启动,系统进入暂停状态0 l; p% U$ a0 E$ P( s
//主程序流程,直到重置或恢复。
5 S; D7 F8 A" r, G. e4 |待办事项:检查模式?如何处理呢?可能没有,因为它只会在空闲,然后重置Grbl。
& @7 l( _5 W6 N# n$ D/ {3 N3 K状态检查容许状态的方法。
( M% e" z- k) V% g2 M, `
' M/ H. H0 c% C+ D- @" {1 M        //如果全局各自报警标志位其中(执行取消动作) | (执行进给保持) | (执行安全门)任意一位为真进入; W9 j; L. p# S. U5 m
            if (rt_exec & (EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR)) {        & I2 a+ v) v6 u; ~& n( G) V" u
+ v) h, v" ?, ]% S: f
        //如果是循环状态执行暂停状态
& {# z: j- D3 I: R% c4 Q        if (sys.state == STATE_CYCLE) {+ w' Z& O* Q* ~' T/ S, ?% Y6 V
        st_update_plan_block_parameters(); //通知stepper module验算减速。
) H7 R1 W& Z! w) r, N' G2 K        sys.suspend = SUSPEND_ENABLE_HOLD; // 开始暂停标志0 V9 K* a3 C! x
        }  ]$ w  H% o0 Y* x$ D) v* y
. H7 }3 u9 |- i. z
        // 如果,Grbl空闲不在运动。简单的指示暂停就绪状态。
1 k/ u" M4 W, c7 a3 x- z        if (sys.state == STATE_IDLE) { sys.suspend = SUSPEND_ENABLE_READY; }
: U9 O! _. A, H' ]
. p% u7 a8 x8 G4 N
$ H8 M1 J' E5 V, H        //执行和标志和减速运动取消并返回空闲。主要由探测使用周期
0 M0 G! _# ]' I0 E& \        //停止和取消剩余的运动。      
0 u8 z+ H; x& n2 e# @        if (rt_exec & EXEC_MOTION_CANCEL) {
# Q- c( j; G, ~7 {& O1 q          if (sys.state == STATE_CYCLE) { sys.state = STATE_MOTION_CANCEL; }6 i3 @9 H7 y8 [9 V, n1 q; @/ o
          sys.suspend |= SUSPEND_MOTION_CANCEL; ) d& M/ A. r5 w# Z: r2 ?
        }
7 P+ i, n# W0 `- n6 O
; I1 F# P8 a+ [: V! r& B        // 只在循环时执行进给保持减速
0 V) D. ?5 L7 Q' `, @" e         if (rt_exec & EXEC_FEED_HOLD) {
8 v) G* {" m! J  q0 X9 K. j: @7 x        //只有安全门为1才执行保持进给状态赋值
8 B: w# C: L( ]1 j          if (bit_isfalse(sys.state,STATE_SAFETY_DOOR)) { sys.state = STATE_HOLD; }
) o* z$ D! a% }- z- o+ [        }/ N8 W8 [; i! a* D# |( c

: t9 O3 w2 W! m! ^7 A  Z# I        if (rt_exec & EXEC_SAFETY_DOOR) {
2 \4 I4 e$ Y8 l- Z          report_feedback_message(MESSAGE_SAFETY_DOOR_AJAR);
* c* g2 H* n0 D( ]: m, T/ /如果已经活跃,准备好重新开始,CYCLE_STOP标志设置为强制断开。& k0 T1 Q& \" E  v
/ /注意:只是暂时设置“rt_exec”变量,不是动荡的“rt_exec_state”变量。
4 H' z7 |0 o, M$ L- l2 q. P0 |1 M2 S          if (sys.suspend & SUSPEND_ENABLE_READY) { bit_true(rt_exec,EXEC_CYCLE_STOP); }/ v+ @" p/ `+ V  a3 z: t6 Y1 |
          sys.suspend |= SUSPEND_ENERGIZE;9 P( V7 c  F/ |' i& |1 G, g
          sys.state = STATE_SAFETY_DOOR;
5 C2 e6 z. i$ y        }
! \9 [3 m* j4 {: W( i1 U6 J( D6 ^3 @
bit_false_atomic(sys_rt_exec_state,(EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR));    7 b$ _0 T7 l% j5 v! ^, |

$ m) t5 X6 j6 L- F/ a3 K}' T7 K% ~* {1 W# \" d
以上代码执行了
3 q  N7 N& p5 x& i: c5 q1.如果全局各自报警标志位其中(执行取消动作) | (执行进给保持) | (执行安全门)任意一位为真进入
3 q! E- B7 q; z/ E! {( Y0 F4 l( o2.系统为闲着状态, 开始循环状态, 回原点状态, 控制取消状态, 开始保持状态, 开始安全门状态时进入0 Z- }9 }1 c  S. T
3.如果是循环状态执行暂停状态
) l8 V* Y9 g5 o8 e! M4.如果系统闲置状态执行暂停就绪状态
1 N& G! r3 [# |$ ]% G( B6 N5.执行动作取消
% @  V6 @+ `' C  K6.如果是保持进给状态,执行保持进给状态- ]) O, P0 F( b3 \
7.执行安全门状态
* {$ t6 y% k3 G) [" [( }最后执行bit_false_atomic清标志清除(执行取消动作)(执行进给保持)(执行安全门)标志位                 
; g( Q0 g3 Y4 `7 ~_____________________________________________________________________________
3 U) c  x" d: n7 u' W
6 i. G7 ^9 E0 P3 P    // Execute a cycle start by starting the stepper interrupt to begin executing the blocks in queue.
3 W2 C  ~. C$ P) l! s+ u7 g# Q    // 执行一个循环开始启动步进开始执行中断队列的街区# ^- h+ l' D: w$ L8 W
    if (rt_exec & EXEC_CYCLE_START) {        //循环开始状态进入
2 R5 r; ?, N9 U      // Block if called at same time as the hold commands: feed hold, motion cancel, and safety door.1 @3 g1 s: D( J! g+ q
      // Ensures auto-cycle-start doesn't resume a hold without an explicit user-input.* |3 v6 W" v! W
          //块如果在同时举行的命令:保持进给,运动取消,和安全的门。 //确保auto-cycle-start没有简历没有显式的用户输入。
8 V! A% f( `1 j  W' Z           ! y1 n" N, P1 ^* ]5 s
      if (!(rt_exec & (EXEC_FEED_HOLD | EXEC_MOTION_CANCEL | EXEC_SAFETY_DOOR))) {   //状态机如果不是保持进给,运动取消,和安全的门。
; z; g9 ]- {) z8 g        // Cycle start only when IDLE or when a hold is complete and ready to resume.' C# a% ]% J+ [+ o+ y
        // NOTE: SAFETY_DOOR is implicitly blocked. It reverts to HOLD when the door is closed.
6 ^$ j2 @" X) \( P                //循环开始时只有当闲置或持有完成并准备简历。; V$ f* M$ _) p5 t7 I: m5 H
                //注意:SAFETY_DOOR是隐式地屏蔽。它返回的时候门是关闭的。    , o5 N& G$ j5 A3 L

" r* g) K, {4 L* o6 w                // 如果系统状态为闲着状态,系统状态为开始进给或运动取消,暂停标志为位重新开始* }& D6 m* `( a& r5 u  M: U* r# G
        if ((sys.state == STATE_IDLE) || ((sys.state & (STATE_HOLD | STATE_MOTION_CANCEL)) && (sys.suspend & SUSPEND_ENABLE_READY))) {( S1 j7 H, s. S0 N
          // Re-energize powered components, if disabled by SAFETY_DOOR., x' W# D$ `" F# r& z$ [/ E& \
          //        由SAFETY_DOOR重振组件供电,如果禁用。9 p  o& H1 N7 ], O, F' r$ f
          if (sys.suspend & SUSPEND_ENERGIZE) {
  ?( a5 K2 Z0 f/ `: j, `9 }            // Delayed Tasks: Restart spindle and coolant, delay to power-up, then resume cycle.
4 Z( G* Y: ~/ n  ?+ r2 d6 I/ Z3 l            //延迟任务:重新启动主轴和冷却剂,延迟升高,然后恢复周期。
' t" I( g+ i. G2 {0 ~- |            if (gc_state.modal.spindle != SPINDLE_DISABLE) {   //主轴模式不是失能进入
2 o& V1 n. k9 p* A: Y- s              spindle_set_state(gc_state.modal.spindle, gc_state.spindle_speed); //设置状态和速度$ V! V' k* Q4 o! d6 @4 D2 |; Q
              //待办事项:阻塞函数调用。最终需要一个非阻塞。
$ y& p% @% M# r                delay_ms(SAFETY_DOOR_SPINDLE_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.- K! S$ D& ~+ N4 R8 [0 f* H
            }. k# Y& ~: x3 R/ H
            if (gc_state.modal.coolant != COOLANT_DISABLE) { / p" d; Y7 [) ?" x, F( c$ f5 j
              coolant_set_state(gc_state.modal.coolant); 8 X/ o5 _/ c6 w( u$ d! |& S: Z
              delay_ms(SAFETY_DOOR_COOLANT_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.9 P' Y2 p5 d: Y* \* B$ _6 h
            }
& }0 D& Z) s2 \1 \" R            // TODO: Install return to pre-park position.
$ [, `9 K& b0 s8 W& K* m          }
4 M9 Z- T. T: E2 o7 i______________________________________________________________________________________________________________! r! A  h* z0 x" \2 m  }) K, m( y
          // Start cycle only if queued motions exist in planner buffer and the motion is not canceled.
& @2 ?( X# k. L0 R% `! _                  
% X6 j7 a  |. a# L( r                  //只有在队列马达存在规定的缓冲,并且动机没有让取消,才会循环
- w% }4 v6 o; d0 W9 K                  
+ g+ b8 ^( y3 [- }0 Q9 ^+ {! M7 P          if (plan_get_current_block() && bit_isfalse(sys.suspend,SUSPEND_MOTION_CANCEL)) {/ X7 W3 u/ q$ g& _, z: x8 o
            sys.state = STATE_CYCLE;
- G4 U% L' A3 I. E            st_prep_buffer(); // Initialize step segment buffer before beginning cycle.初始化步开始循环之前
- H- `9 P4 p' Q            st_wake_up();5 {3 J: c& \' w6 x8 G
          } else { // Otherwise, do nothing. Set and resume IDLE state.否则,什么也不做,设置和复位空闲模式- N  ]% A) f+ L4 h- s3 C
            sys.state = STATE_IDLE;
: |% u* k4 }7 f4 e! m2 I          }
; I  V5 I/ i& a6 r% G  }% W          sys.suspend = SUSPEND_DISABLE; // Break suspend state.
! N3 |/ l6 O" `: Q* v' X# F        }- [, G" t0 o" F$ }! ^7 H
      }    % C( e; [/ i! h5 j) ?* s8 Z
      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_START);        4 ^7 u, P, ?2 H: x% Q, ~
    }* r4 J; R4 T* U8 {1 k, R

2 f0 }( [* w! m% S_______________________________________________________________________________________________________5 ]( F+ Y' s3 }6 D: x% f, E
    // Reinitializes the cycle plan and stepper system after a feed hold for a resume. Called by / y& p% U% l! J* q) ^, B
    // realtime command execution in the main program, ensuring that the planner re-plans safely.0 O9 E6 Y1 O! C. R
    // NOTE: Bresenham algorithm variables are still maintained through both the planner and stepper
8 j  q+ X' y  {2 n7 u    // cycle reinitializations. The stepper path should continue exactly as if nothing has happened.   
$ M, B: Y& W; z% Y' t( a. }    // NOTE: EXEC_CYCLE_STOP is set by the stepper subsystem when a cycle or feed hold completes.
- R5 n& f% N4 U9 Z0 r
0 P$ Y% q) l* `- G, k0 {) g        //重新启动后循环计划和步进系统的进给保持简历。通过实时命令执行主程序,确保安全计划重新计划。- _5 H! w- S6 N' ]& X1 S( a+ j+ }' s
        //注意:画线算法变量仍保持通过规划师和步进
/ G4 n2 u. G, u! i3 \' k5 z! f( f6 n        //循环仅。步进路径应该继续,好像什么都没发生一样。       
+ ]* V8 F- k6 _  H( Z        //注意:EXEC_CYCLE_STOP由步进子系统周期或进给保持时完成。
( ], n, k) a/ g0 }7 i% y& H* R9 l5 m3 C
    if (rt_exec & EXEC_CYCLE_STOP) {                         //如果是循环停止状态进入
9 P  M. H( B, x2 @( j( l0 c      if (sys.state & (STATE_HOLD | STATE_SAFETY_DOOR)) {
7 Z' K/ r3 c1 F  ^4 N/ j$ Q        // Hold complete. Set to indicate ready to resume.  Remain in HOLD or DOOR states until user
- s4 [$ |- P2 F9 W        // has issued a resume command or reset.! R  F+ z- ^, }$ i  i1 {$ w' w
+ P% A8 C! o6 E
                //保存完整。设置为指示准备简历。继续持有或门状态,直到用户
4 M( M+ _0 @3 {+ T                //已发布了一份简历命令或重置。
8 z5 n- ?0 K5 ~6 N                4 x! p" j( K9 m
        if (sys.suspend & SUSPEND_ENERGIZE) { // De-energize system if safety door has been opened. 如果安全的门已被打开。断开系统8 f# g2 G  L; f0 v( i- M. D" N; ~
          spindle_stop();) c4 q+ X7 J' W# L. O  O. m, i$ l! l! l/ w
          coolant_stop();
$ b- u4 _/ F4 U( q2 c; `1 X" \8 S          // TODO: Install parking motion here. 安装停车动作。8 X9 ], h: L9 A% i- k  }8 A
        }0 f1 ~1 ]4 d- f) N% X. d" b* q
        bit_true(sys.suspend,SUSPEND_ENABLE_READY);
9 N+ C& L- `+ L1 ^' E9 R) h& m) [      } else { // Motion is complete. Includes CYCLE, HOMING, and MOTION_CANCEL states. 电机完成,循环,回原点,,MOTION_CANCEL
7 p8 R+ s: C2 z$ b* m; H' U/ h        sys.suspend = SUSPEND_DISABLE;4 P4 J9 W3 v# v! n& e+ F
        sys.state = STATE_IDLE;
% a2 i) T: j3 P" t, R, j* a      }% f, j6 i5 V4 W" x
      bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_STOP);
& t3 n/ u& o" L0 }) J. g    }6 A( `/ @6 F& H  {
   
8 V& R( |3 d0 `; p% P  }# }- \  y4 p2 d) d% k0 n5 ?
___________________________________________________________________________________________________
% X8 U0 @, L5 N) I4 j. o% V; t) M# F* ~. D/ b  A
  // Overrides flag byte (sys.override) and execution should be installed here, since they
% g* E% A( V. ^' d( c0 r  // are realtime and require a direct and controlled interface to the main stepper program.
! f0 g. l+ C* ?9 `! d' L* Q
6 [( @7 a3 i5 B+ Q6 f+ r  //重写标志字节(sys.override)和执行应该安装在这里,因为他们
* \- ]3 L% m8 n0 _8 F8 y  //实时和需要直接和控制接口的主要步进程序。% F- K2 |; P! R* O
" g0 @; s/ G2 l8 i8 Q; g+ J
$ H# a3 \, M4 |5 w; v1 C- K
  // Reload step segment buffer 重新加载步段缓冲  Y! w% n2 j8 F9 a% ^
  if (sys.state & (STATE_CYCLE | STATE_HOLD | STATE_MOTION_CANCEL | STATE_SAFETY_DOOR | STATE_HOMING)) { st_prep_buffer(); }
  g4 j" ~9 C. W' u
$ [: \+ \5 Q  r, }4 n7 ?  // If safety door was opened, actively check when safety door is closed and ready to resume.
# O1 u1 O; F/ M' l! s( F  // NOTE: This unlocks the SAFETY_DOOR state to a HOLD state, such that CYCLE_START can activate a resume.        ; n- T  T- \. S: M% @) g$ X
. \, {. z3 R  q. Y1 g+ T" k0 ~
//如果安全的门被打开,积极检查当安全门关闭,准备简历。
( ^+ z* C8 h- k7 n% P* Q  //注意:这解锁SAFETY_DOOR状态保持状态,这样CYCLE_START可以激活一个简历。) ]2 N5 n: \- z4 @; f
4 e- _) w- M/ P9 `/ B# g
  if (sys.state == STATE_SAFETY_DOOR) {                 //安全门状态进入8 L0 o/ S- I' {
    if (bit_istrue(sys.suspend,SUSPEND_ENABLE_READY)) { ' R) c# |! u! X
      if (!(system_check_safety_door_ajar())) {
2 j+ F" E$ D- s  ^5 L! x, A        sys.state = STATE_HOLD; // Update to HOLD state to indicate door is closed and ready to resume. 更新保存状态指示门关闭,准备简历。: |  n. c: c3 W- l; s" T" e
      }
' H$ Q9 x$ S9 P; p% O. f9 M! p& w    }. y; o9 Y5 u3 }/ ?0 R
  }
' y, P2 G2 P/ u( _( V) T, A' K, x# E; {/ B* ~) |, S4 s" k8 t/ N, B
  } while(sys.suspend); // Check for system suspend state before exiting.# z' z( u+ V' |+ a: `0 u
  ; S1 }( V% J5 h: _7 j
}  
发表于 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-10-14 21:19 , Processed in 0.101184 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.5 Licensed

© 2001-2025 Discuz! Team.

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