机械必威体育网址

找回密码
注册会员

QQ登录

只需一步,快速开始

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

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

[复制链接]
跳转到指定楼层
1#
发表于 2016-8-20 23:56:23 | 只看该作者 回帖奖励 | 倒序浏览 | 阅读模式
本帖最后由 1五湖四海1 于 2016-8-21 00:09 编辑" S& \, X& J8 G7 |2 [
! o! h2 _4 T) Y8 t( K; t1 W
以前制作过CNC雕刻机,是用MACH3作为上位机控制,硬件是采用PC接并口输出脉冲和方向使能信号经过隔离驱动步进电机驱动器,步进电机驱动是采用TB6560芯片控制。最后就接到步进电机。机械是用铝合金制作,主要部件有三个1605的滚珠丝杠,多个运动滑块等制作。用这台DIY CNC雕刻机可以雕刻木头塑料等东西。当时没有一直玩下去,现在发现网上有用单片机制作的雕刻机挺精巧的现在分享给大家。
) S2 |$ Y3 g G% h: P( w3 uGRBL 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个运动来规划运行速度,以实现平稳的加速和无冲击的转弯。很棒吧!开始玩起。% M8 s3 e3 h0 r5 r+ z3 q; a5 `
还没有雕刻机的机械部分可以用废旧光驱制作个微型雕刻机运动平台。雕刻机最重要的是主控程序这次用Arduino/AVR328单片机,价格在15元左右,主控程序是上面提到的目前很火的开源
的GRBL,还有一种基于STM32平台的开源主控程序Dlion也不错可以替代grbl。如果从性能比较这两个方案,显然是stm32平台运行速度更快毕竟他是32单片机呀!
' R1 ?* n, r( e" a`3 @# U7 ~* s. Q7 k6 o5 H

/ l2 i9 E. q$ T" c& B下面介绍小这个些主控程序主要干的事,通过串口PC和主控板通讯,PC命令给控制板,控制板接收命令做不同的响应,PC可以发G代码给主控板,接收完成后可以自动开始雕刻任务。; h/ S+ B8 P5 u4 F
在介绍下G代码因为G代码是雕刻机的核心部分
6 r' f0 g4 V' a/ C0 J, _& LG代码是数控程序中的指令。一般都称为G指令。8 E& `5 C# A/ L! V
G00------快速定位
0 R) H# V8 ]( B- K& u2 kG01------直线插补1 ^9 ?% \2 \7 S# {$ b
G02------顺时针方向圆弧插补$ u: ^+ C: j3 D+ u
G03------逆时针方向圆弧插补
" K i7 G, ?: lG04------定时暂停m) |) h1 ~, r2 \
G05------通过中间点圆弧插补
9 u& ~! O% z6 Q) HG06------抛物线插补
6 g: X( t- g8 J! LG07------Z 样条曲线插补! q0 A, |8 `; |* R( ~
G08------进给加速
1 O+ I' b1 v; @G09------进给减速& Q: ^4 r# U- ^4 }
G10------数据设置
5 B' @, F2 Y" X, ^4 G' g9 [G16------极坐标编程
8 d2 s2 g. M" N- ~4 }. AG17------加工XY平面& }# _: _* ]% o- L, f' c+ y* `
G18------加工XZ平面. S: h: V0 O, R. f
G19------加工YZ平面
7 @. R5 D4 c; p1 _1 U& Q
核心就是解析G代码,完成步进电机驱动,和控制主轴开启关闭,还有插补算法,直线插补,圆弧插补,还有一些步进电机的加减速算法。
5 _( J" D M5 A下面对grbl主结构做介绍0 z3 q% {% U9 t$ ^8 U" ?( J4 d) L: v
main()主函数首先执行下面初始化函数# C8 j+ z. L! s& C: G" J
serial_init(); // 设置串口波特率和中断
/ k2 m! P! a5 n( B: ~- _settings_init(); // 从ROM加载grbl设置
4 O- j6 Q: S4 G7 x. K! sstepper_init(); // 配置步进方向和中断定时器
* u6 d" a$ g" _6 Rsystem_init(); // 配置引脚分配别针和pin-change中断T" O. b, M" r/ G
memset(&sys, 0, sizeof(system_t)); // 清除所有系统变量7 H% x3 g8 b5 l9 j
sys.abort = true; // 中止标识位置位+ O1 y- D( z/ I5 h, K
sei(); // 使能中断
4 F# p F# | ?6 f+ i- P( T#ifdef HOMING_INIT_LOCK // 宏运算(settings.flags & (1 << 4)) != 0结果flags等于执行sys.state = STATE_ALARM
: E o, E W& v2 f5 H6 z// 系统状态赋值为报警状态/ P, x2 w, \1 r( K8 p) o' r+ j
if (bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE)) { sys.state = STATE_ALARM; }5 g* V. z2 ~* J. N; w& H' U' q
#endif
# V5 K# q! [) g- ]_____________________________________________________________________________________________________________________________________3 | E5 l6 z# f9 n8 i4 g Z4 T
接下来是一些主要部分初始化
/ E3 R! r. n q. i* p qfor(;;) {
# N& B! F4 ?1 R$ y) g, `5 N/ Oserial_reset_read_buffer(); //清除串口读缓冲区
: S6 O9 [# P, `, V$ agc_init(); //初始化G代码功能函数* u6 ]' P/ `8 i# A4 H
spindle_init(); //主轴初始化( g- P' t5 _# h9 G
coolant_init(); //冷却液初始化
4 i5 C6 x8 ~' O/ t& Q$ r# llimits_init(); //极限开关初始化
- o0 `$ l# i6 j$ O7 ~0 ]probe_init(); //探测部件初始化
5 i9 X% ?5 c- d) `7 Mplan_reset(); //清除块缓冲区和规划师变量) L/ d4 m) j- Z5 \, m! ?; H
st_reset(); //清除步进系统变量。8 B8 }2 h) B5 D& [3 }; E8 k
7 X$ j4 I; V5 y ]

( }$ W7 C. \" o- _$ N//下面两行清除同步gcode和策划师职位当前系统位置。( v3 Q6 ]3 f ~. A/ A' g
plan_sync_position();
' Q% {: r7 T8 c$ b4 ^& c# t% Ngc_sync_position();8 Z% P1 f3 V2 ^& C* z
; i6 T0 w" Y! d8 L
" @4 J- \' D' e0 s
//复位系统变量
' k1 I- M- k; Msys.abort = false; //系统中止标志
* ]8 c$ o3 H" J" ?! x) ^: Vsys_rt_exec_state = 0; //系统标志位变量状态管理。看到EXEC位掩码。
) {7 g' L3 k' l, Q) A3 gsys_rt_exec_alarm = 0; //系统标志位变量设置不同的警报。
" h; V# X$ w0 A3 Q- fsys.suspend = false; //系统暂停标志位变量管理,取消,和安全保护。
/ T$ K# d3 h0 isys.soft_limit = false; //限位开关限制状态机错误。(布尔)
3 r! g" _5 n- f5 u) b" J+ {* K* w: J. H0 A

0 ~4 n3 c( Y2 F1 b" dprotocol_main_loop(); //主协议循环
' Q' I) r2 M( g3 M( c" _5 U" f} //
& }8 A# C+ f+ ~* N_____________________________________________________________________________________________________________________________
, w2 v6 W6 N' I' A& I' L进入void protocol_main_loop()函数. o E( @% B, H$ p
{. I3 V3 f/ T! X! D: H# Z
report_init_message(); // 打印欢迎信息( R9 j' z A% m( z( }* _: d+ B# [
//重启后检验和报告报警状态如果错误重启初始化。
- O" s* B: H/ S5 B+ ~) h( F* p
if (sys.state == STATE_ALARM) {+ ?' m( G5 n) f2 S2 t- g
report_feedback_message(MESSAGE_ALARM_LOCK); //打印信息8 H; D. V* w& A4 F, W0 \
} else {
( q# H: N+ b5 f0 r9 g// 如果没有报警说明一切正常!但还是要检查安全门.
$ n8 D* W2 D. Q6 }4 y! }5 s' l0 X+ Tif (system_check_safety_door_ajar()) {# L- J. f+ S' U7 @
bit_true(sys_rt_exec_state, EXEC_SAFETY_DOOR);
8 B/ i2 A5 u0 R; F H mprotocol_execute_realtime(); // 进入安全模式。应该返回空闲状态。9 W3 F. c$ ?6 @' _- H2 _
} else {4 Y1 I6 e& @) J; o% N8 v' ^: }/ J
sys.state = STATE_IDLE; // .设置系统做好准备。清除所有国家国旗。
4 J5 m6 B2 f! E, u}1 a3 ]6 l W4 y" @
system_execute_startup(line); //开始执行系统脚本1 b5 ]8 f" x2 b5 Y
}
& H; F' P5 \% K( }+ h* K, r' o. s
, K& d& I p- W0 V# _& |& x
// 这是主循环!在系统中止时这是出口回到主函数来重置系统。
4 {: w4 x/ S* s" G# z- ~# U// ---------------------------------------------------------------------------------
) j1 l- g2 M$ f
8 t0 b: L# @# M: n- j- Q! ^5 Juint8_t comment = COMMENT_NONE;
E. |8 n. ^; E% u5 |uint8_t char_counter = 0;
! q/ D: ]: T N+ x p/ Uuint8_t c;/ G% x" ]8 G* d# h% r" l
_______________________________________________________________________________________________________________________________
* N! ~% d& e3 g接下来进入for(;;)循环 //下面代码是G代码解析核心部分,程序中comment(注释)变量会被赋不同值,代表发符号有‘(’‘)’‘;’# d( f4 l7 I% ?3 y, E3 ?
{: M$ U. M L2 h; [0 K; D9 F
//串行数据输入一行的的过程,作为数据。执行一个
/ b! Z2 S9 f+ x+ a4 i//所有数据初始过滤去除空格和注释。+ l! @8 S" S& L* r7 Q
//注意:注释,空格和程序段删除(如果支持的话)处理技术& J3 U% v0 ]$ j$ C& ?) H
//在G代码解析器,它有助于压缩到Grbl传入的数据
L. ` E, Y, J- ^//线缓冲区,这是有限的。刀位点标准实际上州一行不行
! Q; a/ C% S; k {4 E7 m& m% `//不能超过256个字符,Arduino Uno没有更多内存空间。9 r, y/ x# S* c z5 c
//有更好的处理器,它会很容易把这个初步解析的) A1 q- e) z( {4 {8 T
//分离任务共享的刀位点解析器和Grbl系统命令。. B6 ]9 C- ?3 W8 I% Y5 ]6 a
while((c = serial_read()) != SERIAL_NO_DATA) { //读取串口数据,有数据执行下面代码2 {# {/ ?. k/ J) y! f. i+ V
if ((c == '\n') || (c == '\r')) { // End of line reached //如果数据是/r,/n代表一行结束
& H* f z+ `0 x- N! e" nline[char_counter] = 0; // Set string termination character. //设置结束标志
: _* e+ l- q1 p x+ n3 S8 Eprotocol_execute_line(line); // Line is complete. Execute it! //一行完成执行此函数
# a: v- d- R, _8 X5 J$ Mcomment = COMMENT_NONE; //注释清零|$ B1 K3 d4 i' Q; m; |
char_counter = 0; //字符计数清零
% F u( `2 f) l. k) b { Z+ b+ i1 R9 q/ E6 R
else {5 H) n; I# E# k$ l/ u$ Q, \ j
if (comment != COMMENT_NONE) {$ u8 e& `6 p, U' N v
//扔掉所有注释字符
- T7 ? }$ L& }$ Q8 Lif (c == ')') {
1 n0 G9 p" ]# o0 L8 x//最后注释。重新开始。但是如果有分号类型的注释。
/ p2 n6 ^% [' {( ?if (comment == COMMENT_TYPE_PARENTHESES) { comment = COMMENT_NONE; }0 F# F7 e' M3 e) e: O x
}6 ~7 M/ m' ~4 O, r8 d( g% {
} else {
\% K7 s$ E P8 p% @1 Eif (c <= ' ') {8 j9 U( H9 B7 |# a4 u. _
//扔掉whitepace和控制字符- K; }' A1 r: d# H' l0 y
} else if (c == '/') {# I7 ~- h: H' ~7 d+ s
//块删除不支持将忽略字符。3 q* g# Y. Z, |+ c8 \4 P3 J) ?
//注意:如果支持,只需要检查系统是否启用了块删除。8 e* i- x, b; ^
} else if (c == '(') {; _5 E [+ N+ `5 X
// Enable comments flag and ignore all characters until ')' or EOL.
: F2 j3 Z5 C/ x9 b. T$ I& T4 m2 u// NOTE: This doesn't follow the NIST definition exactly, but is good enough for now.- o0 T' W8 c2 i# r5 q- @" y# R
// In the future, we could simply remove the items within the comments, but retain the
7 J) ]" n, O& D, T k// comment control characters, so that the g-code parser can error-check it.
, P8 }" T5 v" z( y pcomment = COMMENT_TYPE_PARENTHESES;$ R+ Y2 o" n4 k, P. k, y, Z
} else if (c == ';') {/ [' ^5 l/ U* j7 N7 S
//注意:','注释EOL LinuxCNC定义。没有国家标准。6 A- _, m% ~( Q/ ?9 g& T( A
comment = COMMENT_TYPE_SEMICOLON;
& v! C, m8 D9 f0 M3 W/ A7 P& y6 _) f: e; o& }! Z
* ^4 D' l+ n; X9 o8 \! k
_____________________________________________________________________________________________________________________________________8 c3 g5 ]; \; e
} else if (char_counter >= (LINE_BUFFER_SIZE-1)) { //串口接收数据大于80字符时2 T, [! T# S; t( {, q* l
// Detect line buffer overflow. Report error and reset line buffer. 检测缓冲区溢出。报告错误和复位线缓冲区。% g5 c2 Q* _0 F! G& B- Z" d& x
report_status_message(STATUS_OVERFLOW); //打印溢出信息
5 n" `+ S- X0 i e" R* a# n. m" e9 acomment = COMMENT_NONE;
8 {5 s# ]% z: b I% wchar_counter = 0;' Q" v0 b2 B/ p+ x! ?$ y
} else if (c >= 'a' && c <= 'z') { // Upcase lowercase //小写改大写T- B# o0 v, E( i
line[char_counter++] = c-'a'+'A';# F' p0 I4 @ y/ h( b$ L: \
} else {
6 u" `6 y; |1 W& U: eline[char_counter++] = c;
0 S9 g# E0 O6 j7 {) Q! z7 S}+ ?* ]. t4 g2 A$ n. x
}" Y, K% N$ |* K! f5 R7 C
}& R' X4 V3 a/ J) {
}
4 Q% n b! v9 N: O, Z0 U8 b____________________________________________________________________________________________________________________________________. z7 M/ A U5 ]. \+ k5 @
//如果没有其他字符在串行处理读取缓冲区和执行,这表明以完成,自动启动,如果启用,任何队列动作。) e( l% E& D9 V! ]# _
protocol_auto_cycle_start(); //自动开始协议循环
7 P5 G& Z- {- a- c5 W. E1 D7 E0 k5 O; R1 w. ^
protocol_execute_realtime(); //运行实时命令。. `' l' T! G0 Z0 g' Z8 x3 ]% E' j
if (sys.abort) { return; } //中止标识置位程序循环重置系统。3 ?( r6 S* z3 i- a' k1 k
}" e1 P4 e0 P* V0 y5 [
return; //一般程序不会执行到这里
5 ~; N9 ~0 w2 l. M. {8 n* ?}$ z) v6 j, o4 S0 S8 K" q
____________________________________________________________________________________________________________________________________8 F" M% T1 _* Q g' `: A% ?
正常情况下,读取完G代码程序会进入protocol_auto_cycle_start();//自动开始协议循环 函数下面介绍此函数* C, S$ M6 U0 J1 u# Y- c6 H1 V
// Auto-cycle start has two purposes: 1. Resumes a plan_synchronize() call from a function that$ n2 K! A d, e$ x7 r- Y
// requires the planner buffer to empty (spindle enable, dwell, etc.) 2. As a user setting that
4 g- L7 B2 g( I6 G/ o$ y// automatically begins the cycle when a user enters a valid motion command manually. This is7 n: C. h: q2 O& a6 F
// intended as a beginners feature to help new users to understand g-code. It can be disabled5 [. r3 d7 c7 ?
// as a beginner tool, but (1.) still operates. If disabled, the operation of cycle start is4 c2 o6 e* p- |5 s% a
// manually issuing a cycle start command whenever the user is ready and there is a valid motion+ I# X4 w y; W! I. ~5 N
// command in the planner queue.
! L8 W# b% W) z2 O7 s// NOTE: This function is called from the main loop, buffer sync, and mc_line() only and executes
E: H6 c9 a: ^0 D# g' {' b// when one of these conditions exist respectively: There are no more blocks sent (i.e. streaming0 g' F/ I8 Q( |$ @
// is finished, single commands), a command that needs to wait for the motions in the buffer to
# r, o( @! g" Y7 f// execute calls a buffer sync, or the planner buffer is full and ready to go.
/ f; l; t' D. A# J//自动开始有两个目的:1。回复一个plan_synchronize()调用的函数+ q/ C# `2 D0 X5 {; y9 B
//需要规划师缓冲区空(主轴启用、住等)2。作为一个用户设置w$ _, f5 z& H6 u U8 N
//自动循环开始当一个用户输入一个有效的运动命令手动。这是. F q( o3 N; ^" P: |$ e
//作为一个初学者的特性来帮助新用户了解刀位点。它可以被禁用
- {+ W* L s( y% _$ \3 t//作为一个初学者工具,但(1)仍然运作。如果禁用,运行周期开始' }, y# w: J( \4 i' J
//手动发出一个周期开始命令每当用户准备好,有一个有效的运动
- I% s. Z8 Y( Q/ h/ K1 r u: `//命令的规划师队列。0 u( }# ]* X) [1 _0 R; g& [
//注意:这个函数被称为从主循环缓冲区同步,mc_line只()并执行[5 H" s( N; d9 B7 S
//当其中一个条件分别存在:没有更多的块(即流发送8 ^% g% O9 X' b; C, f' x3 K& a
//完成后,单一的命令),一个命令,需要等待缓冲的动作
4 X2 ?. z% Z" F2 ^4 b//执行调用一个缓冲区同步,或规划师缓冲区满了,准备好了。
; ?8 y N. v7 N4 ^3 zvoid protocol_auto_cycle_start() { bit_true_atomic(sys_rt_exec_state, EXEC_CYCLE_START); }
) q6 X8 H1 r; C( R0 k( j$ O_______________________________________________________________________________________________1 h6 T7 c2 O1 Q0 O2 q* H, N' t- N. p
接下来程序运行protocol_execute_realtime(); /运行实时命令。
8 J8 D9 f# G, ]) ^' | N// Executes run-time commands, when required. This is called from various check points in the main" u! }$ {) f. o" B: D) O
// program, primarily where there may be a while loop waiting for a buffer to clear space or any9 w- l6 ^& s( e6 } m" f
// point where the execution time from the last check point may be more than a fraction of a second.
6 [0 f+ u9 g% {8 m7 v7 @// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code
+ R$ x0 [, J+ f) j x/ z% n1 `// parsing and planning functions. This function also serves as an interface for the interrupts to8 g2 @* Y3 { n0 V' i: C
// set the system realtime flags, where only the main program handles them, removing the need to
r5 e3 m; Y8 u( y" j) _// define more computationally-expensive volatile variables. This also provides a controlled way to" ?: }& k. c. a' p* {1 u) D: _& R
// execute certain tasks without having two or more instances of the same task, such as the planner
- {4 L* U$ g& o# ^$ K// recalculating the buffer upon a feedhold or override.
& Q3 U/ Y; B0 E( x( t# a// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,7 X/ _6 G \6 @6 r" D
// limit switches, or the main program.
: a9 r3 n7 j( Zvoid protocol_execute_realtime()
$ _% J2 @) S4 D5 Huint8_t rt_exec; // Temp variable to avoid calling volatile multiple times.临时变量来避免多次调用不稳定。
5 ]9 _. G3 |- \* j就先分享到这吧!
t2 g4 |3 X7 [$ v: }
! O5 O% d0 d' @% p4 e. l, r( O6 Z& x! v( M- h1 q
/ k2 E+ J5 D( A" Y. \$ m4 p2 b2 `
. a$ g# A: |: `- c* C7 J) a8 R+ S, D

1 z1 H; W1 K% l' V# Y! Z. @1 v9 S6 ^4 X

9 D* W" ?; S1 c& o! Q. N9 d
& P# r* A. ?9 p; z* |$ d2 O# _: F2 p" V/ T" p7 @7 i

( X4 u6 f& n, R* E" G( E( i) F; Z. g# t( m9 z* y
! ?9 G& J; v5 c8 S7 f

+ [3 k* |, D' u+ y9 h* h, @3 ~; m X6 Q

$ @( w. _/ y p! D6 D3 a/ L, V( ^/ |5 i" n6 |

y) m! z" f( Z( D; \* j0 Y
! x& y; ]6 z7 \4 Y. H' t/ `$ T8 w8 m: Z1 S8 y) ]" g1 h9 e5 q! j

& V- C7 Q3 r$ K3 |/ n+ }, c+ V! N2 H
6 ]: F& ]: A: [- I6 J' A5 T
* v; h i) ?! l: _- B3 S
{ U* `; Q5 p0 M; x- z补充内容 (2016-8-25 22:40):9 B1 `6 W" Z+ F/ v. t% s; E% _
配置说明
% x/ u, R* O# t8 d# D5 ]//这个文件包含编译时配置Grbl的内部系统。在大多数情况下,
+ l" X) |3 K) j% {//用户不需要直接修改这些,但是他们在这里为特定的需求,即。# ?& @ y3 g9 E8 k: L5 w2 o2 }% ~
//性能调优或适应非典型的机器。: E$ i6 ^& }8 I* x
主要配置项:* s8 b5 R& S' R- U3 f7 j8 X; W
1.#define DEFAULTS_GENERIC //在重置eepm时使用。在defaults.h改变想要的名字, x2 E' b: I8 g9 z
2.#define BAUD_RATE 115200 //配置串口波特率115200
& b0 N/ F, _5 b7 @+ n; h; E3.#define CPU_MAP_ATMEGA328P // Arduino Uno CPU' f* _7 r- B; y/ E+ m
4.#define CMD_STATUS_REPORT '?' //定义实时命令特殊字符
( K! N8 x( o k& {0 ~5.#define HOMING_INIT_LOCK //回原点保护锁6 c9 a7 c( W6 b: n) l( Y5 p0 |
6.#define HOMING_CYCLE_0 (1<; H! G. x) {% T: ]! I7 Q7 G
#define HOMING_CYCLE_1 ((1</ X9 T+ X* g( W, H
7.#define N_HOMING_LOCATE_CYCLE 1 //回原点循环次数
# W" W n6 q+ b- l. c- m8.#define HOMING_FORCE_SET_ORIGIN //取消这定义迫使Grbl总是在这时候位置设置机器原点尽管开关方向。$ ^/ v0 ~ c: ~1 k6 M% D- z
9.#define N_STARTUP_LINE 2 //块Grbl启动时执行的数量。6 n7 ?. }3 G0 T5 y$ m) B/ a- {. Y
10.#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 协调或位置价值英寸" i; I! @1 S+ m; \" N0 n3 G6 A0 k6 _7 T
#define N_DECIMAL_COORDVALUE_MM 3 // Coordinate or position value in mm 协调在毫米或位置价值5 z) [* R4 A( Q8 g
#define N_DECIMAL_RATEVALUE_INCH 1 // Rate or velocity value in in/min 率或/分钟的速度值; d& @0 c( y; w) k8 h) @$ [- L
#define N_DECIMAL_RATEVALUE_MM 0 // Rate or velocity value in mm/min 速率或速度值在毫米/分钟
+ S6 U6 m; j2 q' V2 w#define N_DECIMAL_SETTINGVALUE 3 // Decimals for floating point setting values 对浮点小数设置值
, v- t5 H% V% ]/ W11.#define LIMITS_TWO_SWITCHES_ON_AXES //如果你的机器有两个极限开关连接在平行于一个轴,您需要启用这个特性K, v E8 f4 C
12.#define USE_LINE_NUMBERS //允许GRBL跟踪和报告gcode行号
% q5 s0 R+ m8 |5 E5 S13.#define REPORT_REALTIME_RATE //允许GRBL报告实时进给速率- S @4 t [( k# j" }1 N
14.#define MESSAGE_PROBE_COORDINATES //坐标通过Grbl $ #的打印参数?
$ Y; A5 \( a( R' V W15.#define SAFETY_DOOR_SPINDLE_DELAY 4000 //安全门主轴延时
3 F# y, y- ~1 A& ^' P$ T16.#define SAFETY_DOOR_COOLANT_DELAY 1000 //安全门冷却液延时; h' U8 v0 ]# { H; A0 l1 f2 h
17.#define HOMING_CYCLE_0 (1<* X+ F2 a6 l0 Z
18.#define COREXY // Default disabled. Uncomment to enable.改变X和Y轴的运动原理
) E! D( n5 e) [) ~: Z4 A19.#define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.反转针销逻辑的控制命令
! N: d/ S+ q8 I7 Y20.#define INVERT_SPINDLE_ENABLE_PIN // 反转主轴使销从low-disabled
* Y0 c7 t; |" ^) o) ?$ g21.#define REPORT_CONTROL_PIN_STATE //启用控制销状态反馈状态报告。7 v5 L$ ~; y- p
22.#define FORCE_INITIALIZATION_ALARM //启用和用户安装限位开关,Grbl将启动报警状态指示
! M9 [& R L' C8 Q/ R- Q6 Y, w* `23.#define REPORT_GUI_MODE // gui允许最小的报告反馈模式" J' m3 _6 d) P4 N0 ~
24.#define ACCELERATION_TICKS_PER_SECOND 100 //加速度的时间分辨率管理子系统。- g% v5 ]) N% Y" |2 S" q0 O# Y& d
25.#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING //自适应多轴步平滑(积累)是一种先进的功能( p/ i! R" a. W$ V; b: j P+ n
26.#define MAX_STEP_RATE_HZ 30000 //设置最大一步速率可以写成Grbl设置6 i& ~. f! f H C- C
27.#define DISABLE_LIMIT_PIN_PULL_UP //以下选项禁用内部上拉电阻
9 ~. G8 a( L" e2 ]28.#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS //设置哪个轴长度补偿应用的工具。假设轴总是与选择轴工具面向负方向
$ k2 U7 }3 V, C' H; F- d$ u29.#define VARIABLE_SPINDLE //允许变量轴输出电压不同的转速值。( e7 } i. a3 m6 C) V
30.#define SPINDLE_MAX_RPM 1000.0 // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.& F. P. [% _# }( I" \
#define SPINDLE_MIN_RPM 0.0 // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.
; K! `* H# G6 Y! J31.#define MINIMUM_SPINDLE_PWM 5 //使用的变量轴输出。这迫使PWM输出最小占空比时启用。+ V* G- ?9 F$ N$ q Y$ A$ V- i1 H3 A- A
32.#define USE_SPINDLE_DIR_AS_ENABLE_PIN //主轴方向使能M4被删除9 Z* q* h& O" d2 k- T
33.#define REPORT_ECHO_LINE_RECEIVED //应该对所有正常线路送到Grbl5 E' y. V; a6 p4 j: p% r+ P) N
34.#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min) //最小规划师结速度。设置默认最小连接速度规划计划
' ^3 P( ^: Z0 z ^' ~4 j35.#define MINIMUM_FEED_RATE 1.0 // (mm/min)//设置计划将允许的最小进给速率
: Z6 C, X" [3 w( `2 T36.#define N_ARC_CORRECTION 12 //弧生成迭代次数之前小角度近似精确的弧线轨迹
1 E3 K: p! o' L: a6 Z, N37.#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)//定义值设置机器ε截止来确定电弧是一个原点了?
- u$ H0 F3 t, @7 V5 e/ T, Q38.#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds) //延时增加表现在住。默认值设置为50毫秒
4 b9 A( n& z+ `1 X9 }: s) |. c39.#define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.6 r- ?9 L3 p! P q/ d2 q
40.#define BLOCK_BUFFER_SIZE 18 //线性运动规划师缓冲区的数量在任何给出时间计划
! f1 }6 I3 y7 ^ ~41.#define SEGMENT_BUFFER_SIZE 6 //控制之间的中间段缓冲大小的步骤执行算法
, q7 I& B4 R0 W& i7 s42.#define LINE_BUFFER_SIZE 80 //行执行串行输入流的缓冲区大小。
( N5 _: w: m0 t# W/ {; e& W* k43.define RX_BUFFER_SIZE 128 //串行发送和接收缓冲区大小
2 n- }0 v5 R% }4 J+ E6 s- D44.#define TX_BUFFER_SIZE 64
: }& w" @& z. q- D/ w0 ]! c45.#define ENABLE_XONXOFF ////切换为串行通信发送流软件流控制。
8 Y/ v! c3 w( l; F: j/ U8 ^9 ^46.#define ENABLE_SOFTWARE_DEBOUNCE //一个简单的软件消除抖动特性硬限位开关。" {5 i" C1 G" G! f+ c7 H2 S. D
47.#define HARD_LIMIT_FORCE_STATE_CHECK //Grbl检查硬限位开关的状态
0 F& a. T5 a V0 L5 }- {: [5 w48.// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:编译时错误检查的定义值:% [: m, l$ Y# z$ D$ Z

1 y6 [! [- g1 ~$ Q___________________________________________________________________________________________________
- e6 I1 f1 ]0 d; s- ?& h/*4 N- X; x( @, m0 S
config.h - compile time configuration; u' h7 @) h8 n0 L. ^
Part of Grbl9 V0 q' L. N. X0 T) P- y
% y1 C6 O7 B( A
Copyright (c) 2012-2015 Sungeun K. Jeon% `/ ]! E' ?- n5 N( i5 X
Copyright (c) 2009-2011 Simen Svale Skogsrud
8 \& H* i1 J3 f, M" V+ \8 n9 s
- @# z- i- j0 D$ n0 F+ U7 o7 IGrbl is free software: you can redistribute it and/or modify( \: F4 e" _( t: n3 T
it under the terms of the GNU General Public License as published by
, ` j7 U) L' ~" Ythe Free Software Foundation, either version 3 of the License, or6 j5 U5 D" }! V1 T
(at your option) any later version./ i7 Q$ C0 s# q" b* {/ X

) Z/ Z& t& ]; O F" FGrbl is distributed in the hope that it will be useful,
; I" X/ y5 n% x/ y5 L8 m- Abut WITHOUT ANY WARRANTY; without even the implied warranty of
- P+ _7 ?( h% t3 TMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the! k: R; Z# F! ^
GNU General Public License for more details.
& J" g9 T5 G! a- K$ ^) n
3 n7 u! W; u: C) U; A9 }You should have received a copy of the GNU General Public License
) z4 [6 b, P+ E0 ?; `. ealong with Grbl. If not, see .
9 V) U, L4 m# `. j' _/ Z) hconfig.h -编译时配置,Grbl的一部分& A I/ F& s4 w3 f) j6 |

( K' o! Z0 ` z版权(c)2012 - 2015 Sungeun K. Jeon" v3 ^7 E: A1 u2 V1 |2 S
版权(c)2009 - 2011 Simen Svale Skogsrud
6 z* P4 {, U; K+ R2 n
" w- }' [6 v, j- ~/ e5 `Grbl是免费软件:可以重新分配和/或修改
! `! M6 y7 Q+ e4 z6 b' uGNU通用公共许可证的条款下发布的自由软件基金会,版本3的许可,或(任您选)其后的版本。; e9 V+ Q( | g, b9 x$ V3 L% [

0 R. G* ?; V9 A& c. R& n+ u- vGrbl分布,希望这将是有用的,但是没有任何保证;没有即使的默示保证适销性或健身为特定目的。看到
" j2 c' |- P J7 K& F5 QGNU通用公共许可证的更多细节。. Z' ^, j5 d7 ]( `2 I
! [. W2 n& u& f( O
你应该收到了GNU通用公共许可证的副本
( A" J8 C! S' T3 b连同Grbl。如果没有,看< http://www.gnu.org/licenses/ >。
0 p: u5 t1 e* L, }6 \; {" K' S; q0 l& K( @6 j+ V- Y5 d
*/
3 p5 ~; v2 I8 R) I6 h0 Z
9 |5 H4 n0 M' I// This file contains compile-time configurations for Grbl's internal system. For the most part,
6 z" K6 k5 G5 d! n// users will not need to directly modify these, but they are here for specific needs, i.e.8 {& g ^# r: z8 ^- k! y. E, ?" Q. ], a
// performance tuning or adjusting to non-typical machines.
* M3 m" r% p4 w$ @# W//这个文件包含编译时配置Grbl的内部系统。在大多数情况下,
7 q7 P& L% k0 k7 G//用户不需要直接修改这些,但是他们在这里为特定的需求,即。( h+ f, \* Y# c0 ^! o
//性能调优或适应非典型的机器。
`: o. t2 J) h8 V2 S+ |
9 r: ~# J" y3 W2 n9 y1 |: m/ K( D// IMPORTANT: Any changes here requires a full re-compiling of the source code to propagate them.+ q3 s+ g/ r! q5 c' \6 z
//重要:任何变化需要一个完整的基于源代码的传播。
* e% P4 T) L- ~4 a4 M
: @/ y3 B; h) V8 x5 r4 J#ifndef config_h
( V% B8 t3 L4 Z9 O" w/ P: q; M8 }#define config_h
9 a& ^, x5 B$ o1 M#include "grbl.h" // For Arduino IDE compatibility.; g% a0 @* N5 Y9 a+ v7 b" R

9 {6 ~# J h7 G4 |/ r7 _// Default settings. Used when resetting EEPROM. Change to desired name in defaults.h
& b) n7 n" R# }1 W. n$ F3 X// 默认设置。在重置eepm时使用。在defaults.h改变想要的名字
" I, F( ^, [# u9 U7 q9 ]3 p
' h& o j/ j ~8 }- x- f#define DEFAULTS_GENERIC% W2 u [1 J: f7 q3 Q/ }

* t" W5 I& }0 Q5 j/ f) n// Serial baud rate
* B# K* i1 {3 U5 S1 x% @0 Q6 \( I#define BAUD_RATE 115200 //配置串口波特率1152002 r# c4 }" ]. h @9 w% V
( D- O _0 v8 u; |$ M& F+ Q
// Default cpu mappings. Grbl officially supports the Arduino Uno only. Other processor types
' s( S8 u, H8 P% p) L// may exist from user-supplied templates or directly user-defined in cpu_map.h
4 b* ^6 u* q( k6 R5 a//默认cpu映射。Grbl正式支持Arduino Uno。其他类型的处理器可能存在cpu_map.h直接从用户提供的模板或用户定义的7 R( F6 q: R" j/ q/ c$ J2 ~

" ?( _% u; C3 A' g7 ?, r#define CPU_MAP_ATMEGA328P // Arduino Uno CPU% F: u: m5 l2 C0 y4 b* d
3 g* _# Z$ {1 k' ~ I
// Define realtime command special characters. These characters are 'picked-off' directly from the
4 p& @2 ?8 C4 [// serial read data stream and are not passed to the grbl line execution parser. Select characters( Y) z' P: T, I" v5 J4 r9 p
// that do not and must not exist in the streamed g-code program. ASCII control characters may be6 f( R6 n& A* c0 T" b# T
// used, if they are available per user setup. Also, extended ASCII codes (>127), which are never in3 ]" X, p Z; d/ O& C
// g-code programs, maybe selected for interface programs.
. t8 \1 e: F* w// NOTE: If changed, manually update help message in report.c.
1 D& \4 E/ A* f, r) [6 u/ L8 H7 y9 O& K$ \: g: i1 o: D. c+ U5 f) C
//定义实时命令特殊字符。这些字符是直接从“各个击破”串口读取数据流并没有传递到grbl行执行解析器。选择角色
+ [6 g$ o) p6 r$ }# F+ }//不,不能存在于程序流刀位点。ASCII控制字符
5 }) \ u+ Q. B: N//使用,如果他们是可用的每个用户设置。同时,扩展的ASCII码(> 127),从来没有- X! o; |) W8 o8 y$ F
//刀位点的程序,也许选择界面程序。, ~) z/ n% F" }+ O9 e
//注意:如果改变,手动更新report.c帮助信息。
. J3 p1 p* H: s# P+ V1 K8 l* h* ]
#define CMD_STATUS_REPORT '?'! I0 f1 c. C1 X& R! g6 P
#define CMD_FEED_HOLD '!'; J) |5 S C7 n2 S5 e
#define CMD_CYCLE_START '~'
/ y8 G8 k$ z; ~7 U$ H- u# k#define CMD_RESET 0x18 // ctrl-x.
: ~0 M8 n7 {3 f% A/ p#define CMD_SAFETY_DOOR '@'9 U5 T; A2 |: [+ j
$ Q! M6 ]; t9 F0 x9 O5 C
// If homing is enabled, homing init lock sets Grbl into an alarm state upon power up. This forces
9 Z0 N8 o2 R3 g! J- A& {; ~# b n// the user to perform the homing cycle (or override the locks) before doing anything else. This is
* h3 o5 x; p5 y// mainly a safety feature to remind the user to home, since position is unknown to Grbl.
& Q: a) }- y( |$ N
0 ^( ?4 a$ A6 L//如果启用了回原点,导航初始化锁集Grbl进入警报状态启动。这就迫使
8 l8 t; Q* `8 I- `5 h% W4 r//用户执行归航周期(或覆盖锁)在做任何其他事情之前。这是! T& X0 R- g7 u" f' C2 @, S
//主要安全功能,提醒用户家里,因为Grbl位置是未知的。
6 X# N9 i. ^' y D2 E2 Y3 A, Y1 [$ ]" q( L4 n: h
#define HOMING_INIT_LOCK // Comment to disable' W c2 h6 g. d$ @2 m
, Y3 n+ l1 |5 X* e
// Define the homing cycle patterns with bitmasks. The homing cycle first performs a search mode
@4 l7 y0 c7 u B8 T; k// to quickly engage the limit switches, followed by a slower locate mode, and finished by a short
5 U/ R+ L2 k7 P, m6 U! b3 f: [// pull-off motion to disengage the limit switches. The following HOMING_CYCLE_x defines are executed
5 o/ V' ~8 P4 C2 E# M' p// in order starting with suffix 0 and completes the homing routine for the specified-axes only. If8 t7 V i( D4 M' q) N1 i. v) ^
// an axis is omitted from the defines, it will not home, nor will the system update its position.
4 ]. A7 D: H Y! U4 b, M0 j' w4 ]$ n// Meaning that this allows for users with non-standard cartesian machines, such as a lathe (x then z,
. `9 X7 ^4 q4 o5 X4 z4 U// with no y), to configure the homing cycle behavior to their needs.' N' b# K9 `' G. ?
// NOTE: The homing cycle is designed to allow sharing of limit pins, if the axes are not in the same+ Q! U8 T; A1 N- {7 k$ e
// cycle, but this requires some pin settings changes in cpu_map.h file. For example, the default homing3 p/ k) k( Q& i; m$ w# a
// cycle can share the Z limit pin with either X or Y limit pins, since they are on different cycles.+ q2 C) v+ W' w [ c+ K( a6 j' O4 F
// By sharing a pin, this frees up a precious IO pin for other purposes. In theory, all axes limit pins
8 M; y- E# J( m# j4 v/ A5 e( e- U// may be reduced to one pin, if all axes are homed with seperate cycles, or vice versa, all three axes* Q) K& h7 Q6 o
// on separate pin, but homed in one cycle. Also, it should be noted that the function of hard limits% q+ Q, T- E+ b8 A) U, h
// will not be affected by pin sharing./ J5 B: X9 i- n- A1 o
//定义导航循环模式的位掩码。归航周期首先执行一个搜索模式
# y) b3 v; Q4 s3 ?( T//快速进行限位开关,其次是较慢的定位模式,完成了由一个短( F+ F; e" W; I
//拖出运动脱离限位开关。以下HOMING_CYCLE_x定义执行
! p" }! }+ P" G//为了与后缀0开始并完成specified-axes只寻的例程。如果) K& ~) N" Z; g1 f! N
//定义省略一个轴,它会不在家,也不会系统更新它的位置。
d6 K- k/ I* K: }, v" t8 k; @2 r: e//意义,这允许用户与非标准笛卡尔的机器,比如车床(x,z,
8 A M" C0 E% j+ x/ m//没有y),配置导航循环行为对他们的需求。
+ J; j! W& y: t& m//注意:归航周期允许共享限制针,如果轴不相同8 r$ R4 t9 P+ S% W4 J- f- L9 O# }
//循环,但这需要一些销设置cpu_map的变化。h文件。例如,默认的导航
6 r4 f2 F/ H; l, I4 M$ ?% V/ Z: t+ ?//循环可以分享Z限位销X或Y限制针,因为它们是在不同的周期。
4 N5 z: H3 l: i1 A" p//通过共享一个销,这腾出宝贵的IO销用于其他目的。从理论上讲,所有轴限制别针
. V+ @' B7 m1 e8 m//可能会减少到一个销,如果所有轴与分离周期居住的地方,反之亦然,所有三个轴! _5 i! j" H8 {
//在不同销,但这时候一个周期。同时,应该注意的是,硬限制的功能
/ N' ?5 F% J w) q6 @- X//将不会影响销共享。+ h( ~+ H0 ]" J1 q
//注意:默认设置为一个传统的硬件数控机器。z轴首次明确,其次是X和Y。9 ]& n j% G. J( k/ ]" B. e1 O

3 \" p7 x6 Y) e# j( Z8 e" }// NOTE: Defaults are set for a traditional 3-axis CNC machine. Z-axis first to clear, followed by X & Y.' u; U6 j& _. x3 {
#define HOMING_CYCLE_0 (1<: c5 E* p- n6 k: |/ e#define HOMING_CYCLE_1 ((1<) W; T& w. \: i* J3 D: S2 @// #define HOMING_CYCLE_2 // OPTIONAL: Uncomment and add axes mask to enable: b1 m& U9 }2 D# o: A- U }" s% G
5 @; @4 K2 S7 C1 j2 ]+ K, E
// Number of homing cycles performed after when the machine initially jogs to limit switches.
# y2 |( K0 J' \- {& s7 M0 @// This help in preventing overshoot and should improve repeatability. This value should be one or& a) H9 [3 ]. w$ y
// greater.
$ {# X; T. k2 J/ `9 U+ n; [: R5 X' p//执行回原点循环次数后,当机器最初慢跑限位开关。这个帮助防止过度,应该提高重复性。这个值应该是一个或大。
; r) `# d* ~( Q1 m# ~7 C9 }, d( c: Z+ T+ W$ c) c3 B! W
#define N_HOMING_LOCATE_CYCLE 1 // Integer (1-128)
, E5 A6 h# b, ]
9 \+ r, ^% j; F- f& W" V/ f& Z// After homing, Grbl will set by default the entire machine space into negative space, as is typical
( R8 A$ Y" ~$ l5 r# _, x// for professional CNC machines, regardless of where the limit switches are located. Uncomment this
* @2 d' H2 N- R" B# G* g" T// define to force Grbl to always set the machine origin at the homed location despite switch orientation.
) F7 |; u' b c! x' h( b! n+ o+ z4 K7 s' G# c
//导航后,默认Grbl将整个机器空间留白,是典型的专业数控机器,不管限位开关所在的地方。
0 w7 S7 S# B3 K5 h//取消这定义迫使Grbl总是在这时候位置设置机器原点尽管开关方向。
( l1 `: X. L% F% m5 O& |& @- v, T4 z' J4 ]# m
// #define HOMING_FORCE_SET_ORIGIN // Uncomment to enable.) V9 \" X9 o4 q6 ^$ [
# h4 O7 K/ u* v) m* R8 b3 q
* B1 n9 Q8 J4 L z
// Number of blocks Grbl executes upon startup. These blocks are stored in EEPROM, where the size
5 O9 R' F3 b- l6 Y// and addresses are defined in settings.h. With the current settings, up to 2 startup blocks mays7 w9 @# |8 W1 L
// be stored and executed in order. These startup blocks would typically be used to set the g-code' W6 P, {" z. h; e5 S, w2 {9 Q
// parser state depending on user preferences.# x1 R) ~, [5 m( y. d

2 K- M6 A3 E& P* M3 _' ]//块Grbl启动时执行的数量。这些块存储在eepm,大小
+ I7 g: ~# u: D( p1 S' V//和地址在settings.h中定义。与当前设置,可能2启动块' y$ g, q* ~0 F
//存储和执行。这些启动块通常被用来设置刀位点, g8 u, `6 w$ Y, @* |8 A: o
//解析器的状态取决于用户首选项。
" H& u' x4 k+ l/ O' B/ v, J3 n) K P
! X, P8 Y* B& j% W9 _#define N_STARTUP_LINE 2 // Integer (1-2)
& Y7 h, \( d% A
- y; @& U3 a2 x" v( H+ `3 m// Number of floating decimal points printed by Grbl for certain value types. These settings are7 W$ v. N( M8 Y
// determined by realistic and commonly observed values in CNC machines. For example, position8 }: A A! U. C4 @! M
// values cannot be less than 0.001mm or 0.0001in, because machines can not be physically more
- O5 G3 [* y$ o, z! {- ?- f2 ]; V/ z// precise this. So, there is likely no need to change these, but you can if you need to here.
! _! S- x, u1 Q// NOTE: Must be an integer value from 0 to ~4. More than 4 may exhibit round-off errors.
5 y' U% j; t( ^8 a( r; N/ \" ~
2 K) z3 B5 `2 N5 [// Grbl浮动小数点的数字印刷的特定的值类型。这些设置是
! S1 T' b( w1 E/ o//一般由现实和观测值在数控机器。例如,位置
; w( X1 e$ _2 v1 G% X% K! ~6 G2 B: G//值不能小于0.001毫米或0.0001,因为机器不能身体更多
7 Y# P% ~+ B3 O( {//精确。因此,有可能不需要改变这些,但你可以在这里如果你需要。3 K c8 T: n6 k" h
//注意:必须是一个整数值从0 ~ 4。超过4可能出现舍入错误。: ^( H6 l5 u$ e8 L6 Q
* i& m6 a+ h% @, ^3 D
#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 协调或位置价值英寸! a& |2 d" x) b+ ?# C. X
#define N_DECIMAL_COORDVALUE_MM 3 // Coordinate or position value in mm 协调在毫米或位置价值
8 i. e7 [! L1 `* A6 X#define N_DECIMAL_RATEVALUE_INCH 1 // Rate or velocity value in in/min 率或/分钟的速度值
: r; B2 i& Y0 T+ g, `6 ~/ S#define N_DECIMAL_RATEVALUE_MM 0 // Rate or velocity value in mm/min 速率或速度值在毫米/分钟
v8 J A; G9 r( V$ j#define N_DECIMAL_SETTINGVALUE 3 // Decimals for floating point setting values 对浮点小数设置值
" H% D. Q8 o+ z9 k* A, J2 X- m6 Q/ M' R, r; ~, f0 j( A# V, U
// If your machine has two limits switches wired in parallel to one axis, you will need to enable) k5 I, n/ T, M! T5 L! {
// this feature. Since the two switches are sharing a single pin, there is no way for Grbl to tell7 z' m, \3 \% R% x. Q9 Y
// which one is enabled. This option only effects homing, where if a limit is engaged, Grbl will
8 E4 c, t! ^4 q8 G; R// alarm out and force the user to manually disengage the limit switch. Otherwise, if you have one( ?3 J( o% Y7 [+ m* V" ^$ O5 x: J
// limit switch for each axis, don't enable this option. By keeping it disabled, you can perform a7 ?6 B$ e; W* E7 Z+ z4 {
// homing cycle while on the limit switch and not have to move the machine off of it.7 N% G3 c$ D; T9 Q
4 E4 e: b/ ]# i' h1 k' G- p- p
//如果你的机器有两个极限开关连接在平行于一个轴,您需要启用$ j' J2 q) I+ L" e& N
//这个特性。自从两个交换机共享一个销,没有办法Grbl告诉
# o5 ?; `: O! W//启用哪一个。此选项仅影响归航,如果限制,Grbl意志
+ t% G! v$ _" t& ^3 l" p//报警,迫使用户手动松开限位开关。否则,如果你有一个& ^& O( x2 X4 F- n3 m
//为每个轴限位开关,不启用该选项。通过保持禁用,您可以执行
1 I/ d2 O6 t/ k% y2 |: d. Z D//导航循环在限位开关并没有将这台机器。
6 e C8 @9 ^& ^5 R. }: C" k! [7 `7 O. Z- Q7 e6 y' `4 k: Q% j# I
// #define LIMITS_TWO_SWITCHES_ON_AXES3 }2 w: @+ V& n: @- u1 v

/ i/ r8 [0 M- {( T4 o! V// Allows GRBL to track and report gcode line numbers. Enabling this means that the planning buffer
+ ^4 C* c/ b! f: ~// goes from 18 or 16 to make room for the additional line number data in the plan_block_t struct
" B7 N' E) |1 m1 o
3 G0 H9 {# S8 e//允许GRBL跟踪和报告gcode行号。使这意味着计划缓冲从18岁或16岁,为额外的行号plan_block_t结构中的数据- T' B$ P/ H) _- {

6 ~4 ]$ K4 i7 n! A, c// #define USE_LINE_NUMBERS // Disabled by default. Uncomment to enable." n4 e% C8 S. @# b f6 ?" T

/ ~9 p0 }2 O+ Z3 O: i7 g. K// Allows GRBL to report the real-time feed rate. Enabling this means that GRBL will be reporting more) `( Z8 O9 [3 v0 `
// data with each status update.
$ @9 @. D* d4 C3 _7 A( f// NOTE: This is experimental and doesn't quite work 100%. Maybe fixed or refactored later.0 r3 q/ |$ R# ?9 b6 [ r! k
//允许GRBL报告实时进给速率。使这意味着GRBL将报告数据和状态更新。
2 W9 G# d9 [8 _//注意:这是实验和100%没有工作。也许以后固定或重构。
% ]- g( d% E" m1 j9 v6 d2 q5 L
. [9 r: b ^9 J9 _' I// #define REPORT_REALTIME_RATE // Disabled by default. Uncomment to enable.& o ^0 N+ g& o- A

D: j9 _% V; A// Upon a successful probe cycle, this option provides immediately feedback of the probe coordinates: `$ Z5 d8 O* J$ P" t9 D
// through an automatically generated message. If disabled, users can still access the last probe
. E* U \' I- v4 U// coordinates through Grbl '$#' print parameters.
1 B9 G: I: m" t* M7 x9 P1 `//在一个成功的调查周期,这个选项提供立即反馈的探测器坐标
6 ^! A6 Y! U: r$ w//通过一个自动生成的消息。如果禁用,用户仍然能够访问调查
( O- d) {$ E# Q//坐标通过Grbl $ #的打印参数。
9 s3 X# [) b& S; P
" D8 N, m; ^, `( C0 m9 l" @/ w. O; o* l#define MESSAGE_PROBE_COORDINATES // Enabled by default. Comment to disable.
* _2 F8 f7 {/ e+ e7 p: [8 n% O" x) `; a+ ~ \1 J
// Enables a second coolant control pin via the mist coolant g-code command M7 on the Arduino Uno. P% R; Y+ T7 F8 U" H
// analog pin 5. Only use this option if you require a second coolant control pin.
! u" o6 q: Q. b" d// NOTE: The M8 flood coolant control pin on analog pin 4 will still be functional regardless.2 X% d# G% P& G) q S
// #define ENABLE_M7 // Disabled by default. Uncomment to enable.% J6 F( ~* C/ W+ L
4 }: O% y: D8 j" |: Y# W
// This option causes the feed hold input to act as a safety door switch. A safety door, when triggered,
/ T- [6 `, S9 `. S- R) i// immediately forces a feed hold and then safely de-energizes the machine. Resuming is blocked until: L1 @8 P$ C5 W
// the safety door is re-engaged. When it is, Grbl will re-energize the machine and then resume on the
0 m" s q' h% R2 }% S7 d// previous tool path, as if nothing happened.% O* [ p- F7 @. [& k, q9 c
// #define ENABLE_SAFETY_DOOR_INPUT_PIN // Default disabled. Uncomment to enable.$ o: D1 }* c9 y3 o s/ |' i, x) S: n
4 g% j d9 ]) L6 I1 }8 Z
// After the safety door switch has been toggled and restored, this setting sets the power-up delay
1 w& h2 C( e7 g! W+ _// between restoring the spindle and coolant and resuming the cycle.
% @3 B6 r# @9 H/ q// NOTE: Delay value is defined in milliseconds from zero to 65,535.
& ~- C# u, C3 j0 W2 Q9 f. N: x* z0 L& R, R' z; g3 H! I
//定义导航循环模式的位掩码。归航周期首先执行一个搜索模式
- }0 C" j9 P/ T) n: N//快速进行限位开关,其次是较慢的定位模式,完成了由一个短
: u6 g! k3 x( ^$ `, \//拖出运动脱离限位开关。以下HOMING_CYCLE_x定义执行" C9 x- ?! @3 G; j9 R
//为了与后缀0开始并完成specified-axes只寻的例程。如果
6 O, M# h; V: g//定义省略一个轴,它会不在家,也不会系统更新它的位置。
3 t& c/ q+ ~3 S5 ?8 c4 z3 k//意义,这允许用户与非标准笛卡尔的机器,比如车床(x,z,
# n0 \8 A: t7 w4 T//没有y),配置导航循环行为对他们的需求。
- F7 E0 T$ ^; P0 O; o//注意:归航周期允许共享限制针,如果轴不相同3 o. B- t7 R- W$ l) ?# |7 y
//循环,但这需要一些销设置cpu_map的变化。h文件。例如,默认的导航
/ J$ I4 I' {* u: p1 r: U" \; n! z//循环可以分享Z限位销X或Y限制针,因为它们是在不同的周期。
% U5 M) D% E7 d1 B//通过共享一个销,这腾出宝贵的IO销用于其他目的。从理论上讲,所有轴限制别针! r8 Q, V( P4 O% L1 a, E! ^
//可能会减少到一个销,如果所有轴与分离周期居住的地方,反之亦然,所有三个轴6 G5 p9 p# y! @% ~) |
//在不同销,但这时候一个周期。同时,应该注意的是,硬限制的功能9 f. ^4 x3 r0 H
//将不会影响销共享。
4 g2 w* U: L% h4 c/ ^//注意:默认设置为一个传统的硬件数控机器。z轴首次明确,其次是X和Y。
; D/ i {7 J. q4 [% b8 A; ~$ C- N! A; @% Z+ @7 S" V
! _) U$ b& L8 T8 X4 u* Q
#define SAFETY_DOOR_SPINDLE_DELAY 4000
4 a) w& _, c/ J1 s' B8 K" y z8 A7 t6 O#define SAFETY_DOOR_COOLANT_DELAY 10002 u0 e/ L$ d- H0 f! e4 U
3 o0 Z1 T" y; \. i
// Enable CoreXY kinematics. Use ONLY with CoreXY machines.8 y3 R+ S5 D. c1 [
// IMPORTANT: If homing is enabled, you must reconfigure the homing cycle #defines above to
s# N/ H0 R3 d//启用CoreXY运动学。只使用与CoreXY机器。$ o6 B# `5 E9 ^, M% N
//重要:如果启用了自动寻的,你必须重新配置导航循环#定义上面3 H* u% e' P4 h/ ?2 P& o
; ?0 z% [ }* ~7 b/ U `& c, p; n0 r
// #define HOMING_CYCLE_0 (1<$ z) {# b7 h9 N

4 z' K i: k1 C. Z6 y// NOTE: This configuration option alters the motion of the X and Y axes to principle of operation6 R2 C/ S8 k( D' ?$ N: `/ [
// defined at (http://corexy.com/theory.html). Motors are assumed to positioned and wired exactly as$ K7 R" L ]( q a5 q7 M
// described, if not, motions may move in strange directions. Grbl assumes the CoreXY A and B motors
% y- T7 L; G, W' d% v8 A$ p' L$ T// have the same steps per mm internally.A7 Y% O0 u& ?& P, v( ?
//注意:这种配置选项改变X和Y轴的运动原理,操作! f5 q: x& n3 k, g/ f. T9 l
//定义(http://corexy.com/theory.html)。汽车被认为定位和连接一样% z* m0 c( T# i" V6 E0 M
//描述,如果没有,运动可能会奇怪的方向移动。A和B Grbl假设CoreXY马达9 p! h( m! q% U" n, K- Y5 g' p! k
//每毫米内部有相同的步骤。
# k% m5 l% ^0 N) r& a* d
3 V" |& @3 x5 m9 n9 B// #define COREXY // Default disabled. Uncomment to enable.
4 ]6 ?% x5 v- h% M/ g( T; n! j% f8 G) O. i1 H: p
// Inverts pin logic of the control command pins. This essentially means when this option is enabled
% h6 s5 d# x. `+ A. E/ X' N% L// you can use normally-closed switches, rather than the default normally-open switches.
9 f# A5 K3 ] ^: \7 A0 W1 p// NOTE: Will eventually be added to Grbl settings in v1.0.* M2 Y2 K5 i2 M$ r f$ e3 I7 k
//反转针销逻辑的控制命令。这实质上意味着当启用这个选项
) i$ W+ J' D" G- [//可以使用闭合开关,而不是默认的常开开关。3 f, V- \; x4 @
//注意:最终将被添加到在v1.0 Grbl设置。i- I5 x0 }$ t7 ]1 n3 W

+ ~$ p4 P7 j3 K// #define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.
+ ]+ B5 n c1 n9 |9 H& K; A$ H) C% `/ U
// Inverts the spindle enable pin from low-disabled/high-enabled to low-enabled/high-disabled. Useful
& G B ]- R2 w3 x$ p. j// for some pre-built electronic boards.
4 |* F3 j3 |4 J4 T" K, ^; a8 N// NOTE: If VARIABLE_SPINDLE is enabled(default), this option has no effect as the PWM output and# @, l2 O* a& [3 d
// spindle enable are combined to one pin. If you need both this option and spindle speed PWM,* x0 Y. Q% D" p5 Z3 c
// uncomment the config option USE_SPINDLE_DIR_AS_ENABLE_PIN below.
1 `7 ?7 E' g) [//反转主轴使销从low-disabled / high-enabled low-enabled / high-disabled。有用的
5 A X4 x1 q2 U9 q( k//预构建的电子板。
5 R/ h0 E, b+ }//注意:如果启用了VARIABLE_SPINDLE(默认),这个选项作为PWM输出并没有影响- ~ C+ L [5 I8 u( O( X
//销轴使结合。如果你需要这个选项和主轴转速PWM,
. i9 l- V5 m+ _7 E# r//取消注释以下配置选项USE_SPINDLE_DIR_AS_ENABLE_PIN+ j# P9 d& q Z4 F4 z. F3 e
' z& ?. i8 q, m+ s
// #define INVERT_SPINDLE_ENABLE_PIN // Default disabled. Uncomment to enable.
; N3 H1 Y! `+ ?0 C- i1 t) e) g' A3 c9 R3 \6 ~ F. M. ], [
// Enable control pin states feedback in status reports. The data is presented as simple binary of
9 u4 g4 e, @+ y8 m// the control pin port (0 (low) or 1(high)), masked to show only the input pins. Non-control pins on the, x4 b6 \0 J8 x) C9 I0 }4 v6 ^
// port will always show a 0 value. See cpu_map.h for the pin bitmap. As with the limit pin reporting,7 i) D# s) y, @ h- T& V! O1 z
// we do not recommend keeping this option enabled. Try to only use this for setting up a new CNC.9 s5 I4 z3 i: R8 e8 I9 k6 j
//启用控制销状态反馈状态报告。作为简单的二进制数据: }9 L! }' E1 w9 O q4 c
//控制针端口(0(低)或1(高)),蒙面,只显示输入插脚。非控制性针上
4 q: J# L$ l1 X8 |5 u; w9 C) p& Y& X3 g//端口总是显示0值。看到cpu_map。针位图h。与限制销报告,
1 {. D, c; ?! G( P( Q9 }( u//我们不推荐保持启用这个选项。尽量只使用这个设置一个新的数控。
* m4 E0 [* @8 ~. Q! W) B4 z, |0 g* b! z
// #define REPORT_CONTROL_PIN_STATE // Default disabled. Uncomment to enable.
% N6 [/ L2 n8 {5 F' ?6 t7 }, D+ a8 R5 S9 D+ _8 R3 d
// When Grbl powers-cycles or is hard reset with the Arduino reset button, Grbl boots up with no ALARM& |/ ]2 [# v- \' W5 I6 Y+ R; V
// by default. This is to make it as simple as possible for new users to start using Grbl. When homing
" m# y+ R, F+ C3 F// is enabled and a user has installed limit switches, Grbl will boot up in an ALARM state to indicate
1 N7 _9 H$ A9 W7 o; C4 m% [// Grbl doesn't know its position and to force the user to home before proceeding. This option forces
4 [! }& x6 x9 n. C3 J1 B/ }// Grbl to always initialize into an ALARM state regardless of homing or not. This option is more for, [8 B6 i! z# V( n/ `6 w
// OEMs and LinuxCNC users that would like this power-cycle behavior.
' Z, Y- ~8 X8 ]& v2 r4 F//当Grbl powers-cycles还是硬重置Arduino复位按钮,Grbl启动没有报警1 v2 H0 q+ U F" U5 S) w
//默认情况下。这是为了让新用户尽可能简单使用Grbl开始。当归航# q" J: | V* r6 P( i
//启用和用户安装限位开关,Grbl将启动报警状态指示
3 N3 |3 ?5 ~# G- S: e$ x+ y// Grbl不知道它的位置,迫使用户在继续之前回家。这个选项部队
% R; X9 Y0 G& a: ~4 [& y# d0 q// Grbl总是初始化进入警报状态不管归航。这个选项是更多
3 w$ }) e- p8 Z5 L' }# V! F9 o//原始设备制造商和LinuxCNC用户这样的控制行为。8 V; v) A) v9 X% S0 s5 v7 B9 a

. H* K! F5 F2 S, Z// #define FORCE_INITIALIZATION_ALARM // Default disabled. Uncomment to enable./ _$ H5 b# t+ h9 u$ h' _; z- t

O: K1 \9 N3 @( `0 o) p, a* H* q! ]1 |# }// ---------------------------------------------------------------------------------------
, H' Q- c" S; Y// ADVANCED CONFIGURATION OPTIONS://高级配置选项:+ _) i# z" T" x3 G' Y
* O0 u1 M, Q* G7 e1 M
// Enables minimal reporting feedback mode for GUIs, where human-readable strings are not as important.* E. B, r; T. X) u' l M/ Y
// This saves nearly 2KB of flash space and may allow enough space to install other/future features.7 p/ M Q& S" G6 y, s# r
// GUIs will need to install a look-up table for the error-codes that Grbl sends back in their place.' [ A- O# ?0 s& m1 g k" T
// NOTE: This feature is new and experimental. Make sure the GUI you are using supports this mode.
% h8 K9 N7 S+ G3 V: F9 N, n, h
$ R4 v: Y5 q$ z4 L$ g// gui允许最小的报告反馈模式,人类可读的字符串在哪里不重要。
8 |% r. r( c% d5 U8 _6 G/ v7 o& V//这个节省近2 kb的闪存空间,允许足够的空间来安装其他/未来的功能。+ O, H& E4 p J
// gui需要安装一个查找表的错误代码Grbl发回。4 v# D, d5 a# v, h
//注意:此功能是新的和实验。确保您使用的GUI支持这种模式。
/ u) \/ h9 T1 @1 Y/ h; e8 ?; a
: Y; D e% W+ K// #define REPORT_GUI_MODE // Default disabled. Uncomment to enable." N) e, @4 w9 v" Y
0 y) G( a: M! y) j# P6 M* P8 [# ]$ B
// The temporal resolution of the acceleration management subsystem. A higher number gives smoother- }5 X! Z- @9 G
// acceleration, particularly noticeable on machines that run at very high feedrates, but may negatively
6 m5 Q. V; o5 `& Y; k// impact performance. The correct value for this parameter is machine dependent, so it's advised to
' ]) q% f% a, V8 H1 G) Y! [// set this only as high as needed. Approximate successful values can widely range from 50 to 200 or more.
) l2 f" p1 s- a0 h// NOTE: Changing this value also changes the execution time of a segment in the step segment buffer.
# e% [8 l& d' C x6 G// When increasing this value, this stores less overall time in the segment buffer and vice versa. Make
. n6 i! R& B5 `// certain the step segment buffer is increased/decreased to account for these changes.4 Y9 E/ {8 @1 N9 }6 v
//加速度的时间分辨率管理子系统。更多更平稳
1 x+ V6 F& y% B2 H//加速度,特别明显的机器上,运行在非常高的进料速度,但可能负面O7 H( {$ E: {3 O; E) n2 [7 a
//影响性能。正确的值为这个参数是依赖于机器的,所以建议3 d# e' M4 ^* P8 B% g2 d. O% `
//这只设置为高。近似成功的价值观可以广泛的范围从50到200或者更多。
" d0 M; p, `! L; g ]# ^/ k7 l1 O//注意:改变这个值也变化的部分步骤的执行时间缓冲。
; ~4 Y- c7 [. R3 Y% y, {: a//增加这个值时,这个商店部分缓冲区的总时间减少,反之亦然。使4 F Y4 F0 T" S+ X- s3 {
//特定步骤段缓冲是考虑这些变化增加/减少。; ^# `) U, ~9 Q5 r1 v

3 O) Z- R s# Z$ ~% b#define ACCELERATION_TICKS_PER_SECOND 100 //加速度的时间分辨率管理子系统。更多更平稳9 @9 x/ b0 Q6 h" M5 K" k
5 m' U) Q( q2 t$ ~
// Adaptive Multi-Axis Step Smoothing (AMASS) is an advanced feature that does what its name implies,
( p( J( b1 M9 e/ A F// smoothing the stepping of multi-axis motions. This feature smooths motion particularly at low step* w2 b) w6 Q/ u! z1 z- T
// frequencies below 10kHz, where the aliasing between axes of multi-axis motions can cause audible
d/ O Q% T# j- x" S$ `// noise and shake your machine. At even lower step frequencies, AMASS adapts and provides even better
, y' u! n$ }3 g% m! k' ~// step smoothing. See stepper.c for more details on the AMASS system works.$ }6 ~9 @7 S2 D# C; D! \* Y
//自适应多轴步平滑(积累)是一种先进的功能,它的名字所暗示的那样,7 i) T& k( }! z9 b+ U0 j1 Z
//平滑的多轴步进运动。这个特性平滑运动尤其是在低一步
9 k& {. X6 X* J* n//频率低于10 khz,轴之间的混叠的多轴运动可能导致音响- I( \' b( A9 P% a% c( @7 }
//噪音和震动你的机器。在更低的频率步,积累适应并提供更好
# R9 H% H9 [+ g9 q4 _) X8 z//步骤平滑。看到步进。c更多细节的积累系统的工作原理。% V3 ?; o; d d& w$ U5 S* ]
# U$ p) g+ [1 O: p, B* `
#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING // Default enabled. Comment to disable.//自适应多轴步平滑
D: [7 H" Y. w& o" @2 w
& ]5 F# K! | Z, y// Sets the maximum step rate allowed to be written as a Grbl setting. This option enables an error
3 p8 q5 y* _0 B# `// check in the settings module to prevent settings values that will exceed this limitation. The maximum
' r* a: m0 V9 D$ _4 k// step rate is strictly limited by the CPU speed and will change if something other than an AVR running! c- ~8 m4 {0 H& Y
// at 16MHz is used.) P c. F+ r6 C$ y
// NOTE: For now disabled, will enable if flash space permits.
4 g) a$ S7 c( [; D% j M6 K4 f- e5 O6 |//设置最大一步速率可以写成Grbl设置。这个选项可以使一个错误; w) U7 }0 G7 j$ ?6 f! E9 R1 n
//设置模块中检查,防止设置值将超过这个限制。的最大2 H1 ~& ?9 z a
//步骤严格限制的CPU速度也会改变如果是其他AVR运行, s1 k3 m1 I: o5 K
//使用16兆赫。. u% n0 P$ n, C
//注意:现在残疾,将使如果flash空间许可。
3 d0 G: R/ t1 Q# j
# \/ p) \( L3 G0 [* s// #define MAX_STEP_RATE_HZ 30000 // Hz 设置最大一步速率
" h$ ^& |" [$ G4 [
$ y* b' H6 A) b; S- H, y( B W// By default, Grbl sets all input pins to normal-high operation with their internal pull-up resistors9 n# |1 u( \ {5 e9 O
// enabled. This simplifies the wiring for users by requiring only a switch connected to ground,
- Q* a( G n0 d8 M// although its recommended that users take the extra step of wiring in low-pass filter to reduce1 T5 ]& L9 ^# M8 P$ ], ]' I
// electrical noise detected by the pin. If the user inverts the pin in Grbl settings, this just flips
; m; H* _# D2 [7 U7 ]) I6 |// which high or low reading indicates an active signal. In normal operation, this means the user
: {0 r3 c/ F: J N& H6 M// needs to connect a normal-open switch, but if inverted, this means the user should connect a1 p8 K. x) x! c. K
// normal-closed switch.
% P& c4 l- Y Z6 Z8 [// The following options disable the internal pull-up resistors, sets the pins to a normal-low
. h+ [% ~5 x( h// operation, and switches must be now connect to Vcc instead of ground. This also flips the meaning
. k8 o) N( S7 |2 a// of the invert pin Grbl setting, where an inverted setting now means the user should connect a
- T4 @9 C$ S3 Q1 K7 [// normal-open switch and vice versa.
" Q) [2 W. X, q: o4 h// NOTE: All pins associated with the feature are disabled, i.e. XYZ limit pins, not individual axes.3 f! q5 i2 C6 _% A
// WARNING: When the pull-ups are disabled, this requires additional wiring with pull-down resistors!
# A1 {2 E$ o6 K6 M" P- B% B5 r3 n//默认情况下,Grbl所有输入引脚设置为正常高操作的内部上拉电阻
; y3 P8 a3 v$ V/ O//启用。这简化了布线为用户只需要一个开关连接到地面,
( y, H8 w# _4 H' r//虽然其建议用户采取额外的步骤,在低通滤波器来减少布线
\9 B$ ~' {! q5 H//电噪音检测销。如果用户反转的销Grbl设置,这只是翻转$ u3 ^) [# K+ e6 d: J6 B# _" K
//读高或低表明一个积极的信号。在正常操作中,这意味着用户# o$ C/ `. ]8 p* Q, @4 {& d9 U
//需要连接一个常开开关,但如果倒,这意味着用户应该连接
5 W& Q( h) ~- J5 J) Y, c& m- M6 e// normal-closed开关。
, N* ^2 O! A8 c//以下选项禁用内部上拉电阻,一般低设置别针7 E2 K' w( T" ?1 o. f
//操作,现在开关必须连接到Vcc代替地面。这也掀的意思
* x/ T$ Z/ f/ |0 Q' E& e( a//反销Grbl设置,一个倒置的设置现在意味着用户应该连接
- j2 c7 D" t# V: g; s" ]( g//常开开关,反之亦然。
5 [9 i1 `& O0 s//注意:所有针与功能被禁用,例如XYZ限制针,而不是单独的轴。& b l7 L M2 M2 |
//警告:引体向上被禁用时,这需要额外的布线与下拉电阻!; S, d% Z8 M( H
4 I! k% z; r$ J' |
//#define DISABLE_LIMIT_PIN_PULL_UP //以下选项禁用内部上拉电阻& N2 B; S: }0 X: v
//#define DISABLE_PROBE_PIN_PULL_UP/ Q" c1 f, E# |) F* d+ f( Q) ?$ ^
//#define DISABLE_CONTROL_PIN_PULL_UP
. W) d' R( M8 l2 J- Z2 p1 U4 c [- K- V9 Y4 W' x. h# y
// Sets which axis the tool length offset is applied. Assumes the spindle is always parallel with
3 ~9 p- c1 Z1 ^* o5 u1 k, J B, X# g// the selected axis with the tool oriented toward the negative direction. In other words, a positive. P, s$ h% B6 a' s
// tool length offset value is subtracted from the current location.% k9 r0 N4 x8 u5 \
//设置哪个轴长度补偿应用的工具。假设轴总是与% |) I @, ^" d, P# l
//选择轴工具面向负方向。换句话说,一个积极的
$ u( Q- E$ r* b3 h8 }//工具长度偏移值减去从当前位置。% g+ ~: d0 F! Z. a
; r4 p( d. p& ^4 b8 ^5 h
#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS // Default z-axis. Valid values are X_AXIS, Y_AXIS, or Z_AXIS.设置哪个轴长度补偿应用的工具
6 n6 c1 }5 O* A# ]6 b1 V
" L8 K1 ^% e" f4 ~) B' j( A// Enables variable spindle output voltage for different RPM values. On the Arduino Uno, the spindle
3 f! w: ^6 q# c' U// enable pin will output 5V for maximum RPM with 256 intermediate levels and 0V when disabled.3 W0 B; b( O9 k" p5 X; e3 @+ b
// NOTE: IMPORTANT for Arduino Unos! When enabled, the Z-limit pin D11 and spindle enable pin D12 switch!
6 ~+ _0 c+ i2 V+ F% f. }// The hardware PWM output on pin D11 is required for variable spindle output voltages." Z2 l/ o2 I5 p R8 F, Z
//允许变量轴输出电压不同的转速值。Arduino Uno,主轴K" j. p8 z( W* _, x
//启用销将输出5 v的最高转速256中级水平和0 v时禁用。
/ | A$ r, v4 s0 z; d//注意:重要Arduino凯泽本人!当启用时,Z-limit销这里和轴销D12开关!$ F2 ?9 B/ V8 \8 T& D
//硬件PWM输出销这里需要变量轴输出电压。
8 V' l9 J( y- q& B- h, k; A4 W: H3 g8 w( _" r
#define VARIABLE_SPINDLE // Default enabled. Comment to disable.//允许主轴输出电压不同的转速值/ p7 b) u( V7 J+ I; p9 K" i
6 H+ B* [# R. L' A+ [
// Used by the variable spindle output only. These parameters set the maximum and minimum spindle speed8 f; Z+ I2 }0 J
// "S" g-code values to correspond to the maximum and minimum pin voltages. There are 256 discrete and
, D, Y9 _* _& I2 \// equally divided voltage bins between the maximum and minimum spindle speeds. So for a 5V pin, 1000
% |/ {' }% l* {4 L" `2 x// max rpm, and 250 min rpm, the spindle output voltage would be set for the following "S" commands:[! T: V* G) b
// "S1000" @ 5V, "S250" @ 0.02V, and "S625" @ 2.5V (mid-range). The pin outputs 0V when disabled.
+ i- r) D4 z H$ _* ], y+ ~+ }//使用的变量轴输出。这些参数设置最大和最小轴转速% N5 j3 G0 r( b& T) q9 S O& j
//“S”刀位点值对应于销电压的最大值和最小值。有256个离散和$ `# W1 g. W3 c$ }; I
//电压平均分配箱主轴速度的最大值和最小值之间。所以对于一个5 v销,1000
- q. Z! U" d$ M7 ?1 ]" ?// max rpm,250分钟rpm,主轴输出电压将为以下“S”命令:/ p* D9 s6 c0 Y; X+ L& G" Q
// @“S1000 5 v,“S250”@ 0.02 v,“S625”@ 2.5 v(中档)。销输出0 v时禁用。
7 d' G Q( ~. F! x# i8 q, X# T- \' ?! O) G7 p" P' v- J1 D
#define SPINDLE_MAX_RPM 1000.0 // Max spindle RPM. This value is equal to 100% duty cycle on the PWM., b6 L' E' u4 }6 q2 c
#define SPINDLE_MIN_RPM 0.0 // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.9 k( S9 I; ~! [' G, v7 \

9 \; ?3 D( F" u! q, p! m/ o9 I// Used by variable spindle output only. This forces the PWM output to a minimum duty cycle when enabled.?+ I( y3 @& j9 N" y* G" A
// When disabled, the PWM pin will still read 0V. Most users will not need this option, but it may be8 K* j" c4 t B8 p3 O3 M! c* Y
// useful in certain scenarios. This setting does not update the minimum spindle RPM calculations. Any
. R X9 \- k9 C1 D. G0 X: P// spindle RPM output lower than this value will be set to this value.+ s, c# e0 @0 g* {4 J
//使用的变量轴输出。这迫使PWM输出最小占空比时启用。$ T* R o8 y- C& v7 R! N- y
//当禁用,PWM销仍读0 v。大多数用户不需要这个选项,但是它可能是
7 `, k' E: Z- c0 L$ C//在某些情况下很有用。这个设置不会更新最小主轴转速计算。任何6 p7 t) L3 k' l3 _0 R( |
//输出轴转速低于这个值将被设置为这个值。2 ], F3 I. z6 L

: Q/ r' _( L8 q/ `# V// #define MINIMUM_SPINDLE_PWM 5 // Default disabled. Uncomment to enable. Integer (0-255)# r: U" `: r/ D- v& A

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

2 @1 x5 I4 q# m//启用,Grbl发回的回声线已收到,已预编译(空间
3 ^, \( |. C: r E! }' p: t5 g//移除,大写字母,没有评论),由Grbl立即执行。回声将不会) ?5 {# X$ `; M! J
//发送一个线缓冲区溢位,但应该对所有正常线路送到Grbl。例如,如果一个用户
- G4 X( ^! u' [3 c0 s//发送线的g1 x1.032 y2.45(测试评论)形式”,Grbl将回声”(回声:G1X1.032Y2.45]”。0 s7 _* Y% q6 A! s" N& P' u O% d- {
//注意:只使用这个调试! !当呼应,这占用了宝贵的资源,可以影响
: [# K* T' r$ ?4 N# o2 x//性能。如果正常运行所需的绝对,串行写入缓冲器应该大大增加5 o; _, F4 @, V+ u1 }9 b
//帮助最小化传输等系列内写协议。
0 q9 P& v0 Q7 I9 {
3 g; H" u1 @: B, |6 D" i+ E8 x// #define REPORT_ECHO_LINE_RECEIVED // Default disabled. Uncomment to enable.
7 {4 B% v" l# U|, `1 c! W1 I3 ^0 d$ b
// Minimum planner junction speed. Sets the default minimum junction speed the planner plans to at
# w0 g, [0 q/ x6 }8 J1 E// every buffer block junction, except for starting from rest and end of the buffer, which are always9 L8 V$ _7 e/ F6 j2 H& O/ f" v
// zero. This value controls how fast the machine moves through junctions with no regard for acceleration
" `3 K( ^, S) Q// limits or angle between neighboring block line move directions. This is useful for machines that can't6 [% W# G$ z @) W3 `. @$ ?
// tolerate the tool dwelling for a split second, i.e. 3d printers or laser cutters. If used, this value0 o; I+ q; P! t: |. n
// should not be much greater than zero or to the minimum value necessary for the machine to work.9 b+ w$ K2 I; _
# i. f2 p/ d) E: K! Y: w0 f
//最小规划师结速度。设置默认最小连接速度规划计划
0 H- ~* H1 v6 o* \- I }- v3 [5 ~//每一个缓冲块接头,除了从结束休息和缓冲区,它总是
( V& v0 N+ j: R, W// 0。这个值控制机器的速度穿过路口,没有考虑加速度
$ h0 {! ^5 `# K; g/ M8 N" g6 O//限制或相邻块之间的角线方向移动。这是有用的机器,不能
, }1 k* P O; y//容忍工具居住某一刹那,即3 d打印机或激光切割机。如果使用这个值
: R( y/ C& ?5 ^# S" M5 K4 ^//不应大于零或机器工作所需的最小值。
% \0 P& U9 v/ L6 g* V% N
8 J( G3 O! U& V#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min)
7 T. |; T+ l1 m1 D7 \" M. L- N. e6 h
: z) M U" A5 x8 P// Sets the minimum feed rate the planner will allow. Any value below it will be set to this minimum2 G. {2 c; @1 E) n8 ]
// value. This also ensures that a planned motion always completes and accounts for any floating-point, h1 H# P# t6 ]7 |
// round-off errors. Although not recommended, a lower value than 1.0 mm/min will likely work in smaller( {4 f4 Z# n. {; e% Y/ m5 K. t
// machines, perhaps to 0.1mm/min, but your success may vary based on multiple factors.
o. J' _9 [: W/ G- p: `0 K//设置计划将允许的最小进给速率。任何价值低于它将被设置为最低值。这也保证了运动计划总是完成,占任何浮点
5 t: c& z2 j6 h% P- R5 y//舍入错误。虽然不推荐,价值低于1.0毫米/分钟可能会在较小的工作+ h6 Z% [% ]2 Q1 h
//机器,也许到0.1毫米/分钟,但你的成功基于多种因素可能会有所不同。
6 S4 P9 }6 T4 C9 G' I0 _
" G% Y" V4 w7 {/ J9 s#define MINIMUM_FEED_RATE 1.0 // (mm/min)//设置计划将允许的最小进给速率
0 L# i6 U/ o. p' _
0 C2 K$ c6 U, z8 I7 n: G* ]// Number of arc generation iterations by small angle approximation before exact arc trajectory
4 }3 K& E7 }! C% w' e+ H// correction with expensive sin() and cos() calcualtions. This parameter maybe decreased if there
* M$ ^! J# q: M, J) R// are issues with the accuracy of the arc generations, or increased if arc execution is getting
% Q' ]* F/ c' ~; L9 u// bogged down by too many trig calculations.( X* X' @* a' s$ ]3 I; b! {2 B# _: }
//弧生成迭代次数之前小角度近似精确的弧线轨迹L% @) K+ A' x b+ t
//修正与昂贵的sin()和cos()calcualtions。如果有这个参数可能减少
0 p. \& z) F) i: T7 J7 `//与弧一代又一代的准确性问题,或如果电弧执行得到增加1 I1 M! j! l- `$ R, d% S; ]8 i
//太多的三角计算的泥潭。
' g; a/ M! ~) _6 \
" ?* h' B c5 C9 ?0 ?, v#define N_ARC_CORRECTION 12 // Integer (1-255)5 h: t' S6 L9 `9 E9 t9 k' Q1 d
" }2 d+ A; R& u
// The arc G2/3 g-code standard is problematic by definition. Radius-based arcs have horrible numerical3 C R! v3 a5 E! l- S: S
// errors when arc at semi-circles(pi) or full-circles(2*pi). Offset-based arcs are much more accurate
! W8 q! X6 V# F! m% `/ ]// but still have a problem when arcs are full-circles (2*pi). This define accounts for the floating$ ~1 w# O. d! J9 R
// point issues when offset-based arcs are commanded as full circles, but get interpreted as extremely
. W$ r: x u+ n1 B6 Z5 R$ l: s4 S" T// small arcs with around machine epsilon (1.2e-7rad) due to numerical round-off and precision issues.
7 L) H' c) O+ Z2 \: V// This define value sets the machine epsilon cutoff to determine if the arc is a full-circle or not.& Z' @9 o7 l6 D* [8 q/ K: {+ t( ?
// NOTE: Be very careful when adjusting this value. It should always be greater than 1.2e-7 but not too
! n3 r' e7 p6 R" |$ n// much greater than this. The default setting should capture most, if not all, full arc error situations.
% X) v( _9 f( O8 h& n6 `//弧G2/3刀位点的标准定义是有问题的。Radius-based弧有可怕的数值- j1 E% w) B* O' a9 i
//错误当电弧在半圆(π)或原点(2 *π)。Offset-based弧更准确* E$ d$ u9 @0 i l5 R8 s- e
//但仍有一个问题当弧原点(2 *π)。这个定义占浮动
$ J! [( ^6 \/ D4 ]8 N4 [) Z//当offset-based弧吩咐点问题完整的圆,但解释为极
: u$ A1 s$ J2 J' a, f$ s( L//小弧机周围ε(1.2 e-7rad)由于数字舍入和精度问题。4 i- A6 w6 U/ a; B! Q3 f4 u
//定义值设置机器ε截止来确定电弧是一个原点了。0 b1 k4 \; d5 Y9 R9 g) I+ B
//注意:调整这个值时非常小心。它应该总是大于1.2 e -但不要太0 g: K3 ]. q: P' I0 y
//比这大得多。默认设置应该捕获大部分,如果不是全部,全部错误的情况。
7 }) a* b& ^5 U+ V# `/ w* p* E
+ N, b- k k& Z4 h1 }; h/ @#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)
! b+ ?4 [5 u9 d& w
% K, M5 d$ L; }6 k7 ]// Time delay increments performed during a dwell. The default value is set at 50ms, which provides
( L9 r9 a* k7 }9 T: T" i3 T// a maximum time delay of roughly 55 minutes, more than enough for most any application. Increasing
1 C4 v" n# F: o7 }! i: v2 B' c$ b1 Q// this delay will increase the maximum dwell time linearly, but also reduces the responsiveness of
$ n9 o2 K/ }% F/ ]; Z; z: J2 b// run-time command executions, like status reports, since these are performed between each dwell
8 G7 N6 U# n0 c" T. M. i: e// time step. Also, keep in mind that the Arduino delay timer is not very accurate for long delays.
. `9 C9 i' y) r5 P; _/ y. Y//延时增加表现在住。默认值设置为50毫秒,它提供了9 ^& k; x3 g' n/ B$ {5 U' V# }
//最大延时约55分钟,足够对大多数任何应用程序。增加! h. J( d( O9 i T& x: c
//这种延迟将增加线性最大停留时间,也减少了响应能力0 n& P7 a6 |( z6 Q4 q
//运行命令执行状态报告一样,因为这些每个住之间执行3 m, ~* g" h$ q% B1 a' |
//时间步。还有,记住,Arduino延迟计时器不是很准确的长时间延误。- c" g8 h! [% c

) i" p9 B5 ^. K( x# ?& m& j#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds)4 Z# M; h; @! Q' w' J! j( i- k
( M, H+ X G9 K8 ]# U! x
// Creates a delay between the direction pin setting and corresponding step pulse by creating
5 I0 ^& s+ Z% w/ V( Z K5 M// another interrupt (Timer2 compare) to manage it. The main Grbl interrupt (Timer1 compare)
% Q* @, b( _# A) l/ M// sets the direction pins, and does not immediately set the stepper pins, as it would in
) k, \ N$ Z) i! b! K% s# I// normal operation. The Timer2 compare fires next to set the stepper pins after the step
0 `2 g4 ]: e! [/ ]) `! b# a// pulse delay time, and Timer2 overflow will complete the step pulse, except now delayed
+ ^. O' ]6 r3 G2 B, s// by the step pulse time plus the step pulse delay. (Thanks langwadt for the idea!)
7 E$ @6 P b* q% @, X3 N7 f+ [// NOTE: Uncomment to enable. The recommended delay must be > 3us, and, when added with the) L H7 ^. Z) }- D3 I
// user-supplied step pulse time, the total time must not exceed 127us. Reported successful# f' \) W* {* f: x- V
// values for certain setups have ranged from 5 to 20us.7 L3 l$ {+ b! T( d* _
//创建一个方向销之间的延迟脉冲通过创建设置和相应的步骤* a/ r8 ]( E# a, v
//另一个中断(Timer2比较)来管理它。主要Grbl中断(Timer1比较)+ i0 e0 I' w9 l& ~" K$ X- c5 ?
//设置方向针,不立即设置步进针,因为它会在# e- u5 P8 X4 N# x
//正常操作。Timer2比较火旁边设置步进针后一步! z; [, }$ _- P& _1 Z( x
//脉冲延迟时间,Timer2溢出脉冲将完成的步骤,现在延迟除外
, S+ U8 c6 M$ l" |4 N0 A `//脉冲时间加上的一步一步脉冲延迟。(感谢langwadt主意!)
2 ~+ t. _3 o- U# S3 a, m//注意:取消启用。必须> 3,建议延迟,当添加的I, ]) j- h$ } j5 q* {4 i
//用户提供的步骤脉冲时间,总时间不得超过127美元。成功的报道8 O* C, A5 _& p- |3 V4 }$ m
//值对某些设置范围从5到20。
0 j# k* Y' i# k9 `! m) {* U* x3 n+ M* i6 F! n- m
// #define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.
; `( L) H+ O- ]3 Z0 |% y9 T6 w1 B4 n" o: i
// The number of linear motions in the planner buffer to be planned at any give time. The vast
7 P+ P( H: }4 y// majority of RAM that Grbl uses is based on this buffer size. Only increase if there is extra: y( ?: E7 E6 A4 D" p6 p, O+ ^
// available RAM, like when re-compiling for a Mega or Sanguino. Or decrease if the Arduino) R$ Q) }3 z1 W: V
// begins to crash due to the lack of available RAM or if the CPU is having trouble keeping
' A$ R+ j; g3 U$ D& h3 [7 D9 C0 _/ _// up with planning new incoming motions as they are executed./ u0 J/ K8 v1 Y0 R, g
//线性运动规划师缓冲区的数量在任何给出时间计划。绝大0 ~4 o; j% ^# Z2 k N
//多数RAM Grbl使用基于这个缓冲区的大小。如果有额外的只会增加
. Y% ]! Q5 ?) j: N) I//可用内存,比如当基于大型或Sanguino。如果Arduino或减少
8 q0 r3 P* }! y- G, `9 `4 P. H) y//开始崩溃由于缺乏可用的RAM或者CPU是难以保持% f7 A+ V" P; ]; G. s9 W8 w
//与规划新传入的动作执行。; f3 g E( j& ?" f- d2 }: m
& b5 a5 I% t7 c; O: K' X3 l
// #define BLOCK_BUFFER_SIZE 18 // Uncomment to override default in planner.h.5 w, `5 s' _5 E6 d) x" X; i- L
# `: ^4 B. z. `& W
// Governs the size of the intermediary step segment buffer between the step execution algorithm
" w" [* I* x4 N& J8 z// and the planner blocks. Each segment is set of steps executed at a constant velocity over a3 D& i+ o( P. b
// fixed time defined by ACCELERATION_TICKS_PER_SECOND. They are computed such that the planner6 B/ i6 X0 n. X" p, J+ t
// block velocity profile is traced exactly. The size of this buffer governs how much step
# A% D0 T8 U2 s( ?2 C Z3 ^// execution lead time there is for other Grbl processes have to compute and do their thing
- z! ?, J+ N6 X( `! ~// before having to come back and refill this buffer, currently at ~50msec of step moves.8 K% p1 I! g7 z+ }
//控制之间的中间段缓冲大小的步骤执行算法
5 D: |1 D% J) t3 W, B# p& S4 b1 _1 \//和规划师块。每一部分的步骤执行在一个恒定的速度' a; A! _- S/ L5 |2 [( Z
//固定的时间由ACCELERATION_TICKS_PER_SECOND定义的。他们计算的计划0 \5 a0 Z1 I* W* M% h
//块速度剖面追踪到底。这个缓冲区的大小控制多少步骤
+ }+ P( I$ x1 V) L//执行时间有其他Grbl过程需要计算和做他们的事情
, z+ x4 C9 S0 c2 ~6 M//之前必须回来重新填充这个缓冲区,目前移动~ 50毫秒的一步。$ V- |. J% z* D6 i( A! @# S! T

1 e! I$ ^ w$ |// #define SEGMENT_BUFFER_SIZE 6 // Uncomment to override default in stepper.h.
`. _# I1 r4 C w3 i# [7 c8 N9 Y e4 W3 f: R4 P/ I
// Line buffer size from the serial input stream to be executed. Also, governs the size of2 X$ a- H- `5 h4 T* B0 x+ o* o6 R
// each of the startup blocks, as they are each stored as a string of this size. Make sure1 A. I7 b5 A2 s! D- b6 e. D
// to account for the available EEPROM at the defined memory address in settings.h and for4 [4 ]& |! ?6 j' R5 D6 q+ R
// the number of desired startup blocks.! F' H( a7 F+ G8 H+ K
// NOTE: 80 characters is not a problem except for extreme cases, but the line buffer size
: [( ~0 ]: Z/ Q$ Z// can be too small and g-code blocks can get truncated. Officially, the g-code standards7 n) Z# {$ x6 K8 n5 k- _
// support up to 256 characters. In future versions, this default will be increased, when% Y) j9 ~; M3 `
// we know how much extra memory space we can re-invest into this.7 U$ u' B0 E+ T/ ~
//行执行串行输入流的缓冲区大小。同时,大小的控制
! I y, U* [1 v }+ z//每个启动模块,它们分别存储为字符串的大小。确保& G/ I2 O% y% Z/ {! U- d$ f
//占可用eepm定义内存地址的设置。h和! w6 |& E/ g+ u% j6 H; z
//需要启动块的数量。
( m# }6 [! @& b) k' m//注意:80个字符不是一个问题,除了极端的情况下,但线缓冲区大小6 J: b) A. ~2 ?: f! R
//可以太小和刀位点块可以截断。正式,刀位点标准5 o$ x4 k, M' Q
//支持多达256个字符。在未来的版本中,这个违约将会增加,当
u: K+ L% W0 R! G: e. g//我们知道多少额外内存空间的时候我们可以再投资。
, F7 M. W& @; p. C& I, h& W3 N) r% O. e
// #define LINE_BUFFER_SIZE 80 // Uncomment to override default in protocol.h
7 ]% b* E, ~! k9 U( A5 h2 h
/ r+ a) u9 s* Q7 T// Serial send and receive buffer size. The receive buffer is often used as another streaming2 R( U% r p. g% ~2 g) V/ C
// buffer to store incoming blocks to be processed by Grbl when its ready. Most streaming
8 u% h2 O5 S" H5 U% L// interfaces will character count and track each block send to each block response. So,
# c% l# A$ z7 u. l9 O5 [& J// increase the receive buffer if a deeper receive buffer is needed for streaming and avaiable
+ R; O$ z' r. y% _) x; k" {// memory allows. The send buffer primarily handles messages in Grbl. Only increase if large
. G/ b6 P6 n1 A7 v/ R* M: f7 h// messages are sent and Grbl begins to stall, waiting to send the rest of the message./ F& S+ p! D$ Z |- c% [
// NOTE: Buffer size values must be greater than zero and less than 256.
- J- R, C! E9 }// #define RX_BUFFER_SIZE 128 // Uncomment to override defaults in serial.h
* P4 k! W% z6 o; `+ u2 Z; I1 m//串行发送和接收缓冲区大小。接收缓冲区通常用作另一个流7 R" P1 ]% @# b o1 b7 k, g
//缓冲存储传入的块来处理Grbl当它准备好了。最流
1 G9 @8 h- m1 T1 Z9 @, L$ `4 G//接口将字符计数和跟踪每一块发送给每个块的回应。所以,! X1 W( X% a0 a7 N# J( K
//增加接收缓冲区如果需要更深层次的接收缓冲区为流,、
2 Y d0 G1 R5 i9 h" K% S2 X//内存允许。Grbl发送缓冲主要处理消息。只会增加如果大
- \4 i7 [$ N2 X, y, b R0 j//消息发送和Grbl开始停滞,等待发送其余的消息。" e4 W5 o# e& r6 R# t3 j
//注意:缓冲区大小值必须大于零,小于256。! y" I5 n6 b& k9 O* I
// # define RX_BUFFER_SIZE 128 / /取消serial.h覆盖默认值
, m7 N% d) P r1 U! |- s3 T+ c6 m1 F7 V0 W( \. [. ]

7 e, A$ b" G8 Z// #define TX_BUFFER_SIZE 641 }/ Q+ W# q* i2 R
- b) J6 P3 g) x9 N2 E& N
// Toggles XON/XOFF software flow control for serial communications. Not officially supported
: O1 b+ U6 S, g8 U% I: d// due to problems involving the Atmega8U2 USB-to-serial chips on current Arduinos. The firmware
; S5 ]/ \+ J8 j+ u/ y// on these chips do not support XON/XOFF flow control characters and the intermediate buffer8 m$ G& a) t/ H7 V
// in the chips cause latency and overflow problems with standard terminal programs. However,
3 N9 i" {+ L9 l. P6 p) U* T9 M- m// using specifically-programmed UI's to manage this latency problem has been confirmed to work.
! w4 E0 ?3 h P0 ^// As well as, older FTDI FT232RL-based Arduinos(Duemilanove) are known to work with standard
1 G2 [9 N$ `: n( S% \// terminal programs since their firmware correctly manage these XON/XOFF characters. In any
8 E1 `) e% I* `// case, please report any successes to grbl administrators!
, [8 c$ m T { Y" I- O//切换为串行通信发送朴通/发送葡开软件流控制。不是官方支持
/ d; D6 c8 g# A) F: s: |//由于问题涉及Atmega8U2 USB-to-serial当前arduino芯片。固件
# C. g9 Z# `2 D( H- ]- k//在这些芯片不支持发送朴通/发送葡开流控制字符和中间缓冲区, i* x+ [ e% Z; {) n
//芯片导致延迟和溢出问题的标准终端程序。然而,
3 `$ ]; d# ^: T4 a# b( Y/ [8 e9 {- V//使用specifically-programmed UI的管理这个延迟问题已经确认工作。3 L; d& @: E8 t) L( |
//以及老FTDI FT232RL-based arduino(Duemilanove)是已知的标准6 b6 d7 b8 T8 a; v* l/ p
//终端程序因为他们正确的固件管理这些发送朴通/发送葡开的角色。在任何
% L% L) Z. ]5 R7 |4 i/ v$ d//情况,请报告任何成功grbl管理员!
$ ?& n# o, n2 J4 Q
3 w& ^! ^) S4 k7 y+ X2 H& J! }. z// #define ENABLE_XONXOFF // Default disabled. Uncomment to enable.
! y: r4 A7 v0 J
1 k# {, b. g7 F* W& ]// A simple software debouncing feature for hard limit switches. When enabled, the interrupt5 N5 Z3 ` j* W8 h( g2 b* w V
// monitoring the hard limit switch pins will enable the Arduino's watchdog timer to re-check+ k; R! W$ O- E
// the limit pin state after a delay of about 32msec. This can help with CNC machines with9 |/ g) W4 ]6 T
// problematic false triggering of their hard limit switches, but it WILL NOT fix issues with) c6 _5 u7 }* q% r5 G& O
// electrical interference on the signal cables from external sources. It's recommended to first9 |. ^! f4 I! U- B) @2 v3 g" y
// use shielded signal cables with their shielding connected to ground (old USB/computer cables- K+ A8 G/ R9 a8 |; ~% u
// work well and are cheap to find) and wire in a low-pass circuit into each limit pin.& _/ h% w9 L- V0 J
//一个简单的软件消除抖动特性硬限位开关。当启用时,中断+ t% {: z( ~ [9 W, z( J6 y
//监控硬限位开关针将使Arduino的看门狗定时器重新审视
0 J% H9 u% O- P7 w9 Z* z4 _//销的极限状态后约32毫秒的延迟。这可以帮助与数控机器, v% _; w0 p5 m z( U N
//问题错误引发的硬限位开关,但是它不会解决问题
D7 Q" E) J' x }) y3 Y8 O0 H: s//电干扰信号电缆从外部来源。首先它的建议5 e, t7 A5 K" M1 K
//使用屏蔽信号电缆的屏蔽连接到地面(老USB /计算机电缆# | k% D+ f' @6 O; a2 a( A
//工作得很好,很便宜)和线低通电路到每个限位销。6 A3 b( U& W) @- `1 Q
6 r/ }' F% q' j0 R' u
// #define ENABLE_SOFTWARE_DEBOUNCE // Default disabled. Uncomment to enable.7 |5 h( J. H2 K

+ s2 j8 b) @" @: |4 S; l// Force Grbl to check the state of the hard limit switches when the processor detects a pin
; _! q: B* N, @* @, U+ q// change inside the hard limit ISR routine. By default, Grbl will trigger the hard limits8 r2 m8 k' I3 y! K1 h
// alarm upon any pin change, since bouncing switches can cause a state check like this to
& P( W' V+ V" M( c// misread the pin. When hard limits are triggered, they should be 100% reliable, which is the
+ U+ c- j' Q& S3 r// reason that this option is disabled by default. Only if your system/electronics can guarantee+ \# J6 ~) p8 `) g" u! I: P2 L. |
// that the switches don't bounce, we recommend enabling this option. This will help prevent- L+ K3 z. }# f3 E
// triggering a hard limit when the machine disengages from the switch.
: p+ F' M! ]9 P' X# {) m) d, ]3 }// NOTE: This option has no effect if SOFTWARE_DEBOUNCE is enabled.& M( l6 S, `, x. ~
//力Grbl检查硬限位开关的状态,当处理器检测到一个销% m: t/ U# z3 X) }( c8 a6 a; F: R/ d
//改变内部硬限制ISR例行公事。默认情况下,Grbl将触发硬限制
W8 p1 ?# s& o+ H- t6 {+ u& w3 F//报警在任何销更改,因为跳开关可以导致这样的状态检查6 B/ l, k, W! j5 Q. i2 L
//误读了销。硬限制触发时,他们应该100%可靠,这是4 q" |( V9 G+ [. z, A* }
//原因,这个选项默认是禁用的。只有在你的系统/电子产品可以保证
9 E$ B* R" y. x# S7 _//开关不反弹,我们建议启用这个选项。这将有助于防止
; l' y5 ?/ b; ?" L- z2 b//触发机退出时硬限制开关。7 a) o% o5 }0 q" q
//注意:这个选项如果启用了SOFTWARE_DEBOUNCE没有影响。
* A* F5 @3 r4 ]/ [. k1 y% u1 y
! h- s# I: a3 M3 @* I8 c// #define HARD_LIMIT_FORCE_STATE_CHECK // Default disabled. Uncomment to enable.
' u6 D6 W4 w! f2 v
% k1 j3 w# e+ N; ^) z# `& B3 D
0 D5 l7 G, T% n0 k# A( _; V2 B// ---------------------------------------------------------------------------------------
& y1 U3 p6 x1 q' e3 \3 u. ^// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:编译时错误检查的定义值:
+ [$ \* }1 G, W; l, k( F: e. E: c$ c/ {; a+ T1 b
#ifndef HOMING_CYCLE_0
- q, I" e* M2 Y: }4 g' @#error "Required HOMING_CYCLE_0 not defined."
& f7 t- ^0 c* x) P* @#endif7 ~8 R/ o: b$ y: I5 G- Z: Z

- V& p+ q( ]6 l. t/ _0 R% y#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(VARIABLE_SPINDLE)- ~% R/ F, l7 ?4 J* b: \! S
#error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with VARIABLE_SPINDLE enabled"
7 n# E! ^/ Y: ~2 g#endif# b- X" K9 v2 J' U
" ]: `4 N, Z% P/ U7 t5 O* H
#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(CPU_MAP_ATMEGA328P)
1 a5 l% R6 w& l% r#error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with a 328p processor"* h6 s2 M5 l8 A, _: |9 m
#endif
4 h V# {: }+ s, i9 T8 W8 p7 S
9 z1 x y* ?0 ?. o2 u [+ [6 M// ---------------------------------------------------------------------------------------3 M4 {; t! Y) p) X1 W& o/ N

7 A9 q, f9 {* f, }" _; B0 T% m' `9 `- h
#endif
1 T- L3 ~$ _$ p. } _) d: m. K1 M( C! o7 f, S9 Z$ [4 U
5 Y- x( B% n9 E& U" N! Q, b. C

7 P0 f& @3 J, i( ?! w- d
! V% [+ V+ h/ C8 [/ @ i. i
! q! v. G+ A& h2 B; E! K
* t2 k. Z, h$ M3 Z: p. _4 R; K, D/ S

. ^5 x" a( e: h7 X5 `7 |
6 }$ Y8 P6 X* J' {; ?
- T( F0 T0 o6 g0 [4 ?) u! b) c2 t3 z1 A4 B
! Q, B8 [ H& B) l- C
) H/ f$ | H) ~9 y4 j
& M2 B- v$ L& M
, @: c M1 o& y4 y
& l4 r. W0 {! C

本帖子中包含更多资源

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

x

评分

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

查看全部评分

2#
楼主 | 发表于 2016-8-21 00:11:42 | 只看该作者
那些没有用的照片不知道怎么就上去了好讨厌。
3#
楼主 | 发表于 2016-8-21 00:14:16 | 只看该作者
, B3 z& Q( S, b7 r2 \# ~) G
4#
发表于 2016-8-21 05:50:22 | 只看该作者
楼主厉害!
5#
发表于 2016-8-21 08:22:05 | 只看该作者
谢谢楼主,先收藏一下,慢慢学习
6#
发表于 2016-8-23 15:11:25 | 只看该作者
这是什么宝贝?
7#
发表于 2016-8-23 15:11:47 | 只看该作者
换了个浏览器Chrome,试试能否发言了。
8#
发表于 2016-8-23 20:12:33 | 只看该作者
楼主厉害
9#
楼主 | 发表于 2016-8-23 23:03:17 | 只看该作者
补充+ `: v# O! l, L2 p6 z
程序运行protocol_execute_realtime(); /运行实时命令。* o7 R7 f1 C) j; T6 E
// Executes run-time commands, when required. This is called from various check points in the main
9 g* d) S) l9 Z7 j% {# G8 k! i// program, primarily where there may be a while loop waiting for a buffer to clear space or any
6 c5 X( c" N& Z' o8 I8 m// point where the execution time from the last check point may be more than a fraction of a second.& a5 I0 U/ w9 Z1 p
// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code6 d T* \4 B9 U+ L N- G
// parsing and planning functions. This function also serves as an interface for the interrupts to& K: K3 g( M: x# {$ i" a' z
// set the system realtime flags, where only the main program handles them, removing the need to
% Y9 Q( j% y" b// define more computationally-expensive volatile variables. This also provides a controlled way to* ^0 }* b! P, v
// execute certain tasks without having two or more instances of the same task, such as the planner& t4 X0 A# Y' H8 n
// recalculating the buffer upon a feedhold or override.9 J3 N2 M) ~5 O2 ]& ^/ ~* N
// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,
4 }4 W4 d$ X# d& V, w; `6 {/ e// limit switches, or the main program.
( H$ ?9 ?& x! O2 n7 D9 f d+ W+ o9 @8 ^2 v
//执行运行时间命令,在需要时。这就是所谓的从各种主程序要检查站
! I& ?- F. f( {+ r, F//,主要是那里可能是一个while循环等待缓冲区空间或任何
) H: ]% y6 a: |3 X//执行时间从过去的止点可以超过几分之一秒。
. d- F6 f& j% T//这是一种异步执行实时命令(又名多任务)grbl的刀位点
7 C# x. C5 Y, @9 @//解析和规划功能。这个函数也可以作为一个接口,用于中断" ^/ O" }" p3 b# O. J o4 ?
//设置系统实时的旗帜,只有主程序处理,消除的需要
$ I. N0 v+ \- f( v- o/ B. f//定义更多的计算昂贵volatile变量。这也提供了一种控制方法
, A2 O) `& n; t! o//执行某些任务不相同的两个或多个实例的任务,比如计划7 B) a) J! P* |3 q
//重新计算缓冲feedhold或覆盖。
$ ^/ e+ @2 |5 E: d. {" W1 i% J//注意:sys_rt_exec_state变量标志设置任何过程,步骤或串行中断,插脚引线,/ S6 B) h+ v& B! E
//限位开关或主程序。5 p3 ?' P3 p3 }& z5 R
void protocol_execute_realtime()9 {$ w7 p" S9 n$ Z3 v. h+ N
{$ n% }8 K" Y F0 V- Q' O- Q
// Temp variable to avoid calling volatile multiple times.$ x6 B: C j( ^( t, J. }! a
// 临时变量来避免多次调用不稳定。
% F% J8 C8 S) c& P+ Guint8_t rt_exec;
% [/ I! D' H( j( O1 Tdo{* \1 c7 i; d* _. f$ x$ }6 n2 O" d
if (rt_exec) { // 有标志位置位进入
, y$ U, z! Q2 ?6 v" R/ h+ _' _% g4 O' b/ }
sys.state = STATE_ALARM; // 设置系统为报警状态
% \( h& [/ _. a* |" kreport_alarm_message(ALARM_HARD_LIMIT_ERROR); //报告报警信息为接近极限值1 K9 z/ j9 t7 I
} else if (rt_exec & EXEC_ALARM_SOFT_LIMIT) { //报告执行软件限位报警5 A8 L( U c t# n1 Y
report_alarm_message(ALARM_SOFT_LIMIT_ERROR); //报告出现软件限位报警
6 q2 i( G1 b4 o" J$ y} else if (rt_exec & EXEC_ALARM_ABORT_CYCLE) { //执行停止循环报警3 [) \. C r* ~" f- D
report_alarm_message(ALARM_ABORT_CYCLE); //出现终止循环报警
& t1 t- w1 B9 |; a} else if (rt_exec & EXEC_ALARM_PROBE_FAIL) { //执行探查失败报警
: D$ ~4 w- k h' rreport_alarm_message(ALARM_PROBE_FAIL); //出现探查失败报警
; T; c8 k& W7 [8 R( @& a} else if (rt_exec & EXEC_ALARM_HOMING_FAIL) { //执行返回原点失败报警1 r1 D9 w/ x+ M: y/ h
report_alarm_message(ALARM_HOMING_FAIL); //出现返回原点失败报警$ T# Q! a- k9 T' n( E0 [' C
}- n" j8 X* i; F3 M8 {2 t9 V! F/ n( ^
" O) ?; k+ A7 s
// Halt everything upon a critical event flag. Currently hard and soft limits flag this.
b: b2 ?2 \9 R" j// 停止一切在一个关键事件标志。目前硬和软限制标志. M* b* Q' o1 A
if (rt_exec & EXEC_CRITICAL_EVENT) { //如果系统是循环事件进入/ {0 |# H. X! o
report_feedback_message(MESSAGE_CRITICAL_EVENT); //报告反馈信息6 r' l/ m. _- I8 q) v
bit_false_atomic(sys_rt_exec_state,EXEC_RESET); //清除目前的复位状态
+ _) R4 P# Y( I& ?* y" q3 \0 n6 d. P) M* w5 n7 T- @: a
bit_false_atomic(sys_rt_exec_alarm,0xFF); // 清除所有报警标志
0 {* ]5 D9 x' r9 R6 w# A/ C5 ]! v}& u% a+ T2 R) R9 G; |

3 e, n) P/ C( ~上面代码将rt_exec = sys_rt_exec_alarm ,如果rt_exec为真,打印不同报警信息
: u7 {0 e5 h7 {7 N6 ~和限位保护信息,然后清除报警状态& I# v3 D4 l# o0 E/ u i# `' x
___________________________________________________________________________
( x! T0 U- P/ s% O0 T5 z没有报警进行执行下面代码,执行了终止命令,串口打印命令7 c% E8 U2 _6 s+ O- U% a
// Check amd execute realtime commands 校验和执行实时命令
( W# A1 ^; e3 g( f5 j7 s: Prt_exec = sys_rt_exec_state; // Copy volatile sys_rt_exec_state
* g- o! ~- f, J; }# x7 a
) O7 J+ T0 l! w6 u; hif (rt_exec) { // 输入标志是正确的执行
2 O6 {' Q2 l- ]6 L
4 Z! X ?7 ` Y! y/ E) s// Execute system abort. 执行系统终止命令
& _/ f, D% Z1 E. N3 X3 b% k+ rif (rt_exec & EXEC_RESET) {! e7 Y) R. K* a; l8 u$ h6 k
sys.abort = true; // Only place this is set true.
& U/ k/ \; ~9 @& B" _, B$ v# Treturn; // Nothing else to do but exit.4 r) p; z3 ]* G8 U8 w- I% y
}! p1 h8 O7 A/ P; }5 ?) {% S
, O1 s8 ^$ v: _4 U& L2 C6 ?
// Execute and serial print status 执行和串口打印状态
1 [0 b/ s' |% I, X! hif (rt_exec & EXEC_STATUS_REPORT) {
& M E1 p% y0 |5 r+ x( R) Freport_realtime_status(); //报告实时状态, O# X' u& P: B8 m. q( Q, ^& E1 @
bit_false_atomic(sys_rt_exec_state,EXEC_STATUS_REPORT); //清除报告状态清零% R1 S7 b* ?" v3 E6 {
}# X% p3 R6 F0 x9 q. ]5 A
_____________________________________________________________________________) w n5 E" s3 i: [9 d" x5 e
下面代码
8 ?1 f: s* R" i- k; \//执行状态。* x X7 a! A9 U. e0 J: }
//注意:所涉及的数学计算持有应该足够低对大多数人来说,即使不是全部,% r2 Y) N" T3 \1 M; D; y V
//操作场景。一旦启动,系统进入暂停状态7 ]5 W, p' a' S
//主程序流程,直到重置或恢复。* C. [9 V+ w: _ E1 S( v
待办事项:检查模式?如何处理呢?可能没有,因为它只会在空闲,然后重置Grbl。4 `% U4 y: o8 k% _7 g
状态检查容许状态的方法。
2 {, w1 r0 T; r3 y) e) }1 `* X9 }# B/ G, L g+ K
//如果全局各自报警标志位其中(执行取消动作) | (执行进给保持) | (执行安全门)任意一位为真进入+ R9 {0 f$ @8 e" h( n4 Y
if (rt_exec & (EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR)) {9 V! ^+ \# h. ]% E
7 C: a/ E/ u; ~
//如果是循环状态执行暂停状态
* \8 C7 s; X; Q! K) q' aif (sys.state == STATE_CYCLE) {& g. i- }9 }8 u) }5 a8 k) D' B
st_update_plan_block_parameters(); //通知stepper module验算减速。4 c* ^9 N( X9 u. |4 n( G
sys.suspend = SUSPEND_ENABLE_HOLD; // 开始暂停标志
. O. s) Z6 [% Y6 ?9 V! i}
0 m6 x3 ^2 ]/ y" }5 z- h- k$ V+ c/ {1 t$ {
// 如果,Grbl空闲不在运动。简单的指示暂停就绪状态。
: f x1 U; ~9 Q$ [& ] iif (sys.state == STATE_IDLE) { sys.suspend = SUSPEND_ENABLE_READY; }$ S, i# g7 o/ |3 U

* ?! W* ~, t c% w5 _& T; O, T. W T4 V: \& n
//执行和标志和减速运动取消并返回空闲。主要由探测使用周期* K" J1 D. H! J0 f7 w
//停止和取消剩余的运动。
* Z( x' P; s0 u9 ] F- |8 Vif (rt_exec & EXEC_MOTION_CANCEL) {
! g' r. d* H0 @6 ]+ H1 d9 z* `5 }if (sys.state == STATE_CYCLE) { sys.state = STATE_MOTION_CANCEL; }
}2 |* b0 e# `8 ?, Asys.suspend |= SUSPEND_MOTION_CANCEL;- B2 z2 {: l; q. a9 i" n
}: |4 u; h4 b/ i t" T
, @/ E+ {2 |( Y% ~3 H$ T
// 只在循环时执行进给保持减速! q. M* U5 a- [8 O6 S+ l
if (rt_exec & EXEC_FEED_HOLD) {2 @% r; g* [# z0 X# B0 Z2 b
//只有安全门为1才执行保持进给状态赋值
1 Q2 W$ O# ^1 I+ o1 Mif (bit_isfalse(sys.state,STATE_SAFETY_DOOR)) { sys.state = STATE_HOLD; }
* ^9 _7 Y2 o* n; v( _0 P$ p' r9 Y}
' A/ X: u6 @0 f3 ~0 H" e' }2 m# q# n; Z5 E. L9 ?* f0 T
if (rt_exec & EXEC_SAFETY_DOOR) {! v. j, ~/ b* o" T' v0 H7 I {4 m
report_feedback_message(MESSAGE_SAFETY_DOOR_AJAR);+ d2 s* e9 p& \9 \6 D
/ /如果已经活跃,准备好重新开始,CYCLE_STOP标志设置为强制断开。. n) h1 ^' P* V1 m8 l6 ?2 }
/ /注意:只是暂时设置“rt_exec”变量,不是动荡的“rt_exec_state”变量。* n! f' X( ^; T
if (sys.suspend & SUSPEND_ENABLE_READY) { bit_true(rt_exec,EXEC_CYCLE_STOP); }
/ J: U9 B A1 V7 E) {% Bsys.suspend |= SUSPEND_ENERGIZE;1 R" E2 p" q6 e1 O" J) C2 M L' A
sys.state = STATE_SAFETY_DOOR;
* T) v& I# S1 v& f- A}
: n8 c- w! H8 o* F, ? d# B8 a+ Y: Z) H" g% I! g
bit_false_atomic(sys_rt_exec_state,(EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR));
/ L# R( Y! {& y; Y3 B. U
( O0 f5 ?! F3 A- D, @}
1 r3 h4 d! F) y% {% b% \以上代码执行了1 _5 E( B; _5 e* L4 u# N% n- Y
1.如果全局各自报警标志位其中(执行取消动作) | (执行进给保持) | (执行安全门)任意一位为真进入
0 }0 q" D/ w+ y9 Q8 o2.系统为闲着状态, 开始循环状态, 回原点状态, 控制取消状态, 开始保持状态, 开始安全门状态时进入
7 x) g' d0 R( H; \( k3.如果是循环状态执行暂停状态
7 [' a- O, l. i: C. c" T$ ?, b/ ?4.如果系统闲置状态执行暂停就绪状态
4 a, `3 _9 u# ^& E5.执行动作取消
% _/ n; C( Z/ J6.如果是保持进给状态,执行保持进给状态
; x4 X) F: k7 v% W7.执行安全门状态* Q( B% L# w1 o4 [- z* F) ^
最后执行bit_false_atomic清标志清除(执行取消动作)(执行进给保持)(执行安全门)标志位
' h% \9 | k/ X7 y6 c: ]_____________________________________________________________________________
. S2 |7 i( i- a) r7 w( b/ P+ X" F' @, u
// Execute a cycle start by starting the stepper interrupt to begin executing the blocks in queue., E8 C2 [0 e. b- ?: F+ {0 Z
// 执行一个循环开始启动步进开始执行中断队列的街区1 |% ?6 c: ~5 A5 _; P
if (rt_exec & EXEC_CYCLE_START) { //循环开始状态进入, P7 a! m$ t7 I0 ?# o4 G
// Block if called at same time as the hold commands: feed hold, motion cancel, and safety door.
. u4 R5 W4 e, M! O, P4 Q// Ensures auto-cycle-start doesn't resume a hold without an explicit user-input.% c( X+ P; N0 o3 H% \, ]- M! {4 |
//块如果在同时举行的命令:保持进给,运动取消,和安全的门。 //确保auto-cycle-start没有简历没有显式的用户输入。
[- N6 J* r0 y- O3 U8 u; p. v$ o
* f8 g; q3 g. b" z! V) B5 jif (!(rt_exec & (EXEC_FEED_HOLD | EXEC_MOTION_CANCEL | EXEC_SAFETY_DOOR))) { //状态机如果不是保持进给,运动取消,和安全的门。# B1 D' ]7 |' n/ Y/ o0 d
// Cycle start only when IDLE or when a hold is complete and ready to resume.
' ^8 j- s% q; a' Y+ E3 K7 f// NOTE: SAFETY_DOOR is implicitly blocked. It reverts to HOLD when the door is closed.
. o0 \; d% G5 |2 k* {7 V ~. w//循环开始时只有当闲置或持有完成并准备简历。
/ t. v( N+ Y4 R: z# t* D" h) k+ t//注意:SAFETY_DOOR是隐式地屏蔽。它返回的时候门是关闭的。
8 c. S X& v+ K. Y0 X P1 W
4 o) j' N1 C+ w& n. N A// 如果系统状态为闲着状态,系统状态为开始进给或运动取消,暂停标志为位重新开始- G+ q4 N, ^7 R% d
if ((sys.state == STATE_IDLE) || ((sys.state & (STATE_HOLD | STATE_MOTION_CANCEL)) && (sys.suspend & SUSPEND_ENABLE_READY))) {0 B4 v9 h v" G+ g6 `
// Re-energize powered components, if disabled by SAFETY_DOOR., G" j8 l3 h- ]& s- G/ r$ V
// 由SAFETY_DOOR重振组件供电,如果禁用。
2 E8 P% ]; v! w$ u. j- Y2 Eif (sys.suspend & SUSPEND_ENERGIZE) {
2 Y9 ], W* \! r/ \// Delayed Tasks: Restart spindle and coolant, delay to power-up, then resume cycle.
8 k6 Q' d. @+ P- P2 T0 a//延迟任务:重新启动主轴和冷却剂,延迟升高,然后恢复周期。
1 ^1 n1 R& W) w! l( pif (gc_state.modal.spindle != SPINDLE_DISABLE) { //主轴模式不是失能进入8 M/ p8 n3 j# P5 T: u+ P
spindle_set_state(gc_state.modal.spindle, gc_state.spindle_speed); //设置状态和速度7 g; Q, U5 M" H" C2 r- U; g3 v
//待办事项:阻塞函数调用。最终需要一个非阻塞。
5 \2 x+ C: c8 Odelay_ms(SAFETY_DOOR_SPINDLE_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.5 V; r( N: z+ j1 T( i% ?; ]
}. N3 C, F4 H2 p! L! Q9 h: |) X* d& b1 J
if (gc_state.modal.coolant != COOLANT_DISABLE) {
/ z! ?9 X. W( ^' O2 Z) {' q4 G2 zcoolant_set_state(gc_state.modal.coolant);% _. Y+ }! h) O" W+ m! q! y8 Z# u" A
delay_ms(SAFETY_DOOR_COOLANT_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.6 j8 F$ {+ G1 x9 d$ ^
}
& P/ M$ Z% c: L; a// TODO: Install return to pre-park position.3 G: _4 z% Y, m6 a
}6 T0 ^" M m0 l/ r, h [) @
______________________________________________________________________________________________________________
4 I: a( R& l: ?% m+ s// Start cycle only if queued motions exist in planner buffer and the motion is not canceled.
/ S: q1 {. L5 ot& s% t# J2 S( {
//只有在队列马达存在规定的缓冲,并且动机没有让取消,才会循环
& n6 a* M- b Z$ q* l1 z# B4 Z% F1 x& ^
if (plan_get_current_block() && bit_isfalse(sys.suspend,SUSPEND_MOTION_CANCEL)) {
7 c' S) Y' B4 `& ]sys.state = STATE_CYCLE;
) z x# S7 p9 V! h' _$ tst_prep_buffer(); // Initialize step segment buffer before beginning cycle.初始化步开始循环之前
, e6 s* h" r. {st_wake_up();0 r& J% S2 ?8 R: X; m
} else { // Otherwise, do nothing. Set and resume IDLE state.否则,什么也不做,设置和复位空闲模式! f" I5 `$ Y5 S2 s
sys.state = STATE_IDLE;! A3 _2 }" w* B1 X- ~9 W* r' y
}
" v6 R& ~$ @6 d, O6 T& Rsys.suspend = SUSPEND_DISABLE; // Break suspend state.
- |9 R( b2 u! @" B$ M% A}
' \& y7 ?( g8 g& o; U, E}
5 A" g/ K( S$ p4 r$ o- zbit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_START);8 w- K0 A; |+ u* J7 ]' V0 ]' X% z
}
( n" d8 e7 O9 e% V- H+ n0 |$ S# t" q8 ]8 h- o" e$ G' z
_______________________________________________________________________________________________________" U8 |4 u5 x5 Y
// Reinitializes the cycle plan and stepper system after a feed hold for a resume. Called byK' G+ p% f* z& _: g6 s( |5 A# W
// realtime command execution in the main program, ensuring that the planner re-plans safely.
, f* k o0 l' n7 y- i9 `6 j1 [// NOTE: Bresenham algorithm variables are still maintained through both the planner and stepper
7 ?/ j0 H3 F) \# d* w// cycle reinitializations. The stepper path should continue exactly as if nothing has happened.
4 H& P7 G- \* k N e// NOTE: EXEC_CYCLE_STOP is set by the stepper subsystem when a cycle or feed hold completes.
5 H: _/ [: t, Q x/ i. I) {5 p" N( V1 Y( z: S0 u+ p: [
//重新启动后循环计划和步进系统的进给保持简历。通过实时命令执行主程序,确保安全计划重新计划。
9 R8 }5 |1 w8 B3 J5 N1 v2 f0 e//注意:画线算法变量仍保持通过规划师和步进
" B8 B! C8 g' m0 M: s! y8 X//循环仅。步进路径应该继续,好像什么都没发生一样。+ j( W& ^, |, e h* \
//注意:EXEC_CYCLE_STOP由步进子系统周期或进给保持时完成。
4 @; H! m5 y% X2 l, Y$ G; e: d9 K6 G( I* e
if (rt_exec & EXEC_CYCLE_STOP) { //如果是循环停止状态进入0 T0 ]8 l' O% l- Q6 o |
if (sys.state & (STATE_HOLD | STATE_SAFETY_DOOR)) {
4 J( X0 R; k% j// Hold complete. Set to indicate ready to resume. Remain in HOLD or DOOR states until user
7 p* _! G) V( k: t( {( F6 x7 U// has issued a resume command or reset.3 J# Q) p6 g0 |; g _. W
" n4 H; a* T. \1 @- w
//保存完整。设置为指示准备简历。继续持有或门状态,直到用户/ t3 o: Q; N0 U
//已发布了一份简历命令或重置。0 m; _/ W& Y4 ~5 |* b; e& P% K
) ]( H; j! Q# a
if (sys.suspend & SUSPEND_ENERGIZE) { // De-energize system if safety door has been opened. 如果安全的门已被打开。断开系统( ]" p5 G/ M' C
spindle_stop();+ x/ ~" m/ x3 s: R4 p9 t7 Y9 |$ a
coolant_stop();" x" _0 l8 i0 U3 d
// TODO: Install parking motion here. 安装停车动作。
" Q) Q) M$ X5 r% _- ]. I& s5 x}
" K0 y* V. z; f3 `, L& zbit_true(sys.suspend,SUSPEND_ENABLE_READY);
+ A% y2 \2 C3 z- ]9 J3 [4 ~; U} else { // Motion is complete. Includes CYCLE, HOMING, and MOTION_CANCEL states. 电机完成,循环,回原点,,MOTION_CANCEL
" S% `+ X( D1 g- Ysys.suspend = SUSPEND_DISABLE;
/ e5 [! B2 y9 X- q+ E) ?- ~sys.state = STATE_IDLE;' [6 d& O. c( |0 S
}6 N7 z' c% ?, k% N
bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_STOP);
5 [$ T9 m: H2 i1 d9 }}
+ Y/ s, G0 ]# O$ i3 d9 m% _
9 Q3 _; N2 T1 n* D+ E5 x) {. _}: R1 o. z2 }, m0 b9 e9 F6 ?; i' x- x
___________________________________________________________________________________________________5 i8 t6 ~! d3 w8 F

. r2 n# L1 T1 V7 O, s! w// Overrides flag byte (sys.override) and execution should be installed here, since they- y4 W {4 E2 ]
// are realtime and require a direct and controlled interface to the main stepper program.) r: m! s- U. `: E

8 d0 g0 j$ B& D2 X3 |; R//重写标志字节(sys.override)和执行应该安装在这里,因为他们# E* T. p$ V; ?- y8 o4 {; a
//实时和需要直接和控制接口的主要步进程序。# V% u0 ~6 k3 u3 B8 y# D# E
1 A$ G- l; r7 U+ L0 m9 X
' z- H- }5 U- ]' D
// Reload step segment buffer 重新加载步段缓冲
: v; _- B" O3 J: ^- hif (sys.state & (STATE_CYCLE | STATE_HOLD | STATE_MOTION_CANCEL | STATE_SAFETY_DOOR | STATE_HOMING)) { st_prep_buffer(); }; ?$ M8 u2 E/ A& T
" Q, D( A- }6 ?4 o
// If safety door was opened, actively check when safety door is closed and ready to resume.
$ j' w+ e8 Q: Z, u) \$ ]0 {// NOTE: This unlocks the SAFETY_DOOR state to a HOLD state, such that CYCLE_START can activate a resume.
) g# }" N5 { J, f% A" _1 _! z6 Q4 e- C( R' [3 ]0 A* l
//如果安全的门被打开,积极检查当安全门关闭,准备简历。8 @# h% T8 M( W0 ] U" s7 n
//注意:这解锁SAFETY_DOOR状态保持状态,这样CYCLE_START可以激活一个简历。
! G% L* x" _9 \4 r' L; Q- Es( A: \6 u7 u* |$ g9 a
if (sys.state == STATE_SAFETY_DOOR) { //安全门状态进入! F% O7 b+ p$ h* J, }
if (bit_istrue(sys.suspend,SUSPEND_ENABLE_READY)) {
9 v$ @$ G) R5 ~* t. Z @: Wif (!(system_check_safety_door_ajar())) {- E& H/ O8 s5 [
sys.state = STATE_HOLD; // Update to HOLD state to indicate door is closed and ready to resume. 更新保存状态指示门关闭,准备简历。. k$ L0 }8 [4 o( N
}
& B3 L: F5 j5 Q$ {7 a: w; T}
# c5 n3 \; h4 {6 ^( P% Y. n* |# V}3 E, @" C# l1 ?0 L \2 x' }

i. k/ ^- [& M} while(sys.suspend); // Check for system suspend state before exiting.3 u7 k' W; D6 g7 Q, c6 W
* j8 a. [9 \" }7 h5 h& Z0 @3 d3 ~
}
10#
发表于 2016-8-25 09:31:12 | 只看该作者
楼主这些代码。是网上搜来,然后自己组合的吗?全是自己想的,那是牛逼了

点评

外国的开源软件grbl,在研究它,将打注释了下而已,研究透彻了好移植的其他平台应用,学习阶段。 https://github.com/grbl/grbl 详情 回复 发表于 2016-8-25 22:19
您需要登录后才可以回帖 登录| 注册会员

本版积分规则

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

GMT+8, 2024-5-12 09:23, Processed in 0.084125 second(s), 24 queries , Gzip On.

Powered byDiscuz!X3.4Licensed

? 2001-2017Comsenz Inc.

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