单片机MCP制作数控雕刻机3D打印机
本帖最后由 1五湖四海1 于 2016-8-21 00:09 编辑以前制作过CNC雕刻机,是用MACH3作为上位机控制,硬件是采用PC接并口输出脉冲和方向使能信号经过隔离驱动步进电机驱动器,步进电机驱动是采用TB6560芯片控制。最后就接到步进电机。机械是用铝合金制作,主要部件有三个1605的滚珠丝杠,多个运动滑块等制作。用这台DIY CNC雕刻机可以雕刻木头塑料等东西。当时没有一直玩下去,现在发现网上有用单片机制作的雕刻机挺精巧的现在分享给大家。
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个运动来规划运行速度,以实现平稳的加速和无冲击的转弯。很棒吧!开始玩起。//www.szfco.com/data/attachment/album/201608/20/235410rbrm9p0lvbm1ccbg.png
还没有雕刻机的机械部分可以用废旧光驱制作个微型雕刻机运动平台。雕刻机最重要的是主控程序这次用 Arduino/AVR328单片机,价格在15元左右,主控程序是上面提到的目前很火的开源的GRBL,还有一种基于STM32平台的开源主控程序Dlion也不错可以替代grbl。如果从性能比较这两个方案,显然是stm32平台运行速度更快毕竟他是32单片机呀!
下面介绍小这个些主控程序主要干的事,通过串口PC和主控板通讯,PC命令给控制板,控制板接收命令做不同的响应,PC可以发G代码给主控板,接收完成后可以自动开始雕刻任务。
在介绍下G代码因为G代码是雕刻机的核心部分
G代码是数控程序中的指令。一般都称为G指令。
G00------快速定位
G01------直线插补
G02------顺时针方向圆弧插补
G03------逆时针方向圆弧插补
G04------定时暂停
G05------通过中间点圆弧插补
G06------抛物线插补
G07------Z 样条曲线插补
G08------进给加速
G09------进给减速
G10------数据设置
G16------极坐标编程
G17------加工XY平面
G18------加工XZ平面
G19------加工YZ平面
核心就是解析G代码,完成步进电机驱动,和控制主轴开启关闭,还有插补算法,直线插补,圆弧插补,还有一些步进电机的加减速算法。
下面对grbl主结构做介绍
main()主函数首先执行下面初始化函数
serial_init(); // 设置串口波特率和中断
settings_init(); // 从ROM加载grbl设置
stepper_init(); // 配置步进方向和中断定时器
system_init(); // 配置引脚分配别针和pin-change中断
memset(&sys, 0, sizeof(system_t)); // 清除所有系统变量
sys.abort = true; // 中止标识位置位
sei(); // 使能中断
#ifdef HOMING_INIT_LOCK // 宏运算(settings.flags & (1 << 4)) != 0结果flags等于执行sys.state = STATE_ALARM
// 系统状态赋值为报警状态
if (bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE)) { sys.state = STATE_ALARM; }
#endif
_____________________________________________________________________________________________________________________________________
接下来是一些主要部分初始化
for(;;) {
serial_reset_read_buffer(); //清除串口读缓冲区
gc_init(); //初始化G代码功能函数
spindle_init(); //主轴初始化
coolant_init(); //冷却液初始化
limits_init(); //极限开关初始化
probe_init(); //探测部件初始化
plan_reset(); //清除块缓冲区和规划师变量
st_reset(); //清除步进系统变量。
//下面两行清除同步gcode和策划师职位当前系统位置。
plan_sync_position();
gc_sync_position();
//复位系统变量
sys.abort = false; //系统中止标志
sys_rt_exec_state = 0; //系统标志位变量状态管理。看到EXEC位掩码。
sys_rt_exec_alarm = 0; //系统标志位变量设置不同的警报。
sys.suspend = false; //系统暂停标志位变量管理,取消,和安全保护。
sys.soft_limit = false; //限位开关限制状态机错误。(布尔)
protocol_main_loop(); //主协议循环
} //
_____________________________________________________________________________________________________________________________
进入void protocol_main_loop()函数
{
report_init_message(); // 打印欢迎信息
//重启后检验和报告报警状态如果错误重启初始化。
if (sys.state == STATE_ALARM) {
report_feedback_message(MESSAGE_ALARM_LOCK); //打印信息
} else {
// 如果没有报警说明一切正常!但还是要检查安全门.
if (system_check_safety_door_ajar()) {
bit_true(sys_rt_exec_state, EXEC_SAFETY_DOOR);
protocol_execute_realtime(); // 进入安全模式。应该返回空闲状态。
} else {
sys.state = STATE_IDLE; // .设置系统做好准备。清除所有国家国旗。
}
system_execute_startup(line); //开始执行系统脚本
}
// 这是主循环!在系统中止时这是出口回到主函数来重置系统。
// ---------------------------------------------------------------------------------
uint8_t comment = COMMENT_NONE;
uint8_t char_counter = 0;
uint8_t c;
_______________________________________________________________________________________________________________________________
接下来进入for(;;)循环 //下面代码是G代码解析核心部分,程序中comment(注释)变量会被赋不同值,代表发符号有‘(’‘)’‘;’
{
//串行数据输入一行的的过程,作为数据。执行一个
//所有数据初始过滤去除空格和注释。
//注意:注释,空格和程序段删除(如果支持的话)处理技术
//在G代码解析器,它有助于压缩到Grbl传入的数据
//线缓冲区,这是有限的。刀位点标准实际上州一行不行
//不能超过256个字符,Arduino Uno没有更多内存空间。
//有更好的处理器,它会很容易把这个初步解析的
//分离任务共享的刀位点解析器和Grbl系统命令。
while((c = serial_read()) != SERIAL_NO_DATA) { //读取串口数据,有数据执行下面代码
if ((c == '\n') || (c == '\r')) { // End of line reached //如果数据是/r,/n代表一行结束
line = 0; // Set string termination character. //设置结束标志
protocol_execute_line(line); // Line is complete. Execute it! //一行完成执行此函数
comment = COMMENT_NONE; //注释清零
char_counter = 0; //字符计数清零
else {
if (comment != COMMENT_NONE) {
//扔掉所有注释字符
if (c == ')') {
//最后注释。重新开始。但是如果有分号类型的注释。
if (comment == COMMENT_TYPE_PARENTHESES) { comment = COMMENT_NONE; }
}
} else {
if (c <= ' ') {
//扔掉whitepace和控制字符
} else if (c == '/') {
//块删除不支持将忽略字符。
//注意:如果支持,只需要检查系统是否启用了块删除。
} else if (c == '(') {
// Enable comments flag and ignore all characters until ')' or EOL.
// NOTE: This doesn't follow the NIST definition exactly, but is good enough for now.
// In the future, we could simply remove the items within the comments, but retain the
// comment control characters, so that the g-code parser can error-check it.
comment = COMMENT_TYPE_PARENTHESES;
} else if (c == ';') {
//注意:','注释EOL LinuxCNC定义。没有国家标准。
comment = COMMENT_TYPE_SEMICOLON;
_____________________________________________________________________________________________________________________________________
} else if (char_counter >= (LINE_BUFFER_SIZE-1)) { //串口接收数据大于80字符时
// Detect line buffer overflow. Report error and reset line buffer. 检测缓冲区溢出。报告错误和复位线缓冲区。
report_status_message(STATUS_OVERFLOW); //打印溢出信息
comment = COMMENT_NONE;
char_counter = 0;
} else if (c >= 'a' && c <= 'z') { // Upcase lowercase //小写改大写
line = c-'a'+'A';
} else {
line = c;
}
}
}
}
____________________________________________________________________________________________________________________________________
//如果没有其他字符在串行处理读取缓冲区和执行,这表明以完成,自动启动,如果启用,任何队列动作。
protocol_auto_cycle_start(); //自动开始协议循环
protocol_execute_realtime(); //运行实时命令。
if (sys.abort) { return; } //中止标识置位程序循环重置系统。
}
return; //一般程序不会执行到这里
}
____________________________________________________________________________________________________________________________________
正常情况下,读取完G代码程序会进入protocol_auto_cycle_start();//自动开始协议循环 函数下面介绍此函数
// Auto-cycle start has two purposes: 1. Resumes a plan_synchronize() call from a function that
// requires the planner buffer to empty (spindle enable, dwell, etc.) 2. As a user setting that
// automatically begins the cycle when a user enters a valid motion command manually. This is
// intended as a beginners feature to help new users to understand g-code. It can be disabled
// as a beginner tool, but (1.) still operates. If disabled, the operation of cycle start is
// manually issuing a cycle start command whenever the user is ready and there is a valid motion
// command in the planner queue.
// NOTE: This function is called from the main loop, buffer sync, and mc_line() only and executes
// when one of these conditions exist respectively: There are no more blocks sent (i.e. streaming
// is finished, single commands), a command that needs to wait for the motions in the buffer to
// execute calls a buffer sync, or the planner buffer is full and ready to go.
//自动开始有两个目的:1。回复一个plan_synchronize()调用的函数
//需要规划师缓冲区空(主轴启用、住等)2。作为一个用户设置
//自动循环开始当一个用户输入一个有效的运动命令手动。这是
//作为一个初学者的特性来帮助新用户了解刀位点。它可以被禁用
//作为一个初学者工具,但(1)仍然运作。如果禁用,运行周期开始
//手动发出一个周期开始命令每当用户准备好,有一个有效的运动
//命令的规划师队列。
//注意:这个函数被称为从主循环缓冲区同步,mc_line只()并执行
//当其中一个条件分别存在:没有更多的块(即流发送
//完成后,单一的命令),一个命令,需要等待缓冲的动作
//执行调用一个缓冲区同步,或规划师缓冲区满了,准备好了。
void protocol_auto_cycle_start() { bit_true_atomic(sys_rt_exec_state, EXEC_CYCLE_START); }
_______________________________________________________________________________________________
接下来程序运行protocol_execute_realtime(); /运行实时命令。
// Executes run-time commands, when required. This is called from various check points in the main
// program, primarily where there may be a while loop waiting for a buffer to clear space or any
// point where the execution time from the last check point may be more than a fraction of a second.
// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code
// parsing and planning functions. This function also serves as an interface for the interrupts to
// set the system realtime flags, where only the main program handles them, removing the need to
// define more computationally-expensive volatile variables. This also provides a controlled way to
// execute certain tasks without having two or more instances of the same task, such as the planner
// recalculating the buffer upon a feedhold or override.
// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,
// limit switches, or the main program.
void protocol_execute_realtime()
uint8_t rt_exec; // Temp variable to avoid calling volatile multiple times.临时变量来避免多次调用不稳定。
就先分享到这吧!
补充内容 (2016-8-25 22:40):
配置说明
//这个文件包含编译时配置Grbl的内部系统。在大多数情况下,
//用户不需要直接修改这些,但是他们在这里为特定的需求,即。
//性能调优或适应非典型的机器。
主要配置项:
1.#define DEFAULTS_GENERIC //在重置eepm时使用。在defaults.h改变想要的名字
2.#define BAUD_RATE 115200 //配置串口波特率115200
3.#define CPU_MAP_ATMEGA328P // Arduino Uno CPU
4.#define CMD_STATUS_REPORT '?' //定义实时命令特殊字符
5.#define HOMING_INIT_LOCK //回原点保护锁
6.#define HOMING_CYCLE_0 (1<<Z_AXIS) // 第一步Z清除工作区。
#define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))// 然后X,Y在同一时间。
7.#define N_HOMING_LOCATE_CYCLE 1 //回原点循环次数
8.#define HOMING_FORCE_SET_ORIGIN //取消这定义迫使Grbl总是在这时候位置设置机器原点尽管开关方向。
9.#define N_STARTUP_LINE 2 //块Grbl启动时执行的数量。
10.#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 协调或位置价值英寸
#define N_DECIMAL_COORDVALUE_MM 3 // Coordinate or position value in mm 协调在毫米或位置价值
#define N_DECIMAL_RATEVALUE_INCH1 // Rate or velocity value in in/min 率或/分钟的速度值
#define N_DECIMAL_RATEVALUE_MM 0 // Rate or velocity value in mm/min 速率或速度值在毫米/分钟
#define N_DECIMAL_SETTINGVALUE 3 // Decimals for floating point setting values 对浮点小数设置值
11.#define LIMITS_TWO_SWITCHES_ON_AXES //如果你的机器有两个极限开关连接在平行于一个轴,您需要启用这个特性
12.#define USE_LINE_NUMBERS //允许GRBL跟踪和报告gcode行号
13.#define REPORT_REALTIME_RATE //允许GRBL报告实时进给速率
14.#define MESSAGE_PROBE_COORDINATES//坐标通过Grbl $ #的打印参数?
15.#define SAFETY_DOOR_SPINDLE_DELAY 4000 //安全门主轴延时
16.#define SAFETY_DOOR_COOLANT_DELAY 1000 //安全门冷却液延时
17.#define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS) //启用CoreXY运动学。
18.#define COREXY // Default disabled. Uncomment to enable.改变X和Y轴的运动原理
19.#define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.反转针销逻辑的控制命令
20.#define INVERT_SPINDLE_ENABLE_PIN // 反转主轴使销从low-disabled
21.#define REPORT_CONTROL_PIN_STATE //启用控制销状态反馈状态报告。
22.#define FORCE_INITIALIZATION_ALARM //启用和用户安装限位开关,Grbl将启动报警状态指示
23.#define REPORT_GUI_MODE // gui允许最小的报告反馈模式
24.#define ACCELERATION_TICKS_PER_SECOND 100 //加速度的时间分辨率管理子系统。
25.#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING //自适应多轴步平滑(积累)是一种先进的功能
26.#define MAX_STEP_RATE_HZ 30000 //设置最大一步速率可以写成Grbl设置
27.#define DISABLE_LIMIT_PIN_PULL_UP //以下选项禁用内部上拉电阻
28.#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS //设置哪个轴长度补偿应用的工具。假设轴总是与选择轴工具面向负方向
29.#define VARIABLE_SPINDLE //允许变量轴输出电压不同的转速值。
30.#define SPINDLE_MAX_RPM 1000.0// Max spindle RPM. This value is equal to 100% duty cycle on the PWM.
#define SPINDLE_MIN_RPM 0.0 // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.
31.#define MINIMUM_SPINDLE_PWM 5 //使用的变量轴输出。这迫使PWM输出最小占空比时启用。
32.#define USE_SPINDLE_DIR_AS_ENABLE_PIN //主轴方向使能M4被删除
33.#define REPORT_ECHO_LINE_RECEIVED //应该对所有正常线路送到Grbl
34.#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min) //最小规划师结速度。设置默认最小连接速度规划计划
35.#define MINIMUM_FEED_RATE 1.0 // (mm/min)//设置计划将允许的最小进给速率
36.#define N_ARC_CORRECTION 12 //弧生成迭代次数之前小角度近似精确的弧线轨迹
37.#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)//定义值设置机器ε截止来确定电弧是一个原点了?
38.#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds) //延时增加表现在住。默认值设置为50毫秒
39.#define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.
40.#define BLOCK_BUFFER_SIZE 18//线性运动规划师缓冲区的数量在任何给出时间计划
41.#define SEGMENT_BUFFER_SIZE 6 //控制之间的中间段缓冲大小的步骤执行算法
42.#define LINE_BUFFER_SIZE 80 //行执行串行输入流的缓冲区大小。
43.define RX_BUFFER_SIZE 128 //串行发送和接收缓冲区大小
44.#define TX_BUFFER_SIZE 64
45.#define ENABLE_XONXOFF ////切换为串行通信发送流软件流控制。
46.#define ENABLE_SOFTWARE_DEBOUNCE //一个简单的软件消除抖动特性硬限位开关。
47.#define HARD_LIMIT_FORCE_STATE_CHECK //Grbl检查硬限位开关的状态
48.// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:编译时错误检查的定义值:
___________________________________________________________________________________________________
/*
config.h - compile time configuration
Part of Grbl
Copyright (c) 2012-2015 Sungeun K. Jeon
Copyright (c) 2009-2011 Simen Svale Skogsrud
Grbl is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Grbl is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Grbl.If not, see <http://www.gnu.org/licenses/>.
config.h-编译时配置,Grbl的一部分
版权(c)2012 - 2015 Sungeun K. Jeon
版权(c)2009 - 2011 Simen Svale Skogsrud
Grbl是免费软件:可以重新分配和/或修改
GNU通用公共许可证的条款下发布的自由软件基金会,版本3的许可,或(任您选)其后的版本。
Grbl分布,希望这将是有用的,但是没有任何保证;没有即使的默示保证适销性或健身为特定目的。看到
GNU通用公共许可证的更多细节。
你应该收到了GNU通用公共许可证的副本
连同Grbl。如果没有,看< http://www.gnu.org/licenses/ >。
*/
// This file contains compile-time configurations for Grbl's internal system. For the most part,
// users will not need to directly modify these, but they are here for specific needs, i.e.
// performance tuning or adjusting to non-typical machines.
//这个文件包含编译时配置Grbl的内部系统。在大多数情况下,
//用户不需要直接修改这些,但是他们在这里为特定的需求,即。
//性能调优或适应非典型的机器。
// IMPORTANT: Any changes here requires a full re-compiling of the source code to propagate them.
//重要:任何变化需要一个完整的基于源代码的传播。
#ifndef config_h
#define config_h
#include "grbl.h" // For Arduino IDE compatibility.
// Default settings. Used when resetting EEPROM. Change to desired name in defaults.h
// 默认设置。在重置eepm时使用。在defaults.h改变想要的名字
#define DEFAULTS_GENERIC
// Serial baud rate
#define BAUD_RATE 115200 //配置串口波特率115200
// Default cpu mappings. Grbl officially supports the Arduino Uno only. Other processor types
// may exist from user-supplied templates or directly user-defined in cpu_map.h
//默认cpu映射。Grbl正式支持Arduino Uno。其他类型的处理器可能存在cpu_map.h直接从用户提供的模板或用户定义的
#define CPU_MAP_ATMEGA328P // Arduino Uno CPU
// Define realtime command special characters. These characters are 'picked-off' directly from the
// serial read data stream and are not passed to the grbl line execution parser. Select characters
// that do not and must not exist in the streamed g-code program. ASCII control characters may be
// used, if they are available per user setup. Also, extended ASCII codes (>127), which are never in
// g-code programs, maybe selected for interface programs.
// NOTE: If changed, manually update help message in report.c.
//定义实时命令特殊字符。这些字符是直接从“各个击破”串口读取数据流并没有传递到grbl行执行解析器。选择角色
//不,不能存在于程序流刀位点。ASCII控制字符
//使用,如果他们是可用的每个用户设置。同时,扩展的ASCII码(> 127),从来没有
//刀位点的程序,也许选择界面程序。
//注意:如果改变,手动更新report.c帮助信息。
#define CMD_STATUS_REPORT '?'
#define CMD_FEED_HOLD '!'
#define CMD_CYCLE_START '~'
#define CMD_RESET 0x18 // ctrl-x.
#define CMD_SAFETY_DOOR '@'
// If homing is enabled, homing init lock sets Grbl into an alarm state upon power up. This forces
// the user to perform the homing cycle (or override the locks) before doing anything else. This is
// mainly a safety feature to remind the user to home, since position is unknown to Grbl.
//如果启用了回原点,导航初始化锁集Grbl进入警报状态启动。这就迫使
//用户执行归航周期(或覆盖锁)在做任何其他事情之前。这是
//主要安全功能,提醒用户家里,因为Grbl位置是未知的。
#define HOMING_INIT_LOCK // Comment to disable
// Define the homing cycle patterns with bitmasks. The homing cycle first performs a search mode
// to quickly engage the limit switches, followed by a slower locate mode, and finished by a short
// pull-off motion to disengage the limit switches. The following HOMING_CYCLE_x defines are executed
// in order starting with suffix 0 and completes the homing routine for the specified-axes only. If
// an axis is omitted from the defines, it will not home, nor will the system update its position.
// Meaning that this allows for users with non-standard cartesian machines, such as a lathe (x then z,
// with no y), to configure the homing cycle behavior to their needs.
// NOTE: The homing cycle is designed to allow sharing of limit pins, if the axes are not in the same
// cycle, but this requires some pin settings changes in cpu_map.h file. For example, the default homing
// cycle can share the Z limit pin with either X or Y limit pins, since they are on different cycles.
// By sharing a pin, this frees up a precious IO pin for other purposes. In theory, all axes limit pins
// may be reduced to one pin, if all axes are homed with seperate cycles, or vice versa, all three axes
// on separate pin, but homed in one cycle. Also, it should be noted that the function of hard limits
// will not be affected by pin sharing.
//定义导航循环模式的位掩码。归航周期首先执行一个搜索模式
//快速进行限位开关,其次是较慢的定位模式,完成了由一个短
//拖出运动脱离限位开关。以下HOMING_CYCLE_x定义执行
//为了与后缀0开始并完成specified-axes只寻的例程。如果
//定义省略一个轴,它会不在家,也不会系统更新它的位置。
//意义,这允许用户与非标准笛卡尔的机器,比如车床(x,z,
//没有y),配置导航循环行为对他们的需求。
//注意:归航周期允许共享限制针,如果轴不相同
//循环,但这需要一些销设置cpu_map的变化。h文件。例如,默认的导航
//循环可以分享Z限位销X或Y限制针,因为它们是在不同的周期。
//通过共享一个销,这腾出宝贵的IO销用于其他目的。从理论上讲,所有轴限制别针
//可能会减少到一个销,如果所有轴与分离周期居住的地方,反之亦然,所有三个轴
//在不同销,但这时候一个周期。同时,应该注意的是,硬限制的功能
//将不会影响销共享。
//注意:默认设置为一个传统的硬件数控机器。z轴首次明确,其次是X和Y。
// NOTE: Defaults are set for a traditional 3-axis CNC machine. Z-axis first to clear, followed by X & Y.
#define HOMING_CYCLE_0 (1<<Z_AXIS) // REQUIRED: First move Z to clear workspace. 第一步Z清除工作区。
#define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))// OPTIONAL: Then move X,Y at the same time.然后X,Y在同一时间。
// #define HOMING_CYCLE_2 // OPTIONAL: Uncomment and add axes mask to enable
// Number of homing cycles performed after when the machine initially jogs to limit switches.
// This help in preventing overshoot and should improve repeatability. This value should be one or
// greater.
//执行回原点循环次数后,当机器最初慢跑限位开关。这个帮助防止过度,应该提高重复性。这个值应该是一个或大。
#define N_HOMING_LOCATE_CYCLE 1 // Integer (1-128)
// After homing, Grbl will set by default the entire machine space into negative space, as is typical
// for professional CNC machines, regardless of where the limit switches are located. Uncomment this
// define to force Grbl to always set the machine origin at the homed location despite switch orientation.
//导航后,默认Grbl将整个机器空间留白,是典型的专业数控机器,不管限位开关所在的地方。
//取消这定义迫使Grbl总是在这时候位置设置机器原点尽管开关方向。
// #define HOMING_FORCE_SET_ORIGIN // Uncomment to enable.
// Number of blocks Grbl executes upon startup. These blocks are stored in EEPROM, where the size
// and addresses are defined in settings.h. With the current settings, up to 2 startup blocks may
// be stored and executed in order. These startup blocks would typically be used to set the g-code
// parser state depending on user preferences.
//块Grbl启动时执行的数量。这些块存储在eepm,大小
//和地址在settings.h中定义。与当前设置,可能2启动块
//存储和执行。这些启动块通常被用来设置刀位点
//解析器的状态取决于用户首选项。
#define N_STARTUP_LINE 2 // Integer (1-2)
// Number of floating decimal points printed by Grbl for certain value types. These settings are
// determined by realistic and commonly observed values in CNC machines. For example, position
// values cannot be less than 0.001mm or 0.0001in, because machines can not be physically more
// precise this. So, there is likely no need to change these, but you can if you need to here.
// NOTE: Must be an integer value from 0 to ~4. More than 4 may exhibit round-off errors.
// Grbl浮动小数点的数字印刷的特定的值类型。这些设置是
//一般由现实和观测值在数控机器。例如,位置
//值不能小于0.001毫米或0.0001,因为机器不能身体更多
//精确。因此,有可能不需要改变这些,但你可以在这里如果你需要。
//注意:必须是一个整数值从0 ~ 4。超过4可能出现舍入错误。
#define N_DECIMAL_COORDVALUE_INCH 4 // Coordinate or position value in inches 协调或位置价值英寸
#define N_DECIMAL_COORDVALUE_MM 3 // Coordinate or position value in mm 协调在毫米或位置价值
#define N_DECIMAL_RATEVALUE_INCH1 // Rate or velocity value in in/min 率或/分钟的速度值
#define N_DECIMAL_RATEVALUE_MM 0 // Rate or velocity value in mm/min 速率或速度值在毫米/分钟
#define N_DECIMAL_SETTINGVALUE 3 // Decimals for floating point setting values 对浮点小数设置值
// If your machine has two limits switches wired in parallel to one axis, you will need to enable
// this feature. Since the two switches are sharing a single pin, there is no way for Grbl to tell
// which one is enabled. This option only effects homing, where if a limit is engaged, Grbl will
// alarm out and force the user to manually disengage the limit switch. Otherwise, if you have one
// limit switch for each axis, don't enable this option. By keeping it disabled, you can perform a
// homing cycle while on the limit switch and not have to move the machine off of it.
//如果你的机器有两个极限开关连接在平行于一个轴,您需要启用
//这个特性。自从两个交换机共享一个销,没有办法Grbl告诉
//启用哪一个。此选项仅影响归航,如果限制,Grbl意志
//报警,迫使用户手动松开限位开关。否则,如果你有一个
//为每个轴限位开关,不启用该选项。通过保持禁用,您可以执行
//导航循环在限位开关并没有将这台机器。
// #define LIMITS_TWO_SWITCHES_ON_AXES
// Allows GRBL to track and report gcode line numbers.Enabling this means that the planning buffer
// goes from 18 or 16 to make room for the additional line number data in the plan_block_t struct
//允许GRBL跟踪和报告gcode行号。使这意味着计划缓冲从18岁或16岁,为额外的行号plan_block_t结构中的数据
// #define USE_LINE_NUMBERS // Disabled by default. Uncomment to enable.
// Allows GRBL to report the real-time feed rate.Enabling this means that GRBL will be reporting more
// data with each status update.
// NOTE: This is experimental and doesn't quite work 100%. Maybe fixed or refactored later.
//允许GRBL报告实时进给速率。使这意味着GRBL将报告数据和状态更新。
//注意:这是实验和100%没有工作。也许以后固定或重构。
// #define REPORT_REALTIME_RATE // Disabled by default. Uncomment to enable.
// Upon a successful probe cycle, this option provides immediately feedback of the probe coordinates
// through an automatically generated message. If disabled, users can still access the last probe
// coordinates through Grbl '$#' print parameters.
//在一个成功的调查周期,这个选项提供立即反馈的探测器坐标
//通过一个自动生成的消息。如果禁用,用户仍然能够访问调查
//坐标通过Grbl $ #的打印参数。
#define MESSAGE_PROBE_COORDINATES // Enabled by default. Comment to disable.
// Enables a second coolant control pin via the mist coolant g-code command M7 on the Arduino Uno
// analog pin 5. Only use this option if you require a second coolant control pin.
// NOTE: The M8 flood coolant control pin on analog pin 4 will still be functional regardless.
// #define ENABLE_M7 // Disabled by default. Uncomment to enable.
// This option causes the feed hold input to act as a safety door switch. A safety door, when triggered,
// immediately forces a feed hold and then safely de-energizes the machine. Resuming is blocked until
// the safety door is re-engaged. When it is, Grbl will re-energize the machine and then resume on the
// previous tool path, as if nothing happened.
// #define ENABLE_SAFETY_DOOR_INPUT_PIN // Default disabled. Uncomment to enable.
// After the safety door switch has been toggled and restored, this setting sets the power-up delay
// between restoring the spindle and coolant and resuming the cycle.
// NOTE: Delay value is defined in milliseconds from zero to 65,535.
//定义导航循环模式的位掩码。归航周期首先执行一个搜索模式
//快速进行限位开关,其次是较慢的定位模式,完成了由一个短
//拖出运动脱离限位开关。以下HOMING_CYCLE_x定义执行
//为了与后缀0开始并完成specified-axes只寻的例程。如果
//定义省略一个轴,它会不在家,也不会系统更新它的位置。
//意义,这允许用户与非标准笛卡尔的机器,比如车床(x,z,
//没有y),配置导航循环行为对他们的需求。
//注意:归航周期允许共享限制针,如果轴不相同
//循环,但这需要一些销设置cpu_map的变化。h文件。例如,默认的导航
//循环可以分享Z限位销X或Y限制针,因为它们是在不同的周期。
//通过共享一个销,这腾出宝贵的IO销用于其他目的。从理论上讲,所有轴限制别针
//可能会减少到一个销,如果所有轴与分离周期居住的地方,反之亦然,所有三个轴
//在不同销,但这时候一个周期。同时,应该注意的是,硬限制的功能
//将不会影响销共享。
//注意:默认设置为一个传统的硬件数控机器。z轴首次明确,其次是X和Y。
#define SAFETY_DOOR_SPINDLE_DELAY 4000
#define SAFETY_DOOR_COOLANT_DELAY 1000
// Enable CoreXY kinematics. Use ONLY with CoreXY machines.
// IMPORTANT: If homing is enabled, you must reconfigure the homing cycle #defines above to
//启用CoreXY运动学。只使用与CoreXY机器。
//重要:如果启用了自动寻的,你必须重新配置导航循环#定义上面
// #define HOMING_CYCLE_0 (1<<X_AXIS) and #define HOMING_CYCLE_1 (1<<Y_AXIS)
// NOTE: This configuration option alters the motion of the X and Y axes to principle of operation
// defined at (http://corexy.com/theory.html). Motors are assumed to positioned and wired exactly as
// described, if not, motions may move in strange directions. Grbl assumes the CoreXY A and B motors
// have the same steps per mm internally.
//注意:这种配置选项改变X和Y轴的运动原理,操作
//定义(http://corexy.com/theory.html)。汽车被认为定位和连接一样
//描述,如果没有,运动可能会奇怪的方向移动。A和B Grbl假设CoreXY马达
//每毫米内部有相同的步骤。
// #define COREXY // Default disabled. Uncomment to enable.
// Inverts pin logic of the control command pins. This essentially means when this option is enabled
// you can use normally-closed switches, rather than the default normally-open switches.
// NOTE: Will eventually be added to Grbl settings in v1.0.
//反转针销逻辑的控制命令。这实质上意味着当启用这个选项
//可以使用闭合开关,而不是默认的常开开关。
//注意:最终将被添加到在v1.0 Grbl设置。
// #define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.
// Inverts the spindle enable pin from low-disabled/high-enabled to low-enabled/high-disabled. Useful
// for some pre-built electronic boards.
// NOTE: If VARIABLE_SPINDLE is enabled(default), this option has no effect as the PWM output and
// spindle enable are combined to one pin. If you need both this option and spindle speed PWM,
// uncomment the config option USE_SPINDLE_DIR_AS_ENABLE_PIN below.
//反转主轴使销从low-disabled / high-enabled low-enabled / high-disabled。有用的
//预构建的电子板。
//注意:如果启用了VARIABLE_SPINDLE(默认),这个选项作为PWM输出并没有影响
//销轴使结合。如果你需要这个选项和主轴转速PWM,
//取消注释以下配置选项USE_SPINDLE_DIR_AS_ENABLE_PIN
// #define INVERT_SPINDLE_ENABLE_PIN // Default disabled. Uncomment to enable.
// Enable control pin states feedback in status reports. The data is presented as simple binary of
// the control pin port (0 (low) or 1(high)), masked to show only the input pins. Non-control pins on the
// port will always show a 0 value. See cpu_map.h for the pin bitmap. As with the limit pin reporting,
// we do not recommend keeping this option enabled. Try to only use this for setting up a new CNC.
//启用控制销状态反馈状态报告。作为简单的二进制数据
//控制针端口(0(低)或1(高)),蒙面,只显示输入插脚。非控制性针上
//端口总是显示0值。看到cpu_map。针位图h。与限制销报告,
//我们不推荐保持启用这个选项。尽量只使用这个设置一个新的数控。
// #define REPORT_CONTROL_PIN_STATE // Default disabled. Uncomment to enable.
// When Grbl powers-cycles or is hard reset with the Arduino reset button, Grbl boots up with no ALARM
// by default. This is to make it as simple as possible for new users to start using Grbl. When homing
// is enabled and a user has installed limit switches, Grbl will boot up in an ALARM state to indicate
// Grbl doesn't know its position and to force the user to home before proceeding. This option forces
// Grbl to always initialize into an ALARM state regardless of homing or not. This option is more for
// OEMs and LinuxCNC users that would like this power-cycle behavior.
//当Grbl powers-cycles还是硬重置Arduino复位按钮,Grbl启动没有报警
//默认情况下。这是为了让新用户尽可能简单使用Grbl开始。当归航
//启用和用户安装限位开关,Grbl将启动报警状态指示
// Grbl不知道它的位置,迫使用户在继续之前回家。这个选项部队
// Grbl总是初始化进入警报状态不管归航。这个选项是更多
//原始设备制造商和LinuxCNC用户这样的控制行为。
// #define FORCE_INITIALIZATION_ALARM // Default disabled. Uncomment to enable.
// ---------------------------------------------------------------------------------------
// ADVANCED CONFIGURATION OPTIONS://高级配置选项:
// Enables minimal reporting feedback mode for GUIs, where human-readable strings are not as important.
// This saves nearly 2KB of flash space and may allow enough space to install other/future features.
// GUIs will need to install a look-up table for the error-codes that Grbl sends back in their place.
// NOTE: This feature is new and experimental. Make sure the GUI you are using supports this mode.
// gui允许最小的报告反馈模式,人类可读的字符串在哪里不重要。
//这个节省近2 kb的闪存空间,允许足够的空间来安装其他/未来的功能。
// gui需要安装一个查找表的错误代码Grbl发回。
//注意:此功能是新的和实验。确保您使用的GUI支持这种模式。
// #define REPORT_GUI_MODE // Default disabled. Uncomment to enable.
// The temporal resolution of the acceleration management subsystem. A higher number gives smoother
// acceleration, particularly noticeable on machines that run at very high feedrates, but may negatively
// impact performance. The correct value for this parameter is machine dependent, so it's advised to
// set this only as high as needed. Approximate successful values can widely range from 50 to 200 or more.
// NOTE: Changing this value also changes the execution time of a segment in the step segment buffer.
// When increasing this value, this stores less overall time in the segment buffer and vice versa. Make
// certain the step segment buffer is increased/decreased to account for these changes.
//加速度的时间分辨率管理子系统。更多更平稳
//加速度,特别明显的机器上,运行在非常高的进料速度,但可能负面
//影响性能。正确的值为这个参数是依赖于机器的,所以建议
//这只设置为高。近似成功的价值观可以广泛的范围从50到200或者更多。
//注意:改变这个值也变化的部分步骤的执行时间缓冲。
//增加这个值时,这个商店部分缓冲区的总时间减少,反之亦然。使
//特定步骤段缓冲是考虑这些变化增加/减少。
#define ACCELERATION_TICKS_PER_SECOND 100//加速度的时间分辨率管理子系统。更多更平稳
// Adaptive Multi-Axis Step Smoothing (AMASS) is an advanced feature that does what its name implies,
// smoothing the stepping of multi-axis motions. This feature smooths motion particularly at low step
// frequencies below 10kHz, where the aliasing between axes of multi-axis motions can cause audible
// noise and shake your machine. At even lower step frequencies, AMASS adapts and provides even better
// step smoothing. See stepper.c for more details on the AMASS system works.
//自适应多轴步平滑(积累)是一种先进的功能,它的名字所暗示的那样,
//平滑的多轴步进运动。这个特性平滑运动尤其是在低一步
//频率低于10 khz,轴之间的混叠的多轴运动可能导致音响
//噪音和震动你的机器。在更低的频率步,积累适应并提供更好
//步骤平滑。看到步进。c更多细节的积累系统的工作原理。
#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING// Default enabled. Comment to disable.//自适应多轴步平滑
// Sets the maximum step rate allowed to be written as a Grbl setting. This option enables an error
// check in the settings module to prevent settings values that will exceed this limitation. The maximum
// step rate is strictly limited by the CPU speed and will change if something other than an AVR running
// at 16MHz is used.
// NOTE: For now disabled, will enable if flash space permits.
//设置最大一步速率可以写成Grbl设置。这个选项可以使一个错误
//设置模块中检查,防止设置值将超过这个限制。的最大
//步骤严格限制的CPU速度也会改变如果是其他AVR运行
//使用16兆赫。
//注意:现在残疾,将使如果flash空间许可。
// #define MAX_STEP_RATE_HZ 30000 // Hz 设置最大一步速率
// By default, Grbl sets all input pins to normal-high operation with their internal pull-up resistors
// enabled. This simplifies the wiring for users by requiring only a switch connected to ground,
// although its recommended that users take the extra step of wiring in low-pass filter to reduce
// electrical noise detected by the pin. If the user inverts the pin in Grbl settings, this just flips
// which high or low reading indicates an active signal. In normal operation, this means the user
// needs to connect a normal-open switch, but if inverted, this means the user should connect a
// normal-closed switch.
// The following options disable the internal pull-up resistors, sets the pins to a normal-low
// operation, and switches must be now connect to Vcc instead of ground. This also flips the meaning
// of the invert pin Grbl setting, where an inverted setting now means the user should connect a
// normal-open switch and vice versa.
// NOTE: All pins associated with the feature are disabled, i.e. XYZ limit pins, not individual axes.
// WARNING: When the pull-ups are disabled, this requires additional wiring with pull-down resistors!
//默认情况下,Grbl所有输入引脚设置为正常高操作的内部上拉电阻
//启用。这简化了布线为用户只需要一个开关连接到地面,
//虽然其建议用户采取额外的步骤,在低通滤波器来减少布线
//电噪音检测销。如果用户反转的销Grbl设置,这只是翻转
//读高或低表明一个积极的信号。在正常操作中,这意味着用户
//需要连接一个常开开关,但如果倒,这意味着用户应该连接
// normal-closed开关。
//以下选项禁用内部上拉电阻,一般低设置别针
//操作,现在开关必须连接到Vcc代替地面。这也掀的意思
//反销Grbl设置,一个倒置的设置现在意味着用户应该连接
//常开开关,反之亦然。
//注意:所有针与功能被禁用,例如XYZ限制针,而不是单独的轴。
//警告:引体向上被禁用时,这需要额外的布线与下拉电阻!
//#define DISABLE_LIMIT_PIN_PULL_UP //以下选项禁用内部上拉电阻
//#define DISABLE_PROBE_PIN_PULL_UP
//#define DISABLE_CONTROL_PIN_PULL_UP
// Sets which axis the tool length offset is applied. Assumes the spindle is always parallel with
// the selected axis with the tool oriented toward the negative direction. In other words, a positive
// tool length offset value is subtracted from the current location.
//设置哪个轴长度补偿应用的工具。假设轴总是与
//选择轴工具面向负方向。换句话说,一个积极的
//工具长度偏移值减去从当前位置。
#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS // Default z-axis. Valid values are X_AXIS, Y_AXIS, or Z_AXIS.设置哪个轴长度补偿应用的工具
// Enables variable spindle output voltage for different RPM values. On the Arduino Uno, the spindle
// enable pin will output 5V for maximum RPM with 256 intermediate levels and 0V when disabled.
// NOTE: IMPORTANT for Arduino Unos! When enabled, the Z-limit pin D11 and spindle enable pin D12 switch!
// The hardware PWM output on pin D11 is required for variable spindle output voltages.
//允许变量轴输出电压不同的转速值。Arduino Uno,主轴
//启用销将输出5 v的最高转速256中级水平和0 v时禁用。
//注意:重要Arduino凯泽本人!当启用时,Z-limit销这里和轴销D12开关!
//硬件PWM输出销这里需要变量轴输出电压。
#define VARIABLE_SPINDLE // Default enabled. Comment to disable.//允许主轴输出电压不同的转速值
// Used by the variable spindle output only. These parameters set the maximum and minimum spindle speed
// "S" g-code values to correspond to the maximum and minimum pin voltages. There are 256 discrete and
// equally divided voltage bins between the maximum and minimum spindle speeds. So for a 5V pin, 1000
// max rpm, and 250 min rpm, the spindle output voltage would be set for the following "S" commands:
// "S1000" @ 5V, "S250" @ 0.02V, and "S625" @ 2.5V (mid-range). The pin outputs 0V when disabled.
//使用的变量轴输出。这些参数设置最大和最小轴转速
//“S”刀位点值对应于销电压的最大值和最小值。有256个离散和
//电压平均分配箱主轴速度的最大值和最小值之间。所以对于一个5 v销,1000
// max rpm,250分钟rpm,主轴输出电压将为以下“S”命令:
// @“S1000 5 v,“S250”@ 0.02 v,“S625”@ 2.5 v(中档)。销输出0 v时禁用。
#define SPINDLE_MAX_RPM 1000.0 // Max spindle RPM. This value is equal to 100% duty cycle on the PWM.
#define SPINDLE_MIN_RPM 0.0 // Min spindle RPM. This value is equal to (1/256) duty cycle on the PWM.
// Used by variable spindle output only. This forces the PWM output to a minimum duty cycle when enabled.
// When disabled, the PWM pin will still read 0V. Most users will not need this option, but it may be
// useful in certain scenarios. This setting does not update the minimum spindle RPM calculations. Any
// spindle RPM output lower than this value will be set to this value.
//使用的变量轴输出。这迫使PWM输出最小占空比时启用。
//当禁用,PWM销仍读0 v。大多数用户不需要这个选项,但是它可能是
//在某些情况下很有用。这个设置不会更新最小主轴转速计算。任何
//输出轴转速低于这个值将被设置为这个值。
// #define MINIMUM_SPINDLE_PWM 5 // Default disabled. Uncomment to enable. Integer (0-255)
// By default on a 328p(Uno), Grbl combines the variable spindle PWM and the enable into one pin to help
// preserve I/O pins. For certain setups, these may need to be separate pins. This configure option uses
// the spindle direction pin(D13) as a separate spindle enable pin along with spindle speed PWM on pin D11.
// NOTE: This configure option only works with VARIABLE_SPINDLE enabled and a 328p processor (Uno).
// NOTE: With no direction pin, the spindle clockwise M4 g-code command will be removed. M3 and M5 still work.
// NOTE: BEWARE! The Arduino bootloader toggles the D13 pin when it powers up. If you flash Grbl with
// a programmer (you can use a spare Arduino as "Arduino as ISP". Search the web on how to wire this.),
// this D13 LED toggling should go away. We haven't tested this though. Please report how it goes!
//默认ATmega328 p(Uno),Grbl结合变量轴PWM和使到一个销的帮助
//保存I / O管脚。对于某些设置,这些可能需要单独的别针。这个配置选项使用
//方向轴销(D13)作为一个单独的轴销上启用销以及主轴转速PWM这里。
//注意:该配置选项仅适用于VARIABLE_SPINDLE启用和328 p处理器(Uno)。
//注意:没有方向销,主轴顺时针M4刀位点命令将被删除。M3和M5仍然工作。
//注意:小心!Arduino引导装载程序切换D13销的权力。如果flash Grbl
//程序员(您可以使用一个备用Arduino“Arduino ISP”。搜索网络如何线),
//这D13导致切换应该消失。我们还没有测试这个。请报告将会怎样!
// #define USE_SPINDLE_DIR_AS_ENABLE_PIN // Default disabled. Uncomment to enable.
// With this enabled, Grbl sends back an echo of the line it has received, which has been pre-parsed (spaces
// removed, capitalized letters, no comments) and is to be immediately executed by Grbl. Echoes will not be
// sent upon a line buffer overflow, but should for all normal lines sent to Grbl. For example, if a user
// sendss the line 'g1 x1.032 y2.45 (test comment)', Grbl will echo back in the form ''.
// NOTE: Only use this for debugging purposes!! When echoing, this takes up valuable resources and can effect
// performance. If absolutely needed for normal operation, the serial write buffer should be greatly increased
// to help minimize transmission waiting within the serial write protocol.
//启用,Grbl发回的回声线已收到,已预编译(空间
//移除,大写字母,没有评论),由Grbl立即执行。回声将不会
//发送一个线缓冲区溢位,但应该对所有正常线路送到Grbl。例如,如果一个用户
//发送线的g1 x1.032 y2.45(测试评论)形式”,Grbl将回声”(回声:G1X1.032Y2.45]”。
//注意:只使用这个调试! !当呼应,这占用了宝贵的资源,可以影响
//性能。如果正常运行所需的绝对,串行写入缓冲器应该大大增加
//帮助最小化传输等系列内写协议。
// #define REPORT_ECHO_LINE_RECEIVED // Default disabled. Uncomment to enable.
// Minimum planner junction speed. Sets the default minimum junction speed the planner plans to at
// every buffer block junction, except for starting from rest and end of the buffer, which are always
// zero. This value controls how fast the machine moves through junctions with no regard for acceleration
// limits or angle between neighboring block line move directions. This is useful for machines that can't
// tolerate the tool dwelling for a split second, i.e. 3d printers or laser cutters. If used, this value
// should not be much greater than zero or to the minimum value necessary for the machine to work.
//最小规划师结速度。设置默认最小连接速度规划计划
//每一个缓冲块接头,除了从结束休息和缓冲区,它总是
// 0。这个值控制机器的速度穿过路口,没有考虑加速度
//限制或相邻块之间的角线方向移动。这是有用的机器,不能
//容忍工具居住某一刹那,即3 d打印机或激光切割机。如果使用这个值
//不应大于零或机器工作所需的最小值。
#define MINIMUM_JUNCTION_SPEED 0.0 // (mm/min)
// Sets the minimum feed rate the planner will allow. Any value below it will be set to this minimum
// value. This also ensures that a planned motion always completes and accounts for any floating-point
// round-off errors. Although not recommended, a lower value than 1.0 mm/min will likely work in smaller
// machines, perhaps to 0.1mm/min, but your success may vary based on multiple factors.
//设置计划将允许的最小进给速率。任何价值低于它将被设置为最低值。这也保证了运动计划总是完成,占任何浮点
//舍入错误。虽然不推荐,价值低于1.0毫米/分钟可能会在较小的工作
//机器,也许到0.1毫米/分钟,但你的成功基于多种因素可能会有所不同。
#define MINIMUM_FEED_RATE 1.0 // (mm/min)//设置计划将允许的最小进给速率
// Number of arc generation iterations by small angle approximation before exact arc trajectory
// correction with expensive sin() and cos() calcualtions. This parameter maybe decreased if there
// are issues with the accuracy of the arc generations, or increased if arc execution is getting
// bogged down by too many trig calculations.
//弧生成迭代次数之前小角度近似精确的弧线轨迹
//修正与昂贵的sin()和cos()calcualtions。如果有这个参数可能减少
//与弧一代又一代的准确性问题,或如果电弧执行得到增加
//太多的三角计算的泥潭。
#define N_ARC_CORRECTION 12 // Integer (1-255)
// The arc G2/3 g-code standard is problematic by definition. Radius-based arcs have horrible numerical
// errors when arc at semi-circles(pi) or full-circles(2*pi). Offset-based arcs are much more accurate
// but still have a problem when arcs are full-circles (2*pi). This define accounts for the floating
// point issues when offset-based arcs are commanded as full circles, but get interpreted as extremely
// small arcs with around machine epsilon (1.2e-7rad) due to numerical round-off and precision issues.
// This define value sets the machine epsilon cutoff to determine if the arc is a full-circle or not.
// NOTE: Be very careful when adjusting this value. It should always be greater than 1.2e-7 but not too
// much greater than this. The default setting should capture most, if not all, full arc error situations.
//弧G2/3刀位点的标准定义是有问题的。Radius-based弧有可怕的数值
//错误当电弧在半圆(π)或原点(2 *π)。Offset-based弧更准确
//但仍有一个问题当弧原点(2 *π)。这个定义占浮动
//当offset-based弧吩咐点问题完整的圆,但解释为极
//小弧机周围ε(1.2 e-7rad)由于数字舍入和精度问题。
//定义值设置机器ε截止来确定电弧是一个原点了。
//注意:调整这个值时非常小心。它应该总是大于1.2 e -但不要太
//比这大得多。默认设置应该捕获大部分,如果不是全部,全部错误的情况。
#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7 // Float (radians)
// Time delay increments performed during a dwell. The default value is set at 50ms, which provides
// a maximum time delay of roughly 55 minutes, more than enough for most any application. Increasing
// this delay will increase the maximum dwell time linearly, but also reduces the responsiveness of
// run-time command executions, like status reports, since these are performed between each dwell
// time step. Also, keep in mind that the Arduino delay timer is not very accurate for long delays.
//延时增加表现在住。默认值设置为50毫秒,它提供了
//最大延时约55分钟,足够对大多数任何应用程序。增加
//这种延迟将增加线性最大停留时间,也减少了响应能力
//运行命令执行状态报告一样,因为这些每个住之间执行
//时间步。还有,记住,Arduino延迟计时器不是很准确的长时间延误。
#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds)
// Creates a delay between the direction pin setting and corresponding step pulse by creating
// another interrupt (Timer2 compare) to manage it. The main Grbl interrupt (Timer1 compare)
// sets the direction pins, and does not immediately set the stepper pins, as it would in
// normal operation. The Timer2 compare fires next to set the stepper pins after the step
// pulse delay time, and Timer2 overflow will complete the step pulse, except now delayed
// by the step pulse time plus the step pulse delay. (Thanks langwadt for the idea!)
// NOTE: Uncomment to enable. The recommended delay must be > 3us, and, when added with the
// user-supplied step pulse time, the total time must not exceed 127us. Reported successful
// values for certain setups have ranged from 5 to 20us.
//创建一个方向销之间的延迟脉冲通过创建设置和相应的步骤
//另一个中断(Timer2比较)来管理它。主要Grbl中断(Timer1比较)
//设置方向针,不立即设置步进针,因为它会在
//正常操作。Timer2比较火旁边设置步进针后一步
//脉冲延迟时间,Timer2溢出脉冲将完成的步骤,现在延迟除外
//脉冲时间加上的一步一步脉冲延迟。(感谢langwadt主意!)
//注意:取消启用。必须> 3,建议延迟,当添加的
//用户提供的步骤脉冲时间,总时间不得超过127美元。成功的报道
//值对某些设置范围从5到20。
// #define STEP_PULSE_DELAY 10 // Step pulse delay in microseconds. Default disabled.
// The number of linear motions in the planner buffer to be planned at any give time. The vast
// majority of RAM that Grbl uses is based on this buffer size. Only increase if there is extra
// available RAM, like when re-compiling for a Mega or Sanguino. Or decrease if the Arduino
// begins to crash due to the lack of available RAM or if the CPU is having trouble keeping
// up with planning new incoming motions as they are executed.
//线性运动规划师缓冲区的数量在任何给出时间计划。绝大
//多数RAM Grbl使用基于这个缓冲区的大小。如果有额外的只会增加
//可用内存,比如当基于大型或Sanguino。如果Arduino或减少
//开始崩溃由于缺乏可用的RAM或者CPU是难以保持
//与规划新传入的动作执行。
// #define BLOCK_BUFFER_SIZE 18// Uncomment to override default in planner.h.
// Governs the size of the intermediary step segment buffer between the step execution algorithm
// and the planner blocks. Each segment is set of steps executed at a constant velocity over a
// fixed time defined by ACCELERATION_TICKS_PER_SECOND. They are computed such that the planner
// block velocity profile is traced exactly. The size of this buffer governs how much step
// execution lead time there is for other Grbl processes have to compute and do their thing
// before having to come back and refill this buffer, currently at ~50msec of step moves.
//控制之间的中间段缓冲大小的步骤执行算法
//和规划师块。每一部分的步骤执行在一个恒定的速度
//固定的时间由ACCELERATION_TICKS_PER_SECOND定义的。他们计算的计划
//块速度剖面追踪到底。这个缓冲区的大小控制多少步骤
//执行时间有其他Grbl过程需要计算和做他们的事情
//之前必须回来重新填充这个缓冲区,目前移动~ 50毫秒的一步。
// #define SEGMENT_BUFFER_SIZE 6 // Uncomment to override default in stepper.h.
// Line buffer size from the serial input stream to be executed. Also, governs the size of
// each of the startup blocks, as they are each stored as a string of this size. Make sure
// to account for the available EEPROM at the defined memory address in settings.h and for
// the number of desired startup blocks.
// NOTE: 80 characters is not a problem except for extreme cases, but the line buffer size
// can be too small and g-code blocks can get truncated. Officially, the g-code standards
// support up to 256 characters. In future versions, this default will be increased, when
// we know how much extra memory space we can re-invest into this.
//行执行串行输入流的缓冲区大小。同时,大小的控制
//每个启动模块,它们分别存储为字符串的大小。确保
//占可用eepm定义内存地址的设置。h和
//需要启动块的数量。
//注意:80个字符不是一个问题,除了极端的情况下,但线缓冲区大小
//可以太小和刀位点块可以截断。正式,刀位点标准
//支持多达256个字符。在未来的版本中,这个违约将会增加,当
//我们知道多少额外内存空间的时候我们可以再投资。
// #define LINE_BUFFER_SIZE 80// Uncomment to override default in protocol.h
// Serial send and receive buffer size. The receive buffer is often used as another streaming
// buffer to store incoming blocks to be processed by Grbl when its ready. Most streaming
// interfaces will character count and track each block send to each block response. So,
// increase the receive buffer if a deeper receive buffer is needed for streaming and avaiable
// memory allows. The send buffer primarily handles messages in Grbl. Only increase if large
// messages are sent and Grbl begins to stall, waiting to send the rest of the message.
// NOTE: Buffer size values must be greater than zero and less than 256.
// #define RX_BUFFER_SIZE 128 // Uncomment to override defaults in serial.h
//串行发送和接收缓冲区大小。接收缓冲区通常用作另一个流
//缓冲存储传入的块来处理Grbl当它准备好了。最流
//接口将字符计数和跟踪每一块发送给每个块的回应。所以,
//增加接收缓冲区如果需要更深层次的接收缓冲区为流,、
//内存允许。Grbl发送缓冲主要处理消息。只会增加如果大
//消息发送和Grbl开始停滞,等待发送其余的消息。
//注意:缓冲区大小值必须大于零,小于256。
// # define RX_BUFFER_SIZE 128 / /取消serial.h覆盖默认值
// #define TX_BUFFER_SIZE 64
// Toggles XON/XOFF software flow control for serial communications. Not officially supported
// due to problems involving the Atmega8U2 USB-to-serial chips on current Arduinos. The firmware
// on these chips do not support XON/XOFF flow control characters and the intermediate buffer
// in the chips cause latency and overflow problems with standard terminal programs. However,
// using specifically-programmed UI's to manage this latency problem has been confirmed to work.
// As well as, older FTDI FT232RL-based Arduinos(Duemilanove) are known to work with standard
// terminal programs since their firmware correctly manage these XON/XOFF characters. In any
// case, please report any successes to grbl administrators!
//切换为串行通信发送朴通/发送葡开软件流控制。不是官方支持
//由于问题涉及Atmega8U2 USB-to-serial当前arduino芯片。固件
//在这些芯片不支持发送朴通/发送葡开流控制字符和中间缓冲区
//芯片导致延迟和溢出问题的标准终端程序。然而,
//使用specifically-programmed UI的管理这个延迟问题已经确认工作。
//以及老FTDI FT232RL-based arduino(Duemilanove)是已知的标准
//终端程序因为他们正确的固件管理这些发送朴通/发送葡开的角色。在任何
//情况,请报告任何成功grbl管理员!
// #define ENABLE_XONXOFF // Default disabled. Uncomment to enable.
// A simple software debouncing feature for hard limit switches. When enabled, the interrupt
// monitoring the hard limit switch pins will enable the Arduino's watchdog timer to re-check
// the limit pin state after a delay of about 32msec. This can help with CNC machines with
// problematic false triggering of their hard limit switches, but it WILL NOT fix issues with
// electrical interference on the signal cables from external sources. It's recommended to first
// use shielded signal cables with their shielding connected to ground (old USB/computer cables
// work well and are cheap to find) and wire in a low-pass circuit into each limit pin.
//一个简单的软件消除抖动特性硬限位开关。当启用时,中断
//监控硬限位开关针将使Arduino的看门狗定时器重新审视
//销的极限状态后约32毫秒的延迟。这可以帮助与数控机器
//问题错误引发的硬限位开关,但是它不会解决问题
//电干扰信号电缆从外部来源。首先它的建议
//使用屏蔽信号电缆的屏蔽连接到地面(老USB /计算机电缆
//工作得很好,很便宜)和线低通电路到每个限位销。
// #define ENABLE_SOFTWARE_DEBOUNCE // Default disabled. Uncomment to enable.
// Force Grbl to check the state of the hard limit switches when the processor detects a pin
// change inside the hard limit ISR routine. By default, Grbl will trigger the hard limits
// alarm upon any pin change, since bouncing switches can cause a state check like this to
// misread the pin. When hard limits are triggered, they should be 100% reliable, which is the
// reason that this option is disabled by default. Only if your system/electronics can guarantee
// that the switches don't bounce, we recommend enabling this option. This will help prevent
// triggering a hard limit when the machine disengages from the switch.
// NOTE: This option has no effect if SOFTWARE_DEBOUNCE is enabled.
//力Grbl检查硬限位开关的状态,当处理器检测到一个销
//改变内部硬限制ISR例行公事。默认情况下,Grbl将触发硬限制
//报警在任何销更改,因为跳开关可以导致这样的状态检查
//误读了销。硬限制触发时,他们应该100%可靠,这是
//原因,这个选项默认是禁用的。只有在你的系统/电子产品可以保证
//开关不反弹,我们建议启用这个选项。这将有助于防止
//触发机退出时硬限制开关。
//注意:这个选项如果启用了SOFTWARE_DEBOUNCE没有影响。
// #define HARD_LIMIT_FORCE_STATE_CHECK // Default disabled. Uncomment to enable.
// ---------------------------------------------------------------------------------------
// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:编译时错误检查的定义值:
#ifndef HOMING_CYCLE_0
#error "Required HOMING_CYCLE_0 not defined."
#endif
#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(VARIABLE_SPINDLE)
#error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with VARIABLE_SPINDLE enabled"
#endif
#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(CPU_MAP_ATMEGA328P)
#error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with a 328p processor"
#endif
// ---------------------------------------------------------------------------------------
#endif
那些没有用的照片不知道怎么就上去了好讨厌。 //www.szfco.com/data/attachment/album/201608/20/235410rbrm9p0lvbm1ccbg.png
楼主厉害! 谢谢楼主,先收藏一下,慢慢学习 这是什么宝贝? 换了个浏览器Chrome,试试能否发言了。 楼主厉害 补充
程序运行protocol_execute_realtime(); /运行实时命令。
// Executes run-time commands, when required. This is called from various check points in the main
// program, primarily where there may be a while loop waiting for a buffer to clear space or any
// point where the execution time from the last check point may be more than a fraction of a second.
// This is a way to execute realtime commands asynchronously (aka multitasking) with grbl's g-code
// parsing and planning functions. This function also serves as an interface for the interrupts to
// set the system realtime flags, where only the main program handles them, removing the need to
// define more computationally-expensive volatile variables. This also provides a controlled way to
// execute certain tasks without having two or more instances of the same task, such as the planner
// recalculating the buffer upon a feedhold or override.
// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,
// limit switches, or the main program.
//执行运行时间命令,在需要时。这就是所谓的从各种主程序要检查站
//,主要是那里可能是一个while循环等待缓冲区空间或任何
//执行时间从过去的止点可以超过几分之一秒。
//这是一种异步执行实时命令(又名多任务)grbl的刀位点
//解析和规划功能。这个函数也可以作为一个接口,用于中断
//设置系统实时的旗帜,只有主程序处理,消除的需要
//定义更多的计算昂贵volatile变量。这也提供了一种控制方法
//执行某些任务不相同的两个或多个实例的任务,比如计划
//重新计算缓冲feedhold或覆盖。
//注意:sys_rt_exec_state变量标志设置任何过程,步骤或串行中断,插脚引线,
//限位开关或主程序。
void protocol_execute_realtime()
{
// Temp variable to avoid calling volatile multiple times.
// 临时变量来避免多次调用不稳定。
uint8_t rt_exec;
do{
if (rt_exec) { // 有标志位置位进入
sys.state = STATE_ALARM; // 设置系统为报警状态
report_alarm_message(ALARM_HARD_LIMIT_ERROR); //报告报警信息为接近极限值
} else if (rt_exec & EXEC_ALARM_SOFT_LIMIT) { //报告执行软件限位报警
report_alarm_message(ALARM_SOFT_LIMIT_ERROR); //报告出现软件限位报警
} else if (rt_exec & EXEC_ALARM_ABORT_CYCLE) { //执行停止循环报警
report_alarm_message(ALARM_ABORT_CYCLE); //出现终止循环报警
} else if (rt_exec & EXEC_ALARM_PROBE_FAIL) { //执行探查失败报警
report_alarm_message(ALARM_PROBE_FAIL); //出现探查失败报警
} else if (rt_exec & EXEC_ALARM_HOMING_FAIL) { //执行返回原点失败报警
report_alarm_message(ALARM_HOMING_FAIL); //出现返回原点失败报警
}
// Halt everything upon a critical event flag. Currently hard and soft limits flag this.
// 停止一切在一个关键事件标志。目前硬和软限制标志
if (rt_exec & EXEC_CRITICAL_EVENT) { //如果系统是循环事件进入
report_feedback_message(MESSAGE_CRITICAL_EVENT); //报告反馈信息
bit_false_atomic(sys_rt_exec_state,EXEC_RESET); //清除目前的复位状态
bit_false_atomic(sys_rt_exec_alarm,0xFF); // 清除所有报警标志
}
上面代码将rt_exec = sys_rt_exec_alarm ,如果rt_exec为真,打印不同报警信息
和限位保护信息,然后清除报警状态
___________________________________________________________________________
没有报警进行执行下面代码,执行了终止命令,串口打印命令
// Check amd execute realtime commands 校验和执行实时命令
rt_exec = sys_rt_exec_state; // Copy volatile sys_rt_exec_state
if (rt_exec) { // 输入标志是正确的执行
// Execute system abort. 执行系统终止命令
if (rt_exec & EXEC_RESET) {
sys.abort = true;// Only place this is set true.
return; // Nothing else to do but exit.
}
// Execute and serial print status 执行和串口打印状态
if (rt_exec & EXEC_STATUS_REPORT) {
report_realtime_status(); //报告实时状态
bit_false_atomic(sys_rt_exec_state,EXEC_STATUS_REPORT); //清除报告状态清零
}
_____________________________________________________________________________
下面代码
//执行状态。
//注意:所涉及的数学计算持有应该足够低对大多数人来说,即使不是全部,
//操作场景。一旦启动,系统进入暂停状态
//主程序流程,直到重置或恢复。
待办事项:检查模式?如何处理呢?可能没有,因为它只会在空闲,然后重置Grbl。
状态检查容许状态的方法。
//如果全局各自报警标志位其中(执行取消动作) | (执行进给保持) | (执行安全门)任意一位为真进入
if (rt_exec & (EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR)) {
//如果是循环状态执行暂停状态
if (sys.state == STATE_CYCLE) {
st_update_plan_block_parameters(); //通知stepper module验算减速。
sys.suspend = SUSPEND_ENABLE_HOLD; // 开始暂停标志
}
// 如果,Grbl空闲不在运动。简单的指示暂停就绪状态。
if (sys.state == STATE_IDLE) { sys.suspend = SUSPEND_ENABLE_READY; }
//执行和标志和减速运动取消并返回空闲。主要由探测使用周期
//停止和取消剩余的运动。
if (rt_exec & EXEC_MOTION_CANCEL) {
if (sys.state == STATE_CYCLE) { sys.state = STATE_MOTION_CANCEL; }
sys.suspend |= SUSPEND_MOTION_CANCEL;
}
// 只在循环时执行进给保持减速
if (rt_exec & EXEC_FEED_HOLD) {
//只有安全门为1才执行保持进给状态赋值
if (bit_isfalse(sys.state,STATE_SAFETY_DOOR)) { sys.state = STATE_HOLD; }
}
if (rt_exec & EXEC_SAFETY_DOOR) {
report_feedback_message(MESSAGE_SAFETY_DOOR_AJAR);
/ /如果已经活跃,准备好重新开始,CYCLE_STOP标志设置为强制断开。
/ /注意:只是暂时设置“rt_exec”变量,不是动荡的“rt_exec_state”变量。
if (sys.suspend & SUSPEND_ENABLE_READY) { bit_true(rt_exec,EXEC_CYCLE_STOP); }
sys.suspend |= SUSPEND_ENERGIZE;
sys.state = STATE_SAFETY_DOOR;
}
bit_false_atomic(sys_rt_exec_state,(EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR));
}
以上代码执行了
1.如果全局各自报警标志位其中(执行取消动作) | (执行进给保持) | (执行安全门)任意一位为真进入
2.系统为闲着状态, 开始循环状态, 回原点状态, 控制取消状态, 开始保持状态, 开始安全门状态时进入
3.如果是循环状态执行暂停状态
4.如果系统闲置状态执行暂停就绪状态
5.执行动作取消
6.如果是保持进给状态,执行保持进给状态
7.执行安全门状态
最后执行bit_false_atomic清标志清除(执行取消动作)(执行进给保持)(执行安全门)标志位
_____________________________________________________________________________
// Execute a cycle start by starting the stepper interrupt to begin executing the blocks in queue.
// 执行一个循环开始启动步进开始执行中断队列的街区
if (rt_exec & EXEC_CYCLE_START) { //循环开始状态进入
// Block if called at same time as the hold commands: feed hold, motion cancel, and safety door.
// Ensures auto-cycle-start doesn't resume a hold without an explicit user-input.
//块如果在同时举行的命令:保持进给,运动取消,和安全的门。 //确保auto-cycle-start没有简历没有显式的用户输入。
if (!(rt_exec & (EXEC_FEED_HOLD | EXEC_MOTION_CANCEL | EXEC_SAFETY_DOOR))) { //状态机如果不是保持进给,运动取消,和安全的门。
// Cycle start only when IDLE or when a hold is complete and ready to resume.
// NOTE: SAFETY_DOOR is implicitly blocked. It reverts to HOLD when the door is closed.
//循环开始时只有当闲置或持有完成并准备简历。
//注意:SAFETY_DOOR是隐式地屏蔽。它返回的时候门是关闭的。
// 如果系统状态为闲着状态,系统状态为开始进给或运动取消,暂停标志为位重新开始
if ((sys.state == STATE_IDLE) || ((sys.state & (STATE_HOLD | STATE_MOTION_CANCEL)) && (sys.suspend & SUSPEND_ENABLE_READY))) {
// Re-energize powered components, if disabled by SAFETY_DOOR.
// 由SAFETY_DOOR重振组件供电,如果禁用。
if (sys.suspend & SUSPEND_ENERGIZE) {
// Delayed Tasks: Restart spindle and coolant, delay to power-up, then resume cycle.
//延迟任务:重新启动主轴和冷却剂,延迟升高,然后恢复周期。
if (gc_state.modal.spindle != SPINDLE_DISABLE) { //主轴模式不是失能进入
spindle_set_state(gc_state.modal.spindle, gc_state.spindle_speed); //设置状态和速度
//待办事项:阻塞函数调用。最终需要一个非阻塞。
delay_ms(SAFETY_DOOR_SPINDLE_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.
}
if (gc_state.modal.coolant != COOLANT_DISABLE) {
coolant_set_state(gc_state.modal.coolant);
delay_ms(SAFETY_DOOR_COOLANT_DELAY); // TODO: Blocking function call. Need a non-blocking one eventually.
}
// TODO: Install return to pre-park position.
}
______________________________________________________________________________________________________________
// Start cycle only if queued motions exist in planner buffer and the motion is not canceled.
//只有在队列马达存在规定的缓冲,并且动机没有让取消,才会循环
if (plan_get_current_block() && bit_isfalse(sys.suspend,SUSPEND_MOTION_CANCEL)) {
sys.state = STATE_CYCLE;
st_prep_buffer(); // Initialize step segment buffer before beginning cycle.初始化步开始循环之前
st_wake_up();
} else { // Otherwise, do nothing. Set and resume IDLE state.否则,什么也不做,设置和复位空闲模式
sys.state = STATE_IDLE;
}
sys.suspend = SUSPEND_DISABLE; // Break suspend state.
}
}
bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_START);
}
_______________________________________________________________________________________________________
// Reinitializes the cycle plan and stepper system after a feed hold for a resume. Called by
// realtime command execution in the main program, ensuring that the planner re-plans safely.
// NOTE: Bresenham algorithm variables are still maintained through both the planner and stepper
// cycle reinitializations. The stepper path should continue exactly as if nothing has happened.
// NOTE: EXEC_CYCLE_STOP is set by the stepper subsystem when a cycle or feed hold completes.
//重新启动后循环计划和步进系统的进给保持简历。通过实时命令执行主程序,确保安全计划重新计划。
//注意:画线算法变量仍保持通过规划师和步进
//循环仅。步进路径应该继续,好像什么都没发生一样。
//注意:EXEC_CYCLE_STOP由步进子系统周期或进给保持时完成。
if (rt_exec & EXEC_CYCLE_STOP) { //如果是循环停止状态进入
if (sys.state & (STATE_HOLD | STATE_SAFETY_DOOR)) {
// Hold complete. Set to indicate ready to resume.Remain in HOLD or DOOR states until user
// has issued a resume command or reset.
//保存完整。设置为指示准备简历。继续持有或门状态,直到用户
//已发布了一份简历命令或重置。
if (sys.suspend & SUSPEND_ENERGIZE) { // De-energize system if safety door has been opened. 如果安全的门已被打开。断开系统
spindle_stop();
coolant_stop();
// TODO: Install parking motion here. 安装停车动作。
}
bit_true(sys.suspend,SUSPEND_ENABLE_READY);
} else { // Motion is complete. Includes CYCLE, HOMING, and MOTION_CANCEL states. 电机完成,循环,回原点,,MOTION_CANCEL
sys.suspend = SUSPEND_DISABLE;
sys.state = STATE_IDLE;
}
bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_STOP);
}
}
___________________________________________________________________________________________________
// Overrides flag byte (sys.override) and execution should be installed here, since they
// are realtime and require a direct and controlled interface to the main stepper program.
//重写标志字节(sys.override)和执行应该安装在这里,因为他们
//实时和需要直接和控制接口的主要步进程序。
// Reload step segment buffer 重新加载步段缓冲
if (sys.state & (STATE_CYCLE | STATE_HOLD | STATE_MOTION_CANCEL | STATE_SAFETY_DOOR | STATE_HOMING)) { st_prep_buffer(); }
// If safety door was opened, actively check when safety door is closed and ready to resume.
// NOTE: This unlocks the SAFETY_DOOR state to a HOLD state, such that CYCLE_START can activate a resume.
//如果安全的门被打开,积极检查当安全门关闭,准备简历。
//注意:这解锁SAFETY_DOOR状态保持状态,这样CYCLE_START可以激活一个简历。
if (sys.state == STATE_SAFETY_DOOR) { //安全门状态进入
if (bit_istrue(sys.suspend,SUSPEND_ENABLE_READY)) {
if (!(system_check_safety_door_ajar())) {
sys.state = STATE_HOLD; // Update to HOLD state to indicate door is closed and ready to resume. 更新保存状态指示门关闭,准备简历。
}
}
}
} while(sys.suspend); // Check for system suspend state before exiting.
} 楼主这些代码。是网上搜来,然后自己组合的吗?全是自己想的,那是牛逼了
页:
[1]
2